Bug 1266933. Pass image extend mode to prescale and tile drawable on OS X. r=jrmuizel, a=lizzard
authorMason Chang <mchang@mozilla.com>
Thu, 05 May 2016 07:59:30 -0700
changeset 332806 5e345d6d359c93ccb70aeaf6cccb3713f217a3ab
parent 332805 36e12a7d0ae8166ce03cefc51c93ac3456a12daf
child 332807 8fd6c0a620ca78d14b446a16282895812fb1f511
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, lizzard
bugs1266933
milestone48.0a2
Bug 1266933. Pass image extend mode to prescale and tile drawable on OS X. r=jrmuizel, a=lizzard
gfx/thebes/gfxUtils.cpp
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -547,17 +547,18 @@ ShouldUseTempSurface(Rect aImageRect, Re
 
 static bool
 PrescaleAndTileDrawable(gfxDrawable* aDrawable,
                         gfxContext* aContext,
                         const ImageRegion& aRegion,
                         Rect aImageRect,
                         const Filter& aFilter,
                         const SurfaceFormat aFormat,
-                        gfxFloat aOpacity)
+                        gfxFloat aOpacity,
+                        ExtendMode aExtendMode)
 {
   gfxSize scaleFactor = aContext->CurrentMatrix().ScaleFactors(true);
   gfxMatrix scaleMatrix = gfxMatrix::Scaling(scaleFactor.width, scaleFactor.height);
   const float fuzzFactor = 0.01;
 
   // If we aren't scaling or translating, don't go down this path
   if ((FuzzyEqual(scaleFactor.width, 1.0, fuzzFactor) &&
       FuzzyEqual(scaleFactor.width, 1.0, fuzzFactor)) ||
@@ -598,33 +599,33 @@ PrescaleAndTileDrawable(gfxDrawable* aDr
     return false;
   }
 
   RefPtr<gfxContext> tmpCtx = gfxContext::ForDrawTarget(scaledDT);
   MOZ_ASSERT(tmpCtx); // already checked the target above
 
   scaledDT->SetTransform(ToMatrix(scaleMatrix));
   gfxRect gfxImageRect(aImageRect.x, aImageRect.y, aImageRect.width, aImageRect.height);
-  aDrawable->Draw(tmpCtx, gfxImageRect, ExtendMode::REPEAT, aFilter, 1.0, gfxMatrix());
+  aDrawable->Draw(tmpCtx, gfxImageRect, aExtendMode, aFilter, 1.0, gfxMatrix());
 
   RefPtr<SourceSurface> scaledImage = scaledDT->Snapshot();
 
   {
     gfxContextMatrixAutoSaveRestore autoSR(aContext);
     Matrix withoutScale = ToMatrix(aContext->CurrentMatrix());
     DrawTarget* destDrawTarget = aContext->GetDrawTarget();
 
     // The translation still is in scaled units
     withoutScale.PreScale(1.0 / scaleFactor.width, 1.0 / scaleFactor.height);
     aContext->SetMatrix(ThebesMatrix(withoutScale));
 
     DrawOptions drawOptions(aOpacity, aContext->CurrentOp(),
                             aContext->CurrentAntialiasMode());
 
-    SurfacePattern scaledImagePattern(scaledImage, ExtendMode::REPEAT,
+    SurfacePattern scaledImagePattern(scaledImage, aExtendMode,
                                       Matrix(), aFilter);
     destDrawTarget->FillRect(scaledNeededRect, scaledImagePattern, drawOptions);
   }
   return true;
 }
 #endif // MOZ_WIDGET_COCOA
 
 /* static */ void
@@ -665,17 +666,17 @@ gfxUtils::DrawPixelSnapped(gfxContext*  
                                                aRegion.Restriction(),
                                                extendMode, aFilter, aOpacity)) {
               return;
             }
 
 #ifdef MOZ_WIDGET_COCOA
             if (PrescaleAndTileDrawable(aDrawable, aContext, aRegion,
                                         ToRect(imageRect), aFilter,
-                                        aFormat, aOpacity)) {
+                                        aFormat, aOpacity, extendMode)) {
               return;
             }
 #endif
 
             // On Mobile, we don't ever want to do this; it has the potential for
             // allocating very large temporary surfaces, especially since we'll
             // do full-page snapshots often (see bug 749426).
 #if !defined(MOZ_GFX_OPTIMIZE_MOBILE)