Backout 03cb77f8d75d (bug 769021), 04fd792509d6 (bug 786817) for burning the tree
authorEd Morley <emorley@mozilla.com>
Mon, 03 Sep 2012 09:20:05 +0100
changeset 104141 a4fb15293efc0b8fcda83d03e563480b908d420e
parent 104140 7c77ae28cffda7de934bcd8d5a2dd314208a3d40
child 104142 610d4f3abeebdf4763594e24f5b843e7209b1e5c
push id14352
push useremorley@mozilla.com
push dateMon, 03 Sep 2012 08:20:34 +0000
treeherdermozilla-inbound@a4fb15293efc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs769021, 786817
milestone18.0a1
backs out03cb77f8d75d94f0452799f95d344288c07fc45f
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
Backout 03cb77f8d75d (bug 769021), 04fd792509d6 (bug 786817) for burning the tree
layout/base/FrameLayerBuilder.cpp
layout/base/MaskLayerImageCache.cpp
layout/base/MaskLayerImageCache.h
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -493,28 +493,20 @@ class ThebesDisplayItemLayerUserData : p
 {
 public:
   ThebesDisplayItemLayerUserData() :
     mForcedBackgroundColor(NS_RGBA(0,0,0,0)),
     mXScale(1.f), mYScale(1.f),
     mActiveScrolledRootPosition(0, 0) {}
 
   /**
-   * Record the number of clips in the Thebes layer's mask layer.
-   * Should not be reset when the layer is recycled since it is used to track
-   * changes in the use of mask layers.
-   */
-  uint32_t mMaskClipCount;
-
-  /**
    * A color that should be painted over the bounds of the layer's visible
    * region before any other content is painted.
    */
   nscolor mForcedBackgroundColor;
-
   /**
    * The resolution scale used.
    */
   float mXScale, mYScale;
 
   /**
    * We try to make 0,0 of the ThebesLayer be the top-left of the
    * border-box of the "active scrolled root" frame (i.e. the nearest ancestor
@@ -1678,20 +1670,16 @@ ContainerState::FindThebesLayerFor(nsDis
     mThebesLayerDataStack.AppendElement(thebesLayerData);
     thebesLayerData->mLayer = layer;
     thebesLayerData->mActiveScrolledRoot = aActiveScrolledRoot;
   } else {
     thebesLayerData = mThebesLayerDataStack[lowestUsableLayerWithScrolledRoot];
     layer = thebesLayerData->mLayer;
   }
 
-  // check to see if the new item has rounded rect clips in common with
-  // other items in the layer
-  thebesLayerData->UpdateCommonClipCount(aClip);
-
   thebesLayerData->Accumulate(this, aItem, aVisibleRect, aDrawRect, aClip);
 
   return thebesLayerData;
 }
 
 #ifdef MOZ_DUMP_PAINTING
 static void
 DumpPaintedImage(nsDisplayItem* aItem, gfxASurface* aSurf)
@@ -3209,55 +3197,35 @@ FrameLayerBuilder::Clip::RemoveRoundedCo
   if (mRoundedClipRects.IsEmpty())
     return;
 
   mClipRect = NonRoundedIntersection();
   mRoundedClipRects.Clear();
 }
 
 gfxRect
-CalculateBounds(const nsTArray<FrameLayerBuilder::Clip::RoundedRect>& aRects, int32_t A2D)
+CalculateBounds(nsTArray<FrameLayerBuilder::Clip::RoundedRect> aRects, int32_t A2D)
 {
   nsRect bounds = aRects[0].mRect;
   for (uint32_t i = 1; i < aRects.Length(); ++i) {
     bounds.UnionRect(bounds, aRects[i].mRect);
    }
  
   return nsLayoutUtils::RectToGfxRect(bounds, A2D);
 }
-
-static void
-SetClipCount(ThebesDisplayItemLayerUserData* aThebesData,
-             uint32_t aClipCount)
-{
-  if (aThebesData) {
-    aThebesData->mMaskClipCount = aClipCount;
-  }
-}
-
+ 
 void
 ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aClip,
                                uint32_t aRoundedRectClipCount)
 {
-  // if the number of clips we are going to mask has decreased, then aLayer might have
-  // cached graphics which assume the existence of a soon-to-be non-existent mask layer
-  // in that case, invalidate the whole layer.
-  ThebesDisplayItemLayerUserData* thebesData = GetThebesDisplayItemLayerUserData(aLayer);
-  if (thebesData &&
-      aRoundedRectClipCount < thebesData->mMaskClipCount) {
-    ThebesLayer* thebes = aLayer->AsThebesLayer();
-    thebes->InvalidateRegion(thebes->GetValidRegion().GetBounds());
-  }
-
   // don't build an unnecessary mask
   nsIntRect layerBounds = aLayer->GetVisibleRegion().GetBounds();
   if (aClip.mRoundedClipRects.IsEmpty() ||
-      aRoundedRectClipCount == 0 ||
+      aRoundedRectClipCount <= 0 ||
       layerBounds.IsEmpty()) {
-    SetClipCount(thebesData, 0);
     return;
   }
 
   // check if we can re-use the mask layer
   nsRefPtr<ImageLayer> maskLayer =  CreateOrRecycleMaskImageLayerFor(aLayer);
   MaskLayerUserData* userData = GetMaskLayerUserData(maskLayer);
 
   MaskLayerUserData newData;
@@ -3265,17 +3233,16 @@ ContainerState::SetupMaskLayer(Layer *aL
   if (aRoundedRectClipCount < newData.mRoundedClipRects.Length()) {
     newData.mRoundedClipRects.TruncateLength(aRoundedRectClipCount);
   }
   newData.mScaleX = mParameters.mXScale;
   newData.mScaleY = mParameters.mYScale;
 
   if (*userData == newData) {
     aLayer->SetMaskLayer(maskLayer);
-    SetClipCount(thebesData, aRoundedRectClipCount);
     return;
   }
 
   // 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);
 
@@ -3291,42 +3258,45 @@ ContainerState::SetupMaskLayer(Layer *aL
   gfxMatrix maskTransform;
   maskTransform.Scale(float(surfaceSize.width)/float(boundingRect.Width()),
                       float(surfaceSize.height)/float(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(aLayer->Manager()->GetBackendType()));
-
   // copy and transform the rounded rects
+  nsTArray<MaskLayerImageCache::PixelRoundedRect> roundedRects;
   for (uint32_t i = 0; i < newData.mRoundedClipRects.Length(); ++i) {
-    newKey->mRoundedClipRects.AppendElement(
+    roundedRects.AppendElement(
       MaskLayerImageCache::PixelRoundedRect(newData.mRoundedClipRects[i],
                                             mContainerFrame->PresContext()));
-    newKey->mRoundedClipRects[i].ScaleAndTranslate(imageTransform);
+    roundedRects[i].ScaleAndTranslate(imageTransform);
   }
  
-  const MaskLayerImageCache::MaskLayerImageKey* lookupKey = newKey;
-
   // check to see if we can reuse a mask image
+  const MaskLayerImageCache::MaskLayerImageKey* key =
+    new MaskLayerImageCache::MaskLayerImageKey(roundedRects, aLayer->Manager()->GetBackendType());
+  const MaskLayerImageCache::MaskLayerImageKey* lookupKey = key;
+
   nsRefPtr<ImageContainer> container =
     GetMaskLayerImageCache()->FindImageFor(&lookupKey);
 
-  if (!container) {
+  if (container) {
+    // track the returned key for the mask image
+    delete key;
+    key = lookupKey;
+  } else {
     // no existing mask image, so build a new one
     nsRefPtr<gfxASurface> surface =
       aLayer->Manager()->CreateOptimalMaskSurface(surfaceSize);
 
     // 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;
     }
 
     nsRefPtr<gfxContext> context = new gfxContext(surface);
     context->Multiply(imageTransform);
 
     // paint the clipping rects with alpha to create the mask
     context->SetColor(gfxRGBA(1, 1, 1, 1));
@@ -3339,26 +3309,25 @@ ContainerState::SetupMaskLayer(Layer *aL
     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;
     static_cast<CairoImage*>(image.get())->SetData(data);
     container->SetCurrentImageInTransaction(image);
 
-    GetMaskLayerImageCache()->PutImage(newKey.forget(), container);
+    GetMaskLayerImageCache()->PutImage(key, container);
   }
 
   maskLayer->SetContainer(container);
   maskLayer->SetBaseTransform(gfx3DMatrix::From2D(maskTransform.Invert()));
 
   // save the details of the clip in user data
   userData->mScaleX = newData.mScaleX;
   userData->mScaleY = newData.mScaleY;
   userData->mRoundedClipRects.SwapElements(newData.mRoundedClipRects);
-  userData->mImageKey = lookupKey;
+  userData->mImageKey = key;
 
   aLayer->SetMaskLayer(maskLayer);
-  SetClipCount(thebesData, aRoundedRectClipCount);
   return;
 }
 
 } // namespace mozilla
--- a/layout/base/MaskLayerImageCache.cpp
+++ b/layout/base/MaskLayerImageCache.cpp
@@ -7,23 +7,20 @@
 #include "ImageContainer.h"
 
 using namespace mozilla::layers;
 
 namespace mozilla {
 
 MaskLayerImageCache::MaskLayerImageCache()
 {
-  MOZ_COUNT_CTOR(MaskLayerImageCache);
   mMaskImageContainers.Init();
 }
 MaskLayerImageCache::~MaskLayerImageCache()
-{
-  MOZ_COUNT_DTOR(MaskLayerImageCache);
-}
+{}
 
 
 /* static */ PLDHashOperator
 MaskLayerImageCache::SweepFunc(MaskLayerImageEntry* aEntry,
                                void* aUserArg)
 {
   const MaskLayerImageCache::MaskLayerImageKey* key = aEntry->mKey;
 
--- a/layout/base/MaskLayerImageCache.h
+++ b/layout/base/MaskLayerImageCache.h
@@ -45,34 +45,20 @@ public:
   {
     PixelRoundedRect(const FrameLayerBuilder::Clip::RoundedRect& aRRect,
                      nsPresContext* aPresContext)
       : mRect(aPresContext->AppUnitsToGfxUnits(aRRect.mRect.x),
               aPresContext->AppUnitsToGfxUnits(aRRect.mRect.y),
               aPresContext->AppUnitsToGfxUnits(aRRect.mRect.width),
               aPresContext->AppUnitsToGfxUnits(aRRect.mRect.height))
     {
-      MOZ_COUNT_CTOR(PixelRoundedRect);
       NS_FOR_CSS_HALF_CORNERS(corner) {
         mRadii[corner] = aPresContext->AppUnitsToGfxUnits(aRRect.mRadii[corner]);
       }
     }
-    PixelRoundedRect(const PixelRoundedRect& aPRR)
-      : mRect(aPRR.mRect)
-    {
-      MOZ_COUNT_CTOR(PixelRoundedRect);
-      NS_FOR_CSS_HALF_CORNERS(corner) {
-        mRadii[corner] = aPRR.mRadii[corner];
-      }
-    }
-
-    ~PixelRoundedRect()
-    {
-      MOZ_COUNT_DTOR(PixelRoundedRect);
-    }
 
     // Applies the scale and translate components of aTransform.
     // It is an error to pass a matrix which does more than just scale
     // and translate.
     void ScaleAndTranslate(const gfxMatrix& aTransform)
     {
       NS_ASSERTION(aTransform.xy == 0 && aTransform.yx == 0,
                    "Transform has a component other than scale and translate");
@@ -108,52 +94,36 @@ public:
       hash = AddToHash(hash, HashBytes(mRadii, 8*sizeof(gfxFloat)));
 
       return hash;
     }
 
     gfxRect mRect;
     // Indices into mRadii are the NS_CORNER_* constants in nsStyleConsts.h
     gfxFloat mRadii[8];
-
-  private:
-    PixelRoundedRect() MOZ_DELETE;
   };
 
   /**
    * A key to identify cached image containers.
    * The const-ness of this class is with respect to its use as a key into a
    * hashtable, so anything not used to create the hash is mutable.
    * mLayerCount counts the number of mask layers which have a reference to
    * MaskLayerImageEntry::mContainer; it is maintained by MaskLayerUserData,
    * which keeps a reference to the key. There will usually be mLayerCount + 1
    * pointers to a key object (the +1 being from the hashtable entry), but this
    * invariant may be temporarily broken.
    */
-  struct MaskLayerImageKey
+  class MaskLayerImageKey
   {
-    MaskLayerImageKey(layers::LayersBackend aBackend)
+  public:
+    MaskLayerImageKey(const nsTArray<PixelRoundedRect>& aRoundedClipRects, layers::LayersBackend aBackend)
       : mBackend(aBackend)
       , mLayerCount(0)
-      , mRoundedClipRects()
-    {
-      MOZ_COUNT_CTOR(MaskLayerImageKey);
-    }
-    MaskLayerImageKey(const MaskLayerImageKey& aKey)
-      : mBackend(aKey.mBackend)
-      , mLayerCount(aKey.mLayerCount)
-      , mRoundedClipRects(aKey.mRoundedClipRects)
-    {
-      MOZ_COUNT_CTOR(MaskLayerImageKey);
-    }
-
-    ~MaskLayerImageKey()
-    {
-      MOZ_COUNT_DTOR(MaskLayerImageKey);
-    }
+      , mRoundedClipRects(aRoundedClipRects)
+    {}
 
     void AddRef() const { ++mLayerCount; }
     void Release() const
     {
       NS_ASSERTION(mLayerCount > 0, "Inconsistent layer count");
       --mLayerCount;
     }
 
@@ -197,24 +167,21 @@ public:
 protected:
 
   class MaskLayerImageEntry : public PLDHashEntryHdr
   {
   public:
     typedef const MaskLayerImageKey& KeyType;
     typedef const MaskLayerImageKey* KeyTypePointer;
 
-    MaskLayerImageEntry(KeyTypePointer aKey) : mKey(aKey)
+    MaskLayerImageEntry(KeyTypePointer aKey) : mKey(aKey) {}
+    MaskLayerImageEntry(const MaskLayerImageEntry& aOther)
+      : mKey(aOther.mKey.get())
     {
-      MOZ_COUNT_CTOR(MaskLayerImageEntry);
-    }
-    MaskLayerImageEntry(const MaskLayerImageEntry& aOther) MOZ_DELETE;
-    ~MaskLayerImageEntry()
-    {
-      MOZ_COUNT_DTOR(MaskLayerImageEntry);
+      NS_ERROR("ALLOW_MEMMOVE == true, should never be called");
     }
 
     // KeyEquals(): does this entry match this key?
     bool KeyEquals(KeyTypePointer aKey) const
     {
       return *mKey == *aKey;
     }