[TextureMapper] TextureMapperPlatformLayerProxy::swapBuffers() should hold the lock...
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jan 2017 12:28:46 +0000 (12:28 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jan 2017 12:28:46 +0000 (12:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166852

Reviewed by Michael Catanzaro.

* platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
(WebCore::TextureMapperPlatformLayerProxy::swapBuffer): Append to previous buffer
to the m_usedBuffers Vector while the object's lock is held. Everywhere else the
m_usedBuffers Vector is used under the lock, no reason to not do the same here.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210541 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp

index 21c822b..1c467dc 100644 (file)
@@ -1,3 +1,15 @@
+2017-01-10  Zan Dobersek  <zdobersek@igalia.com>
+
+        [TextureMapper] TextureMapperPlatformLayerProxy::swapBuffers() should hold the lock throughout invocation
+        https://bugs.webkit.org/show_bug.cgi?id=166852
+
+        Reviewed by Michael Catanzaro.
+
+        * platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
+        (WebCore::TextureMapperPlatformLayerProxy::swapBuffer): Append to previous buffer
+        to the m_usedBuffers Vector while the object's lock is held. Everywhere else the
+        m_usedBuffers Vector is used under the lock, no reason to not do the same here.
+
 2017-01-09  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Implement JSSourceCode to propagate SourceCode in module pipeline
index 5e3c82f..88eb573 100644 (file)
@@ -139,18 +139,14 @@ void TextureMapperPlatformLayerProxy::releaseUnusedBuffersTimerFired()
 void TextureMapperPlatformLayerProxy::swapBuffer()
 {
     ASSERT(m_compositorThreadID == WTF::currentThread());
-    std::unique_ptr<TextureMapperPlatformLayerBuffer> prevBuffer;
-
-    {
-        LockHolder locker(m_lock);
-        if (!m_targetLayer || !m_pendingBuffer)
-            return;
+    LockHolder locker(m_lock);
+    if (!m_targetLayer || !m_pendingBuffer)
+        return;
 
-        prevBuffer = WTFMove(m_currentBuffer);
+    auto prevBuffer = WTFMove(m_currentBuffer);
 
-        m_currentBuffer = WTFMove(m_pendingBuffer);
-        m_targetLayer->setContentsLayer(m_currentBuffer.get());
-    }
+    m_currentBuffer = WTFMove(m_pendingBuffer);
+    m_targetLayer->setContentsLayer(m_currentBuffer.get());
 
     if (prevBuffer && prevBuffer->hasManagedTexture())
         m_usedBuffers.append(WTFMove(prevBuffer));