Backout 03cb77f8d75d (bug 769021), 04fd792509d6 (bug 786817) for burning the tree

This commit is contained in:
Ed Morley 2012-09-03 09:20:05 +01:00
parent e35ea77a3f
commit 2ca37472a4
3 changed files with 27 additions and 94 deletions

View File

@ -497,19 +497,11 @@ public:
mXScale(1.f), mYScale(1.f), mXScale(1.f), mYScale(1.f),
mActiveScrolledRootPosition(0, 0) {} 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 * A color that should be painted over the bounds of the layer's visible
* region before any other content is painted. * region before any other content is painted.
*/ */
nscolor mForcedBackgroundColor; nscolor mForcedBackgroundColor;
/** /**
* The resolution scale used. * The resolution scale used.
*/ */
@ -1683,10 +1675,6 @@ ContainerState::FindThebesLayerFor(nsDisplayItem* aItem,
layer = thebesLayerData->mLayer; 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); thebesLayerData->Accumulate(this, aItem, aVisibleRect, aDrawRect, aClip);
return thebesLayerData; return thebesLayerData;
@ -3214,7 +3202,7 @@ FrameLayerBuilder::Clip::RemoveRoundedCorners()
} }
gfxRect 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; nsRect bounds = aRects[0].mRect;
for (uint32_t i = 1; i < aRects.Length(); ++i) { for (uint32_t i = 1; i < aRects.Length(); ++i) {
@ -3224,35 +3212,15 @@ CalculateBounds(const nsTArray<FrameLayerBuilder::Clip::RoundedRect>& aRects, in
return nsLayoutUtils::RectToGfxRect(bounds, A2D); return nsLayoutUtils::RectToGfxRect(bounds, A2D);
} }
static void
SetClipCount(ThebesDisplayItemLayerUserData* aThebesData,
uint32_t aClipCount)
{
if (aThebesData) {
aThebesData->mMaskClipCount = aClipCount;
}
}
void void
ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aClip, ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aClip,
uint32_t aRoundedRectClipCount) 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 // don't build an unnecessary mask
nsIntRect layerBounds = aLayer->GetVisibleRegion().GetBounds(); nsIntRect layerBounds = aLayer->GetVisibleRegion().GetBounds();
if (aClip.mRoundedClipRects.IsEmpty() || if (aClip.mRoundedClipRects.IsEmpty() ||
aRoundedRectClipCount == 0 || aRoundedRectClipCount <= 0 ||
layerBounds.IsEmpty()) { layerBounds.IsEmpty()) {
SetClipCount(thebesData, 0);
return; return;
} }
@ -3270,7 +3238,6 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
if (*userData == newData) { if (*userData == newData) {
aLayer->SetMaskLayer(maskLayer); aLayer->SetMaskLayer(maskLayer);
SetClipCount(thebesData, aRoundedRectClipCount);
return; return;
} }
@ -3296,24 +3263,28 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
gfxMatrix imageTransform = maskTransform; gfxMatrix imageTransform = maskTransform;
imageTransform.Scale(mParameters.mXScale, mParameters.mYScale); imageTransform.Scale(mParameters.mXScale, mParameters.mYScale);
nsAutoPtr<MaskLayerImageCache::MaskLayerImageKey> newKey(
new MaskLayerImageCache::MaskLayerImageKey(aLayer->Manager()->GetBackendType()));
// copy and transform the rounded rects // copy and transform the rounded rects
nsTArray<MaskLayerImageCache::PixelRoundedRect> roundedRects;
for (uint32_t i = 0; i < newData.mRoundedClipRects.Length(); ++i) { for (uint32_t i = 0; i < newData.mRoundedClipRects.Length(); ++i) {
newKey->mRoundedClipRects.AppendElement( roundedRects.AppendElement(
MaskLayerImageCache::PixelRoundedRect(newData.mRoundedClipRects[i], MaskLayerImageCache::PixelRoundedRect(newData.mRoundedClipRects[i],
mContainerFrame->PresContext())); 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 // 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 = nsRefPtr<ImageContainer> container =
GetMaskLayerImageCache()->FindImageFor(&lookupKey); 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 // no existing mask image, so build a new one
nsRefPtr<gfxASurface> surface = nsRefPtr<gfxASurface> surface =
aLayer->Manager()->CreateOptimalMaskSurface(surfaceSize); aLayer->Manager()->CreateOptimalMaskSurface(surfaceSize);
@ -3321,7 +3292,6 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
// fail if we can't get the right surface // fail if we can't get the right surface
if (!surface || surface->CairoStatus()) { if (!surface || surface->CairoStatus()) {
NS_WARNING("Could not create surface for mask layer."); NS_WARNING("Could not create surface for mask layer.");
SetClipCount(thebesData, 0);
return; return;
} }
@ -3344,7 +3314,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
static_cast<CairoImage*>(image.get())->SetData(data); static_cast<CairoImage*>(image.get())->SetData(data);
container->SetCurrentImageInTransaction(image); container->SetCurrentImageInTransaction(image);
GetMaskLayerImageCache()->PutImage(newKey.forget(), container); GetMaskLayerImageCache()->PutImage(key, container);
} }
maskLayer->SetContainer(container); maskLayer->SetContainer(container);
@ -3354,10 +3324,9 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
userData->mScaleX = newData.mScaleX; userData->mScaleX = newData.mScaleX;
userData->mScaleY = newData.mScaleY; userData->mScaleY = newData.mScaleY;
userData->mRoundedClipRects.SwapElements(newData.mRoundedClipRects); userData->mRoundedClipRects.SwapElements(newData.mRoundedClipRects);
userData->mImageKey = lookupKey; userData->mImageKey = key;
aLayer->SetMaskLayer(maskLayer); aLayer->SetMaskLayer(maskLayer);
SetClipCount(thebesData, aRoundedRectClipCount);
return; return;
} }

