[cairo-commit] 2 commits - src/cairo-glitz-surface.c

罗晶华 Jinghua Luo jinghua at kemper.freedesktop.org
Wed Jun 7 11:38:52 PDT 2006


 src/cairo-glitz-surface.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

New commits:
diff-tree bb66d15a7998740b6ce2525ab5d852fb2966f8f8 (from parents)
Merge: 3594fd2d273398b10748c8ed03c7a9da7af377fa b7c7d2e57c2721c3a900694d5620b3f45f495233
Author: Jinghua Luo <sunmoon1997 at gmail.com>
Date:   Thu Jun 8 02:38:17 2006 +0800

    Merge branch 'master' of git+ssh://jinghua@git.cairographics.org/git/cairo

diff-tree 3594fd2d273398b10748c8ed03c7a9da7af377fa (from 32c0e85d45ee26c34ba1af0e4ba6ced044e469cc)
Author: Jinghua Luo <sunmoon1997 at gmail.com>
Date:   Thu Jun 8 02:35:42 2006 +0800

    glitz: Don't hardcode content type when initializing cairo surface
    since we can compute it from glitz format.

diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index 6093f04..f58545a 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -2148,10 +2148,27 @@ _cairo_glitz_surface_get_backend (void)
     return &cairo_glitz_surface_backend;
 }
 
+static cairo_content_t
+_glitz_format_to_content (glitz_format_t * format)
+{
+    assert (format->color.fourcc == GLITZ_FOURCC_RGB);
+
+    if (format->color.alpha_size != 0) {
+	if (format->color.red_size != 0 &&
+	    format->color.green_size != 0 &&
+	    format->color.blue_size  != 0)
+	    return CAIRO_CONTENT_COLOR_ALPHA;
+	else
+	    return CAIRO_CONTENT_ALPHA;
+    }
+    return CAIRO_CONTENT_COLOR;
+}
+
 cairo_surface_t *
 cairo_glitz_surface_create (glitz_surface_t *surface)
 {
     cairo_glitz_surface_t *crsurface;
+    glitz_format_t *format;
 
     if (surface == NULL)
 	return (cairo_surface_t*) &_cairo_surface_nil;
@@ -2162,14 +2179,14 @@ cairo_glitz_surface_create (glitz_surfac
 	return (cairo_surface_t*) &_cairo_surface_nil;
     }
 
-    /* XXX: The content value here might be totally wrong. */
+    format = glitz_surface_get_format (surface);
     _cairo_surface_init (&crsurface->base, &cairo_glitz_surface_backend,
-			 CAIRO_CONTENT_COLOR_ALPHA);
+			 _glitz_format_to_content(format));
 
     glitz_surface_reference (surface);
 
     crsurface->surface = surface;
-    crsurface->format  = glitz_surface_get_format (surface);
+    crsurface->format  = format;
     crsurface->clip    = NULL;
 
     return (cairo_surface_t *) crsurface;


More information about the cairo-commit mailing list