Source/WebCore/ChangeLog

112013-04-26 Noam Rosenthal <noam@webkit.org>
22
 3 Get rid of "non-composited contents" in CoordinatedLayerTreeHost
 4 https://bugs.webkit.org/show_bug.cgi?id=110355
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 When in force compositing mode, always assume that the main layer needs
 9 a backing store. Make setVisibleContentRectTrajectoryVector and accumulatedCoverRect
 10 recursive so that they don't rely on a specialized layer.
 11
 12 No new testable behavior, changes to coverRect and trajectory vector only
 13 affect tiling latency in rare cases that are not trivial to test.
 14
 15 * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
 16 (WebCore::CoordinatedGraphicsLayer:setVisibleContentRectTrajectoryVector):
 17 Make the trajectory vector recursive, though limited only to layers with
 18 translate/identity. This allows us to keep the trajectory vector while removing
 19 the non-composited contents specialization.
 20
 21 (WebCore::CoordinatedGraphicsLayer::accumulatedCoverRect):
 22 Added accumulatedCoverRect, so that the coverRect calculations for the UI process
 23 are not bound to the non-composited contents layer.
 24
 25 (WebCore::CoordinatedGraphicsLayer::findDescendantWithContentsRecursively):
 26 Instead of saving a reference to the non-composited contents layer, we assume that
 27 the first layer we found recursively which has contents is the one to be used for
 28 coverRect/trajectory calculations.
 29
 30 (WebCore):
 31 * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
 32 (CoordinatedGraphicsLayer):
 33 * rendering/RenderLayerBacking.cpp:
 34 (WebCore::RenderLayerBacking::paintsIntoWindow):
 35 Always create a layer for the non-composited contents when in forceCompositing mode.
 36
 372013-04-26 Noam Rosenthal <noam@webkit.org>
 38
339 [Qt] fast/canvas/webgl/webgl-composite-modes.html broken after r148433.
440 https://bugs.webkit.org/show_bug.cgi?id=115243
541