View File

@ -12,13 +12,10 @@ namespace mozilla {
MaskLayerImageCache::MaskLayerImageCache() MaskLayerImageCache::MaskLayerImageCache()
{ {
MOZ_COUNT_CTOR(MaskLayerImageCache);
mMaskImageContainers.Init(); mMaskImageContainers.Init();
} }
MaskLayerImageCache::~MaskLayerImageCache() MaskLayerImageCache::~MaskLayerImageCache()
{ {}
MOZ_COUNT_DTOR(MaskLayerImageCache);
}
/* static */ PLDHashOperator /* static */ PLDHashOperator

View File

@ -50,24 +50,10 @@ public:
aPresContext->AppUnitsToGfxUnits(aRRect.mRect.width), aPresContext->AppUnitsToGfxUnits(aRRect.mRect.width),
aPresContext->AppUnitsToGfxUnits(aRRect.mRect.height)) aPresContext->AppUnitsToGfxUnits(aRRect.mRect.height))
{ {
MOZ_COUNT_CTOR(PixelRoundedRect);
NS_FOR_CSS_HALF_CORNERS(corner) { NS_FOR_CSS_HALF_CORNERS(corner) {
mRadii[corner] = aPresContext->AppUnitsToGfxUnits(aRRect.mRadii[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. // Applies the scale and translate components of aTransform.
// It is an error to pass a matrix which does more than just scale // It is an error to pass a matrix which does more than just scale
@ -113,9 +99,6 @@ public:
gfxRect mRect; gfxRect mRect;
// Indices into mRadii are the NS_CORNER_* constants in nsStyleConsts.h // Indices into mRadii are the NS_CORNER_* constants in nsStyleConsts.h
gfxFloat mRadii[8]; gfxFloat mRadii[8];
private:
PixelRoundedRect() MOZ_DELETE;
}; };
/** /**
@ -128,27 +111,14 @@ public:
* pointers to a key object (the +1 being from the hashtable entry), but this * pointers to a key object (the +1 being from the hashtable entry), but this
* invariant may be temporarily broken. * invariant may be temporarily broken.
*/ */
struct MaskLayerImageKey class MaskLayerImageKey
{ {
MaskLayerImageKey(layers::LayersBackend aBackend) public:
MaskLayerImageKey(const nsTArray<PixelRoundedRect>& aRoundedClipRects, layers::LayersBackend aBackend)
: mBackend(aBackend) : mBackend(aBackend)
, mLayerCount(0) , mLayerCount(0)
, mRoundedClipRects() , mRoundedClipRects(aRoundedClipRects)
{ {}
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);
}
void AddRef() const { ++mLayerCount; } void AddRef() const { ++mLayerCount; }
void Release() const void Release() const
@ -202,14 +172,11 @@ protected:
typedef const MaskLayerImageKey& KeyType; typedef const MaskLayerImageKey& KeyType;
typedef const MaskLayerImageKey* KeyTypePointer; 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); NS_ERROR("ALLOW_MEMMOVE == true, should never be called");
}
MaskLayerImageEntry(const MaskLayerImageEntry& aOther) MOZ_DELETE;
~MaskLayerImageEntry()
{
MOZ_COUNT_DTOR(MaskLayerImageEntry);
} }
// KeyEquals(): does this entry match this key? // KeyEquals(): does this entry match this key?