Changeset 113241 in webkit


Ignore:
Timestamp:
Apr 4, 2012, 2:27:36 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[Chromium] Always skip draw and readback if there is nothing
to draw.
https://bugs.webkit.org/show_bug.cgi?id=82680

This avoids corruption from pushing frames that have no valid
content drawn into them.
Also in addition to checking for non-existing root layers, check
for root layers with no content bounds. It's possible to see those
with kForceCompositing mode for empty documents.

Patch by Daniel Sievers <sievers@chromium.org> on 2012-04-04
Reviewed by James Robinson.

Added CCLayerTreeHostTestEmptyContentsShouldNotDraw.

Source/WebCore:

  • platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:

(WebCore::CCLayerTreeHostImpl::canDraw):
(WebCore::CCLayerTreeHostImpl::prepareToDraw):

  • platform/graphics/chromium/cc/CCThreadProxy.cpp:

(WebCore::CCThreadProxy::scheduledActionDrawAndSwapInternal):

Source/WebKit/chromium:

  • tests/CCLayerTreeHostImplTest.cpp:

(WebKitTests::TEST_F):

  • tests/CCLayerTreeHostTest.cpp:

(WTF::CCLayerTreeHostTest::doBeginTest):
(WTF):
(CCLayerTreeHostTestEmptyContentsShouldNotDraw):
(WTF::CCLayerTreeHostTestEmptyContentsShouldNotDraw::CCLayerTreeHostTestEmptyContentsShouldNotDraw):
(WTF::CCLayerTreeHostTestEmptyContentsShouldNotDraw::beginTest):
(WTF::CCLayerTreeHostTestEmptyContentsShouldNotDraw::drawLayersOnCCThread):
(WTF::CCLayerTreeHostTestEmptyContentsShouldNotDraw::didCommitAndDrawFrame):
(WTF::CCLayerTreeHostTestEmptyContentsShouldNotDraw::afterTest):
(WTF::TEST_F):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r113238 r113241  
     12012-04-04  Daniel Sievers  <sievers@chromium.org>
     2
     3        [Chromium] Always skip draw and readback if there is nothing
     4        to draw.
     5        https://bugs.webkit.org/show_bug.cgi?id=82680
     6
     7        This avoids corruption from pushing frames that have no valid
     8        content drawn into them.
     9        Also in addition to checking for non-existing root layers, check
     10        for root layers with no content bounds. It's possible to see those
     11        with kForceCompositing mode for empty documents.
     12
     13        Reviewed by James Robinson.
     14
     15        Added CCLayerTreeHostTestEmptyContentsShouldNotDraw.
     16
     17        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
     18        (WebCore::CCLayerTreeHostImpl::canDraw):
     19        (WebCore::CCLayerTreeHostImpl::prepareToDraw):
     20        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
     21        (WebCore::CCThreadProxy::scheduledActionDrawAndSwapInternal):
     22
    1232012-03-15  Jer Noble  <jer.noble@apple.com>
    224
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp

    r112551 r113241  
    142142bool CCLayerTreeHostImpl::canDraw()
    143143{
    144     if (!rootLayer())
     144    if (!rootLayer() || rootLayer()->bounds().isEmpty())
    145145        return false;
    146146    if (viewportSize().isEmpty())
     
    377377    frame.renderSurfaceLayerList.clear();
    378378
    379     if (!rootLayer())
    380         return false;
    381 
    382379    if (!calculateRenderPasses(frame.renderPasses, frame.renderSurfaceLayerList))
    383380        return false;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h

    r112446 r113241  
    8989    virtual void commitComplete();
    9090    virtual void animate(double monotonicTime, double wallClockTime);
    91     // Returns false if problems occured preparing the frame, and we should try to avoid displaying the frame.
     91    // Returns false if we should try to avoid displaying the frame, because it has visible checkerboard during an animation.
    9292    virtual bool prepareToDraw(FrameData&);
    9393    virtual void drawLayers(const FrameData&);
     
    103103
    104104    // Implementation
     105
     106    // Returns false if there is no valid root layer and thus no content that can be drawn.
    105107    bool canDraw();
    106108    GraphicsContext3D* context();
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

    r112729 r113241  
    579579    m_layerTreeHostImpl->animate(monotonicTime, wallClockTime);
    580580    CCLayerTreeHostImpl::FrameData frame;
    581     bool drawFrame = m_layerTreeHostImpl->prepareToDraw(frame) || forcedDraw;
     581    bool drawFrame = m_layerTreeHostImpl->canDraw() && (m_layerTreeHostImpl->prepareToDraw(frame) || forcedDraw);
    582582    if (drawFrame) {
    583583        m_layerTreeHostImpl->drawLayers(frame);
     
    587587    // Check for a pending compositeAndReadback.
    588588    if (m_readbackRequestOnImplThread) {
    589         ASSERT(drawFrame); // This should be a forcedDraw
    590         m_layerTreeHostImpl->readback(m_readbackRequestOnImplThread->pixels, m_readbackRequestOnImplThread->rect);
    591         m_readbackRequestOnImplThread->success = !m_layerTreeHostImpl->isContextLost();
     589        if (drawFrame)
     590            m_layerTreeHostImpl->readback(m_readbackRequestOnImplThread->pixels, m_readbackRequestOnImplThread->rect);
     591        m_readbackRequestOnImplThread->success = !m_layerTreeHostImpl->isContextLost() && drawFrame;
    592592        m_readbackRequestOnImplThread->completion.signal();
    593593        m_readbackRequestOnImplThread = 0;
     
    599599    // Process any finish request
    600600    if (m_finishAllRenderingCompletionEventOnImplThread) {
    601         ASSERT(drawFrame); // This should be a forcedDraw
    602601        m_layerTreeHostImpl->finishAllRendering();
    603602        m_finishAllRenderingCompletionEventOnImplThread->signal();
     
    611610    }
    612611
    613     ASSERT(drawFrame || (!drawFrame && !forcedDraw));
    614612    return result;
    615613}
  • trunk/Source/WebKit/chromium/ChangeLog

    r113227 r113241  
     12012-04-04  Daniel Sievers  <sievers@chromium.org>
     2
     3        [Chromium] Always skip draw and readback if there is nothing
     4        to draw.
     5        https://bugs.webkit.org/show_bug.cgi?id=82680
     6
     7        This avoids corruption from pushing frames that have no valid
     8        content drawn into them.
     9        Also in addition to checking for non-existing root layers, check
     10        for root layers with no content bounds. It's possible to see those
     11        with kForceCompositing mode for empty documents.
     12
     13        Reviewed by James Robinson.
     14
     15        Added CCLayerTreeHostTestEmptyContentsShouldNotDraw.
     16
     17        * tests/CCLayerTreeHostImplTest.cpp:
     18        (WebKitTests::TEST_F):
     19        * tests/CCLayerTreeHostTest.cpp:
     20        (WTF::CCLayerTreeHostTest::doBeginTest):
     21        (WTF):
     22        (CCLayerTreeHostTestEmptyContentsShouldNotDraw):
     23        (WTF::CCLayerTreeHostTestEmptyContentsShouldNotDraw::CCLayerTreeHostTestEmptyContentsShouldNotDraw):
     24        (WTF::CCLayerTreeHostTestEmptyContentsShouldNotDraw::beginTest):
     25        (WTF::CCLayerTreeHostTestEmptyContentsShouldNotDraw::drawLayersOnCCThread):
     26        (WTF::CCLayerTreeHostTestEmptyContentsShouldNotDraw::didCommitAndDrawFrame):
     27        (WTF::CCLayerTreeHostTestEmptyContentsShouldNotDraw::afterTest):
     28        (WTF::TEST_F):
     29
    1302012-04-04  Mark Pilgrim  <pilgrim@chromium.org>
    231
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp

    r112127 r113241  
    249249
    250250    OwnPtr<CCLayerImpl> root = CCLayerImpl::create(0);
     251    root->setBounds(IntSize(1, 1));
    251252    root->setScrollable(true);
    252253    root->setScrollPosition(IntPoint(0, 0));
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

    r112896 r113241  
    533533
    534534    RefPtr<LayerChromium> rootLayer = LayerChromium::create();
     535
     536    // Only non-empty root layers will cause drawing to happen.
     537    rootLayer->setBounds(IntSize(1, 1));
     538
    535539    m_layerTreeHost = MockLayerTreeHost::create(this, m_client.get(), rootLayer, m_settings);
    536540    ASSERT_TRUE(m_layerTreeHost);
     
    818822
    819823TEST_F(CCLayerTreeHostTestSetNeedsRedraw, runMultiThread)
     824{
     825    runTestThreaded();
     826}
     827
     828// If the root layer has no content bounds, we should see a commit, but should not be
     829// pushing any frames as the contents will be undefined. Regardless, forced draws need
     830// to always signal completion.
     831class CCLayerTreeHostTestEmptyContentsShouldNotDraw : public CCLayerTreeHostTestThreadOnly {
     832public:
     833    CCLayerTreeHostTestEmptyContentsShouldNotDraw()
     834        : m_numCommits(0)
     835    {
     836    }
     837
     838    virtual void beginTest()
     839    {
     840    }
     841
     842    virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl)
     843    {
     844        // Only the initial draw should bring us here.
     845        EXPECT_FALSE(impl->rootLayer()->bounds().isEmpty());
     846    }
     847
     848    virtual void didCommitAndDrawFrame()
     849    {
     850        m_numCommits++;
     851        if (m_numCommits == 1) {
     852            // Put an empty root layer.
     853            RefPtr<LayerChromium> rootLayer = LayerChromium::create();
     854            m_layerTreeHost->setRootLayer(rootLayer);
     855
     856            OwnArrayPtr<char> pixels(adoptArrayPtr(new char[4]));
     857            m_layerTreeHost->compositeAndReadback(static_cast<void*>(pixels.get()), IntRect(0, 0, 1, 1));
     858        } else if (m_numCommits == 2) {
     859            m_layerTreeHost->setNeedsCommit();
     860            m_layerTreeHost->finishAllRendering();
     861            endTest();
     862        }
     863    }
     864
     865    virtual void afterTest()
     866    {
     867    }
     868
     869private:
     870    int m_numCommits;
     871};
     872
     873TEST_F(CCLayerTreeHostTestEmptyContentsShouldNotDraw, runMultiThread)
    820874{
    821875    runTestThreaded();
Note: See TracChangeset for help on using the changeset viewer.