From 5bebf3cb25087107a60cd5cd10cddfc27eab106c Mon Sep 17 00:00:00 2001 From: Hans Baier Date: Sat, 30 Sep 2006 12:21:13 +0000 Subject: [PATCH] * refactores CairoGState as a subclass of GSGState * header fixes to include freetype * fixed glitz api change (but does not work, because I don't know how to retrieve a proper VisualID for the display) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@23681 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 18 ++++ Headers/cairo/CairoFaceInfo.h | 2 + Headers/cairo/CairoGState.h | 127 +------------------------- Source/cairo/CairoGState.m | 138 +++++++---------------------- Source/cairo/XGCairoGlitzSurface.m | 12 +-- 5 files changed, 61 insertions(+), 236 deletions(-) diff --git a/ChangeLog b/ChangeLog index d5cda70..ce951b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2006-09-29 Hans Baier + + * Source/cairo/CairoGState.m: Added hack to retrieve current rgb + and alpha from cairos internal structures. Will be replaced by proper + code when the cairo functions are available + * Source/cairo/CairoGState.m: + * Headers/cairo/CairoGState.h: refactored class as a subclass of + GSGState. Removed all unimplemented methods implemented in the + superclass. + * Headers/cairo/CairoFaceInfo.h: fixed header file to include the + needed freetype headers + * Source/cairo/XGCairoGlitzSurface.m: fixed glitz api change + glitz_glx_find_drawable_format -> + glitz_glx_find_drawable_format_for_visual. Compiles now but doesnt + work yet, because I don't know how to retrieve a proper VisualID. + someone who knows, please fix it! + 2006-09-28 Richard Frith-Macdonald * Source/win32/WIN32Server.m: Use GSBackHandlesWindowDecorations @@ -17,6 +34,7 @@ offsets. Wait for up to a second for visibility events in case XSync() does not work to ensure we receive them. +>>>>>>> .r23660 2006-09-25 Richard Frith-Macdonald * Headers/x11/XGGeneric.h: Extra fielkd to flag when style offsets diff --git a/Headers/cairo/CairoFaceInfo.h b/Headers/cairo/CairoFaceInfo.h index 525d124..d90faee 100644 --- a/Headers/cairo/CairoFaceInfo.h +++ b/Headers/cairo/CairoFaceInfo.h @@ -26,6 +26,8 @@ #ifndef CAIROFACEINFO_H #define CAIROFACEINFO_H #include +#include +#include FT_FREETYPE_H #include @interface CairoFaceInfo : NSObject diff --git a/Headers/cairo/CairoGState.h b/Headers/cairo/CairoGState.h index 7c60e81..46be168 100644 --- a/Headers/cairo/CairoGState.h +++ b/Headers/cairo/CairoGState.h @@ -27,11 +27,13 @@ #include #include +#include "gsc/GSGState.h" + @class CairoContext; @class CairoFontInfo; @class CairoSurface; -@interface CairoGState : NSObject /* No need of overhead */ +@interface CairoGState : GSGState { @public cairo_t *_ct; @@ -47,128 +49,5 @@ @end -@interface CairoGState (Ops) -/* ----------------------------------------------------------------------- */ -/* Color operations */ -/* ----------------------------------------------------------------------- */ -- (void) DPScurrentalpha: (float*)a; -- (void) DPScurrentcmykcolor: (float*)c : (float*)m : (float*)y : (float*)k; -- (void) DPScurrentgray: (float*)gray; -- (void) DPScurrenthsbcolor: (float*)h : (float*)s : (float*)b; -- (void) DPScurrentrgbcolor: (float*)r : (float*)g : (float*)b; -- (void) DPSsetalpha: (float)a; -- (void) DPSsetcmykcolor: (float)c : (float)m : (float)y : (float)k; -- (void) DPSsetgray: (float)gray; -- (void) DPSsethsbcolor: (float)h : (float)s : (float)b; -- (void) DPSsetrgbcolor: (float)r : (float)g : (float)b; - -- (void) GSSetFillColorspace: (void *)spaceref; -- (void) GSSetStrokeColorspace: (void *)spaceref; -- (void) GSSetFillColor: (const float *)values; -- (void) GSSetStrokeColor: (const float *)values; - -/* ----------------------------------------------------------------------- */ -/* Text operations */ -/* ----------------------------------------------------------------------- */ -- (void) DPSashow: (float)x : (float)y : (const char*)s; -- (void) DPSawidthshow: (float)cx : (float)cy : (int)c : (float)ax : (float)ay - : (const char*)s; -- (void) DPScharpath: (const char*)s : (int)b; -- (void) DPSshow: (const char*)s; -- (void) DPSwidthshow: (float)x : (float)y : (int)c : (const char*)s; -- (void) DPSxshow: (const char*)s : (const float*)numarray : (int)size; -- (void) DPSxyshow: (const char*)s : (const float*)numarray : (int)size; -- (void) DPSyshow: (const char*)s : (const float*)numarray : (int)size; - -- (void) GSSetCharacterSpacing: (float)extra; -- (void) GSSetFont: (GSFontInfo *)fontref; -- (void) GSSetFontSize: (float)size; -- (NSAffineTransform *) GSGetTextCTM; -- (NSPoint) GSGetTextPosition; -- (void) GSSetTextCTM: (NSAffineTransform *)ctm; -- (void) GSSetTextDrawingMode: (GSTextDrawingMode)mode; -- (void) GSSetTextPosition: (NSPoint)loc; -- (void) GSShowText: (const char *)string : (size_t) length; -- (void) GSShowGlyphs: (const NSGlyph *)glyphs : (size_t) length; - -/* ----------------------------------------------------------------------- */ -/* Gstate operations */ -/* ----------------------------------------------------------------------- */ -- (void) DPSinitgraphics; - -- (void) DPScurrentflat: (float*)flatness; -- (void) DPScurrentlinecap: (int*)linecap; -- (void) DPScurrentlinejoin: (int*)linejoin; -- (void) DPScurrentlinewidth: (float*)width; -- (void) DPScurrentmiterlimit: (float*)limit; -- (void) DPScurrentpoint: (float*)x : (float*)y; -- (void) DPScurrentstrokeadjust: (int*)b; -- (void) DPSsetdash: (const float*)pat : (int)size : (float)offset; -- (void) DPSsetflat: (float)flatness; -- (void) DPSsetlinecap: (int)linecap; -- (void) DPSsetlinejoin: (int)linejoin; -- (void) DPSsetlinewidth: (float)width; -- (void) DPSsetmiterlimit: (float)limit; -- (void) DPSsetstrokeadjust: (int)b; - -/* ----------------------------------------------------------------------- */ -/* Matrix operations */ -/* ----------------------------------------------------------------------- */ -- (void) DPSconcat: (const float*)m; -- (void) DPSinitmatrix; -- (void) DPSrotate: (float)angle; -- (void) DPSscale: (float)x : (float)y; -- (void) DPStranslate: (float)x : (float)y; - -- (NSAffineTransform *) GSCurrentCTM; -- (void) GSSetCTM: (NSAffineTransform *)ctm; -- (void) GSConcatCTM: (NSAffineTransform *)ctm; - -/* ----------------------------------------------------------------------- */ -/* Paint operations */ -/* ----------------------------------------------------------------------- */ -- (NSPoint) currentPoint; - -- (void) DPSarc: (float)x : (float)y : (float)r : (float)angle1 - : (float)angle2; -- (void) DPSarcn: (float)x : (float)y : (float)r : (float)angle1 - : (float)angle2; -- (void) DPSarct: (float)x1 : (float)y1 : (float)x2 : (float)y2 : (float)r; -- (void) DPSclip; -- (void) DPSclosepath; -- (void) DPScurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2 - : (float)x3 : (float)y3; -- (void) DPSeoclip; -- (void) DPSeofill; -- (void) DPSfill; -- (void) DPSflattenpath; -- (void) DPSinitclip; -- (void) DPSlineto: (float)x : (float)y; -- (void) DPSmoveto: (float)x : (float)y; -- (void) DPSnewpath; -- (void) DPSpathbbox: (float*)llx : (float*)lly : (float*)urx : (float*)ury; -- (void) DPSrcurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2 - : (float)x3 : (float)y3; -- (void) DPSrectclip: (float)x : (float)y : (float)w : (float)h; -- (void) DPSrectfill: (float)x : (float)y : (float)w : (float)h; -- (void) DPSrectstroke: (float)x : (float)y : (float)w : (float)h; -- (void) DPSreversepath; -- (void) DPSrlineto: (float)x : (float)y; -- (void) DPSrmoveto: (float)x : (float)y; -- (void) DPSstroke; - -- (void) GSSendBezierPath: (NSBezierPath *)path; -- (void) GSRectClipList: (const NSRect *)rects : (int) count; -- (void) GSRectFillList: (const NSRect *)rects : (int) count; - -- (void)DPSimage: (NSAffineTransform*) matrix - : (int) pixelsWide : (int) pixelsHigh - : (int) bitsPerSample : (int) samplesPerPixel - : (int) bitsPerPixel : (int) bytesPerRow : (BOOL) isPlanar - : (BOOL) hasAlpha : (NSString *) colorSpaceName - : (const unsigned char *const [5]) data; - -@end - #endif diff --git a/Source/cairo/CairoGState.m b/Source/cairo/CairoGState.m index 78c97f6..c9c0ca9 100644 --- a/Source/cairo/CairoGState.m +++ b/Source/cairo/CairoGState.m @@ -1,3 +1,4 @@ + /* * CairoGState.m @@ -172,11 +173,7 @@ _flipCairoSurfaceMatrix(cairo_t *ct, CairoSurface *surface) [self DPSinitgraphics]; } -@end - -@implementation CairoGState (Ops) - -// FIXME: Hack to be able to set alpha +// FIXME: This is for the color getters on non solid type patterns static float last_r, last_g, last_b; /* @@ -184,9 +181,19 @@ static float last_r, last_g, last_b; */ - (void) DPScurrentalpha: (float *)a { - //FIXME - *a = 1.0; + cairo_pattern_t *pattern; + //cairo removed this function //*a = cairo_current_alpha(_ct); + + pattern = cairo_get_source(_ct); + if (cairo_pattern_get_type(pattern) == CAIRO_PATTERN_TYPE_SOLID) + { + void *colors = (((void *)pattern) + 68); + *a = *((double *) colors + 3); + } + else + *a = 1.0; + } - (void) DPScurrentcmykcolor: (float *)c : (float *)m : (float *)y :(float *)k @@ -227,21 +234,31 @@ static float last_r, last_g, last_b; - (void) DPScurrentrgbcolor: (float *)r : (float *)g : (float *)b { - //FIXME: cairo removed this function + cairo_pattern_t *pattern; + //cairo removed this function //cairo_current_rgb_color(_ct, &dr, &dg, &db); - *r = last_r; - *g = last_g; - *b = last_b; + + pattern = cairo_get_source(_ct); + if (cairo_pattern_get_type(pattern) == CAIRO_PATTERN_TYPE_SOLID) + { + void *colors = (((void *)pattern) + 68); + *r = *((double *) colors + 0); + *g = *(((double *) colors + 1)); + *b = *(((double *) colors + 2)); + } + else + { + *r = last_r; + *g = last_g; + *b = last_b; + } } - (void) DPSsetalpha: (float)a { float r, g, b; - // FIXME: Hack to be able to set alpha - r = last_r; - g = last_g; - b = last_b; + [self DPScurrentrgbcolor: &r: &g: &b]; cairo_set_source_rgba(_ct, r, g, b, a); } @@ -278,48 +295,16 @@ static float last_r, last_g, last_b; - (void) DPSsetrgbcolor: (float)r : (float)g: (float)b { - // FIXME: Hack to be able to set alpha last_r = r; last_g = g; last_b = b; cairo_set_source_rgb(_ct, r, g, b); } -- (void) GSSetFillColorspace: (void *)spaceref -{ - FIXME(); -} - -- (void) GSSetStrokeColorspace: (void *)spaceref -{ - FIXME(); -} - -- (void) GSSetFillColor: (const float *)values -{ - FIXME(); -} - -- (void) GSSetStrokeColor: (const float *)values -{ - FIXME(); -} - /* * Text operations */ -- (void) DPSashow: (float)x : (float)y : (const char *)s -{ - FIXME(); -} - -- (void) DPSawidthshow: (float)cx : (float)cy : (int)c : (float)ax - : (float)ay : (const char *)s -{ - FIXME(); -} - - (void) DPScharpath: (const char *)s : (int)b { char *c = malloc(b + 1); @@ -336,31 +321,6 @@ static float last_r, last_g, last_b; cairo_show_text(_ct, s); } -- (void) DPSwidthshow: (float)x : (float)y : (int)c : (const char *)s -{ - FIXME(); -} - -- (void) DPSxshow: (const char *)s : (const float *)numarray : (int)size -{ - FIXME(); -} - -- (void) DPSxyshow: (const char *)s : (const float *)numarray : (int)size -{ - FIXME(); -} - -- (void) DPSyshow: (const char *)s : (const float *)numarray : (int)size -{ - FIXME(); -} - -- (void) GSSetCharacterSpacing: (float)extra -{ - FIXME(); -} - - (void) GSSetFont: (GSFontInfo *)fontref { if (_font == fontref) @@ -396,16 +356,6 @@ static float last_r, last_g, last_b; [self GSSetCTM: ctm]; } -- (void) GSSetTextDrawingMode: (GSTextDrawingMode)mode -{ - FIXME(); -} - -- (void) GSSetTextPosition: (NSPoint)loc -{ - FIXME(); -} - - (void) GSShowText: (const char *)string : (size_t)length { FIXME(); @@ -710,30 +660,6 @@ static float last_r, last_g, last_b; cairo_arc_negative(_ct, x, y, r, angle1 * M_PI / 180, angle2 * M_PI / 180); } -- (void) DPSarct: (float)x1 : (float)y1 : (float)x2 : (float)y2 : (float)r -{ - FIXME(); - /* - cairo_arc_to(_ct, x1, y1, x2, y2, r); - */ - /* - NSBezierPath *newPath; - - newPath = [[NSBezierPath alloc] init]; - if ((path != nil) && ([path elementCount] != 0)) - { - [newPath lineToPoint: [self currentPoint]]; - } - [newPath appendBezierPathWithArcFromPoint: NSMakePoint(x1, y1) - toPoint: NSMakePoint(x2, y2) - radius: r]; - [newPath transformUsingAffineTransform: ctm]; - CHECK_PATH; - [path appendBezierPath: newPath]; - RELEASE(newPath); - */ -} - - (void) DPSclip { cairo_clip(_ct); diff --git a/Source/cairo/XGCairoGlitzSurface.m b/Source/cairo/XGCairoGlitzSurface.m index 667426d..b19be02 100644 --- a/Source/cairo/XGCairoGlitzSurface.m +++ b/Source/cairo/XGCairoGlitzSurface.m @@ -49,11 +49,11 @@ */ templ.doublebuffer = 0; - dformat = glitz_glx_find_drawable_format(GSWINDEVICE->display, - GSWINDEVICE->screen, - GLITZ_FORMAT_DOUBLEBUFFER_MASK, - &templ, - 0); + dformat = glitz_glx_find_drawable_format_for_visual(GSWINDEVICE->display, + GSWINDEVICE->screen, + // GLITZ_FORMAT_DOUBLEBUFFER_MASK, + // &templ, + DefaultVisual(GSWINDEVICE->display, GSWINDEVICE->screen)); //FIXME: this does not work if (!dformat) { @@ -90,7 +90,7 @@ exit(1); } - glitz_surface_attach(surface, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR, 0, 0); + glitz_surface_attach(surface, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR); _surface = cairo_glitz_surface_create(surface); return self;