Bug 539356 - Revert changes made by bug 728983

This commit is contained in:
Matt Woodrow 2012-06-30 15:06:10 +12:00
parent 69d08d71a9
commit d41fe1225c
2 changed files with 28 additions and 79 deletions

View File

@ -152,9 +152,9 @@ public:
CollectOldLayers();
}
void AddInvalidThebesContent(const nsIntRegion& aRegion)
void SetInvalidThebesContent(const nsIntRegion& aRegion)
{
mInvalidThebesContent.Or(mInvalidThebesContent, aRegion);
mInvalidThebesContent = aRegion;
}
void SetInvalidateAllThebesContent()
{
@ -204,8 +204,6 @@ public:
mAppUnitsPerDevPixel);
}
const FrameLayerBuilder::ContainerParameters& ScaleParameters() { return mParameters; };
protected:
/**
* We keep a stack of these to represent the ThebesLayers that are
@ -596,8 +594,6 @@ FrameLayerBuilder::Init(nsDisplayListBuilder* aBuilder)
bool
FrameLayerBuilder::DisplayItemDataEntry::HasNonEmptyContainerLayer()
{
if (mIsSharingContainerLayer)
return true;
for (PRUint32 i = 0; i < mData.Length(); ++i) {
if (mData[i].mLayer->GetType() == Layer::TYPE_CONTAINER &&
mData[i].mLayerState != LAYER_ACTIVE_EMPTY)
@ -733,8 +729,7 @@ FrameLayerBuilder::WillEndTransaction(LayerManager* aManager)
* region property. Otherwise set it to the frame's region property.
*/
static void
SetHasContainerLayer(nsIFrame* aFrame, nsPoint aOffsetToRoot,
RefCountedRegion** aThebesLayerInvalidRegion)
SetHasContainerLayer(nsIFrame* aFrame, nsPoint aOffsetToRoot)
{
aFrame->AddStateBits(NS_FRAME_HAS_CONTAINER_LAYER);
for (nsIFrame* f = aFrame;
@ -751,24 +746,6 @@ SetHasContainerLayer(nsIFrame* aFrame, nsPoint aOffsetToRoot,
} else {
props.Set(ThebesLayerLastPaintOffsetProperty(), new nsPoint(aOffsetToRoot));
}
// Reset or create the invalid region now so we can start collecting
// new dirty areas.
if (*aThebesLayerInvalidRegion) {
(*aThebesLayerInvalidRegion)->AddRef();
props.Set(ThebesLayerInvalidRegionProperty(), *aThebesLayerInvalidRegion);
} else {
RefCountedRegion* invalidRegion = static_cast<RefCountedRegion*>
(props.Get(ThebesLayerInvalidRegionProperty()));
if (invalidRegion) {
invalidRegion->mRegion.SetEmpty();
} else {
invalidRegion = new RefCountedRegion();
invalidRegion->AddRef();
props.Set(ThebesLayerInvalidRegionProperty(), invalidRegion);
}
*aThebesLayerInvalidRegion = invalidRegion;
}
}
static void
@ -2091,36 +2068,6 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder,
return result;
}
static void
ApplyThebesLayerInvalidation(nsDisplayListBuilder* aBuilder,
nsIFrame* aContainerFrame,
nsDisplayItem* aContainerItem,
ContainerState& aState,
nsPoint* aCurrentOffset)
{
*aCurrentOffset = aContainerItem ? aContainerItem->ToReferenceFrame()
: aBuilder->ToReferenceFrame(aContainerFrame);
FrameProperties props = aContainerFrame->Properties();
RefCountedRegion* invalidThebesContent = static_cast<RefCountedRegion*>
(props.Get(ThebesLayerInvalidRegionProperty()));
if (invalidThebesContent) {
const FrameLayerBuilder::ContainerParameters& scaleParameters = aState.ScaleParameters();
aState.AddInvalidThebesContent(invalidThebesContent->mRegion.
ScaleToOutsidePixels(scaleParameters.mXScale, scaleParameters.mYScale,
aState.GetAppUnitsPerDevPixel()));
// We have to preserve the current contents of invalidThebesContent
// because there might be multiple container layers for the same
// frame and we need to invalidate the ThebesLayer children of all
// of them. Also, multiple calls to ApplyThebesLayerInvalidation for the
// same layer can share the same region.
} else {
// The region was deleted to indicate that everything should be
// invalidated.
aState.SetInvalidateAllThebesContent();
}
}
already_AddRefed<ContainerLayer>
FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
@ -2130,6 +2077,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder,
const ContainerParameters& aParameters,
const gfx3DMatrix* aTransform)
{
FrameProperties props = aContainerFrame->Properties();
PRUint32 containerDisplayItemKey =
aContainerItem ? aContainerItem->GetPerFrameKey() : 0;
NS_ASSERTION(aContainerFrame, "Container display items here should have a frame");
@ -2185,28 +2133,30 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder,
entry->mData.AppendElement(
DisplayItemData(containerLayer, containerDisplayItemKey, LAYER_ACTIVE));
}
nsPoint currentOffset;
ApplyThebesLayerInvalidation(aBuilder, aContainerFrame, aContainerItem, state,
&currentOffset);
RefCountedRegion* thebesLayerInvalidRegion = nsnull;
SetHasContainerLayer(aContainerFrame, currentOffset, &thebesLayerInvalidRegion);
nsAutoTArray<nsIFrame*,4> mergedFrames;
if (aContainerItem) {
aContainerItem->GetMergedFrames(&mergedFrames);
}
for (PRUint32 i = 0; i < mergedFrames.Length(); ++i) {
nsIFrame* mergedFrame = mergedFrames[i];
DisplayItemDataEntry* entry = mNewDisplayItemData.PutEntry(mergedFrame);
if (entry) {
// Ensure that UpdateDisplayItemDataForFrame recognizes that we
// still have a container layer associated with this frame.
entry->mIsSharingContainerLayer = true;
}
ApplyThebesLayerInvalidation(aBuilder, mergedFrame, nsnull, state,
&currentOffset);
SetHasContainerLayer(mergedFrame, currentOffset, &thebesLayerInvalidRegion);
nsPoint* offsetAtLastPaint = static_cast<nsPoint*>
(props.Get(ThebesLayerLastPaintOffsetProperty()));
nsPoint currentOffset = aBuilder->ToReferenceFrame(aContainerFrame);
nsRegion* invalidThebesContent(static_cast<nsRegion*>
(props.Get(ThebesLayerInvalidRegionProperty())));
if (invalidThebesContent) {
nsPoint offset = offsetAtLastPaint ? *offsetAtLastPaint : currentOffset;
invalidThebesContent->MoveBy(offset);
state.SetInvalidThebesContent(invalidThebesContent->
ScaleToOutsidePixels(scaleParameters.mXScale, scaleParameters.mYScale,
state.GetAppUnitsPerDevPixel()));
// We have to preserve the current contents of invalidThebesContent
// because there might be multiple container layers for the same
// frame and we need to invalidate the ThebesLayer children of all
// of them.
invalidThebesContent->MoveBy(-offset);
} else {
// The region was deleted to indicate that everything should be
// invalidated.
state.SetInvalidateAllThebesContent();
}
SetHasContainerLayer(aContainerFrame, currentOffset);
}
Clip clip;

View File

@ -476,9 +476,9 @@ protected:
*/
class DisplayItemDataEntry : public nsPtrHashKey<nsIFrame> {
public:
DisplayItemDataEntry(const nsIFrame *key) : nsPtrHashKey<nsIFrame>(key), mIsSharingContainerLayer(false) {}
DisplayItemDataEntry(const nsIFrame *key) : nsPtrHashKey<nsIFrame>(key) {}
DisplayItemDataEntry(DisplayItemDataEntry &toCopy) :
nsPtrHashKey<nsIFrame>(toCopy.mKey), mIsSharingContainerLayer(toCopy.mIsSharingContainerLayer)
nsPtrHashKey<nsIFrame>(toCopy.mKey)
{
// This isn't actually a copy-constructor; notice that it steals toCopy's
// array. Be careful.
@ -488,7 +488,6 @@ protected:
bool HasNonEmptyContainerLayer();
nsAutoTArray<DisplayItemData, 1> mData;
bool mIsSharingContainerLayer;
enum { ALLOW_MEMMOVE = false };
};