WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Complete enough for initial review. Dont try running it.
bug-66807-20110824194408.patch (text/plain), 92.13 KB, created by
Nat Duca
on 2011-08-24 19:44:09 PDT
(
hide
)
Description:
Complete enough for initial review. Dont try running it.
Filename:
MIME Type:
Creator:
Nat Duca
Created:
2011-08-24 19:44:09 PDT
Size:
92.13 KB
patch
obsolete
>Subversion Revision: 93717 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index ad2f23d6577b5a310522ed6dc32b4398ad981061..3c5a7a1fa3e2144667e9bc0aa224d2b4e9955e2d 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,86 @@ >+2011-08-23 Nat Duca <nduca@chromium.org> >+ >+ [chromium] Introduce CCLayerTreeHostImplMainThreadProxy in order to move LayerRenderer to CCLayerTreeHostImpl >+ https://bugs.webkit.org/show_bug.cgi?id=66807 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebCore.gypi: >+ * platform/graphics/chromium/LayerRendererChromium.cpp: >+ (WebCore::LayerRendererChromium::initialize): >+ * platform/graphics/chromium/LayerRendererChromium.h: >+ (WebCore::LayerRendererCapabilities::LayerRendererCapabilities): >+ (WebCore::LayerRendererChromium::contextSupportsMapSub): >+ * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: >+ (WebCore::CCLayerTreeHost::initialize): >+ (WebCore::CCLayerTreeHost::~CCLayerTreeHost): >+ (WebCore::CCLayerTreeHost::createLayerTreeHostContext3D): >+ (WebCore::CCLayerTreeHost::createLayerTreeHostCommitter): >+ (WebCore::CCLayerTreeHost::didRecreateGraphicsContext): >+ (WebCore::CCLayerTreeHost::context): >+ (WebCore::CCLayerTreeHost::compositeAndReadback): >+ (WebCore::CCLayerTreeHost::finishAllRendering): >+ (WebCore::CCLayerTreeHost::setVisible): >+ (WebCore::CCLayerTreeHost::composite): >+ * platform/graphics/chromium/cc/CCLayerTreeHost.h: >+ * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp: >+ (WebCore::CCLayerTreeHostImpl::create): >+ (WebCore::CCLayerTreeHostImpl::CCLayerTreeHostImpl): >+ (WebCore::CCLayerTreeHostImpl::compositeImmediately): >+ (WebCore::CCLayerTreeHostImpl::compositeAndReadback): >+ (WebCore::CCLayerTreeHostImpl::drawLayersAndPresent): >+ (WebCore::CCLayerTreeHostImpl::drawLayers): >+ (WebCore::CCLayerTreeHostImpl::finishAllRendering): >+ (WebCore::CCLayerTreeHostImpl::isContextLost): >+ (WebCore::CCLayerTreeHostImpl::present): >+ (WebCore::CCLayerTreeHostImpl::initializeLayerRenderer): >+ (WebCore::CCLayerTreeHostImpl::initializeLayerRep): >+ * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h: >+ (WebCore::CCLayerTreeHostImpl::context): >+ (WebCore::CCLayerTreeHostImpl::layerRendererCapabilities): >+ * platform/graphics/chromium/cc/CCLayerTreeHostImplCCThreadProxy.cpp: Copied from Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp. >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::create): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::CCLayerTreeHostImplCCThreadProxy): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::start): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::~CCLayerTreeHostImplCCThreadProxy): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::isStarted): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::setNeedsCommitAndRedraw): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::setNeedsRedraw): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::stop): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::postDrawLayersTaskOnCCThread): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::requestFrameAndCommitOnCCThread): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::requestFrameAndCommit): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::commitOnCCThread): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::drawLayersOnCCThread): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::setNeedsCommitAndRedrawOnCCThread): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::setNeedsRedrawOnCCThread): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::initImplOnCCThread): >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::layerTreeHostClosedOnCCThread): >+ * platform/graphics/chromium/cc/CCLayerTreeHostImplCCThreadProxy.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h. >+ (WebCore::CCLayerTreeHostImplCCThreadProxy::host): >+ * platform/graphics/chromium/cc/CCLayerTreeHostImplMainThreadProxy.cpp: Added. >+ (WebCore::ScopedSetImplThread::ScopedSetImplThread): >+ (WebCore::ScopedSetImplThread::~ScopedSetImplThread): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::CCLayerTreeHostImplMainThreadProxy): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::start): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::~CCLayerTreeHostImplMainThreadProxy): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::compositeAndReadback): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::context): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::finishAllRendering): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::isStarted): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::initializeLayerRenderer): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::layerRendererCapabilities): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::setNeedsCommitAndRedraw): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::setNeedsRedraw): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::setVisible): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::stop): >+ (WebCore::CCLayerTreeHostImplMainThreadProxy::compositeImmediately): >+ * platform/graphics/chromium/cc/CCLayerTreeHostImplMainThreadProxy.h: Copied from Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h. >+ * platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp: >+ (WebCore::CCLayerTreeHostImplProxy::isImplThread): >+ (WebCore::CCLayerTreeHostImplProxy::setImplThread): >+ * platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h: >+ > 2011-08-24 Sam Weinig <sam@webkit.org> > > JSHTMLImageElement (and associated Node) is abandoned when image load is canceled >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index 9d7b0cc0ec3a930f66b99f537031e20c25398237..8cd803c1fd5dc8fe5765938e456a65ee7272a59e 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -3535,6 +3535,10 @@ > 'platform/graphics/chromium/cc/CCLayerTreeHostCommitter.h', > 'platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp', > 'platform/graphics/chromium/cc/CCLayerTreeHostImpl.h', >+ 'platform/graphics/chromium/cc/CCLayerTreeHostImplCCThreadProxy.cpp', >+ 'platform/graphics/chromium/cc/CCLayerTreeHostImplCCThreadProxy.h', >+ 'platform/graphics/chromium/cc/CCLayerTreeHostImplMainThreadProxy.cpp', >+ 'platform/graphics/chromium/cc/CCLayerTreeHostImplMainThreadProxy.h', > 'platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp', > 'platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h', > 'platform/graphics/chromium/cc/CCMainThread.cpp', >diff --git a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp >index 59c2cca1d92cd3aef63a4701e05bd1fbaacb84e7..781b90875805c9e65a49197567c1639166ccd20d 100644 >--- a/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp >@@ -120,6 +120,8 @@ bool ContentLayerChromium::drawsContent() const > > void ContentLayerChromium::createTextureUpdater(const CCLayerTreeHost* host) > { >+ ASSERT_NOT_REACHED(); >+#if 0 // FIXME BEFORE LANDING > #if !USE(THREADED_COMPOSITING) > #if USE(SKIA) > if (host->settings().acceleratePainting) { >@@ -129,7 +131,8 @@ void ContentLayerChromium::createTextureUpdater(const CCLayerTreeHost* host) > #endif // SKIA > #endif // !THREADED_COMPOSITING > >- m_textureUpdater = LayerTextureUpdaterBitmap::create(ContentLayerPainter::create(m_owner), host->contextSupportsMapSub()); >+ m_textureUpdater = LayerTextureUpdaterBitmap::create(ContentLayerPainter::create(m_owner), host->layerRendererCapabilities().usingMapSub); >+#endif > } > > } >diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp >index 23c8555f50be16e8f8bf3191f8ec57819d2cc5bc..71bc0b6b9db656bc460f4f8565494fa57ab50b8d 100644 >--- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp >@@ -181,7 +181,7 @@ bool ImageLayerChromium::drawsContent() const > > void ImageLayerChromium::createTextureUpdater(const CCLayerTreeHost* host) > { >- m_textureUpdater = ImageLayerTextureUpdater::create(host->contextSupportsMapSub()); >+ m_textureUpdater = ImageLayerTextureUpdater::create(host->layerRendererCapabilities().usingMapSub); > } > > } >diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp >index 9563eaa57f5673c8599d4dbaac88b92d9c494348..e06ba0d8b34e0f5351c54a772203d4328a463196 100644 >--- a/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp >@@ -96,6 +96,20 @@ void LayerChromium::cleanupResources() > { > } > >+void LayerChromium::setLayerRendererRecursive(LayerRendererChromium* renderer) >+{ >+ const Vector<RefPtr<LayerChromium> >& c = children(); >+ for (size_t i = 0; i < c.size(); ++i) >+ c[i]->setLayerRendererRecursive(renderer); >+ >+ if (maskLayer()) >+ maskLayer()->setLayerRendererRecursive(renderer); >+ if (replicaLayer()) >+ replicaLayer()->setLayerRendererRecursive(renderer); >+ >+ setLayerRenderer(renderer); >+} >+ > void LayerChromium::setLayerRenderer(LayerRendererChromium* renderer) > { > // If we're changing layer renderers then we need to free up any resources >diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.h b/Source/WebCore/platform/graphics/chromium/LayerChromium.h >index 58ed1b04096dac3e1bf6e7796af5906b8388cc85..fe2e4c71373be525d58c63b7ce0a81ea8e1e5c87 100644 >--- a/Source/WebCore/platform/graphics/chromium/LayerChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.h >@@ -153,6 +153,8 @@ public: > void setIsRootLayer(bool isRootLayer) { m_isRootLayer = isRootLayer; } > bool isRootLayer() const { return m_isRootLayer; } > >+ void setLayerRendererRecursive(LayerRendererChromium*); >+ > // Derived types must override this method if they need to react to a change > // in the LayerRendererChromium. > // FIXME, replace with CCLayerTreeHost. >diff --git a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp >index a6fb25803ae7070f115dc0c465073a8ec87a9a95..61c6d788d3058a205a6273770615ad229956b7c8 100644 >--- a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp >@@ -45,6 +45,7 @@ > #include "LayerTextureUpdaterCanvas.h" > #include "NonCompositedContentHost.h" > #include "NotImplemented.h" >+#include "PlatformColor.h" > #include "RenderSurfaceChromium.h" > #include "TextStream.h" > #include "TextureManager.h" >@@ -483,14 +484,18 @@ bool LayerRendererChromium::initialize() > // Limit the bytes allocated toward textures in the bitmap->texture cache. > static const size_t maxTextureCacheBytes = 50 * 1024 * 1024; > m_skiaContext->setTextureCacheLimits(maxTextureCacheCount, maxTextureCacheBytes); >+ m_capabilities.usingAcceleratedPainting = true; > } > #endif > > WebCore::Extensions3D* extensions = m_context->getExtensions(); >- m_contextSupportsMapSub = extensions->supports("GL_CHROMIUM_map_sub"); >- if (m_contextSupportsMapSub) >+ m_capabilities.usingMapSub = extensions->supports("GL_CHROMIUM_map_sub"); >+ if (m_capabilities.usingMapSub) > extensions->ensureEnabled("GL_CHROMIUM_map_sub"); > >+ m_capabilities.maxTextureSize = maxTextureSize(); >+ m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_context.get()); >+ > if (!initializeSharedObjects()) > return false; > >@@ -553,13 +558,6 @@ void LayerRendererChromium::updateLayers() > // RenderWidget. > m_headsUpDisplay->onFrameBegin(currentTime()); > >- // Recheck that we still have a root layer. This may become null if >- // compositing gets turned off during a paint operation. >- if (!rootLayer()) { >- m_rootCCLayerImpl.clear(); >- return; >- } >- > updateLayers(rootLayer()->platformLayer()); > } > >@@ -568,12 +566,6 @@ void LayerRendererChromium::drawLayers() > if (!rootLayer()) > return; > >- { >- TRACE_EVENT("LayerRendererChromium::synchronizeTrees", this, 0); >- m_rootCCLayerImpl = TreeSynchronizer::synchronizeTrees(rootLayer()->platformLayer(), m_rootCCLayerImpl.get()); >- } >- >- > m_renderSurfaceTextureManager->setMemoryLimitBytes(textureMemoryHighLimitBytes - m_contentsTextureManager->currentMemoryUseBytes()); > drawLayersInternal(); > >@@ -718,7 +710,7 @@ void LayerRendererChromium::drawLayersInternal() > return; > > TRACE_EVENT("LayerRendererChromium::drawLayers", this, 0); >- CCLayerImpl* rootDrawLayer = m_rootCCLayerImpl.get(); >+ CCLayerImpl* rootDrawLayer = rootLayerImpl(); > makeContextCurrent(); > > if (!rootDrawLayer->renderSurface()) >@@ -826,20 +818,6 @@ void LayerRendererChromium::present() > m_headsUpDisplay->onPresent(); > } > >-void LayerRendererChromium::setLayerRendererRecursive(LayerChromium* layer) >-{ >- const Vector<RefPtr<LayerChromium> >& children = layer->children(); >- for (size_t i = 0; i < children.size(); ++i) >- setLayerRendererRecursive(children[i].get()); >- >- if (layer->maskLayer()) >- setLayerRendererRecursive(layer->maskLayer()); >- if (layer->replicaLayer()) >- setLayerRendererRecursive(layer->replicaLayer()); >- >- layer->setLayerRenderer(this); >-} >- > void LayerRendererChromium::getFramebufferPixels(void *pixels, const IntRect& rect) > { > ASSERT(rect.maxX() <= viewportWidth() && rect.maxY() <= viewportHeight()); >@@ -934,7 +912,7 @@ void LayerRendererChromium::updateCompositorResources(LayerChromium* layer) > > ManagedTexture* LayerRendererChromium::getOffscreenLayerTexture() > { >- return settings().compositeOffscreen && m_rootCCLayerImpl ? m_rootCCLayerImpl->renderSurface()->contentsTexture() : 0; >+ return settings().compositeOffscreen && rootLayerImpl() ? rootLayerImpl()->renderSurface()->contentsTexture() : 0; > } > > void LayerRendererChromium::copyOffscreenTextureToDisplay() >@@ -1291,7 +1269,7 @@ void LayerRendererChromium::dumpRenderSurfaces(TextStream& ts, int indent, const > dumpRenderSurfaces(ts, indent, layer->children()[i].get()); > } > >-bool LayerRendererChromium::isCompositorContextLost() >+bool LayerRendererChromium::isContextLost() > { > return (m_context.get()->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR); > } >diff --git a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h >index 9558fa1e60a0407af19a7c8fb536182d288a13c4..c275934306dde5e7792dee95616b59fd64ee1698 100644 >--- a/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h >+++ b/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h >@@ -42,6 +42,7 @@ > #include "cc/CCHeadsUpDisplay.h" > #include "cc/CCLayerSorter.h" > #include "cc/CCLayerTreeHost.h" >+#include "cc/CCLayerTreeHostImpl.h" > #include "cc/CCPluginLayerImpl.h" > #include "cc/CCVideoLayerImpl.h" > #include <wtf/HashMap.h> >@@ -63,6 +64,7 @@ namespace WebCore { > > class CCHeadsUpDisplay; > class CCLayerImpl; >+class CCLayerTreeHost; // TODO: remove pointers to this > class CCLayerTreeHostCommitter; > class CCLayerTreeHostImpl; > class GeometryBinding; >@@ -77,6 +79,7 @@ public: > virtual ~LayerRendererChromium(); > > const CCSettings& settings() const { return m_owner->settings(); } >+ const LayerRendererCapabilities& capabilities() const { return m_capabilities; } > > CCLayerTreeHost* owner() { return m_owner; } > const CCLayerTreeHost* owner() const { return m_owner; } >@@ -84,14 +87,17 @@ public: > GraphicsLayer* rootLayer() { return m_owner->rootLayer(); } > const GraphicsLayer* rootLayer() const { return m_owner->rootLayer(); } > >+ CCLayerImpl* rootLayerImpl() { return m_ownerImpl->rootLayer(); } >+ const CCLayerImpl* rootLayerImpl() const { return m_ownerImpl->rootLayer(); } >+ > GraphicsContext3D* context(); >- bool contextSupportsMapSub() const { return m_contextSupportsMapSub; } >+ bool contextSupportsMapSub() const { return m_capabilities.usingMapSub; } > > #if USE(SKIA) > GrContext* skiaContext() { return m_skiaContext.get(); } > #endif > >- const IntSize& viewportSize() { return m_owner->viewportSize(); } >+ const IntSize& viewportSize() { return m_ownerImpl->viewportSize(); } > int viewportWidth() { return viewportSize().width(); } > int viewportHeight() { return viewportSize().height(); } > >@@ -143,22 +149,16 @@ public: > > String layerTreeAsText() const; > >- // Return true if the compositor context has an error. >- bool isCompositorContextLost(); >+ bool isContextLost(); > > void releaseTextures(); > >- void setLayerRendererRecursive(LayerChromium*); >- > GC3Denum bestTextureFormat(); > > typedef Vector<RefPtr<LayerChromium> > LayerList; > typedef Vector<RefPtr<CCLayerImpl> > CCLayerList; > > private: >- // FIXME: This needs to be moved to the CCLayerTreeHostImpl when that class exists. >- RefPtr<CCLayerImpl> m_rootCCLayerImpl; >- > LayerRendererChromium(CCLayerTreeHost*, PassRefPtr<GraphicsContext3D>); > bool initialize(); > >@@ -190,8 +190,11 @@ private: > bool initializeSharedObjects(); > void cleanupSharedObjects(); > >- // FIXME: Change this to CCLayerTreeHostImpl >+ // FIXME: Remove this > CCLayerTreeHost* m_owner; >+ CCLayerTreeHostImpl* m_ownerImpl; >+ >+ LayerRendererCapabilities m_capabilities; > > TransformationMatrix m_projectionMatrix; > TransformationMatrix m_windowMatrix; >@@ -232,8 +235,6 @@ private: > OwnPtr<GrContext> m_skiaContext; > #endif > >- bool m_contextSupportsMapSub; >- > CCRenderSurface* m_defaultRenderSurface; > > CCLayerSorter m_layerSorter; >diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp >index 3e102ec865695f83bb7081e3bff6191bbad9e2c3..a79ea12c4d74c191ec4d607ebfd48ad5e37df83a 100644 >--- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp >+++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp >@@ -141,7 +141,7 @@ void TiledLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) > > createTextureUpdater(host); > >- m_textureFormat = host->bestTextureFormat(); >+ m_textureFormat = host->layerRendererCapabilities().bestTextureFormat; > m_textureOrientation = textureUpdater()->orientation(); > m_sampledTexelFormat = textureUpdater()->sampledTexelFormat(m_textureFormat); > m_tiler = CCLayerTilingData::create( >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >index 97e742cc1828278c6b52e296b80de97b4aa1805a..58640e3b126084296ed3a7e5f2cbf2db2ca7a072 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp >@@ -30,10 +30,12 @@ > #include "LayerPainterChromium.h" > #include "LayerRendererChromium.h" > #include "NonCompositedContentHost.h" >-#include "PlatformColor.h" > #include "TraceEvent.h" > #include "cc/CCLayerTreeHostCommitter.h" > #include "cc/CCLayerTreeHostImpl.h" >+#include "cc/CCLayerTreeHostImplCCThreadProxy.h" >+#include "cc/CCLayerTreeHostImplMainThreadProxy.h" >+#include "cc/CCThread.h" > > namespace WebCore { > >@@ -46,10 +48,7 @@ PassRefPtr<CCLayerTreeHost> CCLayerTreeHost::create(CCLayerTreeHostClient* clien > } > > CCLayerTreeHost::CCLayerTreeHost(CCLayerTreeHostClient* client, const CCSettings& settings) >- : m_recreatingGraphicsContext(false) >- , m_maxTextureSize(0) >- , m_contextSupportsMapSub(false) >- , m_animating(false) >+ : m_animating(false) > , m_client(client) > , m_frameNumber(0) > , m_nonCompositedContentHost(NonCompositedContentHost::create(m_client->createRootLayerPainter())) >@@ -59,15 +58,23 @@ CCLayerTreeHost::CCLayerTreeHost(CCLayerTreeHostClient* client, const CCSettings > > bool CCLayerTreeHost::initialize() > { >- m_layerRenderer = createLayerRenderer(); >- if (!m_layerRenderer) >+#if USE(THREADED_COMPOSITING) >+ if (false) // TODO: make thread a runtime flag in CCSettings >+ m_proxy = CCLayerTreeHostImplCCThreadProxy::create(this); >+ else >+ m_proxy = CCLayerTreeHostImplMainThreadProxy::create(this); >+#else >+ m_proxy = CCLayerTreeHostImplMainThreadProxy::create(this); >+#endif >+ m_proxy->start(); >+ >+ // Create the renderer... >+ if (!m_proxy->initializeLayerRenderer(this)) > return false; > >- // FIXME: In the threaded case, these values will need to be initialized >- // by something other than m_layerRenderer. >- m_maxTextureSize = m_layerRenderer->maxTextureSize(); >- m_bestTextureFormat = PlatformColor::bestTextureFormat(m_layerRenderer->context()); >- m_contextSupportsMapSub = m_layerRenderer->contextSupportsMapSub(); >+ // Update m_settings based on capabilities that we got back from the renderer. >+ if (m_settings.acceleratePainting && !m_proxy->layerRendererCapabilities().usingAcceleratedPainting) >+ m_settings.acceleratePainting = false; > > m_rootLayer = GraphicsLayer::create(0); > #ifndef NDEBUG >@@ -77,12 +84,8 @@ bool CCLayerTreeHost::initialize() > > m_rootLayer->addChild(m_nonCompositedContentHost->graphicsLayer()); > >- >-#if USE(THREADED_COMPOSITING) >- m_proxy = CCLayerTreeHostImplProxy::create(this); >- ASSERT(m_proxy->isStarted()); >+ // We changed the root layer. Tell the proxy a commit is needed. > m_proxy->setNeedsCommitAndRedraw(); >-#endif > > return true; > } >@@ -90,10 +93,15 @@ bool CCLayerTreeHost::initialize() > CCLayerTreeHost::~CCLayerTreeHost() > { > TRACE_EVENT("CCLayerTreeHost::~CCLayerTreeHost", this, 0); >-#if USE(THREADED_COMPOSITING) > m_proxy->stop(); > m_proxy.clear(); >-#endif >+} >+ >+void CCLayerTreeHost::animateAndLayout(double frameBeginTime) >+{ >+ m_animating = true; >+ m_client->animateAndLayout(frameBeginTime); >+ m_animating = false; > } > > void CCLayerTreeHost::beginCommit() >@@ -105,47 +113,51 @@ void CCLayerTreeHost::commitComplete() > m_frameNumber++; > } > >-void CCLayerTreeHost::animateAndLayout(double frameBeginTime) >+PassOwnPtr<CCThread> CCLayerTreeHost::createCompositorThread() > { >- m_animating = true; >- m_client->animateAndLayout(frameBeginTime); >- m_animating = false; >+ return m_client->createCompositorThread(); >+} >+ >+PassRefPtr<GraphicsContext3D> CCLayerTreeHost::createLayerTreeHostContext3D() >+{ >+ return m_client->createLayerTreeHostContext3D(); > } > > PassOwnPtr<CCLayerTreeHostCommitter> CCLayerTreeHost::createLayerTreeHostCommitter() > { >- // FIXME: only called in threading case, fix when possible. >- return nullptr; >+ return CCLayerTreeHostCommitter::create(); > } > > PassOwnPtr<CCLayerTreeHostImpl> CCLayerTreeHost::createLayerTreeHostImpl(CCLayerTreeHostImplClient* client) > { >- RefPtr<LayerRendererChromium> renderer(m_layerRenderer); >- return CCLayerTreeHostImpl::create(client, renderer); >+ return CCLayerTreeHostImpl::create(client, m_settings); > } > >-GraphicsContext3D* CCLayerTreeHost::context() >+void CCLayerTreeHost::didRecreateGraphicsContext(bool success) > { >- return m_layerRenderer->context(); >+ m_client->didRecreateGraphicsContext(success); > } > >-void CCLayerTreeHost::compositeAndReadback(void *pixels, const IntRect& rect) >+#if !USE(THREADED_COMPOSITING) >+void CCLayerTreeHost::scheduleComposite() > { >-#if USE(THREADED_COMPOSITING) >- // FIXME: need to implement this. >-#else >- composite(false); >- m_layerRenderer->getFramebufferPixels(pixels, rect); >+ m_client->scheduleComposite(); >+} > #endif >+ >+GraphicsContext3D* CCLayerTreeHost::context() >+{ >+ return m_proxy->context(); >+} >+ >+bool CCLayerTreeHost::compositeAndReadback(void *pixels, const IntRect& rect) >+{ >+ return m_proxy->compositeAndReadback(pixels, rect); > } > > void CCLayerTreeHost::finishAllRendering() > { >-#if USE(THREADED_COMPOSITING) >- // FIXME: need to implement this. >-#else >- m_layerRenderer->finish(); >-#endif >+ m_proxy->finishAllRendering(); > } > > void CCLayerTreeHost::invalidateRootLayerRect(const IntRect& dirtyRect) >@@ -153,6 +165,11 @@ void CCLayerTreeHost::invalidateRootLayerRect(const IntRect& dirtyRect) > m_nonCompositedContentHost->invalidateRect(dirtyRect); > } > >+const LayerRendererCapabilities& CCLayerTreeHost::layerRendererCapabilities() const >+{ >+ return m_proxy->layerRendererCapabilities(); >+} >+ > void CCLayerTreeHost::setNeedsCommitAndRedraw() > { > #if USE(THREADED_COMPOSITING) >@@ -177,11 +194,8 @@ void CCLayerTreeHost::setRootLayer(GraphicsLayer* layer) > { > m_nonCompositedContentHost->graphicsLayer()->removeAllChildren(); > m_nonCompositedContentHost->invalidateEntireLayer(); >- if (layer) { >+ if (layer) > m_nonCompositedContentHost->graphicsLayer()->addChild(layer); >- layer->platformLayer()->setLayerRenderer(m_layerRenderer.get()); >- } >- > } > > void CCLayerTreeHost::setViewport(const IntSize& viewportSize, const IntSize& contentsSize, const IntPoint& scrollPosition) >@@ -192,106 +206,26 @@ void CCLayerTreeHost::setViewport(const IntSize& viewportSize, const IntSize& co > m_nonCompositedContentHost->setScrollPosition(scrollPosition); > m_nonCompositedContentHost->graphicsLayer()->setSize(contentsSize); > >- if (visibleRectChanged) { >+ if (visibleRectChanged) > m_nonCompositedContentHost->invalidateEntireLayer(); >- if (m_layerRenderer) >- m_layerRenderer->viewportChanged(); >- } > > setNeedsCommitAndRedraw(); > } > > void CCLayerTreeHost::setVisible(bool visible) > { >-#if !USE(THREADED_COMPOSITING) >- if (!visible) >- m_layerRenderer->releaseTextures(); >-#endif >+ m_proxy->setVisible(false); > } > >-PassRefPtr<LayerRendererChromium> CCLayerTreeHost::createLayerRenderer() >+void CCLayerTreeHost::loseCompositorContext() > { >- // GraphicsContext3D::create might fail and return 0, in that case fall back to software. >- RefPtr<GraphicsContext3D> context = m_client->createLayerTreeHostContext3D(); >- if (!context) >- return 0; >- >- // Actually create the renderer. >- RefPtr<LayerRendererChromium> layerRenderer = LayerRendererChromium::create(this, context); >- >- // If creation failed, and we had asked for accelerated painting, disable accelerated painting >- // and try creating the renderer again. >- if (m_settings.acceleratePainting && !layerRenderer) { >- m_settings.acceleratePainting = false; >- layerRenderer = LayerRendererChromium::create(this, context); >- } >- >- return layerRenderer; >+ m_proxy->loseCompositorContext(); > } > > #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) > { >- TRACE_EVENT("CCLayerTreeHost::composite", this, 0); >- >- if (m_recreatingGraphicsContext) { >- // reallocateRenderer will request a repaint whether or not it succeeded >- // in creating a new context. >- reallocateRenderer(); >- m_recreatingGraphicsContext = false; >- return; >- } >- >- // Do not composite if the compositor context is already lost. >- if (!m_layerRenderer->isCompositorContextLost()) { >- doComposite(); >- >- // Put result onscreen. >- m_layerRenderer->present(); >- } >- >- if (m_layerRenderer->isCompositorContextLost()) { >- // Trying to recover the context right here will not work if GPU process >- // died. This is because GpuChannelHost::OnErrorMessage will only be >- // called at the next iteration of the message loop, reverting our >- // recovery attempts here. Instead, we detach the root layer from the >- // renderer, recreate the renderer at the next message loop iteration >- // and request a repaint yet again. >- m_recreatingGraphicsContext = true; >- setNeedsCommitAndRedraw(); >- } >-} >- >-void CCLayerTreeHost::loseCompositorContext() >-{ >- m_recreatingGraphicsContext = true; >-} >- >-void CCLayerTreeHost::reallocateRenderer() >-{ >- RefPtr<LayerRendererChromium> layerRenderer = createLayerRenderer(); >- if (!layerRenderer) { >- m_client->didRecreateGraphicsContext(false); >- return; >- } >- >- layerRenderer->setLayerRendererRecursive(m_rootLayer->platformLayer()); >- m_layerRenderer = layerRenderer; >- >- m_client->didRecreateGraphicsContext(true); >+ static_cast<CCLayerTreeHostImplMainThreadProxy*>(m_proxy.get())->compositeImmediately(); > } > #endif // !USE(THREADED_COMPOSITING) > >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h >index fda7220f6a2ff559fd60c1ca9ffe5d69dcee3241..b8548f9fb46c0403d6d23ca1cada77854853ff81 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h >@@ -73,26 +73,49 @@ struct CCSettings { > bool showPlatformLayerTree; > }; > >-class CCLayerTreeHost : public RefCounted<CCLayerTreeHost> { >+// Provides information on an Impl's rendering capabilities back to the CCLayerTreeHost >+struct LayerRendererCapabilities { >+ LayerRendererCapabilities() >+ : bestTextureFormat(0) >+ , usingMapSub(false) >+ , usingAcceleratedPainting(false) >+ , maxTextureSize(0) { } >+ >+ GC3Denum bestTextureFormat; >+ bool usingMapSub; >+ bool usingAcceleratedPainting; >+ int maxTextureSize; >+}; >+ >+class CCLayerTreeHost : public RefCounted<CCLayerTreeHost>, CCLayerTreeHostImplProxyClient { > public: > static PassRefPtr<CCLayerTreeHost> create(CCLayerTreeHostClient*, const CCSettings&); > virtual ~CCLayerTreeHost(); > >+ // CCLayerTreeHostImplProxyClient implementation > virtual void animateAndLayout(double frameBeginTime); > virtual void beginCommit(); > virtual void commitComplete(); >- >+ virtual PassOwnPtr<CCThread> createCompositorThread(); >+ virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D(); > virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl(CCLayerTreeHostImplClient*); > virtual PassOwnPtr<CCLayerTreeHostCommitter> createLayerTreeHostCommitter(); >- >+ virtual void didRecreateGraphicsContext(bool success); >+#if !USE(THREADED_COMPOSITING) >+ virtual void scheduleComposite(); >+#endif > bool animating() const { return m_animating; } > void setAnimating(bool animating) { m_animating = animating; } // Can be removed when non-threaded scheduling moves inside. > > CCLayerTreeHostClient* client() { return m_client; } > >+#if !USE(THREADED_COMPOSITING) >+ void composite(bool finish); >+#endif >+ > GraphicsContext3D* context(); > >- void compositeAndReadback(void *pixels, const IntRect&); >+ bool compositeAndReadback(void *pixels, const IntRect&); > > void finishAllRendering(); > >@@ -100,6 +123,9 @@ public: > > void invalidateRootLayerRect(const IntRect& dirtyRect); > >+ const LayerRendererCapabilities& layerRendererCapabilities() const; >+ void loseCompositorContext(); >+ > void setNeedsCommitAndRedraw(); > void setNeedsRedraw(); > >@@ -115,21 +141,8 @@ public: > > void setVisible(bool); > >- // Temporary home for the non-threaded rendering path. >-#if !USE(THREADED_COMPOSITING) >- void composite(bool finish); >- >- void loseCompositorContext(); >- >- LayerRendererChromium* layerRenderer() const { return m_layerRenderer.get(); } >-#endif >- > NonCompositedContentHost* nonCompositedContentHost() const { return m_nonCompositedContentHost.get(); } > >- bool contextSupportsMapSub() const { return m_contextSupportsMapSub; } >- int maxTextureSize() const { return m_maxTextureSize; } >- GC3Denum bestTextureFormat() { return m_bestTextureFormat; } >- > protected: > CCLayerTreeHost(CCLayerTreeHostClient*, const CCSettings&); > >@@ -138,19 +151,6 @@ private: > > PassRefPtr<LayerRendererChromium> createLayerRenderer(); > >- // Temporary home for the non-threaded rendering path. >-#if !USE(THREADED_COMPOSITING) >- void doComposite(); >- void reallocateRenderer(); >- >- bool m_recreatingGraphicsContext; >- RefPtr<LayerRendererChromium> m_layerRenderer; >-#endif >- >- int m_maxTextureSize; >- GC3Denum m_bestTextureFormat; >- bool m_contextSupportsMapSub; >- > bool m_animating; > > CCLayerTreeHostClient* m_client; >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommitter.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommitter.cpp >index 72dd714be7e384c8ef9e10924ff5cd2058699bea..421df8c92976557892bcdb693bfd9d8e10225625 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommitter.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommitter.cpp >@@ -26,6 +26,11 @@ > > #include "cc/CCLayerTreeHostCommitter.h" > >+#include "GraphicsLayer.h" >+#include "LayerChromium.h" >+#include "TraceEvent.h" >+#include "TreeSynchronizer.h" >+#include "cc/CCLayerImpl.h" > #include "cc/CCLayerTreeHost.h" > #include "cc/CCLayerTreeHostImpl.h" > >@@ -38,7 +43,21 @@ PassOwnPtr<CCLayerTreeHostCommitter> CCLayerTreeHostCommitter::create() > > void CCLayerTreeHostCommitter::commit(CCLayerTreeHost* host, CCLayerTreeHostImpl* hostImpl) > { >+ TRACE_EVENT("CCLayerTreeHostCommitter::commit", this, 0); > hostImpl->setSourceFrameNumber(host->frameNumber()); >+ hostImpl->setViewport(host->viewportSize()); >+ >+ // If compositing is turned off during paint, >+ // this is where we'll notice it. >+ if (!host->rootLayer()) { >+ hostImpl->setRootLayer(0); >+ return; >+ } >+ >+ if (host->rootLayer()->platformLayer()->layerRenderer() != hostImpl->layerRenderer()) >+ host->rootLayer()->platformLayer()->setLayerRendererRecursive(hostImpl->layerRenderer()); >+ >+ hostImpl->setRootLayer(TreeSynchronizer::synchronizeTrees(host->rootLayer()->platformLayer(), hostImpl->rootLayer())); > } > > } >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommitter.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommitter.h >index bc318a4a714232d3184d2fed4ad809517583cc99..6e632154cc6defb316ef81c15adc43f35008fc8f 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommitter.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommitter.h >@@ -33,7 +33,6 @@ namespace WebCore { > class CCLayerTreeHost; > class CCLayerTreeHostImpl; > >-// FIXME: merge in TreeSynchronizer code into here > class CCLayerTreeHostCommitter { > WTF_MAKE_NONCOPYABLE(CCLayerTreeHostCommitter); > public: >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp >index 4e2d1b843c1832cfafa14354862cbfa1538669ae..4f0ff8568b9310068cbfbdad7c5e46e5a94fb0ab 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp >@@ -38,18 +38,16 @@ > > namespace WebCore { > >-PassOwnPtr<CCLayerTreeHostImpl> CCLayerTreeHostImpl::create(CCLayerTreeHostImplClient* client, PassRefPtr<LayerRendererChromium> renderer) >+PassOwnPtr<CCLayerTreeHostImpl> CCLayerTreeHostImpl::create(CCLayerTreeHostImplClient* client, const CCSettings& settings) > { >- return adoptPtr(new CCLayerTreeHostImpl(client, renderer)); >+ return adoptPtr(new CCLayerTreeHostImpl(client, settings)); > } > >-CCLayerTreeHostImpl::CCLayerTreeHostImpl(CCLayerTreeHostImplClient* client, PassRefPtr<LayerRendererChromium> renderer) >+CCLayerTreeHostImpl::CCLayerTreeHostImpl(CCLayerTreeHostImplClient* client, const CCSettings& settings) > : m_sourceFrameNumber(-1) > , m_frameNumber(0) > , m_client(client) >- , m_commitPending(false) >- , m_layerRenderer(renderer) >- , m_redrawPending(false) >+ , m_settings(settings) > { > } > >@@ -64,71 +62,107 @@ void CCLayerTreeHostImpl::beginCommit() > > void CCLayerTreeHostImpl::commitComplete() > { >- m_commitPending = false; >- setNeedsRedraw(); > } > >-void CCLayerTreeHostImpl::drawLayers() >+GraphicsContext3D* CCLayerTreeHostImpl::context() > { >- // If a commit is pending, do not draw. This is a temporary restriction that >- // is necessary because drawLayers is currently a blocking operation on the main thread. >- if (m_commitPending) >- return; >+ return m_layerRenderer ? m_layerRenderer->context() : 0; >+} > >+void CCLayerTreeHostImpl::drawLayers() >+{ > TRACE_EVENT("CCLayerTreeHostImpl::drawLayers", this, 0); >- ASSERT(m_redrawPending); >- m_redrawPending = false; >+ ASSERT(m_layerRenderer); >+ if (m_layerRenderer->owner()->rootLayer()) { >+ m_layerRenderer->updateLayers(); >+ m_layerRenderer->drawLayers(); >+ } > >- { >- TRACE_EVENT("CCLayerTreeHostImpl::drawLayersAndPresent", this, 0); >- CCCompletionEvent completion; >- bool contextLost; >- CCMainThread::postTask(createMainThreadTask(this, &CCLayerTreeHostImpl::drawLayersOnMainThread, AllowCrossThreadAccess(&completion), AllowCrossThreadAccess(&contextLost))); >- completion.wait(); >+ ++m_frameNumber; >+} > >- // FIXME: Send the "UpdateRect" message up to the RenderWidget [or moveplugin equivalents...] >+void CCLayerTreeHostImpl::finishAllRendering() >+{ >+ m_layerRenderer->finish(); >+} > >- // FIXME: handle context lost >- if (contextLost) >- FATAL("LayerRendererChromiumImpl does not handle context lost yet."); >- } >+bool CCLayerTreeHostImpl::isContextLost() >+{ >+ ASSERT(m_layerRenderer); >+ return m_layerRenderer->isContextLost(); >+} > >- ++m_frameNumber; >+const LayerRendererCapabilities& CCLayerTreeHostImpl::layerRendererCapabilities() const >+{ >+ return m_layerRenderer->capabilities(); > } > >-void CCLayerTreeHostImpl::setNeedsCommitAndRedraw() >+void CCLayerTreeHostImpl::present() > { >- TRACE_EVENT("CCLayerTreeHostImpl::setNeedsCommitAndRedraw", this, 0); >+ ASSERT(m_layerRenderer && !isContextLost()); >+ m_layerRenderer->present(); >+} > >- // FIXME: move the requestFrameAndCommit out from here once we add framerate throttling/animation >- double frameBeginTime = currentTime(); >- m_commitPending = true; >- m_client->requestFrameAndCommitOnCCThread(frameBeginTime); >+void CCLayerTreeHostImpl::readback(void* pixels, const IntRect& rect) >+{ >+ m_layerRenderer->getFramebufferPixels(pixels, rect); > } > >-void CCLayerTreeHostImpl::setNeedsRedraw() >+void CCLayerTreeHostImpl::setRootLayer(PassRefPtr<CCLayerImpl> layer) > { >- if (m_redrawPending || m_commitPending) >- return; >+ m_rootLayerImpl = layer; >+} > >- TRACE_EVENT("CCLayerTreeHostImpl::setNeedsRedraw", this, 0); >- m_redrawPending = true; >- m_client->postDrawLayersTaskOnCCThread(); >+void CCLayerTreeHostImpl::setVisible(bool visible) >+{ >+ if (m_layerRenderer) >+ m_layerRenderer->releaseTextures(); > } > >-void CCLayerTreeHostImpl::drawLayersOnMainThread(CCCompletionEvent* completion, bool* contextLost) >+bool CCLayerTreeHostImpl::initializeLayerRenderer(CCLayerTreeHost* implHack, PassRefPtr<GraphicsContext3D> context) > { >- ASSERT(isMainThread()); >+ if (!m_layerRenderer) { >+ // First time layerRenderer creation >+ m_layerRenderer = LayerRendererChromium::create(implHack, context); >+ >+ // If creation failed, and we had asked for accelerated painting, disable accelerated painting >+ // and try creating the renderer again. >+ if (!m_layerRenderer && m_settings.acceleratePainting) { >+ m_settings.acceleratePainting = false; >+ m_layerRenderer = LayerRendererChromium::create(implHack, context); >+ } >+ } else { >+ // LayerRenderer recreation... in the future, do a full delete-and-recreate. >+ RefPtr<LayerRendererChromium> layerRenderer; >+ layerRenderer = LayerRendererChromium::create(m_layerRenderer->owner(), context); >+ >+ // If creation failed, and we had asked for accelerated painting, disable accelerated painting >+ // and try creating the renderer again. >+ if (!layerRenderer && m_settings.acceleratePainting) { >+ m_settings.acceleratePainting = false; >+ layerRenderer = LayerRendererChromium::create(m_layerRenderer->owner(), context); >+ } >+ >+ if (layerRenderer) >+ m_layerRenderer->rootLayer()->platformLayer()->setLayerRendererRecursive(layerRenderer.get()); >+ m_layerRenderer = layerRenderer; >+ } >+ return !!m_layerRenderer; >+} > >- if (m_layerRenderer->owner()->rootLayer()) { >- m_layerRenderer->drawLayers(); >- m_layerRenderer->present(); >+// FIXME: move all this code to LTH >+void CCLayerTreeHostImpl::updateLayers() >+{ >+ if (m_layerRenderer) >+ m_layerRenderer->updateLayers(); >+} > >- GraphicsContext3D* context = m_layerRenderer->context(); >- *contextLost = context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR; >- } else >- *contextLost = false; >- completion->signal(); >+void CCLayerTreeHostImpl::setViewport(const IntSize& viewportSize) >+{ >+ bool changed = viewportSize != m_viewportSize; >+ m_viewportSize = viewportSize; >+ if (changed) >+ m_layerRenderer->viewportChanged(); > } > > } >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h >index c411ccc73554f1dd32bcce2e15e48dbecac4a88e..9f576b0c7df2640df2dc405dae6cdbda6972b9da 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h >@@ -25,20 +25,20 @@ > #ifndef CCLayerTreeHostImpl_h > #define CCLayerTreeHostImpl_h > >-#include "cc/CCThread.h" >+#include "cc/CCLayerTreeHost.h" > #include <wtf/RefPtr.h> >-#include <wtf/ThreadSafeRefCounted.h> > > namespace WebCore { > > class CCCompletionEvent; >+class CCLayerImpl; > class LayerRendererChromium; >+struct LayerRendererCapabilities; > > // Provides scheduling infrastructure for a CCLayerTreeHostImpl > class CCLayerTreeHostImplClient { > public: >- virtual void postDrawLayersTaskOnCCThread() = 0; >- virtual void requestFrameAndCommitOnCCThread(double frameBeginTime) = 0; >+ virtual void setNeedsRedrawOnCCThread() = 0; > > protected: > virtual ~CCLayerTreeHostImplClient() { } >@@ -48,33 +48,52 @@ protected: > class CCLayerTreeHostImpl { > WTF_MAKE_NONCOPYABLE(CCLayerTreeHostImpl); > public: >- static PassOwnPtr<CCLayerTreeHostImpl> create(CCLayerTreeHostImplClient*, PassRefPtr<LayerRendererChromium>); >+ static PassOwnPtr<CCLayerTreeHostImpl> create(CCLayerTreeHostImplClient*, const CCSettings&); > virtual ~CCLayerTreeHostImpl(); > > virtual void beginCommit(); > virtual void commitComplete(); > >+ GraphicsContext3D* context(); >+ > void drawLayers(); > >+ void finishAllRendering(); > int frameNumber() const { return m_frameNumber; } > >- void setNeedsRedraw(); >- void setNeedsCommitAndRedraw(); >+ bool initializeLayerRenderer(CCLayerTreeHost* ownerHack, PassRefPtr<GraphicsContext3D>); >+ bool isContextLost(); >+ LayerRendererChromium* layerRenderer() { return m_layerRenderer.get(); } >+ const LayerRendererCapabilities& layerRendererCapabilities() const; >+ >+ void present(); >+ >+ void readback(void* pixels, const IntRect&); >+ >+ CCLayerImpl* rootLayer() const { return m_rootLayerImpl.get(); } >+ void setRootLayer(PassRefPtr<CCLayerImpl>); >+ >+ void setVisible(bool); > > int sourceFrameNumber() const { return m_sourceFrameNumber; } > void setSourceFrameNumber(int frameNumber) { m_sourceFrameNumber = frameNumber; } > >+ void updateLayers(); >+ >+ void setViewport(const IntSize& viewportSize); >+ const IntSize& viewportSize() const { return m_viewportSize; } >+ > protected: >- CCLayerTreeHostImpl(CCLayerTreeHostImplClient*, PassRefPtr<LayerRendererChromium>); >- void drawLayersOnMainThread(CCCompletionEvent*, bool* contextLost); >+ CCLayerTreeHostImpl(CCLayerTreeHostImplClient*, const CCSettings&); > int m_sourceFrameNumber; > int m_frameNumber; > > private: > CCLayerTreeHostImplClient* m_client; >- bool m_commitPending; > RefPtr<LayerRendererChromium> m_layerRenderer; >- bool m_redrawPending; >+ RefPtr<CCLayerImpl> m_rootLayerImpl; >+ CCSettings m_settings; >+ IntSize m_viewportSize; > }; > > }; >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplCCThreadProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplCCThreadProxy.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..9ad8a1b64e2d5e5aa85fc26f0a67c3c015943060 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplCCThreadProxy.cpp >@@ -0,0 +1,284 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#include "cc/CCLayerTreeHostImplCCThreadProxy.h" >+ >+#include "GraphicsContext3D.h" >+#include "TraceEvent.h" >+#include "cc/CCLayerTreeHost.h" >+#include "cc/CCMainThreadTask.h" >+#include "cc/CCThreadTask.h" >+#include <wtf/MainThread.h> >+ >+using namespace WTF; >+ >+namespace WebCore { >+ >+namespace { >+CCThread* ccThread; >+int numProxies = 0; >+} >+ >+PassOwnPtr<CCLayerTreeHostImplProxy> CCLayerTreeHostImplCCThreadProxy::create(CCLayerTreeHost* client) >+{ >+ return adoptPtr(new CCLayerTreeHostImplCCThreadProxy(client)); >+} >+ >+CCLayerTreeHostImplCCThreadProxy::CCLayerTreeHostImplCCThreadProxy(CCLayerTreeHost* client) >+ : m_commitPending(false) >+ , m_client(client) >+{ >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::CCLayerTreeHostImplCCThreadProxy", this, 0); >+ ASSERT(isMainThread()); >+ numProxies++; >+ if (!ccThread) { >+ ccThread = m_client->createCompositorThread().leakPtr(); >+ CCLayerTreeHostImplProxy::setImplThread(ccThread->threadID()); >+ } >+} >+ >+ >+CCLayerTreeHostImplCCThreadProxy::~CCLayerTreeHostImplCCThreadProxy() >+{ >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::~CCLayerTreeHostImplCCThreadProxy", this, 0); >+ ASSERT(isMainThread()); >+ ASSERT(!m_layerTreeHostImpl && !m_client); // make sure stop() got called. >+ >+ numProxies--; >+ if (!numProxies) { >+ delete ccThread; >+ ccThread = 0; >+ } >+} >+ >+bool CCLayerTreeHostImplCCThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect) >+{ >+ ASSERT_NOT_REACHED(); >+ return false; >+} >+ >+GraphicsContext3D* CCLayerTreeHostImplCCThreadProxy::context() >+{ >+ ASSERT_NOT_REACHED(); >+ return 0; >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::finishAllRendering() >+{ >+ ASSERT_NOT_REACHED(); >+} >+ >+bool CCLayerTreeHostImplCCThreadProxy::isStarted() const >+{ >+ return m_layerTreeHostImpl; >+} >+ >+bool CCLayerTreeHostImplCCThreadProxy::initializeLayerRenderer(CCLayerTreeHost* ownerHack) >+{ >+ RefPtr<GraphicsContext3D> context = m_client->createLayerTreeHostContext3D(); >+ if (!context) >+ return false; >+ ASSERT(context->hasOneRef()); >+ >+ // Leak the context pointer so we can transfer ownership of it to the other side... >+ GraphicsContext3D* contextPtr = context.release().leakRef(); >+ ASSERT(contextPtr->hasOneRef()); >+ >+ // Make a blocking call to initializeLayerRendererOnCCThread. The results of that call >+ // are pushed into the ok and caps local varaibles. >+ CCCompletionEvent completion; >+ bool ok; >+ LayerRendererCapabilities capabilities; >+ ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplCCThreadProxy::initializeLayerRendererOnCCThread, >+ AllowCrossThreadAccess(ownerHack), AllowCrossThreadAccess(contextPtr), >+ AllowCrossThreadAccess(&completion), AllowCrossThreadAccess(&ok), AllowCrossThreadAccess(&capabilities))); >+ completion.wait(); >+ >+ if (ok) >+ m_layerRendererCapabilitiesMainThreadCopy = capabilities; >+ return ok; >+} >+ >+const LayerRendererCapabilities& CCLayerTreeHostImplCCThreadProxy::layerRendererCapabilities() const >+{ >+ return m_layerRendererCapabilitiesMainThreadCopy; >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::loseCompositorContext() >+{ >+ ASSERT_NOT_REACHED(); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::setNeedsCommitAndRedraw() >+{ >+ ASSERT(isMainThread()); >+ if (m_commitPending) >+ return; >+ >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::setNeedsCommitAndRedraw", this, 0); >+ m_commitPending = true; >+ ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplCCThreadProxy::setNeedsCommitAndRedrawOnCCThread)); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::setNeedsRedraw() >+{ >+ ASSERT(isMainThread()); >+ ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplCCThreadProxy::setNeedsRedrawOnCCThread)); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::setVisible(bool visible) >+{ >+ ASSERT(isMainThread()); >+ ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplCCThreadProxy::setVisibleOnCCThread, visible)); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::start() >+{ >+ // Create LayerTreeHostImpl. >+ CCCompletionEvent completion; >+ ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplCCThreadProxy::initializeImplOnCCThread, AllowCrossThreadAccess(&completion))); >+ completion.wait(); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::stop() >+{ >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::stop", this, 0); >+ ASSERT(isMainThread()); >+ // Synchronously deletes the impl. >+ CCCompletionEvent completion; >+ ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplCCThreadProxy::layerTreeHostClosedOnCCThread, AllowCrossThreadAccess(&completion))); >+ completion.wait(); >+ >+ ASSERT(!m_layerTreeHostImpl); // verify that the impl deleted. >+ m_client = 0; >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::setNeedsRedrawOnCCThread() >+{ >+ ASSERT_NOT_REACHED(); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::beginFrameAndCommitOnCCThread() >+{ >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::beginFrameAndCommitOnCCThread", this, 0); >+ ASSERT(isImplThread()); >+ ASSERT_NOT_REACHED(); >+ // TODO: call beginFrameAndCommit on main thread >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::beginFrameAndCommit(double frameBeginTime) >+{ >+ ASSERT(isMainThread()); >+ if (!m_client) >+ return; >+ >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::requestFrameAndCommit", this, 0); >+ { >+ TRACE_EVENT("CCLayerTreeHost::animateAndLayout", this, 0); >+ m_client->animateAndLayout(frameBeginTime); >+ } >+ >+ m_commitPending = false; >+ >+ OwnPtr<CCLayerTreeHostCommitter> committer = m_client->createLayerTreeHostCommitter(); >+ m_client->beginCommit(); >+ >+ // Blocking call to CCLayerTreeHostImplCCThreadProxy::performCommit >+ CCCompletionEvent completion; >+ ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplCCThreadProxy::commitOnCCThread, AllowCrossThreadAccess(committer.get()), AllowCrossThreadAccess(&completion))); >+ completion.wait(); >+ >+ committer.clear(); >+ m_client->commitComplete(); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::commitOnCCThread(CCLayerTreeHostCommitter* committer, CCCompletionEvent* completion) >+{ >+ ASSERT(isImplThread()); >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::commitOnCCThread", this, 0); >+ m_layerTreeHostImpl->beginCommit(); >+ { >+ TRACE_EVENT("CCLayerTreeHost::commit", this, 0); >+ /// xxx get rid of this static cast somehow... >+ CCLayerTreeHost* host = static_cast<CCLayerTreeHost*>(m_client); >+ committer->commit(host, m_layerTreeHostImpl.get()); >+ } >+ completion->signal(); >+ >+ m_layerTreeHostImpl->commitComplete(); >+ setNeedsRedrawOnCCThread(); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::drawLayersOnCCThread() >+{ >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::drawLayersOnCCThread", this, 0); >+ ASSERT(isImplThread()); >+ if (m_layerTreeHostImpl) >+ m_layerTreeHostImpl->drawLayers(); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::setNeedsCommitAndRedrawOnCCThread() >+{ >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::setNeedsCommitAndRedrawOnCCThread", this, 0); >+ ASSERT(isImplThread() && m_layerTreeHostImpl); >+ ASSERT_NOT_REACHED(); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::setVisibleOnCCThread(bool visible) >+{ >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::setNeedsRedrawOnCCThread", this, 0); >+ ASSERT(isImplThread() && m_layerTreeHostImpl); >+ m_layerTreeHostImpl->setVisible(visible); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::initializeImplOnCCThread(CCCompletionEvent* completion) >+{ >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::initializeImplOnCCThread", this, 0); >+ ASSERT(isImplThread()); >+ m_layerTreeHostImpl = m_client->createLayerTreeHostImpl(this); >+ completion->signal(); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::initializeLayerRendererOnCCThread(CCLayerTreeHost* ownerHack, GraphicsContext3D* contextPtr, CCCompletionEvent* completion, bool* ok, LayerRendererCapabilities* capabilities) >+{ >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::initializeLayerRendererOnCCThread", this, 0); >+ ASSERT(isImplThread()); >+ RefPtr<GraphicsContext3D> context(adoptRef(contextPtr)); >+ *ok = m_layerTreeHostImpl->initializeLayerRenderer(ownerHack, context); >+ if (*ok) >+ *capabilities = m_layerTreeHostImpl->layerRendererCapabilities(); >+ completion->signal(); >+} >+ >+void CCLayerTreeHostImplCCThreadProxy::layerTreeHostClosedOnCCThread(CCCompletionEvent* completion) >+{ >+ TRACE_EVENT("CCLayerTreeHostImplCCThreadProxy::layerTreeHostClosedOnCCThread", this, 0); >+ ASSERT(isImplThread()); >+ m_layerTreeHostImpl.clear(); >+ completion->signal(); >+} >+ >+} >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplCCThreadProxy.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplCCThreadProxy.h >new file mode 100644 >index 0000000000000000000000000000000000000000..8a9ef973fe4e0d5c96db0a1228ac3feab3e78198 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplCCThreadProxy.h >@@ -0,0 +1,90 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef CCLayerTreeHostImplCCThreadProxy_h >+#define CCLayerTreeHostImplCCThreadProxy_h >+ >+#include "cc/CCCompletionEvent.h" >+#include "cc/CCLayerTreeHostImpl.h" >+#include "cc/CCLayerTreeHostImplProxy.h" >+#include <wtf/OwnPtr.h> >+ >+namespace WebCore { >+ >+class CCLayerTreeHost; >+class CCLayerTreeHostCommitter; >+ >+class CCLayerTreeHostImplCCThreadProxy : public CCLayerTreeHostImplProxy, CCLayerTreeHostImplClient { >+public: >+ static PassOwnPtr<CCLayerTreeHostImplProxy> create(CCLayerTreeHost* client); >+ >+ virtual ~CCLayerTreeHostImplCCThreadProxy(); >+ >+ // CCLayerTreeHostImplProxy implementation >+ virtual bool compositeAndReadback(void *pixels, const IntRect&); >+ virtual GraphicsContext3D* context(); >+ virtual void finishAllRendering(); >+ virtual bool isStarted() const; >+ virtual bool initializeLayerRenderer(CCLayerTreeHost* ownerHack); >+ virtual const LayerRendererCapabilities& layerRendererCapabilities() const; >+ virtual void loseCompositorContext(); >+ virtual void setNeedsCommitAndRedraw(); >+ virtual void setNeedsRedraw(); >+ virtual void setVisible(bool); >+ virtual void start(); >+ virtual void stop(); >+ >+ // CCLayerTreeHostImplCient -- called on CCThread >+ virtual void setNeedsRedrawOnCCThread(); >+ >+private: >+ explicit CCLayerTreeHostImplCCThreadProxy(CCLayerTreeHost*); >+ >+ // Called on CCMainThread >+ void beginFrameAndCommit(double frameBeginTime); >+ >+ // Called on CCThread >+ void beginFrameAndCommitOnCCThread(); >+ void commitOnCCThread(CCLayerTreeHostCommitter*, CCCompletionEvent*); >+ void drawLayersOnCCThread(); >+ void initializeImplOnCCThread(CCCompletionEvent*); >+ void initializeLayerRendererOnCCThread(CCLayerTreeHost*, GraphicsContext3D*, CCCompletionEvent*, bool* ok, LayerRendererCapabilities*); >+ void setNeedsCommitAndRedrawOnCCThread(); >+ void setVisibleOnCCThread(bool); >+ void layerTreeHostClosedOnCCThread(CCCompletionEvent*); >+ >+ // Used on main-thread only. >+ bool m_commitPending; >+ >+ // Accessed on main thread only. >+ CCLayerTreeHost* m_client; >+ LayerRendererCapabilities m_layerRendererCapabilitiesMainThreadCopy; >+ >+ // Used on the CCThread, but checked on main thread during initialization/shutdown. >+ OwnPtr<CCLayerTreeHostImpl> m_layerTreeHostImpl; >+}; >+ >+} >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplMainThreadProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplMainThreadProxy.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..2b9b9f0302799e979cf99bc3b7db65bdad2e04e2 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplMainThreadProxy.cpp >@@ -0,0 +1,258 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#include "cc/CCLayerTreeHostImplMainThreadProxy.h" >+ >+#include "GraphicsContext3D.h" >+#include "TraceEvent.h" >+#include "cc/CCLayerTreeHost.h" >+#include "cc/CCMainThreadTask.h" >+#include <wtf/CurrentTime.h> >+ >+using namespace WTF; >+ >+namespace WebCore { >+ >+class ScopedSetImplThread { >+public: >+ ScopedSetImplThread() >+ { >+#ifndef NDEBUG >+ CCLayerTreeHostImplProxy::setImplThread(true); >+#endif >+ } >+ ~ScopedSetImplThread() >+ { >+#ifndef NDEBUG >+ CCLayerTreeHostImplProxy::setImplThread(false); >+#endif >+ } >+}; >+ >+PassOwnPtr<CCLayerTreeHostImplProxy> CCLayerTreeHostImplMainThreadProxy::create(CCLayerTreeHost* client) >+{ >+ return adoptPtr(new CCLayerTreeHostImplMainThreadProxy(client)); >+} >+ >+CCLayerTreeHostImplMainThreadProxy::CCLayerTreeHostImplMainThreadProxy(CCLayerTreeHost* client) >+ : m_client(client) >+ , m_commitPending(false) >+ , m_recreatingGraphicsContext(false) >+{ >+ TRACE_EVENT("CCLayerTreeHostImplMainThreadProxy::CCLayerTreeHostImplMainThreadProxy", this, 0); >+ ASSERT(isMainThread()); >+} >+ >+ >+void CCLayerTreeHostImplMainThreadProxy::start() >+{ >+ ScopedSetImplThread impl; >+ m_layerTreeHostImpl = m_client->createLayerTreeHostImpl(this); >+} >+ >+CCLayerTreeHostImplMainThreadProxy::~CCLayerTreeHostImplMainThreadProxy() >+{ >+ TRACE_EVENT("CCLayerTreeHostImplMainThreadProxy::~CCLayerTreeHostImplMainThreadProxy", this, 0); >+ ASSERT(isMainThread()); >+ ASSERT(!m_layerTreeHostImpl && !m_client); // make sure stop() got called. >+} >+ >+bool CCLayerTreeHostImplMainThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect) >+{ >+ ASSERT(isMainThread()); >+ ScopedSetImplThread impl; >+ if (!doComposite(false)) >+ return false; >+ >+ m_layerTreeHostImpl->readback(pixels, rect); >+ >+ if (m_layerTreeHostImpl->isContextLost()) >+ return false; >+ >+ return true; >+} >+ >+GraphicsContext3D* CCLayerTreeHostImplMainThreadProxy::context() >+{ >+ ASSERT(isMainThread()); >+ ScopedSetImplThread impl; >+ return m_layerTreeHostImpl->context(); >+} >+ >+void CCLayerTreeHostImplMainThreadProxy::finishAllRendering() >+{ >+ ASSERT(isMainThread()); >+ ScopedSetImplThread impl; >+ m_layerTreeHostImpl->finishAllRendering(); >+} >+ >+bool CCLayerTreeHostImplMainThreadProxy::isStarted() const >+{ >+ ASSERT(isMainThread()); >+ return m_layerTreeHostImpl; >+} >+ >+bool CCLayerTreeHostImplMainThreadProxy::initializeLayerRenderer(CCLayerTreeHost* ownerHack) >+{ >+ RefPtr<GraphicsContext3D> context = m_client->createLayerTreeHostContext3D(); >+ if (!context) >+ return false; >+ ASSERT(context->hasOneRef()); >+ >+ { >+ ScopedSetImplThread impl; >+ return m_layerTreeHostImpl->initializeLayerRenderer(ownerHack, context); >+ } >+} >+ >+const LayerRendererCapabilities& CCLayerTreeHostImplMainThreadProxy::layerRendererCapabilities() const >+{ >+ ScopedSetImplThread impl; >+ return m_layerTreeHostImpl->layerRendererCapabilities(); >+} >+ >+void CCLayerTreeHostImplMainThreadProxy::loseCompositorContext() >+{ >+ m_recreatingGraphicsContext = true; >+} >+ >+void CCLayerTreeHostImplMainThreadProxy::setNeedsCommitAndRedraw() >+{ >+ ASSERT(isMainThread()); >+ if (m_commitPending) >+ return; >+#if !USE(THREADED_COMPOSITING) >+ m_client->scheduleComposite(); >+#else >+ TRACE_EVENT("CCLayerTreeHostImplMainThreadProxy::setNeedsCommitAndRedraw", this, 0); >+ m_commitPending = true; >+ CCMainThread::postTask(createMainThreadTask(this, &CCLayerTreeHostImplMainThreadProxy::compositeIfNeeded)); >+#endif >+} >+ >+void CCLayerTreeHostImplMainThreadProxy::setNeedsRedraw() >+{ >+ // We don't optimize this case in the main threaded case. >+ setNeedsCommitAndRedraw(); >+} >+ >+void CCLayerTreeHostImplMainThreadProxy::setVisible(bool visible) >+{ >+ ScopedSetImplThread impl; >+ m_layerTreeHostImpl->setVisible(visible); >+} >+ >+void CCLayerTreeHostImplMainThreadProxy::stop() >+{ >+ TRACE_EVENT("CCLayerTreeHostImplMainThreadProxy::stop", this, 0); >+ ASSERT(isMainThread()); >+ { >+ ScopedSetImplThread impl; >+ m_layerTreeHostImpl.clear(); >+ } >+ m_client = 0; >+} >+ >+void CCLayerTreeHostImplMainThreadProxy::setNeedsRedrawOnCCThread() >+{ >+ ASSERT(isImplThread()); >+ if (m_commitPending) >+ return; >+#if !USE(THREADED_COMPOSITING) >+ m_client->scheduleComposite(); >+#else >+ TRACE_EVENT("CCLayerTreeHostImplMainThreadProxy::setNeedsCommitAndRedraw", this, 0); >+ m_commitPending = true; >+ CCMainThread::postTask(createMainThreadTask(this, &CCLayerTreeHostImplMainThreadProxy::compositeIfNeeded)); >+#endif >+} >+ >+// Called by the legacy scheduling path (e.g. where render_widget does the scheduling) >+void CCLayerTreeHostImplMainThreadProxy::compositeImmediately() >+{ >+ doComposite(true); >+} >+ >+void CCLayerTreeHostImplMainThreadProxy::compositeIfNeeded() >+{ >+ if (m_commitPending) { >+ // Update >+ double frameBeginTime = currentTime(); >+ m_client->animateAndLayout(frameBeginTime); >+ m_layerTreeHostImpl->updateLayers(); >+ >+ // Commit >+ OwnPtr<CCLayerTreeHostCommitter> committer = m_client->createLayerTreeHostCommitter(); >+ m_client->beginCommit(); >+ { >+ ScopedSetImplThread impl; >+ m_layerTreeHostImpl->beginCommit(); >+ committer->commit(m_client, m_layerTreeHostImpl.get()); >+ m_layerTreeHostImpl->commitComplete(); >+ } >+ committer.clear(); >+ m_client->commitComplete(); >+ >+ // Draw >+ doComposite(true); >+ } >+} >+ >+bool CCLayerTreeHostImplMainThreadProxy::doComposite(bool presentResult) >+{ >+ if (m_recreatingGraphicsContext) { >+ RefPtr<GraphicsContext3D> context = m_client->createLayerTreeHostContext3D(); >+ ASSERT(context->hasOneRef()); >+ bool ok = !m_layerTreeHostImpl->initializeLayerRenderer(0, context); >+ m_client->didRecreateGraphicsContext(ok); >+ m_recreatingGraphicsContext = false; >+ setNeedsCommitAndRedraw(); >+ return false; >+ } >+ >+ { >+ ScopedSetImplThread impl; >+ m_layerTreeHostImpl->drawLayers(); >+ if (m_layerTreeHostImpl->isContextLost()) { >+ // Trying to recover the context right here will not work if GPU process >+ // died. This is because GpuChannelHost::OnErrorMessage will only be >+ // called at the next iteration of the message loop, reverting our >+ // recovery attempts here. Instead, we detach the root layer from the >+ // renderer, recreate the renderer at the next message loop iteration >+ // and request a repaint yet again. >+ m_recreatingGraphicsContext = true; >+ setNeedsCommitAndRedraw(); >+ return false; >+ } >+ >+ if (presentResult) >+ m_layerTreeHostImpl->present(); >+ } >+ >+ return true; >+} >+ >+} >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplMainThreadProxy.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplMainThreadProxy.h >new file mode 100644 >index 0000000000000000000000000000000000000000..7cfabe96057cce10d25093fafa9cac4b511152df >--- /dev/null >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplMainThreadProxy.h >@@ -0,0 +1,82 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED >+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY >+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES >+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; >+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON >+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef CCLayerTreeHostImplMainThreadProxy_h >+#define CCLayerTreeHostImplMainThreadProxy_h >+ >+#include "cc/CCCompletionEvent.h" >+#include "cc/CCLayerTreeHostImpl.h" >+#include "cc/CCLayerTreeHostImplProxy.h" >+#include <wtf/OwnPtr.h> >+ >+namespace WebCore { >+ >+class CCLayerTreeHost; >+class CCLayerTreeHostCommitter; >+ >+class CCLayerTreeHostImplMainThreadProxy : public CCLayerTreeHostImplProxy, CCLayerTreeHostImplClient { >+public: >+ static PassOwnPtr<CCLayerTreeHostImplProxy> create(CCLayerTreeHost*); >+ virtual ~CCLayerTreeHostImplMainThreadProxy(); >+ >+ // CCLayerTreeHostImplProxy implementation >+ virtual bool compositeAndReadback(void *pixels, const IntRect&); >+ virtual GraphicsContext3D* context(); >+ virtual void finishAllRendering(); >+ virtual bool isStarted() const; >+ virtual bool initializeLayerRenderer(CCLayerTreeHost* ownerHack); >+ virtual const LayerRendererCapabilities& layerRendererCapabilities() const; >+ virtual void loseCompositorContext(); >+ virtual void setNeedsCommitAndRedraw(); >+ virtual void setNeedsRedraw(); >+ virtual void setVisible(bool); >+ virtual void start(); >+ virtual void stop(); >+ >+ // CCLayerTreeHostImplCient -- called on CCThread >+ virtual void setNeedsRedrawOnCCThread(); >+ >+ // Special case functions. >+#if !USE(THREADED_COMPOSITING) >+ void compositeImmediately(); >+#endif >+ >+private: >+ explicit CCLayerTreeHostImplMainThreadProxy(CCLayerTreeHost*); >+ void compositeIfNeeded(); >+ bool doComposite(bool presentResult); >+ >+ // Accessed on main thread only. >+ CCLayerTreeHost* m_client; >+ >+ // Used on the CCThread, but checked on main thread during initialization/shutdown. >+ OwnPtr<CCLayerTreeHostImpl> m_layerTreeHostImpl; >+ >+ bool m_commitPending; >+ bool m_recreatingGraphicsContext; >+}; >+ >+} >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp >index a669288564596d878267661d3f9461ebfb662e98..5011b244ff384a828f6556482d4b8b4f9e23a794 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.cpp >@@ -36,200 +36,32 @@ using namespace WTF; > > namespace WebCore { > >-namespace { >-CCThread* ccThread; >-int numProxies = 0; >-} >- >-CCLayerTreeHostImplProxy::CCLayerTreeHostImplProxy(CCLayerTreeHost* layerTreeHost) >- : m_commitPending(false) >- , m_layerTreeHost(layerTreeHost) >-{ >- TRACE_EVENT("CCLayerTreeHostImplProxy::CCLayerTreeHostImplProxy", this, 0); >- ASSERT(isMainThread()); >- numProxies++; >- if (!ccThread) >- ccThread = layerTreeHost->client()->createCompositorThread().leakPtr(); >-} >- >- >-void CCLayerTreeHostImplProxy::start() >-{ >- // Create LayerTreeHostImpl. >- CCCompletionEvent completion; >- ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplProxy::initImplOnCCThread, AllowCrossThreadAccess(&completion))); >- completion.wait(); >-} >- >-CCLayerTreeHostImplProxy::~CCLayerTreeHostImplProxy() >-{ >- TRACE_EVENT("CCLayerTreeHostImplProxy::~CCLayerTreeHostImplProxy", this, 0); >- ASSERT(isMainThread()); >- ASSERT(!m_layerTreeHostImpl && !m_layerTreeHost); // make sure stop() got called. >- >- numProxies--; >- if (!numProxies) { >- delete ccThread; >- ccThread = 0; >- } >-} >- >-bool CCLayerTreeHostImplProxy::isStarted() const >-{ >- return m_layerTreeHostImpl; >-} >- >-void CCLayerTreeHostImplProxy::setNeedsCommitAndRedraw() >-{ >- ASSERT(isMainThread()); >- if (m_commitPending) >- return; >- >- TRACE_EVENT("CCLayerTreeHostImplProxy::setNeedsCommitAndRedraw", this, 0); >- m_commitPending = true; >- ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplProxy::setNeedsCommitAndRedrawOnCCThread)); >-} >- >-void CCLayerTreeHostImplProxy::setNeedsRedraw() >-{ >- ASSERT(isMainThread()); >- ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplProxy::setNeedsRedrawOnCCThread)); >-} >- >-void CCLayerTreeHostImplProxy::stop() >-{ >- TRACE_EVENT("CCLayerTreeHostImplProxy::stop", this, 0); >- ASSERT(isMainThread()); >- // Synchronously deletes the impl. >- CCCompletionEvent completion; >- ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplProxy::layerTreeHostClosedOnCCThread, AllowCrossThreadAccess(&completion))); >- completion.wait(); >- >- ASSERT(!m_layerTreeHostImpl); // verify that the impl deleted. >- m_layerTreeHost = 0; >-} >- >-void CCLayerTreeHostImplProxy::postDrawLayersTaskOnCCThread() >-{ >- ASSERT(isImplThread()); >- if (m_layerTreeHostImpl) >- ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplProxy::drawLayersOnCCThread)); >-} >- >-void CCLayerTreeHostImplProxy::requestFrameAndCommitOnCCThread(double frameBeginTime) >-{ >- TRACE_EVENT("CCLayerTreeHostImplProxy::requestFrameAndCommitOnCCThread", this, 0); >- ASSERT(isImplThread()); >- if (m_layerTreeHostImpl) >- CCMainThread::postTask(createMainThreadTask(this, &CCLayerTreeHostImplProxy::requestFrameAndCommit, frameBeginTime)); >-} >- > #ifndef NDEBUG > bool CCLayerTreeHostImplProxy::isMainThread() > { > return ::isMainThread(); > } > >-#if USE(THREADED_COMPOSITING) >-bool CCLayerTreeHostImplProxy::isImplThread() >-{ >- return currentThread() == ccThread->threadID(); >-} >-#else > namespace { > bool fakeImplThread = false; >+static WTF::ThreadIdentifier implThreadID; > } > > bool CCLayerTreeHostImplProxy::isImplThread() > { >- return fakeImplThread; >+ return fakeImplThread || currentThread() == implThreadID; > } > > void CCLayerTreeHostImplProxy::setImplThread(bool value) > { > fakeImplThread = value; > } >-#endif // USE(THREADED_COMPOSITING) >- >-#endif // !NDEBUG >- >-void CCLayerTreeHostImplProxy::requestFrameAndCommit(double frameBeginTime) >-{ >- ASSERT(isMainThread()); >- if (!m_layerTreeHost) >- return; >- >- TRACE_EVENT("CCLayerTreeHostImplProxy::requestFrameAndCommit", this, 0); >- { >- TRACE_EVENT("CCLayerTreeHost::animateAndLayout", this, 0); >- m_layerTreeHost->animateAndLayout(frameBeginTime); >- } >- >- m_commitPending = false; >- >- OwnPtr<CCLayerTreeHostCommitter> committer = m_layerTreeHost->createLayerTreeHostCommitter(); >- m_layerTreeHost->beginCommit(); >- >- // Blocking call to CCLayerTreeHostImplProxy::performCommit >- CCCompletionEvent completion; >- ccThread->postTask(createCCThreadTask(this, &CCLayerTreeHostImplProxy::commitOnCCThread, AllowCrossThreadAccess(committer.get()), AllowCrossThreadAccess(&completion))); >- completion.wait(); >- >- committer.clear(); >- >- m_layerTreeHost->commitComplete(); >-} > >-void CCLayerTreeHostImplProxy::commitOnCCThread(CCLayerTreeHostCommitter* committer, CCCompletionEvent* completion) >+void CCLayerTreeHostImplProxy::setImplThread(WTF::ThreadIdentifier value) > { >- ASSERT(isImplThread()); >- TRACE_EVENT("CCLayerTreeHostImplProxy::commitOnCCThread", this, 0); >- m_layerTreeHostImpl->beginCommit(); >- { >- TRACE_EVENT("CCLayerTreeHost::commit", this, 0); >- committer->commit(m_layerTreeHost, m_layerTreeHostImpl.get()); >- } >- completion->signal(); >- >- m_layerTreeHostImpl->commitComplete(); >-} >- >-void CCLayerTreeHostImplProxy::drawLayersOnCCThread() >-{ >- TRACE_EVENT("CCLayerTreeHostImplProxy::drawLayersOnCCThread", this, 0); >- ASSERT(isImplThread()); >- if (m_layerTreeHostImpl) >- m_layerTreeHostImpl->drawLayers(); >-} >- >-void CCLayerTreeHostImplProxy::setNeedsCommitAndRedrawOnCCThread() >-{ >- TRACE_EVENT("CCLayerTreeHostImplProxy::setNeedsCommitAndRedrawOnCCThread", this, 0); >- ASSERT(isImplThread() && m_layerTreeHostImpl); >- m_layerTreeHostImpl->setNeedsCommitAndRedraw(); >-} >- >-void CCLayerTreeHostImplProxy::setNeedsRedrawOnCCThread() >-{ >- TRACE_EVENT("CCLayerTreeHostImplProxy::setNeedsRedrawOnCCThread", this, 0); >- ASSERT(isImplThread() && m_layerTreeHostImpl); >- m_layerTreeHostImpl->setNeedsRedraw(); >-} >- >-void CCLayerTreeHostImplProxy::initImplOnCCThread(CCCompletionEvent* completion) >-{ >- TRACE_EVENT("CCLayerTreeHostImplProxy::initImplOnCCThread", this, 0); >- ASSERT(isImplThread()); >- m_layerTreeHostImpl = m_layerTreeHost->createLayerTreeHostImpl(this); >- completion->signal(); >+ implThreadID = value; > } > >-void CCLayerTreeHostImplProxy::layerTreeHostClosedOnCCThread(CCCompletionEvent* completion) >-{ >- TRACE_EVENT("CCLayerTreeHostImplProxy::layerTreeHostClosedOnCCThread", this, 0); >- ASSERT(isImplThread()); >- m_layerTreeHostImpl.clear(); >- completion->signal(); >-} >+#endif // !NDEBUG > > } >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h >index d0207e561762ac1ddf9dd878378d546356c787ba..5067832959fd27722df108b1845bd76ae78cd7aa 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImplProxy.h >@@ -25,66 +25,79 @@ > #ifndef CCLayerTreeHostImplProxy_h > #define CCLayerTreeHostImplProxy_h > >-#include "cc/CCCompletionEvent.h" >-#include "cc/CCLayerTreeHostImpl.h" >-#include <wtf/OwnPtr.h> >+#include "IntRect.h" >+#include <wtf/Noncopyable.h> >+#include <wtf/PassOwnPtr.h> >+#include <wtf/PassRefPtr.h> >+#include <wtf/Threading.h> > > namespace WebCore { > >+class CCThread; > class CCLayerTreeHost; >+class CCLayerTreeHostImpl; >+class CCLayerTreeHostImplClient; > class CCLayerTreeHostCommitter; >+class GraphicsContext3D; >+struct LayerRendererCapabilities; > >-class CCLayerTreeHostImplProxy : public CCLayerTreeHostImplClient { >+class CCLayerTreeHostImplProxyClient { >+public: >+ virtual ~CCLayerTreeHostImplProxyClient() { } >+ virtual void animateAndLayout(double frameBeginTime) = 0; >+ virtual void beginCommit() = 0; >+ virtual void commitComplete() = 0; >+ virtual PassOwnPtr<CCThread> createCompositorThread() = 0; >+ virtual PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D() = 0; >+ virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl(CCLayerTreeHostImplClient*) = 0; >+ virtual PassOwnPtr<CCLayerTreeHostCommitter> createLayerTreeHostCommitter() = 0; >+ virtual void didRecreateGraphicsContext(bool success) = 0; >+#if !USE(THREADED_COMPOSITING) >+ virtual void scheduleComposite() = 0; >+#endif >+}; >+ >+class CCLayerTreeHostImplProxy { > WTF_MAKE_NONCOPYABLE(CCLayerTreeHostImplProxy); > public: >- virtual ~CCLayerTreeHostImplProxy(); >+ virtual ~CCLayerTreeHostImplProxy() { } >+ >+ virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0; >+ >+ virtual GraphicsContext3D* context() = 0; // Temporary hack until the scheduling inversion is completed. >+ >+ virtual void finishAllRendering() = 0; > >- bool isStarted() const; >+ virtual bool isStarted() const = 0; > >- void setNeedsCommitAndRedraw(); >- void setNeedsRedraw(); >+ // The ownerHack argument is to allow introducing the ImplProxy subclasses >+ // without also trying to change LayerRendererChromium to point at >+ // CCLayerTreeHostImpl. >+ virtual bool initializeLayerRenderer(CCLayerTreeHost* ownerHack) = 0; > >- void start(); // Must be called before using the proxy. >- void stop(); // Must be called before deleting the proxy. >+ virtual const LayerRendererCapabilities& layerRendererCapabilities() const = 0; > >- // CCLayerTreeHostImplCient -- called on CCThread >- virtual void postDrawLayersTaskOnCCThread(); >- virtual void requestFrameAndCommitOnCCThread(double frameBeginTime); >+ // Testing hook >+ virtual void loseCompositorContext() = 0; >+ >+ virtual void setNeedsCommitAndRedraw() = 0; >+ virtual void setNeedsRedraw() = 0; >+ >+ virtual void setVisible(bool) = 0; >+ >+ virtual void start() = 0; // Must be called before using the proxy. >+ virtual void stop() = 0; // Must be called before deleting the proxy. > > #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: >- // Called on CCMainThread >- void requestFrameAndCommit(double frameBeginTime); >- >- // Called on CCThread >- void commitOnCCThread(CCLayerTreeHostCommitter*, CCCompletionEvent*); >- void drawLayersOnCCThread(); >- void initImplOnCCThread(CCCompletionEvent*); >- void setNeedsCommitAndRedrawOnCCThread(); >- void setNeedsRedrawOnCCThread(); >- void layerTreeHostClosedOnCCThread(CCCompletionEvent*); >- >- // Used on main-thread only. >- bool m_commitPending; >- >- // Accessed on main thread only. >- CCLayerTreeHost* m_layerTreeHost; >- >- // Used on the CCThread, but checked on main thread during initialization/shutdown. >- OwnPtr<CCLayerTreeHostImpl> m_layerTreeHostImpl; >+ CCLayerTreeHostImplProxy() { } >+ friend class ScopedSetImplThread; >+ static void setImplThread(bool); >+ static void setImplThread(WTF::ThreadIdentifier value); > }; > > } >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCMainThreadTask.h b/Source/WebCore/platform/graphics/chromium/cc/CCMainThreadTask.h >index fac6e643f05a18bbbaad57b29bbc03a6280eac8a..4c33baa07add357739ddb51761e847b74e51c334 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCMainThreadTask.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCMainThreadTask.h >@@ -158,6 +158,88 @@ private: > P3 m_parameter3; > }; > >+ >+template<typename T, typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4> >+class MainThreadTask4 : public CCMainThread::Task { >+public: >+ typedef void (T::*Method)(MP1, MP2, MP3, MP4); >+ typedef MainThreadTask4<T, P1, MP1, P2, MP2, P3, MP3, P4, MP4> MainThreadTaskImpl; >+ typedef typename CrossThreadTaskTraits<P1>::ParamType Param1; >+ typedef typename CrossThreadTaskTraits<P2>::ParamType Param2; >+ typedef typename CrossThreadTaskTraits<P3>::ParamType Param3; >+ typedef typename CrossThreadTaskTraits<P4>::ParamType Param4; >+ >+ static PassOwnPtr<MainThreadTaskImpl> create(T* instance, Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4) >+ { >+ return adoptPtr(new MainThreadTaskImpl(instance, method, parameter1, parameter2, parameter3, parameter4)); >+ } >+ >+private: >+ MainThreadTask4(T* instance, Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4) >+ : CCMainThread::Task(instance) >+ , m_method(method) >+ , m_parameter1(parameter1) >+ , m_parameter2(parameter2) >+ , m_parameter3(parameter3) >+ , m_parameter4(parameter4) >+ { >+ } >+ >+ virtual void performTask() >+ { >+ (*static_cast<T*>(instance()).*m_method)(m_parameter1, m_parameter2, m_parameter3, m_parameter4); >+ } >+ >+private: >+ Method m_method; >+ P1 m_parameter1; >+ P2 m_parameter2; >+ P3 m_parameter3; >+ P4 m_parameter4; >+}; >+ >+template<typename T, typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5> >+class MainThreadTask5 : public CCMainThread::Task { >+public: >+ typedef void (T::*Method)(MP1, MP2, MP3, MP4, MP5); >+ typedef MainThreadTask5<T, P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5> MainThreadTaskImpl; >+ typedef typename CrossThreadTaskTraits<P1>::ParamType Param1; >+ typedef typename CrossThreadTaskTraits<P2>::ParamType Param2; >+ typedef typename CrossThreadTaskTraits<P3>::ParamType Param3; >+ typedef typename CrossThreadTaskTraits<P4>::ParamType Param4; >+ typedef typename CrossThreadTaskTraits<P5>::ParamType Param5; >+ >+ static PassOwnPtr<MainThreadTaskImpl> create(T* instance, Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4, Param5 parameter5) >+ { >+ return adoptPtr(new MainThreadTaskImpl(instance, method, parameter1, parameter2, parameter3, parameter4, parameter5)); >+ } >+ >+private: >+ MainThreadTask5(T* instance, Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4, Param5 parameter5) >+ : CCMainThread::Task(instance) >+ , m_method(method) >+ , m_parameter1(parameter1) >+ , m_parameter2(parameter2) >+ , m_parameter3(parameter3) >+ , m_parameter4(parameter4) >+ , m_parameter5(parameter5) >+ { >+ } >+ >+ virtual void performTask() >+ { >+ (*static_cast<T*>(instance()).*m_method)(m_parameter1, m_parameter2, m_parameter3, m_parameter4, m_parameter5); >+ } >+ >+private: >+ Method m_method; >+ P1 m_parameter1; >+ P2 m_parameter2; >+ P3 m_parameter3; >+ P4 m_parameter4; >+ P5 m_parameter5; >+}; >+ > template<typename T> > PassOwnPtr<CCMainThread::Task> createMainThreadTask( > T* const callee, >@@ -215,6 +297,46 @@ PassOwnPtr<CCMainThread::Task> createMainThreadTask( > CrossThreadCopier<P3>::copy(parameter3)); > } > >+template<typename T, typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4> >+PassOwnPtr<CCMainThread::Task> createMainThreadTask( >+ T* const callee, >+ void (T::*method)(MP1, MP2, MP3, MP4), >+ const P1& parameter1, >+ const P2& parameter2, >+ const P3& parameter3, >+ const P4& parameter4) >+{ >+ return MainThreadTask4<T, typename CrossThreadCopier<P1>::Type, MP1, typename CrossThreadCopier<P2>::Type, MP2, typename CrossThreadCopier<P3>::Type, MP3, typename CrossThreadCopier<P4>::Type, MP4>::create( >+ callee, >+ method, >+ CrossThreadCopier<P1>::copy(parameter1), >+ CrossThreadCopier<P2>::copy(parameter2), >+ CrossThreadCopier<P3>::copy(parameter3), >+ CrossThreadCopier<P4>::copy(parameter4)); >+ >+} >+ >+template<typename T, typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5> >+PassOwnPtr<CCMainThread::Task> createMainThreadTask( >+ T* const callee, >+ void (T::*method)(MP1, MP2, MP3, MP4, MP5), >+ const P1& parameter1, >+ const P2& parameter2, >+ const P3& parameter3, >+ const P4& parameter4, >+ const P5& parameter5) >+{ >+ return MainThreadTask5<T, typename CrossThreadCopier<P1>::Type, MP1, typename CrossThreadCopier<P2>::Type, MP2, typename CrossThreadCopier<P3>::Type, MP3, typename CrossThreadCopier<P4>::Type, MP4, typename CrossThreadCopier<P5>::Type, MP5>::create( >+ callee, >+ method, >+ CrossThreadCopier<P1>::copy(parameter1), >+ CrossThreadCopier<P2>::copy(parameter2), >+ CrossThreadCopier<P3>::copy(parameter3), >+ CrossThreadCopier<P4>::copy(parameter4), >+ CrossThreadCopier<P5>::copy(parameter5)); >+ >+} >+ > } // namespace WebCore > >-#endif // CCMainThreadTask_h >+#endif // MainThreadTask_h >diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCThreadTask.h b/Source/WebCore/platform/graphics/chromium/cc/CCThreadTask.h >index 91c58e5d25b7bb286e216c4e068cbe109578f183..d8de4ab0346988769fbe2674fd323610c45d720c 100644 >--- a/Source/WebCore/platform/graphics/chromium/cc/CCThreadTask.h >+++ b/Source/WebCore/platform/graphics/chromium/cc/CCThreadTask.h >@@ -198,6 +198,48 @@ private: > P4 m_parameter4; > }; > >+template<typename T, typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5> >+class CCThreadTask5 : public CCThread::Task { >+public: >+ typedef void (T::*Method)(MP1, MP2, MP3, MP4, MP5); >+ typedef CCThreadTask5<T, P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5> CCThreadTaskImpl; >+ typedef typename CrossThreadTaskTraits<P1>::ParamType Param1; >+ typedef typename CrossThreadTaskTraits<P2>::ParamType Param2; >+ typedef typename CrossThreadTaskTraits<P3>::ParamType Param3; >+ typedef typename CrossThreadTaskTraits<P4>::ParamType Param4; >+ typedef typename CrossThreadTaskTraits<P5>::ParamType Param5; >+ >+ static PassOwnPtr<CCThreadTaskImpl> create(T* instance, Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4, Param5 parameter5) >+ { >+ return adoptPtr(new CCThreadTaskImpl(instance, method, parameter1, parameter2, parameter3, parameter4, parameter5)); >+ } >+ >+private: >+ CCThreadTask5(T* instance, Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4, Param5 parameter5) >+ : CCThread::Task(instance) >+ , m_method(method) >+ , m_parameter1(parameter1) >+ , m_parameter2(parameter2) >+ , m_parameter3(parameter3) >+ , m_parameter4(parameter4) >+ , m_parameter5(parameter5) >+ { >+ } >+ >+ virtual void performTask() >+ { >+ (*static_cast<T*>(instance()).*m_method)(m_parameter1, m_parameter2, m_parameter3, m_parameter4, m_parameter5); >+ } >+ >+private: >+ Method m_method; >+ P1 m_parameter1; >+ P2 m_parameter2; >+ P3 m_parameter3; >+ P4 m_parameter4; >+ P5 m_parameter5; >+}; >+ > template<typename T> > PassOwnPtr<CCThread::Task> createCCThreadTask( > T* const callee, >@@ -274,6 +316,27 @@ PassOwnPtr<CCThread::Task> createCCThreadTask( > > } > >+template<typename T, typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5> >+PassOwnPtr<CCThread::Task> createCCThreadTask( >+ T* const callee, >+ void (T::*method)(MP1, MP2, MP3, MP4, MP5), >+ const P1& parameter1, >+ const P2& parameter2, >+ const P3& parameter3, >+ const P4& parameter4, >+ const P5& parameter5) >+{ >+ return CCThreadTask5<T, typename CrossThreadCopier<P1>::Type, MP1, typename CrossThreadCopier<P2>::Type, MP2, typename CrossThreadCopier<P3>::Type, MP3, typename CrossThreadCopier<P4>::Type, MP4, typename CrossThreadCopier<P5>::Type, MP5>::create( >+ callee, >+ method, >+ CrossThreadCopier<P1>::copy(parameter1), >+ CrossThreadCopier<P2>::copy(parameter2), >+ CrossThreadCopier<P3>::copy(parameter3), >+ CrossThreadCopier<P4>::copy(parameter4), >+ CrossThreadCopier<P5>::copy(parameter5)); >+ >+} >+ > } // namespace WebCore > > #endif // CCThreadTask_h >diff --git a/Source/WebKit/chromium/tests/CCThreadTaskTest.cpp b/Source/WebKit/chromium/tests/CCThreadTaskTest.cpp >index 1c5f87725266b088f6866746c8d3a1f963b577c2..d9943e713a20a4d7b09041a4eccf77d90b33b36b 100644 >--- a/Source/WebKit/chromium/tests/CCThreadTaskTest.cpp >+++ b/Source/WebKit/chromium/tests/CCThreadTaskTest.cpp >@@ -41,6 +41,7 @@ public: > MOCK_METHOD2(method2, void(int a1, int a2)); > MOCK_METHOD3(method3, void(int a1, int a2, int a3)); > MOCK_METHOD4(method4, void(int a1, int a2, int a3, int a4)); >+ MOCK_METHOD5(method5, void(int a1, int a2, int a3, int a4, int a5)); > }; > > TEST(CCThreadTaskTest, runnableMethods) >@@ -51,12 +52,14 @@ TEST(CCThreadTaskTest, runnableMethods) > EXPECT_CALL(mock, method2(9, 8)).Times(1); > EXPECT_CALL(mock, method3(9, 8, 7)).Times(1); > EXPECT_CALL(mock, method4(9, 8, 7, 6)).Times(1); >+ EXPECT_CALL(mock, method5(9, 8, 7, 6, 5)).Times(1); > > createCCThreadTask(&mock, &Mock::method0)->performTask(); > createCCThreadTask(&mock, &Mock::method1, 9)->performTask(); > createCCThreadTask(&mock, &Mock::method2, 9, 8)->performTask(); > createCCThreadTask(&mock, &Mock::method3, 9, 8, 7)->performTask(); > createCCThreadTask(&mock, &Mock::method4, 9, 8, 7, 6)->performTask(); >+ createCCThreadTask(&mock, &Mock::method5, 9, 8, 7, 6, 5)->performTask(); > } > > } // namespace
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 66807
:
104906
|
104965
|
105123
|
105197
|
105271
|
105385
|
105505
|
105524
|
105536
|
105537
|
105589
|
105853
|
105871
|
105998