Backout changeset 60affaedccc3 (bug 539356) because of performance and correctness regressions

This commit is contained in:
Ehsan Akhgari 2012-07-03 20:26:55 -04:00
Родитель 658ec4eb81
Коммит 97259d4a95
9 изменённых файлов: 48 добавлений и 128 удалений

Просмотреть файл

@ -58,14 +58,6 @@ public:
nsRefPtr<LayerManager> mLayerManager;
};
LayerManagerLayerBuilder::~LayerManagerLayerBuilder()
{
MOZ_COUNT_DTOR(LayerManagerLayerBuilder);
if (mDelete) {
delete mLayerBuilder;
}
}
namespace {
// a global cache of image containers used for mask layers
@ -130,12 +122,10 @@ class ContainerState {
public:
ContainerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
FrameLayerBuilder* aLayerBuilder,
nsIFrame* aContainerFrame,
ContainerLayer* aContainerLayer,
const FrameLayerBuilder::ContainerParameters& aParameters) :
mBuilder(aBuilder), mManager(aManager),
mLayerBuilder(aLayerBuilder),
mContainerFrame(aContainerFrame), mContainerLayer(aContainerLayer),
mParameters(aParameters),
mNextFreeRecycledThebesLayer(0), mNextFreeRecycledColorLayer(0),
@ -436,7 +426,6 @@ protected:
nsDisplayListBuilder* mBuilder;
LayerManager* mManager;
FrameLayerBuilder* mLayerBuilder;
nsIFrame* mContainerFrame;
ContainerLayer* mContainerLayer;
FrameLayerBuilder::ContainerParameters mParameters;
@ -573,7 +562,6 @@ ThebesDisplayItemLayerUserData* GetThebesDisplayItemLayerUserData(Layer* aLayer)
} // anonymous namespace
PRUint8 gLayerManagerLayerBuilder;
/* static */ void
FrameLayerBuilder::Shutdown()
@ -869,30 +857,6 @@ FrameLayerBuilder::GetOldLayerFor(nsIFrame* aFrame, PRUint32 aDisplayItemKey)
return nsnull;
}
/* static */ Layer*
FrameLayerBuilder::GetDebugOldLayerFor(nsIFrame* aFrame, PRUint32 aDisplayItemKey)
{
FrameProperties props = aFrame->Properties();
LayerManagerData* data = static_cast<LayerManagerData*>(props.Get(LayerManagerDataProperty()));
if (!data) {
return nsnull;
}
DisplayItemDataEntry *entry = data->mFramesWithLayers.GetEntry(aFrame);
if (!entry)
return nsnull;
nsTArray<DisplayItemData> *array = &entry->mData;
if (!array)
return nsnull;
for (PRUint32 i = 0; i < array->Length(); ++i) {
if (array->ElementAt(i).mDisplayItemKey == aDisplayItemKey) {
return array->ElementAt(i).mLayer;
}
}
return nsnull;
}
/**
* Invalidate aRegion in aLayer. aLayer is in the coordinate system
* *after* aTranslation has been applied, so we need to
@ -1074,7 +1038,7 @@ ContainerState::CreateOrRecycleThebesLayer(nsIFrame* aActiveScrolledRoot)
data->mYScale = mParameters.mYScale;
layer->SetAllowResidualTranslation(mParameters.AllowResidualTranslation());
mLayerBuilder->SaveLastPaintOffset(layer);
mBuilder->LayerBuilder()->SaveLastPaintOffset(layer);
// Set up transform so that 0,0 in the Thebes layer corresponds to the
// (pixel-snapped) top-left of the aActiveScrolledRoot.
@ -1183,7 +1147,7 @@ ContainerState::FindOpaqueBackgroundColorFor(PRInt32 aThebesLayerIndex)
nsRect rect =
target->mVisibleRegion.GetBounds().ToAppUnits(mAppUnitsPerDevPixel);
rect.ScaleInverseRoundOut(mParameters.mXScale, mParameters.mYScale);
return mLayerBuilder->
return mBuilder->LayerBuilder()->
FindOpaqueColorCovering(mBuilder, candidate->mLayer, rect);
}
return NS_RGBA(0,0,0,0);
@ -1331,7 +1295,7 @@ ContainerState::PopThebesLayerData()
NS_ASSERTION(commonClipCount >= 0, "Inconsistent clip count.");
SetupMaskLayer(layer, data->mItemClip, commonClipCount);
// copy commonClipCount to the entry
FrameLayerBuilder::ThebesLayerItemsEntry* entry = mLayerBuilder->
FrameLayerBuilder::ThebesLayerItemsEntry* entry = mBuilder->LayerBuilder()->
GetThebesLayerItemsEntry(static_cast<ThebesLayer*>(layer.get()));
entry->mCommonClipCount = commonClipCount;
} else {
@ -1601,8 +1565,7 @@ static void
PaintInactiveLayer(nsDisplayListBuilder* aBuilder,
nsDisplayItem* aItem,
gfxContext* aContext,
nsRenderingContext* aCtx,
FrameLayerBuilder *aLayerBuilder)
nsRenderingContext* aCtx)
{
// This item has an inactive layer. Render it to a ThebesLayer
// using a temporary BasicLayerManager.
@ -1622,7 +1585,6 @@ PaintInactiveLayer(nsDisplayListBuilder* aBuilder,
#endif
nsRefPtr<BasicLayerManager> tempManager = new BasicLayerManager();
tempManager->SetUserData(&gLayerManagerLayerBuilder, new LayerManagerLayerBuilder(aLayerBuilder, false));
tempManager->BeginTransactionWithTarget(context);
nsRefPtr<Layer> layer =
aItem->BuildLayer(aBuilder, tempManager, FrameLayerBuilder::ContainerParameters());
@ -1633,13 +1595,13 @@ PaintInactiveLayer(nsDisplayListBuilder* aBuilder,
RestrictVisibleRegionForLayer(layer, itemVisibleRect);
tempManager->SetRoot(layer);
aLayerBuilder->WillEndTransaction(tempManager);
aBuilder->LayerBuilder()->WillEndTransaction(tempManager);
if (aItem->GetType() == nsDisplayItem::TYPE_SVG_EFFECTS) {
static_cast<nsDisplaySVGEffects*>(aItem)->PaintAsLayer(aBuilder, aCtx, tempManager);
} else {
tempManager->EndTransaction(FrameLayerBuilder::DrawThebesLayer, aBuilder);
}
aLayerBuilder->DidEndTransaction(tempManager);
aBuilder->LayerBuilder()->DidEndTransaction(tempManager);
#ifdef MOZ_DUMP_PAINTING
if (gfxUtils::sDumpPainting) {
@ -1784,7 +1746,7 @@ ContainerState::ProcessDisplayItems(const nsDisplayList& aList,
InvalidateForLayerChange(item, ownLayer);
mNewChildLayers.AppendElement(ownLayer);
mLayerBuilder->AddLayerDisplayItem(ownLayer, item, layerState);
mBuilder->LayerBuilder()->AddLayerDisplayItem(ownLayer, item, layerState);
} else {
ThebesLayerData* data =
FindThebesLayerFor(item, itemVisibleRect, itemDrawRect, aClip,
@ -1796,9 +1758,9 @@ ContainerState::ProcessDisplayItems(const nsDisplayList& aList,
InvalidateForLayerChange(item, data->mLayer);
mLayerBuilder->AddThebesDisplayItem(data->mLayer, item, aClip,
mContainerFrame,
layerState);
mBuilder->LayerBuilder()->AddThebesDisplayItem(data->mLayer, item, aClip,
mContainerFrame,
layerState);
// check to see if the new item has rounded rect clips in common with
// other items in the layer
@ -1814,7 +1776,7 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem, Layer* aNewLayer)
NS_ASSERTION(f, "Display items that render using Thebes must have a frame");
PRUint32 key = aItem->GetPerFrameKey();
NS_ASSERTION(key, "Display items that render using Thebes must have a key");
Layer* oldLayer = mLayerBuilder->GetOldLayerFor(f, key);
Layer* oldLayer = mBuilder->LayerBuilder()->GetOldLayerFor(f, key);
if (!oldLayer) {
// Nothing to do here, this item didn't have a layer before
return;
@ -1837,7 +1799,7 @@ ContainerState::InvalidateForLayerChange(nsDisplayItem* aItem, Layer* aNewLayer)
// or a new scale here
InvalidatePostTransformRegion(t,
bounds.ScaleToOutsidePixels(data->mXScale, data->mYScale, mAppUnitsPerDevPixel),
mLayerBuilder->GetLastPaintOffset(t));
mBuilder->LayerBuilder()->GetLastPaintOffset(t));
}
if (aNewLayer) {
ThebesLayer* newLayer = aNewLayer->AsThebesLayer();
@ -2176,8 +2138,8 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder,
ContainerParameters scaleParameters =
ChooseScaleAndSetTransform(this, aContainerFrame, aTransform, aParameters,
containerLayer);
ContainerState state(aBuilder, aManager, GetLayerBuilderForManager(aManager),
aContainerFrame, containerLayer, scaleParameters);
ContainerState state(aBuilder, aManager, aContainerFrame, containerLayer,
scaleParameters);
if (aManager == mRetainingManager) {
DisplayItemDataEntry* entry = mNewDisplayItemData.PutEntry(aContainerFrame);
@ -2471,16 +2433,15 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer,
nsDisplayListBuilder* builder = static_cast<nsDisplayListBuilder*>
(aCallbackData);
FrameLayerBuilder *layerBuilder = GetLayerBuilderForManager(aLayer->Manager());
if (layerBuilder->CheckDOMModified())
if (builder->LayerBuilder()->CheckDOMModified())
return;
nsTArray<ClippedDisplayItem> items;
PRUint32 commonClipCount;
nsIFrame* containerLayerFrame;
{
ThebesLayerItemsEntry* entry = layerBuilder->mThebesLayerItems.GetEntry(aLayer);
ThebesLayerItemsEntry* entry =
builder->LayerBuilder()->mThebesLayerItems.GetEntry(aLayer);
NS_ASSERTION(entry, "We shouldn't be drawing into a layer with no items!");
items.SwapElements(entry->mItems);
commonClipCount = entry->mCommonClipCount;
@ -2604,7 +2565,7 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer,
}
if (cdi->mInactiveLayer) {
PaintInactiveLayer(builder, cdi->mItem, aContext, rc, layerBuilder);
PaintInactiveLayer(builder, cdi->mItem, aContext, rc);
} else {
nsIFrame* frame = cdi->mItem->GetUnderlyingFrame();
if (frame) {
@ -2622,7 +2583,7 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer,
}
}
if (layerBuilder->CheckDOMModified())
if (builder->LayerBuilder()->CheckDOMModified())
break;
}
@ -2652,10 +2613,12 @@ FrameLayerBuilder::CheckDOMModified()
}
#ifdef MOZ_DUMP_PAINTING
/* static */ void
FrameLayerBuilder::DumpRetainedLayerTree(LayerManager* aManager, FILE* aFile)
void
FrameLayerBuilder::DumpRetainedLayerTree(FILE* aFile)
{
aManager->Dump(aFile);
if (mRetainingManager) {
mRetainingManager->Dump(aFile);
}
}
#endif

