summaryrefslogtreecommitdiff
path: root/src/cairo-directfb-surface.c
diff options
context:
space:
mode:
authorChristopher (Monty) Montgomery <xiphmont@gmail.com>2006-10-18 17:06:23 -0700
committerCarl Worth <cworth@cworth.org>2006-10-18 17:06:23 -0700
commit8d7a02ed58e06584eb09575e6ca11d0a81094ab6 (patch)
tree96e6dfd25b73ff54a6f98286829b420cd7e0fed8 /src/cairo-directfb-surface.c
parent99e2e99a78e492196a76e76cb47e463223db3012 (diff)
Add extents to clone_similar (fixing subimage_copy performance bug)
This fixes a huge performance bug (entire image was being pushed to X server in order to copy a tiny piece of it). I see up to 50x improvement from subimage_copy (which was designed to expose this problem) but also a 5x improvement in some text performance cases. xlib-rgba subimage_copy-512 3.93 2.46% -> 0.07 2.71%: 52.91x faster ███████████████████████████████████████████████████▉ xlib-rgb subimage_copy-512 4.03 1.97% -> 0.09 2.61%: 44.74x faster ███████████████████████████████████████████▊ xlib-rgba subimage_copy-256 1.02 2.25% -> 0.07 0.56%: 14.42x faster █████████████▍ xlib-rgba text_image_rgb_over-256 63.21 1.53% -> 11.87 2.17%: 5.33x faster ████▍ xlib-rgba text_image_rgba_over-256 62.31 0.72% -> 11.87 2.82%: 5.25x faster ████▎ xlib-rgba text_image_rgba_source-256 67.97 0.85% -> 16.48 2.23%: 4.13x faster ███▏ xlib-rgba text_image_rgb_source-256 68.82 0.55% -> 16.93 2.10%: 4.07x faster ███▏ xlib-rgba subimage_copy-128 0.19 1.72% -> 0.06 0.85%: 3.10x faster ██▏
Diffstat (limited to 'src/cairo-directfb-surface.c')
-rw-r--r--src/cairo-directfb-surface.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index fdff40ac..e724ed67 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -548,6 +548,10 @@ _cairo_directfb_surface_release_dest_image (void *abstract_surf
static cairo_status_t
_cairo_directfb_surface_clone_similar (void *abstract_surface,
cairo_surface_t *src,
+ int src_x,
+ int src_y,
+ int width,
+ int height,
cairo_surface_t **clone_out)
{
cairo_directfb_surface_t *surface = abstract_surface;
@@ -583,19 +587,23 @@ _cairo_directfb_surface_clone_similar (void *abstract_surface,
cairo_surface_destroy ((cairo_surface_t *)clone);
return CAIRO_STATUS_NO_MEMORY;
}
+
+ dst += pitch * src_y;
+ src += image_src->stride * src_y;
if (image_src->format == CAIRO_FORMAT_A1) {
/* A1 -> A8 */
- for (i = 0; i < image_src->height; i++) {
- for (j = 0; j < image_src->width; j++)
+ for (i = 0; i < height; i++) {
+ for (j = src_x; j < src_x + width; j++)
dst[j] = (src[j>>3] & (1 << (j&7))) ? 0xff : 0x00;
dst += pitch;
src += image_src->stride;
}
}
- else {
- for (i = 0; i < image_src->height; i++) {
- direct_memcpy( dst, src, image_src->stride );
+ else {
+ /* A8 -> A8 */
+ for (i = 0; i < height; i++) {
+ direct_memcpy( dst+src_x, src+src_x, sizeof(*dst)*width );
dst += pitch;
src += image_src->stride;
}