[chromium] Defer makeContextCurrent in compositor until first frame
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Feb 2012 23:18:56 +0000 (23:18 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Feb 2012 23:18:56 +0000 (23:18 +0000)
commitcabe8d72d368c824bb381e020b97bd47d4466cde
tree89ddb4f1c35799b64f40ccd3c3ccba619e170d6c
parentb77450a236c6004dec15c69ed1feaf189691c4c3
[chromium] Defer makeContextCurrent in compositor until first frame
https://bugs.webkit.org/show_bug.cgi?id=77269

Reviewed by Kenneth Russell.

Source/WebCore:

There are situations where we need to instantiate a compositor, but can't call makeContextCurrent() until some
initialization work completes on another thread that we cannot block for. This defers the first
makeContextCurrent() call until we need to produce the first frame at which point we know the call can succeed,
assuming that the scheduler does the right thing.

This is accomplished by splitting up proxy initialization into two pieces:
*) initializeContext() which attempts to instantiate a GraphicsContext3D. This can fail if we can't make a
context at all, in which case we abort completely and return NULL from CCLayerTreeHost::create().

*) initializeLayerRenderer() which uses the previously-created context to instantiate our compositor objects and
    grab our renderer capabilities. This can fail if the context is not usable for compositing, which we report
    to the client as a lost context event.

Internally this introduces a new state to the CCLayerTreeHostImpl where it has a context but does not yet have a
LayerRendererChromium, which has fairly minimal impact. One other change is that we don't instantiate the
TextureManagers until we have the renderer capabilities, but this isn't necessary until we want to start
painting so it doesn't have any impact outside of some overly intrustive unit tests.

* platform/graphics/chromium/ContentLayerChromium.cpp:
(WebCore::ContentLayerChromium::paintContentsIfDirty):
(WebCore::ContentLayerChromium::createTextureUpdater):
* platform/graphics/chromium/ContentLayerChromium.h:
(ContentLayerChromium):
* platform/graphics/chromium/ImageLayerChromium.cpp:
(WebCore::ImageLayerChromium::paintContentsIfDirty):
* platform/graphics/chromium/ImageLayerChromium.h:
(ImageLayerChromium):
* platform/graphics/chromium/TiledLayerChromium.cpp:
* platform/graphics/chromium/TiledLayerChromium.h:
(WebCore::TiledLayerChromium::setSampledTexelFormat):
(TiledLayerChromium):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::CCLayerTreeHost):
(WebCore::CCLayerTreeHost::initialize):
(WebCore::CCLayerTreeHost::initializeLayerRenderer):
(WebCore):
(WebCore::CCLayerTreeHost::beginCommitOnImplThread):
(WebCore::CCLayerTreeHost::compositeAndReadback):
(WebCore::CCLayerTreeHost::finishAllRendering):
(WebCore::CCLayerTreeHost::setViewportSize):
(WebCore::CCLayerTreeHost::setVisible):
(WebCore::CCLayerTreeHost::updateLayers):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(CCLayerTreeHost):
():
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::isContextLost):
* platform/graphics/chromium/cc/CCProxy.h:
(CCProxy):
* platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
(WebCore::CCSingleThreadProxy::CCSingleThreadProxy):
(WebCore::CCSingleThreadProxy::compositeAndReadback):
(WebCore::CCSingleThreadProxy::initializeContext):
(WebCore::CCSingleThreadProxy::initializeLayerRenderer):
(WebCore::CCSingleThreadProxy::layerRendererCapabilities):
* platform/graphics/chromium/cc/CCSingleThreadProxy.h:
(CCSingleThreadProxy):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::CCThreadProxy):
(WebCore::CCThreadProxy::compositeAndReadback):
(WebCore::CCThreadProxy::initializeContext):
(WebCore):
(WebCore::CCThreadProxy::initializeLayerRenderer):
(WebCore::CCThreadProxy::layerRendererCapabilities):
(WebCore::CCThreadProxy::initializeImplOnImplThread):
(WebCore::CCThreadProxy::initializeContextOnImplThread):
(WebCore::CCThreadProxy::initializeLayerRendererOnImplThread):
* platform/graphics/chromium/cc/CCThreadProxy.h:
(CCThreadProxy):

Source/WebKit/chromium:

* tests/CCLayerTreeHostTest.cpp:
(WTF::CCLayerTreeHostTestSetViewportSize::beginTest):
* tests/TiledLayerChromiumTest.cpp:
(WTF::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@106700 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h
Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/ImageLayerChromium.h
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCProxy.h
Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp
Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h
Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp
Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp
Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp