[cairo-commit] 2 commits - src/cairoint.h src/cairo-pattern.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Apr 19 01:30:55 PDT 2007


 src/cairo-pattern.c |   12 +++++++-----
 src/cairoint.h      |    3 +++
 2 files changed, 10 insertions(+), 5 deletions(-)

New commits:
diff-tree 9cf09556339e64bdf1273e95938b657112df07b6 (from f7b6fc474651311356f116b7d8d7a5ef1cbab570)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Apr 19 09:27:51 2007 +0100

    Create opaque similar solid surfaces when possible.
    
    For opaque surfaces the backends may use simpler code paths - for
    example, the xlib backend may be able to use the Core protocol rather
    than Render. So we only generate a surface with an alpha component if
    the color is not opaque.

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 6bd0951..2bc893e 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1246,9 +1246,11 @@ _cairo_pattern_acquire_surface_for_solid
 					  cairo_surface_attributes_t *attribs)
 {
     *out = _cairo_surface_create_similar_solid (dst,
-				                CAIRO_CONTENT_COLOR_ALPHA,
-						1, 1,
-						&pattern->color);
+	                               CAIRO_COLOR_IS_OPAQUE (&pattern->color) ?
+				       CAIRO_CONTENT_COLOR :
+				       CAIRO_CONTENT_COLOR_ALPHA,
+				       1, 1,
+				       &pattern->color);
     if ((*out)->status)
 	return CAIRO_STATUS_NO_MEMORY;
 
diff-tree f7b6fc474651311356f116b7d8d7a5ef1cbab570 (from 157074c794903f1dbe68c1ba5b129b4176dc7975)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Apr 19 09:22:08 2007 +0100

    Define a CAIRO_ALPHA_IS_OPAQUE variant that operates on uint16.
    
    Introducing this variant also fixed a bug in _gradient_is_opaque()
    which was using the fractional test on a uint16.

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index af432f2..6bd0951 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1246,7 +1246,7 @@ _cairo_pattern_acquire_surface_for_solid
 					  cairo_surface_attributes_t *attribs)
 {
     *out = _cairo_surface_create_similar_solid (dst,
-						CAIRO_CONTENT_COLOR_ALPHA,
+				                CAIRO_CONTENT_COLOR_ALPHA,
 						1, 1,
 						&pattern->color);
     if ((*out)->status)
@@ -1282,7 +1282,7 @@ _cairo_pattern_is_opaque_solid (const ca
 
     solid = (cairo_solid_pattern_t *) pattern;
 
-    return CAIRO_ALPHA_IS_OPAQUE (solid->color.alpha);
+    return CAIRO_COLOR_IS_OPAQUE (&solid->color);
 }
 
 static cairo_bool_t
@@ -1291,7 +1291,7 @@ _gradient_is_opaque (const cairo_gradien
     unsigned int i;
 
     for (i = 0; i < gradient->n_stops; i++)
-	if (! CAIRO_ALPHA_IS_OPAQUE (gradient->stops[i].color.alpha))
+	if (! CAIRO_ALPHA_SHORT_IS_OPAQUE (gradient->stops[i].color.alpha))
 	    return FALSE;
 
     return TRUE;
diff --git a/src/cairoint.h b/src/cairoint.h
index 0288633..2a3ff01 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -192,8 +192,11 @@ typedef cairo_int128_t	cairo_fixed_96_32
 typedef cairo_fixed_16_16_t cairo_fixed_t;
 
 #define CAIRO_ALPHA_IS_OPAQUE(alpha) ((alpha) >= ((double)0xff00 / (double)0xffff))
+#define CAIRO_ALPHA_SHORT_IS_OPAQUE(alpha) ((alpha) >= 0xff00)
 #define CAIRO_ALPHA_IS_ZERO(alpha) ((alpha) <= 0.0)
 
+#define CAIRO_COLOR_IS_OPAQUE(color) CAIRO_ALPHA_SHORT_IS_OPAQUE ((color)->alpha_short)
+
 /* Reverse the bits in a byte with 7 operations (no 64-bit):
  * Devised by Sean Anderson, July 13, 2001.
  * Source: http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits


More information about the cairo-commit mailing list