Changeset 126046 in webkit


Ignore:
Timestamp:
Aug 20, 2012 11:23:08 AM (12 years ago)
Author:
danakj@chromium.org
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):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r126045 r126046  
     12012-08-20  Dana Jansens  <danakj@chromium.org>
     2
     3        [chromium] Update HUD resources as a final step to drawing a frame
     4        https://bugs.webkit.org/show_bug.cgi?id=93743
     5
     6        Reviewed by Adrienne Walker.
     7
     8        The HUD should be painted as a last step, after the whole frame has been
     9        generated. This introduces a new "updateHudTexture" method on the HUD layer
     10        and has the HUD layer save itself on CCLayerTreeHostImpl so that it can
     11        call back to this method.
     12
     13        This allows the CCLayerTreeHostImpl to cause the HUD layer to update its
     14        texture as a final step before drawing the frame, allowing the HUD texture
     15        to contain all possible information about the current frame.
     16
     17        * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp:
     18        (WebCore::CCHeadsUpDisplayLayerImpl::willDraw):
     19        (WebCore):
     20        (WebCore::CCHeadsUpDisplayLayerImpl::appendQuads):
     21        (WebCore::CCHeadsUpDisplayLayerImpl::updateHudTexture):
     22        * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h:
     23        (CCHeadsUpDisplayLayerImpl):
     24        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     25        (WebCore::CCLayerTreeHost::finishCommitOnImplThread):
     26        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
     27        (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl):
     28        (WebCore::CCLayerTreeHostImpl::drawLayers):
     29        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
     30        (WebCore):
     31        (WebCore::CCLayerTreeHostImpl::setHudLayer):
     32        (WebCore::CCLayerTreeHostImpl::hudLayer):
     33        (CCLayerTreeHostImpl):
     34
    1352012-08-20  Ian Vollick  <vollick@chromium.org>
    236
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp

    r125932 r126046  
    8888        m_hudTexture->free();
    8989
    90     if (!m_hudTexture->id() && !m_hudTexture->allocate(CCRenderer::ImplPool, bounds(), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny))
     90    if (!m_hudTexture->id())
     91        m_hudTexture->allocate(CCRenderer::ImplPool, bounds(), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny);
     92}
     93
     94void CCHeadsUpDisplayLayerImpl::appendQuads(CCQuadSink& quadList, const CCSharedQuadState* sharedQuadState, bool&)
     95{
     96    if (!m_hudTexture->id())
     97        return;
     98
     99    IntRect quadRect(IntPoint(), bounds());
     100    bool premultipliedAlpha = true;
     101    FloatRect uvRect(0, 0, 1, 1);
     102    bool flipped = false;
     103    quadList.append(CCTextureDrawQuad::create(sharedQuadState, quadRect, m_hudTexture->id(), premultipliedAlpha, uvRect, flipped));
     104}
     105
     106void CCHeadsUpDisplayLayerImpl::updateHudTexture(CCResourceProvider* resourceProvider)
     107{
     108    if (!m_hudTexture->id())
    91109        return;
    92110
     
    109127    ASSERT(bitmap->config() == SkBitmap::kARGB_8888_Config);
    110128    resourceProvider->upload(m_hudTexture->id(), static_cast<const uint8_t*>(bitmap->getPixels()), layerRect, layerRect, IntSize());
    111 }
    112 
    113 void CCHeadsUpDisplayLayerImpl::appendQuads(CCQuadSink& quadList, const CCSharedQuadState* sharedQuadState, bool&)
    114 {
    115     if (!m_hudTexture->id())
    116         return;
    117 
    118     IntRect quadRect(IntPoint(), bounds());
    119     bool premultipliedAlpha = true;
    120     FloatRect uvRect(0, 0, 1, 1);
    121     bool flipped = false;
    122     quadList.append(CCTextureDrawQuad::create(sharedQuadState, quadRect, m_hudTexture->id(), premultipliedAlpha, uvRect, flipped));
    123129}
    124130
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h

    r125932 r126046  
    5151    virtual void willDraw(CCResourceProvider*) OVERRIDE;
    5252    virtual void appendQuads(CCQuadSink&, const CCSharedQuadState*, bool& hadMissingTiles) OVERRIDE;
     53    void updateHudTexture(CCResourceProvider*);
    5354    virtual void didDraw(CCResourceProvider*) OVERRIDE;
    5455
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r125932 r126046  
    2929#include "CCFontAtlas.h"
    3030#include "CCGraphicsContext.h"
     31#include "CCHeadsUpDisplayLayerImpl.h"
    3132#include "CCLayerAnimationController.h"
    3233#include "CCLayerIterator.h"
     
    237238    hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(rootLayer(), hostImpl->detachLayerTree(), hostImpl));
    238239
     240    if (!m_hudLayer)
     241        hostImpl->setHudLayer(0);
     242    else
     243        hostImpl->setHudLayer(static_cast<CCHeadsUpDisplayLayerImpl*>(CCLayerTreeHostCommon::findLayerInSubtree(hostImpl->rootLayer(), m_hudLayer->id())));
     244
    239245    // We may have added an animation during the tree sync. This will cause both layer tree hosts
    240246    // to visit their controllers.
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp

    r126018 r126046  
    3333#include "CCFontAtlas.h"
    3434#include "CCFrameRateCounter.h"
     35#include "CCHeadsUpDisplayLayerImpl.h"
    3536#include "CCLayerIterator.h"
    3637#include "CCLayerTreeHost.h"
     
    120121    , m_rootScrollLayerImpl(0)
    121122    , m_currentlyScrollingLayerImpl(0)
     123    , m_hudLayerImpl(0)
    122124    , m_scrollingLayerIdFromPreviousTree(-1)
    123125    , m_scrollDeltaIsInScreenSpace(false)
     
    548550    m_fpsCounter->markBeginningOfFrame(currentTime());
    549551
    550     m_layerRenderer->drawFrame(frame.renderPasses, frame.renderPassesById);
    551 
    552552    if (m_settings.showDebugRects())
    553553        m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(), *frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, settings());
     554
     555    // Because the contents of the HUD depend on everything else in the frame, the contents
     556    // of its texture are updated as the last thing before the frame is drawn.
     557    if (m_hudLayerImpl)
     558        m_hudLayerImpl->updateHudTexture(m_resourceProvider.get());
     559
     560    m_layerRenderer->drawFrame(frame.renderPasses, frame.renderPassesById);
    554561
    555562    // Once a RenderPass has been drawn, its damage should be cleared in
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h

    r126018 r126046  
    4242class CCDebugRectHistory;
    4343class CCFrameRateCounter;
     44class CCHeadsUpDisplayLayerImpl;
    4445class CCLayerImpl;
    4546class CCLayerTreeHostImplTimeSourceAdapter;
     
    141142    CCLayerImpl* rootLayer() { return m_rootLayerImpl.get(); }
    142143
     144    void setHudLayer(CCHeadsUpDisplayLayerImpl* layerImpl) { m_hudLayerImpl = layerImpl; }
     145    CCHeadsUpDisplayLayerImpl* hudLayer() { return m_hudLayerImpl; }
     146
    143147    // Release ownership of the current layer tree and replace it with an empty
    144148    // tree. Returns the root layer of the detached tree.
     
    268272    CCLayerImpl* m_rootScrollLayerImpl;
    269273    CCLayerImpl* m_currentlyScrollingLayerImpl;
     274    CCHeadsUpDisplayLayerImpl* m_hudLayerImpl;
    270275    int m_scrollingLayerIdFromPreviousTree;
    271276    bool m_scrollDeltaIsInScreenSpace;
Note: See TracChangeset for help on using the changeset viewer.