Bug 856272; don't round our mask size too early so we get a proper transform for small surfaces. r=roc
authorNicholas Cameron <ncameron@mozilla.com>
Fri, 05 Apr 2013 16:16:38 +1300
changeset 127755 91ac668eeace1af9bf22b24e2d4ea3bd8574427b
parent 127754 bef79d45847ac466040f65c64b14332704356814
child 127756 4c45dbd81a3224768c250fd2bac7d0dbc53d98e6
push id24512
push userryanvm@gmail.com
push dateFri, 05 Apr 2013 20:13:49 +0000
treeherdermozilla-central@139b6ba547fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs856272
milestone23.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 856272; don't round our mask size too early so we get a proper transform for small surfaces. r=roc
layout/base/FrameLayerBuilder.cpp
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -3734,26 +3734,26 @@ ContainerState::SetupMaskLayer(Layer *aL
 
   // calculate a more precise bounding rect
   const int32_t A2D = mContainerFrame->PresContext()->AppUnitsPerDevPixel();
   gfxRect boundingRect = CalculateBounds(newData.mRoundedClipRects, A2D);
   boundingRect.Scale(mParameters.mXScale, mParameters.mYScale);
 
   uint32_t maxSize = mManager->GetMaxTextureSize();
   NS_ASSERTION(maxSize > 0, "Invalid max texture size");
-  nsIntSize surfaceSize(std::min<int32_t>(boundingRect.Width(), maxSize),
-                        std::min<int32_t>(boundingRect.Height(), maxSize));
+  gfxSize surfaceSize(std::min<float>(boundingRect.Width(), maxSize),
+                      std::min<float>(boundingRect.Height(), maxSize));
 
   // maskTransform is applied to the clip when it is painted into the mask (as a
   // component of imageTransform), and its inverse used when the mask is used for
   // masking.
   // It is the transform from the masked layer's space to mask space
   gfxMatrix maskTransform;
-  maskTransform.Scale(float(surfaceSize.width)/float(boundingRect.Width()),
-                      float(surfaceSize.height)/float(boundingRect.Height()));
+  maskTransform.Scale(surfaceSize.width/boundingRect.Width(),
+                      surfaceSize.height/boundingRect.Height());
   maskTransform.Translate(-boundingRect.TopLeft());
   // imageTransform is only used when the clip is painted to the mask
   gfxMatrix imageTransform = maskTransform;
   imageTransform.Scale(mParameters.mXScale, mParameters.mYScale);
 
   nsAutoPtr<MaskLayerImageCache::MaskLayerImageKey> newKey(
     new MaskLayerImageCache::MaskLayerImageKey());
 
@@ -3767,19 +3767,21 @@ ContainerState::SetupMaskLayer(Layer *aL
  
   const MaskLayerImageCache::MaskLayerImageKey* lookupKey = newKey;
 
   // check to see if we can reuse a mask image
   nsRefPtr<ImageContainer> container =
     GetMaskLayerImageCache()->FindImageFor(&lookupKey);
 
   if (!container) {
+    nsIntSize surfaceSizeInt = nsIntSize(NSToIntCeil(surfaceSize.width),
+                                         NSToIntCeil(surfaceSize.height));
     // no existing mask image, so build a new one
     nsRefPtr<gfxASurface> surface =
-      aLayer->Manager()->CreateOptimalMaskSurface(surfaceSize);
+      aLayer->Manager()->CreateOptimalMaskSurface(surfaceSizeInt);
 
     // fail if we can't get the right surface
     if (!surface || surface->CairoStatus()) {
       NS_WARNING("Could not create surface for mask layer.");
       SetClipCount(thebesData, 0);
       return;
     }
 
@@ -3793,17 +3795,17 @@ ContainerState::SetupMaskLayer(Layer *aL
     // build the image and container
     container = aLayer->Manager()->CreateImageContainer();
     NS_ASSERTION(container, "Could not create image container for mask layer.");
     static const ImageFormat format = CAIRO_SURFACE;
     nsRefPtr<Image> image = container->CreateImage(&format, 1);
     NS_ASSERTION(image, "Could not create image container for mask layer.");
     CairoImage::Data data;
     data.mSurface = surface;
-    data.mSize = surfaceSize;
+    data.mSize = surfaceSizeInt;
     static_cast<CairoImage*>(image.get())->SetData(data);
     container->SetCurrentImageInTransaction(image);
 
     GetMaskLayerImageCache()->PutImage(newKey.forget(), container);
   }
 
   maskLayer->SetContainer(container);