[cairo-commit] 2 commits - pixman/src src/cairo-image-surface.c src/cairo-paginated-surface.c src/cairo-paginated-surface-private.h src/cairo-ps-surface.c

Carl Worth cworth at kemper.freedesktop.org
Fri Apr 14 16:27:52 PDT 2006


 pixman/src/icpixels.c                 |    1 +
 src/cairo-image-surface.c             |    7 ++++---
 src/cairo-paginated-surface-private.h |    8 ++++++++
 src/cairo-paginated-surface.c         |   30 ++++++++++++++++++++++++++++++
 src/cairo-ps-surface.c                |   27 ---------------------------
 5 files changed, 43 insertions(+), 30 deletions(-)

New commits:
diff-tree 0e44e798b5f6fd58cc586e40f926d363cd8fff50 (from e8a0da637fda4a29281cfb4f463169e51c300c42)
Author: Dom Lachowicz <cinamod at hotmail.com>
Date:   Fri Apr 14 16:15:29 2006 -0700

    Change cairo_image_surface_create to zero out surface contents.
    
    This closes bug #5816:
    
    	Image surfaces do not start out blank by default
    	https://bugs.freedesktop.org/show_bug.cgi?id=5816
    
    This also fixes all of the test suite failures introduced by moving
    the CLEAR on blank page optimization up to the paginated surface from
    the PS surface.

