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),
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.
*/
@ -1683,10 +1675,6 @@ ContainerState::FindThebesLayerFor(nsDisplayItem* aItem,
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;
@ -3214,7 +3202,7 @@ FrameLayerBuilder::Clip::RemoveRoundedCorners()
}
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) {
@ -3223,36 +3211,16 @@ CalculateBounds(const nsTArray<FrameLayerBuilder::Clip::RoundedRect>& aRects, in
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;
}
@ -3270,7 +3238,6 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
if (*userData == newData) {
aLayer->SetMaskLayer(maskLayer);
SetClipCount(thebesData, aRoundedRectClipCount);
return;
}
@ -3296,24 +3263,28 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
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);
@ -3321,7 +3292,6 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
// 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;
}
@ -3344,7 +3314,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
static_cast<CairoImage*>(image.get())->SetData(data);
container->SetCurrentImageInTransaction(image);
GetMaskLayerImageCache()->PutImage(newKey.forget(), container);
GetMaskLayerImageCache()->PutImage(key, container);
}
maskLayer->SetContainer(container);
@ -3354,10 +3324,9 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
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;
}

View File

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

View File

@ -50,24 +50,10 @@ public:
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
@ -113,9 +99,6 @@ public:
gfxRect mRect;
// Indices into mRadii are the NS_CORNER_* constants in nsStyleConsts.h
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
* 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
@ -202,14 +172,11 @@ protected:
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?