[maemo-commits] [maemo-commits] r19194 - in projects/haf/trunk/sapwood: . engine
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Aug 25 10:50:14 EEST 2009
- Previous message: [maemo-commits] r19192 - in projects/haf/trunk/sapwood: . server
- Next message: [maemo-commits] r19195 - projects/haf/trunk/sapwood/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: herzi Date: 2009-08-25 10:50:12 +0300 (Tue, 25 Aug 2009) New Revision: 19194 Modified: projects/haf/trunk/sapwood/ChangeLog projects/haf/trunk/sapwood/engine/sapwood-pixmap.c Log: 2009-08-25 Sven Herzberg <sven at lanedo.com> Fixes: NB#134552 (Progress Banner at start of maps and tutorial applet is broken.) * engine/sapwood-pixmap.c (sapwood_pixmap_render_rects_internal), (sapwood_crop_pixmap), (sapwood_pixmap_render_rects): properly clip to the cropped region; also respect the alpha mask in the cropping Modified: projects/haf/trunk/sapwood/ChangeLog =================================================================== --- projects/haf/trunk/sapwood/ChangeLog 2009-08-25 07:49:55 UTC (rev 19193) +++ projects/haf/trunk/sapwood/ChangeLog 2009-08-25 07:50:12 UTC (rev 19194) @@ -1,5 +1,14 @@ 2009-08-25 Sven Herzberg <sven at lanedo.com> + Fixes: NB#134552 (Progress Banner at start of maps and tutorial applet + is broken.) + + * engine/sapwood-pixmap.c (sapwood_pixmap_render_rects_internal), + (sapwood_crop_pixmap), (sapwood_pixmap_render_rects): properly clip + to the cropped region; also respect the alpha mask in the cropping + +2009-08-25 Sven Herzberg <sven at lanedo.com> + About: NB#134552 (Progress Banner at start of maps and tutorial applet is broken.) Modified: projects/haf/trunk/sapwood/engine/sapwood-pixmap.c =================================================================== --- projects/haf/trunk/sapwood/engine/sapwood-pixmap.c 2009-08-25 07:49:55 UTC (rev 19193) +++ projects/haf/trunk/sapwood/engine/sapwood-pixmap.c 2009-08-25 07:50:12 UTC (rev 19194) @@ -340,6 +340,15 @@ cairo_pattern_destroy (pattern); cairo_destroy (tmp_cr); + cairo_destroy (cr); + + cr = gdk_cairo_create (mask); + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + gdk_cairo_set_source_pixmap (cr, rect[n].pixmask, dest->x, dest->y); + cairo_pattern_set_extend (cairo_get_source (cr), + CAIRO_EXTEND_REPEAT); + cairo_rectangle (cr, area.x, area.y, area.width, area.height); + cairo_fill (cr); } cairo_destroy (cr); } @@ -348,58 +357,107 @@ static void sapwood_crop_pixmap (GdkPixmap *pixmap, - int x, - int y, + GdkBitmap *mask, int requested_width, int requested_height, int original_width, int original_height) { - cairo_t *cr; - cairo_surface_t *surface; - int w1, h1, w2, h2; + cairo_t * cr = gdk_cairo_create (pixmap); + cairo_surface_t* surface = cairo_get_target (cr); - cr = gdk_cairo_create (pixmap); - surface = cairo_get_target (cr); + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); - w1 = requested_width / 2; - h1 = requested_height / 2; - w2 = (requested_width + 1) / 2; - h2 = (requested_height + 1) / 2; + /* crop horizontally */ + if (requested_width < original_width) + { + int left = requested_width / 2; + int right = requested_width - left; - /* top-left */ - cairo_save (cr); - cairo_set_source_surface (cr, surface, x, y); - cairo_rectangle (cr, x, y, w2, h2); - cairo_clip (cr); - cairo_paint (cr); - cairo_restore (cr); + /* left -- remains as it is */ - /* top-right */ - cairo_save (cr); - cairo_set_source_surface (cr, surface, x + requested_width - original_width, y); - cairo_rectangle (cr, x + w1, y, w2, h2); - cairo_clip (cr); - cairo_paint (cr); - cairo_restore (cr); + /* right */ + cairo_save (cr); + cairo_set_source_surface (cr, surface, -(original_width - requested_width), 0); + cairo_rectangle (cr, left, 0, right, MAX (original_height, requested_height)); + cairo_clip (cr); + if (!mask) + { + cairo_paint (cr); + } + else + { + cairo_matrix_t matrix; + int width = 1; + int height = 1; - /* bottom-left */ - cairo_save (cr); - cairo_set_source_surface (cr, surface, x, y + requested_height - original_height); - cairo_rectangle (cr, x, y + h1, w2, h2); - cairo_clip (cr); - cairo_paint (cr); - cairo_restore (cr); + gdk_drawable_get_size (mask, &width, &height); - /* bottom-right */ - cairo_save (cr); - cairo_set_source_surface (cr, surface, x + requested_width - original_width, - y + requested_height - original_height); - cairo_rectangle (cr, x + w1, y + h1, w2, h2); - cairo_clip (cr); - cairo_paint (cr); - cairo_restore (cr); + cairo_t* tmp_cr = gdk_cairo_create (mask); + cairo_pattern_t* pattern = cairo_pattern_create_for_surface (cairo_get_target (tmp_cr)); + cairo_matrix_init_translate (&matrix, (original_width - requested_width), 0); + cairo_pattern_set_matrix (pattern, + &matrix); + + cairo_mask (cr, pattern); + cairo_pattern_destroy (pattern); + + /* adjust the bitmap */ + cairo_set_source_surface (tmp_cr, cairo_get_target (tmp_cr), -(original_width - requested_width), 0); + cairo_set_operator (tmp_cr, CAIRO_OPERATOR_SOURCE); + cairo_rectangle (tmp_cr, left, 0, right, MAX (original_height, requested_height)); + cairo_clip (tmp_cr); + cairo_paint (tmp_cr); + + cairo_destroy (tmp_cr); + } + cairo_restore (cr); + } + + if (requested_height < original_height) + { + int top = requested_height / 2; + int bottom = requested_height - top; + + /* top -- remains as it is */ + + /* bottom */ + cairo_save (cr); + cairo_set_source_surface (cr, surface, 0, -(original_height - requested_height)); + cairo_rectangle (cr, 0, top, MAX (original_width, requested_width), bottom); + cairo_clip (cr); + if (!mask) + { + cairo_paint (cr); + } + else + { + cairo_matrix_t matrix; + + cairo_t* tmp_cr = gdk_cairo_create (mask); + cairo_pattern_t* pattern = cairo_pattern_create_for_surface (cairo_get_target (tmp_cr)); + + cairo_matrix_init_translate (&matrix, 0, (original_height - requested_height)); + cairo_pattern_set_extend (pattern, + CAIRO_EXTEND_REPEAT); + cairo_pattern_set_matrix (pattern, + &matrix); + + cairo_mask (cr, pattern); + cairo_pattern_destroy (pattern); + + /* adjust the bitmap */ + cairo_set_source_surface (tmp_cr, cairo_get_target (tmp_cr), 0, -(original_height - requested_height)); + cairo_set_operator (tmp_cr, CAIRO_OPERATOR_SOURCE); + cairo_rectangle (tmp_cr, 0, top, MAX (original_width, requested_width), bottom); + cairo_fill (tmp_cr); + + cairo_destroy (tmp_cr); + } + cairo_restore (cr); + } + cairo_destroy (cr); } @@ -489,9 +547,14 @@ cairo_translate (cr, draw_x, draw_y); - if (width > 0 && width < tmp_width || height > 0 && height < tmp_height) - sapwood_crop_pixmap (tmp, 0, 0, width, height, + if ((width > 0 && width < tmp_width) || (height > 0 && height < tmp_height)) + { + sapwood_crop_pixmap (tmp, tmp_mask, width, height, self->width, self->height); + + cairo_rectangle (cr, 0, 0, width, height); + cairo_clip (cr); + } else if (width != tmp_width || height != tmp_height) { cairo_scale (cr, (double)width / (double)tmp_width,
- Previous message: [maemo-commits] r19192 - in projects/haf/trunk/sapwood: . server
- Next message: [maemo-commits] r19195 - projects/haf/trunk/sapwood/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]