diff --git a/pixman/src/icpixels.c b/pixman/src/icpixels.c
index cdec492..2ad34f4 100644
--- a/pixman/src/icpixels.c
+++ b/pixman/src/icpixels.c
@@ -70,6 +70,7 @@ FbPixelsCreate (int width, int height, i
 	return NULL;
 
     buf = (pixman_bits_t *) ((char *)pixels + base + adjust);
+    memset (buf, 0, height * stride);
 
     FbPixelsInit (pixels, buf, width, height, depth, bpp, stride);
 
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index e095aa0..cef455b 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -188,9 +188,10 @@ _create_pixman_format (cairo_format_t fo
  * @height: height of the surface, in pixels
  * 
  * Creates an image surface of the specified format and
- * dimensions. The initial contents of the surface is undefined; you
- * must explicitly initialize the surface contents, using, for
- * example, cairo_paint().
+ * dimensions. Initially the surface contents are all
+ * 0. (Specifically, within each pixel, each color or alpha channel
+ * belonging to format will be 0. The contents of bits within a pixel,
+ * but not belonging to the given format are undefined).
  *
  * Return value: a pointer to the newly created surface. The caller
  * owns the surface and should call cairo_surface_destroy when done
diff-tree e8a0da637fda4a29281cfb4f463169e51c300c42 (from b8fb8dc375d2828a962bac2e1f50f44d8ec8cbee)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Apr 14 16:18:36 2006 -0700

    Move optimization of CLEAR on blank page up from PS to paginated surface.

diff --git a/src/cairo-paginated-surface-private.h b/src/cairo-paginated-surface-private.h
index 247ed72..b5e4d5c 100644
--- a/src/cairo-paginated-surface-private.h
+++ b/src/cairo-paginated-surface-private.h
@@ -116,6 +116,14 @@ typedef struct _cairo_paginated_surface_
  * CAIRO_STATUS_SUCCESS or CAIRO_INT_STATUS_UNSUPPORTED to indicate
  * whether rendering would be supported. And it should do this as
  * quickly as possible.
+ *
+ * NOTE: The paginated surface layer assumes that the target surface
+ * is "blank" by default at the beginning of each page, without any
+ * need for an explicit erasea operation, (as opposed to an image
+ * surface, for example, which might have uninitialized content
+ * originally). As such, it optimizes away CLEAR operations that
+ * happen at the beginning of each page---the target surface will not
+ * even see these operations.
  */
 cairo_private cairo_surface_t *
 _cairo_paginated_surface_create (cairo_surface_t				*target,
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index 01b6ed8..34b42e7 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -70,6 +70,8 @@ typedef struct _cairo_paginated_surface 
      * fallbacks. */
     cairo_surface_t *meta;
 
+    cairo_bool_t page_is_blank;
+
 } cairo_paginated_surface_t;
 
 const cairo_private cairo_surface_backend_t cairo_paginated_surface_backend;
@@ -126,6 +128,8 @@ _cairo_paginated_surface_create (cairo_s
     if (cairo_surface_status (surface->meta))
 	goto FAIL_CLEANUP_SURFACE;
 
+    surface->page_is_blank = TRUE;
+
     return &surface->base;
 
   FAIL_CLEANUP_SURFACE:
@@ -296,6 +300,8 @@ _cairo_paginated_surface_show_page (void
     if (cairo_surface_status (surface->meta))
 	return cairo_surface_status (surface->meta);
 
+    surface->page_is_blank = TRUE;
+
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -329,6 +335,12 @@ _cairo_paginated_surface_paint (void			*
 {
     cairo_paginated_surface_t *surface = abstract_surface;
 
+    /* Optimize away erasing of nothing. */
+    if (surface->page_is_blank && op == CAIRO_OPERATOR_CLEAR)
+	return CAIRO_STATUS_SUCCESS;
+
+    surface->page_is_blank = FALSE;
+
     return _cairo_surface_paint (surface->meta, op, source);
 }
 
@@ -356,6 +368,12 @@ _cairo_paginated_surface_stroke (void			
 {
     cairo_paginated_surface_t *surface = abstract_surface;
 
+    /* Optimize away erasing of nothing. */
+    if (surface->page_is_blank && op == CAIRO_OPERATOR_CLEAR)
+	return CAIRO_STATUS_SUCCESS;
+
+    surface->page_is_blank = FALSE;
+
     return _cairo_surface_stroke (surface->meta, op, source,
 				  path, style,
 				  ctm, ctm_inverse,
@@ -373,6 +391,12 @@ _cairo_paginated_surface_fill (void			*a
 {
     cairo_paginated_surface_t *surface = abstract_surface;
 
+    /* Optimize away erasing of nothing. */
+    if (surface->page_is_blank && op == CAIRO_OPERATOR_CLEAR)
+	return CAIRO_STATUS_SUCCESS;
+
+    surface->page_is_blank = FALSE;
+
     return _cairo_surface_fill (surface->meta, op, source,
 				path, fill_rule,
 				tolerance, antialias);
@@ -388,6 +412,12 @@ _cairo_paginated_surface_show_glyphs (vo
 {
     cairo_paginated_surface_t *surface = abstract_surface;
 
+    /* Optimize away erasing of nothing. */
+    if (surface->page_is_blank && op == CAIRO_OPERATOR_CLEAR)
+	return CAIRO_STATUS_SUCCESS;
+
+    surface->page_is_blank = FALSE;
+
     return _cairo_surface_show_glyphs (surface->meta, op, source,
 				       glyphs, num_glyphs,
 				       scaled_font);
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 84efa6e..9319f83 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -96,7 +96,6 @@ typedef struct cairo_ps_surface {
     double x_dpi;
     double y_dpi;
 
-    cairo_bool_t page_is_blank;
     int num_pages;
 
     cairo_paginated_mode_t paginated_mode;
@@ -574,7 +573,6 @@ _cairo_ps_surface_create_for_stream_inte
     surface->y_dpi = PS_SURFACE_DPI_DEFAULT;
     surface->paginated_mode = CAIRO_PAGINATED_MODE_ANALYZE;
 
-    surface->page_is_blank = TRUE;
     surface->num_pages = 0;
 
     return _cairo_paginated_surface_create (&surface->base,
@@ -1518,12 +1516,6 @@ _cairo_ps_surface_paint (void			*abstrac
     cairo_output_stream_t *stream = surface->stream;
     cairo_ps_surface_path_info_t info;
 
-    /* Optimize away erasing of nothing. */
-    if (surface->page_is_blank && op == CAIRO_OPERATOR_CLEAR)
-	return CAIRO_STATUS_SUCCESS;
-
-    surface->page_is_blank = FALSE;
-
     if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
 	return _analyze_operation (surface, op, source);
 
@@ -1602,12 +1594,6 @@ _cairo_ps_surface_stroke (void			*abstra
     cairo_int_status_t status;
     cairo_ps_surface_path_info_t info;
 
-    /* Optimize away erasing of nothing. */
-    if (surface->page_is_blank && op == CAIRO_OPERATOR_CLEAR)
-	return CAIRO_STATUS_SUCCESS;
-
-    surface->page_is_blank = FALSE;
-
     if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
 	return _analyze_operation (surface, op, source);
 
@@ -1681,12 +1667,6 @@ _cairo_ps_surface_fill (void		*abstract_
     cairo_ps_surface_path_info_t info;
     const char *ps_operator;
 
-    /* Optimize away erasing of nothing. */
-    if (surface->page_is_blank && op == CAIRO_OPERATOR_CLEAR)
-	return CAIRO_STATUS_SUCCESS;
-
-    surface->page_is_blank = FALSE;
-
     if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
 	return _analyze_operation (surface, op, source);
 
@@ -1750,12 +1730,6 @@ _cairo_ps_surface_show_glyphs (void		   
     cairo_ps_font_t *ps_font;
     cairo_ps_glyph_t *ps_glyph;
 
-    /* Optimize away erasing of nothing. */
-    if (surface->page_is_blank && op == CAIRO_OPERATOR_CLEAR)
-	return CAIRO_STATUS_SUCCESS;
-
-    surface->page_is_blank = FALSE;
-
     if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
 	return _analyze_operation (surface, op, source);
 
@@ -1814,7 +1788,6 @@ _cairo_ps_surface_set_paginated_mode (vo
     cairo_ps_surface_t *surface = abstract_surface;
 
     surface->paginated_mode = paginated_mode;
-    surface->page_is_blank = TRUE;
 }
 
 static const cairo_surface_backend_t cairo_ps_surface_backend = {


More information about the cairo-commit mailing list