Source/WebKit2/ChangeLog

 12013-04-26 Noam Rosenthal <noam@webkit.org>
 2
 3 Get rid of "non-composited contents" in CoordinatedLayerTreeHost
 4 https://bugs.webkit.org/show_bug.cgi?id=110355
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Instead of using a special non-composited contents layer, we let RenderLayerCompositor create
 9 a proper GraphicsLayer for that content.
 10 CoordinatedLayerTreeHost now needs to find the main contents layer for the purpose of setting
 11 the trajectory vector and applying the cover rect.
 12
 13 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
 14 (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
 15 (WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):
 16 Don't create the non-composited layer, instead keep a raw pointer to the root
 17 compositing layer created by the WebCore compositor.
 18
 19 (WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplay):
 20 (WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplayInRect):
 21 (WebKit::CoordinatedLayerTreeHost::scrollNonCompositedContents):
 22 (WebKit::CoordinatedLayerTreeHost::sizeDidChange):
 23 (WebKit::CoordinatedLayerTreeHost::paintContents):
 24 (WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
 25 (WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
 26 Remove non-composited layer specialization.
 27
1282013-04-23 Noam Rosenthal <noam@webkit.org>
229
330 [Coordinated Graphics] Remove the lockAnimations code path

Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp

@@void CoordinatedGraphicsLayer::tiledBackingStorePaintBegin()
836836{
837837}
838838
 839CoordinatedGraphicsLayer* CoordinatedGraphicsLayer::findFirstDescendantWithContentsRecursively()
 840{
 841 if (shouldHaveBackingStore())
 842 return this;
 843
 844 for (size_t i = 0; i < children().size(); ++i) {
 845 CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(children()[i])->findFirstDescendantWithContentsRecursively();
 846 if (layer)
 847 return layer;
 848 }
 849
 850 return 0;
 851}
 852
839853void CoordinatedGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
840854{
841855 if (!m_mainBackingStore)

Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h

@@public:
148148 bool hasPendingVisibleChanges();
149149
150150 static void setShouldSupportContentsTiling(bool);
151 
 151 CoordinatedGraphicsLayer* findFirstDescendantWithContentsRecursively();
152152private:
153153#if USE(GRAPHICS_SURFACE)
154154 enum PendingCanvasOperation {

Source/WebCore/rendering/RenderLayerBacking.cpp

@@bool RenderLayerBacking::paintsIntoWindow() const
18451845 return false;
18461846
18471847 if (m_owningLayer->isRootLayer()) {
1848 #if PLATFORM(BLACKBERRY)
 1848#if PLATFORM(BLACKBERRY) || USE(COORDINATED_GRAPHICS)
18491849 if (compositor()->inForcedCompositingMode())
18501850 return false;
18511851#endif

Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp

@@CoordinatedLayerTreeHost::~CoordinatedLayerTreeHost()
8080
8181CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
8282 : LayerTreeHost(webPage)
 83 , m_rootCompositingLayer(0)
8384 , m_notifyAfterScheduledLayerFlush(false)
8485 , m_isValid(true)
8586 , m_isPurging(false)

@@CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
99100
100101 // Create a root layer.
101102 m_rootLayer = GraphicsLayer::create(this, this);
102  CoordinatedGraphicsLayer* coordinatedRootLayer = toCoordinatedGraphicsLayer(m_rootLayer.get());
103103#ifndef NDEBUG
104104 m_rootLayer->setName("CoordinatedLayerTreeHost root layer");
105105#endif
106106 m_rootLayer->setDrawsContent(false);
107107 m_rootLayer->setSize(m_webPage->size());
108  m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(coordinatedRootLayer)->id();
109 
110  m_nonCompositedContentLayer = GraphicsLayer::create(this, this);
111 #ifndef NDEBUG
112  m_nonCompositedContentLayer->setName("CoordinatedLayerTreeHost non-composited content");
113 #endif
114  m_nonCompositedContentLayer->setDrawsContent(true);
115  m_nonCompositedContentLayer->setSize(m_webPage->size());
116 
117  m_nonCompositedContentLayer->setShowDebugBorder(m_webPage->corePage()->settings()->showDebugBorders());
118  m_nonCompositedContentLayer->setShowRepaintCounter(m_webPage->corePage()->settings()->showRepaintCounter());
119 
120  m_rootLayer->addChild(m_nonCompositedContentLayer.get());
 108 m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_rootLayer.get())->id();
121109
122110 CoordinatedSurface::setFactory(createCoordinatedSurface);
123111

@@void CoordinatedLayerTreeHost::setShouldNotifyAfterNextScheduledLayerFlush(bool
167155
168156void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer)
169157{
170  m_nonCompositedContentLayer->removeAllChildren();
171  m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground());
 158 if (m_rootCompositingLayer)
 159 m_rootCompositingLayer->removeFromParent();
172160
173  // Add the accelerated layer tree hierarchy.
174  if (graphicsLayer)
175  m_nonCompositedContentLayer->addChild(graphicsLayer);
 161 m_rootCompositingLayer = graphicsLayer;
 162 if (m_rootCompositingLayer)
 163 m_rootLayer->addChildAtIndex(m_rootCompositingLayer, 0);
176164}
177165
178166void CoordinatedLayerTreeHost::invalidate()

@@void CoordinatedLayerTreeHost::invalidate()
184172 m_isValid = false;
185173}
186174
187 void CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplay()
188 {
189  m_nonCompositedContentLayer->setNeedsDisplay();
190  if (m_pageOverlayLayer)
191  m_pageOverlayLayer->setNeedsDisplay();
192 
193  scheduleLayerFlush();
194 }
195 
196 void CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect& rect)
197 {
198  m_nonCompositedContentLayer->setNeedsDisplayInRect(rect);
199  if (m_pageOverlayLayer)
200  m_pageOverlayLayer->setNeedsDisplayInRect(rect);
201 
202  scheduleLayerFlush();
203 }
204 
205 void CoordinatedLayerTreeHost::scrollNonCompositedContents(const WebCore::IntRect&)
206 {
207  if (!m_webPage->useFixedLayout())
208  setNonCompositedContentsNeedDisplay();
209 
210  scheduleLayerFlush();
211 }
212 
213175void CoordinatedLayerTreeHost::forceRepaint()
214176{
215177 // This is necessary for running layout tests. Since in this case we are not waiting for a UIProcess to reply nicely.

@@bool CoordinatedLayerTreeHost::forceRepaintAsync(uint64_t callbackID)
233195
234196void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize)
235197{
236  if (m_rootLayer->size() == newSize)
237  return;
238 
239198 m_rootLayer->setSize(newSize);
240 
241  // If the newSize exposes new areas of the non-composited content a setNeedsDisplay is needed
242  // for those newly exposed areas.
243  FloatSize oldSize = m_nonCompositedContentLayer->size();
244  m_nonCompositedContentLayer->setSize(newSize);
245 
246  if (newSize.width() > oldSize.width()) {
247  float height = std::min(static_cast<float>(newSize.height()), oldSize.height());
248  m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(oldSize.width(), 0, newSize.width() - oldSize.width(), height));
249  }
250 
251  if (newSize.height() > oldSize.height())
252  m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(0, oldSize.height(), newSize.width(), newSize.height() - oldSize.height()));
253 
254  if (m_pageOverlayLayer)
255  m_pageOverlayLayer->setSize(newSize);
256 
257199 scheduleLayerFlush();
258200}
259201

