Title: [126046] trunk/Source/WebCore
Revision
126046
Author
[email protected]
Date
2012-08-20 11:23:08 -0700 (Mon, 20 Aug 2012)

Log Message

[chromium] Update HUD resources as a final step to drawing a frame
https://bugs.webkit.org/show_bug.cgi?id=93743

Reviewed by Adrienne Walker.

The HUD should be painted as a last step, after the whole frame has been
generated. This introduces a new "updateHudTexture" method on the HUD layer
and has the HUD layer save itself on CCLayerTreeHostImpl so that it can
call back to this method.

This allows the CCLayerTreeHostImpl to cause the HUD layer to update its
texture as a final step before drawing the frame, allowing the HUD texture
to contain all possible information about the current frame.

* platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp:
(WebCore::CCHeadsUpDisplayLayerImpl::willDraw):
(WebCore):
(WebCore::CCHeadsUpDisplayLayerImpl::appendQuads):
(WebCore::CCHeadsUpDisplayLayerImpl::updateHudTexture):
* platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h:
(CCHeadsUpDisplayLayerImpl):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::finishCommitOnImplThread):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
(WebCore::CCLayerTreeHostImpl::drawLayers):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
(WebCore):
(WebCore::CCLayerTreeHostImpl::setHudLayer):
(WebCore::CCLayerTreeHostImpl::hudLayer):
(CCLayerTreeHostImpl):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (126045 => 126046)


--- trunk/Source/WebCore/ChangeLog	2012-08-20 18:21:45 UTC (rev 126045)
+++ trunk/Source/WebCore/ChangeLog	2012-08-20 18:23:08 UTC (rev 126046)
@@ -1,3 +1,37 @@
+2012-08-20  Dana Jansens  <[email protected]>
+
+        [chromium] Update HUD resources as a final step to drawing a frame
+        https://bugs.webkit.org/show_bug.cgi?id=93743
+
+        Reviewed by Adrienne Walker.
+
+        The HUD should be painted as a last step, after the whole frame has been
+        generated. This introduces a new "updateHudTexture" method on the HUD layer
+        and has the HUD layer save itself on CCLayerTreeHostImpl so that it can
+        call back to this method.
+
+        This allows the CCLayerTreeHostImpl to cause the HUD layer to update its
+        texture as a final step before drawing the frame, allowing the HUD texture
+        to contain all possible information about the current frame.
+
+        * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp:
+        (WebCore::CCHeadsUpDisplayLayerImpl::willDraw):
+        (WebCore):
+        (WebCore::CCHeadsUpDisplayLayerImpl::appendQuads):
+        (WebCore::CCHeadsUpDisplayLayerImpl::updateHudTexture):
+        * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h:
+        (CCHeadsUpDisplayLayerImpl):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::finishCommitOnImplThread):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
+        (WebCore::CCLayerTreeHostImpl::drawLayers):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        (WebCore):
+        (WebCore::CCLayerTreeHostImpl::setHudLayer):
+        (WebCore::CCLayerTreeHostImpl::hudLayer):
+        (CCLayerTreeHostImpl):
+
 2012-08-20  Ian Vollick  <[email protected]>
 
         [chromium] Add tracing for active composited animations

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp (126045 => 126046)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp	2012-08-20 18:21:45 UTC (rev 126045)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp	2012-08-20 18:23:08 UTC (rev 126046)
@@ -87,9 +87,27 @@
     if (m_hudTexture->size() != bounds())
         m_hudTexture->free();
 
-    if (!m_hudTexture->id() && !m_hudTexture->allocate(CCRenderer::ImplPool, bounds(), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny))
+    if (!m_hudTexture->id())
+        m_hudTexture->allocate(CCRenderer::ImplPool, bounds(), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny);
+}
+
+void CCHeadsUpDisplayLayerImpl::appendQuads(CCQuadSink& quadList, const CCSharedQuadState* sharedQuadState, bool&)
+{
+    if (!m_hudTexture->id())
         return;
 
+    IntRect quadRect(IntPoint(), bounds());
+    bool premultipliedAlpha = true;
+    FloatRect uvRect(0, 0, 1, 1);
+    bool flipped = false;
+    quadList.append(CCTextureDrawQuad::create(sharedQuadState, quadRect, m_hudTexture->id(), premultipliedAlpha, uvRect, flipped));
+}
+
+void CCHeadsUpDisplayLayerImpl::updateHudTexture(CCResourceProvider* resourceProvider)
+{
+    if (!m_hudTexture->id())
+        return;
+
     SkISize canvasSize;
     if (m_hudCanvas)
         canvasSize = m_hudCanvas->getDeviceSize();
@@ -110,18 +128,6 @@
     resourceProvider->upload(m_hudTexture->id(), static_cast<const uint8_t*>(bitmap->getPixels()), layerRect, layerRect, IntSize());
 }
 
