author | Robert O'Callahan <robert@ocallahan.org> |
Tue, 21 Oct 2014 10:32:10 +1300 | |
changeset 214031 | 0af9b31d714c5776756f03bafcc2ee9742985903 |
parent 214030 | 7e996612b3b14f58f720deb3e5c44ee61b546b61 |
child 214032 | 80142bab0f14848a458fa9142529682a2382f4bd |
push id | 27771 |
push user | ryanvm@gmail.com |
push date | Wed, 05 Nov 2014 19:04:24 +0000 |
treeherder | mozilla-central@305b4fecce99 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mattwoodrow |
bugs | 1083635 |
milestone | 36.0a1 |
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
|
--- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -1278,19 +1278,19 @@ nsDisplayList::ComputeVisibilityForSubli return anyVisible; } /** * We paint by executing a layer manager transaction, constructing a * single layer representing the display list, and then making it the * root of the layer manager, drawing into the PaintedLayers. */ -void nsDisplayList::PaintRoot(nsDisplayListBuilder* aBuilder, - nsRenderingContext* aCtx, - uint32_t aFlags) { +already_AddRefed<LayerManager> nsDisplayList::PaintRoot(nsDisplayListBuilder* aBuilder, + nsRenderingContext* aCtx, + uint32_t aFlags) { PROFILER_LABEL("nsDisplayList", "PaintRoot", js::ProfileEntry::Category::GRAPHICS); nsRefPtr<LayerManager> layerManager; bool widgetTransaction = false; bool allowRetaining = false; bool doBeginTransaction = true; nsView *view = nullptr; @@ -1306,17 +1306,17 @@ void nsDisplayList::PaintRoot(nsDisplayL doBeginTransaction = !(aFlags & PAINT_EXISTING_TRANSACTION); widgetTransaction = true; } } } if (!layerManager) { if (!aCtx) { NS_WARNING("Nowhere to paint into"); - return; + return nullptr; } layerManager = new BasicLayerManager(BasicLayerManager::BLM_OFFSCREEN); } // Store the existing layer builder to reinstate it on return. FrameLayerBuilder *oldBuilder = layerManager->GetLayerBuilder(); FrameLayerBuilder *layerBuilder = new FrameLayerBuilder(); @@ -1364,17 +1364,17 @@ void nsDisplayList::PaintRoot(nsDisplayL nsIDocument* document = nullptr; if (presShell) { document = presShell->GetDocument(); } if (!root) { layerManager->SetUserData(&gLayerManagerLayerBuilder, oldBuilder); - return; + return nullptr; } // Root is being scaled up by the X/Y resolution. Scale it back down. root->SetPostScale(1.0f/containerParameters.mXScale, 1.0f/containerParameters.mYScale); bool isRoot = presContext->IsRootContentDocument(); nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame(); @@ -1463,16 +1463,17 @@ void nsDisplayList::PaintRoot(nsDisplayL } } if (aFlags & PAINT_FLUSH_LAYERS) { FrameLayerBuilder::InvalidateAllLayers(layerManager); } layerManager->SetUserData(&gLayerManagerLayerBuilder, oldBuilder); + return layerManager.forget(); } uint32_t nsDisplayList::Count() const { uint32_t count = 0; for (nsDisplayItem* i = GetBottom(); i; i = i->GetAbove()) { ++count; } return count;
--- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -1652,31 +1652,33 @@ public: * * If PAINT_EXISTING_TRANSACTION is set, the reference frame's widget's * layer manager has already had BeginTransaction() called on it and * we should not call it again. * * If PAINT_COMPRESSED is set, the FrameLayerBuilder should be set to compressed mode * to avoid short cut optimizations. * - * ComputeVisibility must be called before Paint. - * * This must only be called on the root display list of the display list * tree. + * + * We return the layer manager used for painting --- mainly so that + * callers can dump its layer tree if necessary. */ enum { PAINT_DEFAULT = 0, PAINT_USE_WIDGET_LAYERS = 0x01, PAINT_FLUSH_LAYERS = 0x02, PAINT_EXISTING_TRANSACTION = 0x04, PAINT_NO_COMPOSITE = 0x08, PAINT_COMPRESSED = 0x10 }; - void PaintRoot(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx, - uint32_t aFlags); + already_AddRefed<LayerManager> PaintRoot(nsDisplayListBuilder* aBuilder, + nsRenderingContext* aCtx, + uint32_t aFlags); /** * Get the bounds. Takes the union of the bounds of all children. * The result is not cached. */ nsRect GetBounds(nsDisplayListBuilder* aBuilder) const; /** * Find the topmost display item that returns a non-null frame, and return * the frame.
--- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -3119,34 +3119,31 @@ nsLayoutUtils::PaintFrame(nsRenderingCon } if (aFlags & PAINT_NO_COMPOSITE) { flags |= nsDisplayList::PAINT_NO_COMPOSITE; } if (aFlags & PAINT_COMPRESSED) { flags |= nsDisplayList::PAINT_COMPRESSED; } - list.PaintRoot(&builder, aRenderingContext, flags); + nsRefPtr<LayerManager> layerManager = + list.PaintRoot(&builder, aRenderingContext, flags); #ifdef MOZ_DUMP_PAINTING if (gfxUtils::DumpPaintList() || gfxUtils::sDumpPainting) { if (gfxUtils::sDumpPaintingToFile) { *ss << "</script>"; } *ss << "Painting --- after optimization:\n"; nsFrame::PrintDisplayList(&builder, list, *ss, gfxUtils::sDumpPaintingToFile); - *ss << "Painting --- retained layer tree:\n"; - nsIWidget* widget = aFrame->GetNearestWidget(); - if (widget) { - nsRefPtr<LayerManager> layerManager = widget->GetLayerManager(); - if (layerManager) { - FrameLayerBuilder::DumpRetainedLayerTree(layerManager, *ss, - gfxUtils::sDumpPaintingToFile); - } + *ss << "Painting --- layer tree:\n"; + if (layerManager) { + FrameLayerBuilder::DumpRetainedLayerTree(layerManager, *ss, + gfxUtils::sDumpPaintingToFile); } if (gfxUtils::sDumpPaintingToFile) { *ss << "</body></html>"; } fprint_stderr(gfxUtils::sDumpPaintFile, *ss); if (gfxUtils::sDumpPaintingToFile) { @@ -3172,22 +3169,16 @@ nsLayoutUtils::PaintFrame(nsRenderingCon const nsRegion& draggingRegion = builder.GetWindowDraggingRegion(); widget->UpdateWindowDraggingRegion( draggingRegion.ToNearestPixels(presContext->AppUnitsPerDevPixel())); } } if (builder.WillComputePluginGeometry()) { - nsRefPtr<LayerManager> layerManager; - nsIWidget* widget = aFrame->GetNearestWidget(); - if (widget) { - layerManager = widget->GetLayerManager(); - } - rootPresContext->ComputePluginGeometryUpdates(aFrame, &builder, &list); // We're not going to get a WillPaintWindow event here if we didn't do // widget invalidation, so just apply the plugin geometry update here instead. // We could instead have the compositor send back an equivalent to WillPaintWindow, // but it should be close enough to now not to matter. if (layerManager && !layerManager->NeedsWidgetInvalidation()) { rootPresContext->ApplyPluginGeometryUpdates();
--- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -5250,17 +5250,19 @@ PresShell::PaintRangePaintInfo(nsTArray< // the display lists paint relative to the offset from the reference // frame, so account for that translation too: gfxPoint rootOffset = nsLayoutUtils::PointToGfxPoint(rangeInfo->mRootOffset, pc->AppUnitsPerDevPixel()); ctx->SetMatrix(initialTM.Translate(rootOffset)); aArea.MoveBy(-rangeInfo->mRootOffset.x, -rangeInfo->mRootOffset.y); nsRegion visible(aArea); - rangeInfo->mList.PaintRoot(&rangeInfo->mBuilder, &rc, nsDisplayList::PAINT_DEFAULT); + nsRefPtr<LayerManager> layerManager = + rangeInfo->mList.PaintRoot(&rangeInfo->mBuilder, &rc, + nsDisplayList::PAINT_DEFAULT); aArea.MoveBy(rangeInfo->mRootOffset.x, rangeInfo->mRootOffset.y); } // restore the old selection display state frameSelection->SetDisplaySelection(oldDisplaySelection); return dt->Snapshot(); }