diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2011-01-21 11:35:05 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2011-01-21 11:35:05 -0500 |
commit | e164e4ef722433b87c98f32a39e93dbd55b2231f (patch) | |
tree | 5ae8ea4c41923e3175768bef06c02b3e39fe5bfa | |
parent | f39a9ccbb32f10d193742b98986d1d2327e9a3fe (diff) |
Use cairo_push_group() for all double buffering, drop window_copy_*()
-rw-r--r-- | clients/dnd.c | 21 | ||||
-rw-r--r-- | clients/image.c | 23 | ||||
-rw-r--r-- | clients/window.c | 24 | ||||
-rw-r--r-- | clients/window.h | 9 |
4 files changed, 23 insertions, 54 deletions
diff --git a/clients/dnd.c b/clients/dnd.c index 33562bc..3b54dec 100644 --- a/clients/dnd.c +++ b/clients/dnd.c @@ -171,21 +171,20 @@ dnd_draw(struct dnd *dnd) { struct rectangle allocation; cairo_t *cr; - cairo_surface_t *wsurface, *surface; + cairo_surface_t *surface; int i; window_draw(dnd->window); + surface = window_get_surface(dnd->window); + cr = cairo_create(surface); window_get_child_allocation(dnd->window, &allocation); + cairo_rectangle(cr, allocation.x, allocation.y, + allocation.width, allocation.height); + cairo_clip(cr); + cairo_push_group(cr); - wsurface = window_get_surface(dnd->window); - surface = cairo_surface_create_similar(wsurface, - CAIRO_CONTENT_COLOR_ALPHA, - allocation.width, - allocation.height); - cairo_surface_destroy(wsurface); - - cr = cairo_create(surface); + cairo_translate(cr, allocation.x, allocation.y); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba(cr, 0, 0, 0, 0.8); cairo_paint(cr); @@ -199,9 +198,9 @@ dnd_draw(struct dnd *dnd) cairo_paint(cr); } + cairo_pop_group_to_source(cr); + cairo_paint(cr); cairo_destroy(cr); - - window_copy_surface(dnd->window, &allocation, surface); cairo_surface_destroy(surface); window_flush(dnd->window); } diff --git a/clients/image.c b/clients/image.c index 61d8b25..891bd8a 100644 --- a/clients/image.c +++ b/clients/image.c @@ -140,7 +140,7 @@ image_draw(struct image *image) struct rectangle allocation; GdkPixbuf *pb; cairo_t *cr; - cairo_surface_t *wsurface, *surface; + cairo_surface_t *surface; window_draw(image->window); @@ -153,14 +153,15 @@ image_draw(struct image *image) if (pb == NULL) return; - wsurface = window_get_surface(image->window); - surface = cairo_surface_create_similar(wsurface, - CAIRO_CONTENT_COLOR_ALPHA, - allocation.width, - allocation.height); - - cairo_surface_destroy(wsurface); + surface = window_get_surface(image->window); cr = cairo_create(surface); + window_get_child_allocation(image->window, &allocation); + cairo_rectangle(cr, allocation.x, allocation.y, + allocation.width, allocation.height); + cairo_clip(cr); + cairo_push_group(cr); + cairo_translate(cr, allocation.x, allocation.y); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba(cr, 0, 0, 0, 1); cairo_paint(cr); @@ -169,11 +170,13 @@ image_draw(struct image *image) allocation.width, allocation.height); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); cairo_paint(cr); - cairo_destroy(cr); g_object_unref(pb); - window_copy_surface(image->window, &allocation, surface); + cairo_pop_group_to_source(cr); + cairo_paint(cr); + cairo_destroy(cr); + window_flush(image->window); cairo_surface_destroy(surface); } diff --git a/clients/window.c b/clients/window.c index ce2164c..f598bcd 100644 --- a/clients/window.c +++ b/clients/window.c @@ -1102,30 +1102,6 @@ window_set_child_size(struct window *window, int32_t width, int32_t height) } } -void -window_copy_image(struct window *window, - struct rectangle *rectangle, EGLImageKHR image) -{ - /* set image as read buffer, copy pixels or something... */ -} - -void -window_copy_surface(struct window *window, - struct rectangle *rectangle, - cairo_surface_t *surface) -{ - cairo_t *cr; - - cr = cairo_create (window->cairo_surface); - - cairo_set_source_surface (cr, - surface, - rectangle->x, rectangle->y); - - cairo_paint (cr); - cairo_destroy (cr); -} - static gboolean idle_redraw(void *data) { diff --git a/clients/window.h b/clients/window.h index a333f77..7d6afdc 100644 --- a/clients/window.h +++ b/clients/window.h @@ -141,10 +141,6 @@ window_get_child_allocation(struct window *window, void window_set_child_size(struct window *window, int32_t width, int32_t height); void -window_copy_image(struct window *window, - struct rectangle *rectangle, - void *image); -void window_schedule_redraw(struct window *window); void @@ -155,11 +151,6 @@ cairo_surface_t * window_get_surface(struct window *window); void -window_copy_surface(struct window *window, - struct rectangle *rectangle, - cairo_surface_t *surface); - -void window_flush(struct window *window); void |