From 0fcd2824ce3c21a7f112d9ce2a2ce9f087b2625e Mon Sep 17 00:00:00 2001 From: Anthony Jones Date: Sun, 2 Sep 2012 19:07:05 -0400 Subject: [PATCH] Bug 781731 - Clean up DrawTargetCairo::DrawSurfaceWithShadow() to make it simpler and paint correctly in all modes. r=jrmuizel --- gfx/2d/DrawTargetCairo.cpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index af241cffdae..548ae14e12a 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -412,19 +412,13 @@ DrawTargetCairo::DrawSurfaceWithShadow(SourceSurface *aSurface, // Draw the source surface into the surface we're going to blur. SourceSurfaceCairo* source = static_cast(aSurface); cairo_surface_t* surf = source->GetSurface(); - cairo_pattern_t* pat = cairo_pattern_create_for_surface(surf); - cairo_pattern_set_extend(pat, CAIRO_EXTEND_PAD); cairo_t* ctx = cairo_create(blursurf); - - cairo_set_source(ctx, pat); - + cairo_set_source_surface(ctx, surf, 0, 0); IntRect blurrect = blur.GetRect(); cairo_new_path(ctx); cairo_rectangle(ctx, blurrect.x, blurrect.y, blurrect.width, blurrect.height); - cairo_clip(ctx); - cairo_paint(ctx); - + cairo_fill(ctx); cairo_destroy(ctx); // Blur the result, then use that blurred result as a mask to draw the shadow @@ -440,32 +434,26 @@ DrawTargetCairo::DrawSurfaceWithShadow(SourceSurface *aSurface, cairo_push_group(mContext); cairo_set_source_rgba(mContext, aColor.r, aColor.g, aColor.b, aColor.a); cairo_mask_surface(mContext, blursurf, aOffset.x, aOffset.y); - cairo_pop_group_to_source(mContext); - cairo_paint(mContext); - // Now that the shadow has been drawn, we can draw the surface on top. - cairo_push_group(mContext); + // Now that the shadow has been drawn, we can draw the surface on top. + cairo_set_source_surface(mContext, surf, 0, 0); cairo_new_path(mContext); cairo_rectangle(mContext, 0, 0, width, height); - cairo_set_source(mContext, pat); cairo_fill(mContext); cairo_pop_group_to_source(mContext); + cairo_paint(mContext); } else { cairo_set_source_rgba(mContext, aColor.r, aColor.g, aColor.b, aColor.a); cairo_mask_surface(mContext, blursurf, aOffset.x, aOffset.y); // Now that the shadow has been drawn, we can draw the surface on top. - cairo_set_source(mContext, pat); + cairo_set_source_surface(mContext, surf, 0, 0); cairo_new_path(mContext); cairo_rectangle(mContext, 0, 0, width, height); - cairo_clip(mContext); + cairo_fill(mContext); } - cairo_paint(mContext); - cairo_restore(mContext); - - cairo_pattern_destroy(pat); cairo_surface_destroy(blursurf); }