[cairo-commit] 2 commits - src/cairo-image-surface.c test/glitz-surface-source.argb32.ref.png test/glitz-surface-source.ref.png test/glitz-surface-source.rgb24.ref.png test/image-surface-source.argb32.ref.png test/image-surface-source.ref.png test/image-surface-source.rgb24.ref.png test/Makefile.am test/pdf-surface-source.argb32.ref.png test/pdf-surface-source.ref.png test/pdf-surface-source.rgb24.ref.png test/ps-surface-source.argb32.ref.png test/ps-surface-source.ref.png test/ps-surface-source.rgb24.ref.png test/quartz-surface-source.argb32.ref.png test/quartz-surface-source.ref.png test/quartz-surface-source.rgb24.ref.png test/surface-source.c test/svg-surface-source.argb32.ref.png test/svg-surface-source.ref.png test/svg-surface-source.rgb24.ref.png test/test-fallback16-surface-source.ref.png test/xlib-surface-source.argb32.ref.png test/xlib-surface-source.ref.png test/xlib-surface-source.rgb24.ref.png

Chris Wilson ickle at kemper.freedesktop.org
Wed Sep 23 07:38:21 PDT 2009


 dev/null                                  |binary
 src/cairo-image-surface.c                 |   26 +++++++++++++++++----
 test/Makefile.am                          |   18 +++++++++-----
 test/glitz-surface-source.argb32.ref.png  |binary
 test/glitz-surface-source.rgb24.ref.png   |binary
 test/image-surface-source.argb32.ref.png  |binary
 test/image-surface-source.rgb24.ref.png   |binary
 test/pdf-surface-source.argb32.ref.png    |binary
 test/pdf-surface-source.rgb24.ref.png     |binary
 test/ps-surface-source.argb32.ref.png     |binary
 test/ps-surface-source.rgb24.ref.png      |binary
 test/quartz-surface-source.argb32.ref.png |binary
 test/quartz-surface-source.rgb24.ref.png  |binary
 test/surface-source.c                     |   37 ++++++++++++++++++++++++++++--
 test/svg-surface-source.argb32.ref.png    |binary
 test/svg-surface-source.rgb24.ref.png     |binary
 test/xlib-surface-source.argb32.ref.png   |binary
 test/xlib-surface-source.rgb24.ref.png    |binary
 18 files changed, 69 insertions(+), 12 deletions(-)

New commits:
commit 07ee9cfbf07deba228e73d26b419a4e130de24e3
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Sep 23 15:33:23 2009 +0100

    [image] Do assumption initial user data is cleared.
    
    Benjamin Otte pointed out the error of my ways that a clear on a
    cairo_image_surface_create_for_data() was not working. This is because I
    modified the image surface to skip clears when it knows the target data
    has been cleared. This flag must be reset when the user interacts with
    the surface, such as providing the initial surface data.

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 3b23200..8ad259d 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -542,6 +542,7 @@ cairo_image_surface_create_for_data (unsigned char     *data,
 				     int		stride)
 {
     pixman_format_code_t pixman_format;
+    cairo_surface_t *surface;
     int minstride;
 
     if (! CAIRO_FORMAT_VALID (format))
@@ -562,9 +563,16 @@ cairo_image_surface_create_for_data (unsigned char     *data,
     }
 
     pixman_format = _cairo_format_to_pixman_format_code (format);
-
-    return _cairo_image_surface_create_with_pixman_format (data, pixman_format,
-							   width, height, stride);
+    surface = _cairo_image_surface_create_with_pixman_format (data,
+							      pixman_format,
+							      width, height,
+							      stride);
+    if (unlikely (surface->status))
+	return surface;
+
+    /* we can not make any assumptions by the initial state of the data */
+    ((cairo_image_surface_t *) surface)->is_clear = FALSE;
+    return surface;
 }
 slim_hidden_def (cairo_image_surface_create_for_data);
 
@@ -1610,6 +1618,16 @@ _cairo_image_surface_get_font_options (void                  *abstract_surface,
     cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
 }
 
