[cairo-commit] 8 commits - src/cairo-paginated-surface.c src/cairo-pdf-operators.c src/cairo-ps-surface.c src/cairo-scaled-font.c src/cairo-scaled-font-private.h src/cairo-type3-glyph-surface.c test/Makefile.am test/Makefile.sources test/subsurface-modify-child.c test/subsurface-modify-child.ref.png test/subsurface-modify-parent.c test/subsurface-modify-parent.ref.png test/subsurface-pad.c test/subsurface-pad.ref.png

Chris Wilson ickle at kemper.freedesktop.org
Tue May 4 11:16:24 PDT 2010


 src/cairo-paginated-surface.c         |    2 
 src/cairo-pdf-operators.c             |    3 -
 src/cairo-ps-surface.c                |    4 -
 src/cairo-scaled-font-private.h       |    2 
 src/cairo-scaled-font.c               |   46 +++++++--------
 src/cairo-type3-glyph-surface.c       |    8 --
 test/Makefile.am                      |    3 +
 test/Makefile.sources                 |    3 +
 test/subsurface-modify-child.c        |   98 ++++++++++++++++++++++++++++++++++
 test/subsurface-modify-child.ref.png  |binary
 test/subsurface-modify-parent.c       |   77 ++++++++++++++++++++++++++
 test/subsurface-modify-parent.ref.png |binary
 test/subsurface-pad.c                 |   76 ++++++++++++++++++++++++++
 test/subsurface-pad.ref.png           |binary
 14 files changed, 287 insertions(+), 35 deletions(-)

New commits:
commit 4a46c715564c886e7434d65625fb84b5d87c0970
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 4 18:51:30 2010 +0100

    type3: Minor tweaks to remove a redundant check.

