Diff
Modified: trunk/Source/WebCore/ChangeLog (145562 => 145563)
--- trunk/Source/WebCore/ChangeLog 2013-03-12 17:44:37 UTC (rev 145562)
+++ trunk/Source/WebCore/ChangeLog 2013-03-12 17:54:44 UTC (rev 145563)
@@ -1,3 +1,57 @@
+2013-03-12 Simon Fraser <simon.fra...@apple.com>
+
+ Keep track of the number of GraphicsLayers with tiled backing in RenderLayerCompositor
+ https://bugs.webkit.org/show_bug.cgi?id=112083
+
+ Reviewed by Dean Jackson.
+
+ Have RenderLayerCompositor keep track of how many of its GraphicsLayers use TiledBacking.
+ This is useful for platforms to decide whether it's necessary to force GraphicsLayer flushes
+ to update the visibleRect of those TiledBackings.
+
+ GraphicsLayers are always created without TiledBacking. There are two
+ ways the count can change:
+ 1. A GraphicsLayerCA toggles into or out of tiled mode. It notifies its
+ client via a new tiledBackingUsageChanged() callback on GraphicsLayerClient.
+ 2. A tiled GraphicsLayerCA is destroyed. Added a new bottleneck function to
+ RenderLayerBacking::willDestroyLayer() that is called everywhere we destroy layers.
+
+ The main page TiledBacking is not counted as part of this.
+
+ Also renamed uses of "tiledLayer" to "tiledBacking" in GraphicsLayer[CA].
+
+ * platform/graphics/GraphicsLayer.cpp:
+ (WebCore::GraphicsLayer::GraphicsLayer):
+ (WebCore::GraphicsLayer::getDebugBorderInfo):
+ (WebCore::GraphicsLayer::dumpProperties):
+ * platform/graphics/GraphicsLayer.h:
+ (WebCore::GraphicsLayer::usingTiledBacking):
+ * platform/graphics/GraphicsLayerClient.h:
+ (WebCore::GraphicsLayerClient::tiledBackingUsageChanged):
+ * platform/graphics/ca/GraphicsLayerCA.cpp:
+ (WebCore::GraphicsLayerCA::recursiveCommitChanges):
+ (WebCore::GraphicsLayerCA::updateGeometry):
+ (WebCore::GraphicsLayerCA::updateLayerDrawsContent):
+ (WebCore::GraphicsLayerCA::updateContentsScale):
+ (WebCore::GraphicsLayerCA::swapFromOrToTiledLayer):
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::willDestroyLayer):
+ (WebCore::RenderLayerBacking::tiledBackingUsageChanged):
+ (WebCore::RenderLayerBacking::destroyGraphicsLayers):
+ (WebCore::RenderLayerBacking::updateClippingLayers):
+ (WebCore::RenderLayerBacking::updateOverflowControlsLayers):
+ (WebCore::RenderLayerBacking::updateForegroundLayer):
+ (WebCore::RenderLayerBacking::updateBackgroundLayer):
+ (WebCore::RenderLayerBacking::updateMaskLayer):
+ (WebCore::RenderLayerBacking::updateScrollingLayers):
+ (WebCore::RenderLayerBacking::compositingLayerType):
+ * rendering/RenderLayerBacking.h:
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::RenderLayerCompositor):
+ (WebCore::RenderLayerCompositor::layerTiledBackingUsageChanged):
+ * rendering/RenderLayerCompositor.h:
+ (WebCore::RenderLayerCompositor::haveNonMainLayersWithTiledBacking):
+
2013-03-12 Abhishek Arya <infe...@chromium.org>
Replace static_casts with to* functions.
Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (145562 => 145563)
--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp 2013-03-12 17:44:37 UTC (rev 145562)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp 2013-03-12 17:54:44 UTC (rev 145563)
@@ -83,7 +83,7 @@
, m_contentsOpaque(false)
, m_preserves3D(false)
, m_backfaceVisibility(true)
- , m_usingTiledLayer(false)
+ , m_usingTiledBacking(false)
, m_masksToBounds(false)
, m_drawsContent(false)
, m_contentsVisible(true)
@@ -348,7 +348,7 @@
void GraphicsLayer::getDebugBorderInfo(Color& color, float& width) const
{
if (drawsContent()) {
- if (m_usingTiledLayer) {
+ if (m_usingTiledBacking) {
color = Color(255, 128, 0, 128); // tiled layer: orange
width = 2;
return;
@@ -605,9 +605,9 @@
ts << "(opacity " << m_opacity << ")\n";
}
- if (m_usingTiledLayer) {
+ if (m_usingTiledBacking) {
writeIndent(ts, indent + 1);
- ts << "(usingTiledLayer " << m_usingTiledLayer << ")\n";
+ ts << "(usingTiledLayer " << m_usingTiledBacking << ")\n";
}
if (m_contentsOpaque) {
Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (145562 => 145563)
--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h 2013-03-12 17:44:37 UTC (rev 145562)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h 2013-03-12 17:54:44 UTC (rev 145563)
@@ -416,8 +416,7 @@
// Return an estimate of the backing store memory cost (in bytes). May be incorrect for tiled layers.
virtual double backingStoreMemoryEstimate() const;
- bool usingTiledLayer() const { return m_usingTiledLayer; }
-
+ bool usingTiledBacking() const { return m_usingTiledBacking; }
virtual TiledBacking* tiledBacking() const { return 0; }
void resetTrackedRepaints();
@@ -498,7 +497,7 @@
bool m_contentsOpaque : 1;
bool m_preserves3D: 1;
bool m_backfaceVisibility : 1;
- bool m_usingTiledLayer : 1;
+ bool m_usingTiledBacking : 1;
bool m_masksToBounds : 1;
bool m_drawsContent : 1;
bool m_contentsVisible : 1;
Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h (145562 => 145563)
--- trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h 2013-03-12 17:44:37 UTC (rev 145562)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h 2013-03-12 17:54:44 UTC (rev 145563)
@@ -60,6 +60,7 @@
virtual ~GraphicsLayerClient() {}
virtual bool shouldUseTiledBacking(const GraphicsLayer*) const { return false; }
+ virtual void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) { }
// Callback for when hardware-accelerated animation started.
virtual void notifyAnimationStarted(const GraphicsLayer*, double time) = 0;
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (145562 => 145563)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2013-03-12 17:44:37 UTC (rev 145562)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2013-03-12 17:54:44 UTC (rev 145563)
@@ -978,7 +978,7 @@
#ifdef VISIBLE_TILE_WASH
// Use having a transform as a key to making the tile wash layer. If every layer gets a wash,
// they start to obscure useful information.
- if ((!m_transform.isIdentity() || m_usingTiledLayer) && !m_visibleTileWashLayer) {
+ if ((!m_transform.isIdentity() || m_usingTiledBacking) && !m_visibleTileWashLayer) {
static Color washFillColor(255, 0, 0, 50);
static Color washBorderColor(255, 0, 0, 100);
@@ -1253,10 +1253,10 @@
computePixelAlignment(pageScaleFactor, positionRelativeToBase, scaledPosition, scaledSize, scaledAnchorPoint, pixelAlignmentOffset);
bool needTiledLayer = requiresTiledLayer(pageScaleFactor);
- if (needTiledLayer != m_usingTiledLayer)
+ if (needTiledLayer != m_usingTiledBacking)
swapFromOrToTiledLayer(needTiledLayer);
- FloatSize usedSize = m_usingTiledLayer ? constrainedSize() : scaledSize;
+ FloatSize usedSize = m_usingTiledBacking ? constrainedSize() : scaledSize;
FloatRect adjustedBounds(m_boundsOrigin - pixelAlignmentOffset, usedSize);
// Update position.
@@ -1525,7 +1525,7 @@
void GraphicsLayerCA::updateLayerDrawsContent(float pageScaleFactor)
{
bool needTiledLayer = requiresTiledLayer(pageScaleFactor);
- if (needTiledLayer != m_usingTiledLayer)
+ if (needTiledLayer != m_usingTiledBacking)
swapFromOrToTiledLayer(needTiledLayer);
if (m_drawsContent)
@@ -2523,7 +2523,7 @@
void GraphicsLayerCA::updateContentsScale(float pageScaleFactor)
{
bool needTiledLayer = requiresTiledLayer(pageScaleFactor);
- if (needTiledLayer != m_usingTiledLayer)
+ if (needTiledLayer != m_usingTiledBacking)
swapFromOrToTiledLayer(needTiledLayer);
float contentsScale = clampedContentsScaleForScale(pageScaleFactor * deviceScaleFactor());
@@ -2644,11 +2644,11 @@
void GraphicsLayerCA::swapFromOrToTiledLayer(bool useTiledLayer)
{
ASSERT(m_layer->layerType() != PlatformCALayer::LayerTypePageTiledBackingLayer);
- ASSERT(useTiledLayer != m_usingTiledLayer);
+ ASSERT(useTiledLayer != m_usingTiledBacking);
RefPtr<PlatformCALayer> oldLayer = m_layer;
m_layer = PlatformCALayer::create(useTiledLayer ? PlatformCALayer::LayerTypeTiledBackingLayer : PlatformCALayer::LayerTypeWebLayer, this);
- m_usingTiledLayer = useTiledLayer;
+ m_usingTiledBacking = useTiledLayer;
m_layer->adoptSublayers(oldLayer.get());
@@ -2677,7 +2677,7 @@
| OpacityChanged
| DebugIndicatorsChanged;
- if (m_usingTiledLayer)
+ if (m_usingTiledBacking)
m_uncommittedChanges |= VisibleRectChanged;
#ifndef NDEBUG
@@ -2690,6 +2690,9 @@
// need to tell new layer to draw itself
setNeedsDisplay();
+
+ if (client())
+ client()->tiledBackingUsageChanged(this, m_usingTiledBacking);
}
GraphicsLayer::CompositingCoordinatesOrientation GraphicsLayerCA::defaultContentsOrientation() const
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (145562 => 145563)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2013-03-12 17:44:37 UTC (rev 145562)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2013-03-12 17:54:44 UTC (rev 145563)
@@ -162,6 +162,14 @@
destroyGraphicsLayers();
}
+void RenderLayerBacking::willDestroyLayer(const GraphicsLayer* layer)
+{
+ if (layer && layer->usingTiledBacking()) {
+ if (RenderLayerCompositor* compositor = this->compositor())
+ compositor->layerTiledBackingUsageChanged(layer, false);
+ }
+}
+
PassOwnPtr<GraphicsLayer> RenderLayerBacking::createGraphicsLayer(const String& name)
{
GraphicsLayerFactory* graphicsLayerFactory = 0;
@@ -189,6 +197,11 @@
return m_usingTiledCacheLayer && m_creatingPrimaryGraphicsLayer;
}
+void RenderLayerBacking::tiledBackingUsageChanged(const GraphicsLayer* layer, bool usingTiledBacking)
+{
+ compositor()->layerTiledBackingUsageChanged(layer, usingTiledBacking);
+}
+
TiledBacking* RenderLayerBacking::tiledBacking() const
{
return m_graphicsLayer->tiledBacking();
@@ -311,8 +324,10 @@
void RenderLayerBacking::destroyGraphicsLayers()
{
- if (m_graphicsLayer)
+ if (m_graphicsLayer) {
+ willDestroyLayer(m_graphicsLayer.get());
m_graphicsLayer->removeFromParent();
+ }
m_ancestorClippingLayer = nullptr;
m_contentsContainmentLayer = nullptr;
@@ -959,6 +974,7 @@
layersChanged = true;
}
} else if (m_ancestorClippingLayer) {
+ willDestroyLayer(m_ancestorClippingLayer.get());
m_ancestorClippingLayer->removeFromParent();
m_ancestorClippingLayer = nullptr;
layersChanged = true;
@@ -971,6 +987,7 @@
layersChanged = true;
}
} else if (hasClippingLayer()) {
+ willDestroyLayer(m_childContainmentLayer.get());
m_childContainmentLayer->removeFromParent();
m_childContainmentLayer = nullptr;
layersChanged = true;
@@ -1020,7 +1037,8 @@
horizontalScrollbarLayerChanged = true;
}
} else if (m_layerForHorizontalScrollbar) {
- m_layerForHorizontalScrollbar.clear();
+ willDestroyLayer(m_layerForHorizontalScrollbar.get());
+ m_layerForHorizontalScrollbar = nullptr;
horizontalScrollbarLayerChanged = true;
}
@@ -1031,7 +1049,8 @@
verticalScrollbarLayerChanged = true;
}
} else if (m_layerForVerticalScrollbar) {
- m_layerForVerticalScrollbar.clear();
+ willDestroyLayer(m_layerForVerticalScrollbar.get());
+ m_layerForVerticalScrollbar = nullptr;
verticalScrollbarLayerChanged = true;
}
@@ -1042,7 +1061,8 @@
scrollCornerLayerChanged = true;
}
} else if (m_layerForScrollCorner) {
- m_layerForScrollCorner.clear();
+ willDestroyLayer(m_layerForScrollCorner.get());
+ m_layerForScrollCorner = nullptr;
scrollCornerLayerChanged = true;
}
@@ -1121,6 +1141,7 @@
layerChanged = true;
}
} else if (m_foregroundLayer) {
+ willDestroyLayer(m_foregroundLayer.get());
m_foregroundLayer->removeFromParent();
m_foregroundLayer = nullptr;
layerChanged = true;
@@ -1160,11 +1181,13 @@
}
} else {
if (m_backgroundLayer) {
+ willDestroyLayer(m_backgroundLayer.get());
m_backgroundLayer->removeFromParent();
m_backgroundLayer = nullptr;
layerChanged = true;
}
if (m_contentsContainmentLayer) {
+ willDestroyLayer(m_contentsContainmentLayer.get());
m_contentsContainmentLayer->removeFromParent();
m_contentsContainmentLayer = nullptr;
layerChanged = true;
@@ -1192,6 +1215,7 @@
layerChanged = true;
}
} else if (m_maskLayer) {
+ willDestroyLayer(m_maskLayer.get());
m_maskLayer = nullptr;
layerChanged = true;
}
@@ -1228,6 +1252,8 @@
scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_owningLayer);
}
} else if (m_scrollingLayer) {
+ willDestroyLayer(m_scrollingLayer.get());
+ willDestroyLayer(m_scrollingContentsLayer.get());
m_scrollingLayer = nullptr;
m_scrollingContentsLayer = nullptr;
layerChanged = true;
@@ -2187,7 +2213,7 @@
return MediaCompositingLayer;
if (m_graphicsLayer->drawsContent())
- return m_graphicsLayer->usingTiledLayer() ? TiledCompositingLayer : NormalCompositingLayer;
+ return m_graphicsLayer->usingTiledBacking() ? TiledCompositingLayer : NormalCompositingLayer;
return ContainerCompositingLayer;
}
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (145562 => 145563)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.h 2013-03-12 17:44:37 UTC (rev 145562)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h 2013-03-12 17:54:44 UTC (rev 145563)
@@ -155,6 +155,7 @@
// GraphicsLayerClient interface
virtual bool shouldUseTiledBacking(const GraphicsLayer*) const OVERRIDE;
+ virtual void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) OVERRIDE;
virtual void notifyAnimationStarted(const GraphicsLayer*, double startTime) OVERRIDE;
virtual void notifyFlushRequired(const GraphicsLayer*) OVERRIDE;
virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) OVERRIDE;
@@ -198,6 +199,8 @@
void createPrimaryGraphicsLayer();
void destroyGraphicsLayers();
+ void willDestroyLayer(const GraphicsLayer*);
+
PassOwnPtr<GraphicsLayer> createGraphicsLayer(const String&);
RenderLayerModelObject* renderer() const { return m_owningLayer->renderer(); }
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (145562 => 145563)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2013-03-12 17:44:37 UTC (rev 145562)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2013-03-12 17:54:44 UTC (rev 145563)
@@ -209,6 +209,7 @@
, m_forceCompositingMode(false)
, m_inPostLayoutUpdate(false)
, m_isTrackingRepaints(false)
+ , m_layersWithTiledBackingCount(0)
, m_rootLayerAttachment(RootLayerUnattached)
#if !LOG_DISABLED
, m_rootLayerUpdateCount(0)
@@ -390,6 +391,16 @@
flushPendingLayerChanges(true); // FIXME: deal with iframes
}
+void RenderLayerCompositor::layerTiledBackingUsageChanged(const GraphicsLayer*, bool usingTiledBacking)
+{
+ if (usingTiledBacking)
+ ++m_layersWithTiledBackingCount;
+ else {
+ ASSERT(m_layersWithTiledBackingCount > 0);
+ --m_layersWithTiledBackingCount;
+ }
+}
+
RenderLayerCompositor* RenderLayerCompositor::enclosingCompositorFlushingLayers() const
{
if (!m_renderView->frameView())
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.h (145562 => 145563)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.h 2013-03-12 17:44:37 UTC (rev 145562)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.h 2013-03-12 17:54:44 UTC (rev 145563)
@@ -241,6 +241,8 @@
virtual float pageScaleFactor() const OVERRIDE;
virtual void didCommitChangesForLayer(const GraphicsLayer*) const OVERRIDE;
virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) OVERRIDE;
+
+ void layerTiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/);
bool keepLayersPixelAligned() const;
bool acceleratedDrawingEnabled() const { return m_acceleratedDrawingEnabled; }
@@ -340,6 +342,8 @@
Page* page() const;
TiledBacking* pageTiledBacking() const;
+
+ bool haveNonMainLayersWithTiledBacking() const { return m_layersWithTiledBackingCount; }
GraphicsLayerFactory* graphicsLayerFactory() const;
ScrollingCoordinator* scrollingCoordinator() const;
@@ -405,6 +409,8 @@
bool m_inPostLayoutUpdate; // true when it's OK to trust layout information (e.g. layer sizes and positions)
bool m_isTrackingRepaints; // Used for testing.
+
+ unsigned m_layersWithTiledBackingCount;
RootLayerAttachment m_rootLayerAttachment;