summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2012-05-28 01:22:26 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2012-05-28 17:37:52 -0400
commit3c1cfef1ecfe0a15231b073a2cdedfd8e4e081e7 (patch)
tree27222a07baba25364ae89aefc117f0432ecce1e5
parent103109d4f0278531b563d7a2788070ecf3979798 (diff)
Optimize add_glyphs
-rw-r--r--pixman/pixman-glyph.c153
1 files changed, 79 insertions, 74 deletions
diff --git a/pixman/pixman-glyph.c b/pixman/pixman-glyph.c
index ca0f2874..6325d7c4 100644
--- a/pixman/pixman-glyph.c
+++ b/pixman/pixman-glyph.c
@@ -387,6 +387,47 @@ pixman_glyph_get_extents (pixman_glyph_cache_t *cache,
}
}
+static pixman_bool_t
+box32_intersect (pixman_box32_t *dest, const pixman_box32_t *box1, const pixman_box32_t *box2)
+{
+ dest->x1 = MAX (box1->x1, box2->x1);
+ dest->y1 = MAX (box1->y1, box2->y1);
+ dest->x2 = MIN (box1->x2, box2->x2);
+ dest->y2 = MIN (box1->y2, box2->y2);
+
+ return dest->x2 > dest->x1 && dest->y2 > dest->y1;
+}
+
+PIXMAN_EXPORT void
+pixman_composite_glyphs_no_mask (pixman_op_t op,
+ pixman_image_t *src,
+ pixman_image_t *dest,
+ int32_t src_x,
+ int32_t src_y,
+ int32_t dest_x,
+ int32_t dest_y,
+ pixman_glyph_cache_t *cache,
+ int n_glyphs,
+ pixman_glyph_t *glyphs)
+{
+ int i;
+
+ for (i = 0; i < n_glyphs; ++i)
+ {
+ glyph_t *glyph = (glyph_t *)glyphs[i].glyph;
+ pixman_image_t *glyph_img = glyph->image;
+
+ pixman_image_composite32 (op, src, glyph_img, dest,
+ src_x + glyphs[i].x - glyph->origin_x,
+ src_y + glyphs[i].y - glyph->origin_y,
+ 0, 0,
+ dest_x + glyphs[i].x - glyph->origin_x,
+ dest_y + glyphs[i].y - glyph->origin_y,
+ glyph_img->bits.width,
+ glyph_img->bits.height);
+ }
+}
+
static void
add_glyphs (pixman_glyph_cache_t *cache,
pixman_image_t *dest,
@@ -395,34 +436,39 @@ add_glyphs (pixman_glyph_cache_t *cache,
{
pixman_format_code_t glyph_format = PIXMAN_null;
uint32_t glyph_flags = 0;
- uint32_t dest_flags;
- pixman_format_code_t dest_format;
- pixman_implementation_t *implementation;
pixman_composite_func_t func = NULL;
+ pixman_implementation_t *implementation = NULL;
+ uint32_t dest_format;
+ uint32_t dest_flags;
+ pixman_box32_t dest_box;
pixman_composite_info_t info;
- uint32_t extra = FAST_PATH_SAMPLES_COVER_CLIP_NEAREST;
int i;
_pixman_image_validate (dest);
-
- dest_flags = dest->common.flags;
+
dest_format = dest->common.extended_format_code;
+ dest_flags = dest->common.flags;
info.op = PIXMAN_OP_ADD;
info.mask_image = NULL;
info.dest_image = dest;
- info.src_flags = glyph_flags | extra;
- info.mask_flags = FAST_PATH_IS_OPAQUE;
- info.dest_flags = dest_flags;
- info.src_x = 0;
- info.src_y = 0;
info.mask_x = 0;
info.mask_y = 0;
+ info.mask_flags = FAST_PATH_IS_OPAQUE;
+ info.dest_flags = dest_flags;
+
+ dest_box.x1 = 0;
+ dest_box.y1 = 0;
+ dest_box.x2 = dest->bits.width;
+ dest_box.y2 = dest->bits.height;
for (i = 0; i < n_glyphs; ++i)
{
glyph_t *glyph = (glyph_t *)glyphs[i].glyph;
pixman_image_t *glyph_img = glyph->image;
+ uint32_t extra = FAST_PATH_SAMPLES_COVER_CLIP_NEAREST;
+ pixman_box32_t glyph_box;
+ pixman_box32_t composite_box;
if (glyph_img->common.extended_format_code != glyph_format ||
glyph_img->common.flags != glyph_flags)
@@ -441,56 +487,27 @@ add_glyphs (pixman_glyph_cache_t *cache,
return;
}
- info.src_image = glyph_img;
- info.dest_x = glyphs[i].x - glyph->origin_x + off_x;
- info.dest_y = glyphs[i].y - glyph->origin_y + off_y;
- info.width = glyph->image->bits.width;
- info.height = glyph->image->bits.height;
-
- restrict_and_composite (func, implementation, &info);
-
- pixman_list_move_to_front (&cache->mru, &glyph->mru_link);
- }
-}
-
-static pixman_bool_t
-box32_intersect (pixman_box32_t *dest, const pixman_box32_t *box1, const pixman_box32_t *box2)
-{
- dest->x1 = MAX (box1->x1, box2->x1);
- dest->y1 = MAX (box1->y1, box2->y1);
- dest->x2 = MIN (box1->x2, box2->x2);
- dest->y2 = MIN (box1->y2, box2->y2);
-
- return dest->x2 > dest->x1 && dest->y2 > dest->y1;
-}
-
-PIXMAN_EXPORT void
-pixman_composite_glyphs_no_mask (pixman_op_t op,
- pixman_image_t *src,
- pixman_image_t *dest,
- int32_t src_x,
- int32_t src_y,
- int32_t dest_x,
- int32_t dest_y,
- pixman_glyph_cache_t *cache,
- int n_glyphs,
- pixman_glyph_t *glyphs)
-{
- int i;
-
- for (i = 0; i < n_glyphs; ++i)
- {
- glyph_t *glyph = (glyph_t *)glyphs[i].glyph;
- pixman_image_t *glyph_img = glyph->image;
-
- pixman_image_composite32 (op, src, glyph_img, dest,
- src_x + glyphs[i].x - glyph->origin_x,
- src_y + glyphs[i].y - glyph->origin_y,
- 0, 0,
- dest_x + glyphs[i].x - glyph->origin_x,
- dest_y + glyphs[i].y - glyph->origin_y,
- glyph_img->bits.width,
- glyph_img->bits.height);
+ glyph_box.x1 = glyphs[i].x - glyph->origin_x + off_x;
+ glyph_box.y1 = glyphs[i].y - glyph->origin_y + off_y;
+ glyph_box.x2 = glyph_box.x1 + glyph->image->bits.width;
+ glyph_box.y2 = glyph_box.y1 + glyph->image->bits.height;
+
+ if (box32_intersect (&composite_box, &glyph_box, &dest_box))
+ {
+ info.src_image = glyph_img;
+ info.src_x = composite_box.x1 - glyph_box.x1;
+ info.src_y = composite_box.y1 - glyph_box.y1;
+ info.dest_x = composite_box.x1;
+ info.dest_y = composite_box.y1;
+ info.width = composite_box.x2 - composite_box.x1;
+ info.height = composite_box.y2 - composite_box.y1;
+
+ info.src_flags = glyph_flags;
+
+ func (implementation, &info);
+
+ pixman_list_move_to_front (&cache->mru, &glyph->mru_link);
+ }
}
}
@@ -525,7 +542,6 @@ pixman_composite_glyphs (pixman_op_t op,
pixman_glyph_t *glyphs)
{
pixman_image_t *mask;
- int i;
if (!(mask = pixman_image_create_bits (mask_format, width, height, NULL, -1)))
return;
@@ -536,18 +552,7 @@ pixman_composite_glyphs (pixman_op_t op,
pixman_image_set_component_alpha (mask, TRUE);
}
- for (i = 0; i < n_glyphs; ++i)
- {
- glyph_t *glyph = (glyph_t *)glyphs[i].glyph;
- pixman_image_t *glyph_img = glyph->image;
-
- pixman_image_composite32 (PIXMAN_OP_ADD, glyph_img, NULL, mask,
- 0, 0, 0, 0,
- glyphs[i].x - glyph->origin_x - mask_x,
- glyphs[i].y - glyph->origin_y - mask_y,
- glyph->image->bits.width,
- glyph->image->bits.height);
- }
+ add_glyphs (cache, mask, - mask_x, - mask_y, n_glyphs, glyphs);
pixman_image_composite32 (op, src, mask, dest,
src_x, src_y,