Просмотреть файл

@ -21,8 +21,6 @@ class nsRootPresContext;
namespace mozilla {
class FrameLayerBuilder;
enum LayerState {
LAYER_NONE,
LAYER_INACTIVE,
@ -36,35 +34,6 @@ enum LayerState {
LAYER_SVG_EFFECTS
};
class LayerManagerLayerBuilder : public layers::LayerUserData {
public:
LayerManagerLayerBuilder(FrameLayerBuilder* aBuilder, bool aDelete = true)
: mLayerBuilder(aBuilder)
, mDelete(aDelete)
{
MOZ_COUNT_CTOR(LayerManagerLayerBuilder);
}
~LayerManagerLayerBuilder();
FrameLayerBuilder* mLayerBuilder;
bool mDelete;
};
extern PRUint8 gLayerManagerLayerBuilder;
class ContainerLayerPresContext : public layers::LayerUserData {
public:
nsPresContext* mPresContext;
};
extern PRUint8 gContainerLayerPresContext;
static inline FrameLayerBuilder *GetLayerBuilderForManager(layers::LayerManager* aManager)
{
LayerManagerLayerBuilder *data = static_cast<LayerManagerLayerBuilder*>(aManager->GetUserData(&gLayerManagerLayerBuilder));
return data ? data->mLayerBuilder : nsnull;
}
/**
* The FrameLayerBuilder belongs to an nsDisplayListBuilder and is
* responsible for converting display lists into layer trees.
@ -116,14 +85,9 @@ public:
mDetectedDOMModification(false),
mInvalidateAllLayers(false)
{
MOZ_COUNT_CTOR(FrameLayerBuilder);
mNewDisplayItemData.Init();
mThebesLayerItems.Init();
}
~FrameLayerBuilder()
{
MOZ_COUNT_DTOR(FrameLayerBuilder);
}
static void Shutdown();
@ -268,7 +232,7 @@ public:
* Dumps this FrameLayerBuilder's retained layer manager's retained
* layer tree to stderr.
*/
static void DumpRetainedLayerTree(LayerManager* aManager, FILE* aFile = stdout);
void DumpRetainedLayerTree(FILE* aFile = stdout);
#endif
/******* PRIVATE METHODS to FrameLayerBuilder.cpp ********/
@ -305,7 +269,6 @@ public:
*/
Layer* GetOldLayerFor(nsIFrame* aFrame, PRUint32 aDisplayItemKey);
static Layer* GetDebugOldLayerFor(nsIFrame* aFrame, PRUint32 aDisplayItemKey);
/**
* Try to determine whether the ThebesLayer aLayer paints an opaque
* single color everywhere it's visible in aRect.

Просмотреть файл

@ -86,6 +86,8 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
}
}
LayerBuilder()->Init(this);
PR_STATIC_ASSERT(nsDisplayItem::TYPE_MAX < (1 << nsDisplayItem::TYPE_BITS));
}
@ -584,10 +586,6 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
layerManager = new BasicLayerManager();
}
FrameLayerBuilder *layerBuilder = new FrameLayerBuilder();
layerBuilder->Init(aBuilder);
layerManager->SetUserData(&gLayerManagerLayerBuilder, new LayerManagerLayerBuilder(layerBuilder));
if (aFlags & PAINT_FLUSH_LAYERS) {
FrameLayerBuilder::InvalidateAllLayers(layerManager);
}
@ -600,7 +598,7 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
}
}
if (allowRetaining) {
layerBuilder->DidBeginRetainedLayerTransaction(layerManager);
aBuilder->LayerBuilder()->DidBeginRetainedLayerTransaction(layerManager);
}
nsPresContext* presContext = aForFrame->PresContext();
@ -608,14 +606,11 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
nsDisplayItem::ContainerParameters containerParameters
(presShell->GetXResolution(), presShell->GetYResolution());
nsRefPtr<ContainerLayer> root = layerBuilder->
nsRefPtr<ContainerLayer> root = aBuilder->LayerBuilder()->
BuildContainerLayerFor(aBuilder, layerManager, aForFrame, nsnull, *this,
containerParameters, nsnull);
if (!root) {
layerManager->RemoveUserData(&gLayerManagerLayerBuilder);
if (!root)
return;
}
// Root is being scaled up by the X/Y resolution. Scale it back down.
gfx3DMatrix rootTransform = root->GetTransform()*
gfx3DMatrix::ScalingMatrix(1.0f/containerParameters.mXScale,
@ -646,17 +641,16 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
}
layerManager->SetRoot(root);
layerBuilder->WillEndTransaction(layerManager);
aBuilder->LayerBuilder()->WillEndTransaction(layerManager);
layerManager->EndTransaction(FrameLayerBuilder::DrawThebesLayer,
aBuilder);
layerBuilder->DidEndTransaction(layerManager);
aBuilder->LayerBuilder()->DidEndTransaction(layerManager);
if (aFlags & PAINT_FLUSH_LAYERS) {
FrameLayerBuilder::InvalidateAllLayers(layerManager);
}
nsCSSRendering::DidPaint();
layerManager->RemoveUserData(&gLayerManagerLayerBuilder);
}
PRUint32 nsDisplayList::Count() const {
@ -1916,7 +1910,7 @@ already_AddRefed<Layer>
nsDisplayOpacity::BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerParameters& aContainerParameters) {
nsRefPtr<Layer> layer = GetLayerBuilderForManager(aManager)->
nsRefPtr<Layer> layer = aBuilder->LayerBuilder()->
BuildContainerLayerFor(aBuilder, aManager, mFrame, this, mList,
aContainerParameters, nsnull);
if (!layer)
@ -2002,7 +1996,7 @@ already_AddRefed<Layer>
nsDisplayOwnLayer::BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerParameters& aContainerParameters) {
nsRefPtr<Layer> layer = GetLayerBuilderForManager(aManager)->
nsRefPtr<Layer> layer = aBuilder->LayerBuilder()->
BuildContainerLayerFor(aBuilder, aManager, mFrame, this, mList,
aContainerParameters, nsnull);
return layer.forget();
@ -2131,7 +2125,7 @@ already_AddRefed<Layer>
nsDisplayScrollLayer::BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerParameters& aContainerParameters) {
nsRefPtr<ContainerLayer> layer = GetLayerBuilderForManager(aManager)->
nsRefPtr<ContainerLayer> layer = aBuilder->LayerBuilder()->
BuildContainerLayerFor(aBuilder, aManager, mFrame, this, mList,
aContainerParameters, nsnull);
@ -2887,7 +2881,7 @@ already_AddRefed<Layer> nsDisplayTransform::BuildLayer(nsDisplayListBuilder *aBu
return nsnull;
}
nsRefPtr<ContainerLayer> container = GetLayerBuilderForManager(aManager)->
nsRefPtr<ContainerLayer> container = aBuilder->LayerBuilder()->
BuildContainerLayerFor(aBuilder, aManager, mFrame, this, *mStoredList.GetList(),
aContainerParameters, &newTransformMatrix);
@ -3303,7 +3297,7 @@ nsDisplaySVGEffects::BuildLayer(nsDisplayListBuilder* aBuilder,
return nsnull;
}
nsRefPtr<ContainerLayer> container = GetLayerBuilderForManager(aManager)->
nsRefPtr<ContainerLayer> container = aBuilder->LayerBuilder()->
BuildContainerLayerFor(aBuilder, aManager, mFrame, this, mList,
aContainerParameters, nsnull);

Просмотреть файл

@ -329,6 +329,11 @@ public:
*/
void MarkPreserve3DFramesForDisplayList(nsIFrame* aDirtyFrame, const nsRect& aDirtyRect);
/**
* Return the FrameLayerBuilder.
*/
FrameLayerBuilder* LayerBuilder() { return &mLayerBuilder; }
/**
* Get the area of the final transparent region.
*/
@ -498,6 +503,7 @@ private:
return &mPresShellStates[mPresShellStates.Length() - 1];
}
FrameLayerBuilder mLayerBuilder;
nsIFrame* mReferenceFrame;
nsIFrame* mIgnoreScrollFrame;
PLArenaPool mPool;

Просмотреть файл

@ -180,7 +180,7 @@ PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
}
if (f) {
PRUint32 key = i->GetPerFrameKey();
Layer* layer = mozilla::FrameLayerBuilder::GetDebugOldLayerFor(f, key);
Layer* layer = aBuilder->LayerBuilder()->GetOldLayerFor(f, key);
if (layer) {
fprintf(aOutput, " <a href=\"#%p\">layer=%p</a>", layer, layer);
}

Просмотреть файл

@ -1805,13 +1805,7 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
nsFrame::PrintDisplayList(&builder, list, gfxUtils::sDumpPaintFile);
fprintf(gfxUtils::sDumpPaintFile, "Painting --- retained layer tree:\n");
nsIWidget* widget = aFrame->GetNearestWidget();
if (widget) {
nsRefPtr<LayerManager> layerManager = widget->GetLayerManager();
if (layerManager) {
FrameLayerBuilder::DumpRetainedLayerTree(layerManager, gfxUtils::sDumpPaintFile);
}
}
builder.LayerBuilder()->DumpRetainedLayerTree(gfxUtils::sDumpPaintFile);
fprintf(gfxUtils::sDumpPaintFile, "</body></html>");
if (gfxUtils::sDumpPaintingToFile) {

Просмотреть файл

@ -263,7 +263,7 @@ nsHTMLCanvasFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
return nsnull;
CanvasLayer* oldLayer = static_cast<CanvasLayer*>
(GetLayerBuilderForManager(aManager)->GetLeafLayerFor(aBuilder, aManager, aItem));
(aBuilder->LayerBuilder()->GetLeafLayerFor(aBuilder, aManager, aItem));
nsRefPtr<CanvasLayer> layer = element->GetCanvasLayer(aBuilder, oldLayer, aManager);
if (!layer)
return nsnull;

Просмотреть файл

@ -1530,7 +1530,7 @@ nsObjectFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
// to provide crisper and faster drawing.
r.Round();
nsRefPtr<Layer> layer =
(GetLayerBuilderForManager(aManager)->GetLeafLayerFor(aBuilder, aManager, aItem));
(aBuilder->LayerBuilder()->GetLeafLayerFor(aBuilder, aManager, aItem));
if (aItem->GetType() == nsDisplayItem::TYPE_PLUGIN) {
if (!layer) {

Просмотреть файл

@ -191,7 +191,7 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
container->SetScaleHint(scaleHint);
nsRefPtr<ImageLayer> layer = static_cast<ImageLayer*>
(GetLayerBuilderForManager(aManager)->GetLeafLayerFor(aBuilder, aManager, aItem));
(aBuilder->LayerBuilder()->GetLeafLayerFor(aBuilder, aManager, aItem));
if (!layer) {
layer = aManager->CreateImageLayer();
if (!layer)