diff --git a/src/cairo-type3-glyph-surface.c b/src/cairo-type3-glyph-surface.c
index 15cfadd..74257d4 100644
--- a/src/cairo-type3-glyph-surface.c
+++ b/src/cairo-type3-glyph-surface.c
@@ -430,7 +430,6 @@ _cairo_type3_glyph_surface_analyze_glyph (void		     *abstract_surface,
     _cairo_scaled_font_freeze_cache (surface->scaled_font);
     status = _cairo_scaled_glyph_lookup (surface->scaled_font,
 					 glyph_index,
-					 CAIRO_SCALED_GLYPH_INFO_METRICS |
 					 CAIRO_SCALED_GLYPH_INFO_RECORDING_SURFACE,
 					 &scaled_glyph);
 
@@ -447,10 +446,7 @@ _cairo_type3_glyph_surface_analyze_glyph (void		     *abstract_surface,
     if (unlikely (status))
 	goto cleanup;
 
-    status2 = _cairo_pdf_operators_flush (&surface->pdf_operators);
-    if (status == CAIRO_STATUS_SUCCESS)
-	status = status2;
-
+    status = _cairo_pdf_operators_flush (&surface->pdf_operators);
     if (status == CAIRO_INT_STATUS_IMAGE_FALLBACK)
 	status = CAIRO_STATUS_SUCCESS;
 
@@ -507,7 +503,7 @@ _cairo_type3_glyph_surface_emit_glyph (void		     *abstract_surface,
     status2 = cairo_matrix_invert (&font_matrix_inverse);
 
     /* The invertability of font_matrix is tested in
-     * pdf_operators_show_glyphs before any glyphs are mappped to the
+     * pdf_operators_show_glyphs before any glyphs are mapped to the
      * subset. */
     assert (status2 == CAIRO_STATUS_SUCCESS);
 
commit 11531b90a2317bb1113b187d6aa9c5083f5ecaa1
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 4 18:50:58 2010 +0100

    ps: Force finish of the type3 glyph surfaces.

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index fc69669..2e46781 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -532,6 +532,7 @@ _cairo_ps_surface_analyze_user_font_subset (cairo_scaled_font_subset_t *font_sub
 	    break;
 
     }
+    cairo_surface_finish (type3_surface);
     cairo_surface_destroy (type3_surface);
 
     return status;
@@ -616,6 +617,7 @@ _cairo_ps_surface_emit_type3_font_subset (cairo_ps_surface_t		*surface,
                 font_bbox.p2.y = bbox.p2.y;
         }
     }
+    cairo_surface_finish (type3_surface);
     cairo_surface_destroy (type3_surface);
     if (unlikely (status))
 	return status;
commit 5155ebeaa25815124124db2599336ab2ddbe7413
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 4 18:50:27 2010 +0100

    pdf: Assert that no other error can occur for an invertible matrix.

diff --git a/src/cairo-pdf-operators.c b/src/cairo-pdf-operators.c
index 11911dc..601011a 100644
--- a/src/cairo-pdf-operators.c
+++ b/src/cairo-pdf-operators.c
@@ -1381,8 +1381,7 @@ _cairo_pdf_operators_show_text_glyphs (cairo_pdf_operators_t	  *pdf_operators,
     status = cairo_matrix_invert (&pdf_operators->font_matrix_inverse);
     if (status == CAIRO_STATUS_INVALID_MATRIX)
 	return CAIRO_STATUS_SUCCESS;
-    if (unlikely (status))
-	return status;
+    assert (status == CAIRO_STATUS_SUCCESS);
 
     pdf_operators->is_new_text_object = FALSE;
     if (pdf_operators->in_text_object == FALSE) {
commit d9259bd06822c871a4c653f395cfc1f933caaeb7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 4 18:49:55 2010 +0100

    paginated: Mark as clear initially.

diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index 98260b8..af4790e 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -122,6 +122,7 @@ _cairo_paginated_surface_create (cairo_surface_t				*target,
 	goto FAIL_CLEANUP_SURFACE;
 
     surface->page_num = 1;
+    surface->base.is_clear = TRUE;
 
     return &surface->base;
 
@@ -485,6 +486,7 @@ _cairo_paginated_surface_show_page (void *abstract_surface)
 	    return status;
 
 	surface->page_num++;
+	surface->base.is_clear = TRUE;
     }
 
     return CAIRO_STATUS_SUCCESS;
commit bc14e0e953630d47a65e701a377631e406eb080c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon May 3 14:18:33 2010 +0100

    scaled-font: Convert to cairo_list_t
    
    Convert the open-coded doubly-linked list of glyph pages for a font into
    the common cairo_list_t.

diff --git a/src/cairo-scaled-font-private.h b/src/cairo-scaled-font-private.h
index a1e7da5..029377b 100644
--- a/src/cairo-scaled-font-private.h
+++ b/src/cairo-scaled-font-private.h
@@ -108,7 +108,7 @@ struct _cairo_scaled_font {
     cairo_mutex_t mutex;
 
     cairo_hash_table_t *glyphs;
-    cairo_scaled_glyph_page_t *glyph_pages;
+    cairo_list_t glyph_pages;
     cairo_bool_t cache_frozen;
     cairo_bool_t global_cache_frozen;
 
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index ce92354..f4b3558 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -69,7 +69,7 @@ static cairo_cache_t cairo_scaled_glyph_page_cache;
 struct _cairo_scaled_glyph_page {
     cairo_cache_entry_t cache_entry;
 
-    struct _cairo_scaled_glyph_page *prev, *next;
+    cairo_list_t link;
 
     unsigned int num_glyphs;
     cairo_scaled_glyph_t glyphs[CAIRO_SCALED_GLYPH_PAGE_SIZE];
@@ -228,7 +228,7 @@ static const cairo_scaled_font_t _cairo_scaled_font_nil = {
     { 0., 0., 0., 0., 0. },	/* fs_extents */
     CAIRO_MUTEX_NIL_INITIALIZER,/* mutex */
     NULL,			/* glyphs */
-    NULL,			/* pages */
+    { NULL, NULL },		/* pages */
     FALSE,			/* cache_frozen */
     FALSE,			/* global_cache_frozen */
     NULL,			/* surface_backend */
@@ -440,13 +440,7 @@ _cairo_scaled_glyph_page_destroy (void *closure)
 	_cairo_scaled_glyph_fini (scaled_font, &page->glyphs[n]);
     }
 
-    if (page->prev != NULL)
-	page->prev->next = page->next;
-    else
-	scaled_font->glyph_pages = page->next;
-
-    if (page->next != NULL)
-	page->next->prev = page->prev;
+    cairo_list_del (&page->link);
 
     free (page);
 }
@@ -724,7 +718,7 @@ _cairo_scaled_font_init (cairo_scaled_font_t               *scaled_font,
     if (unlikely (scaled_font->glyphs == NULL))
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-    scaled_font->glyph_pages = NULL;
+    cairo_list_init (&scaled_font->glyph_pages);
     scaled_font->cache_frozen = FALSE;
     scaled_font->global_cache_frozen = FALSE;
 
@@ -781,9 +775,11 @@ _cairo_scaled_font_reset_cache (cairo_scaled_font_t *scaled_font)
     assert (! scaled_font->cache_frozen);
 
     CAIRO_MUTEX_LOCK (_cairo_scaled_glyph_page_cache_mutex);
-    while (scaled_font->glyph_pages != NULL) {
+    while (! cairo_list_is_empty (&scaled_font->glyph_pages)) {
 	_cairo_cache_remove (&cairo_scaled_glyph_page_cache,
-			     &scaled_font->glyph_pages->cache_entry);
+                             &cairo_list_first_entry (&scaled_font->glyph_pages,
+                                                      cairo_scaled_glyph_page_t,
+                                                      link)->cache_entry);
     }
     CAIRO_MUTEX_UNLOCK (_cairo_scaled_glyph_page_cache_mutex);
 }
@@ -2579,10 +2575,14 @@ _cairo_scaled_font_allocate_glyph (cairo_scaled_font_t *scaled_font,
     cairo_status_t status;
 
     /* only the first page in the list may contain available slots */
-    page = scaled_font->glyph_pages;
-    if (page != NULL && page->num_glyphs < CAIRO_SCALED_GLYPH_PAGE_SIZE) {
-	*scaled_glyph = &page->glyphs[page->num_glyphs++];
-	return CAIRO_STATUS_SUCCESS;
+    if (! cairo_list_is_empty (&scaled_font->glyph_pages)) {
+        page = cairo_list_last_entry (&scaled_font->glyph_pages,
+                                      cairo_scaled_glyph_page_t,
+                                      link);
+        if (page->num_glyphs < CAIRO_SCALED_GLYPH_PAGE_SIZE) {
+            *scaled_glyph = &page->glyphs[page->num_glyphs++];
+            return CAIRO_STATUS_SUCCESS;
+        }
     }
 
     page = malloc (sizeof (cairo_scaled_glyph_page_t));
@@ -2620,11 +2620,7 @@ _cairo_scaled_font_allocate_glyph (cairo_scaled_font_t *scaled_font,
 	return status;
     }
 
-    page->next = scaled_font->glyph_pages;
-    page->prev = NULL;
-    if (scaled_font->glyph_pages != NULL)
-	scaled_font->glyph_pages->prev = page;
-    scaled_font->glyph_pages = page;
+    cairo_list_add (&page->link, &scaled_font->glyph_pages);
 
     *scaled_glyph = &page->glyphs[page->num_glyphs++];
     return CAIRO_STATUS_SUCCESS;
@@ -2636,15 +2632,17 @@ _cairo_scaled_font_free_last_glyph (cairo_scaled_font_t *scaled_font,
 {
     cairo_scaled_glyph_page_t *page;
 
-    page = scaled_font->glyph_pages;
-    assert (page != NULL && scaled_glyph == &page->glyphs[page->num_glyphs-1]);
+    assert (! cairo_list_is_empty (&scaled_font->glyph_pages));
+    page = cairo_list_last_entry (&scaled_font->glyph_pages,
+                                  cairo_scaled_glyph_page_t,
+                                  link);
+    assert (scaled_glyph == &page->glyphs[page->num_glyphs-1]);
 
     _cairo_scaled_glyph_fini (scaled_font, scaled_glyph);
 
     if (--page->num_glyphs == 0) {
 	_cairo_cache_remove (&cairo_scaled_glyph_page_cache,
 		             &page->cache_entry);
-	assert (scaled_font->glyph_pages != page);
     }
 }
 
commit 627527693c38c328fdb79058f5299609c0031029
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon May 3 13:41:41 2010 +0100

    ps: Remove the fill stroke command
    
    This is not supported by PostScript, so eliminate it from the prologue.

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 13ccb0b..fc69669 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -257,8 +257,6 @@ _cairo_ps_surface_emit_header (cairo_ps_surface_t *surface)
 				 "/S { stroke } bind def\n"
 				 "/f { fill } bind def\n"
 				 "/f* { eofill } bind def\n"
-				 "/B { fill stroke } bind def\n"
-				 "/B* { eofill stroke } bind def\n"
 				 "/n { newpath } bind def\n"
 				 "/W { clip } bind def\n"
 				 "/W* { eoclip } bind def\n"
commit 4dd92ef2bc877eb197f096c3eb8fe74cb2e7b099
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun May 2 14:35:59 2010 +0100

    test: Add subsurface-pad
    
    Round out the subsurface tests with PAD.

diff --git a/test/Makefile.am b/test/Makefile.am
index 622df8d..5950c37 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1075,6 +1075,7 @@ REFERENCE_IMAGES = \
 	subsurface.image16.ref.png \
 	subsurface-reflect.ref.png \
 	subsurface-repeat.ref.png \
+	subsurface-pad.ref.png \
 	subsurface-modify-child.ref.png \
 	subsurface-modify-parent.ref.png \
 	subsurface-similar-repeat.ref.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 5817097..2770fd4 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -228,6 +228,7 @@ test_sources = \
 	subsurface.c                                    \
 	subsurface-repeat.c                             \
 	subsurface-reflect.c                            \
+	subsurface-pad.c                                \
 	subsurface-modify-child.c                       \
 	subsurface-modify-parent.c                      \
 	subsurface-similar-repeat.c                     \
diff --git a/test/subsurface-pad.c b/test/subsurface-pad.c
new file mode 100644
index 0000000..05e6d72
--- /dev/null
+++ b/test/subsurface-pad.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2009 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Intel not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Intel makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * INTEL CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_surface_t *region;
+    cairo_t *cr_region;
+
+    cairo_set_source_rgb (cr, .5, .5, .5);
+    cairo_paint (cr);
+
+    /* fill the centre */
+    region = cairo_surface_create_for_rectangle (cairo_get_target (cr),
+						 20, 20, 20, 20);
+    cr_region = cairo_create (region);
+    cairo_surface_destroy (region);
+
+    cairo_set_source_rgb (cr_region, 1, 1, 1);
+    cairo_rectangle (cr_region, 0, 0, 10, 10);
+    cairo_fill (cr_region);
+
+    cairo_set_source_rgb (cr_region, 1, 0, 0);
+    cairo_rectangle (cr_region, 10, 0, 10, 10);
+    cairo_fill (cr_region);
+
+    cairo_set_source_rgb (cr_region, 0, 1, 0);
+    cairo_rectangle (cr_region, 0, 10, 10, 10);
+    cairo_fill (cr_region);
+
+    cairo_set_source_rgb (cr_region, 0, 0, 1);
+    cairo_rectangle (cr_region, 10, 10, 10, 10);
+    cairo_fill (cr_region);
+
+    cairo_set_source_surface (cr, cairo_get_target (cr_region), 20, 20);
+    cairo_destroy (cr_region);
+
+    /* reflect the pattern around the outside, but do not overwrite...*/
+    cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_PAD);
+    cairo_rectangle (cr, 0, 0, width, height);
+    cairo_rectangle (cr, 20, 40, 20, -20);
+    cairo_fill (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (subsurface_pad,
+	    "Tests source clipping with pad",
+	    "subsurface, pad", /* keywords */
+	    NULL, /* requirements */
+	    60, 60,
+	    NULL, draw)
diff --git a/test/subsurface-pad.ref.png b/test/subsurface-pad.ref.png
new file mode 100644
index 0000000..eeb9f8f
Binary files /dev/null and b/test/subsurface-pad.ref.png differ
commit 85e3cffde164a5af444639dfd182fde2448809ee
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Apr 30 21:09:01 2010 +0100

    test: Add subsurface-modify-{child,parent}
    
    Add tests to ensure that modifications to the subsurface via the
    original surface are tracked by the subsurface, i.e. that any snapshots
    are detached upon modification of the parent as well as modification of
    itself and vice versa.

diff --git a/test/Makefile.am b/test/Makefile.am
index 8607a54..622df8d 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1075,6 +1075,8 @@ REFERENCE_IMAGES = \
 	subsurface.image16.ref.png \
 	subsurface-reflect.ref.png \
 	subsurface-repeat.ref.png \
+	subsurface-modify-child.ref.png \
+	subsurface-modify-parent.ref.png \
 	subsurface-similar-repeat.ref.png \
 	surface-pattern-big-scale-down.ref.png \
 	surface-pattern-big-scale-down.ps.xfail.png \
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 4224786..5817097 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -228,6 +228,8 @@ test_sources = \
 	subsurface.c                                    \
 	subsurface-repeat.c                             \
 	subsurface-reflect.c                            \
+	subsurface-modify-child.c                       \
+	subsurface-modify-parent.c                      \
 	subsurface-similar-repeat.c                     \
 	surface-finish-twice.c				\
 	surface-pattern.c				\
diff --git a/test/subsurface-modify-child.c b/test/subsurface-modify-child.c
new file mode 100644
index 0000000..3a1e8ff
--- /dev/null
+++ b/test/subsurface-modify-child.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2010 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Intel not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Intel makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * INTEL CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_surface_t *region, *similar;
+    cairo_t *cr_region, *cr_similar;
+
+    cairo_set_source_rgb (cr, .5, .5, .5);
+    cairo_paint (cr);
+
+    similar = cairo_surface_create_similar (cairo_get_target (cr),
+					    CAIRO_CONTENT_COLOR_ALPHA,
+					    20, 20);
+
+    /* copy the centre */
+    cr_similar = cairo_create (similar);
+    cairo_surface_destroy (similar);
+    cairo_set_source_surface (cr_similar, cairo_get_target (cr), -20, -20);
+    cairo_paint (cr_similar);
+    similar = cairo_surface_reference (cairo_get_target (cr_similar));
+    cairo_destroy (cr_similar);
+
+    /* fill the centre */
+    region = cairo_surface_create_for_rectangle (cairo_get_target (cr),
+						 20, 20, 20, 20);
+    cr_region = cairo_create (region);
+    cairo_surface_destroy (region);
+
+    cairo_set_source_rgb (cr_region, 1, 1, 1);
+    cairo_rectangle (cr_region, 0, 0, 10, 10);
+    cairo_fill (cr_region);
+
+    cairo_set_source_rgb (cr_region, 1, 0, 0);
+    cairo_rectangle (cr_region, 10, 0, 10, 10);
+    cairo_fill (cr_region);
+
+    cairo_set_source_rgb (cr_region, 0, 1, 0);
+    cairo_rectangle (cr_region, 0, 10, 10, 10);
+    cairo_fill (cr_region);
+
+    cairo_set_source_rgb (cr_region, 0, 0, 1);
+    cairo_rectangle (cr_region, 10, 10, 10, 10);
+    cairo_fill (cr_region);
+
+    cairo_destroy (cr_region);
+
+    /* copy the centre, again */
+    cr_similar = cairo_create (similar);
+    cairo_surface_destroy (similar);
+    cairo_set_source_surface (cr_similar, cairo_get_target (cr), -20, -20);
+    cairo_paint (cr_similar);
+    similar = cairo_surface_reference (cairo_get_target (cr_similar));
+    cairo_destroy (cr_similar);
+
+    /* repeat the pattern around the outside, but do not overwrite...*/
+    cairo_set_source_surface (cr, similar, 20, 20);
+    cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
+    cairo_rectangle (cr, 0, 0, width, height);
+    cairo_rectangle (cr, 20, 40, 20, -20);
+    cairo_fill (cr);
+
+    cairo_surface_destroy (similar);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (subsurface_modify_child,
+	    "Tests source clipping with later modifications",
+	    "subsurface", /* keywords */
+	    NULL, /* requirements */
+	    60, 60,
+	    NULL, draw)
diff --git a/test/subsurface-modify-child.ref.png b/test/subsurface-modify-child.ref.png
new file mode 100644
index 0000000..c37e22e
Binary files /dev/null and b/test/subsurface-modify-child.ref.png differ
diff --git a/test/subsurface-modify-parent.c b/test/subsurface-modify-parent.c
new file mode 100644
index 0000000..3dab2dd
--- /dev/null
+++ b/test/subsurface-modify-parent.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2010 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Intel not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Intel makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * INTEL CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_surface_t *region;
+
+    cairo_set_source_rgb (cr, .5, .5, .5);
+    cairo_paint (cr);
+
+    /* fill the centre, but through the *original* surface */
+    region = cairo_surface_create_for_rectangle (cairo_get_target (cr),
+						 20, 20, 20, 20);
+
+    /* first trigger a snapshot of the region... */
+    cairo_set_source_surface (cr, region, 20, 20);
+    cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
+    cairo_paint (cr);
+
+    cairo_set_source_rgb (cr, 1, 1, 1);
+    cairo_rectangle (cr, 20, 20, 10, 10);
+    cairo_fill (cr);
+
+    cairo_set_source_rgb (cr, 1, 0, 0);
+    cairo_rectangle (cr, 30, 20, 10, 10);
+    cairo_fill (cr);
+
+    cairo_set_source_rgb (cr, 0, 1, 0);
+    cairo_rectangle (cr, 20, 30, 10, 10);
+    cairo_fill (cr);
+
+    cairo_set_source_rgb (cr, 0, 0, 1);
+    cairo_rectangle (cr, 30, 30, 10, 10);
+    cairo_fill (cr);
+
+    cairo_set_source_surface (cr, region, 20, 20);
+
+    /* repeat the pattern around the outside, but do not overwrite...*/
+    cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
+    cairo_rectangle (cr, 0, 0, width, height);
+    cairo_rectangle (cr, 20, 40, 20, -20);
+    cairo_fill (cr);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (subsurface_modify_parent,
+	    "Tests source clipping with later modifications",
+	    "subsurface", /* keywords */
+	    NULL, /* requirements */
+	    60, 60,
+	    NULL, draw)
diff --git a/test/subsurface-modify-parent.ref.png b/test/subsurface-modify-parent.ref.png
new file mode 100644
index 0000000..c37e22e
Binary files /dev/null and b/test/subsurface-modify-parent.ref.png differ


More information about the cairo-commit mailing list