@@bool CoordinatedLayerTreeHost::flushPendingLayerChanges()
296238 TemporaryChange<bool> protector(m_isFlushingLayerChanges, true);
297239
298240 createCompositingLayers();
299 
300241 initializeRootCompositingLayerIfNeeded();
301242
302243 m_rootLayer->flushCompositingStateForThisLayerOnly();
303  m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly();
304244 if (m_pageOverlayLayer)
305245 m_pageOverlayLayer->flushCompositingStateForThisLayerOnly();
306246
307247 bool didSync = m_webPage->corePage()->mainFrame()->view()->flushCompositingStateIncludingSubframes();
308248
309249 flushPendingImageBackingChanges();
310 
311250 deleteCompositingLayers();
312251
313252 if (m_shouldSyncFrame) {
314253 didSync = true;
315254
316  m_state.contentsSize = roundedIntSize(m_nonCompositedContentLayer->size());
317  m_state.coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect();
 255 if (m_rootCompositingLayer) {
 256 m_state.contentsSize = roundedIntSize(m_rootCompositingLayer->size());
 257 if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
 258 m_state.coveredRect = contentsLayer->coverRect();
 259 }
 260
318261 m_state.scrollPosition = m_visibleContentsRect.location();
319262
320263 m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::CommitCoordinatedGraphicsState(m_state));

@@void CoordinatedLayerTreeHost::notifyFlushRequired(const WebCore::GraphicsLayer*
594537
595538void CoordinatedLayerTreeHost::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect)
596539{
597  if (graphicsLayer == m_nonCompositedContentLayer) {
598  m_webPage->drawRect(graphicsContext, clipRect);
599  return;
600  }
601 
602540 if (graphicsLayer == m_pageOverlayLayer) {
603541 // Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here.
604542 graphicsContext.clearRect(clipRect);

@@WebCore::FloatRect CoordinatedLayerTreeHost::visibleContentsRect() const
660598 return m_visibleContentsRect;
661599}
662600
 601CoordinatedGraphicsLayer* CoordinatedLayerTreeHost::mainContentsLayer()
 602{
 603 if (!m_rootCompositingLayer)
 604 return 0;
 605
 606 return toCoordinatedGraphicsLayer(m_rootCompositingLayer)->findFirstDescendantWithContentsRecursively();
 607}
 608
663609void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
664610{
665611 // A zero trajectoryVector indicates that tiles all around the viewport are requested.
666  toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector);
 612 if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
 613 contentsLayer->setVisibleContentRectTrajectoryVector(trajectoryVector);
667614
668615 bool contentsRectDidChange = rect != m_visibleContentsRect;
669616 if (contentsRectDidChange) {

@@void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, con
686633void CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged()
687634{
688635 m_rootLayer->deviceOrPageScaleFactorChanged();
689  m_nonCompositedContentLayer->deviceOrPageScaleFactorChanged();
690636 if (m_pageOverlayLayer)
691637 m_pageOverlayLayer->deviceOrPageScaleFactorChanged();
692638}

Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h

@@public:
6565 virtual void setRootCompositingLayer(WebCore::GraphicsLayer*);
6666 virtual void invalidate();
6767
68  virtual void setNonCompositedContentsNeedDisplay() OVERRIDE;
69  virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) OVERRIDE;
70  virtual void scrollNonCompositedContents(const WebCore::IntRect&) OVERRIDE;
 68 virtual void setNonCompositedContentsNeedDisplay() OVERRIDE { }
 69 virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) OVERRIDE { }
 70 virtual void scrollNonCompositedContents(const WebCore::IntRect&) OVERRIDE { }
7171 virtual void forceRepaint();
7272 virtual bool forceRepaintAsync(uint64_t callbackID);
7373 virtual void sizeDidChange(const WebCore::IntSize& newSize);

@@public:
8888 virtual void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint&);
8989 virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
9090 virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE;
 91 WebCore::CoordinatedGraphicsLayer* mainContentsLayer();
9192
9293#if ENABLE(REQUEST_ANIMATION_FRAME)
9394 virtual void scheduleAnimation() OVERRIDE;

@@private:
143144 void performScheduledLayerFlush();
144145 void didPerformScheduledLayerFlush();
145146 void syncDisplayState();
146 
147147 void layerFlushTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*);
148148
149149 void scheduleReleaseInactiveAtlases();

@@private:
164164#endif
165165
166166 OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
167 
168  // The layer which contains all non-composited content.
169  OwnPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
 167 WebCore::GraphicsLayer* m_rootCompositingLayer;
170168
171169 // The page overlay layer. Will be null if there's no page overlay.
172170 OwnPtr<WebCore::GraphicsLayer> m_pageOverlayLayer;