From ab4d7bfdd3bdc646635e32b185bbe097ff262316 Mon Sep 17 00:00:00 2001 From: scuri Date: Fri, 30 Sep 2011 19:45:49 +0000 Subject: Fixed: PutImageRGBA and Pattern when using the Cairo context plus base driver for the Cairo 1.10 version. --- html/en/history.html | 6 +++++- mak.vc9/cdcairo.vcproj | 7 +++++++ src/cairo/cdcairo.c | 38 ++++++++++++++++++++++++++------------ test/simple/config.mak | 1 + test/simple/simple.c | 6 +++--- 5 files changed, 42 insertions(+), 16 deletions(-) diff --git a/html/en/history.html b/html/en/history.html index 0644c9b..eeb7526 100644 --- a/html/en/history.html +++ b/html/en/history.html @@ -27,7 +27,7 @@

History of Changes

-

CVS (27/Sep/2011)

+

CVS (30/Sep/2011)

Version 5.4.1 (09/Nov/2010)

diff --git a/mak.vc9/cdcairo.vcproj b/mak.vc9/cdcairo.vcproj index 662963f..e7a059b 100644 --- a/mak.vc9/cdcairo.vcproj +++ b/mak.vc9/cdcairo.vcproj @@ -129,6 +129,13 @@ + + + pattern) - cairo_pattern_destroy(ctxcanvas->pattern); + cairo_surface_mark_dirty(pattern_surface); - ctxcanvas->pattern = cairo_pattern_create_for_surface(pattern_surface); - cairo_pattern_reference(ctxcanvas->pattern); - cairo_pattern_set_extend(ctxcanvas->pattern, CAIRO_EXTEND_REPEAT); + pattern = cairo_pattern_create_for_surface(pattern_surface); + if (cairo_pattern_status(pattern) == CAIRO_STATUS_SUCCESS) + { + if (ctxcanvas->pattern) + cairo_pattern_destroy(ctxcanvas->pattern); + + ctxcanvas->pattern = pattern; + cairo_pattern_reference(ctxcanvas->pattern); + cairo_pattern_set_extend(ctxcanvas->pattern, CAIRO_EXTEND_REPEAT); + } cairo_surface_destroy(pattern_surface); } @@ -1336,6 +1343,7 @@ 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. */ + cairo_surface_flush(image_surface); data = (unsigned int*)cairo_image_surface_get_data(image_surface); stride = cairo_image_surface_get_stride(image_surface); offset = stride/4 - w; @@ -1392,6 +1400,7 @@ static void cdputimagerectrgb(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsi return; } + cairo_surface_flush(image_surface); data = (unsigned int*)cairo_image_surface_get_data(image_surface); stride = cairo_image_surface_get_stride(image_surface); offset = stride/4 - rw; @@ -1413,6 +1422,8 @@ static void cdputimagerectrgb(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsi data += offset; } + cairo_surface_mark_dirty(image_surface); + cairo_save (ctxcanvas->cr); cairo_rectangle(ctxcanvas->cr, x, y, w, h); @@ -1444,9 +1455,6 @@ 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) { @@ -1454,6 +1462,7 @@ static void cdputimagerectrgba(cdCtxCanvas *ctxcanvas, int iw, int ih, const uns return; } + cairo_surface_flush(image_surface); data = (unsigned int*)cairo_image_surface_get_data(image_surface); stride = cairo_image_surface_get_stride(image_surface); offset = stride/4 - rw; @@ -1475,6 +1484,8 @@ static void cdputimagerectrgba(cdCtxCanvas *ctxcanvas, int iw, int ih, const uns data += offset; } + cairo_surface_mark_dirty(image_surface); + cairo_save (ctxcanvas->cr); cairo_rectangle(ctxcanvas->cr, x, y, w, h); @@ -1530,6 +1541,7 @@ static void cdputimagerectmap(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsi return; } + cairo_surface_flush(image_surface); data = (unsigned int*)cairo_image_surface_get_data(image_surface); stride = cairo_image_surface_get_stride(image_surface); offset = stride/4 - rw; @@ -1558,6 +1570,8 @@ static void cdputimagerectmap(cdCtxCanvas *ctxcanvas, int iw, int ih, const unsi data += offset; } + cairo_surface_mark_dirty(image_surface); + cairo_save (ctxcanvas->cr); cairo_rectangle(ctxcanvas->cr, x, y, w, h); diff --git a/test/simple/config.mak b/test/simple/config.mak index b0d39bc..09e0029 100644 --- a/test/simple/config.mak +++ b/test/simple/config.mak @@ -61,6 +61,7 @@ else ifndef GDK_CAIRO SLIB += $(CDLIB)/libcdcontextplus.a LIBS = Xrender Xft +# USE_CAIRO=Yes endif ifdef USE_OPENGL SLIB += $(CDLIB)/libcdgl.a $(CDLIB)/libftgl.a diff --git a/test/simple/simple.c b/test/simple/simple.c index f3b17fe..3f8cf83 100644 --- a/test/simple/simple.c +++ b/test/simple/simple.c @@ -964,9 +964,9 @@ void SimpleDrawAll(cdCanvas* canvas) // cdPutImageRectRGB(16, 16, red, green, blue, 10, 10, 608, 608, 5, 10, 5, 10); // cdPutImageRectRGB(16, 16, red, green, blue, 10, 10, 64, 64, 5, 10, 5, 10); -// cdPutImageRGB(IMAGE_SIZE, IMAGE_SIZE, red, green, blue, 100, h - 200, IMAGE_SIZE, IMAGE_SIZE); -// cdPutImageRGBA(IMAGE_SIZE, IMAGE_SIZE, red, green, blue, alpha, 100, h - 200, IMAGE_SIZE, IMAGE_SIZE); -// cdPutImageRGB(IMAGE_SIZE, IMAGE_SIZE, red, green, blue, w - 400, h - 310, 3*IMAGE_SIZE, 3*IMAGE_SIZE); +// cdCanvasPutImageRectRGB(canvas, IMAGE_SIZE, IMAGE_SIZE, red, green, blue, 100, h - 200, IMAGE_SIZE, IMAGE_SIZE, 0, 0, 0, 0); +// cdCanvasPutImageRectRGBA(canvas, IMAGE_SIZE, IMAGE_SIZE, red, green, blue, alpha, 100, h - 200, IMAGE_SIZE, IMAGE_SIZE, 0, 0, 0, 0); +// cdCanvasPutImageRectRGB(canvas, IMAGE_SIZE, IMAGE_SIZE, red, green, blue, w - 400, h - 310, 3*IMAGE_SIZE, 3*IMAGE_SIZE, 0, 0, 0, 0); /* Draw the image on the top-right corner but increasing its actual size, and uses its full area */ cdCanvasPutImageRectRGBA(canvas, IMAGE_SIZE, IMAGE_SIZE, red, green, blue, alpha, w - 400, h - 310, 3*IMAGE_SIZE, 3*IMAGE_SIZE, 0, 0, 0, 0); -- cgit v1.2.3