diff options
author | scuri <scuri> | 2011-09-30 19:45:49 +0000 |
---|---|---|
committer | scuri <scuri> | 2011-09-30 19:45:49 +0000 |
commit | ab4d7bfdd3bdc646635e32b185bbe097ff262316 (patch) | |
tree | 52d5ab9dfcbeb560fda5be1ef94d1cc440a161c9 | |
parent | 18dc8b841de3c7acf274fe4a2fb21a37091c6cb0 (diff) |
Fixed: PutImageRGBA and Pattern when using the Cairo context plus base driver for the Cairo 1.10 version.HEADoriginmaster
-rw-r--r-- | html/en/history.html | 6 | ||||
-rw-r--r-- | mak.vc9/cdcairo.vcproj | 7 | ||||
-rw-r--r-- | src/cairo/cdcairo.c | 38 | ||||
-rw-r--r-- | test/simple/config.mak | 1 | ||||
-rw-r--r-- | 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 @@ <body> <h2>History of Changes</h2> -<h3>CVS (27/Sep/2011)</h3> +<h3>CVS (30/Sep/2011)</h3> <ul> <li><span class="hist_new">New:</span> functions <strong>cdContextIsPlus</strong> and <strong>cdContextType</strong>.</li> @@ -47,6 +47,10 @@ mso-fareast-language:PT-BR;mso-bidi-language:AR-SA">CD_RGBA.</span></li> <li> <span class="hist_fixed">Fixed:</span> documentation of <strong> YAxisMode</strong>.</li> + <li> + <span class="hist_fixed">Fixed:</span> + <strong>PutImageRGBA</strong> and <strong>Pattern</strong> when using the Cairo context plus base + driver for the Cairo 1.10 version.</li> </ul> <h3><a href="http://sourceforge.net/projects/canvasdraw/files/5.4.1/">Version 5.4.1</a> (09/Nov/2010)</h3> 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 @@ <File RelativePath="..\src\cairo\cdcaironative_gdk.c" > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + /> + </FileConfiguration> </File> <File RelativePath="..\src\cairo\cdcaironative_win32.c" diff --git a/src/cairo/cdcairo.c b/src/cairo/cdcairo.c index f950cc8..f6e69f8 100644 --- a/src/cairo/cdcairo.c +++ b/src/cairo/cdcairo.c @@ -220,7 +220,9 @@ static int cdclip(cdCtxCanvas *ctxcanvas, int mode) static unsigned int sEncodeRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { - /* Pre-multiplied alpha */ + /* 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.) */ if (a != 255) { r = CD_ALPHAPRE(r, a); @@ -240,10 +242,8 @@ static void make_pattern(cdCtxCanvas *ctxcanvas, int n, int m, void* userdata, i unsigned char r, g, b, a; cairo_surface_t* pattern_surface; unsigned int* data; + cairo_pattern_t *pattern; - /* 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) { @@ -251,6 +251,7 @@ static void make_pattern(cdCtxCanvas *ctxcanvas, int n, int m, void* userdata, i return; } + cairo_surface_flush(pattern_surface); data = (unsigned int*)cairo_image_surface_get_data(pattern_surface); stride = cairo_image_surface_get_stride(pattern_surface); offset = stride/4 - n; @@ -278,12 +279,18 @@ static void make_pattern(cdCtxCanvas *ctxcanvas, int n, int m, void* userdata, i data += offset; } - if (ctxcanvas->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); |