Changeset 100055 in webkit


Ignore:
Timestamp:
Nov 11, 2011 6:05:39 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Fix CCThreadProxy::setVisible
https://bugs.webkit.org/show_bug.cgi?id=71903

The behavior is different depending on whether we're showing
or hiding the compositor. This patch fixes both code paths.

Patch by Iain Merrick <husky@google.com> on 2011-11-11
Reviewed by James Robinson.

  • platform/graphics/chromium/cc/CCCompletionEvent.h:

(WebCore::CCCompletionEvent::CCCompletionEvent):
(WebCore::CCCompletionEvent::~CCCompletionEvent):
(WebCore::CCCompletionEvent::wait):
(WebCore::CCCompletionEvent::signal):

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

(WebCore::CCThreadProxy::setVisible):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r100054 r100055  
     12011-11-11  Iain Merrick  <husky@google.com>
     2
     3        [chromium] Fix CCThreadProxy::setVisible
     4        https://bugs.webkit.org/show_bug.cgi?id=71903
     5
     6        The behavior is different depending on whether we're showing
     7        or hiding the compositor. This patch fixes both code paths.
     8
     9        Reviewed by James Robinson.
     10
     11        * platform/graphics/chromium/cc/CCCompletionEvent.h:
     12        (WebCore::CCCompletionEvent::CCCompletionEvent):
     13        (WebCore::CCCompletionEvent::~CCCompletionEvent):
     14        (WebCore::CCCompletionEvent::wait):
     15        (WebCore::CCCompletionEvent::signal):
     16        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
     17        (WebCore::CCThreadProxy::setVisible):
     18
    1192011-11-11  Iain Merrick  <husky@google.com>
    220
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCCompletionEvent.h

    r95901 r100055  
    3131
    3232// Used for making blocking calls from one thread to another. Use only when
    33 // absolutely certain that doing-so will not lead to a livelock.
     33// absolutely certain that doing-so will not lead to a deadlock.
    3434//
    3535// It is safe to destroy this object as soon as wait() returns.
     
    3838    CCCompletionEvent()
    3939    {
     40#ifndef NDEBUG
     41        m_waited = false;
     42        m_signaled = false;
     43#endif
    4044        m_mutex.lock();
    4145    }
     
    4448    {
    4549        m_mutex.unlock();
     50        ASSERT(m_waited);
     51        ASSERT(m_signaled);
    4652    }
    4753
    4854    void wait()
    4955    {
     56        ASSERT(!m_waited);
     57#ifndef NDEBUG
     58        m_waited = true;
     59#endif
    5060        m_condition.wait(m_mutex);
    5161    }
     
    5464    {
    5565        MutexLocker lock(m_mutex);
     66        ASSERT(!m_signaled);
     67#ifndef NDEBUG
     68        m_signaled = true;
     69#endif
    5670        m_condition.signal();
    5771    }
     
    6074    Mutex m_mutex;
    6175    ThreadCondition m_condition;
     76#ifndef NDEBUG
     77    // Used to assert that wait() and signal() are each called exactly once.
     78    bool m_waited;
     79    bool m_signaled;
     80#endif
    6281};
    6382
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

    r100054 r100055  
    250250{
    251251    ASSERT(isMainThread());
    252     if (!visible) {
    253         CCCompletionEvent completion;
    254         s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::didBecomeInvisibleOnImplThread, AllowCrossThreadAccess(&completion)));
    255         return;
    256     }
    257     setNeedsRedraw();
    258 }
    259 
    260 void CCThreadProxy::didBecomeInvisibleOnImplThread(CCCompletionEvent* completion)
    261 {
    262     ASSERT(isImplThread());
    263     m_layerTreeHost->didBecomeInvisibleOnImplThread(m_layerTreeHostImpl.get());
    264     m_schedulerOnImplThread->setVisible(false);
    265     m_layerTreeHostImpl->setVisible(false);
     252    CCCompletionEvent completion;
     253    s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::setVisibleOnImplThread, AllowCrossThreadAccess(&completion), visible));
     254    completion.wait();
     255}
     256
     257void CCThreadProxy::setVisibleOnImplThread(CCCompletionEvent* completion, bool visible)
     258{
     259    ASSERT(isImplThread());
     260    if (!visible)
     261        m_layerTreeHost->didBecomeInvisibleOnImplThread(m_layerTreeHostImpl.get());
     262    else
     263        m_schedulerOnImplThread->setNeedsRedraw();
     264    m_schedulerOnImplThread->setVisible(visible);
     265    m_layerTreeHostImpl->setVisible(visible);
    266266    completion->signal();
    267267}
     
    448448    m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get());
    449449    CCTextureUpdater updater(m_layerTreeHostImpl->contentsTextureAllocator());
    450     m_layerTreeHostImpl->setVisible(m_layerTreeHost->visible());
    451     m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible());
    452450    m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get());
    453451
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h

    r99844 r100055  
    100100    void initializeLayerRendererOnImplThread(GraphicsContext3D*, CCCompletionEvent*, bool* initializeSucceeded, LayerRendererCapabilities*, int* compositorIdentifier);
    101101    void setNeedsAnimateOnImplThread();
    102     void didBecomeInvisibleOnImplThread(CCCompletionEvent*);
     102    void setVisibleOnImplThread(CCCompletionEvent*, bool visible);
    103103    void layerTreeHostClosedOnImplThread(CCCompletionEvent*);
    104104
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp

    r99943 r100055  
    210210    }
    211211
     212    void postSetVisibleToMainThread(bool visible)
     213    {
     214        callOnMainThread(visible ? CCLayerTreeHostTest::dispatchSetVisible : CCLayerTreeHostTest::dispatchSetInvisible, this);
     215    }
     216
    212217    void timeout()
    213218    {
     
    270275      if (test->m_layerTreeHost)
    271276          test->m_layerTreeHost->setNeedsRedraw();
     277    }
     278
     279    static void dispatchSetVisible(void* self)
     280    {
     281      ASSERT(isMainThread());
     282      CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self);
     283      ASSERT(test);
     284      if (test->m_layerTreeHost)
     285          test->m_layerTreeHost->setVisible(true);
     286    }
     287
     288    static void dispatchSetInvisible(void* self)
     289    {
     290      ASSERT(isMainThread());
     291      CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self);
     292      ASSERT(test);
     293      if (test->m_layerTreeHost)
     294          test->m_layerTreeHost->setVisible(false);
    272295    }
    273296
     
    765788}
    766789
     790class CCLayerTreeHostTestSetVisible : public CCLayerTreeHostTest {
     791public:
     792
     793    CCLayerTreeHostTestSetVisible()
     794        : m_numCommits(0)
     795        , m_numDraws(0)
     796    {
     797    }
     798
     799    virtual void beginTest()
     800    {
     801        postSetVisibleToMainThread(false);
     802        postSetNeedsRedrawToMainThread(); // This is suppressed while we're invisible.
     803        postSetVisibleToMainThread(true); // Triggers the redraw.
     804    }
     805
     806    virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl)
     807    {
     808        EXPECT_TRUE(impl->visible());
     809        ++m_numDraws;
     810        endTest();
     811    }
     812
     813    virtual void afterTest()
     814    {
     815        EXPECT_EQ(1, m_numDraws);
     816    }
     817
     818private:
     819    int m_numCommits;
     820    int m_numDraws;
     821};
     822
     823TEST_F(CCLayerTreeHostTestSetVisible, runMultiThread)
     824{
     825    runTest(true);
     826}
     827
    767828} // namespace
Note: See TracChangeset for help on using the changeset viewer.