Bug 484954 - Propogate the component alpha flag when wrapping image surfaces to fix RGBA text on win32. r=vlad
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Thu, 07 May 2009 15:15:34 -0400
changeset 28077 89338a224278a839b3c6f79a7e46f13235ee8911
parent 28076 ddb8d3efc243a075fc5bb064127f0164125c3aa0
child 28078 53eebf02eac766300426cb0d386eb4a61564cd61
push id6885
push userjdrew@mozilla.com
push dateThu, 07 May 2009 19:16:04 +0000
treeherdermozilla-central@89338a224278 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad
bugs484954
milestone1.9.2a1pre
Bug 484954 - Propogate the component alpha flag when wrapping image surfaces to fix RGBA text on win32. r=vlad
gfx/cairo/cairo/src/cairo-surface.c
gfx/cairo/libpixman/src/pixman-image.c
gfx/cairo/libpixman/src/pixman.h
gfx/cairo/pixman-component-alpha.patch
gfx/cairo/wrap-source_image.patch
--- a/gfx/cairo/cairo/src/cairo-surface.c
+++ b/gfx/cairo/cairo/src/cairo-surface.c
@@ -1281,43 +1281,46 @@ static void
 
 static cairo_status_t
 _wrap_image (cairo_surface_t *src,
 	     cairo_image_surface_t *image,
 	     void *image_extra,
 	     cairo_image_surface_t **out)
 {
     static cairo_user_data_key_t wrap_image_key;
-    cairo_surface_t *surface;
+    cairo_image_surface_t *surface;
     cairo_status_t status;
 
     struct acquire_source_image_data *data = malloc(sizeof(*data));
     data->src = src;
     data->image = image;
     data->image_extra = image_extra;
 
-    surface = cairo_image_surface_create_for_data (image->data,
+    surface = (cairo_image_surface_t*)cairo_image_surface_create_for_data (image->data,
 	    image->format,
 	    image->width,
 	    image->height,
 	    image->stride);
-    status = surface->status;
+    status = surface->base.status;
     if (status)
 	return status;
 
-    status = _cairo_user_data_array_set_data (&surface->user_data,
+    status = _cairo_user_data_array_set_data (&surface->base.user_data,
 	    &wrap_image_key,
 	    data,
 	    _wrap_release_source_image);
     if (status) {
-	cairo_surface_destroy (surface);
+	cairo_surface_destroy (&surface->base);
 	return status;
     }
 
-    *out = (cairo_image_surface_t *) surface;
+    pixman_image_set_component_alpha (surface->pixman_image,
+            pixman_image_get_component_alpha (surface->pixman_image));
+
+    *out = surface;
     return CAIRO_STATUS_SUCCESS;
 }
 
 
 
 /**
  * _cairo_surface_clone_similar:
  * @surface: a #cairo_surface_t
--- a/gfx/cairo/libpixman/src/pixman-image.c
+++ b/gfx/cairo/libpixman/src/pixman-image.c
@@ -558,16 +558,21 @@ pixman_image_set_alpha_map (pixman_image
 
 PIXMAN_EXPORT void
 pixman_image_set_component_alpha   (pixman_image_t       *image,
 				    pixman_bool_t         component_alpha)
 {
     image->common.component_alpha = component_alpha;
 }
 
+PIXMAN_EXPORT pixman_bool_t
+pixman_image_get_component_alpha   (pixman_image_t       *image)
+{
+    return image->common.component_alpha;
+}
 
 PIXMAN_EXPORT void
 pixman_image_set_accessors (pixman_image_t             *image,
 			    pixman_read_memory_func_t	read_func,
 			    pixman_write_memory_func_t	write_func)
 {
     return_if_fail (image != NULL);
 
--- a/gfx/cairo/libpixman/src/pixman.h
+++ b/gfx/cairo/libpixman/src/pixman.h
@@ -762,16 +762,17 @@ pixman_bool_t   pixman_image_set_filter 
 void		pixman_image_set_source_clipping     (pixman_image_t		   *image,
 						      pixman_bool_t                 source_clipping);
 void            pixman_image_set_alpha_map           (pixman_image_t               *image,
 						      pixman_image_t               *alpha_map,
 						      int16_t                       x,
 						      int16_t                       y);
 void            pixman_image_set_component_alpha     (pixman_image_t               *image,
 						      pixman_bool_t                 component_alpha);
+pixman_bool_t   pixman_image_get_component_alpha     (pixman_image_t               *image);
 void		pixman_image_set_accessors	     (pixman_image_t		   *image,
 						      pixman_read_memory_func_t	    read_func,
 						      pixman_write_memory_func_t    write_func);
 void		pixman_image_set_indexed	     (pixman_image_t		   *image,
 						      const pixman_indexed_t	   *indexed);
 uint32_t       *pixman_image_get_data                (pixman_image_t               *image);
 int		pixman_image_get_width               (pixman_image_t               *image);
 int             pixman_image_get_height              (pixman_image_t               *image);
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/pixman-component-alpha.patch
@@ -0,0 +1,34 @@
+commit d14b8c688f4cbe6c9289955d9ce7257c07869f9e
+Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
+Date:   Wed May 6 10:19:04 2009 -0400
+
+    create getter for component alpha
+
+diff --git a/gfx/cairo/libpixman/src/pixman-image.c b/gfx/cairo/libpixman/src/pixman-image.c
+index e80c479..2c49f92 100644
+--- a/gfx/cairo/libpixman/src/pixman-image.c
++++ b/gfx/cairo/libpixman/src/pixman-image.c
+@@ -563,6 +563,11 @@ pixman_image_set_component_alpha   (pixman_image_t       *image,
+     image->common.component_alpha = component_alpha;
+ }
+ 
++PIXMAN_EXPORT pixman_bool_t
++pixman_image_get_component_alpha   (pixman_image_t       *image)
++{
++    return image->common.component_alpha;
++}
+ 
+ PIXMAN_EXPORT void
+ pixman_image_set_accessors (pixman_image_t             *image,
+diff --git a/gfx/cairo/libpixman/src/pixman.h b/gfx/cairo/libpixman/src/pixman.h
+index 49c39d5..522a866 100644
+--- a/gfx/cairo/libpixman/src/pixman.h
++++ b/gfx/cairo/libpixman/src/pixman.h
+@@ -767,6 +767,7 @@ void            pixman_image_set_alpha_map           (pixman_image_t
+ 						      int16_t                       y);
+ void            pixman_image_set_component_alpha     (pixman_image_t               *image,
+ 						      pixman_bool_t                 component_alpha);
++pixman_bool_t   pixman_image_get_component_alpha     (pixman_image_t               *image);
+ void		pixman_image_set_accessors	     (pixman_image_t		   *image,
+ 						      pixman_read_memory_func_t	    read_func,
+ 						      pixman_write_memory_func_t    write_func);
--- a/gfx/cairo/wrap-source_image.patch
+++ b/gfx/cairo/wrap-source_image.patch
@@ -1,19 +1,19 @@
-commit bddef148c243b4f3317165babe068fbea0b0fd2c
+commit 367aa46142f7c0cf3405814487bbbbc7411b96a4
 Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date:   Tue Mar 17 15:14:53 2009 -0400
+Date:   Thu Apr 23 15:42:55 2009 -0400
 
     wrap source_image
 
 diff --git a/src/cairo-surface.c b/src/cairo-surface.c
-index 456f851..4897e5a 100644
+index a4a7084..e4c3752 100644
 --- a/src/cairo-surface.c
 +++ b/src/cairo-surface.c
-@@ -1264,6 +1264,60 @@ _cairo_surface_release_dest_image (cairo_surface_t         *surface,
+@@ -1264,6 +1264,63 @@ _cairo_surface_release_dest_image (cairo_surface_t         *surface,
  					      image, image_rect, image_extra);
  }
  
 +struct acquire_source_image_data
 +{
 +    cairo_surface_t *src;
 +    cairo_image_surface_t *image;
 +    void *image_extra;
@@ -29,52 +29,55 @@ index 456f851..4897e5a 100644
 +
 +static cairo_status_t
 +_wrap_image (cairo_surface_t *src,
 +	     cairo_image_surface_t *image,
 +	     void *image_extra,
 +	     cairo_image_surface_t **out)
 +{
 +    static cairo_user_data_key_t wrap_image_key;
-+    cairo_surface_t *surface;
++    cairo_image_surface_t *surface;
 +    cairo_status_t status;
 +
 +    struct acquire_source_image_data *data = malloc(sizeof(*data));
 +    data->src = src;
 +    data->image = image;
 +    data->image_extra = image_extra;
 +
-+    surface = cairo_image_surface_create_for_data (image->data,
++    surface = (cairo_image_surface_t*)cairo_image_surface_create_for_data (image->data,
 +	    image->format,
 +	    image->width,
 +	    image->height,
 +	    image->stride);
-+    status = surface->status;
++    status = surface->base.status;
 +    if (status)
 +	return status;
 +
-+    status = _cairo_user_data_array_set_data (&surface->user_data,
++    status = _cairo_user_data_array_set_data (&surface->base.user_data,
 +	    &wrap_image_key,
 +	    data,
 +	    _wrap_release_source_image);
 +    if (status) {
-+	cairo_surface_destroy (surface);
++	cairo_surface_destroy (&surface->base);
 +	return status;
 +    }
 +
-+    *out = (cairo_image_surface_t *) surface;
++    pixman_image_set_component_alpha (surface->pixman_image,
++            pixman_image_get_component_alpha (surface->pixman_image));
++
++    *out = surface;
 +    return CAIRO_STATUS_SUCCESS;
 +}
 +
 +
 +
  /**
   * _cairo_surface_clone_similar:
   * @surface: a #cairo_surface_t
-@@ -1342,15 +1396,19 @@ _cairo_surface_clone_similar (cairo_surface_t  *surface,
+@@ -1342,15 +1399,19 @@ _cairo_surface_clone_similar (cairo_surface_t  *surface,
  	    /* If we failed, try again with an image surface */
  	    status = _cairo_surface_acquire_source_image (src, &image, &image_extra);
  	    if (status == CAIRO_STATUS_SUCCESS) {
 -		status =
 +		status = _wrap_image(src, image, image_extra, &image);
 +		if (status != CAIRO_STATUS_SUCCESS) {
 +		    _cairo_surface_release_source_image (src, image, image_extra);
 +		} else {