mirror of
https://github.com/darlinghq/darling-cocotron.git
synced 2024-11-27 14:00:22 +00:00
more AntiGrain work
This commit is contained in:
parent
192b27647c
commit
0d70882b6a
@ -7,19 +7,26 @@
|
||||
#include <agg_pixfmt_rgba.h>
|
||||
#include <agg_path_storage.h>
|
||||
#include <agg_renderer_base.h>
|
||||
#include <agg_renderer_mclip.h>
|
||||
#include <agg_scanline_u.h>
|
||||
#include <agg_rasterizer_scanline_aa.h>
|
||||
#include <agg_renderer_scanline.h>
|
||||
#include <agg_conv_curve.h>
|
||||
#include <agg_conv_stroke.h>
|
||||
|
||||
typedef agg::blender_rgba_pre<agg::rgba8, agg::order_bgra> blender_type_pre;
|
||||
typedef agg::pixfmt_alpha_blend_rgba<blender_type_pre, agg::rendering_buffer, agg::int32u> pixfmt_pre;
|
||||
|
||||
typedef agg::comp_op_adaptor_rgba<agg::rgba8, agg::order_bgra> blender_type;
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_type;
|
||||
|
||||
typedef agg::renderer_base<agg::pixfmt_bgra32> renderer_base;
|
||||
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_aa;
|
||||
typedef agg::renderer_scanline_bin_solid<renderer_base> renderer_aliased;
|
||||
|
||||
struct O2AGGContext {
|
||||
agg::rendering_buffer *renderingBuffer;
|
||||
agg::pixfmt_bgra32 pixelFormat;
|
||||
agg::rasterizer_scanline_aa<> *rasterizer;
|
||||
renderer_base *ren_base;
|
||||
agg::path_storage path;
|
||||
};
|
||||
|
||||
@ -35,6 +42,8 @@ O2AGGContextRef O2AGGContextCreateBGRA32(unsigned char *pixelBytes,size_t width,
|
||||
self->renderingBuffer=new agg::rendering_buffer(pixelBytes,width,height,bytesPerRow);
|
||||
self->pixelFormat.attach(*(self->renderingBuffer));
|
||||
self->rasterizer=new agg::rasterizer_scanline_aa<>();
|
||||
self->ren_base=new renderer_base(self->pixelFormat);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -60,40 +69,56 @@ void O2AGGContextAddQuadCurveToPoint(O2AGGContextRef self,double cp1x,double cp1
|
||||
}
|
||||
|
||||
void O2AGGContextCloseSubpath(O2AGGContextRef self) {
|
||||
self->path.close_polygon();
|
||||
self->path.end_poly();
|
||||
}
|
||||
|
||||
void O2AGGContextClipReset(O2AGGContextRef self) {
|
||||
// self->renderer.reset_clipping(1);
|
||||
}
|
||||
|
||||
void O2AGGContextSetDeviceViewport(O2AGGContextRef self,int x,int y,int w,int h) {
|
||||
self->ren_base->reset_clipping(1);
|
||||
self->ren_base->clip_box(x,y,x+w,y+h);
|
||||
}
|
||||
|
||||
void O2AGGContextClipToPath(O2AGGContextRef self,int evenOdd) {
|
||||
}
|
||||
|
||||
void O2AGGContextFillPath(O2AGGContextRef self,float r,float g,float b,float a,double xa,double xb,double xc,double xd,double xtx,double xty) {
|
||||
renderer_base ren_base(self->pixelFormat);
|
||||
renderer_aa ren_aa(ren_base);
|
||||
void O2AGGContextFillPathWithRule(O2AGGContextRef self,float r,float g,float b,float a,double xa,double xb,double xc,double xd,double xtx,double xty,agg::filling_rule_e fillingRule) {
|
||||
agg::scanline_u8 sl;
|
||||
|
||||
ren_aa.color(agg::rgba(r,g,b,a));
|
||||
printf("%s %d %f %f %f %f %f %f\n",__FILE__,__LINE__,xa,xb,xc,xd,xtx,xty);
|
||||
agg::trans_affine mtx(xa,xb,xc,xd,xtx,xty);
|
||||
printf("%s %d\n",__FILE__,__LINE__);
|
||||
agg::conv_transform<agg::path_storage, agg::trans_affine> trans(self->path, mtx);
|
||||
printf("%s %d\n",__FILE__,__LINE__);
|
||||
|
||||
agg::conv_curve<agg::path_storage> curve(self->path);
|
||||
agg::conv_transform<agg::conv_curve<agg::path_storage>, agg::trans_affine> trans(curve, mtx);
|
||||
|
||||
curve.approximation_scale(mtx.scale());
|
||||
|
||||
self->rasterizer->add_path(trans);
|
||||
printf("%s %d\n",__FILE__,__LINE__);
|
||||
self->rasterizer->filling_rule(agg::fill_non_zero);
|
||||
printf("%s %d\n",__FILE__,__LINE__);
|
||||
render_scanlines(*(self->rasterizer),sl,ren_aa);
|
||||
printf("%s %d\n",__FILE__,__LINE__);
|
||||
self->rasterizer->filling_rule(fillingRule);
|
||||
|
||||
#if 0
|
||||
agg::make_polygon(&pf,&curve,0);
|
||||
agg::render_polygon(&renderer,&pf);
|
||||
//self->pixelFormat.comp_op(2);
|
||||
|
||||
agg::render_scanlines_aa_solid(*(self->rasterizer),sl,*(self->ren_base),agg::rgba(r,g,b,a));
|
||||
}
|
||||
|
||||
void O2AGGContextFillPath(O2AGGContextRef self,float r,float g,float b,float a,double xa,double xb,double xc,double xd,double xtx,double xty) {
|
||||
O2AGGContextFillPathWithRule(self,r,g,b,a,xa,xb,xc,xd,xtx,xty,agg::fill_non_zero);
|
||||
}
|
||||
|
||||
void O2AGGContextEOFillPath(O2AGGContextRef self,float r,float g,float b,float a,double xa,double xb,double xc,double xd,double xtx,double xty) {
|
||||
O2AGGContextFillPathWithRule(self,r,g,b,a,xa,xb,xc,xd,xtx,xty,agg::fill_even_odd);
|
||||
}
|
||||
|
||||
void O2AGGContextStrokePath(O2AGGContextRef self,float r,float g,float b,float a,double xa,double xb,double xc,double xd,double xtx,double xty) {
|
||||
agg::scanline_u8 sl;
|
||||
|
||||
agg::trans_affine mtx(xa,xb,xc,xd,xtx,xty);
|
||||
agg::conv_stroke<agg::path_storage> stroke(self->path);
|
||||
// agg::conv_transform<agg::conv_stroke<agg::path_storage>, agg::trans_affine> trans(stroke, mtx);
|
||||
|
||||
self->rasterizer->add_path(stroke);
|
||||
self->rasterizer->filling_rule(agg::fill_non_zero);
|
||||
agg::render_scanlines_aa_solid(*(self->rasterizer),sl,*(self->ren_base),agg::rgba(r,g,b,a));
|
||||
|
||||
agg::render_scanlines_aa_solid(rasterizer,sl,renderer,agg::rgba8(0,0,0));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,12 @@ void O2AGGContextAddQuadCurveToPoint(O2AGGContextRef self,double cp1x,double cp1
|
||||
void O2AGGContextCloseSubpath(O2AGGContextRef self);
|
||||
|
||||
void O2AGGContextClipReset(O2AGGContextRef self);
|
||||
void O2AGGContextSetDeviceViewport(O2AGGContextRef self,int x,int y,int w,int h);
|
||||
void O2AGGContextClipToPath(O2AGGContextRef self,int evenOdd);
|
||||
|
||||
void O2AGGContextFillPath(O2AGGContextRef self,float r,float g,float b,float a,double xa,double xb,double xc,double xd,double xtx,double xty);
|
||||
void O2AGGContextEOFillPath(O2AGGContextRef self,float r,float g,float b,float a,double xa,double xb,double xc,double xd,double xtx,double xty);
|
||||
void O2AGGContextStrokePath(O2AGGContextRef self,float r,float g,float b,float a,double xa,double xb,double xc,double xd,double xtx,double xty);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ static void transferPath(O2AGGContextRef agg,O2PathRef path,O2AffineTransform xf
|
||||
unsigned i,numberOfElements=O2PathNumberOfElements(path),pointIndex;
|
||||
|
||||
pointIndex=0;
|
||||
|
||||
O2AGGContextBeginPath(agg);
|
||||
|
||||
for(i=0;i<numberOfElements;i++){
|
||||
|
||||
switch(elements[i]){
|
||||
@ -67,12 +70,14 @@ static void transferPath(O2AGGContextRef agg,O2PathRef path,O2AffineTransform xf
|
||||
|
||||
-(void)clipToState:(O2ClipState *)clipState {
|
||||
[super clipToState:clipState];
|
||||
|
||||
O2AGGContextSetDeviceViewport(_agg,_vpx,_vpy,_vpwidth,_vpheight);
|
||||
|
||||
O2GState *gState=O2ContextCurrentGState(self);
|
||||
NSArray *phases=[O2GStateClipState(gState) clipPhases];
|
||||
int i,count=[phases count];
|
||||
|
||||
// O2DeviceContextClipReset_gdi(_dc);
|
||||
// O2AGGContextClipReset(_agg);
|
||||
|
||||
for(i=0;i<count;i++){
|
||||
O2ClipPhase *phase=[phases objectAtIndex:i];
|
||||
@ -102,24 +107,61 @@ static void transferPath(O2AGGContextRef agg,O2PathRef path,O2AffineTransform xf
|
||||
-(void)drawPath:(O2PathDrawingMode)drawingMode {
|
||||
O2GState *gState=O2ContextCurrentGState(self);
|
||||
|
||||
if(drawingMode==kO2PathFill){
|
||||
O2ColorRef rgbColor=O2ColorConvertToDeviceRGB(gState->_fillColor);
|
||||
const float *components=O2ColorGetComponents(rgbColor);
|
||||
|
||||
transferPath(_agg,(O2PathRef)_path,O2AffineTransformInvert(gState->_userSpaceTransform));
|
||||
transferPath(_agg,(O2PathRef)_path,O2AffineTransformInvert(gState->_userSpaceTransform));
|
||||
|
||||
O2AffineTransform deviceTransform=gState->_deviceSpaceTransform;
|
||||
|
||||
O2AGGContextFillPath(_agg,components[0],components[1],components[2],components[3],
|
||||
O2ColorRef fillColor=O2ColorConvertToDeviceRGB(gState->_fillColor);
|
||||
const float *fill=O2ColorGetComponents(fillColor);
|
||||
O2ColorRef strokeColor=O2ColorConvertToDeviceRGB(gState->_strokeColor);
|
||||
const float *stroke=O2ColorGetComponents(strokeColor);
|
||||
|
||||
O2AffineTransform deviceTransform=gState->_deviceSpaceTransform;
|
||||
|
||||
BOOL doFill=NO;
|
||||
BOOL doEOFill=NO;
|
||||
BOOL doStroke=NO;
|
||||
|
||||
switch(drawingMode){
|
||||
|
||||
case kO2PathFill:
|
||||
doFill=YES;
|
||||
break;
|
||||
|
||||
case kO2PathEOFill:
|
||||
doEOFill=YES;
|
||||
break;
|
||||
|
||||
case kO2PathStroke:
|
||||
doStroke=YES;
|
||||
break;
|
||||
|
||||
case kO2PathFillStroke:
|
||||
doFill=YES;
|
||||
doStroke=YES;
|
||||
break;
|
||||
|
||||
case kO2PathEOFillStroke:
|
||||
doEOFill=YES;
|
||||
doStroke=YES;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if(doFill)
|
||||
O2AGGContextFillPath(_agg,fill[0],fill[1],fill[2],fill[3],
|
||||
deviceTransform.a,deviceTransform.b,deviceTransform.c,deviceTransform.d,deviceTransform.tx,deviceTransform.ty);
|
||||
|
||||
if(doEOFill)
|
||||
O2AGGContextEOFillPath(_agg,fill[0],fill[1],fill[2],fill[3],
|
||||
deviceTransform.a,deviceTransform.b,deviceTransform.c,deviceTransform.d,deviceTransform.tx,deviceTransform.ty);
|
||||
|
||||
O2ColorRelease(rgbColor);
|
||||
O2PathReset(_path);
|
||||
}
|
||||
else {
|
||||
// O2PathReset(_path);
|
||||
[super drawPath:drawingMode];
|
||||
}
|
||||
if(doStroke)
|
||||
O2AGGContextStrokePath(_agg,stroke[0],stroke[1],stroke[2],stroke[3],
|
||||
deviceTransform.a,deviceTransform.b,deviceTransform.c,deviceTransform.d,deviceTransform.tx,deviceTransform.ty);
|
||||
|
||||
O2ColorRelease(fillColor);
|
||||
O2ColorRelease(strokeColor);
|
||||
|
||||
O2PathReset(_path);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -337,10 +337,10 @@
|
||||
EXECUTABLE_SUFFIX = .1.0.dll;
|
||||
FRAMEWORK_SEARCH_PATHS = /Developer/Cocotron/1.0/Windows/i386/Frameworks;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
HEADER_SEARCH_PATHS = "/Developer/Cocotron/1.0/Windows/i386/agg-2.4/include/";
|
||||
HEADER_SEARCH_PATHS = "/Developer/Cocotron/1.0/Windows/i386/agg-2.5/include/";
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = /Developer/Cocotron/1.0/Windows/i386/Frameworks/AppKit.framework/Resources;
|
||||
LIBRARY_SEARCH_PATHS = "/Developer/Cocotron/1.0/Windows/i386/agg-2.4";
|
||||
LIBRARY_SEARCH_PATHS = "/Developer/Cocotron/1.0/Windows/i386/agg-2.5";
|
||||
OTHER_CFLAGS = "-D__LITTLE_ENDIAN__";
|
||||
OTHER_LDFLAGS = (
|
||||
"-static",
|
||||
|
@ -225,9 +225,18 @@
|
||||
2A37F4A9FDCFA73011CA2CEA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = C05733CB08A9546B00998B17 /* Build configuration list for PBXProject "TextEditor" */;
|
||||
compatibilityVersion = "Xcode 2.4";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
English,
|
||||
Japanese,
|
||||
French,
|
||||
German,
|
||||
);
|
||||
mainGroup = 2A37F4AAFDCFA73011CA2CEA /* TextEditor */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
FE7135E30B370ED7006C9493 /* TextEditor */,
|
||||
8D15AC270486D014006FF6A4 /* TextEditor-Mac */,
|
||||
|
Loading…
Reference in New Issue
Block a user