- Revision
- 93346
- Author
- [email protected]
- Date
- 2011-08-18 13:37:25 -0700 (Thu, 18 Aug 2011)
Log Message
[chromium] Assert that main thread and compositor thread are used safely
https://bugs.webkit.org/show_bug.cgi?id=66145
CCLayerTreeHostImplProxy now has public static methods isMainThread()
and isImplThread(), and we ASSERT these in various places. If threaded
compositing is disabled, we fake isImplThread() by setting a flag for
the duration of compositing, so the assert is still valid.
Patch by Iain Merrick <[email protected]> on 2011-08-18
Reviewed by James Robinson.
Covered by existing tests.
* platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp:
(WebCore::CCCanvasLayerImpl::draw):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::doComposite):
* platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp:
(WebCore::CCLayerTreeHostImplProxy::postDrawLayersTaskOnCCThread):
(WebCore::CCLayerTreeHostImplProxy::requestFrameAndCommitOnCCThread):
(WebCore::CCLayerTreeHostImplProxy::isMainThread):
(WebCore::CCLayerTreeHostImplProxy::isImplThread):
(WebCore::CCLayerTreeHostImplProxy::setImplThread):
(WebCore::CCLayerTreeHostImplProxy::commitOnCCThread):
(WebCore::CCLayerTreeHostImplProxy::drawLayersOnCCThread):
(WebCore::CCLayerTreeHostImplProxy::setNeedsCommitAndRedrawOnCCThread):
(WebCore::CCLayerTreeHostImplProxy::setNeedsRedrawOnCCThread):
(WebCore::CCLayerTreeHostImplProxy::initImplOnCCThread):
(WebCore::CCLayerTreeHostImplProxy::layerTreeHostClosedOnCCThread):
* platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h:
* platform/graphics/chromium/cc/CCPluginLayerImpl.cpp:
(WebCore::CCPluginLayerImpl::draw):
* platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
(WebCore::CCTiledLayerImpl::draw):
* platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
(WebCore::CCVideoLayerImpl::draw):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (93345 => 93346)
--- trunk/Source/WebCore/ChangeLog 2011-08-18 20:36:17 UTC (rev 93345)
+++ trunk/Source/WebCore/ChangeLog 2011-08-18 20:37:25 UTC (rev 93346)
@@ -1,3 +1,41 @@
+2011-08-18 Iain Merrick <[email protected]>
+
+ [chromium] Assert that main thread and compositor thread are used safely
+ https://bugs.webkit.org/show_bug.cgi?id=66145
+
+ CCLayerTreeHostImplProxy now has public static methods isMainThread()
+ and isImplThread(), and we ASSERT these in various places. If threaded
+ compositing is disabled, we fake isImplThread() by setting a flag for
+ the duration of compositing, so the assert is still valid.
+
+ Reviewed by James Robinson.
+
+ Covered by existing tests.
+
+ * platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp:
+ (WebCore::CCCanvasLayerImpl::draw):
+ * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+ (WebCore::CCLayerTreeHost::doComposite):
+ * platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp:
+ (WebCore::CCLayerTreeHostImplProxy::postDrawLayersTaskOnCCThread):
+ (WebCore::CCLayerTreeHostImplProxy::requestFrameAndCommitOnCCThread):
+ (WebCore::CCLayerTreeHostImplProxy::isMainThread):
+ (WebCore::CCLayerTreeHostImplProxy::isImplThread):
+ (WebCore::CCLayerTreeHostImplProxy::setImplThread):
+ (WebCore::CCLayerTreeHostImplProxy::commitOnCCThread):
+ (WebCore::CCLayerTreeHostImplProxy::drawLayersOnCCThread):
+ (WebCore::CCLayerTreeHostImplProxy::setNeedsCommitAndRedrawOnCCThread):
+ (WebCore::CCLayerTreeHostImplProxy::setNeedsRedrawOnCCThread):
+ (WebCore::CCLayerTreeHostImplProxy::initImplOnCCThread):
+ (WebCore::CCLayerTreeHostImplProxy::layerTreeHostClosedOnCCThread):
+ * platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h:
+ * platform/graphics/chromium/cc/CCPluginLayerImpl.cpp:
+ (WebCore::CCPluginLayerImpl::draw):
+ * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
+ (WebCore::CCTiledLayerImpl::draw):
+ * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
+ (WebCore::CCVideoLayerImpl::draw):
+
2011-08-18 Alexey Proskuryakov <[email protected]>
Regional indicator symbols that are combined should behave as a single character when editing
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp (93345 => 93346)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp 2011-08-18 20:36:17 UTC (rev 93345)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp 2011-08-18 20:37:25 UTC (rev 93346)
@@ -31,6 +31,7 @@
#include "GraphicsContext3D.h"
#include "LayerRendererChromium.h"
+#include "cc/CCLayerTreeHostImplProxy.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -49,6 +50,7 @@
void CCCanvasLayerImpl::draw()
{
+ ASSERT(CCLayerTreeHostImplProxy::isImplThread());
ASSERT(layerRenderer());
const CCCanvasLayerImpl::Program* program = layerRenderer()->canvasLayerProgram();
ASSERT(program && program->initialized());
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp (93345 => 93346)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2011-08-18 20:36:17 UTC (rev 93345)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp 2011-08-18 20:37:25 UTC (rev 93346)
@@ -223,9 +223,15 @@
#if !USE(THREADED_COMPOSITING)
void CCLayerTreeHost::doComposite()
{
+#ifndef NDEBUG
+ CCLayerTreeHostImplProxy::setImplThread(true);
+#endif
ASSERT(m_layerRenderer);
m_layerRenderer->updateLayers();
m_layerRenderer->drawLayers();
+#ifndef NDEBUG
+ CCLayerTreeHostImplProxy::setImplThread(false);
+#endif
}
void CCLayerTreeHost::composite(bool finish)
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp (93345 => 93346)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp 2011-08-18 20:36:17 UTC (rev 93345)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp 2011-08-18 20:37:25 UTC (rev 93346)
@@ -111,7 +111,7 @@
void CCLayerTreeHostImplProxy::postDrawLayersTaskOnCCThread()
{
- ASSERT(isCCThread());
+ ASSERT(isImplThread());
if (m_layerTreeHostImpl)
ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplProxy::drawLayersOnCCThread));
}
@@ -119,21 +119,40 @@
void CCLayerTreeHostImplProxy::requestFrameAndCommitOnCCThread(double frameBeginTime)
{
TRACE_EVENT("CCLayerTreeHostImplProxy::requestFrameAndCommitOnCCThread", this, 0);
- ASSERT(isCCThread());
+ ASSERT(isImplThread());
if (m_layerTreeHostImpl)
CCMainThread::postTask(createMainThreadTask(this, &CCLayerTreeHostImplProxy::requestFrameAndCommit, frameBeginTime));
}
-bool CCLayerTreeHostImplProxy::isMainThread() const
+#ifndef NDEBUG
+bool CCLayerTreeHostImplProxy::isMainThread()
{
return ::isMainThread();
}
-bool CCLayerTreeHostImplProxy::isCCThread() const
+#if USE(THREADED_COMPOSITING)
+bool CCLayerTreeHostImplProxy::isImplThread()
{
return currentThread() == ccThread->threadID();
}
+#else
+namespace {
+bool fakeImplThread = false;
+}
+bool CCLayerTreeHostImplProxy::isImplThread()
+{
+ return fakeImplThread;
+}
+
+void CCLayerTreeHostImplProxy::setImplThread(bool value)
+{
+ fakeImplThread = value;
+}
+#endif // USE(THREADED_COMPOSITING)
+
+#endif // !NDEBUG
+
void CCLayerTreeHostImplProxy::requestFrameAndCommit(double frameBeginTime)
{
ASSERT(isMainThread());
@@ -163,7 +182,7 @@
void CCLayerTreeHostImplProxy::commitOnCCThread(CCLayerTreeHostCommitter* committer, CCCompletionEvent* completion)
{
- ASSERT(isCCThread());
+ ASSERT(isImplThread());
TRACE_EVENT("CCLayerTreeHostImplProxy::commitOnCCThread", this, 0);
m_layerTreeHostImpl->beginCommit();
{
@@ -178,7 +197,7 @@
void CCLayerTreeHostImplProxy::drawLayersOnCCThread()
{
TRACE_EVENT("CCLayerTreeHostImplProxy::drawLayersOnCCThread", this, 0);
- ASSERT(isCCThread());
+ ASSERT(isImplThread());
if (m_layerTreeHostImpl)
m_layerTreeHostImpl->drawLayers();
}
@@ -186,21 +205,21 @@
void CCLayerTreeHostImplProxy::setNeedsCommitAndRedrawOnCCThread()
{
TRACE_EVENT("CCLayerTreeHostImplProxy::setNeedsCommitAndRedrawOnCCThread", this, 0);
- ASSERT(isCCThread() && m_layerTreeHostImpl);
+ ASSERT(isImplThread() && m_layerTreeHostImpl);
m_layerTreeHostImpl->setNeedsCommitAndRedraw();
}
void CCLayerTreeHostImplProxy::setNeedsRedrawOnCCThread()
{
TRACE_EVENT("CCLayerTreeHostImplProxy::setNeedsRedrawOnCCThread", this, 0);
- ASSERT(isCCThread() && m_layerTreeHostImpl);
+ ASSERT(isImplThread() && m_layerTreeHostImpl);
m_layerTreeHostImpl->setNeedsRedraw();
}
void CCLayerTreeHostImplProxy::initImplOnCCThread(CCCompletionEvent* completion)
{
TRACE_EVENT("CCLayerTreeHostImplProxy::initImplOnCCThread", this, 0);
- ASSERT(isCCThread());
+ ASSERT(isImplThread());
m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this);
completion->signal();
}
@@ -208,7 +227,7 @@
void CCLayerTreeHostImplProxy::layerTreeHostClosedOnCCThread(CCCompletionEvent* completion)
{
TRACE_EVENT("CCLayerTreeHostImplProxy::layerTreeHostClosedOnCCThread", this, 0);
- ASSERT(isCCThread());
+ ASSERT(isImplThread());
m_layerTreeHostImpl.clear();
completion->signal();
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h (93345 => 93346)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h 2011-08-18 20:36:17 UTC (rev 93345)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h 2011-08-18 20:37:25 UTC (rev 93346)
@@ -51,15 +51,21 @@
virtual void postDrawLayersTaskOnCCThread();
virtual void requestFrameAndCommitOnCCThread(double frameBeginTime);
+#ifndef NDEBUG
+ static bool isMainThread();
+ static bool isImplThread();
+#if !USE(THREADED_COMPOSITING)
+ // Fake threaded compositing so we can catch incorrect usage.
+ static void setImplThread(bool);
+#endif
+#endif
+
protected:
explicit CCLayerTreeHostImplProxy(CCLayerTreeHost*);
virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl() = 0;
CCLayerTreeHost* host() const { return m_layerTreeHost; }
private:
- bool isMainThread() const;
- bool isCCThread() const;
-
// Called on CCMainThread
void requestFrameAndCommit(double frameBeginTime);
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp (93345 => 93346)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp 2011-08-18 20:36:17 UTC (rev 93345)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp 2011-08-18 20:37:25 UTC (rev 93346)
@@ -31,6 +31,7 @@
#include "GraphicsContext3D.h"
#include "LayerRendererChromium.h"
+#include "cc/CCLayerTreeHostImplProxy.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -47,6 +48,7 @@
void CCPluginLayerImpl::draw()
{
+ ASSERT(CCLayerTreeHostImplProxy::isImplThread());
ASSERT(layerRenderer());
const CCPluginLayerImpl::Program* program = layerRenderer()->pluginLayerProgram();
ASSERT(program && program->initialized());
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp (93345 => 93346)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp 2011-08-18 20:36:17 UTC (rev 93345)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp 2011-08-18 20:37:25 UTC (rev 93346)
@@ -30,7 +30,7 @@
#include "cc/CCTiledLayerImpl.h"
#include "LayerRendererChromium.h"
-
+#include "cc/CCLayerTreeHostImplProxy.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -49,6 +49,7 @@
void CCTiledLayerImpl::draw()
{
+ ASSERT(CCLayerTreeHostImplProxy::isImplThread());
const IntRect& layerRect = visibleLayerRect();
if (!layerRect.isEmpty()) {
GraphicsContext3D* context = layerRenderer()->context();
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp (93345 => 93346)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp 2011-08-18 20:36:17 UTC (rev 93345)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp 2011-08-18 20:37:25 UTC (rev 93346)
@@ -33,6 +33,7 @@
#include "LayerRendererChromium.h"
#include "NotImplemented.h"
#include "VideoLayerChromium.h"
+#include "cc/CCLayerTreeHostImplProxy.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -77,6 +78,8 @@
void CCVideoLayerImpl::draw()
{
+ ASSERT(CCLayerTreeHostImplProxy::isImplThread());
+
if (m_skipsDraw)
return;