-void CCHeadsUpDisplayLayerImpl::appendQuads(CCQuadSink& quadList, const CCSharedQuadState* sharedQuadState, bool&)
-{
-    if (!m_hudTexture->id())
-        return;
-
-    IntRect quadRect(IntPoint(), bounds());
-    bool premultipliedAlpha = true;
-    FloatRect uvRect(0, 0, 1, 1);
-    bool flipped = false;
-    quadList.append(CCTextureDrawQuad::create(sharedQuadState, quadRect, m_hudTexture->id(), premultipliedAlpha, uvRect, flipped));
-}
-
 void CCHeadsUpDisplayLayerImpl::didDraw(CCResourceProvider* resourceProvider)
 {
     CCLayerImpl::didDraw(resourceProvider);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h (126045 => 126046)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h	2012-08-20 18:21:45 UTC (rev 126045)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h	2012-08-20 18:23:08 UTC (rev 126046)
@@ -50,6 +50,7 @@
 
     virtual void willDraw(CCResourceProvider*) OVERRIDE;
     virtual void appendQuads(CCQuadSink&, const CCSharedQuadState*, bool& hadMissingTiles) OVERRIDE;
+    void updateHudTexture(CCResourceProvider*);
     virtual void didDraw(CCResourceProvider*) OVERRIDE;
 
     virtual void didLoseContext() OVERRIDE;

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (126045 => 126046)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp	2012-08-20 18:21:45 UTC (rev 126045)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp	2012-08-20 18:23:08 UTC (rev 126046)
@@ -28,6 +28,7 @@
 
 #include "CCFontAtlas.h"
 #include "CCGraphicsContext.h"
+#include "CCHeadsUpDisplayLayerImpl.h"
 #include "CCLayerAnimationController.h"
 #include "CCLayerIterator.h"
 #include "CCLayerTreeHostCommon.h"
@@ -236,6 +237,11 @@
 
     hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostImpl->detachLayerTree(), hostImpl));
 
+    if (!m_hudLayer)
+        hostImpl->setHudLayer(0);
+    else
+        hostImpl->setHudLayer(static_cast<CCHeadsUpDisplayLayerImpl*>(CCLayerTreeHostCommon::findLayerInSubtree(hostImpl->rootLayer(), m_hudLayer->id())));
+
     // We may have added an animation during the tree sync. This will cause both layer tree hosts
     // to visit their controllers.
     if (rootLayer() && m_needsAnimateLayers)

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (126045 => 126046)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-08-20 18:21:45 UTC (rev 126045)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-08-20 18:23:08 UTC (rev 126046)
@@ -32,6 +32,7 @@
 #include "CCDelayBasedTimeSource.h"
 #include "CCFontAtlas.h"
 #include "CCFrameRateCounter.h"
+#include "CCHeadsUpDisplayLayerImpl.h"
 #include "CCLayerIterator.h"
 #include "CCLayerTreeHost.h"
 #include "CCLayerTreeHostCommon.h"
@@ -119,6 +120,7 @@
     , m_sourceFrameNumber(-1)
     , m_rootScrollLayerImpl(0)
     , m_currentlyScrollingLayerImpl(0)
+    , m_hudLayerImpl(0)
     , m_scrollingLayerIdFromPreviousTree(-1)
     , m_scrollDeltaIsInScreenSpace(false)
     , m_settings(settings)
@@ -547,11 +549,16 @@
     // RenderWidget.
     m_fpsCounter->markBeginningOfFrame(currentTime());
 
-    m_layerRenderer->drawFrame(frame.renderPasses, frame.renderPassesById);
-
     if (m_settings.showDebugRects())
         m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(), *frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, settings());
 
+    // Because the contents of the HUD depend on everything else in the frame, the contents
+    // of its texture are updated as the last thing before the frame is drawn.
+    if (m_hudLayerImpl)
+        m_hudLayerImpl->updateHudTexture(m_resourceProvider.get());
+
+    m_layerRenderer->drawFrame(frame.renderPasses, frame.renderPassesById);
+
     // Once a RenderPass has been drawn, its damage should be cleared in
     // case the RenderPass will be reused next frame.
     for (unsigned int i = 0; i < frame.renderPasses.size(); i++)

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h (126045 => 126046)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2012-08-20 18:21:45 UTC (rev 126045)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2012-08-20 18:23:08 UTC (rev 126046)
@@ -41,6 +41,7 @@
 class CCCompletionEvent;
 class CCDebugRectHistory;
 class CCFrameRateCounter;
+class CCHeadsUpDisplayLayerImpl;
 class CCLayerImpl;
 class CCLayerTreeHostImplTimeSourceAdapter;
 class CCPageScaleAnimation;
@@ -140,6 +141,9 @@
     void setRootLayer(PassOwnPtr<CCLayerImpl>);
     CCLayerImpl* rootLayer() { return m_rootLayerImpl.get(); }
 
+    void setHudLayer(CCHeadsUpDisplayLayerImpl* layerImpl) { m_hudLayerImpl = layerImpl; }
+    CCHeadsUpDisplayLayerImpl* hudLayer() { return m_hudLayerImpl; }
+
     // Release ownership of the current layer tree and replace it with an empty
     // tree. Returns the root layer of the detached tree.
     PassOwnPtr<CCLayerImpl> detachLayerTree();
@@ -267,6 +271,7 @@
     OwnPtr<CCLayerImpl> m_rootLayerImpl;
     CCLayerImpl* m_rootScrollLayerImpl;
     CCLayerImpl* m_currentlyScrollingLayerImpl;
+    CCHeadsUpDisplayLayerImpl* m_hudLayerImpl;
     int m_scrollingLayerIdFromPreviousTree;
     bool m_scrollDeltaIsInScreenSpace;
     CCLayerTreeSettings m_settings;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to