From 69f2ee12568de79395ee9b794c759a8f2e5932bd Mon Sep 17 00:00:00 2001 From: Jason Crain Date: Tue, 18 Aug 2015 01:34:10 -0500 Subject: [PATCH] cairo: fix size of transparency group surface Under rotation cairo_surface_create_similar_clip will create a surface with incorect width/height. Rely on cairo to do the correct calculation. Bug #66229 --- poppler/CairoOutputDev.cc | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index a86ec12..20ae90d 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -1433,29 +1433,15 @@ static inline int splashFloor(SplashCoord x) { static cairo_surface_t *cairo_surface_create_similar_clip (cairo_t *cairo, cairo_content_t content) { - double x1, y1, x2, y2; - int width, height; - cairo_clip_extents (cairo, &x1, &y1, &x2, &y2); - cairo_matrix_t matrix; - cairo_get_matrix (cairo, &matrix); - //cairo_matrix_transform_point(&matrix, &x1, &y1); - //cairo_matrix_transform_point(&matrix, &x2, &y2);*/ - cairo_user_to_device(cairo, &x1, &y1); - cairo_user_to_device(cairo, &x2, &y2); - width = splashCeil(x2) - splashFloor(x1); - //XXX: negative matrix - ////height = splashCeil(y2) - splashFloor(y1); - height = splashFloor(y1) - splashCeil(y2); - cairo_surface_t *target = cairo_get_target (cairo); - cairo_surface_t *result; - - result = cairo_surface_create_similar (target, content, width, height); - double x_offset, y_offset; - cairo_surface_get_device_offset(target, &x_offset, &y_offset); - cairo_surface_set_device_offset(result, x_offset, y_offset); + cairo_pattern_t *pattern; + cairo_surface_t *surface = NULL; - - return result; + cairo_push_group_with_content (cairo, content); + pattern = cairo_pop_group (cairo); + cairo_pattern_get_surface (pattern, &surface); + cairo_surface_reference (surface); + cairo_pattern_destroy (pattern); + return surface; } -- 2.1.4