[cairo-commit] 3 commits - src/cairo-image-surface.c src/cairoint.h src/cairo-pattern.c src/cairo-surface.c

Carl Worth cworth at kemper.freedesktop.org
Thu Jun 15 16:25:40 PDT 2006


 src/cairo-image-surface.c |   19 ++++---------------
 src/cairo-pattern.c       |    2 +-
 src/cairo-surface.c       |   37 +------------------------------------
 src/cairoint.h            |    1 +
 4 files changed, 7 insertions(+), 52 deletions(-)

New commits:
diff-tree abe1bfad8d8a3252bdc65da40bf303626881b163 (from 9fa24975b4b9cc9983331991d2a3c53a37272162)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Jun 15 15:43:00 2006 -0700

    Add missing breaks in switch statement.
    
    Yes, I am an idiot.

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 5b6cc54..e94673c 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -102,18 +102,21 @@ _cairo_format_from_pixman_format (pixman
 	    gm == 0x0000ff00 &&
 	    bm == 0x000000ff)
 	    return CAIRO_FORMAT_RGB24;
+	break;
     case 8:
 	if (am == 0xff &&
 	    rm == 0x0 &&
 	    gm == 0x0 &&
 	    bm == 0x0)
 	    return CAIRO_FORMAT_A8;
+	break;
     case 1:
 	if (am == 0x1 &&
 	    rm == 0x0 &&
 	    gm == 0x0 &&
 	    bm == 0x0)
 	    return CAIRO_FORMAT_A1;
+	break;
     }
 
     fprintf (stderr,
diff-tree 9fa24975b4b9cc9983331991d2a3c53a37272162 (from 0ba040d7f63c62e482d40fc6db0e1f0714806839)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Jun 15 15:33:45 2006 -0700

    Drop _cairo_surface_is_opaque now that we have cairo_surface_get_content

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 496a884..c8f4353 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1105,7 +1105,7 @@ _cairo_pattern_is_opaque (const cairo_pa
     case CAIRO_PATTERN_TYPE_SOLID:
 	return _cairo_pattern_is_opaque_solid (abstract_pattern);
     case CAIRO_PATTERN_TYPE_SURFACE:
-	return _cairo_surface_is_opaque (pattern->surface.surface);
+	return cairo_surface_get_content (pattern->surface.surface) == CAIRO_CONTENT_COLOR;
     case CAIRO_PATTERN_TYPE_LINEAR:
     case CAIRO_PATTERN_TYPE_RADIAL:
 	return _gradient_is_opaque (&pattern->gradient.base);
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 3218607..b7d0e75 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -170,6 +170,7 @@ cairo_surface_get_content (cairo_surface
 {
     return surface->content;
 }
+slim_hidden_def(cairo_surface_get_content);
 
 /**
  * cairo_surface_status:
@@ -2002,42 +2003,6 @@ _cairo_surface_composite_shape_fixup_unb
 							      dst_x, dst_y, width, height);
 }
 
-static cairo_bool_t
-_format_is_opaque (cairo_format_t format)
-{
-    switch (format) {
-    case CAIRO_FORMAT_ARGB32:
-	return FALSE;
-    case CAIRO_FORMAT_RGB24:
-	return TRUE;
-    case CAIRO_FORMAT_A8:
-	return FALSE;
-    case CAIRO_FORMAT_A1:
-	return TRUE;
-    }
-    return FALSE;
-}
-
-/* XXX: This function is funny in a couple of ways. First it seems to
- * be computing something like "not translucent" rather than "opaque"
- * since it returns TRUE for an A1 image surface. Second, it just
- * gives up on anything other than an image surface.
- *
- * I imagine something that might be more useful here (or in addition)
- * would be cairo_surface_get_content.
- */
-cairo_bool_t
-_cairo_surface_is_opaque (const cairo_surface_t *surface)
-{
-    if (_cairo_surface_is_image (surface)) {
-	const cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
-
-	return _format_is_opaque (image_surface->format);
-    }
-
-    return FALSE;
-}
-
 /**
  * _cairo_surface_copy_pattern_for_destination
  * @pattern: the pattern to copy
diff --git a/src/cairoint.h b/src/cairoint.h
index 45173c7..e4bf6fc 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2219,6 +2219,7 @@ slim_hidden_proto(cairo_restore)
 slim_hidden_proto(cairo_save)
 slim_hidden_proto(cairo_stroke_preserve)
 slim_hidden_proto(cairo_surface_destroy)
+slim_hidden_proto(cairo_surface_get_content)
 slim_hidden_proto(cairo_push_group)
 slim_hidden_proto(cairo_push_group_with_content)
 slim_hidden_proto(cairo_pop_group)
diff-tree 0ba040d7f63c62e482d40fc6db0e1f0714806839 (from 82496a6f7c5b0a9f91db6abc9e34202b8ffa77c4)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Jun 15 14:56:59 2006 -0700

    Remove _cairo_image_surface_is_alpha_only in favor of just looking at content value.

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index c4f0cc4..5b6cc54 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -806,20 +806,6 @@ _cairo_image_surface_fill_rectangles (vo
     return CAIRO_STATUS_SUCCESS;
 }
 
-static cairo_bool_t
-_cairo_image_surface_is_alpha_only (cairo_image_surface_t *surface)
-{
-    int bpp, alpha, red, green, blue;
-
-    if (surface->format != (cairo_format_t) -1)
-	return surface->format == CAIRO_FORMAT_A1 || surface->format == CAIRO_FORMAT_A8;
-
-    pixman_format_get_masks (pixman_image_get_format (surface->pixman_image),
-			     &bpp, &alpha, &red, &green, &blue);
-
-    return red == 0 && blue == 0 && green == 0;
-}
-
 static cairo_int_status_t
 _cairo_image_surface_composite_trapezoids (cairo_operator_t	op,
 					   cairo_pattern_t	*pattern,
@@ -859,7 +845,7 @@ _cairo_image_surface_composite_trapezoid
      */
     if (op == CAIRO_OPERATOR_ADD &&
 	_cairo_pattern_is_opaque_solid (pattern) &&
-	_cairo_image_surface_is_alpha_only (dst) &&
+	dst->base.content == CAIRO_CONTENT_ALPHA &&
 	!dst->has_clip &&
 	antialias != CAIRO_ANTIALIAS_NONE)
     {


More information about the cairo-commit mailing list