+static cairo_status_t
+_cairo_image_surface_mark_dirty_rectangle (void *abstract_surface,
+					   int x, int y,
+					   int width, int height)
+{
+    cairo_image_surface_t *surface = abstract_surface;
+    surface->is_clear = FALSE;
+    return CAIRO_STATUS_SUCCESS;
+}
+
 static cairo_int_status_t
 _cairo_image_surface_paint (void *abstract_surface,
 			    cairo_operator_t	 op,
@@ -1663,7 +1681,7 @@ const cairo_surface_backend_t _cairo_image_surface_backend = {
     NULL, /* old_show_glyphs */
     _cairo_image_surface_get_font_options,
     NULL, /* flush */
-    NULL, /* mark_dirty_rectangle */
+    _cairo_image_surface_mark_dirty_rectangle,
     NULL, /* font_fini */
     NULL, /* glyph_fini */
 
commit 9948b5180aa4312b3184d9ba46e9ad6f0d8e700c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Sep 22 18:20:03 2009 +0100

    [test] Revamp surface-source
    
    Include a translucent region in the source that exercises the xlib bug
    that I'm trying to fix. Hmm.

diff --git a/test/Makefile.am b/test/Makefile.am
index 0428052..b8174f6 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -548,7 +548,8 @@ REFERENCE_IMAGES = \
 	huge-radial.ref.png \
 	image-surface-source.ps2.ref.png \
 	image-surface-source.ps3.ref.png \
-	image-surface-source.ref.png \
+	image-surface-source.rgb24.ref.png \
+	image-surface-source.argb32.ref.png \
 	image-surface-source.svg12.argb32.xfail.png \
 	image-surface-source.svg12.rgb24.xfail.png \
 	implicit-close.ref.png \
@@ -747,12 +748,14 @@ REFERENCE_IMAGES = \
 	path-append.xlib-fallback.ref.png \
 	path-append.xlib.ref.png \
 	pattern-getters.ref.png \
-	pdf-surface-source.ref.png \
+	pdf-surface-source.rgb24.ref.png \
+	pdf-surface-source.argb32.ref.png \
 	pdf-surface-source.svg12.argb32.xfail.png \
 	pdf-surface-source.svg12.rgb24.xfail.png \
 	pixman-rotate.ref.png \
 	pixman-rotate.rgb24.ref.png \
-	ps-surface-source.ref.png \
+	ps-surface-source.rgb24.ref.png \
+	ps-surface-source.argb32.ref.png \
 	ps-surface-source.svg12.argb32.xfail.png \
 	ps-surface-source.svg12.rgb24.xfail.png \
 	push-group.ref.png \
@@ -761,9 +764,10 @@ REFERENCE_IMAGES = \
 	push-group.xlib.rgb24.ref.png \
 	push-group-color.ref.png \
 	push-group-color.xlib.ref.png \
+	quartz-surface-source.rgb24.ref.png \
+	quartz-surface-source.argb32.ref.png \
 	quartz-surface-source.ps2.ref.png \
 	quartz-surface-source.ps3.ref.png \
-	quartz-surface-source.ref.png \
 	radial-gradient.pdf.ref.png \
 	radial-gradient.quartz.ref.png \
 	radial-gradient.ref.png \
@@ -922,7 +926,8 @@ REFERENCE_IMAGES = \
 	surface-pattern.ps.xfail.png \
 	surface-pattern.ref.png \
 	surface-pattern.svg.xfail.png \
-	svg-surface-source.ref.png \
+	svg-surface-source.rgb24.ref.png \
+	svg-surface-source.argb32.ref.png \
 	svg-surface-source.svg12.argb32.xfail.png \
 	svg-surface-source.svg12.rgb24.xfail.png \
 	test-fallback16-surface-source.ps.ref.png \
@@ -1023,9 +1028,10 @@ REFERENCE_IMAGES = \
 	user-font.svg.ref.png \
 	user-font.xlib.ref.png \
 	xlib-expose-event.ref.png \
+	xlib-surface-source.rgb24.ref.png \
+	xlib-surface-source.argb32.ref.png \
 	xlib-surface-source.ps2.ref.png \
 	xlib-surface-source.ps3.ref.png \
-	xlib-surface-source.ref.png \
 	xlib-surface-source.svg12.argb32.xfail.png \
 	xlib-surface-source.svg12.rgb24.xfail.png \
 	zero-alpha.ref.png
diff --git a/test/glitz-surface-source.argb32.ref.png b/test/glitz-surface-source.argb32.ref.png
new file mode 100644
index 0000000..0182972
Binary files /dev/null and b/test/glitz-surface-source.argb32.ref.png differ
diff --git a/test/glitz-surface-source.ref.png b/test/glitz-surface-source.ref.png
deleted file mode 100644
index 3fa8bbe..0000000
Binary files a/test/glitz-surface-source.ref.png and /dev/null differ
diff --git a/test/glitz-surface-source.rgb24.ref.png b/test/glitz-surface-source.rgb24.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/glitz-surface-source.rgb24.ref.png differ
diff --git a/test/image-surface-source.argb32.ref.png b/test/image-surface-source.argb32.ref.png
new file mode 100644
index 0000000..0182972
Binary files /dev/null and b/test/image-surface-source.argb32.ref.png differ
diff --git a/test/image-surface-source.ref.png b/test/image-surface-source.ref.png
deleted file mode 100644
index 9fbbedd..0000000
Binary files a/test/image-surface-source.ref.png and /dev/null differ
diff --git a/test/image-surface-source.rgb24.ref.png b/test/image-surface-source.rgb24.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/image-surface-source.rgb24.ref.png differ
diff --git a/test/pdf-surface-source.argb32.ref.png b/test/pdf-surface-source.argb32.ref.png
new file mode 100644
index 0000000..0182972
Binary files /dev/null and b/test/pdf-surface-source.argb32.ref.png differ
diff --git a/test/pdf-surface-source.ref.png b/test/pdf-surface-source.ref.png
deleted file mode 100644
index 3fa8bbe..0000000
Binary files a/test/pdf-surface-source.ref.png and /dev/null differ
diff --git a/test/pdf-surface-source.rgb24.ref.png b/test/pdf-surface-source.rgb24.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/pdf-surface-source.rgb24.ref.png differ
diff --git a/test/ps-surface-source.argb32.ref.png b/test/ps-surface-source.argb32.ref.png
new file mode 100644
index 0000000..0182972
Binary files /dev/null and b/test/ps-surface-source.argb32.ref.png differ
diff --git a/test/ps-surface-source.ref.png b/test/ps-surface-source.ref.png
deleted file mode 100644
index 3fa8bbe..0000000
Binary files a/test/ps-surface-source.ref.png and /dev/null differ
diff --git a/test/ps-surface-source.rgb24.ref.png b/test/ps-surface-source.rgb24.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/ps-surface-source.rgb24.ref.png differ
diff --git a/test/quartz-surface-source.argb32.ref.png b/test/quartz-surface-source.argb32.ref.png
new file mode 100644
index 0000000..0182972
Binary files /dev/null and b/test/quartz-surface-source.argb32.ref.png differ
diff --git a/test/quartz-surface-source.ref.png b/test/quartz-surface-source.ref.png
deleted file mode 100644
index 9fbbedd..0000000
Binary files a/test/quartz-surface-source.ref.png and /dev/null differ
diff --git a/test/quartz-surface-source.rgb24.ref.png b/test/quartz-surface-source.rgb24.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/quartz-surface-source.rgb24.ref.png differ
diff --git a/test/surface-source.c b/test/surface-source.c
index 5d978f2..bd047c9 100644
--- a/test/surface-source.c
+++ b/test/surface-source.c
@@ -34,16 +34,22 @@ static cairo_surface_t *create_source_surface (int size);
  */
 #define SOURCE_SIZE 2000
 #define INTER_SIZE 512
-#define SIZE 90
+#define SIZE 96
 
 static void
 draw_pattern (cairo_surface_t **surface_inout, int surface_size)
 {
     cairo_t *cr;
+    int mid = surface_size/2;
 
     cr = cairo_create (*surface_inout);
     cairo_surface_destroy (*surface_inout);
 
+    cairo_rectangle (cr, 0, 0, surface_size, surface_size);
+    cairo_rectangle (cr, mid - SIZE/4, mid + SIZE/4, SIZE/2, -SIZE/2);
+    cairo_clip (cr);
+
+    /* outside squares -> opaque */
     cairo_set_source_rgb (cr, 1, 1, 1);
     cairo_rectangle (cr,
 		     0, 0,
@@ -65,6 +71,33 @@ draw_pattern (cairo_surface_t **surface_inout, int surface_size)
 		     surface_size / 2, surface_size / 2);
     cairo_fill (cr);
 
+    cairo_reset_clip (cr);
+    cairo_rectangle (cr, mid - SIZE/4, mid - SIZE/4, SIZE/2, SIZE/2);
+    cairo_clip (cr);
+
+    /* inside squares -> translucent */
+    cairo_set_source_rgba (cr, 0, 0, 1, .5);
+    cairo_rectangle (cr,
+		     0, 0,
+		     surface_size / 2, surface_size / 2);
+    cairo_fill (cr);
+    cairo_set_source_rgba (cr, 0, 1, 0, .5);
+    cairo_rectangle (cr,
+		     surface_size / 2, 0,
+		     surface_size / 2, surface_size / 2);
+    cairo_fill (cr);
+    cairo_set_source_rgba (cr, 1, 0, 0, .5);
+    cairo_rectangle (cr,
+		     0, surface_size / 2,
+		     surface_size / 2, surface_size / 2);
+    cairo_fill (cr);
+    cairo_set_source_rgba (cr, 1, 1, 1, .5);
+    cairo_rectangle (cr,
+		     surface_size / 2, surface_size / 2,
+		     surface_size / 2, surface_size / 2);
+    cairo_fill (cr);
+
+
     *surface_inout = cairo_surface_reference (cairo_get_target (cr));
     cairo_destroy (cr);
 }
@@ -101,7 +134,7 @@ draw (cairo_t *cr, int width, int height)
 			      (width - INTER_SIZE)/2,
 			      (height - INTER_SIZE)/2);
     cairo_destroy (cr2);
-    cairo_rectangle (cr, 15, 15, 60, 60);
+    cairo_rectangle (cr, 16, 16, 64, 64);
     cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
     cairo_fill (cr);
 
diff --git a/test/svg-surface-source.argb32.ref.png b/test/svg-surface-source.argb32.ref.png
new file mode 100644
index 0000000..0182972
Binary files /dev/null and b/test/svg-surface-source.argb32.ref.png differ
diff --git a/test/svg-surface-source.ref.png b/test/svg-surface-source.ref.png
deleted file mode 100644
index 3fa8bbe..0000000
Binary files a/test/svg-surface-source.ref.png and /dev/null differ
diff --git a/test/svg-surface-source.rgb24.ref.png b/test/svg-surface-source.rgb24.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/svg-surface-source.rgb24.ref.png differ
diff --git a/test/test-fallback16-surface-source.ref.png b/test/test-fallback16-surface-source.ref.png
deleted file mode 100644
index 3fa8bbe..0000000
Binary files a/test/test-fallback16-surface-source.ref.png and /dev/null differ
diff --git a/test/xlib-surface-source.argb32.ref.png b/test/xlib-surface-source.argb32.ref.png
new file mode 100644
index 0000000..0182972
Binary files /dev/null and b/test/xlib-surface-source.argb32.ref.png differ
diff --git a/test/xlib-surface-source.ref.png b/test/xlib-surface-source.ref.png
deleted file mode 100644
index 3fa8bbe..0000000
Binary files a/test/xlib-surface-source.ref.png and /dev/null differ
diff --git a/test/xlib-surface-source.rgb24.ref.png b/test/xlib-surface-source.rgb24.ref.png
new file mode 100644
index 0000000..0d68a82
Binary files /dev/null and b/test/xlib-surface-source.rgb24.ref.png differ


More information about the cairo-commit mailing list