Bug 856272; don't round our mask size too early so we get a proper transform for small surfaces. r=roc
☠☠ backed out by ca34eba9c8b6 ☠ ☠
authorNicholas Cameron <ncameron@mozilla.com>
Fri, 05 Apr 2013 12:42:14 +1300
changeset 127716 795e9ec338a77719d61475ac57c7a9ec22e4156a
parent 127715 24d4bd4b5fd7cbfb08b328e321dd111905209af7
child 127717 d4499dadb6e779534d556c758952e587b9c7aa67
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)
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
--- 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());
   // 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 =
   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);
@@ -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;
     GetMaskLayerImageCache()->PutImage(newKey.forget(), container);