[cairo-commit] 2 commits - src/cairo-xlib-source.c src/cairo-xlib-surface-shm.c
Chris Wilson
ickle at kemper.freedesktop.org
Sun Jan 6 08:42:37 PST 2013
src/cairo-xlib-source.c | 92 +++++++++++++++----------------------------
src/cairo-xlib-surface-shm.c | 23 ++++++----
2 files changed, 47 insertions(+), 68 deletions(-)
New commits:
commit a73e7ff0186176bc82cd3ae1432c054c1fd3aebd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sun Jan 6 11:29:27 2013 +0000
xlib: Simplify source creation by use of map-to-image
We were open-coding the functionality of map-to-image inside the source
creation routines. so refactor to actually use map-to-image instead.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/cairo-xlib-source.c b/src/cairo-xlib-source.c
index e312222..d08052a 100644
--- a/src/cairo-xlib-source.c
+++ b/src/cairo-xlib-source.c
@@ -898,9 +898,6 @@ surface_source (cairo_xlib_surface_t *dst,
cairo_surface_pattern_t local_pattern;
cairo_status_t status;
cairo_rectangle_int_t upload, limit;
- cairo_matrix_t m;
- pixman_format_code_t format;
- int draw_x, draw_y;
src = pattern->surface;
if (src->type == CAIRO_SURFACE_TYPE_IMAGE &&
@@ -910,7 +907,6 @@ surface_source (cairo_xlib_surface_t *dst,
cairo_surface_reference (src);
-prepare_shm_image:
proxy = malloc (sizeof(*proxy));
if (unlikely (proxy == NULL)) {
cairo_surface_destroy (src);
@@ -954,46 +950,47 @@ prepare_shm_image:
}
}
- if (_cairo_surface_is_image (src))
- format = ((cairo_image_surface_t *)src)->pixman_format;
- else
- format = _cairo_format_to_pixman_format_code (_cairo_format_from_content (src->content));
- src = _cairo_xlib_surface_create_shm (dst, format,
- upload.width, upload.height);
- if (src == NULL) {
- if (_cairo_surface_is_image (pattern->surface)) {
- draw_x = upload.x;
- draw_y = upload.y;
- src = cairo_surface_reference (pattern->surface);
- goto skip_paint;
- }
-
- src = _cairo_image_surface_create_with_pixman_format (NULL,
- format,
- upload.width,
- upload.height,
- 0);
+ xsrc = (cairo_xlib_surface_t *)
+ _cairo_surface_create_similar_scratch (&dst->base,
+ src->content,
+ upload.width,
+ upload.height);
+ if (xsrc->base.type != CAIRO_SURFACE_TYPE_XLIB) {
+ cairo_surface_destroy (src);
+ cairo_surface_destroy (&xsrc->base);
+ return None;
}
- _cairo_pattern_init_for_surface (&local_pattern, pattern->surface);
- cairo_matrix_init_translate (&local_pattern.base.matrix,
- upload.x, upload.y);
+ if (_cairo_surface_is_image (src)) {
+ status = _cairo_xlib_surface_draw_image (xsrc, (cairo_image_surface_t *)src,
+ upload.x, upload.y,
+ upload.width, upload.height,
+ 0, 0);
+ } else {
+ cairo_image_surface_t *image;
- status = _cairo_surface_paint (src,
- CAIRO_OPERATOR_SOURCE,
- &local_pattern.base,
- NULL);
- _cairo_pattern_fini (&local_pattern.base);
+ image = _cairo_surface_map_to_image (&xsrc->base, NULL);
- if (unlikely (status)) {
- cairo_surface_destroy (src);
- return _cairo_surface_create_in_error (status);
+ _cairo_pattern_init_for_surface (&local_pattern, pattern->surface);
+ cairo_matrix_init_translate (&local_pattern.base.matrix,
+ upload.x, upload.y);
+
+ status = _cairo_surface_paint (&image->base,
+ CAIRO_OPERATOR_SOURCE,
+ &local_pattern.base,
+ NULL);
+ _cairo_pattern_fini (&local_pattern.base);
+
+ status = _cairo_surface_unmap_image (&xsrc->base, image);
+ if (unlikely (status)) {
+ cairo_surface_destroy (src);
+ return _cairo_surface_create_in_error (status);
+ }
}
- draw_x = draw_y = 0;
-skip_paint:
_cairo_pattern_init_static_copy (&local_pattern.base, &pattern->base);
if (upload.x | upload.y) {
+ cairo_matrix_t m;
cairo_matrix_init_translate (&m, -upload.x, -upload.y);
cairo_matrix_multiply (&local_pattern.base.matrix,
&local_pattern.base.matrix,
@@ -1001,29 +998,6 @@ skip_paint:
}
*src_x = *src_y = 0;
- if (src->device == dst->base.device &&
- _cairo_xlib_shm_surface_get_pixmap (src)) {
- pattern = &local_pattern;
- goto prepare_shm_image;
- }
-
- xsrc = (cairo_xlib_surface_t *)
- _cairo_surface_create_similar_scratch (&dst->base,
- src->content,
- upload.width,
- upload.height);
- if (xsrc->base.type != CAIRO_SURFACE_TYPE_XLIB) {
- cairo_surface_destroy (src);
- cairo_surface_destroy (&xsrc->base);
- return None;
- }
-
- status = _cairo_xlib_surface_draw_image (xsrc, (cairo_image_surface_t *)src,
- draw_x, draw_y,
- upload.width, upload.height,
- 0, 0);
- cairo_surface_destroy (src);
-
_cairo_xlib_surface_ensure_picture (xsrc);
if (! picture_set_properties (xsrc->display,
xsrc->picture,
commit 4f142f3a7bf24b659c5caccab3a1aedd6b680909
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Sun Jan 6 10:32:25 2013 +0000
xlib/shm: Only mark the shm pixmap as active if we upload into it
Be more strict with when we mark the pixmap as active so that we only
wait for the actual XCopyArea involving the pixmap to complete.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/cairo-xlib-surface-shm.c b/src/cairo-xlib-surface-shm.c
index 1e2c6e6..2c2858c 100644
--- a/src/cairo-xlib-surface-shm.c
+++ b/src/cairo-xlib-surface-shm.c
@@ -1066,10 +1066,6 @@ _cairo_xlib_surface_put_shm (cairo_xlib_surface_t *surface)
damage = _cairo_damage_reduce (shm->image.base.damage);
shm->image.base.damage = _cairo_damage_create ();
- status = _cairo_xlib_surface_get_gc (display, surface, &gc);
- if (unlikely (status))
- goto out;
-
TRACE ((stderr, "%s: flushing damage x %d\n", __FUNCTION__,
damage->region ? cairo_region_num_rectangles (damage->region) : 0));
if (damage->status == CAIRO_STATUS_SUCCESS && damage->region) {
@@ -1079,9 +1075,16 @@ _cairo_xlib_surface_put_shm (cairo_xlib_surface_t *surface)
int n_rects, i;
n_rects = cairo_region_num_rectangles (damage->region);
- if (n_rects == 0) {
- } else if (n_rects == 1) {
+ if (n_rects == 0)
+ goto out;
+
+ status = _cairo_xlib_surface_get_gc (display, surface, &gc);
+ if (unlikely (status))
+ goto out;
+
+ if (n_rects == 1) {
cairo_region_get_rectangle (damage->region, 0, &r);
+ _cairo_xlib_shm_surface_mark_active (surface->shm);
XCopyArea (display->display,
shm->pixmap, surface->drawable, gc,
r.x, r.y,
@@ -1092,6 +1095,7 @@ _cairo_xlib_surface_put_shm (cairo_xlib_surface_t *surface)
rects = _cairo_malloc_ab (n_rects, sizeof (XRectangle));
if (unlikely (rects == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ _cairo_xlib_surface_put_gc (display, surface, gc);
goto out;
}
}
@@ -1105,6 +1109,7 @@ _cairo_xlib_surface_put_shm (cairo_xlib_surface_t *surface)
}
XSetClipRectangles (display->display, gc, 0, 0, rects, i, YXBanded);
+ _cairo_xlib_shm_surface_mark_active (surface->shm);
XCopyArea (display->display,
shm->pixmap, surface->drawable, gc,
0, 0,
@@ -1114,12 +1119,12 @@ _cairo_xlib_surface_put_shm (cairo_xlib_surface_t *surface)
if (damage->status == CAIRO_STATUS_SUCCESS && damage->region)
XSetClipMask (display->display, gc, None);
}
+
+ _cairo_xlib_surface_put_gc (display, surface, gc);
}
- _cairo_damage_destroy (damage);
- _cairo_xlib_shm_surface_mark_active (surface->shm);
- _cairo_xlib_surface_put_gc (display, surface, gc);
out:
+ _cairo_damage_destroy (damage);
cairo_device_release (&display->base);
}
More information about the cairo-commit
mailing list