From 80f074806db0fdd9646f7b5892d43a558c3a8f9b Mon Sep 17 00:00:00 2001 From: scuri Date: Wed, 3 Nov 2010 18:37:03 +0000 Subject: Fixed: PutImageRGB, PutImageRGBA, PutImageMap and Pattern when in 64bits using the Cairo context plus base driver. Improved double buffer update. --- src/cairo/cdcairo.c | 105 ++++++++++++++++++++++++++++++------------ src/cairo/cdcairodbuf.c | 22 +-------- src/cairo/cdcaironative_gdk.c | 1 + src/cd.c | 49 +++++++++++++------- src/cd.def | 1 + src/cdgdk.def | 1 + src/drv/cdirgb.c | 28 ++--------- src/gdk/cdgdkdbuf.c | 21 +-------- src/win32/cdwdbuf.c | 27 ++--------- src/x11/cdxdbuf.c | 22 +-------- 10 files changed, 121 insertions(+), 156 deletions(-) (limited to 'src') diff --git a/src/cairo/cdcairo.c b/src/cairo/cdcairo.c index b86c046..493ae1f 100644 --- a/src/cairo/cdcairo.c +++ b/src/cairo/cdcairo.c @@ -117,7 +117,8 @@ void cdcairoKillCanvas(cdCtxCanvas *ctxcanvas) if (ctxcanvas->strLastConvertUTF8) g_free(ctxcanvas->strLastConvertUTF8); - cairo_destroy(ctxcanvas->cr); + if (ctxcanvas->cr) + cairo_destroy(ctxcanvas->cr); memset(ctxcanvas, 0, sizeof(cdCtxCanvas)); free(ctxcanvas); @@ -213,7 +214,7 @@ static int cdclip(cdCtxCanvas *ctxcanvas, int mode) #define CD_ALPHAPRE(_src, _alpha) (((_src)*(_alpha))/255) -static unsigned long sEncodeRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) +static unsigned int sEncodeRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { /* Pre-multiplied alpha */ if (a != 255) @@ -223,23 +224,32 @@ static unsigned long sEncodeRGBA(unsigned char r, unsigned char g, unsigned char b = CD_ALPHAPRE(b, a); } - return (((unsigned long)a) << 24) | - (((unsigned long)r) << 16) | - (((unsigned long)g) << 8) | - (((unsigned long)b) << 0); + return (((unsigned int)a) << 24) | + (((unsigned int)r) << 16) | + (((unsigned int)g) << 8) | + (((unsigned int)b) << 0); } static void make_pattern(cdCtxCanvas *ctxcanvas, int n, int m, void* userdata, int (*data2rgb)(cdCtxCanvas *ctxcanvas, int n, int i, int j, void* userdata, unsigned char*r, unsigned char*g, unsigned char*b, unsigned char*a)) { - int i, j, offset, ret; + int i, j, offset, ret, stride; unsigned char r, g, b, a; cairo_surface_t* pattern_surface; - unsigned long* data; + unsigned int* data; + /* CAIRO_FORMAT_ARGB32 each pixel is a 32-bit quantity, with alpha in the upper 8 bits, then red, then green, then blue. + The 32-bit quantities are stored native-endian. + Pre-multiplied alpha is used. (That is, 50% transparent red is 0x80800000, not 0x80ff0000.) */ pattern_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, n, m); + if (cairo_surface_status(pattern_surface) != CAIRO_STATUS_SUCCESS) + { + cairo_surface_destroy(pattern_surface); + return; + } - data = (unsigned long*)cairo_image_surface_get_data(pattern_surface); - offset = cairo_image_surface_get_stride(pattern_surface)/4 - n; + data = (unsigned int*)cairo_image_surface_get_data(pattern_surface); + stride = cairo_image_surface_get_stride(pattern_surface); + offset = stride/4 - n; for (j = 0; j < m; j++) { @@ -284,7 +294,7 @@ static int long2rgb(cdCtxCanvas *ctxcanvas, int n, int i, int j, void* data, uns return 1; } -static void cdpattern(cdCtxCanvas *ctxcanvas, int n, int m, const long int *pattern) +static void cdpattern(cdCtxCanvas *ctxcanvas, int n, int m, const long *pattern) { make_pattern(ctxcanvas, n, m, (void*)pattern, long2rgb); cairo_set_source(ctxcanvas->cr, ctxcanvas->pattern); @@ -572,7 +582,7 @@ static void cdgetfontdim(cdCtxCanvas *ctxcanvas, int *max_width, int *height, in pango_font_metrics_unref(metrics); } -static long int cdforeground(cdCtxCanvas *ctxcanvas, long int color) +static long cdforeground(cdCtxCanvas *ctxcanvas, long color) { if (ctxcanvas->solid) cairo_pattern_destroy(ctxcanvas->solid); @@ -1288,8 +1298,8 @@ static void cdfpoly(cdCtxCanvas *ctxcanvas, int mode, cdfPoint* poly, int n) static void cdgetimagergb(cdCtxCanvas *ctxcanvas, unsigned char *r, unsigned char *g, unsigned char *b, int x, int y, int w, int h) { - int i, j, pos, offset; - unsigned long* data; + int i, j, pos, offset, stride; + unsigned int* data; cairo_surface_t* image_surface; cairo_t* cr; @@ -1304,7 +1314,15 @@ static void cdgetimagergb(cdCtxCanvas *ctxcanvas, unsigned char *r, unsigned cha /* y is the bottom-left of the image in CD, must be at upper-left */ y -= h-1; + /* CAIRO_FORMAT_RGB24 each pixel is a 32-bit quantity, with the upper 8 bits unused. + Red, Green, and Blue are stored in the remaining 24 bits in that order. */ image_surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, w, h); + if (cairo_surface_status(image_surface) != CAIRO_STATUS_SUCCESS) + { + cairo_surface_destroy(image_surface); + return; + } + cr = cairo_create(image_surface); /* creates a pattern from the canvas and sets it as source in the image. */ @@ -1314,8 +1332,9 @@ static void cdgetimagergb(cdCtxCanvas *ctxcanvas, unsigned char *r, unsigned cha cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_paint(cr); /* paints the current source everywhere within the current clip region. */ - data = (unsigned long*)cairo_image_surface_get_data(image_surface); - offset = cairo_image_surface_get_stride(image_surface)/4 - w; + data = (unsigned int*)cairo_image_surface_get_data(image_surface); + stride = cairo_image_surface_get_stride(image_surface); + offset = stride/4 - w; for (i=0; iiw || ymax-ymin+1>ih) return; @@ -1360,10 +1379,18 @@ static void cdputimagerectrgb(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsi rw = xmax-xmin+1; rh = ymax-ymin+1; + /* CAIRO_FORMAT_RGB24 each pixel is a 32-bit quantity, with the upper 8 bits unused. + Red, Green, and Blue are stored in the remaining 24 bits in that order. */ image_surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, rw, rh); + if (cairo_surface_status(image_surface) != CAIRO_STATUS_SUCCESS) + { + cairo_surface_destroy(image_surface); + return; + } - data = (unsigned long*)cairo_image_surface_get_data(image_surface); - offset = cairo_image_surface_get_stride(image_surface)/4 - rw; + data = (unsigned int*)cairo_image_surface_get_data(image_surface); + stride = cairo_image_surface_get_stride(image_surface); + offset = stride/4 - rw; sFixImageY(ctxcanvas->canvas, &topdown, &y, h); @@ -1404,8 +1431,8 @@ static void cdputimagerectrgb(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsi static void cdputimagerectrgba(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, const unsigned char *a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax) { - int i, j, rw, rh, pos, offset, topdown; - unsigned long* data; + int i, j, rw, rh, pos, offset, topdown, stride; + unsigned int* data; cairo_surface_t* image_surface; if (xmin<0 || ymin<0 || xmax-xmin+1>iw || ymax-ymin+1>ih) return; @@ -1413,10 +1440,19 @@ static void cdputimagerectrgba(cdCtxCanvas *ctxcanvas, int iw, int ih, const uns rw = xmax-xmin+1; rh = ymax-ymin+1; + /* CAIRO_FORMAT_ARGB32 each pixel is a 32-bit quantity, with alpha in the upper 8 bits, then red, then green, then blue. + The 32-bit quantities are stored native-endian. + Pre-multiplied alpha is used. (That is, 50% transparent red is 0x80800000, not 0x80ff0000.) */ image_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, rw, rh); + if (cairo_surface_status(image_surface) != CAIRO_STATUS_SUCCESS) + { + cairo_surface_destroy(image_surface); + return; + } - data = (unsigned long*)cairo_image_surface_get_data(image_surface); - offset = cairo_image_surface_get_stride(image_surface)/4 - rw; + data = (unsigned int*)cairo_image_surface_get_data(image_surface); + stride = cairo_image_surface_get_stride(image_surface); + offset = stride/4 - rw; sFixImageY(ctxcanvas->canvas, &topdown, &y, h); @@ -1469,10 +1505,11 @@ static int sCalcPalSize(int size, const unsigned char *index) return pal_size; } -static void cdputimagerectmap(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsigned char *index, const long int *colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax) +static void cdputimagerectmap(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsigned char *index, const long *colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax) { - int i, j, rw, rh, pos, offset, pal_size, topdown; - unsigned long* data, cairo_colors[256], c; + int i, j, rw, rh, pos, offset, pal_size, topdown, stride; + unsigned int* data, cairo_colors[256]; + long c; cairo_surface_t* image_surface; if (xmin<0 || ymin<0 || xmax-xmin+1>iw || ymax-ymin+1>ih) return; @@ -1480,10 +1517,18 @@ static void cdputimagerectmap(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsi rw = xmax-xmin+1; rh = ymax-ymin+1; + /* CAIRO_FORMAT_RGB24 each pixel is a 32-bit quantity, with the upper 8 bits unused. + Red, Green, and Blue are stored in the remaining 24 bits in that order. */ image_surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, rw, rh); + if (cairo_surface_status(image_surface) != CAIRO_STATUS_SUCCESS) + { + cairo_surface_destroy(image_surface); + return; + } - data = (unsigned long*)cairo_image_surface_get_data(image_surface); - offset = cairo_image_surface_get_stride(image_surface)/4 - rw; + data = (unsigned int*)cairo_image_surface_get_data(image_surface); + stride = cairo_image_surface_get_stride(image_surface); + offset = stride/4 - rw; pal_size = sCalcPalSize(iw*ih, index); for (i=0; icr); } -static void cdpixel(cdCtxCanvas *ctxcanvas, int x, int y, long int color) +static void cdpixel(cdCtxCanvas *ctxcanvas, int x, int y, long color) { cairo_pattern_t* old_source = cairo_get_source(ctxcanvas->cr); cairo_set_source_rgba(ctxcanvas->cr, cdCairoGetRed(color), cdCairoGetGreen(color), cdCairoGetBlue(color), cdCairoGetAlpha(color)); diff --git a/src/cairo/cdcairodbuf.c b/src/cairo/cdcairodbuf.c index 4c5897a..91f1649 100644 --- a/src/cairo/cdcairodbuf.c +++ b/src/cairo/cdcairodbuf.c @@ -112,31 +112,13 @@ static int cdactivate(cdCtxCanvas* ctxcanvas) /* remove the old image and canvas */ cdKillImage(old_image_dbuffer); + old_ctxcanvas->cr = NULL; /* avoid to destroy it twice */ cdcairoKillCanvas(old_ctxcanvas); ctxcanvas = canvas->ctxcanvas; /* update canvas attributes */ - canvas->cxBackground(ctxcanvas, canvas->background); - canvas->cxForeground(ctxcanvas, canvas->foreground); - canvas->cxBackOpacity(ctxcanvas, canvas->back_opacity); - canvas->cxWriteMode(ctxcanvas, canvas->write_mode); - canvas->cxLineStyle(ctxcanvas, canvas->line_style); - canvas->cxLineWidth(ctxcanvas, canvas->line_width); - canvas->cxLineCap(ctxcanvas, canvas->line_cap); - canvas->cxLineJoin(ctxcanvas, canvas->line_join); - canvas->cxHatch(ctxcanvas, canvas->hatch_style); - if (canvas->stipple) canvas->cxStipple(ctxcanvas, canvas->stipple_w, canvas->stipple_h, canvas->stipple); - if (canvas->pattern) canvas->cxPattern(ctxcanvas, canvas->pattern_w, canvas->pattern_h, canvas->pattern); - canvas->cxInteriorStyle(ctxcanvas, canvas->interior_style); - canvas->cxFont(ctxcanvas, canvas->font_type_face, canvas->font_style, canvas->font_size); -/* canvas->cxTextAlignment(ctxcanvas, canvas->text_alignment); */ -/* canvas->cxTextOrientation(ctxcanvas, canvas->text_orientation); */ - if (canvas->clip_mode == CD_CLIPAREA && canvas->cxClipArea) canvas->cxClipArea(ctxcanvas, canvas->clip_rect.xmin, canvas->clip_rect.xmax, canvas->clip_rect.ymin, canvas->clip_rect.ymax); -/* if (canvas->clip_mode == CD_CLIPAREA && canvas->cxFClipArea) canvas->cxFClipArea(ctxcanvas, canvas->clip_frect.xmin, canvas->clip_frect.xmax, canvas->clip_frect.ymin, canvas->clip_frect.ymax); */ - if (canvas->clip_mode == CD_CLIPPOLYGON && canvas->clip_poly) canvas->cxPoly(ctxcanvas, CD_CLIP, canvas->clip_poly, canvas->clip_poly_n); -/* if (canvas->clip_mode == CD_CLIPPOLYGON && canvas->clip_fpoly) canvas->cxFPoly(ctxcanvas, CD_CLIP, canvas->clip_fpoly, canvas->clip_poly_n); */ - if (canvas->clip_mode != CD_CLIPOFF) canvas->cxClip(ctxcanvas, canvas->clip_mode); + cdUpdateAttributes(canvas); } return CD_OK; diff --git a/src/cairo/cdcaironative_gdk.c b/src/cairo/cdcaironative_gdk.c index e233ed6..143efaf 100644 --- a/src/cairo/cdcaironative_gdk.c +++ b/src/cairo/cdcaironative_gdk.c @@ -31,6 +31,7 @@ int cdactivate(cdCtxCanvas *ctxcanvas) if (old_w != canvas->w || old_h != canvas->h) { + /* Re-create the context so internal size is updated. */ cairo_destroy(ctxcanvas->cr); ctxcanvas->cr = gdk_cairo_create(ctxcanvas->drawable); diff --git a/src/cd.c b/src/cd.c index 13d2541..ea3effd 100644 --- a/src/cd.c +++ b/src/cd.c @@ -93,23 +93,39 @@ static void cd_setdefaultattrib(cdCanvas* canvas) /* o resto recebeu zero no memset */ } -static void cd_updatedefaultattrib(cdCanvas* canvas) +void cdUpdateAttributes(cdCanvas* canvas) { - cdCanvasActivate(canvas); + cdCtxCanvas* ctxcanvas = canvas->ctxcanvas; + + if (canvas->cxBackground) canvas->cxBackground(ctxcanvas, canvas->background); + if (canvas->cxForeground) canvas->cxForeground(ctxcanvas, canvas->foreground); + if (canvas->cxBackOpacity) canvas->cxBackOpacity(ctxcanvas, canvas->back_opacity); + if (canvas->cxWriteMode) canvas->cxWriteMode(ctxcanvas, canvas->write_mode); + + if (canvas->cxLineStyle) canvas->cxLineStyle(ctxcanvas, canvas->line_style); + if (canvas->cxLineWidth) canvas->cxLineWidth(ctxcanvas, canvas->line_width); + if (canvas->cxLineCap) canvas->cxLineCap(ctxcanvas, canvas->line_cap); + if (canvas->cxLineJoin) canvas->cxLineJoin(ctxcanvas, canvas->line_join); + + if (canvas->cxHatch) canvas->cxHatch(ctxcanvas, canvas->hatch_style); + if (canvas->stipple && canvas->cxStipple) canvas->cxStipple(ctxcanvas, canvas->stipple_w, canvas->stipple_h, canvas->stipple); + if (canvas->pattern && canvas->cxPattern) canvas->cxPattern(ctxcanvas, canvas->pattern_w, canvas->pattern_h, canvas->pattern); + if (canvas->cxInteriorStyle) canvas->cxInteriorStyle(ctxcanvas, canvas->interior_style); - if (canvas->cxBackground) canvas->cxBackground(canvas->ctxcanvas, canvas->background); - if (canvas->cxForeground) canvas->cxForeground(canvas->ctxcanvas, canvas->foreground); - if (canvas->cxBackOpacity) canvas->cxBackOpacity(canvas->ctxcanvas, canvas->back_opacity); - if (canvas->cxWriteMode) canvas->cxWriteMode(canvas->ctxcanvas, canvas->write_mode); - if (canvas->cxLineStyle) canvas->cxLineStyle(canvas->ctxcanvas, canvas->line_style); - if (canvas->cxLineWidth) canvas->cxLineWidth(canvas->ctxcanvas, canvas->line_width); - if (canvas->cxLineCap) canvas->cxLineCap(canvas->ctxcanvas, canvas->line_cap); - if (canvas->cxLineJoin) canvas->cxLineJoin(canvas->ctxcanvas, canvas->line_join); - if (canvas->cxHatch) canvas->cxHatch(canvas->ctxcanvas, canvas->hatch_style); - if (canvas->cxInteriorStyle) canvas->cxInteriorStyle(canvas->ctxcanvas, canvas->interior_style); - if (canvas->cxFont) canvas->cxFont(canvas->ctxcanvas, canvas->font_type_face, canvas->font_style, canvas->font_size); - if (canvas->cxTextAlignment) canvas->cxTextAlignment(canvas->ctxcanvas, canvas->text_alignment); - if (canvas->cxTextOrientation) canvas->cxTextOrientation(canvas->ctxcanvas, canvas->text_orientation); + if (canvas->native_font[0] && canvas->cxNativeFont) + canvas->cxNativeFont(ctxcanvas, canvas->native_font); + else if (canvas->cxFont) + canvas->cxFont(ctxcanvas, canvas->font_type_face, canvas->font_style, canvas->font_size); + if (canvas->cxTextAlignment) canvas->cxTextAlignment(ctxcanvas, canvas->text_alignment); + if (canvas->cxTextOrientation) canvas->cxTextOrientation(ctxcanvas, canvas->text_orientation); + + if (canvas->use_matrix && canvas->cxTransform) canvas->cxTransform(ctxcanvas, canvas->matrix); + + if (canvas->clip_mode == CD_CLIPAREA && canvas->cxClipArea) canvas->cxClipArea(ctxcanvas, canvas->clip_rect.xmin, canvas->clip_rect.xmax, canvas->clip_rect.ymin, canvas->clip_rect.ymax); + if (canvas->clip_mode == CD_CLIPAREA && canvas->cxFClipArea) canvas->cxFClipArea(ctxcanvas, canvas->clip_frect.xmin, canvas->clip_frect.xmax, canvas->clip_frect.ymin, canvas->clip_frect.ymax); + if (canvas->clip_mode == CD_CLIPPOLYGON && canvas->clip_poly) canvas->cxPoly(ctxcanvas, CD_CLIP, canvas->clip_poly, canvas->clip_poly_n); + if (canvas->clip_mode == CD_CLIPPOLYGON && canvas->clip_fpoly) canvas->cxFPoly(ctxcanvas, CD_CLIP, canvas->clip_fpoly, canvas->clip_poly_n); + if (canvas->clip_mode != CD_CLIPOFF && canvas->cxClip) canvas->cxClip(ctxcanvas, canvas->clip_mode); } cdCanvas* cdCreateCanvasf(cdContext *context, const char* format, ...) @@ -172,7 +188,8 @@ cdCanvas *cdCreateCanvas(cdContext* context, void *data_str) context->cxInitTable(canvas); /* update the default atributes, must be after InitTable */ - cd_updatedefaultattrib(canvas); + cdCanvasActivate(canvas); + cdUpdateAttributes(canvas); /* must be after creating the canvas, so that we know canvas width and height */ canvas->clip_rect.xmax = canvas->w-1; diff --git a/src/cd.def b/src/cd.def index e3802b2..d1b1334 100644 --- a/src/cd.def +++ b/src/cd.def @@ -49,6 +49,7 @@ EXPORTS cdSetfAttribute cdGetAttribute cdRegisterAttribute + cdUpdateAttributes cdReleaseState cdRegisterCallback diff --git a/src/cdgdk.def b/src/cdgdk.def index dba219a..6489315 100644 --- a/src/cdgdk.def +++ b/src/cdgdk.def @@ -49,6 +49,7 @@ EXPORTS cdSetfAttribute cdGetAttribute cdRegisterAttribute + cdUpdateAttributes cdReleaseState cdRegisterCallback diff --git a/src/drv/cdirgb.c b/src/drv/cdirgb.c index d9dd6a8..fa45f97 100644 --- a/src/drv/cdirgb.c +++ b/src/drv/cdirgb.c @@ -1908,7 +1908,7 @@ static void cdcreatecanvasDB(cdCanvas* canvas, cdCanvas* canvas_dbuffer) { char rgbdata[100]; sprintf(rgbdata, "%dx%d -r%g", canvas_dbuffer->w, canvas_dbuffer->h, canvas_dbuffer->xres); - cdcreatecanvas(canvas, rgbdata); + cdcreatecanvas(canvas, rgbdata); /* the double buffer image will be internally allocated as the canvas RGB image itself */ if (canvas->ctxcanvas) canvas->ctxcanvas->canvas_dbuffer = canvas_dbuffer; } @@ -1941,34 +1941,12 @@ static int cdactivateDB(cdCtxCanvas *ctxcanvas) } /* remove the old image and canvas */ - cdkillcanvas(old_ctxcanvas); + cdkillcanvas(old_ctxcanvas); /* the double buffer image is the canvas itself */ ctxcanvas = canvas->ctxcanvas; /* update canvas attributes */ - if (canvas->cxBackground) canvas->cxBackground(ctxcanvas, canvas->background); - if (canvas->cxForeground) canvas->cxForeground(ctxcanvas, canvas->foreground); - if (canvas->cxBackOpacity) canvas->cxBackOpacity(ctxcanvas, canvas->back_opacity); - if (canvas->cxWriteMode) canvas->cxWriteMode(ctxcanvas, canvas->write_mode); - if (canvas->cxLineStyle) canvas->cxLineStyle(ctxcanvas, canvas->line_style); - if (canvas->cxLineWidth) canvas->cxLineWidth(ctxcanvas, canvas->line_width); - if (canvas->cxLineCap) canvas->cxLineCap(ctxcanvas, canvas->line_cap); - if (canvas->cxLineJoin) canvas->cxLineJoin(ctxcanvas, canvas->line_join); - if (canvas->cxHatch) canvas->cxHatch(ctxcanvas, canvas->hatch_style); - if (canvas->stipple && canvas->cxStipple) canvas->cxStipple(ctxcanvas, canvas->stipple_w, canvas->stipple_h, canvas->stipple); - if (canvas->pattern && canvas->cxPattern) canvas->cxPattern(ctxcanvas, canvas->pattern_w, canvas->pattern_h, canvas->pattern); - if (canvas->cxInteriorStyle) canvas->cxInteriorStyle(ctxcanvas, canvas->interior_style); - if (canvas->native_font[0] && canvas->cxNativeFont) - canvas->cxNativeFont(ctxcanvas, canvas->native_font); - else if (canvas->cxFont) canvas->cxFont(ctxcanvas, canvas->font_type_face, canvas->font_style, canvas->font_size); - if (canvas->cxTextAlignment) canvas->cxTextAlignment(ctxcanvas, canvas->text_alignment); - if (canvas->cxTextOrientation) canvas->cxTextOrientation(ctxcanvas, canvas->text_orientation); - if (canvas->use_matrix && canvas->cxTransform) canvas->cxTransform(ctxcanvas, canvas->matrix); - if (canvas->clip_mode == CD_CLIPAREA && canvas->cxClipArea) canvas->cxClipArea(ctxcanvas, canvas->clip_rect.xmin, canvas->clip_rect.xmax, canvas->clip_rect.ymin, canvas->clip_rect.ymax); - if (canvas->clip_mode == CD_CLIPAREA && canvas->cxFClipArea) canvas->cxFClipArea(ctxcanvas, canvas->clip_frect.xmin, canvas->clip_frect.xmax, canvas->clip_frect.ymin, canvas->clip_frect.ymax); - if (canvas->clip_mode == CD_CLIPPOLYGON && canvas->clip_poly) canvas->cxPoly(ctxcanvas, CD_CLIP, canvas->clip_poly, canvas->clip_poly_n); - if (canvas->clip_mode == CD_CLIPPOLYGON && canvas->clip_fpoly) canvas->cxFPoly(ctxcanvas, CD_CLIP, canvas->clip_fpoly, canvas->clip_poly_n); - if (canvas->clip_mode != CD_CLIPOFF && canvas->cxClip) canvas->cxClip(ctxcanvas, canvas->clip_mode); + cdUpdateAttributes(canvas); } return CD_OK; diff --git a/src/gdk/cdgdkdbuf.c b/src/gdk/cdgdkdbuf.c index 9a8854a..50a93a5 100644 --- a/src/gdk/cdgdkdbuf.c +++ b/src/gdk/cdgdkdbuf.c @@ -109,26 +109,7 @@ static int cdactivate(cdCtxCanvas* ctxcanvas) ctxcanvas = canvas->ctxcanvas; /* update canvas attributes */ - canvas->cxBackground(ctxcanvas, canvas->background); - canvas->cxForeground(ctxcanvas, canvas->foreground); - canvas->cxBackOpacity(ctxcanvas, canvas->back_opacity); - canvas->cxWriteMode(ctxcanvas, canvas->write_mode); - canvas->cxLineStyle(ctxcanvas, canvas->line_style); - canvas->cxLineWidth(ctxcanvas, canvas->line_width); - canvas->cxLineCap(ctxcanvas, canvas->line_cap); - canvas->cxLineJoin(ctxcanvas, canvas->line_join); - canvas->cxHatch(ctxcanvas, canvas->hatch_style); - if (canvas->stipple) canvas->cxStipple(ctxcanvas, canvas->stipple_w, canvas->stipple_h, canvas->stipple); - if (canvas->pattern) canvas->cxPattern(ctxcanvas, canvas->pattern_w, canvas->pattern_h, canvas->pattern); - canvas->cxInteriorStyle(ctxcanvas, canvas->interior_style); - canvas->cxFont(ctxcanvas, canvas->font_type_face, canvas->font_style, canvas->font_size); -/* canvas->cxTextAlignment(ctxcanvas, canvas->text_alignment); */ -/* canvas->cxTextOrientation(ctxcanvas, canvas->text_orientation); */ - if (canvas->clip_mode == CD_CLIPAREA && canvas->cxClipArea) canvas->cxClipArea(ctxcanvas, canvas->clip_rect.xmin, canvas->clip_rect.xmax, canvas->clip_rect.ymin, canvas->clip_rect.ymax); -/* if (canvas->clip_mode == CD_CLIPAREA && canvas->cxFClipArea) canvas->cxFClipArea(ctxcanvas, canvas->clip_frect.xmin, canvas->clip_frect.xmax, canvas->clip_frect.ymin, canvas->clip_frect.ymax); */ - if (canvas->clip_mode == CD_CLIPPOLYGON && canvas->clip_poly) canvas->cxPoly(ctxcanvas, CD_CLIP, canvas->clip_poly, canvas->clip_poly_n); -/* if (canvas->clip_mode == CD_CLIPPOLYGON && canvas->clip_fpoly) canvas->cxFPoly(ctxcanvas, CD_CLIP, canvas->clip_fpoly, canvas->clip_poly_n); */ - if (canvas->clip_mode != CD_CLIPOFF) canvas->cxClip(ctxcanvas, canvas->clip_mode); + cdUpdateAttributes(canvas); } return CD_OK; diff --git a/src/win32/cdwdbuf.c b/src/win32/cdwdbuf.c index 4beac10..9d79e9b 100644 --- a/src/win32/cdwdbuf.c +++ b/src/win32/cdwdbuf.c @@ -114,35 +114,14 @@ static int cdactivate(cdCtxCanvas *ctxcanvas) } /* remove the old image and canvas */ - cdKillImage(old_image_dbuffer); - cdwKillCanvas(old_ctxcanvas); + cdwKillCanvas(old_ctxcanvas); /* ctxcanvas e ctxcanvas->hDC released in each driver */ + cdKillImage(old_image_dbuffer); /* the ctxcanvas->hDC is released here, so do it after the cdwKillCanvas */ free(old_ctxcanvas); ctxcanvas = canvas->ctxcanvas; /* update canvas attributes */ - canvas->cxBackground(ctxcanvas, canvas->background); - canvas->cxForeground(ctxcanvas, canvas->foreground); - canvas->cxBackOpacity(ctxcanvas, canvas->back_opacity); - canvas->cxWriteMode(ctxcanvas, canvas->write_mode); - canvas->cxLineStyle(ctxcanvas, canvas->line_style); - canvas->cxLineWidth(ctxcanvas, canvas->line_width); - canvas->cxLineCap(ctxcanvas, canvas->line_cap); - canvas->cxLineJoin(ctxcanvas, canvas->line_join); - canvas->cxHatch(ctxcanvas, canvas->hatch_style); - if (canvas->stipple) canvas->cxStipple(ctxcanvas, canvas->stipple_w, canvas->stipple_h, canvas->stipple); - if (canvas->pattern) canvas->cxPattern(ctxcanvas, canvas->pattern_w, canvas->pattern_h, canvas->pattern); - canvas->cxInteriorStyle(ctxcanvas, canvas->interior_style); - if (canvas->native_font[0] == 0) canvas->cxFont(ctxcanvas, canvas->font_type_face, canvas->font_style, canvas->font_size); - else canvas->cxNativeFont(ctxcanvas, canvas->native_font); - canvas->cxTextAlignment(ctxcanvas, canvas->text_alignment); - canvas->cxTextOrientation(ctxcanvas, canvas->text_orientation); - if (canvas->use_matrix && canvas->cxTransform) canvas->cxTransform(ctxcanvas, canvas->matrix); - if (canvas->clip_mode == CD_CLIPAREA && canvas->cxClipArea) canvas->cxClipArea(ctxcanvas, canvas->clip_rect.xmin, canvas->clip_rect.xmax, canvas->clip_rect.ymin, canvas->clip_rect.ymax); -/* if (canvas->clip_mode == CD_CLIPAREA && canvas->cxFClipArea) canvas->cxFClipArea(ctxcanvas, canvas->clip_frect.xmin, canvas->clip_frect.xmax, canvas->clip_frect.ymin, canvas->clip_frect.ymax); */ - if (canvas->clip_mode == CD_CLIPPOLYGON && canvas->clip_poly) canvas->cxPoly(ctxcanvas, CD_CLIP, canvas->clip_poly, canvas->clip_poly_n); -/* if (canvas->clip_mode == CD_CLIPPOLYGON && canvas->clip_fpoly) canvas->cxFPoly(ctxcanvas, CD_CLIP, canvas->clip_fpoly, canvas->clip_poly_n); */ - if (canvas->clip_mode != CD_CLIPOFF) canvas->cxClip(ctxcanvas, canvas->clip_mode); + cdUpdateAttributes(canvas); } return CD_OK; diff --git a/src/x11/cdxdbuf.c b/src/x11/cdxdbuf.c index 0f4955e..29d1e4e 100644 --- a/src/x11/cdxdbuf.c +++ b/src/x11/cdxdbuf.c @@ -108,27 +108,7 @@ static int cdactivate(cdCtxCanvas* ctxcanvas) ctxcanvas = canvas->ctxcanvas; /* update canvas attributes */ - canvas->cxBackground(ctxcanvas, canvas->background); - canvas->cxForeground(ctxcanvas, canvas->foreground); - canvas->cxBackOpacity(ctxcanvas, canvas->back_opacity); - canvas->cxWriteMode(ctxcanvas, canvas->write_mode); - canvas->cxLineStyle(ctxcanvas, canvas->line_style); - canvas->cxLineWidth(ctxcanvas, canvas->line_width); - canvas->cxLineCap(ctxcanvas, canvas->line_cap); - canvas->cxLineJoin(ctxcanvas, canvas->line_join); - canvas->cxHatch(ctxcanvas, canvas->hatch_style); - if (canvas->stipple) canvas->cxStipple(ctxcanvas, canvas->stipple_w, canvas->stipple_h, canvas->stipple); - if (canvas->pattern) canvas->cxPattern(ctxcanvas, canvas->pattern_w, canvas->pattern_h, canvas->pattern); - canvas->cxInteriorStyle(ctxcanvas, canvas->interior_style); - if (canvas->native_font[0] == 0) canvas->cxFont(ctxcanvas, canvas->font_type_face, canvas->font_style, canvas->font_size); - else canvas->cxNativeFont(ctxcanvas, canvas->native_font); -/* canvas->cxTextAlignment(ctxcanvas, canvas->text_alignment); */ -/* canvas->cxTextOrientation(ctxcanvas, canvas->text_orientation); */ - if (canvas->clip_mode == CD_CLIPAREA && canvas->cxClipArea) canvas->cxClipArea(ctxcanvas, canvas->clip_rect.xmin, canvas->clip_rect.xmax, canvas->clip_rect.ymin, canvas->clip_rect.ymax); -/* if (canvas->clip_mode == CD_CLIPAREA && canvas->cxFClipArea) canvas->cxFClipArea(ctxcanvas, canvas->clip_frect.xmin, canvas->clip_frect.xmax, canvas->clip_frect.ymin, canvas->clip_frect.ymax); */ - if (canvas->clip_mode == CD_CLIPPOLYGON && canvas->clip_poly) canvas->cxPoly(ctxcanvas, CD_CLIP, canvas->clip_poly, canvas->clip_poly_n); -/* if (canvas->clip_mode == CD_CLIPPOLYGON && canvas->clip_fpoly) canvas->cxFPoly(ctxcanvas, CD_CLIP, canvas->clip_fpoly, canvas->clip_poly_n); */ - if (canvas->clip_mode != CD_CLIPOFF) canvas->cxClip(ctxcanvas, canvas->clip_mode); + cdUpdateAttributes(canvas); } return CD_OK; -- cgit v1.2.3