[cairo-commit] test/any2ppm.c test/pdf2png.c

Chris Wilson ickle at kemper.freedesktop.org
Fri Jun 11 06:12:43 PDT 2010


 test/any2ppm.c |    9 ++++++---
 test/pdf2png.c |    9 ++++++---
 2 files changed, 12 insertions(+), 6 deletions(-)

New commits:
commit f74b11415a1f7682dd50c222baa8815ef93681dc
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Jun 11 14:06:15 2010 +0100

    test: Use a group to render PDF correctly using poppler.
    
    In order to support blend modes, we need to use a clear background
    whilst rendering the PDF, which inspired the use of DEST_OVER to avoid
    having to render to an intermediate surface. However, the adjunct of
    using subpixel text means that we cannot simply using the alpha channel
    as the sole mask and so need to render to an intermediate and paint it
    over an opaque background.

diff --git a/test/any2ppm.c b/test/any2ppm.c
index 55b4c7e..b4c9de6 100644
--- a/test/any2ppm.c
+++ b/test/any2ppm.c
@@ -357,14 +357,17 @@ _poppler_render_page (const char *filename,
 
     poppler_page_get_size (page, &width, &height);
 
-    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+    surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
     cr = cairo_create (surface);
 
+    cairo_set_source_rgb (cr, 1., 1., 1.);
+    cairo_paint (cr);
+    cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR_ALPHA);
+
     poppler_page_render (page, cr);
     g_object_unref (page);
 
-    cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
-    cairo_set_source_rgb (cr, 1., 1., 1.);
+    cairo_pop_group_to_source (cr);
     cairo_paint (cr);
 
     status = cairo_status (cr);
diff --git a/test/pdf2png.c b/test/pdf2png.c
index f60170c..06fa05b 100644
--- a/test/pdf2png.c
+++ b/test/pdf2png.c
@@ -74,15 +74,18 @@ int main (int argc, char *argv[])
 
     poppler_page_get_size (page, &width, &height);
 
-    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+    surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
     cr = cairo_create (surface);
     cairo_surface_destroy (surface);
 
+    cairo_set_source_rgb (cr, 1,1,1);
+    cairo_paint (cr);
+    cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR_ALPHA);
+
     poppler_page_render (page, cr);
     g_object_unref (page);
 
-    cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
-    cairo_set_source_rgb (cr, 1., 1., 1.);
+    cairo_pop_group_to_source (cr);
     cairo_paint (cr);
 
     status = cairo_surface_write_to_png (cairo_get_target (cr),


More information about the cairo-commit mailing list