Bug 1034209 (Part 1) - Replace the dead Image case in nsImageRenderer::Draw with the code used in DrawBackground. r=nrc
authorSeth Fowler <seth@mozilla.com>
Mon, 21 Jul 2014 17:59:23 -0700
changeset 195384 152a6d71f7390391b345e9c011c87e39188cb072
parent 195383 f1d7b63dc997a6ac00e0f2c340f3ec0698fa9557
child 195385 fd4c9f4cd1f0b4b1436e15a16b81aa2363ecaa7f
push id46576
push usermfowler@mozilla.com
push dateTue, 22 Jul 2014 00:59:51 +0000
treeherdermozilla-inbound@fd4c9f4cd1f0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnrc
bugs1034209
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1034209 (Part 1) - Replace the dead Image case in nsImageRenderer::Draw with the code used in DrawBackground. r=nrc
layout/base/nsCSSRendering.cpp
layout/base/nsCSSRendering.h
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -4739,40 +4739,41 @@ ConvertImageRendererToDrawFlags(uint32_t
   }
   return drawFlags;
 }
 
 void
 nsImageRenderer::Draw(nsPresContext*       aPresContext,
                       nsRenderingContext&  aRenderingContext,
                       const nsRect&        aDirtyRect,
+                      const nsRect&        aDest,
                       const nsRect&        aFill,
-                      const nsRect&        aDest,
+                      const nsPoint&       aAnchor,
                       const CSSIntRect&    aSrc)
 {
   if (!mIsReady) {
     NS_NOTREACHED("Ensure PrepareImage() has returned true before calling me");
     return;
   }
   if (aDest.IsEmpty() || aFill.IsEmpty() ||
       mSize.width <= 0 || mSize.height <= 0) {
     return;
   }
 
-  GraphicsFilter graphicsFilter =
-    nsLayoutUtils::GetGraphicsFilterForFrame(mForFrame);
+  GraphicsFilter filter = nsLayoutUtils::GetGraphicsFilterForFrame(mForFrame);
 
   switch (mType) {
     case eStyleImageType_Image:
     {
-      nsLayoutUtils::DrawSingleImage(&aRenderingContext, aPresContext,
-                                     mImageContainer,
-                                     graphicsFilter, aFill, aDirtyRect,
-                                     nullptr,
-                                     ConvertImageRendererToDrawFlags(mFlags));
+      nsIntSize imageSize(nsPresContext::AppUnitsToIntCSSPixels(mSize.width),
+                          nsPresContext::AppUnitsToIntCSSPixels(mSize.height));
+      nsLayoutUtils::DrawBackgroundImage(&aRenderingContext, aPresContext,
+                                         mImageContainer, imageSize, filter,
+                                         aDest, aFill, aAnchor, aDirtyRect,
+                                         ConvertImageRendererToDrawFlags(mFlags));
       return;
     }
     case eStyleImageType_Gradient:
     {
       nsCSSRendering::PaintGradient(aPresContext, aRenderingContext,
                                     mGradientData, aDirtyRect,
                                     aDest, aFill, aSrc, mSize);
       return;
@@ -4783,18 +4784,17 @@ nsImageRenderer::Draw(nsPresContext*    
                                                           aRenderingContext);
       if (!drawable) {
         NS_WARNING("Could not create drawable for element");
         return;
       }
 
       nsCOMPtr<imgIContainer> image(ImageOps::CreateFromDrawable(drawable));
       nsLayoutUtils::DrawImage(&aRenderingContext, aPresContext, image,
-                               graphicsFilter, aDest, aFill,
-                               aDest.TopLeft(), aDirtyRect, 
+                               filter, aDest, aFill, aAnchor, aDirtyRect,
                                ConvertImageRendererToDrawFlags(mFlags));
       return;
     }
     case eStyleImageType_Null:
     default:
       return;
   }
 }
@@ -4839,32 +4839,18 @@ nsImageRenderer::DrawBackground(nsPresCo
     NS_NOTREACHED("Ensure PrepareImage() has returned true before calling me");
     return;
   }
   if (aDest.IsEmpty() || aFill.IsEmpty() ||
       mSize.width <= 0 || mSize.height <= 0) {
     return;
   }
 
-  if (mType == eStyleImageType_Image) {
-    GraphicsFilter graphicsFilter =
-      nsLayoutUtils::GetGraphicsFilterForFrame(mForFrame);
-
-    nsLayoutUtils::DrawBackgroundImage(&aRenderingContext, aPresContext,
-                mImageContainer,
-                nsIntSize(nsPresContext::AppUnitsToIntCSSPixels(mSize.width),
-                          nsPresContext::AppUnitsToIntCSSPixels(mSize.height)),
-                graphicsFilter,
-                aDest, aFill, aAnchor, aDirty,
-                ConvertImageRendererToDrawFlags(mFlags));
-    return;
-  }
-
   Draw(aPresContext, aRenderingContext,
-       aDirty, aFill, aDest,
+       aDirty, aDest, aFill, aAnchor,
        CSSIntRect(0, 0,
                   nsPresContext::AppUnitsToIntCSSPixels(mSize.width),
                   nsPresContext::AppUnitsToIntCSSPixels(mSize.height)));
 }
 
 /**
  * Compute the size and position of the master copy of the image. I.e., a single
  * tile used to fill the dest rect.
@@ -5008,17 +4994,18 @@ nsImageRenderer::DrawBorderImageComponen
                              imgIContainer::FLAG_NONE);
     return;
   }
 
   nsRect destTile = RequiresScaling(aFill, aHFill, aVFill, aUnitSize)
                   ? ComputeTile(aFill, aHFill, aVFill, aUnitSize)
                   : aFill;
 
-  Draw(aPresContext, aRenderingContext, aDirtyRect, aFill, destTile, aSrc);
+  Draw(aPresContext, aRenderingContext, aDirtyRect, destTile,
+       aFill, destTile.TopLeft(), aSrc);
 }
 
 bool
 nsImageRenderer::IsRasterImage()
 {
   if (mType != eStyleImageType_Image || !mImageContainer)
     return false;
   return mImageContainer->GetType() == imgIContainer::TYPE_RASTER;
--- a/layout/base/nsCSSRendering.h
+++ b/layout/base/nsCSSRendering.h
@@ -166,18 +166,19 @@ public:
   /**
    * Draws the image to the target rendering context.
    * aSrc is a rect on the source image which will be mapped to aDest.
    * @see nsLayoutUtils::DrawImage() for other parameters.
    */
   void Draw(nsPresContext*       aPresContext,
             nsRenderingContext&  aRenderingContext,
             const nsRect&        aDirtyRect,
+            const nsRect&        aDest,
             const nsRect&        aFill,
-            const nsRect&        aDest,
+            const nsPoint&       aAnchor,
             const mozilla::CSSIntRect& aSrc);
   /**
    * Draws the image to the target rendering context using background-specific
    * arguments.
    * @see nsLayoutUtils::DrawImage() for parameters.
    */
   void DrawBackground(nsPresContext*       aPresContext,
                       nsRenderingContext&  aRenderingContext,