Changeset 112304 in webkit


Ignore:
Timestamp:
Mar 27, 2012 1:06:14 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] fix confusing destruction sequence in LayerCompositingThread
https://bugs.webkit.org/show_bug.cgi?id=81706

Patch by Joe Mason <jmason@rim.com> on 2012-03-27
Reviewed by Rob Buis.

LayerCompositingThread has a destructor that does a synchronous
dispatch to the compositing thread and then does the actual cleanup
from a helper function. This is confusing.It should be the
opposite: the helper function dispatches to the compositing thread,
which calls delete.

No new tests since the existing animation tests will exercise this
code.

  • platform/graphics/blackberry/LayerCompositingThread.cpp:

(WebCore::LayerCompositingThread::destroyOnCompositingThread):
(WebCore):
(WebCore::LayerCompositingThread::~LayerCompositingThread):

  • platform/graphics/blackberry/LayerCompositingThread.h:

(LayerCompositingThread):
(WTF):
(WTF::::deref):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r112302 r112304  
     12012-03-27  Joe Mason  <jmason@rim.com>
     2
     3        [BlackBerry] fix confusing destruction sequence in LayerCompositingThread
     4        https://bugs.webkit.org/show_bug.cgi?id=81706
     5
     6        Reviewed by Rob Buis.
     7
     8        LayerCompositingThread has a destructor that does a synchronous
     9        dispatch to the compositing thread and then does the actual cleanup
     10        from a helper function. This is confusing.It should be the
     11        opposite: the helper function dispatches to the compositing thread,
     12        which calls delete.
     13
     14        No new tests since the existing animation tests will exercise this
     15        code.
     16
     17        * platform/graphics/blackberry/LayerCompositingThread.cpp:
     18        (WebCore::LayerCompositingThread::destroyOnCompositingThread):
     19        (WebCore):
     20        (WebCore::LayerCompositingThread::~LayerCompositingThread):
     21        * platform/graphics/blackberry/LayerCompositingThread.h:
     22        (LayerCompositingThread):
     23        (WTF):
     24        (WTF::::deref):
     25
    1262012-03-27  Alexey Proskuryakov  <ap@apple.com>
    227
  • trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.cpp

    r112110 r112304  
    7272}
    7373
    74 LayerCompositingThread::~LayerCompositingThread()
    75 {
    76     // Unfortunately, ThreadSafeShared<T> is hardwired to call T::~T().
    77     // To switch threads in case the last reference is released on the
    78     // WebKit thread, we send a sync message to the compositing thread.
    79     destroyOnCompositingThread();
    80 }
    81 
    8274void LayerCompositingThread::destroyOnCompositingThread()
    8375{
     
    8880        return;
    8981    }
     82
     83    delete this;
     84}
     85
     86LayerCompositingThread::~LayerCompositingThread()
     87{
     88    ASSERT(isCompositingThread());
    9089
    9190    m_tiler->layerCompositingThreadDestroyed();
  • trunk/Source/WebCore/platform/graphics/blackberry/LayerCompositingThread.h

    r112110 r112304  
    5454namespace WebCore {
    5555
    56 class DestroyOnCompositingThread;
    5756class LayerRenderer;
    5857
     
    146145    LayerCompositingThread(LayerType, PassRefPtr<LayerTiler>);
    147146
    148     friend class DestroyOnCompositingThread;
     147    friend class WTF::ThreadSafeRefCounted<WebCore::LayerCompositingThread>;
    149148    void destroyOnCompositingThread();
    150149
     
    189188};
    190189
    191 }
     190} // namespace WebCore
     191
     192namespace WTF {
     193
     194// LayerCompositingThread objects must be destroyed on the compositing thread.
     195// But it's possible for the last reference to be held by the WebKit thread.
     196// So we create a custom specialization of ThreadSafeRefCounted which calls a
     197// function that ensures the destructor is called on the correct thread, rather
     198// than calling delete directly.
     199template<>
     200inline void ThreadSafeRefCounted<WebCore::LayerCompositingThread>::deref()
     201{
     202    if (derefBase())
     203        static_cast<WebCore::LayerCompositingThread*>(this)->destroyOnCompositingThread();
     204}
     205
     206} // namespace WTF
     207
    192208
    193209#endif // USE(ACCELERATED_COMPOSITING)
Note: See TracChangeset for help on using the changeset viewer.