summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-01-22 19:27:45 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2010-01-22 23:01:52 +0000
commitec7cc9dea16f94e1e56720be548cf5520ec4708b (patch)
tree4a8c993df96819614fd547c9f3c806142b306a3a
parentb713510f213d0a83cb0575d6870416a0f13786c9 (diff)
ft: Tidy computation of transformed bitmap, and mark if CA
Discard a redundant clear as the image surface is guaranteed to return a cleared surface that meets pixman/xlib requirements for alignment, and more importantly add the ComponentAlpha flag on the pixman image generated as appropriate.
-rw-r--r--src/cairo-ft-font.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 1c56031ac..56f0d1079 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -992,6 +992,9 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
return (*surface)->base.status;
}
+ if (format == CAIRO_FORMAT_ARGB32)
+ pixman_image_set_component_alpha ((*surface)->pixman_image, TRUE);
+
_cairo_image_surface_assume_ownership_of_data ((*surface));
_cairo_debug_check_image_surface_is_defined (&(*surface)->base);
@@ -1202,8 +1205,8 @@ _transform_glyph_bitmap (cairo_matrix_t * shape,
original_to_transformed = *shape;
cairo_surface_get_device_offset (&(*surface)->base, &origin_x, &origin_y);
- orig_width = cairo_image_surface_get_width (&(*surface)->base);
- orig_height = cairo_image_surface_get_height (&(*surface)->base);
+ orig_width = (*surface)->width;
+ orig_height = (*surface)->height;
cairo_matrix_translate (&original_to_transformed,
-origin_x, -origin_y);
@@ -1241,9 +1244,8 @@ _transform_glyph_bitmap (cairo_matrix_t * shape,
original_to_transformed.x0 -= x_min;
original_to_transformed.y0 -= y_min;
- /* Create the transformed bitmap
- */
- width = x_max - x_min;
+ /* Create the transformed bitmap */
+ width = x_max - x_min;
height = y_max - y_min;
transformed_to_original = original_to_transformed;
@@ -1251,30 +1253,19 @@ _transform_glyph_bitmap (cairo_matrix_t * shape,
if (unlikely (status))
return status;
- /* We need to pad out the width to 32-bit intervals for cairo-xlib-surface.c */
- width = (width + 3) & ~3;
image = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height);
if (unlikely (image->status))
return image->status;
- /* Initialize it to empty
- */
- status = _cairo_surface_fill_rectangle (image, CAIRO_OPERATOR_CLEAR,
- CAIRO_COLOR_TRANSPARENT,
- 0, 0,
- width, height);
- if (unlikely (status)) {
- cairo_surface_destroy (image);
- return status;
- }
-
/* Draw the original bitmap transformed into the new bitmap
*/
_cairo_pattern_init_for_surface (&pattern, &(*surface)->base);
cairo_pattern_set_matrix (&pattern.base, &transformed_to_original);
- status = _cairo_surface_paint (image, CAIRO_OPERATOR_OVER,
- &pattern.base, NULL);
+ status = _cairo_surface_paint (image,
+ CAIRO_OPERATOR_SOURCE,
+ &pattern.base,
+ NULL);
_cairo_pattern_fini (&pattern.base);