- Revision
- 149292
- Author
- [email protected]
- Date
- 2013-04-29 09:24:18 -0700 (Mon, 29 Apr 2013)
Log Message
Get rid of "non-composited contents" in CoordinatedLayerTreeHost
https://bugs.webkit.org/show_bug.cgi?id=110355
Patch by Noam Rosenthal <[email protected]> on 2013-04-29
Reviewed by Jocelyn Turcotte.
Source/WebCore:
When in force compositing mode, always assume that the main layer needs
a backing store. Make setVisibleContentRectTrajectoryVector and accumulatedCoverRect
recursive so that they don't rely on a specialized layer.
No new testable behavior, changes to coverRect and trajectory vector only
affect tiling latency in rare cases that are not trivial to test.
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer:setVisibleContentRectTrajectoryVector):
Make the trajectory vector recursive, though limited only to layers with
translate/identity. This allows us to keep the trajectory vector while removing
the non-composited contents specialization.
(WebCore::CoordinatedGraphicsLayer::accumulatedCoverRect):
Added accumulatedCoverRect, so that the coverRect calculations for the UI process
are not bound to the non-composited contents layer.
(WebCore::CoordinatedGraphicsLayer::findDescendantWithContentsRecursively):
Instead of saving a reference to the non-composited contents layer, we assume that
the first layer we found recursively which has contents is the one to be used for
coverRect/trajectory calculations.
(WebCore):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
(CoordinatedGraphicsLayer):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::paintsIntoWindow):
Always create a layer for the non-composited contents when in forceCompositing mode.
Source/WebKit2:
Instead of using a special non-composited contents layer, we let RenderLayerCompositor create
a proper GraphicsLayer for that content.
CoordinatedLayerTreeHost now needs to find the main contents layer for the purpose of setting
the trajectory vector and applying the cover rect.
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
(WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):
Don't create the non-composited layer, instead keep a raw pointer to the root
compositing layer created by the WebCore compositor.
(WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplay):
(WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplayInRect):
(WebKit::CoordinatedLayerTreeHost::scrollNonCompositedContents):
(WebKit::CoordinatedLayerTreeHost::sizeDidChange):
(WebKit::CoordinatedLayerTreeHost::paintContents):
(WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
(WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
Remove non-composited layer specialization.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (149291 => 149292)
--- trunk/Source/WebCore/ChangeLog 2013-04-29 16:07:10 UTC (rev 149291)
+++ trunk/Source/WebCore/ChangeLog 2013-04-29 16:24:18 UTC (rev 149292)
@@ -1,3 +1,39 @@
+2013-04-29 Noam Rosenthal <[email protected]>
+
+ Get rid of "non-composited contents" in CoordinatedLayerTreeHost
+ https://bugs.webkit.org/show_bug.cgi?id=110355
+
+ Reviewed by Jocelyn Turcotte.
+
+ When in force compositing mode, always assume that the main layer needs
+ a backing store. Make setVisibleContentRectTrajectoryVector and accumulatedCoverRect
+ recursive so that they don't rely on a specialized layer.
+
+ No new testable behavior, changes to coverRect and trajectory vector only
+ affect tiling latency in rare cases that are not trivial to test.
+
+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+ (WebCore::CoordinatedGraphicsLayer:setVisibleContentRectTrajectoryVector):
+ Make the trajectory vector recursive, though limited only to layers with
+ translate/identity. This allows us to keep the trajectory vector while removing
+ the non-composited contents specialization.
+
+ (WebCore::CoordinatedGraphicsLayer::accumulatedCoverRect):
+ Added accumulatedCoverRect, so that the coverRect calculations for the UI process
+ are not bound to the non-composited contents layer.
+
+ (WebCore::CoordinatedGraphicsLayer::findDescendantWithContentsRecursively):
+ Instead of saving a reference to the non-composited contents layer, we assume that
+ the first layer we found recursively which has contents is the one to be used for
+ coverRect/trajectory calculations.
+
+ (WebCore):
+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+ (CoordinatedGraphicsLayer):
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::paintsIntoWindow):
+ Always create a layer for the non-composited contents when in forceCompositing mode.
+
2013-04-29 Dirk Schulze <[email protected]>
Animate clip rect() between different Length types
Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp (149291 => 149292)
--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp 2013-04-29 16:07:10 UTC (rev 149291)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp 2013-04-29 16:24:18 UTC (rev 149292)
@@ -836,6 +836,20 @@
{
}
+CoordinatedGraphicsLayer* CoordinatedGraphicsLayer::findFirstDescendantWithContentsRecursively()
+{
+ if (shouldHaveBackingStore())
+ return this;
+
+ for (size_t i = 0; i < children().size(); ++i) {
+ CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(children()[i])->findFirstDescendantWithContentsRecursively();
+ if (layer)
+ return layer;
+ }
+
+ return 0;
+}
+
void CoordinatedGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
{
if (!m_mainBackingStore)
Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h (149291 => 149292)
--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h 2013-04-29 16:07:10 UTC (rev 149291)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h 2013-04-29 16:24:18 UTC (rev 149292)
@@ -148,6 +148,7 @@
bool hasPendingVisibleChanges();
static void setShouldSupportContentsTiling(bool);
+ CoordinatedGraphicsLayer* findFirstDescendantWithContentsRecursively();
private:
#if USE(GRAPHICS_SURFACE)
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (149291 => 149292)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2013-04-29 16:07:10 UTC (rev 149291)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2013-04-29 16:24:18 UTC (rev 149292)
@@ -1845,7 +1845,7 @@
return false;
if (m_owningLayer->isRootLayer()) {
-#if PLATFORM(BLACKBERRY)
+#if PLATFORM(BLACKBERRY) || USE(COORDINATED_GRAPHICS)
if (compositor()->inForcedCompositingMode())
return false;
#endif
Modified: trunk/Source/WebKit2/ChangeLog (149291 => 149292)
--- trunk/Source/WebKit2/ChangeLog 2013-04-29 16:07:10 UTC (rev 149291)
+++ trunk/Source/WebKit2/ChangeLog 2013-04-29 16:24:18 UTC (rev 149292)
@@ -1,3 +1,30 @@
+2013-04-29 Noam Rosenthal <[email protected]>
+
+ Get rid of "non-composited contents" in CoordinatedLayerTreeHost
+ https://bugs.webkit.org/show_bug.cgi?id=110355
+
+ Reviewed by Jocelyn Turcotte.
+
+ Instead of using a special non-composited contents layer, we let RenderLayerCompositor create
+ a proper GraphicsLayer for that content.
+ CoordinatedLayerTreeHost now needs to find the main contents layer for the purpose of setting
+ the trajectory vector and applying the cover rect.
+
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+ (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
+ (WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):
+ Don't create the non-composited layer, instead keep a raw pointer to the root
+ compositing layer created by the WebCore compositor.
+
+ (WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplay):
+ (WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplayInRect):
+ (WebKit::CoordinatedLayerTreeHost::scrollNonCompositedContents):
+ (WebKit::CoordinatedLayerTreeHost::sizeDidChange):
+ (WebKit::CoordinatedLayerTreeHost::paintContents):
+ (WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
+ (WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
+ Remove non-composited layer specialization.
+
2013-04-29 Zoltan Arvai <[email protected]>
[Qt] Build fix. Enabling c++11 for Qt WK2 after r149259.
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp (149291 => 149292)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp 2013-04-29 16:07:10 UTC (rev 149291)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp 2013-04-29 16:24:18 UTC (rev 149292)
@@ -80,6 +80,7 @@
CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
: LayerTreeHost(webPage)
+ , m_rootCompositingLayer(0)
, m_notifyAfterScheduledLayerFlush(false)
, m_isValid(true)
, m_isPurging(false)
@@ -99,26 +100,13 @@
// Create a root layer.
m_rootLayer = GraphicsLayer::create(this, this);
- CoordinatedGraphicsLayer* coordinatedRootLayer = toCoordinatedGraphicsLayer(m_rootLayer.get());
#ifndef NDEBUG
m_rootLayer->setName("CoordinatedLayerTreeHost root layer");
#endif
m_rootLayer->setDrawsContent(false);
m_rootLayer->setSize(m_webPage->size());
- m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(coordinatedRootLayer)->id();
+ m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_rootLayer.get())->id();
- m_nonCompositedContentLayer = GraphicsLayer::create(this, this);
-#ifndef NDEBUG
- m_nonCompositedContentLayer->setName("CoordinatedLayerTreeHost non-composited content");
-#endif
- m_nonCompositedContentLayer->setDrawsContent(true);
- m_nonCompositedContentLayer->setSize(m_webPage->size());
-
- m_nonCompositedContentLayer->setShowDebugBorder(m_webPage->corePage()->settings()->showDebugBorders());
- m_nonCompositedContentLayer->setShowRepaintCounter(m_webPage->corePage()->settings()->showRepaintCounter());
-
- m_rootLayer->addChild(m_nonCompositedContentLayer.get());
-
CoordinatedSurface::setFactory(createCoordinatedSurface);
// This is a temporary way to enable this only in the GL case, until TextureMapperImageBuffer is removed.
@@ -167,12 +155,12 @@
void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer)
{
- m_nonCompositedContentLayer->removeAllChildren();
- m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground());
+ if (m_rootCompositingLayer)
+ m_rootCompositingLayer->removeFromParent();
- // Add the accelerated layer tree hierarchy.
- if (graphicsLayer)
- m_nonCompositedContentLayer->addChild(graphicsLayer);
+ m_rootCompositingLayer = graphicsLayer;
+ if (m_rootCompositingLayer)
+ m_rootLayer->addChildAtIndex(m_rootCompositingLayer, 0);
}
void CoordinatedLayerTreeHost::invalidate()
@@ -184,32 +172,6 @@
m_isValid = false;
}
-void CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplay()
-{
- m_nonCompositedContentLayer->setNeedsDisplay();
- if (m_pageOverlayLayer)
- m_pageOverlayLayer->setNeedsDisplay();
-
- scheduleLayerFlush();
-}
-
-void CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect& rect)
-{
- m_nonCompositedContentLayer->setNeedsDisplayInRect(rect);
- if (m_pageOverlayLayer)
- m_pageOverlayLayer->setNeedsDisplayInRect(rect);
-
- scheduleLayerFlush();
-}
-
-void CoordinatedLayerTreeHost::scrollNonCompositedContents(const WebCore::IntRect&)
-{
- if (!m_webPage->useFixedLayout())
- setNonCompositedContentsNeedDisplay();
-
- scheduleLayerFlush();
-}
-
void CoordinatedLayerTreeHost::forceRepaint()
{
// This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely.
@@ -233,27 +195,7 @@
void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize)
{
- if (m_rootLayer->size() == newSize)
- return;
-
m_rootLayer->setSize(newSize);
-
- // If the newSize exposes new areas of the non-composited content a setNeedsDisplay is needed
- // for those newly exposed areas.
- FloatSize oldSize = m_nonCompositedContentLayer->size();
- m_nonCompositedContentLayer->setSize(newSize);
-
- if (newSize.width() > oldSize.width()) {
- float height = std::min(static_cast<float>(newSize.height()), oldSize.height());
- m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(oldSize.width(), 0, newSize.width() - oldSize.width(), height));
- }
-
- if (newSize.height() > oldSize.height())
- m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(0, oldSize.height(), newSize.width(), newSize.height() - oldSize.height()));
-
- if (m_pageOverlayLayer)
- m_pageOverlayLayer->setSize(newSize);
-
scheduleLayerFlush();
}
@@ -296,25 +238,26 @@
TemporaryChange<bool> protector(m_isFlushingLayerChanges, true);
createCompositingLayers();
-
initializeRootCompositingLayerIfNeeded();
m_rootLayer->flushCompositingStateForThisLayerOnly();
- m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly();
if (m_pageOverlayLayer)
m_pageOverlayLayer->flushCompositingStateForThisLayerOnly();
bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes();
flushPendingImageBackingChanges();
-
deleteCompositingLayers();
if (m_shouldSyncFrame) {
didSync = true;
- m_state.contentsSize = roundedIntSize(m_nonCompositedContentLayer->size());
- m_state.coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect();
+ if (m_rootCompositingLayer) {
+ m_state.contentsSize = roundedIntSize(m_rootCompositingLayer->size());
+ if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
+ m_state.coveredRect = contentsLayer->coverRect();
+ }
+
m_state.scrollPosition = m_visibleContentsRect.location();
m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(m_state));
@@ -594,11 +537,6 @@
void CoordinatedLayerTreeHost::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect)
{
- if (graphicsLayer == m_nonCompositedContentLayer) {
- m_webPage->drawRect(graphicsContext, clipRect);
- return;
- }
-
if (graphicsLayer == m_pageOverlayLayer) {
// Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here.
graphicsContext.clearRect(clipRect);
@@ -660,10 +598,19 @@
return m_visibleContentsRect;
}
+CoordinatedGraphicsLayer* CoordinatedLayerTreeHost::mainContentsLayer()
+{
+ if (!m_rootCompositingLayer)
+ return 0;
+
+ return toCoordinatedGraphicsLayer(m_rootCompositingLayer)->findFirstDescendantWithContentsRecursively();
+}
+
void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
{
// A zero trajectoryVector indicates that tiles all around the viewport are requested.
- toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector);
+ if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
+ contentsLayer->setVisibleContentRectTrajectoryVector(trajectoryVector);
bool contentsRectDidChange = rect != m_visibleContentsRect;
if (contentsRectDidChange) {
@@ -686,7 +633,6 @@
void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
{
m_rootLayer->deviceOrPageScaleFactorChanged();
- m_nonCompositedContentLayer->deviceOrPageScaleFactorChanged();
if (m_pageOverlayLayer)
m_pageOverlayLayer->deviceOrPageScaleFactorChanged();
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h (149291 => 149292)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h 2013-04-29 16:07:10 UTC (rev 149291)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h 2013-04-29 16:24:18 UTC (rev 149292)
@@ -65,9 +65,9 @@
virtual void setRootCompositingLayer(WebCore::GraphicsLayer*);
virtual void invalidate();
- virtual void setNonCompositedContentsNeedDisplay() OVERRIDE;
- virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) OVERRIDE;
- virtual void scrollNonCompositedContents(const WebCore::IntRect&) OVERRIDE;
+ virtual void setNonCompositedContentsNeedDisplay() OVERRIDE { }
+ virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) OVERRIDE { }
+ virtual void scrollNonCompositedContents(const WebCore::IntRect&) OVERRIDE { }
virtual void forceRepaint();
virtual bool forceRepaintAsync(uint64_t callbackID);
virtual void sizeDidChange(const WebCore::IntSize& newSize);
@@ -88,6 +88,7 @@
virtual void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&);
virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE;
+ WebCore::CoordinatedGraphicsLayer* mainContentsLayer();
#if ENABLE(REQUEST_ANIMATION_FRAME)
virtual void scheduleAnimation() OVERRIDE;
@@ -143,7 +144,6 @@
void performScheduledLayerFlush();
void didPerformScheduledLayerFlush();
void syncDisplayState();
-
void layerFlushTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*);
void scheduleReleaseInactiveAtlases();
@@ -164,10 +164,8 @@
#endif
OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
+ WebCore::GraphicsLayer* m_rootCompositingLayer;
- // The layer which contains all non-composited content.
- OwnPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
-
// The page overlay layer. Will be null if there's no page overlay.
OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;
RefPtr<PageOverlay> m_pageOverlay;