Bug 781731 - Clean up DrawTargetCairo::DrawSurfaceWithShadow() to make it simpler and paint correctly in all modes; r=jrmuizel
authorAnthony Jones <ajones@mozilla.com>
Mon, 27 Aug 2012 11:31:56 +0200
changeset 105582 ddff99db5f7c61f3a58eadde82541bf0235d5a3a
parent 105581 7402befeff1c5462046704415800b16b690f5cc9
child 105583 4041007e49cd37f4fa1018bbda066c8cc158e2a9
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersjrmuizel
bugs781731
milestone17.0a1
Bug 781731 - Clean up DrawTargetCairo::DrawSurfaceWithShadow() to make it simpler and paint correctly in all modes; r=jrmuizel
gfx/2d/DrawTargetCairo.cpp
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -407,70 +407,58 @@ DrawTargetCairo::DrawSurfaceWithShadow(S
                                                                   blursize.height,
                                                                   blur.GetStride());
 
   ClearSurfaceForUnboundedSource(aOperator);
   
   // Draw the source surface into the surface we're going to blur.
   SourceSurfaceCairo* source = static_cast<SourceSurfaceCairo*>(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
   // colour to the surface.
   blur.Blur();
   cairo_save(mContext);
   cairo_set_operator(mContext, GfxOpToCairoOp(aOperator));
   cairo_identity_matrix(mContext);
   cairo_translate(mContext, aDest.x, aDest.y);
 
   if (OperatorAffectsUncoveredAreas(aOperator) ||
       aOperator == OP_SOURCE){
     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);
+
+      // 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_fill(mContext);
     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);
-      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);
   } 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);
 }
 
 void
 DrawTargetCairo::DrawPattern(const Pattern& aPattern,
                              const StrokeOptions& aStrokeOptions,
                              const DrawOptions& aOptions,
                              DrawPatternType aDrawType)