[chromium] Use WebGraphicsContext3D in compositor implementation
authorjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jun 2012 00:55:55 +0000 (00:55 +0000)
committerjamesr@google.com <jamesr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jun 2012 00:55:55 +0000 (00:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89700

Reviewed by Adrienne Walker.

Source/Platform:

Puts all callback destructors in protected section and removes obsolete memory callback signature.

* chromium/public/WebGraphicsContext3D.h:
(WebGraphicsContextLostCallback):
(WebGraphicsErrorMessageCallback):
(WebGraphicsSwapBuffersCompleteCallbackCHROMIUM):
(WebGraphicsMemoryAllocationChangedCallbackCHROMIUM):

Source/WebCore:

This converts the compositor implementation from using WebCore::GraphicsContext3D to using the Platform-provided
WebGraphicsContext3D. This removes several unnecessary layers of indirection/wrapping and cuts down the
compositor's implementation dependencies. GraphicsContext3D.h is still widely used to provide GL enum values.
Most of the changes are purely mechanical - changing type names and the like.

Ownership is changed a bit. Instead of multiple components holding references to the compositor's context, the
context is now owned by the CCGraphicsContext, which is now owned directly by CCLayerTreeHostImpl.
CCLayerTreeHostImpl also has ownership of its CCRenderer (LayerRendererChromium in 3D mode) and passes a
non-owning pointer down to the CCRenderer.

Extension checking is a bit different. The compositor does not (and never has) used extensions provided by
WebGL's request/ensure mechanism. It simply checks for the existence of extensions it needs in the GL_EXTENSIONS
string.

FrameBufferSkPictureCanvasLayerTextureUpdater had to be patched as well, since it was grabbing a GrContext off
of the compositor's GraphicsContext3D. This caused many problems. It was inefficient, since it required a full
state flush when switching between ganesh and compositor calls. The gpu memory management was completely broken
since the compositor clobbered ganesh's onMemoryAllocationChanged callback. This moves FBSkPCLTU over to using
the appropriate SharedGraphicsContext3D, like filters.

* platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp:
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect):
(WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect):
* platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h:
(FrameBufferSkPictureCanvasLayerTextureUpdater):
* platform/graphics/chromium/GeometryBinding.cpp:
(WebCore::GeometryBinding::GeometryBinding):
* platform/graphics/chromium/GeometryBinding.h:
(WebKit):
(GeometryBinding):
(WebCore::GeometryBinding::context):
* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::create):
(WebCore::LayerRendererChromium::LayerRendererChromium):
(WebCore::LayerRendererChromium::initialize):
(WebCore::LayerRendererChromium::~LayerRendererChromium):
(WebCore::LayerRendererChromium::context):
(WebCore::LayerRendererChromium::debugGLCall):
(WebCore::LayerRendererChromium::setVisible):
(WebCore::LayerRendererChromium::drawStreamVideoQuad):
(WebCore::LayerRendererChromium::drawHeadsUpDisplay):
(WebCore::LayerRendererChromium::swapBuffers):
(WebCore::LayerRendererChromium::onMemoryAllocationChanged):
(WebCore):
(WebCore::LayerRendererChromium::onMemoryAllocationChangedOnImplThread):
(WebCore::LayerRendererChromium::discardFramebuffer):
(WebCore::LayerRendererChromium::ensureFramebuffer):
(WebCore::LayerRendererChromium::onContextLost):
(WebCore::LayerRendererChromium::getFramebufferPixels):
(WebCore::LayerRendererChromium::getFramebufferTexture):
(WebCore::LayerRendererChromium::bindFramebufferToTexture):
(WebCore::LayerRendererChromium::initializeSharedObjects):
(WebCore::LayerRendererChromium::tileCheckerboardProgram):
(WebCore::LayerRendererChromium::solidColorProgram):
(WebCore::LayerRendererChromium::headsUpDisplayProgram):
(WebCore::LayerRendererChromium::renderPassProgram):
(WebCore::LayerRendererChromium::renderPassProgramAA):
(WebCore::LayerRendererChromium::renderPassMaskProgram):
(WebCore::LayerRendererChromium::renderPassMaskProgramAA):
(WebCore::LayerRendererChromium::tileProgram):
(WebCore::LayerRendererChromium::tileProgramOpaque):
(WebCore::LayerRendererChromium::tileProgramAA):
(WebCore::LayerRendererChromium::tileProgramSwizzle):
(WebCore::LayerRendererChromium::tileProgramSwizzleOpaque):
(WebCore::LayerRendererChromium::tileProgramSwizzleAA):
(WebCore::LayerRendererChromium::textureProgram):
(WebCore::LayerRendererChromium::textureProgramFlip):
(WebCore::LayerRendererChromium::textureIOSurfaceProgram):
(WebCore::LayerRendererChromium::videoYUVProgram):
(WebCore::LayerRendererChromium::videoStreamTextureProgram):
(WebCore::LayerRendererChromium::cleanupSharedObjects):
(WebCore::LayerRendererChromium::isContextLost):
* platform/graphics/chromium/LayerRendererChromium.h:
(WebKit):
(WebCore):
(LayerRendererChromium):
(WebCore::LayerRendererChromium::isFramebufferDiscarded):
* platform/graphics/chromium/LayerTextureSubImage.cpp:
(WebCore::LayerTextureSubImage::uploadWithTexSubImage):
(WebCore::LayerTextureSubImage::uploadWithMapTexSubImage):
* platform/graphics/chromium/ManagedTexture.cpp:
(WebCore::ManagedTexture::bindTexture):
(WebCore::ManagedTexture::framebufferTexture2D):
* platform/graphics/chromium/PlatformColor.h:
(WebCore::PlatformColor::bestTextureFormat):
* platform/graphics/chromium/ProgramBinding.cpp:
(WebCore::contextLost):
(WebCore::ProgramBindingBase::init):
(WebCore::ProgramBindingBase::cleanup):
(WebCore::ProgramBindingBase::loadShader):
(WebCore::ProgramBindingBase::createShaderProgram):
* platform/graphics/chromium/ProgramBinding.h:
(WebKit):
(ProgramBindingBase):
(WebCore::ProgramBinding::ProgramBinding):
(WebCore::ProgramBinding::initialize):
* platform/graphics/chromium/ShaderChromium.cpp:
(WebCore::VertexShaderPosTex::init):
(WebCore::VertexShaderPosTexYUVStretch::init):
(WebCore::VertexShaderPos::init):
(WebCore::VertexShaderPosTexTransform::init):
(WebCore::VertexShaderQuad::init):
(WebCore::VertexShaderTile::init):
(WebCore::VertexShaderVideoTransform::init):
(WebCore::FragmentTexAlphaBinding::init):
(WebCore::FragmentTexOpaqueBinding::init):
(WebCore::FragmentShaderOESImageExternal::init):
(WebCore::FragmentShaderRGBATexAlphaAA::init):
(WebCore::FragmentTexClampAlphaAABinding::init):
(WebCore::FragmentShaderRGBATexAlphaMask::init):
(WebCore::FragmentShaderRGBATexAlphaMaskAA::init):
(WebCore::FragmentShaderYUVVideo::init):
(WebCore::FragmentShaderColor::init):
(WebCore::FragmentShaderCheckerboard::init):
* platform/graphics/chromium/ShaderChromium.h:
(WebKit):
(VertexShaderPosTex):
(VertexShaderPosTexYUVStretch):
(VertexShaderPos):
(WebCore::VertexShaderPosTexIdentity::init):
(VertexShaderPosTexTransform):
(VertexShaderQuad):
(VertexShaderTile):
(VertexShaderVideoTransform):
(FragmentTexAlphaBinding):
(FragmentTexOpaqueBinding):
(FragmentShaderOESImageExternal):
(FragmentShaderRGBATexAlphaAA):
(FragmentTexClampAlphaAABinding):
(FragmentShaderRGBATexAlphaMask):
(FragmentShaderRGBATexAlphaMaskAA):
(FragmentShaderYUVVideo):
(FragmentShaderColor):
(FragmentShaderCheckerboard):
* platform/graphics/chromium/TextureCopier.cpp:
(WebCore::AcceleratedTextureCopier::AcceleratedTextureCopier):
(WebCore::AcceleratedTextureCopier::~AcceleratedTextureCopier):
(WebCore::AcceleratedTextureCopier::copyTexture):
* platform/graphics/chromium/TextureCopier.h:
(WebKit):
(WebCore):
(WebCore::AcceleratedTextureCopier::create):
(AcceleratedTextureCopier):
* platform/graphics/chromium/TextureManager.h:
* platform/graphics/chromium/ThrottledTextureUploader.cpp:
(WebCore::ThrottledTextureUploader::Query::Query):
(WebCore::ThrottledTextureUploader::Query::~Query):
(WebCore::ThrottledTextureUploader::Query::begin):
(WebCore::ThrottledTextureUploader::Query::end):
(WebCore::ThrottledTextureUploader::Query::isPending):
(WebCore::ThrottledTextureUploader::Query::wait):
(WebCore::ThrottledTextureUploader::ThrottledTextureUploader):
* platform/graphics/chromium/ThrottledTextureUploader.h:
(WebKit):
(WebCore::ThrottledTextureUploader::create):
(WebCore::ThrottledTextureUploader::Query::create):
(Query):
(ThrottledTextureUploader):
* platform/graphics/chromium/TrackingTextureAllocator.cpp:
(WebCore::TrackingTextureAllocator::TrackingTextureAllocator):
(WebCore::TrackingTextureAllocator::createTexture):
(WebCore::TrackingTextureAllocator::deleteTexture):
(WebCore::TrackingTextureAllocator::deleteAllTextures):
* platform/graphics/chromium/TrackingTextureAllocator.h:
(WebKit):
(WebCore::TrackingTextureAllocator::create):
(TrackingTextureAllocator):
* platform/graphics/chromium/cc/CCGraphicsContext.h:
(CCGraphicsContext):
(WebCore::CCGraphicsContext::create2D):
(WebCore::CCGraphicsContext::create3D):
(WebCore::CCGraphicsContext::context3D):
(WebCore::CCGraphicsContext::CCGraphicsContext):
* platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
(WebCore::CCHeadsUpDisplay::draw):
* platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp:
(WebCore::CCIOSurfaceLayerImpl::~CCIOSurfaceLayerImpl):
(WebCore::CCIOSurfaceLayerImpl::willDraw):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::createContext):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(CCLayerTreeHostClient):
(WebCore::LayerRendererCapabilities::LayerRendererCapabilities):
(LayerRendererCapabilities):
(WebCore::CCLayerTreeHost::needsSharedContext):
(CCLayerTreeHost):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::initializeLayerRenderer):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
(CCLayerTreeHostImpl):
* platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
(WebCore::CCSingleThreadProxy::initializeContext):
(WebCore::CCSingleThreadProxy::recreateContext):
* platform/graphics/chromium/cc/CCSingleThreadProxy.h:
* platform/graphics/chromium/cc/CCTextureUpdater.cpp:
(WebCore::CCTextureUpdater::update):
* platform/graphics/chromium/cc/CCThreadProxy.cpp:
(WebCore::CCThreadProxy::initializeContext):
(WebCore::CCThreadProxy::recreateContext):
(WebCore::CCThreadProxy::beginFrame):
(WebCore::CCThreadProxy::initializeContextOnImplThread):
(WebCore::CCThreadProxy::recreateContextOnImplThread):
* platform/graphics/chromium/cc/CCThreadProxy.h:
(CCThreadProxy):
* platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
(WebCore::CCVideoLayerImpl::FramePlane::allocateData):
(WebCore::CCVideoLayerImpl::FramePlane::freeData):
(WebCore::CCVideoLayerImpl::copyPlaneData):

Source/WebKit/chromium:

Updates tests for refactor, mostly by removing unnecessary GraphicsContext3D wrapper around mock contexts.

* WebKit.gypi:
* src/WebLayerTreeView.cpp:
(WebKit::WebLayerTreeView::context):
* src/WebLayerTreeViewImpl.cpp:
* tests/CCLayerTreeHostImplTest.cpp:
* tests/CCLayerTreeHostTest.cpp:
(WTF::CCLayerTreeHostTestAtomicCommit::commitCompleteOnCCThread):
(WTF::CCLayerTreeHostTestAtomicCommit::drawLayersOnCCThread):
(WTF::CCLayerTreeHostTestAtomicCommitWithPartialUpdate::commitCompleteOnCCThread):
(WTF::CCLayerTreeHostTestAtomicCommitWithPartialUpdate::drawLayersOnCCThread):
* tests/CCSingleThreadProxyTest.cpp:
* tests/CCThreadedTest.cpp:
(WebKitTests::TestHooks::createContext):
* tests/CCThreadedTest.h:
(TestHooks):
* tests/Canvas2DLayerBridgeTest.cpp:
(Canvas2DLayerBridgeTest::fullLifecycleTest):
* tests/CompositorFakeGraphicsContext3D.h: Removed.
* tests/DrawingBufferChromiumTest.cpp: Removed.
* tests/FakeCCLayerTreeHostClient.h:
* tests/FakeGraphicsContext3DTest.cpp:
(TEST):
* tests/GraphicsLayerChromiumTest.cpp:
* tests/LayerRendererChromiumTest.cpp:
(FakeLayerRendererChromium::FakeLayerRendererChromium):
(LayerRendererChromiumTest::LayerRendererChromiumTest):
(LayerRendererChromiumTest):
(TEST_F):
(TEST):
* tests/TextureCopierTest.cpp:
* tests/ThrottledTextureUploaderTest.cpp:
(WebKit::TEST):
* tests/TiledLayerChromiumTest.cpp:

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

55 files changed:
Source/Platform/ChangeLog
Source/Platform/chromium/public/WebGraphicsContext3D.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp
Source/WebCore/platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h
Source/WebCore/platform/graphics/chromium/GeometryBinding.cpp
Source/WebCore/platform/graphics/chromium/GeometryBinding.h
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
Source/WebCore/platform/graphics/chromium/LayerTextureSubImage.cpp
Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp
Source/WebCore/platform/graphics/chromium/PlatformColor.h
Source/WebCore/platform/graphics/chromium/ProgramBinding.cpp
Source/WebCore/platform/graphics/chromium/ProgramBinding.h
Source/WebCore/platform/graphics/chromium/ShaderChromium.cpp
Source/WebCore/platform/graphics/chromium/ShaderChromium.h
Source/WebCore/platform/graphics/chromium/TextureCopier.cpp
Source/WebCore/platform/graphics/chromium/TextureCopier.h
Source/WebCore/platform/graphics/chromium/TextureManager.h
Source/WebCore/platform/graphics/chromium/ThrottledTextureUploader.cpp
Source/WebCore/platform/graphics/chromium/ThrottledTextureUploader.h
Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp
Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h
Source/WebCore/platform/graphics/chromium/cc/CCGraphicsContext.h
Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp
Source/WebCore/platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp
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/CCLayerTreeHostImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp
Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h
Source/WebCore/platform/graphics/chromium/cc/CCTextureUpdater.cpp
Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp
Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h
Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gypi
Source/WebKit/chromium/src/WebLayerTreeView.cpp
Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp
Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
Source/WebKit/chromium/tests/CCSingleThreadProxyTest.cpp
Source/WebKit/chromium/tests/CCThreadedTest.cpp
Source/WebKit/chromium/tests/CCThreadedTest.h
Source/WebKit/chromium/tests/Canvas2DLayerBridgeTest.cpp
Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h [deleted file]
Source/WebKit/chromium/tests/DrawingBufferChromiumTest.cpp [deleted file]
Source/WebKit/chromium/tests/FakeCCLayerTreeHostClient.h
Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp
Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp
Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
Source/WebKit/chromium/tests/TextureCopierTest.cpp
Source/WebKit/chromium/tests/ThrottledTextureUploaderTest.cpp
Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp

index 5e0b023..5a762fa 100644 (file)
@@ -1,3 +1,18 @@
+2012-06-25  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Use WebGraphicsContext3D in compositor implementation
+        https://bugs.webkit.org/show_bug.cgi?id=89700
+
+        Reviewed by Adrienne Walker.
+
+        Puts all callback destructors in protected section and removes obsolete memory callback signature.
+
+        * chromium/public/WebGraphicsContext3D.h:
+        (WebGraphicsContextLostCallback):
+        (WebGraphicsErrorMessageCallback):
+        (WebGraphicsSwapBuffersCompleteCallbackCHROMIUM):
+        (WebGraphicsMemoryAllocationChangedCallbackCHROMIUM):
+
 2012-06-25  Scott Graham  <scottmg@chromium.org>
 
         Plumb Scrollbar button dimensions through WebThemeEngine
index dc035ae..577d702 100644 (file)
@@ -111,27 +111,30 @@ public:
     class WebGraphicsContextLostCallback {
     public:
         virtual void onContextLost() = 0;
+
+    protected:
         virtual ~WebGraphicsContextLostCallback() { }
     };
 
     class WebGraphicsErrorMessageCallback {
     public:
         virtual void onErrorMessage(const WebString&, WGC3Dint) = 0;
+
+    protected:
         virtual ~WebGraphicsErrorMessageCallback() { }
     };
 
     class WebGraphicsSwapBuffersCompleteCallbackCHROMIUM {
     public:
         virtual void onSwapBuffersComplete() = 0;
+
+    protected:
         virtual ~WebGraphicsSwapBuffersCompleteCallbackCHROMIUM() { }
     };
 
     class WebGraphicsMemoryAllocationChangedCallbackCHROMIUM {
     public:
-        // FIXME: Remove this once we switch to WebGraphicsMemoryAllocation version.
-        virtual void onMemoryAllocationChanged(size_t gpuResourceSizeInBytes) = 0;
-        // FIXME: Make this pure virtual once we implement everywhere.
-        virtual void onMemoryAllocationChanged(WebGraphicsMemoryAllocation) { }
+        virtual void onMemoryAllocationChanged(WebGraphicsMemoryAllocation) = 0;
 
     protected:
         virtual ~WebGraphicsMemoryAllocationChangedCallbackCHROMIUM() { }
index 44e08f7..aa8cc32 100644 (file)
@@ -1,3 +1,219 @@
+2012-06-25  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Use WebGraphicsContext3D in compositor implementation
+        https://bugs.webkit.org/show_bug.cgi?id=89700
+
+        Reviewed by Adrienne Walker.
+
+        This converts the compositor implementation from using WebCore::GraphicsContext3D to using the Platform-provided
+        WebGraphicsContext3D. This removes several unnecessary layers of indirection/wrapping and cuts down the
+        compositor's implementation dependencies. GraphicsContext3D.h is still widely used to provide GL enum values.
+        Most of the changes are purely mechanical - changing type names and the like.
+
+        Ownership is changed a bit. Instead of multiple components holding references to the compositor's context, the
+        context is now owned by the CCGraphicsContext, which is now owned directly by CCLayerTreeHostImpl.
+        CCLayerTreeHostImpl also has ownership of its CCRenderer (LayerRendererChromium in 3D mode) and passes a
+        non-owning pointer down to the CCRenderer.
+
+        Extension checking is a bit different. The compositor does not (and never has) used extensions provided by
+        WebGL's request/ensure mechanism. It simply checks for the existence of extensions it needs in the GL_EXTENSIONS
+        string.
+
+        FrameBufferSkPictureCanvasLayerTextureUpdater had to be patched as well, since it was grabbing a GrContext off
+        of the compositor's GraphicsContext3D. This caused many problems. It was inefficient, since it required a full
+        state flush when switching between ganesh and compositor calls. The gpu memory management was completely broken
+        since the compositor clobbered ganesh's onMemoryAllocationChanged callback. This moves FBSkPCLTU over to using
+        the appropriate SharedGraphicsContext3D, like filters.
+
+        * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.cpp:
+        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect):
+        (WebCore::FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect):
+        * platform/graphics/chromium/FrameBufferSkPictureCanvasLayerTextureUpdater.h:
+        (FrameBufferSkPictureCanvasLayerTextureUpdater):
+        * platform/graphics/chromium/GeometryBinding.cpp:
+        (WebCore::GeometryBinding::GeometryBinding):
+        * platform/graphics/chromium/GeometryBinding.h:
+        (WebKit):
+        (GeometryBinding):
+        (WebCore::GeometryBinding::context):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::create):
+        (WebCore::LayerRendererChromium::LayerRendererChromium):
+        (WebCore::LayerRendererChromium::initialize):
+        (WebCore::LayerRendererChromium::~LayerRendererChromium):
+        (WebCore::LayerRendererChromium::context):
+        (WebCore::LayerRendererChromium::debugGLCall):
+        (WebCore::LayerRendererChromium::setVisible):
+        (WebCore::LayerRendererChromium::drawStreamVideoQuad):
+        (WebCore::LayerRendererChromium::drawHeadsUpDisplay):
+        (WebCore::LayerRendererChromium::swapBuffers):
+        (WebCore::LayerRendererChromium::onMemoryAllocationChanged):
+        (WebCore):
+        (WebCore::LayerRendererChromium::onMemoryAllocationChangedOnImplThread):
+        (WebCore::LayerRendererChromium::discardFramebuffer):
+        (WebCore::LayerRendererChromium::ensureFramebuffer):
+        (WebCore::LayerRendererChromium::onContextLost):
+        (WebCore::LayerRendererChromium::getFramebufferPixels):
+        (WebCore::LayerRendererChromium::getFramebufferTexture):
+        (WebCore::LayerRendererChromium::bindFramebufferToTexture):
+        (WebCore::LayerRendererChromium::initializeSharedObjects):
+        (WebCore::LayerRendererChromium::tileCheckerboardProgram):
+        (WebCore::LayerRendererChromium::solidColorProgram):
+        (WebCore::LayerRendererChromium::headsUpDisplayProgram):
+        (WebCore::LayerRendererChromium::renderPassProgram):
+        (WebCore::LayerRendererChromium::renderPassProgramAA):
+        (WebCore::LayerRendererChromium::renderPassMaskProgram):
+        (WebCore::LayerRendererChromium::renderPassMaskProgramAA):
+        (WebCore::LayerRendererChromium::tileProgram):
+        (WebCore::LayerRendererChromium::tileProgramOpaque):
+        (WebCore::LayerRendererChromium::tileProgramAA):
+        (WebCore::LayerRendererChromium::tileProgramSwizzle):
+        (WebCore::LayerRendererChromium::tileProgramSwizzleOpaque):
+        (WebCore::LayerRendererChromium::tileProgramSwizzleAA):
+        (WebCore::LayerRendererChromium::textureProgram):
+        (WebCore::LayerRendererChromium::textureProgramFlip):
+        (WebCore::LayerRendererChromium::textureIOSurfaceProgram):
+        (WebCore::LayerRendererChromium::videoYUVProgram):
+        (WebCore::LayerRendererChromium::videoStreamTextureProgram):
+        (WebCore::LayerRendererChromium::cleanupSharedObjects):
+        (WebCore::LayerRendererChromium::isContextLost):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        (WebKit):
+        (WebCore):
+        (LayerRendererChromium):
+        (WebCore::LayerRendererChromium::isFramebufferDiscarded):
+        * platform/graphics/chromium/LayerTextureSubImage.cpp:
+        (WebCore::LayerTextureSubImage::uploadWithTexSubImage):
+        (WebCore::LayerTextureSubImage::uploadWithMapTexSubImage):
+        * platform/graphics/chromium/ManagedTexture.cpp:
+        (WebCore::ManagedTexture::bindTexture):
+        (WebCore::ManagedTexture::framebufferTexture2D):
+        * platform/graphics/chromium/PlatformColor.h:
+        (WebCore::PlatformColor::bestTextureFormat):
+        * platform/graphics/chromium/ProgramBinding.cpp:
+        (WebCore::contextLost):
+        (WebCore::ProgramBindingBase::init):
+        (WebCore::ProgramBindingBase::cleanup):
+        (WebCore::ProgramBindingBase::loadShader):
+        (WebCore::ProgramBindingBase::createShaderProgram):
+        * platform/graphics/chromium/ProgramBinding.h:
+        (WebKit):
+        (ProgramBindingBase):
+        (WebCore::ProgramBinding::ProgramBinding):
+        (WebCore::ProgramBinding::initialize):
+        * platform/graphics/chromium/ShaderChromium.cpp:
+        (WebCore::VertexShaderPosTex::init):
+        (WebCore::VertexShaderPosTexYUVStretch::init):
+        (WebCore::VertexShaderPos::init):
+        (WebCore::VertexShaderPosTexTransform::init):
+        (WebCore::VertexShaderQuad::init):
+        (WebCore::VertexShaderTile::init):
+        (WebCore::VertexShaderVideoTransform::init):
+        (WebCore::FragmentTexAlphaBinding::init):
+        (WebCore::FragmentTexOpaqueBinding::init):
+        (WebCore::FragmentShaderOESImageExternal::init):
+        (WebCore::FragmentShaderRGBATexAlphaAA::init):
+        (WebCore::FragmentTexClampAlphaAABinding::init):
+        (WebCore::FragmentShaderRGBATexAlphaMask::init):
+        (WebCore::FragmentShaderRGBATexAlphaMaskAA::init):
+        (WebCore::FragmentShaderYUVVideo::init):
+        (WebCore::FragmentShaderColor::init):
+        (WebCore::FragmentShaderCheckerboard::init):
+        * platform/graphics/chromium/ShaderChromium.h:
+        (WebKit):
+        (VertexShaderPosTex):
+        (VertexShaderPosTexYUVStretch):
+        (VertexShaderPos):
+        (WebCore::VertexShaderPosTexIdentity::init):
+        (VertexShaderPosTexTransform):
+        (VertexShaderQuad):
+        (VertexShaderTile):
+        (VertexShaderVideoTransform):
+        (FragmentTexAlphaBinding):
+        (FragmentTexOpaqueBinding):
+        (FragmentShaderOESImageExternal):
+        (FragmentShaderRGBATexAlphaAA):
+        (FragmentTexClampAlphaAABinding):
+        (FragmentShaderRGBATexAlphaMask):
+        (FragmentShaderRGBATexAlphaMaskAA):
+        (FragmentShaderYUVVideo):
+        (FragmentShaderColor):
+        (FragmentShaderCheckerboard):
+        * platform/graphics/chromium/TextureCopier.cpp:
+        (WebCore::AcceleratedTextureCopier::AcceleratedTextureCopier):
+        (WebCore::AcceleratedTextureCopier::~AcceleratedTextureCopier):
+        (WebCore::AcceleratedTextureCopier::copyTexture):
+        * platform/graphics/chromium/TextureCopier.h:
+        (WebKit):
+        (WebCore):
+        (WebCore::AcceleratedTextureCopier::create):
+        (AcceleratedTextureCopier):
+        * platform/graphics/chromium/TextureManager.h:
+        * platform/graphics/chromium/ThrottledTextureUploader.cpp:
+        (WebCore::ThrottledTextureUploader::Query::Query):
+        (WebCore::ThrottledTextureUploader::Query::~Query):
+        (WebCore::ThrottledTextureUploader::Query::begin):
+        (WebCore::ThrottledTextureUploader::Query::end):
+        (WebCore::ThrottledTextureUploader::Query::isPending):
+        (WebCore::ThrottledTextureUploader::Query::wait):
+        (WebCore::ThrottledTextureUploader::ThrottledTextureUploader):
+        * platform/graphics/chromium/ThrottledTextureUploader.h:
+        (WebKit):
+        (WebCore::ThrottledTextureUploader::create):
+        (WebCore::ThrottledTextureUploader::Query::create):
+        (Query):
+        (ThrottledTextureUploader):
+        * platform/graphics/chromium/TrackingTextureAllocator.cpp:
+        (WebCore::TrackingTextureAllocator::TrackingTextureAllocator):
+        (WebCore::TrackingTextureAllocator::createTexture):
+        (WebCore::TrackingTextureAllocator::deleteTexture):
+        (WebCore::TrackingTextureAllocator::deleteAllTextures):
+        * platform/graphics/chromium/TrackingTextureAllocator.h:
+        (WebKit):
+        (WebCore::TrackingTextureAllocator::create):
+        (TrackingTextureAllocator):
+        * platform/graphics/chromium/cc/CCGraphicsContext.h:
+        (CCGraphicsContext):
+        (WebCore::CCGraphicsContext::create2D):
+        (WebCore::CCGraphicsContext::create3D):
+        (WebCore::CCGraphicsContext::context3D):
+        (WebCore::CCGraphicsContext::CCGraphicsContext):
+        * platform/graphics/chromium/cc/CCHeadsUpDisplay.cpp:
+        (WebCore::CCHeadsUpDisplay::draw):
+        * platform/graphics/chromium/cc/CCIOSurfaceLayerImpl.cpp:
+        (WebCore::CCIOSurfaceLayerImpl::~CCIOSurfaceLayerImpl):
+        (WebCore::CCIOSurfaceLayerImpl::willDraw):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::createContext):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (CCLayerTreeHostClient):
+        (WebCore::LayerRendererCapabilities::LayerRendererCapabilities):
+        (LayerRendererCapabilities):
+        (WebCore::CCLayerTreeHost::needsSharedContext):
+        (CCLayerTreeHost):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::initializeLayerRenderer):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        (CCLayerTreeHostImpl):
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
+        (WebCore::CCSingleThreadProxy::initializeContext):
+        (WebCore::CCSingleThreadProxy::recreateContext):
+        * platform/graphics/chromium/cc/CCSingleThreadProxy.h:
+        * platform/graphics/chromium/cc/CCTextureUpdater.cpp:
+        (WebCore::CCTextureUpdater::update):
+        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
+        (WebCore::CCThreadProxy::initializeContext):
+        (WebCore::CCThreadProxy::recreateContext):
+        (WebCore::CCThreadProxy::beginFrame):
+        (WebCore::CCThreadProxy::initializeContextOnImplThread):
+        (WebCore::CCThreadProxy::recreateContextOnImplThread):
+        * platform/graphics/chromium/cc/CCThreadProxy.h:
+        (CCThreadProxy):
+        * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
+        (WebCore::CCVideoLayerImpl::FramePlane::allocateData):
+        (WebCore::CCVideoLayerImpl::FramePlane::freeData):
+        (WebCore::CCVideoLayerImpl::copyPlaneData):
+
 2012-06-25  Adrienne Walker  <enne@google.com>
 
         [chromium] Make CCThreadProxy not draw a frame mid-commit
index a2c43ce..743bcc1 100644 (file)
 #include "FrameBufferSkPictureCanvasLayerTextureUpdater.h"
 
 #include "LayerPainterChromium.h"
+#include "SharedGraphicsContext3D.h"
 #include "SkCanvas.h"
 #include "SkGpuDevice.h"
-#include "cc/CCGraphicsContext.h"
+#include "cc/CCProxy.h"
 
 namespace WebCore {
 
@@ -67,9 +68,12 @@ FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::~Texture()
 {
 }
 
-void FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect(CCGraphicsContext* context, TextureAllocator* allocator, const IntRect& sourceRect, const IntRect& destRect)
+void FrameBufferSkPictureCanvasLayerTextureUpdater::Texture::updateRect(CCGraphicsContext*, TextureAllocator* allocator, const IntRect& sourceRect, const IntRect& destRect)
 {
-    textureUpdater()->updateTextureRect(context, allocator, texture(), sourceRect, destRect);
+    RefPtr<GraphicsContext3D> sharedContext = CCProxy::hasImplThread() ? SharedGraphicsContext3D::getForImplThread() : SharedGraphicsContext3D::get();
+    if (!sharedContext)
+        return;
+    textureUpdater()->updateTextureRect(sharedContext.release(), allocator, texture(), sourceRect, destRect);
 }
 
 PassRefPtr<FrameBufferSkPictureCanvasLayerTextureUpdater> FrameBufferSkPictureCanvasLayerTextureUpdater::create(PassOwnPtr<LayerPainterChromium> painter)
@@ -97,21 +101,15 @@ LayerTextureUpdater::SampledTexelFormat FrameBufferSkPictureCanvasLayerTextureUp
     return LayerTextureUpdater::SampledTexelFormatRGBA;
 }
 
-void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(CCGraphicsContext* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
+void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(PassRefPtr<GraphicsContext3D> prpContext, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& destRect)
 {
-    GraphicsContext3D* context3d = context->context3D();
-    if (!context3d) {
-        // FIXME: Implement this path for software compositing.
-        return;
-    }
+    RefPtr<GraphicsContext3D> context(prpContext);
 
     // Make sure ganesh uses the correct GL context.
-    context3d->makeContextCurrent();
-    // Notify ganesh to sync its internal GL state.
-    context3d->grContext()->resetContext();
+    context->makeContextCurrent();
 
     // Create an accelerated canvas to draw on.
-    OwnPtr<SkCanvas> canvas = createAcceleratedCanvas(context3d, allocator, texture);
+    OwnPtr<SkCanvas> canvas = createAcceleratedCanvas(context.get(), allocator, texture);
 
     // The compositor expects the textures to be upside-down so it can flip
     // the final composited image. Ganesh renders the image upright so we
@@ -127,7 +125,10 @@ void FrameBufferSkPictureCanvasLayerTextureUpdater::updateTextureRect(CCGraphics
     drawPicture(canvas.get());
 
     // Flush ganesh context so that all the rendered stuff appears on the texture.
-    context3d->grContext()->flush();
+    context->grContext()->flush();
+
+    // Flush the GL context so rendering results from this context are visible in the compositor's context.
+    context->flush();
 }
 
 } // namespace WebCore
index abeaf52..1f2f20c 100644 (file)
@@ -56,7 +56,7 @@ public:
 
     virtual PassOwnPtr<LayerTextureUpdater::Texture> createTexture(TextureManager*) OVERRIDE;
     virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) OVERRIDE;
-    void updateTextureRect(CCGraphicsContext*, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
+    void updateTextureRect(PassRefPtr<GraphicsContext3D>, TextureAllocator*, ManagedTexture*, const IntRect& sourceRect, const IntRect& destRect);
 
 private:
     explicit FrameBufferSkPictureCanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium>);
index a859aae..1a4568b 100644 (file)
 
 #include "GeometryBinding.h"
 
-#include "GraphicsContext.h"
 #include "GraphicsContext3D.h"
 #include "LayerRendererChromium.h"
+#include <public/WebGraphicsContext3D.h>
 
 namespace WebCore {
 
-GeometryBinding::GeometryBinding(GraphicsContext3D* context)
+GeometryBinding::GeometryBinding(WebKit::WebGraphicsContext3D* context)
     : m_context(context)
     , m_quadVerticesVbo(0)
     , m_quadElementsVbo(0)
index ec19970..20b2d5a 100644 (file)
 
 #if USE(ACCELERATED_COMPOSITING)
 
-#include "PlatformString.h"
+namespace WebKit {
+class WebGraphicsContext3D;
+}
 
 namespace WebCore {
 
-class GraphicsContext3D;
-
 class GeometryBinding {
 public:
-    explicit GeometryBinding(GraphicsContext3D*);
+    explicit GeometryBinding(WebKit::WebGraphicsContext3D*);
     ~GeometryBinding();
 
     bool initialized() const { return m_initialized; }
 
-    GraphicsContext3D* context() const { return m_context; }
+    WebKit::WebGraphicsContext3D* context() const { return m_context; }
     unsigned quadVerticesVbo() const { return m_quadVerticesVbo; }
     unsigned quadElementsVbo() const { return m_quadElementsVbo; }
 
@@ -54,7 +54,7 @@ public:
     static int texCoordAttribLocation() { return 1; }
 
 private:
-    GraphicsContext3D* m_context;
+    WebKit::WebGraphicsContext3D* m_context;
     unsigned m_quadVerticesVbo;
     unsigned m_quadElementsVbo;
     bool m_initialized;
index 119af39..2624c0e 100644 (file)
@@ -38,7 +38,6 @@
 #include "FloatQuad.h"
 #include "GeometryBinding.h"
 #include "GrTexture.h"
-#include "GraphicsContext3D.h"
 #include "ManagedTexture.h"
 #include "NativeImageSkia.h"
 #include "NotImplemented.h"
 #include "cc/CCTileDrawQuad.h"
 #include "cc/CCVideoLayerImpl.h"
 #include "cc/CCYUVVideoDrawQuad.h"
+#include <public/WebGraphicsContext3D.h>
 #include <public/WebVideoFrame.h>
 #include <wtf/CurrentTime.h>
 #include <wtf/MainThread.h>
+#include <wtf/text/StringHash.h>
 
 using namespace std;
+using WebKit::WebGraphicsContext3D;
+using WebKit::WebGraphicsMemoryAllocation;
 using WebKit::WebTransformationMatrix;
 
 namespace WebCore {
@@ -112,25 +115,6 @@ static WebTransformationMatrix screenMatrix(int x, int y, int width, int height)
     return screen;
 }
 
-bool contextSupportsAcceleratedPainting(GraphicsContext3D* context)
-{
-    WebCore::Extensions3D* extensions = context->getExtensions();
-    if (extensions->supports("GL_EXT_texture_format_BGRA8888"))
-        extensions->ensureEnabled("GL_EXT_texture_format_BGRA8888");
-    else
-        return false;
-
-    if (extensions->supports("GL_EXT_read_format_bgra"))
-        extensions->ensureEnabled("GL_EXT_read_format_bgra");
-    else
-        return false;
-
-    if (!context->grContext())
-        return false;
-
-    return true;
-}
-
 bool needsLionIOSurfaceReadbackWorkaround()
 {
 #if OS(DARWIN)
@@ -166,66 +150,7 @@ protected:
 
 } // anonymous namespace
 
-class LayerRendererSwapBuffersCompleteCallbackAdapter : public Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM {
-public:
-    static PassOwnPtr<LayerRendererSwapBuffersCompleteCallbackAdapter> create(LayerRendererChromium* layerRenderer)
-    {
-        return adoptPtr(new LayerRendererSwapBuffersCompleteCallbackAdapter(layerRenderer));
-    }
-    virtual ~LayerRendererSwapBuffersCompleteCallbackAdapter() { }
-
-    virtual void onSwapBuffersComplete()
-    {
-        m_layerRenderer->onSwapBuffersComplete();
-    }
-
-private:
-    explicit LayerRendererSwapBuffersCompleteCallbackAdapter(LayerRendererChromium* layerRenderer)
-    {
-        m_layerRenderer = layerRenderer;
-    }
-
-    LayerRendererChromium* m_layerRenderer;
-};
-
-class LayerRendererGpuMemoryAllocationChangedCallbackAdapter : public Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM {
-public:
-    static PassOwnPtr<LayerRendererGpuMemoryAllocationChangedCallbackAdapter> create(LayerRendererChromium* layerRenderer)
-    {
-        return adoptPtr(new LayerRendererGpuMemoryAllocationChangedCallbackAdapter(layerRenderer));
-    }
-    virtual ~LayerRendererGpuMemoryAllocationChangedCallbackAdapter() { }
-
-    virtual void onGpuMemoryAllocationChanged(Extensions3DChromium::GpuMemoryAllocationCHROMIUM allocation)
-    {
-        // FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread.
-        if (m_bindToImplThread) {
-          ASSERT(CCProxy::isMainThread());
-          DebugScopedSetImplThread impl;
-          onGpuMemoryAllocationChangedOnImpl(allocation);
-        } else {
-          ASSERT(CCProxy::isImplThread());
-          onGpuMemoryAllocationChangedOnImpl(allocation);
-        }
-    }
-
-private:
-    explicit LayerRendererGpuMemoryAllocationChangedCallbackAdapter(LayerRendererChromium* layerRenderer)
-        : m_layerRenderer(layerRenderer), m_bindToImplThread(!CCProxy::hasImplThread())
-    {
-    }
-
-    void onGpuMemoryAllocationChangedOnImpl(Extensions3DChromium::GpuMemoryAllocationCHROMIUM allocation)
-    {
-        ASSERT(CCProxy::isImplThread());
-        m_layerRenderer->setGpuMemoryAllocation(allocation);
-    }
-
-    LayerRendererChromium* m_layerRenderer;
-    bool m_bindToImplThread;
-};
-
-PassOwnPtr<LayerRendererChromium> LayerRendererChromium::create(CCRendererClient* client, PassRefPtr<GraphicsContext3D> context, TextureUploaderOption textureUploaderSetting)
+PassOwnPtr<LayerRendererChromium> LayerRendererChromium::create(CCRendererClient* client, WebGraphicsContext3D* context, TextureUploaderOption textureUploaderSetting)
 {
     OwnPtr<LayerRendererChromium> layerRenderer(adoptPtr(new LayerRendererChromium(client, context, textureUploaderSetting)));
     if (!layerRenderer->initialize())
@@ -235,7 +160,7 @@ PassOwnPtr<LayerRendererChromium> LayerRendererChromium::create(CCRendererClient
 }
 
 LayerRendererChromium::LayerRendererChromium(CCRendererClient* client,
-                                             PassRefPtr<GraphicsContext3D> context,
+                                             WebGraphicsContext3D* context,
                                              TextureUploaderOption textureUploaderSetting)
     : CCRenderer(client)
     , m_currentRenderPass(0)
@@ -249,96 +174,65 @@ LayerRendererChromium::LayerRendererChromium(CCRendererClient* client,
     , m_visible(true)
     , m_textureUploaderSetting(textureUploaderSetting)
 {
-    ASSERT(m_context.get());
+    ASSERT(m_context);
 }
 
-class ContextLostCallbackAdapter : public GraphicsContext3D::ContextLostCallback {
-public:
-    static PassOwnPtr<ContextLostCallbackAdapter> create(CCRendererClient* client)
-    {
-        return adoptPtr(new ContextLostCallbackAdapter(client));
-    }
-
-    virtual void onContextLost()
-    {
-        m_client->didLoseContext();
-    }
-
-private:
-    explicit ContextLostCallbackAdapter(CCRendererClient* client)
-        : m_client(client) { }
-
-    CCRendererClient* m_client;
-};
-
 bool LayerRendererChromium::initialize()
 {
     if (!m_context->makeContextCurrent())
         return false;
 
-    m_context->setContextLostCallback(ContextLostCallbackAdapter::create(m_client));
+    m_context->setContextLostCallback(this);
 
-    if (settings().acceleratePainting && contextSupportsAcceleratedPainting(m_context.get()))
+    String extensionsString = m_context->getString(GraphicsContext3D::EXTENSIONS);
+    Vector<String> extensionsList;
+    extensionsString.split(' ', extensionsList);
+    HashSet<String> extensions;
+    for (size_t i = 0; i < extensionsList.size(); ++i)
+        extensions.add(extensionsList[i]);
+
+    if (settings().acceleratePainting && extensions.contains("GL_EXT_texture_format_BGRA8888")
+                                      && extensions.contains("GL_EXT_read_format_bgra"))
         m_capabilities.usingAcceleratedPainting = true;
+    else
+        m_capabilities.usingAcceleratedPainting = false;
 
-    WebCore::Extensions3D* extensions = m_context->getExtensions();
-    m_capabilities.contextHasCachedFrontBuffer = extensions->supports("GL_CHROMIUM_front_buffer_cached");
-    if (m_capabilities.contextHasCachedFrontBuffer)
-        extensions->ensureEnabled("GL_CHROMIUM_front_buffer_cached");
 
-    m_capabilities.usingPartialSwap = CCSettings::partialSwapEnabled() && extensions->supports("GL_CHROMIUM_post_sub_buffer");
-    if (m_capabilities.usingPartialSwap)
-        extensions->ensureEnabled("GL_CHROMIUM_post_sub_buffer");
+    m_capabilities.contextHasCachedFrontBuffer = extensions.contains("GL_CHROMIUM_front_buffer_cached");
+
+    m_capabilities.usingPartialSwap = CCSettings::partialSwapEnabled() && extensions.contains("GL_CHROMIUM_post_sub_buffer");
 
-    m_capabilities.usingMapSub = extensions->supports("GL_CHROMIUM_map_sub");
-    if (m_capabilities.usingMapSub)
-        extensions->ensureEnabled("GL_CHROMIUM_map_sub");
+    m_capabilities.usingMapSub = extensions.contains("GL_CHROMIUM_map_sub");
 
     // Use the swapBuffers callback only with the threaded proxy.
     if (CCProxy::hasImplThread())
-        m_capabilities.usingSwapCompleteCallback = extensions->supports("GL_CHROMIUM_swapbuffers_complete_callback");
+        m_capabilities.usingSwapCompleteCallback = extensions.contains("GL_CHROMIUM_swapbuffers_complete_callback");
     if (m_capabilities.usingSwapCompleteCallback) {
-        extensions->ensureEnabled("GL_CHROMIUM_swapbuffers_complete_callback");
-        Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(extensions);
-        extensions3DChromium->setSwapBuffersCompleteCallbackCHROMIUM(LayerRendererSwapBuffersCompleteCallbackAdapter::create(this));
+        m_context->setSwapBuffersCompleteCallbackCHROMIUM(this);
     }
 
-    if (extensions->supports("GL_EXT_texture_format_BGRA8888"))
-        extensions->ensureEnabled("GL_EXT_texture_format_BGRA8888");
+    m_capabilities.usingSetVisibility = extensions.contains("GL_CHROMIUM_set_visibility");
 
-    m_capabilities.usingSetVisibility = extensions->supports("GL_CHROMIUM_set_visibility");
-    if (m_capabilities.usingSetVisibility)
-        extensions->ensureEnabled("GL_CHROMIUM_set_visibility");
-
-    if (extensions->supports("GL_CHROMIUM_iosurface")) {
-        ASSERT(extensions->supports("GL_ARB_texture_rectangle"));
-        extensions->ensureEnabled("GL_ARB_texture_rectangle");
-        extensions->ensureEnabled("GL_CHROMIUM_iosurface");
+    if (extensions.contains("GL_CHROMIUM_iosurface")) {
+        ASSERT(extensions.contains("GL_ARB_texture_rectangle"));
     }
 
-    m_capabilities.usingTextureUsageHint = extensions->supports("GL_ANGLE_texture_usage");
-    if (m_capabilities.usingTextureUsageHint)
-        extensions->ensureEnabled("GL_ANGLE_texture_usage");
+    m_capabilities.usingTextureUsageHint = extensions.contains("GL_ANGLE_texture_usage");
 
-    m_capabilities.usingTextureStorageExtension = extensions->supports("GL_EXT_texture_storage");
-    if (m_capabilities.usingTextureStorageExtension)
-        extensions->ensureEnabled("GL_EXT_texture_storage");
+    m_capabilities.usingTextureStorageExtension = extensions.contains("GL_EXT_texture_storage");
 
-    m_capabilities.usingGpuMemoryManager = extensions->supports("GL_CHROMIUM_gpu_memory_manager");
-    if (m_capabilities.usingGpuMemoryManager) {
-        extensions->ensureEnabled("GL_CHROMIUM_gpu_memory_manager");
-        Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(extensions);
-        extensions3DChromium->setGpuMemoryAllocationChangedCallbackCHROMIUM(LayerRendererGpuMemoryAllocationChangedCallbackAdapter::create(this));
-    } else {
+    m_capabilities.usingGpuMemoryManager = extensions.contains("GL_CHROMIUM_gpu_memory_manager");
+    if (m_capabilities.usingGpuMemoryManager)
+        m_context->setMemoryAllocationChangedCallbackCHROMIUM(this);
+    else
         m_client->setMemoryAllocationLimitBytes(TextureManager::highLimitBytes(viewportSize()));
-    }
 
-    m_capabilities.usingDiscardFramebuffer = extensions->supports("GL_CHROMIUM_discard_framebuffer");
-    if (m_capabilities.usingDiscardFramebuffer)
-        extensions->ensureEnabled("GL_CHROMIUM_discard_framebuffer");
+    m_capabilities.usingDiscardFramebuffer = extensions.contains("GL_CHROMIUM_discard_framebuffer");
+
+    m_capabilities.usingEglImage = extensions.contains("GL_OES_EGL_image_external");
 
     GLC(m_context, m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &m_capabilities.maxTextureSize));
-    m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_context.get());
+    m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_context, extensions.contains("GL_EXT_texture_format_BGRA8888"));
 
     if (!initializeSharedObjects())
         return false;
@@ -351,18 +245,18 @@ bool LayerRendererChromium::initialize()
 LayerRendererChromium::~LayerRendererChromium()
 {
     ASSERT(CCProxy::isImplThread());
-    Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(m_context->getExtensions());
-    extensions3DChromium->setSwapBuffersCompleteCallbackCHROMIUM(nullptr);
-    extensions3DChromium->setGpuMemoryAllocationChangedCallbackCHROMIUM(nullptr);
+    m_context->setSwapBuffersCompleteCallbackCHROMIUM(0);
+    m_context->setMemoryAllocationChangedCallbackCHROMIUM(0);
+    m_context->setContextLostCallback(0);
     cleanupSharedObjects();
 }
 
-GraphicsContext3D* LayerRendererChromium::context()
+WebGraphicsContext3D* LayerRendererChromium::context()
 {
-    return m_context.get();
+    return m_context;
 }
 
-void LayerRendererChromium::debugGLCall(GraphicsContext3D* context, const char* command, const char* file, int line)
+void LayerRendererChromium::debugGLCall(WebGraphicsContext3D* context, const char* command, const char* file, int line)
 {
     unsigned long error = context->getError();
     if (error != GraphicsContext3D::NO_ERROR)
@@ -378,8 +272,7 @@ void LayerRendererChromium::setVisible(bool visible)
     // TODO: Replace setVisibilityCHROMIUM with an extension to explicitly manage front/backbuffers
     // crbug.com/116049
     if (m_capabilities.usingSetVisibility) {
-        Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(m_context->getExtensions());
-        extensions3DChromium->setVisibilityCHROMIUM(visible);
+        m_context->setVisibilityCHROMIUM(visible);
     }
 }
 
@@ -1047,7 +940,7 @@ void LayerRendererChromium::drawStreamVideoQuad(const CCStreamVideoDrawQuad* qua
 {
     static float glMatrix[16];
 
-    ASSERT(context()->getExtensions()->supports("GL_OES_EGL_image_external") && context()->getExtensions()->isEnabled("GL_OES_EGL_image_external"));
+    ASSERT(m_capabilities.usingEglImage);
 
     const VideoStreamTextureProgram* program = videoStreamTextureProgram();
     GLC(context(), context()->useProgram(program->program()));
@@ -1165,8 +1058,9 @@ void LayerRendererChromium::drawHeadsUpDisplay(ManagedTexture* hudTexture, const
     const HeadsUpDisplayProgram* program = headsUpDisplayProgram();
     ASSERT(program && program->initialized());
     GLC(m_context, m_context->activeTexture(GraphicsContext3D::TEXTURE0));
-    RefPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(m_context);
-    hudTexture->bindTexture(ccContext.get(), m_implTextureAllocator.get());
+    if (!hudTexture->textureId())
+        hudTexture->allocate(m_implTextureAllocator.get());
+    GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, hudTexture->textureId()));
     GLC(m_context, m_context->useProgram(program->program()));
     GLC(m_context, m_context->uniform1i(program->fragmentShader().samplerLocation(), 0));
 
@@ -1261,22 +1155,6 @@ void LayerRendererChromium::copyTextureToFramebuffer(int textureId, const IntSiz
                                     -1);
 }
 
-void LayerRendererChromium::setGpuMemoryAllocation(Extensions3DChromium::GpuMemoryAllocationCHROMIUM allocation)
-{
-    if (m_visible && !allocation.gpuResourceSizeInBytes)
-        return;
-
-    if (!allocation.suggestHaveBackbuffer && !m_visible)
-        discardFramebuffer();
-
-    if (!allocation.gpuResourceSizeInBytes) {
-        releaseRenderPassTextures();
-        m_client->releaseContentsTextures();
-        GLC(m_context, m_context->flush());
-    } else
-        m_client->setMemoryAllocationLimitBytes(allocation.gpuResourceSizeInBytes);
-}
-
 void LayerRendererChromium::finish()
 {
     TRACE_EVENT("LayerRendererChromium::finish", this, 0);
@@ -1295,12 +1173,11 @@ bool LayerRendererChromium::swapBuffers(const IntRect& subBuffer)
         // If supported, we can save significant bandwidth by only swapping the damaged/scissored region (clamped to the viewport)
         IntRect clippedSubBuffer = subBuffer;
         clippedSubBuffer.intersect(IntRect(IntPoint::zero(), viewportSize()));
-        Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(m_context->getExtensions());
         int flippedYPosOfRectBottom = viewportHeight() - clippedSubBuffer.y() - clippedSubBuffer.height();
-        extensions3DChromium->postSubBufferCHROMIUM(clippedSubBuffer.x(), flippedYPosOfRectBottom, clippedSubBuffer.width(), clippedSubBuffer.height());
+        m_context->postSubBufferCHROMIUM(clippedSubBuffer.x(), flippedYPosOfRectBottom, clippedSubBuffer.width(), clippedSubBuffer.height());
     } else
         // Note that currently this has the same effect as swapBuffers; we should
-        // consider exposing a different entry point on GraphicsContext3D.
+        // consider exposing a different entry point on WebGraphicsContext3D.
         m_context->prepareTexture();
 
     return true;
@@ -1311,6 +1188,35 @@ void LayerRendererChromium::onSwapBuffersComplete()
     m_client->onSwapBuffersComplete();
 }
 
+void LayerRendererChromium::onMemoryAllocationChanged(WebGraphicsMemoryAllocation allocation)
+{
+    // FIXME: This is called on the main thread in single threaded mode, but we expect it on the impl thread.
+    if (!CCProxy::hasImplThread()) {
+      ASSERT(CCProxy::isMainThread());
+      DebugScopedSetImplThread impl;
+      onMemoryAllocationChangedOnImplThread(allocation);
+    } else {
+      ASSERT(CCProxy::isImplThread());
+      onMemoryAllocationChangedOnImplThread(allocation);
+    }
+}
+
+void LayerRendererChromium::onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemoryAllocation allocation)
+{
+    if (m_visible && !allocation.gpuResourceSizeInBytes)
+        return;
+
+    if (!allocation.suggestHaveBackbuffer && !m_visible)
+        discardFramebuffer();
+
+    if (!allocation.gpuResourceSizeInBytes) {
+        releaseRenderPassTextures();
+        m_client->releaseContentsTextures();
+        GLC(m_context, m_context->flush());
+    } else
+        m_client->setMemoryAllocationLimitBytes(allocation.gpuResourceSizeInBytes);
+}
+
 void LayerRendererChromium::discardFramebuffer()
 {
     if (m_isFramebufferDiscarded)
@@ -1319,10 +1225,8 @@ void LayerRendererChromium::discardFramebuffer()
     if (!m_capabilities.usingDiscardFramebuffer)
         return;
 
-    Extensions3D* extensions = m_context->getExtensions();
-    Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(extensions);
     // FIXME: Update attachments argument to appropriate values once they are no longer ignored.
-    extensions3DChromium->discardFramebufferEXT(GraphicsContext3D::TEXTURE_2D, 0, 0);
+    m_context->discardFramebufferEXT(GraphicsContext3D::TEXTURE_2D, 0, 0);
     m_isFramebufferDiscarded = true;
 
     // Damage tracker needs a full reset every time framebuffer is discarded.
@@ -1337,12 +1241,16 @@ void LayerRendererChromium::ensureFramebuffer()
     if (!m_capabilities.usingDiscardFramebuffer)
         return;
 
-    Extensions3D* extensions = m_context->getExtensions();
-    Extensions3DChromium* extensions3DChromium = static_cast<Extensions3DChromium*>(extensions);
-    extensions3DChromium->ensureFramebufferCHROMIUM();
+    m_context->ensureFramebufferCHROMIUM();
     m_isFramebufferDiscarded = false;
 }
 
+void LayerRendererChromium::onContextLost()
+{
+    m_client->didLoseContext();
+}
+
+
 void LayerRendererChromium::getFramebufferPixels(void *pixels, const IntRect& rect)
 {
     ASSERT(rect.maxX() <= viewportWidth() && rect.maxY() <= viewportHeight());
@@ -1356,7 +1264,6 @@ void LayerRendererChromium::getFramebufferPixels(void *pixels, const IntRect& re
 
     Platform3DObject temporaryTexture = NullPlatform3DObject;
     Platform3DObject temporaryFBO = NullPlatform3DObject;
-    GraphicsContext3D* context = m_context.get();
 
     if (doWorkaround) {
         // On Mac OS X 10.7, calling glReadPixels against an FBO whose color attachment is an
@@ -1364,31 +1271,31 @@ void LayerRendererChromium::getFramebufferPixels(void *pixels, const IntRect& re
         // different OpenGL contexts. It is believed that this is the root cause of top crasher
         // http://crbug.com/99393. <rdar://problem/10949687>
 
-        temporaryTexture = context->createTexture();
-        GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, temporaryTexture));
-        GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
-        GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
-        GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
-        GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
+        temporaryTexture = m_context->createTexture();
+        GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, temporaryTexture));
+        GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
+        GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
+        GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
+        GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
         // Copy the contents of the current (IOSurface-backed) framebuffer into a temporary texture.
-        GLC(context, context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 0, 0, rect.maxX(), rect.maxY(), 0));
-        temporaryFBO = context->createFramebuffer();
+        GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 0, 0, rect.maxX(), rect.maxY(), 0));
+        temporaryFBO = m_context->createFramebuffer();
         // Attach this texture to an FBO, and perform the readback from that FBO.
-        GLC(context, context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, temporaryFBO));
-        GLC(context, context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, temporaryTexture, 0));
+        GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, temporaryFBO));
+        GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, temporaryTexture, 0));
 
-        ASSERT(context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE);
+        ASSERT(m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE);
     }
 
-    GLC(context, context->readPixels(rect.x(), rect.y(), rect.width(), rect.height(),
+    GLC(m_context, m_context->readPixels(rect.x(), rect.y(), rect.width(), rect.height(),
                                      GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, pixels));
 
     if (doWorkaround) {
         // Clean up.
-        GLC(context, context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0));
-        GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0));
-        GLC(context, context->deleteFramebuffer(temporaryFBO));
-        GLC(context, context->deleteTexture(temporaryTexture));
+        GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0));
+        GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0));
+        GLC(m_context, m_context->deleteFramebuffer(temporaryFBO));
+        GLC(m_context, m_context->deleteTexture(temporaryTexture));
     }
 
     if (!m_visible) {
@@ -1405,8 +1312,9 @@ bool LayerRendererChromium::getFramebufferTexture(ManagedTexture* texture, const
     if (!texture->reserve(deviceRect.size(), GraphicsContext3D::RGB))
         return false;
 
-    RefPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(m_context);
-    texture->bindTexture(ccContext.get(), m_implTextureAllocator.get());
+    if (!texture->textureId())
+        texture->allocate(m_implTextureAllocator.get());
+    GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, texture->textureId()));
     GLC(m_context, m_context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, texture->format(),
                                              deviceRect.x(), deviceRect.y(), deviceRect.width(), deviceRect.height(), 0));
     return true;
@@ -1446,8 +1354,9 @@ bool LayerRendererChromium::bindFramebufferToTexture(ManagedTexture* texture, co
 {
     GLC(m_context, m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_offscreenFramebufferId));
 
-    RefPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(m_context);
-    texture->framebufferTexture2D(ccContext.get(), m_implTextureAllocator.get());
+    if (!texture->textureId())
+        texture->allocate(m_implTextureAllocator.get());
+    GLC(m_context, m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, texture->textureId(), 0));
 
 #if !defined ( NDEBUG )
     if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
@@ -1512,23 +1421,23 @@ bool LayerRendererChromium::initializeSharedObjects()
 
     // We will always need these programs to render, so create the programs eagerly so that the shader compilation can
     // start while we do other work. Other programs are created lazily on first access.
-    m_sharedGeometry = adoptPtr(new GeometryBinding(m_context.get()));
-    m_renderPassProgram = adoptPtr(new RenderPassProgram(m_context.get()));
-    m_tileProgram = adoptPtr(new TileProgram(m_context.get()));
-    m_tileProgramOpaque = adoptPtr(new TileProgramOpaque(m_context.get()));
+    m_sharedGeometry = adoptPtr(new GeometryBinding(m_context));
+    m_renderPassProgram = adoptPtr(new RenderPassProgram(m_context));
+    m_tileProgram = adoptPtr(new TileProgram(m_context));
+    m_tileProgramOpaque = adoptPtr(new TileProgramOpaque(m_context));
 
     GLC(m_context, m_context->flush());
 
     m_implTextureManager = TextureManager::create(TextureManager::highLimitBytes(viewportSize()),
                                                   TextureManager::reclaimLimitBytes(viewportSize()),
                                                   m_capabilities.maxTextureSize);
-    m_textureCopier = AcceleratedTextureCopier::create(m_context.get());
+    m_textureCopier = AcceleratedTextureCopier::create(m_context);
     if (m_textureUploaderSetting == ThrottledUploader)
-        m_textureUploader = ThrottledTextureUploader::create(m_context.get());
+        m_textureUploader = ThrottledTextureUploader::create(m_context);
     else
         m_textureUploader = UnthrottledTextureUploader::create();
-    m_contentsTextureAllocator = TrackingTextureAllocator::create(m_context.get());
-    m_implTextureAllocator = TrackingTextureAllocator::create(m_context.get());
+    m_contentsTextureAllocator = TrackingTextureAllocator::create(m_context);
+    m_implTextureAllocator = TrackingTextureAllocator::create(m_context);
     if (m_capabilities.usingTextureUsageHint)
         m_implTextureAllocator->setTextureUsageHint(TrackingTextureAllocator::FramebufferAttachment);
     if (m_capabilities.usingTextureStorageExtension) {
@@ -1542,10 +1451,10 @@ bool LayerRendererChromium::initializeSharedObjects()
 const LayerRendererChromium::TileCheckerboardProgram* LayerRendererChromium::tileCheckerboardProgram()
 {
     if (!m_tileCheckerboardProgram)
-        m_tileCheckerboardProgram = adoptPtr(new TileCheckerboardProgram(m_context.get()));
+        m_tileCheckerboardProgram = adoptPtr(new TileCheckerboardProgram(m_context));
     if (!m_tileCheckerboardProgram->initialized()) {
         TRACE_EVENT("LayerRendererChromium::checkerboardProgram::initalize", this, 0);
-        m_tileCheckerboardProgram->initialize(m_context.get());
+        m_tileCheckerboardProgram->initialize(m_context);
     }
     return m_tileCheckerboardProgram.get();
 }
@@ -1553,10 +1462,10 @@ const LayerRendererChromium::TileCheckerboardProgram* LayerRendererChromium::til
 const LayerRendererChromium::SolidColorProgram* LayerRendererChromium::solidColorProgram()
 {
     if (!m_solidColorProgram)
-        m_solidColorProgram = adoptPtr(new SolidColorProgram(m_context.get()));
+        m_solidColorProgram = adoptPtr(new SolidColorProgram(m_context));
     if (!m_solidColorProgram->initialized()) {
         TRACE_EVENT("LayerRendererChromium::solidColorProgram::initialize", this, 0);
-        m_solidColorProgram->initialize(m_context.get());
+        m_solidColorProgram->initialize(m_context);
     }
     return m_solidColorProgram.get();
 }
@@ -1564,10 +1473,10 @@ const LayerRendererChromium::SolidColorProgram* LayerRendererChromium::solidColo
 const LayerRendererChromium::HeadsUpDisplayProgram* LayerRendererChromium::headsUpDisplayProgram()
 {
     if (!m_headsUpDisplayProgram)
-        m_headsUpDisplayProgram = adoptPtr(new HeadsUpDisplayProgram(m_context.get()));
+        m_headsUpDisplayProgram = adoptPtr(new HeadsUpDisplayProgram(m_context));
     if (!m_headsUpDisplayProgram->initialized()) {
         TRACE_EVENT("LayerRendererChromium::headsUpDisplayProgram::initialize", this, 0);
-        m_headsUpDisplayProgram->initialize(m_context.get());
+        m_headsUpDisplayProgram->initialize(m_context);
     }
     return m_headsUpDisplayProgram.get();
 }
@@ -1577,7 +1486,7 @@ const LayerRendererChromium::RenderPassProgram* LayerRendererChromium::renderPas
     ASSERT(m_renderPassProgram);
     if (!m_renderPassProgram->initialized()) {
         TRACE_EVENT("LayerRendererChromium::renderPassProgram::initialize", this, 0);
-        m_renderPassProgram->initialize(m_context.get());
+        m_renderPassProgram->initialize(m_context);
     }
     return m_renderPassProgram.get();
 }
@@ -1585,10 +1494,10 @@ const LayerRendererChromium::RenderPassProgram* LayerRendererChromium::renderPas
 const LayerRendererChromium::RenderPassProgramAA* LayerRendererChromium::renderPassProgramAA()
 {
     if (!m_renderPassProgramAA)
-        m_renderPassProgramAA = adoptPtr(new RenderPassProgramAA(m_context.get()));
+        m_renderPassProgramAA = adoptPtr(new RenderPassProgramAA(m_context));
     if (!m_renderPassProgramAA->initialized()) {
         TRACE_EVENT("LayerRendererChromium::renderPassProgramAA::initialize", this, 0);
-        m_renderPassProgramAA->initialize(m_context.get());
+        m_renderPassProgramAA->initialize(m_context);
     }
     return m_renderPassProgramAA.get();
 }
@@ -1596,10 +1505,10 @@ const LayerRendererChromium::RenderPassProgramAA* LayerRendererChromium::renderP
 const LayerRendererChromium::RenderPassMaskProgram* LayerRendererChromium::renderPassMaskProgram()
 {
     if (!m_renderPassMaskProgram)
-        m_renderPassMaskProgram = adoptPtr(new RenderPassMaskProgram(m_context.get()));
+        m_renderPassMaskProgram = adoptPtr(new RenderPassMaskProgram(m_context));
     if (!m_renderPassMaskProgram->initialized()) {
         TRACE_EVENT("LayerRendererChromium::renderPassMaskProgram::initialize", this, 0);
-        m_renderPassMaskProgram->initialize(m_context.get());
+        m_renderPassMaskProgram->initialize(m_context);
     }
     return m_renderPassMaskProgram.get();
 }
@@ -1607,10 +1516,10 @@ const LayerRendererChromium::RenderPassMaskProgram* LayerRendererChromium::rende
 const LayerRendererChromium::RenderPassMaskProgramAA* LayerRendererChromium::renderPassMaskProgramAA()
 {
     if (!m_renderPassMaskProgramAA)
-        m_renderPassMaskProgramAA = adoptPtr(new RenderPassMaskProgramAA(m_context.get()));
+        m_renderPassMaskProgramAA = adoptPtr(new RenderPassMaskProgramAA(m_context));
     if (!m_renderPassMaskProgramAA->initialized()) {
         TRACE_EVENT("LayerRendererChromium::renderPassMaskProgramAA::initialize", this, 0);
-        m_renderPassMaskProgramAA->initialize(m_context.get());
+        m_renderPassMaskProgramAA->initialize(m_context);
     }
     return m_renderPassMaskProgramAA.get();
 }
@@ -1620,7 +1529,7 @@ const LayerRendererChromium::TileProgram* LayerRendererChromium::tileProgram()
     ASSERT(m_tileProgram);
     if (!m_tileProgram->initialized()) {
         TRACE_EVENT("LayerRendererChromium::tileProgram::initialize", this, 0);
-        m_tileProgram->initialize(m_context.get());
+        m_tileProgram->initialize(m_context);
     }
     return m_tileProgram.get();
 }
@@ -1630,7 +1539,7 @@ const LayerRendererChromium::TileProgramOpaque* LayerRendererChromium::tileProgr
     ASSERT(m_tileProgramOpaque);
     if (!m_tileProgramOpaque->initialized()) {
         TRACE_EVENT("LayerRendererChromium::tileProgramOpaque::initialize", this, 0);
-        m_tileProgramOpaque->initialize(m_context.get());
+        m_tileProgramOpaque->initialize(m_context);
     }
     return m_tileProgramOpaque.get();
 }
@@ -1638,10 +1547,10 @@ const LayerRendererChromium::TileProgramOpaque* LayerRendererChromium::tileProgr
 const LayerRendererChromium::TileProgramAA* LayerRendererChromium::tileProgramAA()
 {
     if (!m_tileProgramAA)
-        m_tileProgramAA = adoptPtr(new TileProgramAA(m_context.get()));
+        m_tileProgramAA = adoptPtr(new TileProgramAA(m_context));
     if (!m_tileProgramAA->initialized()) {
         TRACE_EVENT("LayerRendererChromium::tileProgramAA::initialize", this, 0);
-        m_tileProgramAA->initialize(m_context.get());
+        m_tileProgramAA->initialize(m_context);
     }
     return m_tileProgramAA.get();
 }
@@ -1649,10 +1558,10 @@ const LayerRendererChromium::TileProgramAA* LayerRendererChromium::tileProgramAA
 const LayerRendererChromium::TileProgramSwizzle* LayerRendererChromium::tileProgramSwizzle()
 {
     if (!m_tileProgramSwizzle)
-        m_tileProgramSwizzle = adoptPtr(new TileProgramSwizzle(m_context.get()));
+        m_tileProgramSwizzle = adoptPtr(new TileProgramSwizzle(m_context));
     if (!m_tileProgramSwizzle->initialized()) {
         TRACE_EVENT("LayerRendererChromium::tileProgramSwizzle::initialize", this, 0);
-        m_tileProgramSwizzle->initialize(m_context.get());
+        m_tileProgramSwizzle->initialize(m_context);
     }
     return m_tileProgramSwizzle.get();
 }
@@ -1660,10 +1569,10 @@ const LayerRendererChromium::TileProgramSwizzle* LayerRendererChromium::tileProg
 const LayerRendererChromium::TileProgramSwizzleOpaque* LayerRendererChromium::tileProgramSwizzleOpaque()
 {
     if (!m_tileProgramSwizzleOpaque)
-        m_tileProgramSwizzleOpaque = adoptPtr(new TileProgramSwizzleOpaque(m_context.get()));
+        m_tileProgramSwizzleOpaque = adoptPtr(new TileProgramSwizzleOpaque(m_context));
     if (!m_tileProgramSwizzleOpaque->initialized()) {
         TRACE_EVENT("LayerRendererChromium::tileProgramSwizzleOpaque::initialize", this, 0);
-        m_tileProgramSwizzleOpaque->initialize(m_context.get());
+        m_tileProgramSwizzleOpaque->initialize(m_context);
     }
     return m_tileProgramSwizzleOpaque.get();
 }
@@ -1671,10 +1580,10 @@ const LayerRendererChromium::TileProgramSwizzleOpaque* LayerRendererChromium::ti
 const LayerRendererChromium::TileProgramSwizzleAA* LayerRendererChromium::tileProgramSwizzleAA()
 {
     if (!m_tileProgramSwizzleAA)
-        m_tileProgramSwizzleAA = adoptPtr(new TileProgramSwizzleAA(m_context.get()));
+        m_tileProgramSwizzleAA = adoptPtr(new TileProgramSwizzleAA(m_context));
     if (!m_tileProgramSwizzleAA->initialized()) {
         TRACE_EVENT("LayerRendererChromium::tileProgramSwizzleAA::initialize", this, 0);
-        m_tileProgramSwizzleAA->initialize(m_context.get());
+        m_tileProgramSwizzleAA->initialize(m_context);
     }
     return m_tileProgramSwizzleAA.get();
 }
@@ -1682,10 +1591,10 @@ const LayerRendererChromium::TileProgramSwizzleAA* LayerRendererChromium::tilePr
 const LayerRendererChromium::TextureProgram* LayerRendererChromium::textureProgram()
 {
     if (!m_textureProgram)
-        m_textureProgram = adoptPtr(new TextureProgram(m_context.get()));
+        m_textureProgram = adoptPtr(new TextureProgram(m_context));
     if (!m_textureProgram->initialized()) {
         TRACE_EVENT("LayerRendererChromium::textureProgram::initialize", this, 0);
-        m_textureProgram->initialize(m_context.get());
+        m_textureProgram->initialize(m_context);
     }
     return m_textureProgram.get();
 }
@@ -1693,10 +1602,10 @@ const LayerRendererChromium::TextureProgram* LayerRendererChromium::textureProgr
 const LayerRendererChromium::TextureProgramFlip* LayerRendererChromium::textureProgramFlip()
 {
     if (!m_textureProgramFlip)
-        m_textureProgramFlip = adoptPtr(new TextureProgramFlip(m_context.get()));
+        m_textureProgramFlip = adoptPtr(new TextureProgramFlip(m_context));
     if (!m_textureProgramFlip->initialized()) {
         TRACE_EVENT("LayerRendererChromium::textureProgramFlip::initialize", this, 0);
-        m_textureProgramFlip->initialize(m_context.get());
+        m_textureProgramFlip->initialize(m_context);
     }
     return m_textureProgramFlip.get();
 }
@@ -1704,10 +1613,10 @@ const LayerRendererChromium::TextureProgramFlip* LayerRendererChromium::textureP
 const LayerRendererChromium::TextureIOSurfaceProgram* LayerRendererChromium::textureIOSurfaceProgram()
 {
     if (!m_textureIOSurfaceProgram)
-        m_textureIOSurfaceProgram = adoptPtr(new TextureIOSurfaceProgram(m_context.get()));
+        m_textureIOSurfaceProgram = adoptPtr(new TextureIOSurfaceProgram(m_context));
     if (!m_textureIOSurfaceProgram->initialized()) {
         TRACE_EVENT("LayerRendererChromium::textureIOSurfaceProgram::initialize", this, 0);
-        m_textureIOSurfaceProgram->initialize(m_context.get());
+        m_textureIOSurfaceProgram->initialize(m_context);
     }
     return m_textureIOSurfaceProgram.get();
 }
@@ -1715,10 +1624,10 @@ const LayerRendererChromium::TextureIOSurfaceProgram* LayerRendererChromium::tex
 const LayerRendererChromium::VideoYUVProgram* LayerRendererChromium::videoYUVProgram()
 {
     if (!m_videoYUVProgram)
-        m_videoYUVProgram = adoptPtr(new VideoYUVProgram(m_context.get()));
+        m_videoYUVProgram = adoptPtr(new VideoYUVProgram(m_context));
     if (!m_videoYUVProgram->initialized()) {
         TRACE_EVENT("LayerRendererChromium::videoYUVProgram::initialize", this, 0);
-        m_videoYUVProgram->initialize(m_context.get());
+        m_videoYUVProgram->initialize(m_context);
     }
     return m_videoYUVProgram.get();
 }
@@ -1726,10 +1635,10 @@ const LayerRendererChromium::VideoYUVProgram* LayerRendererChromium::videoYUVPro
 const LayerRendererChromium::VideoStreamTextureProgram* LayerRendererChromium::videoStreamTextureProgram()
 {
     if (!m_videoStreamTextureProgram)
-        m_videoStreamTextureProgram = adoptPtr(new VideoStreamTextureProgram(m_context.get()));
+        m_videoStreamTextureProgram = adoptPtr(new VideoStreamTextureProgram(m_context));
     if (!m_videoStreamTextureProgram->initialized()) {
         TRACE_EVENT("LayerRendererChromium::streamTextureProgram::initialize", this, 0);
-        m_videoStreamTextureProgram->initialize(m_context.get());
+        m_videoStreamTextureProgram->initialize(m_context);
     }
     return m_videoStreamTextureProgram.get();
 }
@@ -1741,46 +1650,46 @@ void LayerRendererChromium::cleanupSharedObjects()
     m_sharedGeometry.clear();
 
     if (m_tileProgram)
-        m_tileProgram->cleanup(m_context.get());
+        m_tileProgram->cleanup(m_context);
     if (m_tileProgramOpaque)
-        m_tileProgramOpaque->cleanup(m_context.get());
+        m_tileProgramOpaque->cleanup(m_context);
     if (m_tileProgramSwizzle)
-        m_tileProgramSwizzle->cleanup(m_context.get());
+        m_tileProgramSwizzle->cleanup(m_context);
     if (m_tileProgramSwizzleOpaque)
-        m_tileProgramSwizzleOpaque->cleanup(m_context.get());
+        m_tileProgramSwizzleOpaque->cleanup(m_context);
     if (m_tileProgramAA)
-        m_tileProgramAA->cleanup(m_context.get());
+        m_tileProgramAA->cleanup(m_context);
     if (m_tileProgramSwizzleAA)
-        m_tileProgramSwizzleAA->cleanup(m_context.get());
+        m_tileProgramSwizzleAA->cleanup(m_context);
     if (m_tileCheckerboardProgram)
-        m_tileCheckerboardProgram->cleanup(m_context.get());
+        m_tileCheckerboardProgram->cleanup(m_context);
 
     if (m_renderPassMaskProgram)
-        m_renderPassMaskProgram->cleanup(m_context.get());
+        m_renderPassMaskProgram->cleanup(m_context);
     if (m_renderPassProgram)
-        m_renderPassProgram->cleanup(m_context.get());
+        m_renderPassProgram->cleanup(m_context);
     if (m_renderPassMaskProgramAA)
-        m_renderPassMaskProgramAA->cleanup(m_context.get());
+        m_renderPassMaskProgramAA->cleanup(m_context);
     if (m_renderPassProgramAA)
-        m_renderPassProgramAA->cleanup(m_context.get());
+        m_renderPassProgramAA->cleanup(m_context);
 
     if (m_textureProgram)
-        m_textureProgram->cleanup(m_context.get());
+        m_textureProgram->cleanup(m_context);
     if (m_textureProgramFlip)
-        m_textureProgramFlip->cleanup(m_context.get());
+        m_textureProgramFlip->cleanup(m_context);
     if (m_textureIOSurfaceProgram)
-        m_textureIOSurfaceProgram->cleanup(m_context.get());
+        m_textureIOSurfaceProgram->cleanup(m_context);
 
     if (m_videoYUVProgram)
-        m_videoYUVProgram->cleanup(m_context.get());
+        m_videoYUVProgram->cleanup(m_context);
     if (m_videoStreamTextureProgram)
-        m_videoStreamTextureProgram->cleanup(m_context.get());
+        m_videoStreamTextureProgram->cleanup(m_context);
 
     if (m_solidColorProgram)
-        m_solidColorProgram->cleanup(m_context.get());
+        m_solidColorProgram->cleanup(m_context);
 
     if (m_headsUpDisplayProgram)
-        m_headsUpDisplayProgram->cleanup(m_context.get());
+        m_headsUpDisplayProgram->cleanup(m_context);
 
     if (m_offscreenFramebufferId)
         GLC(m_context, m_context->deleteFramebuffer(m_offscreenFramebufferId));
@@ -1793,7 +1702,7 @@ void LayerRendererChromium::cleanupSharedObjects()
 
 bool LayerRendererChromium::isContextLost()
 {
-    return (m_context.get()->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR);
+    return (m_context->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR);
 }
 
 } // namespace WebCore
index f7ccb65..34254b0 100644 (file)
 #include "cc/CCRenderer.h"
 #include <wtf/PassOwnPtr.h>
 
+namespace WebKit {
+class WebGraphicsContext3D;
+}
+
 namespace WebCore {
 
 class CCCheckerboardDrawQuad;
@@ -53,22 +57,23 @@ class CCTextureDrawQuad;
 class CCTileDrawQuad;
 class CCYUVVideoDrawQuad;
 class GeometryBinding;
-class GraphicsContext3D;
-class LayerRendererSwapBuffersCompleteCallbackAdapter;
 class ManagedTexture;
 class ScopedEnsureFramebufferAllocation;
 
 // Class that handles drawing of composited render layers using GL.
-class LayerRendererChromium : public CCRenderer {
+class LayerRendererChromium : public CCRenderer,
+                              public WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM,
+                              public WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM ,
+                              public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback {
     WTF_MAKE_NONCOPYABLE(LayerRendererChromium);
 public:
-    static PassOwnPtr<LayerRendererChromium> create(CCRendererClient*, PassRefPtr<GraphicsContext3D>, TextureUploaderOption);
+    static PassOwnPtr<LayerRendererChromium> create(CCRendererClient*, WebKit::WebGraphicsContext3D*, TextureUploaderOption);
 
     virtual ~LayerRendererChromium();
 
     virtual const LayerRendererCapabilities& capabilities() const OVERRIDE { return m_capabilities; }
 
-    GraphicsContext3D* context();
+    WebKit::WebGraphicsContext3D* context();
 
     virtual void viewportChanged() OVERRIDE;
 
@@ -88,7 +93,7 @@ public:
     // puts backbuffer onscreen
     virtual bool swapBuffers(const IntRect& subBuffer) OVERRIDE;
 
-    static void debugGLCall(GraphicsContext3D*, const char* command, const char* file, int line);
+    static void debugGLCall(WebKit::WebGraphicsContext3D*, const char* command, const char* file, int line);
 
     const GeometryBinding* sharedGeometry() const { return m_sharedGeometry.get(); }
 
@@ -111,14 +116,11 @@ public:
                           float width, float height, float opacity, const FloatQuad&,
                           int matrixLocation, int alphaLocation, int quadLocation);
     void copyTextureToFramebuffer(int textureId, const IntSize& bounds, const WebKit::WebTransformationMatrix& drawMatrix);
-    void setGpuMemoryAllocation(Extensions3DChromium::GpuMemoryAllocationCHROMIUM);
 
 protected:
-    void discardFramebuffer();
-    void ensureFramebuffer();
-    bool isFramebufferDiscarded() const { return m_isFramebufferDiscarded; }
+    LayerRendererChromium(CCRendererClient*, WebKit::WebGraphicsContext3D*, TextureUploaderOption);
 
-    LayerRendererChromium(CCRendererClient*, PassRefPtr<GraphicsContext3D>, TextureUploaderOption);
+    bool isFramebufferDiscarded() const { return m_isFramebufferDiscarded; }
     bool initialize();
 
 private:
@@ -154,8 +156,17 @@ private:
     bool initializeSharedObjects();
     void cleanupSharedObjects();
 
-    friend class LayerRendererSwapBuffersCompleteCallbackAdapter;
-    void onSwapBuffersComplete();
+    // WebKit::WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM implementation.
+    virtual void onSwapBuffersComplete() OVERRIDE;
+
+    // WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM implementation.
+    virtual void onMemoryAllocationChanged(WebKit::WebGraphicsMemoryAllocation) OVERRIDE;
+    void onMemoryAllocationChangedOnImplThread(WebKit::WebGraphicsMemoryAllocation);
+    void discardFramebuffer();
+    void ensureFramebuffer();
+
+    // WebGraphicsContext3D::WebGraphicsContextLostCallback implementation.
+    virtual void onContextLost() OVERRIDE;
 
     LayerRendererCapabilities m_capabilities;
 
@@ -252,7 +263,7 @@ private:
     OwnPtr<TrackingTextureAllocator> m_contentsTextureAllocator;
     OwnPtr<TrackingTextureAllocator> m_implTextureAllocator;
 
-    RefPtr<GraphicsContext3D> m_context;
+    WebKit::WebGraphicsContext3D* m_context;
 
     const CCRenderPass* m_defaultRenderPass;
 
index 4bea904..4aa9965 100644 (file)
@@ -89,7 +89,7 @@ void LayerTextureSubImage::uploadWithTexSubImage(const uint8_t* image, const Int
         pixelSource = &m_subImage[0];
     }
 
-    GraphicsContext3D* context3d = context->context3D();
+    WebKit::WebGraphicsContext3D* context3d = context->context3D();
     if (!context3d) {
         // FIXME: Implement this path for software compositing.
         return;
@@ -102,7 +102,7 @@ void LayerTextureSubImage::uploadWithMapTexSubImage(const uint8_t* image, const
                                                     GC3Denum format, CCGraphicsContext* context)
 {
     TRACE_EVENT("LayerTextureSubImage::uploadWithMapTexSubImage", this, 0);
-    GraphicsContext3D* context3d = context->context3D();
+    WebKit::WebGraphicsContext3D* context3d = context->context3D();
     if (!context3d) {
         // FIXME: Implement this path for software compositing.
         return;
@@ -112,8 +112,7 @@ void LayerTextureSubImage::uploadWithMapTexSubImage(const uint8_t* image, const
     IntPoint offset(sourceRect.x() - imageRect.x(), sourceRect.y() - imageRect.y());
 
     // Upload tile data via a mapped transfer buffer
-    Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context3d->getExtensions());
-    uint8_t* pixelDest = static_cast<uint8_t*>(extensions->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), format, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY));
+    uint8_t* pixelDest = static_cast<uint8_t*>(context3d->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), format, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY));
 
     if (!pixelDest) {
         uploadWithTexSubImage(image, imageRect, sourceRect, destRect, format, context);
@@ -137,7 +136,7 @@ void LayerTextureSubImage::uploadWithMapTexSubImage(const uint8_t* image, const
                    &image[4 * (offset.x() + (offset.y() + row) * imageRect.width())],
                    destRect.width() * componentsPerPixel * bytesPerComponent);
     }
-    GLC(context3d, extensions->unmapTexSubImage2DCHROMIUM(pixelDest));
+    GLC(context3d, context3d->unmapTexSubImage2DCHROMIUM(pixelDest));
 }
 
 } // namespace WebCore
index b06aaa9..8cc0c2f 100644 (file)
@@ -30,6 +30,9 @@
 
 #include "GraphicsContext3D.h"
 #include "cc/CCGraphicsContext.h"
+#include <public/WebGraphicsContext3D.h>
+
+using WebKit::WebGraphicsContext3D;
 
 namespace WebCore {
 
@@ -120,7 +123,7 @@ void ManagedTexture::allocate(TextureAllocator* allocator)
 void ManagedTexture::bindTexture(CCGraphicsContext* context, TextureAllocator* allocator)
 {
     allocate(allocator);
-    GraphicsContext3D* context3d = context->context3D();
+    WebGraphicsContext3D* context3d = context->context3D();
     if (!context3d) {
         // FIXME: Implement this path for software compositing.
         return;
@@ -131,7 +134,7 @@ void ManagedTexture::bindTexture(CCGraphicsContext* context, TextureAllocator* a
 void ManagedTexture::framebufferTexture2D(CCGraphicsContext* context, TextureAllocator* allocator)
 {
     allocate(allocator);
-    GraphicsContext3D* context3d = context->context3D();
+    WebGraphicsContext3D* context3d = context->context3D();
     if (!context3d) {
         // FIXME: Implement this path for software compositing.
         return;
index ab6545d..a855215 100644 (file)
@@ -29,6 +29,7 @@
 #include "Extensions3D.h"
 #include "GraphicsContext3D.h"
 #include "SkTypes.h" 
+#include <public/WebGraphicsContext3D.h>
 
 namespace WebCore {
 
@@ -40,14 +41,14 @@ public:
     }
 
     // Returns the most efficient texture format for this platform.
-    static GC3Denum bestTextureFormat(GraphicsContext3D* context)
+    static GC3Denum bestTextureFormat(WebKit::WebGraphicsContext3D* context, bool supportsBGRA8888)
     {
         GC3Denum textureFormat = GraphicsContext3D::RGBA;
         switch (format()) {
         case GraphicsContext3D::SourceFormatRGBA8:
             break;
         case GraphicsContext3D::SourceFormatBGRA8:
-            if (context->getExtensions()->supports("GL_EXT_texture_format_BGRA8888"))
+            if (supportsBGRA8888)
                 textureFormat = Extensions3D::BGRA_EXT;
             break;
         default:
index 376434e..6afbb34 100644 (file)
 
 #include "ProgramBinding.h"
 
-#include "Extensions3D.h"
 #include "GeometryBinding.h"
-#include "GraphicsContext.h"
 #include "GraphicsContext3D.h"
 #include "LayerRendererChromium.h"
 #include "TraceEvent.h"
+#include <public/WebGraphicsContext3D.h>
+
+using WebKit::WebGraphicsContext3D;
 
 namespace WebCore {
 
@@ -51,19 +52,19 @@ ProgramBindingBase::~ProgramBindingBase()
     ASSERT(!m_initialized);
 }
 
-static bool contextLost(GraphicsContext3D* context)
+static bool contextLost(WebGraphicsContext3D* context)
 {
-    return (context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR);
+    return (context->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR);
 }
 
 
-void ProgramBindingBase::init(GraphicsContext3D* context, const String& vertexShader, const String& fragmentShader)
+void ProgramBindingBase::init(WebGraphicsContext3D* context, const String& vertexShader, const String& fragmentShader)
 {
     m_program = createShaderProgram(context, vertexShader, fragmentShader);
     ASSERT(m_program || contextLost(context));
 }
 
-void ProgramBindingBase::cleanup(GraphicsContext3D* context)
+void ProgramBindingBase::cleanup(WebGraphicsContext3D* context)
 {
     m_initialized = false;
     if (!m_program)
@@ -74,13 +75,13 @@ void ProgramBindingBase::cleanup(GraphicsContext3D* context)
     m_program = 0;
 }
 
-unsigned ProgramBindingBase::loadShader(GraphicsContext3D* context, unsigned type, const String& shaderSource)
+unsigned ProgramBindingBase::loadShader(WebGraphicsContext3D* context, unsigned type, const String& shaderSource)
 {
     unsigned shader = context->createShader(type);
     if (!shader)
         return 0;
     String sourceString(shaderSource);
-    GLC(context, context->shaderSource(shader, sourceString));
+    GLC(context, context->shaderSource(shader, sourceString.utf8().data()));
     GLC(context, context->compileShader(shader));
 #ifndef NDEBUG
     int compiled = 0;
@@ -93,9 +94,9 @@ unsigned ProgramBindingBase::loadShader(GraphicsContext3D* context, unsigned typ
     return shader;
 }
 
-unsigned ProgramBindingBase::createShaderProgram(GraphicsContext3D* context, const String& vertexShaderSource, const String& fragmentShaderSource)
+unsigned ProgramBindingBase::createShaderProgram(WebGraphicsContext3D* context, const String& vertexShaderSource, const String& fragmentShaderSource)
 {
-    TRACE_EVENT("ProgramBindingBase::createShaderProgram", this, 0);
+    TRACE_EVENT0("cc", "ProgramBindingBase::createShaderProgram");
     unsigned vertexShader = loadShader(context, GraphicsContext3D::VERTEX_SHADER, vertexShaderSource);
     if (!vertexShader) {
         if (!contextLost(context))
index aea2856..39048f9 100644 (file)
 
 #if USE(ACCELERATED_COMPOSITING)
 
-#include "PlatformString.h"
+#include <wtf/text/WTFString.h>
 
-namespace WebCore {
+namespace WebKit {
+class WebGraphicsContext3D;
+}
 
-class GraphicsContext3D;
+namespace WebCore {
 
 class ProgramBindingBase {
 public:
     ProgramBindingBase();
     ~ProgramBindingBase();
 
-    void init(GraphicsContext3D*, const String& vertexShader, const String& fragmentShader);
-    void cleanup(GraphicsContext3D*);
+    void init(WebKit::WebGraphicsContext3D*, const String& vertexShader, const String& fragmentShader);
+    void cleanup(WebKit::WebGraphicsContext3D*);
 
     unsigned program() const { ASSERT(m_initialized); return m_program; }
     bool initialized() const { return m_initialized; }
 
 protected:
 
-    unsigned loadShader(GraphicsContext3D*, unsigned type, const String& shaderSource);
-    unsigned createShaderProgram(GraphicsContext3D*, const String& vertexShaderSource, const String& fragmentShaderSource);
+    unsigned loadShader(WebKit::WebGraphicsContext3D*, unsigned type, const String& shaderSource);
+    unsigned createShaderProgram(WebKit::WebGraphicsContext3D*, const String& vertexShaderSource, const String& fragmentShaderSource);
 
     unsigned m_program;
     bool m_initialized;
@@ -57,12 +59,12 @@ protected:
 template<class VertexShader, class FragmentShader>
 class ProgramBinding : public ProgramBindingBase {
 public:
-    explicit ProgramBinding(GraphicsContext3D* context)
+    explicit ProgramBinding(WebKit::WebGraphicsContext3D* context)
     {
         ProgramBindingBase::init(context, m_vertexShader.getShaderString(), m_fragmentShader.getShaderString());
     }
 
-    void initialize(GraphicsContext3D* context)
+    void initialize(WebKit::WebGraphicsContext3D* context)
     {
         ASSERT(context);
         ASSERT(m_program);
index 6ed6f4a..2a140d1 100644 (file)
 
 #include "ShaderChromium.h"
 
-#include "GraphicsContext.h"
-#include "GraphicsContext3D.h"
+#include <public/WebGraphicsContext3D.h>
 
 #define SHADER0(Src) #Src
 #define SHADER(Src) SHADER0(Src)
 
+using WebKit::WebGraphicsContext3D;
+
 namespace WebCore {
 
 VertexShaderPosTex::VertexShaderPosTex()
@@ -42,7 +43,7 @@ VertexShaderPosTex::VertexShaderPosTex()
 {
 }
 
-void VertexShaderPosTex::init(GraphicsContext3D* context, unsigned program)
+void VertexShaderPosTex::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_matrixLocation = context->getUniformLocation(program, "matrix");
     ASSERT(m_matrixLocation != -1);
@@ -70,7 +71,7 @@ VertexShaderPosTexYUVStretch::VertexShaderPosTexYUVStretch()
 {
 }
 
-void VertexShaderPosTexYUVStretch::init(GraphicsContext3D* context, unsigned program)
+void VertexShaderPosTexYUVStretch::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_matrixLocation = context->getUniformLocation(program, "matrix");
     m_yWidthScaleFactorLocation = context->getUniformLocation(program, "y_widthScaleFactor");
@@ -103,7 +104,7 @@ VertexShaderPos::VertexShaderPos()
 {
 }
 
-void VertexShaderPos::init(GraphicsContext3D* context, unsigned program)
+void VertexShaderPos::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_matrixLocation = context->getUniformLocation(program, "matrix");
     ASSERT(m_matrixLocation != -1);
@@ -127,7 +128,7 @@ VertexShaderPosTexTransform::VertexShaderPosTexTransform()
 {
 }
 
-void VertexShaderPosTexTransform::init(GraphicsContext3D* context, unsigned program)
+void VertexShaderPosTexTransform::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_matrixLocation = context->getUniformLocation(program, "matrix");
     m_texTransformLocation = context->getUniformLocation(program, "texTransform");
@@ -169,7 +170,7 @@ String VertexShaderPosTexIdentity::getShaderString() const
     );
 }
 
-void VertexShaderQuad::init(GraphicsContext3D* context, unsigned program)
+void VertexShaderQuad::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_matrixLocation = context->getUniformLocation(program, "matrix");
     m_pointLocation = context->getUniformLocation(program, "point");
@@ -205,7 +206,7 @@ VertexShaderTile::VertexShaderTile()
 {
 }
 
-void VertexShaderTile::init(GraphicsContext3D* context, unsigned program)
+void VertexShaderTile::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_matrixLocation = context->getUniformLocation(program, "matrix");
     m_pointLocation = context->getUniformLocation(program, "point");
@@ -242,7 +243,7 @@ VertexShaderVideoTransform::VertexShaderVideoTransform()
 {
 }
 
-bool VertexShaderVideoTransform::init(GraphicsContext3D* context, unsigned program)
+bool VertexShaderVideoTransform::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_matrixLocation = context->getUniformLocation(program, "matrix");
     m_texMatrixLocation = context->getUniformLocation(program, "texMatrix");
@@ -271,7 +272,7 @@ FragmentTexAlphaBinding::FragmentTexAlphaBinding()
 {
 }
 
-void FragmentTexAlphaBinding::init(GraphicsContext3D* context, unsigned program)
+void FragmentTexAlphaBinding::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_samplerLocation = context->getUniformLocation(program, "s_texture");
     m_alphaLocation = context->getUniformLocation(program, "alpha");
@@ -284,7 +285,7 @@ FragmentTexOpaqueBinding::FragmentTexOpaqueBinding()
 {
 }
 
-void FragmentTexOpaqueBinding::init(GraphicsContext3D* context, unsigned program)
+void FragmentTexOpaqueBinding::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_samplerLocation = context->getUniformLocation(program, "s_texture");
 
@@ -306,7 +307,7 @@ String FragmentShaderRGBATexFlipAlpha::getShaderString() const
     );
 }
 
-bool FragmentShaderOESImageExternal::init(GraphicsContext3D* context, unsigned program)
+bool FragmentShaderOESImageExternal::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_samplerLocation = context->getUniformLocation(program, "s_texture");
 
@@ -436,7 +437,7 @@ FragmentShaderRGBATexAlphaAA::FragmentShaderRGBATexAlphaAA()
 {
 }
 
-void FragmentShaderRGBATexAlphaAA::init(GraphicsContext3D* context, unsigned program)
+void FragmentShaderRGBATexAlphaAA::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_samplerLocation = context->getUniformLocation(program, "s_texture");
     m_alphaLocation = context->getUniformLocation(program, "alpha");
@@ -478,7 +479,7 @@ FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding()
 {
 }
 
-void FragmentTexClampAlphaAABinding::init(GraphicsContext3D* context, unsigned program)
+void FragmentTexClampAlphaAABinding::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_samplerLocation = context->getUniformLocation(program, "s_texture");
     m_alphaLocation = context->getUniformLocation(program, "alpha");
@@ -549,7 +550,7 @@ FragmentShaderRGBATexAlphaMask::FragmentShaderRGBATexAlphaMask()
 {
 }
 
-void FragmentShaderRGBATexAlphaMask::init(GraphicsContext3D* context, unsigned program)
+void FragmentShaderRGBATexAlphaMask::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_samplerLocation = context->getUniformLocation(program, "s_texture");
     m_maskSamplerLocation = context->getUniformLocation(program, "s_mask");
@@ -582,7 +583,7 @@ FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA()
 {
 }
 
-void FragmentShaderRGBATexAlphaMaskAA::init(GraphicsContext3D* context, unsigned program)
+void FragmentShaderRGBATexAlphaMaskAA::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_samplerLocation = context->getUniformLocation(program, "s_texture");
     m_maskSamplerLocation = context->getUniformLocation(program, "s_mask");
@@ -628,7 +629,7 @@ FragmentShaderYUVVideo::FragmentShaderYUVVideo()
 {
 }
 
-void FragmentShaderYUVVideo::init(GraphicsContext3D* context, unsigned program)
+void FragmentShaderYUVVideo::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_yTextureLocation = context->getUniformLocation(program, "y_texture");
     m_uTextureLocation = context->getUniformLocation(program, "u_texture");
@@ -671,7 +672,7 @@ FragmentShaderColor::FragmentShaderColor()
 {
 }
 
-void FragmentShaderColor::init(GraphicsContext3D* context, unsigned program)
+void FragmentShaderColor::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_colorLocation = context->getUniformLocation(program, "color");
     ASSERT(m_colorLocation != -1);
@@ -696,7 +697,7 @@ FragmentShaderCheckerboard::FragmentShaderCheckerboard()
 {
 }
 
-void FragmentShaderCheckerboard::init(GraphicsContext3D* context, unsigned program)
+void FragmentShaderCheckerboard::init(WebGraphicsContext3D* context, unsigned program)
 {
     m_alphaLocation = context->getUniformLocation(program, "alpha");
     m_texTransformLocation = context->getUniformLocation(program, "texTransform");
index 9277ecc..475b789 100644 (file)
 #include "PlatformString.h"
 #include "SkColorPriv.h"
 
-namespace WebCore {
+namespace WebKit {
+class WebGraphicsContext3D;
+}
 
-class GraphicsContext3D;
+namespace WebCore {
 
 class VertexShaderPosTex {
 public:
     VertexShaderPosTex();
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -52,7 +54,7 @@ class VertexShaderPosTexYUVStretch {
 public:
     VertexShaderPosTexYUVStretch();
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -69,7 +71,7 @@ class VertexShaderPos {
 public:
     VertexShaderPos();
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -80,7 +82,7 @@ private:
 
 class VertexShaderPosTexIdentity {
 public:
-    void init(GraphicsContext3D*, unsigned program) { }
+    void init(WebKit::WebGraphicsContext3D*, unsigned program) { }
     String getShaderString() const;
 };
 
@@ -88,7 +90,7 @@ class VertexShaderPosTexTransform {
 public:
     VertexShaderPosTexTransform();
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -103,7 +105,7 @@ class VertexShaderQuad {
 public:
     VertexShaderQuad();
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -118,7 +120,7 @@ class VertexShaderTile {
 public:
     VertexShaderTile();
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -135,7 +137,7 @@ class VertexShaderVideoTransform {
 public:
     VertexShaderVideoTransform();
 
-    bool init(GraphicsContext3D*, unsigned program);
+    bool init(WebKit::WebGraphicsContext3D*, unsigned program);
     String getShaderString() const;
 
     int matrixLocation() const { return m_matrixLocation; }
@@ -150,7 +152,7 @@ class FragmentTexAlphaBinding {
 public:
     FragmentTexAlphaBinding();
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     int alphaLocation() const { return m_alphaLocation; }
     int edgeLocation() const { return -1; }
     int fragmentTexTransformLocation() const { return -1; }
@@ -165,7 +167,7 @@ class FragmentTexOpaqueBinding {
 public:
     FragmentTexOpaqueBinding();
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     int alphaLocation() const { return -1; }
     int edgeLocation() const { return -1; }
     int fragmentTexTransformLocation() const { return -1; }
@@ -221,7 +223,7 @@ public:
 class FragmentShaderOESImageExternal : public FragmentTexAlphaBinding {
 public:
     String getShaderString() const;
-    bool init(GraphicsContext3D*, unsigned program);
+    bool init(WebKit::WebGraphicsContext3D*, unsigned program);
 private:
     int m_samplerLocation;
 };
@@ -230,7 +232,7 @@ class FragmentShaderRGBATexAlphaAA {
 public:
     FragmentShaderRGBATexAlphaAA();
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     String getShaderString() const;
 
     int alphaLocation() const { return m_alphaLocation; }
@@ -247,7 +249,7 @@ class FragmentTexClampAlphaAABinding {
 public:
     FragmentTexClampAlphaAABinding();
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     int alphaLocation() const { return m_alphaLocation; }
     int samplerLocation() const { return m_samplerLocation; }
     int fragmentTexTransformLocation() const { return m_fragmentTexTransformLocation; }
@@ -276,7 +278,7 @@ public:
     FragmentShaderRGBATexAlphaMask();
     String getShaderString() const;
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     int alphaLocation() const { return m_alphaLocation; }
     int samplerLocation() const { return m_samplerLocation; }
     int maskSamplerLocation() const { return m_maskSamplerLocation; }
@@ -292,7 +294,7 @@ public:
     FragmentShaderRGBATexAlphaMaskAA();
     String getShaderString() const;
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     int alphaLocation() const { return m_alphaLocation; }
     int samplerLocation() const { return m_samplerLocation; }
     int maskSamplerLocation() const { return m_maskSamplerLocation; }
@@ -310,7 +312,7 @@ public:
     FragmentShaderYUVVideo();
     String getShaderString() const;
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
 
     int yTextureLocation() const { return m_yTextureLocation; }
     int uTextureLocation() const { return m_uTextureLocation; }
@@ -333,7 +335,7 @@ public:
     FragmentShaderColor();
     String getShaderString() const;
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     int colorLocation() const { return m_colorLocation; }
 
 private:
@@ -345,7 +347,7 @@ public:
     FragmentShaderCheckerboard();
     String getShaderString() const;
 
-    void init(GraphicsContext3D*, unsigned program);
+    void init(WebKit::WebGraphicsContext3D*, unsigned program);
     int alphaLocation() const { return m_alphaLocation; }
     int texTransformLocation() const { return m_texTransformLocation; }
     int frequencyLocation() const { return m_frequencyLocation; }
index a29c285..0f23090 100644 (file)
 #include "config.h"
 
 #include "TextureCopier.h"
-#include "TraceEvent.h"
 
+#include "GraphicsContext3D.h"
 #include "LayerRendererChromium.h" // For the GLC() macro
+#include "TraceEvent.h"
+#include <public/WebGraphicsContext3D.h>
 
 namespace WebCore {
 
 #if USE(ACCELERATED_COMPOSITING)
-AcceleratedTextureCopier::AcceleratedTextureCopier(PassRefPtr<GraphicsContext3D> context)
+AcceleratedTextureCopier::AcceleratedTextureCopier(WebKit::WebGraphicsContext3D* context)
     : m_context(context)
 {
+    ASSERT(m_context);
     GLC(m_context, m_fbo = m_context->createFramebuffer());
     GLC(m_context, m_positionBuffer = m_context->createBuffer());
 
@@ -45,17 +48,17 @@ AcceleratedTextureCopier::AcceleratedTextureCopier(PassRefPtr<GraphicsContext3D>
         {-1, 1, 0, 1}
     };
 
-    GLC(m_context.get(), m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_positionBuffer));
-    GLC(m_context.get(), m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, sizeof(kPositions), kPositions, GraphicsContext3D::STATIC_DRAW));
-    GLC(m_context.get(), m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0));
+    GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_positionBuffer));
+    GLC(m_context, m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, sizeof(kPositions), kPositions, GraphicsContext3D::STATIC_DRAW));
+    GLC(m_context, m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, 0));
 
-    m_blitProgram = adoptPtr(new BlitProgram(m_context.get()));
+    m_blitProgram = adoptPtr(new BlitProgram(m_context));
 }
 
 AcceleratedTextureCopier::~AcceleratedTextureCopier()
 {
     if (m_blitProgram)
-        m_blitProgram->cleanup(m_context.get());
+        m_blitProgram->cleanup(m_context);
     if (m_positionBuffer)
         GLC(m_context, m_context->deleteBuffer(m_positionBuffer));
     if (m_fbo)
@@ -66,7 +69,7 @@ void AcceleratedTextureCopier::copyTexture(CCGraphicsContext* ccContext, unsigne
 {
     TRACE_EVENT("TextureCopier::copyTexture", this, 0);
 
-    GraphicsContext3D* context = ccContext->context3D();
+    WebKit::WebGraphicsContext3D* context = ccContext->context3D();
     if (!context) {
         // FIXME: Implement this path for software compositing.
         return;
index 3ac2d11..646189a 100644 (file)
 #include "ProgramBinding.h"
 #include "ShaderChromium.h"
 #include "cc/CCGraphicsContext.h"
-#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+class WebGraphicsContext3D;
+}
 
 namespace WebCore {
+class IntSize;
 
 class TextureCopier {
 public:
@@ -49,7 +53,7 @@ protected:
 class AcceleratedTextureCopier : public TextureCopier {
     WTF_MAKE_NONCOPYABLE(AcceleratedTextureCopier);
 public:
-    static PassOwnPtr<AcceleratedTextureCopier> create(PassRefPtr<GraphicsContext3D> context)
+    static PassOwnPtr<AcceleratedTextureCopier> create(WebKit::WebGraphicsContext3D* context)
     {
         return adoptPtr(new AcceleratedTextureCopier(context));
     }
@@ -58,12 +62,12 @@ public:
     virtual void copyTexture(CCGraphicsContext*, unsigned sourceTextureId, unsigned destTextureId, const IntSize&);
 
 protected:
-    explicit AcceleratedTextureCopier(PassRefPtr<GraphicsContext3D>);
+    explicit AcceleratedTextureCopier(WebKit::WebGraphicsContext3D*);
 
 private:
     typedef ProgramBinding<VertexShaderPosTexIdentity, FragmentShaderRGBATex> BlitProgram;
 
-    RefPtr<GraphicsContext3D> m_context;
+    WebKit::WebGraphicsContext3D* m_context;
     Platform3DObject m_fbo;
     Platform3DObject m_positionBuffer;
     OwnPtr<BlitProgram> m_blitProgram;
index 7ca14f4..47a189b 100644 (file)
@@ -28,7 +28,6 @@
 #include "GraphicsContext3D.h"
 #include "IntRect.h"
 #include "IntSize.h"
-
 #include <wtf/FastAllocBase.h>
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
index f5cf2a4..a8253d0 100644 (file)
@@ -27,6 +27,7 @@
 #include "ThrottledTextureUploader.h"
 
 #include "Extensions3DChromium.h"
+#include <public/WebGraphicsContext3D.h>
 
 namespace {
 
@@ -37,57 +38,52 @@ static const size_t maxPendingQueries = 2;
 
 namespace WebCore {
 
-ThrottledTextureUploader::Query::Query(PassRefPtr<GraphicsContext3D> context)
+ThrottledTextureUploader::Query::Query(WebKit::WebGraphicsContext3D* context)
     : m_context(context)
     , m_queryId(0)
 {
-    Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions());
-    m_queryId = extensions->createQueryEXT();
+    m_queryId = m_context->createQueryEXT();
 }
 
 ThrottledTextureUploader::Query::~Query()
 {
-    Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions());
-    extensions->deleteQueryEXT(m_queryId);
+    m_context->deleteQueryEXT(m_queryId);
 }
 
 void ThrottledTextureUploader::Query::begin()
 {
-    Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions());
-    extensions->beginQueryEXT(Extensions3DChromium::COMMANDS_ISSUED_CHROMIUM, m_queryId);
+    m_context->beginQueryEXT(Extensions3DChromium::COMMANDS_ISSUED_CHROMIUM, m_queryId);
 }
 
 void ThrottledTextureUploader::Query::end()
 {
-    Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions());
-    extensions->endQueryEXT(Extensions3DChromium::COMMANDS_ISSUED_CHROMIUM);
+    m_context->endQueryEXT(Extensions3DChromium::COMMANDS_ISSUED_CHROMIUM);
 }
 
 bool ThrottledTextureUploader::Query::isPending()
 {
-    Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions());
     unsigned available = 1;
-    extensions->getQueryObjectuivEXT(m_queryId, Extensions3DChromium::QUERY_RESULT_AVAILABLE_EXT, &available);
+    m_context->getQueryObjectuivEXT(m_queryId, Extensions3DChromium::QUERY_RESULT_AVAILABLE_EXT, &available);
     return !available;
 }
 
 void ThrottledTextureUploader::Query::wait()
 {
-    Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions());
     unsigned result;
-    extensions->getQueryObjectuivEXT(m_queryId, Extensions3DChromium::QUERY_RESULT_EXT, &result);
+    m_context->getQueryObjectuivEXT(m_queryId, Extensions3DChromium::QUERY_RESULT_EXT, &result);
 }
 
-ThrottledTextureUploader::ThrottledTextureUploader(PassRefPtr<GraphicsContext3D> context)
+ThrottledTextureUploader::ThrottledTextureUploader(WebKit::WebGraphicsContext3D* context)
     : m_context(context)
     , m_maxPendingQueries(maxPendingQueries)
 {
 }
 
-ThrottledTextureUploader::ThrottledTextureUploader(PassRefPtr<GraphicsContext3D> context, size_t pendingUploadLimit)
+ThrottledTextureUploader::ThrottledTextureUploader(WebKit::WebGraphicsContext3D* context, size_t pendingUploadLimit)
     : m_context(context)
     , m_maxPendingQueries(pendingUploadLimit)
 {
+    ASSERT(m_context);
 }
 
 ThrottledTextureUploader::~ThrottledTextureUploader()
index dea3d35..ae5b749 100644 (file)
 
 #include <wtf/Deque.h>
 
+namespace WebKit {
+class WebGraphicsContext3D;
+}
+
 namespace WebCore {
 
 class ThrottledTextureUploader : public TextureUploader {
     WTF_MAKE_NONCOPYABLE(ThrottledTextureUploader);
 public:
-    static PassOwnPtr<ThrottledTextureUploader> create(PassRefPtr<GraphicsContext3D> context)
+    static PassOwnPtr<ThrottledTextureUploader> create(WebKit::WebGraphicsContext3D* context)
     {
         return adoptPtr(new ThrottledTextureUploader(context));
     }
-    static PassOwnPtr<ThrottledTextureUploader> create(PassRefPtr<GraphicsContext3D> context, size_t pendingUploadLimit)
+    static PassOwnPtr<ThrottledTextureUploader> create(WebKit::WebGraphicsContext3D* context, size_t pendingUploadLimit)
     {
         return adoptPtr(new ThrottledTextureUploader(context, pendingUploadLimit));
     }
@@ -52,7 +56,7 @@ public:
 private:
     class Query {
     public:
-        static PassOwnPtr<Query> create(PassRefPtr<GraphicsContext3D> context) { return adoptPtr(new Query(context)); }
+        static PassOwnPtr<Query> create(WebKit::WebGraphicsContext3D* context) { return adoptPtr(new Query(context)); }
 
         virtual ~Query();
 
@@ -62,18 +66,18 @@ private:
         void wait();
 
     private:
-        explicit Query(PassRefPtr<GraphicsContext3D>);
+        explicit Query(WebKit::WebGraphicsContext3D*);
 
-        RefPtr<GraphicsContext3D> m_context;
+        WebKit::WebGraphicsContext3D* m_context;
         unsigned m_queryId;
     };
 
-    ThrottledTextureUploader(PassRefPtr<GraphicsContext3D>);
-    ThrottledTextureUploader(PassRefPtr<GraphicsContext3D>, size_t pendingUploadLimit);
+    ThrottledTextureUploader(WebKit::WebGraphicsContext3D*);
+    ThrottledTextureUploader(WebKit::WebGraphicsContext3D*, size_t pendingUploadLimit);
 
     void processQueries();
 
-    RefPtr<GraphicsContext3D> m_context;
+    WebKit::WebGraphicsContext3D* m_context;
     size_t m_maxPendingQueries;
     Deque<OwnPtr<Query> > m_pendingQueries;
     Deque<OwnPtr<Query> > m_availableQueries;
index 957711e..8e586e2 100644 (file)
 #include "TrackingTextureAllocator.h"
 
 #include "Extensions3DChromium.h"
+#include "GraphicsContext3D.h"
 #include "IntRect.h"
 #include "LayerRendererChromium.h" // For the GLC() macro
 
 namespace WebCore {
 
-TrackingTextureAllocator::TrackingTextureAllocator(PassRefPtr<GraphicsContext3D> context)
+TrackingTextureAllocator::TrackingTextureAllocator(WebKit::WebGraphicsContext3D* context)
     : m_context(context)
     , m_currentMemoryUseBytes(0)
     , m_textureUsageHint(Any)
     , m_useTextureStorageExt(false)
 {
+    ASSERT(m_context);
 }
 
 TrackingTextureAllocator::~TrackingTextureAllocator()
@@ -72,23 +74,22 @@ unsigned TrackingTextureAllocator::createTexture(const IntSize& size, GC3Denum f
     m_currentMemoryUseBytes += TextureManager::memoryUseBytes(size, format);
 
     unsigned textureId = 0;
-    GLC(m_context.get(), textureId = m_context->createTexture());
-    GLC(m_context.get(), m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId));
+    GLC(m_context, textureId = m_context->createTexture());
+    GLC(m_context, m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId));
     // Do basic linear filtering on resize.
-    GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
-    GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
+    GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR));
+    GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
     // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE.
-    GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
-    GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
+    GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
+    GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
 
     if (m_textureUsageHint == FramebufferAttachment)
-        GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, Extensions3DChromium::GL_TEXTURE_USAGE_ANGLE, Extensions3DChromium::GL_FRAMEBUFFER_ATTACHMENT_ANGLE));
+        GLC(m_context, m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, Extensions3DChromium::GL_TEXTURE_USAGE_ANGLE, Extensions3DChromium::GL_FRAMEBUFFER_ATTACHMENT_ANGLE));
     if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) {
-        Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions());
         GC3Denum storageFormat = textureToStorageFormat(format);
-        extensions->texStorage2DEXT(GraphicsContext3D::TEXTURE_2D, 1, storageFormat, size.width(), size.height());
+        m_context->texStorage2DEXT(GraphicsContext3D::TEXTURE_2D, 1, storageFormat, size.width(), size.height());
     } else
-        GLC(m_context.get(), m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE));
+        GLC(m_context, m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE, 0));
     m_allocatedTextureIds.add(textureId);
     return textureId;
 }
@@ -96,7 +97,8 @@ unsigned TrackingTextureAllocator::createTexture(const IntSize& size, GC3Denum f
 void TrackingTextureAllocator::deleteTexture(unsigned textureId, const IntSize& size, GC3Denum format)
 {
     m_currentMemoryUseBytes -= TextureManager::memoryUseBytes(size, format);
-    GLC(m_context.get(), m_context->deleteTexture(textureId));
+    GLC(m_context, m_context->deleteTexture(textureId));
+    GLC(m_context, m_context->deleteTexture(textureId));
     ASSERT(m_allocatedTextureIds.contains(textureId));
     m_allocatedTextureIds.remove(textureId);
 }
@@ -104,7 +106,7 @@ void TrackingTextureAllocator::deleteTexture(unsigned textureId, const IntSize&
 void TrackingTextureAllocator::deleteAllTextures()
 {
     for (HashSet<unsigned>::const_iterator it = m_allocatedTextureIds.begin(); it != m_allocatedTextureIds.end(); ++it)
-        GLC(m_context.get(), m_context->deleteTexture(*it));
+        GLC(m_context, m_context->deleteTexture(*it));
     m_currentMemoryUseBytes = 0;
     m_allocatedTextureIds.clear();
 }
index 980b94e..c10c257 100644 (file)
 #ifndef TrackingTextureAllocator_h
 #define TrackingTextureAllocator_h
 
-#include "GraphicsContext3D.h"
 #include "TextureManager.h"
 #include <wtf/HashSet.h>
 #include <wtf/PassRefPtr.h>
 
+namespace WebKit {
+class WebGraphicsContext3D;
+}
+
 namespace WebCore {
 
 class TrackingTextureAllocator : public TextureAllocator {
     WTF_MAKE_NONCOPYABLE(TrackingTextureAllocator);
 public:
-    static PassOwnPtr<TrackingTextureAllocator> create(PassRefPtr<GraphicsContext3D> context)
+    static PassOwnPtr<TrackingTextureAllocator> create(WebKit::WebGraphicsContext3D* context)
     {
         return adoptPtr(new TrackingTextureAllocator(context));
     }
@@ -53,9 +56,9 @@ public:
     void setUseTextureStorageExt(bool useStorageExt) { m_useTextureStorageExt = useStorageExt; }
 
 protected:
-    explicit TrackingTextureAllocator(PassRefPtr<GraphicsContext3D>);
+    explicit TrackingTextureAllocator(WebKit::WebGraphicsContext3D*);
 
-    RefPtr<GraphicsContext3D> m_context;
+    WebKit::WebGraphicsContext3D* m_context;
     size_t m_currentMemoryUseBytes;
     TextureUsageHint m_textureUsageHint;
     bool m_useTextureStorageExt;
index 395f18c..43536a4 100644 (file)
 #ifndef CCGraphicsContext_h
 #define CCGraphicsContext_h
 
-#include "GraphicsContext3D.h"
-#include <wtf/PassRefPtr.h>
+#include <public/WebGraphicsContext3D.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/OwnPtr.h>
 
 namespace WebCore {
 
-class GraphicsContext3D;
 
-class CCGraphicsContext : public RefCounted<CCGraphicsContext> {
+class CCGraphicsContext {
+    WTF_MAKE_NONCOPYABLE(CCGraphicsContext);
 public:
-    static PassRefPtr<CCGraphicsContext> create2D()
+    static PassOwnPtr<CCGraphicsContext> create2D()
     {
-        return adoptRef(new CCGraphicsContext());
+        return adoptPtr(new CCGraphicsContext());
     }
-    static PassRefPtr<CCGraphicsContext> create3D(PassRefPtr<GraphicsContext3D> context3D)
+    static PassOwnPtr<CCGraphicsContext> create3D(PassOwnPtr<WebKit::WebGraphicsContext3D> context3D)
     {
-        return adoptRef(new CCGraphicsContext(context3D));
+        return adoptPtr(new CCGraphicsContext(context3D));
     }
 
-    GraphicsContext3D* context3D() { return m_context3D.get(); }
+    WebKit::WebGraphicsContext3D* context3D() { return m_context3D.get(); }
 
 private:
     CCGraphicsContext() { }
-    explicit CCGraphicsContext(PassRefPtr<GraphicsContext3D> context3D)
+    explicit CCGraphicsContext(PassOwnPtr<WebKit::WebGraphicsContext3D> context3D)
         : m_context3D(context3D) { }
 
-    RefPtr<GraphicsContext3D> m_context3D;
+    OwnPtr<WebKit::WebGraphicsContext3D> m_context3D;
 };
 
 }
index 1b61317..f3d415d 100644 (file)
@@ -35,6 +35,7 @@
 #include "cc/CCDebugRectHistory.h"
 #include "cc/CCFrameRateCounter.h"
 #include "cc/CCLayerTreeHostImpl.h"
+#include <public/WebGraphicsContext3D.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -68,7 +69,7 @@ bool CCHeadsUpDisplay::showDebugRects(const CCLayerTreeSettings& settings) const
 void CCHeadsUpDisplay::draw(CCLayerTreeHostImpl* layerTreeHostImpl)
 {
     CCRenderer* layerRenderer = layerTreeHostImpl->layerRenderer();
-    GraphicsContext3D* context = layerTreeHostImpl->context()->context3D();
+    WebKit::WebGraphicsContext3D* context = layerTreeHostImpl->context()->context3D();
     if (!context) {
         // FIXME: Implement this path for software compositing.
         return;
@@ -106,13 +107,12 @@ void CCHeadsUpDisplay::draw(CCLayerTreeHostImpl* layerTreeHostImpl)
         m_hudTexture->bindTexture(layerTreeHostImpl->context(), layerRenderer->implTextureAllocator());
         bool uploadedViaMap = false;
         if (layerRenderer->capabilities().usingMapSub) {
-            Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context->getExtensions());
-            uint8_t* pixelDest = static_cast<uint8_t*>(extensions->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, hudSize.width(), hudSize.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY));
+            uint8_t* pixelDest = static_cast<uint8_t*>(context->mapTexSubImage2DCHROMIUM(GraphicsContext3D::TEXTURE_2D, 0, 0, 0, hudSize.width(), hudSize.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, Extensions3DChromium::WRITE_ONLY));
 
             if (pixelDest) {
                 uploadedViaMap = true;
                 memcpy(pixelDest, locker.pixels(), hudSize.width() * hudSize.height() * 4);
-                extensions->unmapTexSubImage2DCHROMIUM(pixelDest);
+                context->unmapTexSubImage2DCHROMIUM(pixelDest);
             }
         }
 
index f844667..ce3b38e 100644 (file)
 
 #include "cc/CCIOSurfaceLayerImpl.h"
 
-#include "Extensions3DChromium.h"
+#include "Extensions3D.h"
 #include "LayerRendererChromium.h"
 #include "TextStream.h"
 #include "cc/CCGraphicsContext.h"
 #include "cc/CCIOSurfaceDrawQuad.h"
 #include "cc/CCLayerTreeHostImpl.h"
 #include "cc/CCQuadCuller.h"
+#include <public/WebGraphicsContext3D.h>
 
 namespace WebCore {
 
@@ -54,7 +55,7 @@ CCIOSurfaceLayerImpl::~CCIOSurfaceLayerImpl()
 
     CCGraphicsContext* context = layerTreeHostImpl()->context();
     // FIXME: Implement this path for software compositing.
-    GraphicsContext3D* context3d = context->context3D();
+    WebKit::WebGraphicsContext3D* context3d = context->context3D();
     if (context3d)
         context3d->deleteTexture(m_ioSurfaceTextureId);
 }
@@ -64,14 +65,11 @@ void CCIOSurfaceLayerImpl::willDraw(CCRenderer* layerRenderer, CCGraphicsContext
     CCLayerImpl::willDraw(layerRenderer, context);
 
     if (m_ioSurfaceChanged) {
-        GraphicsContext3D* context3d = context->context3D();
+        WebKit::WebGraphicsContext3D* context3d = context->context3D();
         if (!context3d) {
             // FIXME: Implement this path for software compositing.
             return;
         }
-        Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(context3d->getExtensions());
-        ASSERT(extensions->supports("GL_CHROMIUM_iosurface"));
-        ASSERT(extensions->supports("GL_ARB_texture_rectangle"));
 
         // FIXME: Do this in a way that we can track memory usage.
         if (!m_ioSurfaceTextureId)
@@ -83,11 +81,11 @@ void CCIOSurfaceLayerImpl::willDraw(CCRenderer* layerRenderer, CCGraphicsContext
         GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR));
         GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
         GLC(context3d, context3d->texParameteri(Extensions3D::TEXTURE_RECTANGLE_ARB, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
-        extensions->texImageIOSurface2DCHROMIUM(Extensions3D::TEXTURE_RECTANGLE_ARB,
-                                                m_ioSurfaceSize.width(),
-                                                m_ioSurfaceSize.height(),
-                                                m_ioSurfaceId,
-                                                0);
+        context3d->texImageIOSurface2DCHROMIUM(Extensions3D::TEXTURE_RECTANGLE_ARB,
+                                               m_ioSurfaceSize.width(),
+                                               m_ioSurfaceSize.height(),
+                                               m_ioSurfaceId,
+                                               0);
         // Do not check for error conditions. texImageIOSurface2DCHROMIUM is supposed to hold on to
         // the last good IOSurface if the new one is already closed. This is only a possibility
         // during live resizing of plugins. However, it seems that this is not sufficient to
index 7d14cf5..3f9abf1 100644 (file)
@@ -260,9 +260,8 @@ void CCLayerTreeHost::commitComplete()
     m_client->didCommit();
 }
 
-PassRefPtr<CCGraphicsContext> CCLayerTreeHost::createContext()
+PassOwnPtr<CCGraphicsContext> CCLayerTreeHost::createContext()
 {
-    RefPtr<CCGraphicsContext> context;
     if (settings().forceSoftwareCompositing)
         return CCGraphicsContext::create2D();
     return CCGraphicsContext::create3D(m_client->createContext3D());
index 6f6946e..1f4d3c9 100644 (file)
@@ -61,7 +61,7 @@ public:
     virtual void updateAnimations(double frameBeginTime) = 0;
     virtual void layout() = 0;
     virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) = 0;
-    virtual PassRefPtr<GraphicsContext3D> createContext3D() = 0;
+    virtual PassOwnPtr<WebKit::WebGraphicsContext3D> createContext3D() = 0;
     virtual void didRecreateContext(bool success) = 0;
     virtual void willCommit() = 0;
     virtual void didCommit() = 0;
@@ -117,6 +117,7 @@ struct LayerRendererCapabilities {
         , usingTextureStorageExtension(false)
         , usingGpuMemoryManager(false)
         , usingDiscardFramebuffer(false)
+        , usingEglImage(false)
         , maxTextureSize(0) { }
 
     GC3Denum bestTextureFormat;
@@ -130,6 +131,7 @@ struct LayerRendererCapabilities {
     bool usingTextureStorageExtension;
     bool usingGpuMemoryManager;
     bool usingDiscardFramebuffer;
+    bool usingEglImage;
     int maxTextureSize;
 };
 
@@ -146,6 +148,7 @@ public:
 
     static bool needsFilterContext() { return s_needsFilterContext; }
     static void setNeedsFilterContext(bool needsFilterContext) { s_needsFilterContext = needsFilterContext; }
+    bool needsSharedContext() const { return needsFilterContext() || settings().acceleratePainting; }
 
     // CCLayerTreeHost interface to CCProxy.
     void willBeginFrame() { m_client->willBeginFrame(); }
@@ -155,7 +158,7 @@ public:
     void beginCommitOnImplThread(CCLayerTreeHostImpl*);
     void finishCommitOnImplThread(CCLayerTreeHostImpl*);
     void commitComplete();
-    PassRefPtr<CCGraphicsContext> createContext();
+    PassOwnPtr<CCGraphicsContext> createContext();
     virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl(CCLayerTreeHostImplClient*);
     void didLoseContext();
     enum RecreateResult {
index 9a11bd2..3011b5e 100644 (file)
@@ -649,9 +649,9 @@ void CCLayerTreeHostImpl::setVisible(bool visible)
     setBackgroundTickingEnabled(!m_visible && m_needsAnimateLayers);
 }
 
-bool CCLayerTreeHostImpl::initializeLayerRenderer(PassRefPtr<CCGraphicsContext> context, TextureUploaderOption textureUploader)
+bool CCLayerTreeHostImpl::initializeLayerRenderer(PassOwnPtr<CCGraphicsContext> context, TextureUploaderOption textureUploader)
 {
-    GraphicsContext3D* context3d = context->context3D();
+    WebKit::WebGraphicsContext3D* context3d = context->context3D();
     if (!context3d) {
         // FIXME: Implement this path for software compositing.
         return false;
index 939e42e..4e4f6cc 100644 (file)
@@ -121,7 +121,7 @@ public:
     void finishAllRendering();
     int frameNumber() const { return m_frameNumber; }
 
-    bool initializeLayerRenderer(PassRefPtr<CCGraphicsContext>, TextureUploaderOption);
+    bool initializeLayerRenderer(PassOwnPtr<CCGraphicsContext>, TextureUploaderOption);
     bool isContextLost();
     CCRenderer* layerRenderer() { return m_layerRenderer.get(); }
     const LayerRendererCapabilities& layerRendererCapabilities() const;
@@ -224,7 +224,7 @@ private:
 
     void dumpRenderSurfaces(TextStream&, int indent, const CCLayerImpl*) const;
 
-    RefPtr<CCGraphicsContext> m_context;
+    OwnPtr<CCGraphicsContext> m_context;
     OwnPtr<CCRenderer> m_layerRenderer;
     OwnPtr<CCLayerImpl> m_rootLayerImpl;
     CCLayerImpl* m_rootScrollLayerImpl;
index f54ba77..cbd51d4 100644 (file)
@@ -140,11 +140,10 @@ bool CCSingleThreadProxy::isStarted() const
 bool CCSingleThreadProxy::initializeContext()
 {
     ASSERT(CCProxy::isMainThread());
-    RefPtr<CCGraphicsContext> context = m_layerTreeHost->createContext();
+    OwnPtr<CCGraphicsContext> context = m_layerTreeHost->createContext();
     if (!context)
         return false;
-    ASSERT(context->hasOneRef());
-    m_contextBeforeInitialization = context;
+    m_contextBeforeInitialization = context.release();
     return true;
 }
 
@@ -183,16 +182,15 @@ bool CCSingleThreadProxy::recreateContext()
     ASSERT(CCProxy::isMainThread());
     ASSERT(m_contextLost);
 
-    RefPtr<CCGraphicsContext> context = m_layerTreeHost->createContext();
+    OwnPtr<CCGraphicsContext> context = m_layerTreeHost->createContext();
     if (!context)
         return false;
 
-    ASSERT(context->hasOneRef());
     bool initialized;
     {
         DebugScopedSetImplThread impl;
         m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->contentsTextureAllocator());
-        initialized = m_layerTreeHostImpl->initializeLayerRenderer(context, UnthrottledUploader);
+        initialized = m_layerTreeHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
         if (initialized) {
             m_layerRendererCapabilitiesForMainThread = m_layerTreeHostImpl->layerRendererCapabilities();
         }
index 46cb302..6fb733d 100644 (file)
@@ -97,7 +97,7 @@ private:
 
     // Holds on to the context between initializeContext() and initializeLayerRenderer() calls. Shouldn't
     // be used for anything else.
-    RefPtr<CCGraphicsContext> m_contextBeforeInitialization;
+    OwnPtr<CCGraphicsContext> m_contextBeforeInitialization;
 
     OwnPtr<CCSingleThreadProxyAnimationTimer> m_animationTimer;
 
index 1fd0c73..c329993 100644 (file)
@@ -129,7 +129,7 @@ void CCTextureUpdater::update(CCGraphicsContext* context, TextureAllocator* allo
     // before letting the main thread proceed as it may make draw calls to the source texture of one of
     // our copy operations.
     if (m_copyEntries.size()) {
-        GraphicsContext3D* context3d = context->context3D();
+        WebKit::WebGraphicsContext3D* context3d = context->context3D();
         if (context3d)
             context3d->flush();
         // FIXME: Implement this path for software compositing.
index 0cdbfdb..1988032 100644 (file)
@@ -180,17 +180,12 @@ bool CCThreadProxy::isStarted() const
 bool CCThreadProxy::initializeContext()
 {
     TRACE_EVENT("CCThreadProxy::initializeContext", this, 0);
-    RefPtr<CCGraphicsContext> context = m_layerTreeHost->createContext();
+    OwnPtr<CCGraphicsContext> context = m_layerTreeHost->createContext();
     if (!context)
         return false;
-    ASSERT(context->hasOneRef());
-
-    // Leak the context pointer so we can transfer ownership of it to the other side...
-    CCGraphicsContext* contextPtr = context.release().leakRef();
-    ASSERT(contextPtr->hasOneRef());
 
     CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::initializeContextOnImplThread,
-                                                       AllowCrossThreadAccess(contextPtr)));
+                                                       AllowCrossThreadAccess(context.leakPtr())));
     return true;
 }
 
@@ -249,19 +244,13 @@ bool CCThreadProxy::recreateContext()
     ASSERT(isMainThread());
 
     // Try to create the context.
-    RefPtr<CCGraphicsContext> context = m_layerTreeHost->createContext();
+    OwnPtr<CCGraphicsContext> context = m_layerTreeHost->createContext();
     if (!context)
         return false;
-    if (CCLayerTreeHost::needsFilterContext() && !m_layerTreeHost->settings().forceSoftwareCompositing)
+    if (m_layerTreeHost->needsSharedContext() && !m_layerTreeHost->settings().forceSoftwareCompositing)
         if (!SharedGraphicsContext3D::createForImplThread())
             return false;
 
-    ASSERT(context->hasOneRef());
-
-    // Leak the context pointer so we can transfer ownership of it to the other side...
-    CCGraphicsContext* contextPtr = context.release().leakRef();
-    ASSERT(contextPtr->hasOneRef());
-
     // Make a blocking call to recreateContextOnImplThread. The results of that
     // call are pushed into the recreateSucceeded and capabilities local
     // variables.
@@ -270,7 +259,7 @@ bool CCThreadProxy::recreateContext()
     LayerRendererCapabilities capabilities;
     CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::recreateContextOnImplThread,
                                                        AllowCrossThreadAccess(&completion),
-                                                       AllowCrossThreadAccess(contextPtr),
+                                                       AllowCrossThreadAccess(context.leakPtr()),
                                                        AllowCrossThreadAccess(&recreateSucceeded),
                                                        AllowCrossThreadAccess(&capabilities)));
     completion.wait();
@@ -480,7 +469,7 @@ void CCThreadProxy::beginFrame()
         return;
     }
 
-    if (CCLayerTreeHost::needsFilterContext() && !m_layerTreeHost->settings().forceSoftwareCompositing && !SharedGraphicsContext3D::haveForImplThread())
+    if (m_layerTreeHost->needsSharedContext() && !m_layerTreeHost->settings().forceSoftwareCompositing && !SharedGraphicsContext3D::haveForImplThread())
         SharedGraphicsContext3D::createForImplThread();
 
     OwnPtr<BeginFrameAndCommitState> request(m_pendingBeginFrameRequest.release());
@@ -830,7 +819,7 @@ void CCThreadProxy::initializeContextOnImplThread(CCGraphicsContext* context)
 {
     TRACE_EVENT("CCThreadProxy::initializeContextOnImplThread", this, 0);
     ASSERT(isImplThread());
-    m_contextBeforeInitializationOnImplThread = adoptRef(context);
+    m_contextBeforeInitializationOnImplThread = adoptPtr(context);
 }
 
 void CCThreadProxy::initializeLayerRendererOnImplThread(CCCompletionEvent* completion, bool* initializeSucceeded, LayerRendererCapabilities* capabilities)
@@ -889,7 +878,7 @@ void CCThreadProxy::recreateContextOnImplThread(CCCompletionEvent* completion, C
     TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread");
     ASSERT(isImplThread());
     m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->contentsTextureAllocator());
-    *recreateSucceeded = m_layerTreeHostImpl->initializeLayerRenderer(adoptRef(contextPtr), textureUploader);
+    *recreateSucceeded = m_layerTreeHostImpl->initializeLayerRenderer(adoptPtr(contextPtr), textureUploader);
     if (*recreateSucceeded) {
         *capabilities = m_layerTreeHostImpl->layerRendererCapabilities();
         m_schedulerOnImplThread->didRecreateContext();
index 572f9f4..33d3d99 100644 (file)
@@ -171,7 +171,7 @@ private:
 
     // Holds on to the context we might use for compositing in between initializeContext()
     // and initializeLayerRenderer() calls.
-    RefPtr<CCGraphicsContext> m_contextBeforeInitializationOnImplThread;
+    OwnPtr<CCGraphicsContext> m_contextBeforeInitializationOnImplThread;
 
     // Set when the main thread is waiting on a scheduledActionBeginFrame to be issued.
     CCCompletionEvent* m_beginFrameCompletionEventOnImplThread;
index dbb07a0..db6d8f0 100644 (file)
@@ -288,7 +288,7 @@ bool CCVideoLayerImpl::FramePlane::allocateData(CCGraphicsContext* context)
     if (textureId)
         return true;
 
-    GraphicsContext3D* context3D = context->context3D();
+    WebKit::WebGraphicsContext3D* context3D = context->context3D();
     if (!context3D)
         return false;
 
@@ -301,7 +301,7 @@ bool CCVideoLayerImpl::FramePlane::allocateData(CCGraphicsContext* context)
     GLC(context3D, context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
     GLC(context3D, context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
 
-    GLC(context3D, context3D->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE));
+    GLC(context3D, context3D->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE, 0));
 
     return textureId;
 }
@@ -311,7 +311,7 @@ void CCVideoLayerImpl::FramePlane::freeData(CCGraphicsContext* context)
     if (!textureId)
         return;
 
-    GraphicsContext3D* context3D = context->context3D();
+    WebKit::WebGraphicsContext3D* context3D = context->context3D();
     if (!context3D)
         return;
 
@@ -351,7 +351,7 @@ bool CCVideoLayerImpl::copyPlaneData(CCRenderer* layerRenderer, CCGraphicsContex
     if (!softwarePlaneCount)
         return true;
 
-    GraphicsContext3D* context3d = context->context3D();
+    WebKit::WebGraphicsContext3D* context3d = context->context3D();
     if (!context3d) {
         // FIXME: Implement this path for software compositing.
         return false;
index 91ee21b..1963f81 100644 (file)
@@ -1,3 +1,46 @@
+2012-06-25  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Use WebGraphicsContext3D in compositor implementation
+        https://bugs.webkit.org/show_bug.cgi?id=89700
+
+        Reviewed by Adrienne Walker.
+
+        Updates tests for refactor, mostly by removing unnecessary GraphicsContext3D wrapper around mock contexts.
+
+        * WebKit.gypi:
+        * src/WebLayerTreeView.cpp:
+        (WebKit::WebLayerTreeView::context):
+        * src/WebLayerTreeViewImpl.cpp:
+        * tests/CCLayerTreeHostImplTest.cpp:
+        * tests/CCLayerTreeHostTest.cpp:
+        (WTF::CCLayerTreeHostTestAtomicCommit::commitCompleteOnCCThread):
+        (WTF::CCLayerTreeHostTestAtomicCommit::drawLayersOnCCThread):
+        (WTF::CCLayerTreeHostTestAtomicCommitWithPartialUpdate::commitCompleteOnCCThread):
+        (WTF::CCLayerTreeHostTestAtomicCommitWithPartialUpdate::drawLayersOnCCThread):
+        * tests/CCSingleThreadProxyTest.cpp:
+        * tests/CCThreadedTest.cpp:
+        (WebKitTests::TestHooks::createContext):
+        * tests/CCThreadedTest.h:
+        (TestHooks):
+        * tests/Canvas2DLayerBridgeTest.cpp:
+        (Canvas2DLayerBridgeTest::fullLifecycleTest):
+        * tests/CompositorFakeGraphicsContext3D.h: Removed.
+        * tests/DrawingBufferChromiumTest.cpp: Removed.
+        * tests/FakeCCLayerTreeHostClient.h:
+        * tests/FakeGraphicsContext3DTest.cpp:
+        (TEST):
+        * tests/GraphicsLayerChromiumTest.cpp:
+        * tests/LayerRendererChromiumTest.cpp:
+        (FakeLayerRendererChromium::FakeLayerRendererChromium):
+        (LayerRendererChromiumTest::LayerRendererChromiumTest):
+        (LayerRendererChromiumTest):
+        (TEST_F):
+        (TEST):
+        * tests/TextureCopierTest.cpp:
+        * tests/ThrottledTextureUploaderTest.cpp:
+        (WebKit::TEST):
+        * tests/TiledLayerChromiumTest.cpp:
+
 2012-06-25  Kausalya Madhusudhanan  <kmadhusu@chromium.org>
 
         [Chromium] Add a chromium-webkit API to create a serializable file system.
index 549fdfa..dd2bfb2 100644 (file)
             'tests/CCThreadedTest.h',
             'tests/CCTimerTest.cpp',
             'tests/ClipboardChromiumTest.cpp',
-            'tests/CompositorFakeGraphicsContext3D.h',
             'tests/CompositorFakeWebGraphicsContext3D.h',
             'tests/DecimalTest.cpp',
             'tests/DragImageTest.cpp',
-            'tests/DrawingBufferChromiumTest.cpp',
             'tests/EventListenerTest.cpp',
             'tests/FakeCCLayerTreeHostClient.h',
             'tests/FakeGraphicsContext3DTest.cpp',
index 356af1d..7f22f79 100644 (file)
@@ -175,7 +175,7 @@ void WebLayerTreeView::finishAllRendering()
 
 WebGraphicsContext3D* WebLayerTreeView::context()
 {
-    return GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_private->layerTreeHost()->context()->context3D());
+    return m_private->layerTreeHost()->context()->context3D();
 }
 
 void WebLayerTreeView::loseCompositorContext(int numTimes)
index 17d5fe8..825fc01 100644 (file)
@@ -54,12 +54,9 @@ public:
     virtual void updateAnimations(double monotonicFrameBeginTime) OVERRIDE { m_client->updateAnimations(monotonicFrameBeginTime); }
     virtual void layout() OVERRIDE { m_client->layout(); }
     virtual void applyScrollAndScale(const WebCore::IntSize& scrollDelta, float pageScale) OVERRIDE { m_client->applyScrollAndScale(scrollDelta, pageScale); }
-    virtual PassRefPtr<WebCore::GraphicsContext3D> createContext3D() OVERRIDE
+    virtual PassOwnPtr<WebGraphicsContext3D> createContext3D() OVERRIDE
     {
-        OwnPtr<WebGraphicsContext3D> webContext = adoptPtr(m_client->createContext3D());
-        if (!webContext)
-            return 0;
-        return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow, false /* preserveDrawingBuffer */ );
+        return adoptPtr(m_client->createContext3D());
     }
     virtual void didRecreateContext(bool success) OVERRIDE { m_client->didRebindGraphicsContext(success); }
     virtual void willCommit() OVERRIDE { m_client->willCommit(); }
index 28e3349..34846b7 100644 (file)
@@ -30,7 +30,6 @@
 #include "CCLayerTestCommon.h"
 #include "CCTestCommon.h"
 #include "FakeWebGraphicsContext3D.h"
-#include "GraphicsContext3DPrivate.h"
 #include "LayerRendererChromium.h"
 #include "ManagedTexture.h"
 #include "cc/CCIOSurfaceLayerImpl.h"
@@ -82,7 +81,7 @@ public:
     virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = true; }
     virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE { }
 
-    PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, PassRefPtr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr)
+    PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, PassOwnPtr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr)
     {
         CCSettings::setPartialSwapEnabled(partialSwap);
 
@@ -162,9 +161,9 @@ public:
     }
 
 protected:
-    PassRefPtr<CCGraphicsContext> createContext()
+    PassOwnPtr<CCGraphicsContext> createContext()
     {
-        return CCGraphicsContext::create3D(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3D()), GraphicsContext3D::RenderDirectlyToHostWindow));
+        return CCGraphicsContext::create3D(adoptPtr(new FakeWebGraphicsContext3D));
     }
 
     DebugScopedSetImplThread m_alwaysImplThread;
@@ -1511,10 +1510,9 @@ public:
 // viewport size is never set.
 TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw)
 {
-    ReshapeTrackerContext* reshapeTracker = new ReshapeTrackerContext();
-    RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(reshapeTracker), GraphicsContext3D::RenderDirectlyToHostWindow);
-    RefPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(context);
-    m_hostImpl->initializeLayerRenderer(ccContext, UnthrottledUploader);
+    OwnPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(adoptPtr(new ReshapeTrackerContext));
+    ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(ccContext->context3D());
+    m_hostImpl->initializeLayerRenderer(ccContext.release(), UnthrottledUploader);
 
     CCLayerImpl* root = new FakeDrawableCCLayerImpl(1);
     root->setAnchorPoint(FloatPoint(0, 0));
@@ -1555,16 +1553,15 @@ private:
 // where it should request to swap only the subBuffer that is damaged.
 TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect)
 {
-    PartialSwapTrackerContext* partialSwapTracker = new PartialSwapTrackerContext();
-    RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(partialSwapTracker), GraphicsContext3D::RenderDirectlyToHostWindow);
-    RefPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(context);
+    OwnPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(adoptPtr(new PartialSwapTrackerContext));
+    PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrackerContext*>(ccContext->context3D());
 
     // This test creates its own CCLayerTreeHostImpl, so
     // that we can force partial swap enabled.
     CCLayerTreeSettings settings;
     CCSettings::setPartialSwapEnabled(true);
     OwnPtr<CCLayerTreeHostImpl> layerTreeHostImpl = CCLayerTreeHostImpl::create(settings, this);
-    layerTreeHostImpl->initializeLayerRenderer(ccContext, UnthrottledUploader);
+    layerTreeHostImpl->initializeLayerRenderer(ccContext.release(), UnthrottledUploader);
     layerTreeHostImpl->setViewportSize(IntSize(500, 500));
 
     CCLayerImpl* root = new FakeDrawableCCLayerImpl(1);
@@ -1725,15 +1722,15 @@ public:
 
 TEST_F(CCLayerTreeHostImplTest, noPartialSwap)
 {
-    MockContext* mockContext = new MockContext();
-    RefPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(mockContext), GraphicsContext3D::RenderDirectlyToHostWindow));
+    OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new MockContext));
+    MockContext* mockContext = static_cast<MockContext*>(context->context3D());
     MockContextHarness harness(mockContext);
 
     harness.mustDrawSolidQuad();
     harness.mustSetScissor(0, 0, 10, 10);
 
     // Run test case
-    OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context, FakeLayerWithQuads::create(1));
+    OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context.release(), FakeLayerWithQuads::create(1));
 
     CCLayerTreeHostImpl::FrameData frame;
     EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
@@ -1744,14 +1741,14 @@ TEST_F(CCLayerTreeHostImplTest, noPartialSwap)
 
 TEST_F(CCLayerTreeHostImplTest, partialSwap)
 {
-    MockContext* mockContext = new MockContext();
-    RefPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(mockContext), GraphicsContext3D::RenderDirectlyToHostWindow));
+    OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new MockContext));
+    MockContext* mockContext = static_cast<MockContext*>(context->context3D());
     MockContextHarness harness(mockContext);
 
     harness.mustDrawSolidQuad();
     harness.mustSetScissor(0, 0, 10, 10);
 
-    OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context, FakeLayerWithQuads::create(1));
+    OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context.release(), FakeLayerWithQuads::create(1));
 
     CCLayerTreeHostImpl::FrameData frame;
     EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
@@ -1762,8 +1759,8 @@ TEST_F(CCLayerTreeHostImplTest, partialSwap)
 
 TEST_F(CCLayerTreeHostImplTest, partialSwapNoUpdate)
 {
-    MockContext* mockContext = new MockContext();
-    RefPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(mockContext), GraphicsContext3D::RenderDirectlyToHostWindow));
+    OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new MockContext));
+    MockContext* mockContext = static_cast<MockContext*>(context->context3D());
     MockContextHarness harness(mockContext);
 
     harness.mustDrawSolidQuad();
@@ -1771,7 +1768,7 @@ TEST_F(CCLayerTreeHostImplTest, partialSwapNoUpdate)
     harness.mustDrawSolidQuad();
     harness.mustSetScissor(0, 0, 10, 10);
 
-    OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context, FakeLayerWithQuads::create(1));
+    OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context.release(), FakeLayerWithQuads::create(1));
 
     // Draw once to make sure layer is not new
     CCLayerTreeHostImpl::FrameData frame;
@@ -1817,7 +1814,7 @@ static PassOwnPtr<CCLayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, C
 {
     CCSettings::setPartialSwapEnabled(partialSwap);
 
-    RefPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new PartialSwapContext()), GraphicsContext3D::RenderDirectlyToHostWindow));
+    OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext));
 
     CCLayerTreeSettings settings;
     OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, client);
@@ -1928,7 +1925,7 @@ TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnScissoredLayer)
     CCLayerTreeSettings settings;
     CCSettings::setPartialSwapEnabled(true);
 
-    RefPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new PartialSwapContext()), GraphicsContext3D::RenderDirectlyToHostWindow));
+    OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext));
     OwnPtr<CCLayerTreeHostImpl> myHostImpl = CCLayerTreeHostImpl::create(settings, this);
     myHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
     myHostImpl->setViewportSize(IntSize(10, 10));
@@ -2028,7 +2025,7 @@ public:
 TEST_F(CCLayerTreeHostImplTest, finishAllRenderingAfterContextLost)
 {
     // The context initialization will fail, but we should still be able to call finishAllRendering() without any ill effects.
-    m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3DMakeCurrentFails), GraphicsContext3D::RenderDirectlyToHostWindow)), UnthrottledUploader);
+    m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new FakeWebGraphicsContext3DMakeCurrentFails)), UnthrottledUploader);
     m_hostImpl->finishAllRendering();
 }
 
@@ -2138,11 +2135,6 @@ public:
             ADD_FAILURE() << "Trying to bind texture id " << id;
     }
 
-    static PassRefPtr<GraphicsContext3D> createGraphicsContext()
-    {
-        return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new StrictWebGraphicsContext3D()), GraphicsContext3D::RenderDirectlyToHostWindow);
-    }
-
 private:
     HashSet<unsigned> m_allocatedTextureIds;
 };
@@ -2193,11 +2185,6 @@ public:
 
         return WebString();
     }
-
-    static PassRefPtr<GraphicsContext3D> createGraphicsContext()
-    {
-        return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new StrictWebGraphicsContext3DWithIOSurface()), GraphicsContext3D::RenderDirectlyToHostWindow);
-    }
 };
 
 class FakeWebGraphicsContext3DWithIOSurface : public FakeWebGraphicsContext3D {
@@ -2209,11 +2196,6 @@ public:
 
         return WebString();
     }
-
-    static PassRefPtr<GraphicsContext3D> createGraphicsContext()
-    {
-        return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3DWithIOSurface()), GraphicsContext3D::RenderDirectlyToHostWindow);
-    }
 };
 
 TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
@@ -2261,7 +2243,7 @@ TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
     rootLayer->addChild(ioSurfaceLayer.release());
 
     // Use a context that supports IOSurfaces
-    m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(FakeWebGraphicsContext3DWithIOSurface::createGraphicsContext()), UnthrottledUploader);
+    m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new FakeWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);
 
     m_hostImpl->setRootLayer(rootLayer.release());
 
@@ -2273,7 +2255,7 @@ TEST_F(CCLayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
 
     // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSurface,
     // that will warn if any resource from the previous context gets used.
-    m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(StrictWebGraphicsContext3DWithIOSurface::createGraphicsContext()), UnthrottledUploader);
+    m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(adoptPtr(new StrictWebGraphicsContext3DWithIOSurface)), UnthrottledUploader);
     EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
     m_hostImpl->drawLayers(frame);
     m_hostImpl->didDrawAllLayers(frame);
@@ -2314,11 +2296,6 @@ public:
         return WebString();
     }
 
-    PassRefPtr<GraphicsContext3D> createGraphicsContext()
-    {
-        return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(this), GraphicsContext3D::RenderDirectlyToHostWindow);
-    }
-
     unsigned numTextures() const { return m_numTextures; }
 
 private:
@@ -2370,11 +2347,10 @@ TEST_F(CCLayerTreeHostImplTest, layersFreeTextures)
     ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get());
     rootLayer->addChild(ioSurfaceLayer.release());
 
-    // Lose the context, replacing it with a TrackingWebGraphicsContext3D, that
-    // tracks the number of textures allocated. This pointer is owned by its
-    // GraphicsContext3D.
-    TrackingWebGraphicsContext3D* trackingWebGraphicsContext = new TrackingWebGraphicsContext3D();
-    m_hostImpl->initializeLayerRenderer(CCGraphicsContext::create3D(trackingWebGraphicsContext->createGraphicsContext()), UnthrottledUploader);
+    // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which the CCLayerTreeHostImpl takes ownership of).
+    OwnPtr<CCGraphicsContext> ccContext(CCGraphicsContext::create3D(adoptPtr(new TrackingWebGraphicsContext3D)));
+    TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<TrackingWebGraphicsContext3D*>(ccContext->context3D());
+    m_hostImpl->initializeLayerRenderer(ccContext.release(), UnthrottledUploader);
 
     m_hostImpl->setRootLayer(rootLayer.release());
 
@@ -2402,11 +2378,11 @@ public:
 
 TEST_F(CCLayerTreeHostImplTest, hasTransparentBackground)
 {
-    MockDrawQuadsToFillScreenContext* mockContext = new MockDrawQuadsToFillScreenContext();
-    RefPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(mockContext), GraphicsContext3D::RenderDirectlyToHostWindow));
+    OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new MockDrawQuadsToFillScreenContext));
+    MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToFillScreenContext*>(context->context3D());
 
     // Run test case
-    OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context, CCLayerImpl::create(1));
+    OwnPtr<CCLayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, context.release(), CCLayerImpl::create(1));
     myHostImpl->setBackgroundColor(Color::white);
 
     // Verify one quad is drawn when transparent background set is not set.
@@ -2431,7 +2407,7 @@ TEST_F(CCLayerTreeHostImplTest, hasTransparentBackground)
 
 static void setupLayersForTextureCaching(CCLayerTreeHostImpl* layerTreeHostImpl, CCLayerImpl*& rootPtr, CCLayerImpl*& intermediateLayerPtr, CCLayerImpl*& surfaceLayerPtr, CCLayerImpl*& childPtr, const IntSize& rootSize)
 {
-    RefPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new PartialSwapContext()), GraphicsContext3D::RenderDirectlyToHostWindow));
+    OwnPtr<CCGraphicsContext> context = CCGraphicsContext::create3D(adoptPtr(new PartialSwapContext));
 
     layerTreeHostImpl->initializeLayerRenderer(context.release(), UnthrottledUploader);
     layerTreeHostImpl->setViewportSize(rootSize);
index d277379..3bf2620 100644 (file)
@@ -1369,7 +1369,7 @@ public:
 
     virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl)
     {
-        CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(impl->context()->context3D()));
+        CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->context3D());
 
         switch (impl->sourceFrameNumber()) {
         case 0:
@@ -1403,7 +1403,7 @@ public:
 
     virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl)
     {
-        CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(impl->context()->context3D()));
+        CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->context3D());
 
         // Number of textures used for draw should always be one.
         EXPECT_EQ(1, context->numUsedTextures());
@@ -1473,7 +1473,7 @@ public:
 
     virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl)
     {
-        CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(impl->context()->context3D()));
+        CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->context3D());
 
         switch (impl->sourceFrameNumber()) {
         case 0:
@@ -1542,7 +1542,7 @@ public:
 
     virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl)
     {
-        CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(impl->context()->context3D()));
+        CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->context3D());
 
         // Number of textures used for drawing should two except for frame 4
         // where the viewport only contains one layer.
index 4fe40f2..541c23f 100644 (file)
@@ -70,9 +70,9 @@ public:
         endTestAfterDelay(ceil(CCSingleThreadProxy::animationTimerDelay() * 1000));
     }
 
-    virtual PassRefPtr<GraphicsContext3D> createContext() OVERRIDE
+    virtual PassOwnPtr<WebGraphicsContext3D> createContext() OVERRIDE
     {
-        return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3DMakeCurrentFails), GraphicsContext3D::RenderDirectlyToHostWindow);
+        return adoptPtr(new FakeWebGraphicsContext3DMakeCurrentFails);
     }
 
     virtual void afterTest()
@@ -117,9 +117,9 @@ public:
         endTestAfterDelay(ceil(CCSingleThreadProxy::animationTimerDelay() * 1000));
     }
 
-    virtual PassRefPtr<GraphicsContext3D> createContext() OVERRIDE
+    virtual PassOwnPtr<WebGraphicsContext3D> createContext() OVERRIDE
     {
-        return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3DMakeCurrentFails), GraphicsContext3D::RenderDirectlyToHostWindow);
+        return adoptPtr(new FakeWebGraphicsContext3DMakeCurrentFails);
     }
 
     virtual void afterTest()
index 57b6df1..40d3ce5 100644 (file)
@@ -103,14 +103,9 @@ CompositorFakeWebGraphicsContext3DWithTextureTracking::CompositorFakeWebGraphics
 {
 }
 
-PassRefPtr<GraphicsContext3D> TestHooks::createContext()
+PassOwnPtr<WebGraphicsContext3D> TestHooks::createContext()
 {
-    GraphicsContext3D::Attributes attrs;
-    WebGraphicsContext3D::Attributes webAttrs;
-    webAttrs.alpha = attrs.alpha;
-
-    OwnPtr<WebGraphicsContext3D> webContext = CompositorFakeWebGraphicsContext3DWithTextureTracking::create(webAttrs);
-    return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow);
+    return CompositorFakeWebGraphicsContext3DWithTextureTracking::create(WebGraphicsContext3D::Attributes());
 }
 
 PassOwnPtr<MockLayerTreeHostImpl> MockLayerTreeHostImpl::create(TestHooks* testHooks, const CCLayerTreeSettings& settings, CCLayerTreeHostImplClient* client)
@@ -232,7 +227,7 @@ public:
         m_testHooks->applyScrollAndScale(scrollDelta, scale);
     }
 
-    virtual PassRefPtr<GraphicsContext3D> createContext3D() OVERRIDE
+    virtual PassOwnPtr<WebGraphicsContext3D> createContext3D() OVERRIDE
     {
         return m_testHooks->createContext();
     }
index c0ca44f..75886ef 100644 (file)
@@ -68,7 +68,7 @@ public:
     virtual void notifyAnimationStarted(double time) { }
     virtual void notifyAnimationFinished(double time) { }
 
-    virtual PassRefPtr<WebCore::GraphicsContext3D> createContext();
+    virtual PassOwnPtr<WebKit::WebGraphicsContext3D> createContext();
 };
 
 class TimeoutTask;
index bacf873..30450db 100644 (file)
@@ -74,15 +74,11 @@ class Canvas2DLayerBridgeTest : public Test {
 protected:
     void fullLifecycleTest(ThreadMode threadMode, DeferralMode deferralMode)
     {
-        GraphicsContext3D::Attributes attrs;
-
-        RefPtr<GraphicsContext3D> mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), GraphicsContext3D::RenderDirectlyToHostWindow);
-        RefPtr<CCGraphicsContext> ccMainContext = CCGraphicsContext::create3D(mainContext);
-        RefPtr<GraphicsContext3D> implContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), GraphicsContext3D::RenderDirectlyToHostWindow);
-        RefPtr<CCGraphicsContext> ccImplContext = CCGraphicsContext::create3D(implContext);
+        RefPtr<GraphicsContext3D> mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext), GraphicsContext3D::RenderOffscreen);
+        OwnPtr<CCGraphicsContext> ccImplContext = CCGraphicsContext::create3D(adoptPtr(new MockCanvasContext));
 
         MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(mainContext.get()));
-        MockCanvasContext& implMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(implContext.get()));
+        MockCanvasContext& implMock = *static_cast<MockCanvasContext*>(ccImplContext->context3D());
 
         MockWebTextureUpdater updater;
 
@@ -151,7 +147,7 @@ TEST(Canvas2DLayerBridgeTest2, testClearClient)
 {
     GraphicsContext3D::Attributes attrs;
 
-    RefPtr<GraphicsContext3D> mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), GraphicsContext3D::RenderDirectlyToHostWindow);
+    RefPtr<GraphicsContext3D> mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext), GraphicsContext3D::RenderDirectlyToHostWindow);
     OwnPtr<Canvas2DLayerBridge> bridge = Canvas2DLayerBridge::create(mainContext.get(), IntSize(100, 100), Deferred, 1);
     RefPtr<LayerChromium> layer = bridge->layer();
     bridge.clear();
diff --git a/Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h b/Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h
deleted file mode 100644 (file)
index 937b62d..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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 CompositorFakeGraphicsContext3D_h
-#define CompositorFakeGraphicsContext3D_h
-
-#include "CompositorFakeWebGraphicsContext3D.h"
-#include "GraphicsContext3D.h"
-#include "GraphicsContext3DPrivate.h"
-
-namespace WebCore {
-
-static PassRefPtr<GraphicsContext3D> createCompositorMockGraphicsContext3D(GraphicsContext3D::Attributes attrs)
-{
-    WebKit::WebGraphicsContext3D::Attributes webAttrs;
-    webAttrs.alpha = attrs.alpha;
-
-    OwnPtr<WebKit::WebGraphicsContext3D> webContext = WebKit::CompositorFakeWebGraphicsContext3D::create(webAttrs);
-    return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow);
-}
-
-}
-
-#endif
diff --git a/Source/WebKit/chromium/tests/DrawingBufferChromiumTest.cpp b/Source/WebKit/chromium/tests/DrawingBufferChromiumTest.cpp
deleted file mode 100644 (file)
index 27ef492..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2012 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 "DrawingBuffer.h"
-
-#include "CompositorFakeGraphicsContext3D.h"
-#include "LayerChromium.h"
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-using namespace WebCore;
-using namespace WebKit;
-
-namespace {
-
-TEST(DrawingBufferChromiumTest, opaqueFormats)
-{
-    RefPtr<DrawingBuffer> buffer;
-
-    GraphicsContext3D::Attributes alphaAttrs;
-    alphaAttrs.alpha = true;
-    GraphicsContext3D::Attributes opaqueAttrs;
-    opaqueAttrs.alpha = false;
-
-    RefPtr<GraphicsContext3D> alphaContext = createCompositorMockGraphicsContext3D(alphaAttrs);
-    EXPECT_TRUE(alphaContext);
-    RefPtr<GraphicsContext3D> opaqueContext = createCompositorMockGraphicsContext3D(opaqueAttrs);
-    EXPECT_TRUE(opaqueContext);
-
-    buffer = DrawingBuffer::create(alphaContext.get(), IntSize(), DrawingBuffer::Preserve, DrawingBuffer::Alpha);
-    EXPECT_FALSE(buffer->platformLayer()->opaque());
-    buffer = DrawingBuffer::create(alphaContext.get(), IntSize(), DrawingBuffer::Discard, DrawingBuffer::Alpha);
-    EXPECT_FALSE(buffer->platformLayer()->opaque());
-
-    buffer = DrawingBuffer::create(opaqueContext.get(), IntSize(), DrawingBuffer::Preserve, DrawingBuffer::Opaque);
-    EXPECT_TRUE(buffer->platformLayer()->opaque());
-    buffer = DrawingBuffer::create(opaqueContext.get(), IntSize(), DrawingBuffer::Discard, DrawingBuffer::Opaque);
-    EXPECT_TRUE(buffer->platformLayer()->opaque());
-}
-
-} // namespace
index 6ab616d..0b3c3fe 100755 (executable)
@@ -27,8 +27,8 @@
 
 #include "config.h"
 
+#include "CompositorFakeWebGraphicsContext3D.h"
 #include "cc/CCLayerTreeHost.h"
-#include "CompositorFakeGraphicsContext3D.h"
 
 namespace WebCore {
 
@@ -39,10 +39,10 @@ public:
     virtual void updateAnimations(double monotonicFrameBeginTime) OVERRIDE { }
     virtual void layout() OVERRIDE { }
     virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) OVERRIDE { }
-    virtual PassRefPtr<GraphicsContext3D> createContext3D() OVERRIDE
+    virtual PassOwnPtr<WebKit::WebGraphicsContext3D> createContext3D() OVERRIDE
     {
-        GraphicsContext3D::Attributes attrs;
-        return createCompositorMockGraphicsContext3D(attrs);
+        WebKit::WebGraphicsContext3D::Attributes attrs;
+        return WebKit::CompositorFakeWebGraphicsContext3D::create(WebKit::WebGraphicsContext3D::Attributes());
     }
     virtual void didRecreateContext(bool success) OVERRIDE { }
     virtual void willCommit() OVERRIDE { }
index 71cb8ba..720630e 100644 (file)
 
 #include "config.h"
 
-#include "GraphicsContext3D.h"
-
 #include "FakeWebGraphicsContext3D.h"
-#include "GraphicsContext3DPrivate.h"
 
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
 using namespace WebCore;
 using namespace WebKit;
 
-class FrameCountingContext : public FakeWebGraphicsContext3D {
-public:
-    FrameCountingContext() : m_frame(0) { }
-
-    // This method would normally do a glSwapBuffers under the hood.
-    virtual void prepareTexture() { m_frame++; }
-
-    int frameCount() { return m_frame; }
-
-private:
-    int m_frame;
-};
-
-TEST(FakeGraphicsContext3DTest, CanOverrideManually)
-{
-    GraphicsContext3D::Attributes attrs;
-    RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FrameCountingContext()), GraphicsContext3D::RenderDirectlyToHostWindow);
-    FrameCountingContext& mockContext = *static_cast<FrameCountingContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()));
-
-    for (int i = 0; i < 10; i++) {
-        context->clearColor(0, 0, 0, 1);
-        context->prepareTexture();
-    }
-    context->finish();
-
-    EXPECT_EQ(10, mockContext.frameCount());
-}
-
-
-class GMockContext : public FakeWebGraphicsContext3D {
-public:
-    MOCK_METHOD0(getError, WGC3Denum());
-};
-
-TEST(FakeGraphicsContext3DTest, CanUseGMock)
-{
-    GraphicsContext3D::Attributes attrs;
-    RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new GMockContext()), GraphicsContext3D::RenderDirectlyToHostWindow);
-    GMockContext& mockContext = *static_cast<GMockContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()));
-
-    EXPECT_CALL(mockContext, getError())
-            .WillRepeatedly(testing::Return(314));
-
-    // It's OK to call methods GMock doesn't know about.
-    context->makeContextCurrent();
-
-    // Check that the mocked method is returning as intended.
-    for (int i = 0; i < 10; i++)
-        EXPECT_EQ((int)context->getError(), 314);
-}
-
 class ContextThatCountsMakeCurrents : public FakeWebGraphicsContext3D {
 public:
     ContextThatCountsMakeCurrents() : m_makeCurrentCount(0) { }
@@ -101,21 +47,10 @@ private:
 };
 
 
-TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldNotMakeCurrent)
-{
-    GraphicsContext3D::Attributes attrs;
-    RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), GraphicsContext3D::RenderDirectlyToHostWindow);
-    EXPECT_TRUE(context);
-    ContextThatCountsMakeCurrents& mockContext = *static_cast<ContextThatCountsMakeCurrents*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()));
-    EXPECT_EQ(0, mockContext.makeCurrentCount());
-}
-
-TEST(FakeGraphicsContext3DTest, ContextForAnotherThreadShouldNotMakeCurrent)
+TEST(FakeGraphicsContext3DTest, ContextCreationShouldNotMakeCurrent)
 {
-    GraphicsContext3D::Attributes attrs;
-    RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), GraphicsContext3D::RenderDirectlyToHostWindow);
+    OwnPtr<ContextThatCountsMakeCurrents> context(adoptPtr(new ContextThatCountsMakeCurrents));
     EXPECT_TRUE(context);
-    ContextThatCountsMakeCurrents& mockContext = *static_cast<ContextThatCountsMakeCurrents*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()));
-    EXPECT_EQ(0, mockContext.makeCurrentCount());
+    EXPECT_EQ(0, context->makeCurrentCount());
 }
 
index 410c45d..1979d93 100644 (file)
@@ -27,7 +27,7 @@
 #include "GraphicsLayerChromium.h"
 
 #include "CCAnimationTestCommon.h"
-#include "CompositorFakeGraphicsContext3D.h"
+#include "CompositorFakeWebGraphicsContext3D.h"
 #include "GraphicsContext3D.h"
 #include "GraphicsContext3DPrivate.h"
 #include "GraphicsLayer.h"
@@ -42,6 +42,7 @@
 #include "cc/CCSingleThreadProxy.h"
 
 #include <gtest/gtest.h>
+#include <public/WebGraphicsContext3D.h>
 #include <wtf/PassOwnPtr.h>
 
 using namespace WebCore;
@@ -67,10 +68,9 @@ public:
     virtual void updateAnimations(double frameBeginTime) OVERRIDE { }
     virtual void layout() OVERRIDE { }
     virtual void applyScrollAndScale(const IntSize& scrollDelta, float pageScale) OVERRIDE { }
-    virtual PassRefPtr<GraphicsContext3D> createContext3D() OVERRIDE
+    virtual PassOwnPtr<WebGraphicsContext3D> createContext3D() OVERRIDE
     {
-        GraphicsContext3D::Attributes attrs;
-        return createCompositorMockGraphicsContext3D(attrs);
+        return CompositorFakeWebGraphicsContext3D::create(WebGraphicsContext3D::Attributes());
     }
     virtual void didRecreateContext(bool success) OVERRIDE { }
     virtual void willCommit() OVERRIDE { }
index e465096..cfdcdc1 100644 (file)
@@ -28,7 +28,6 @@
 #include "CCTestCommon.h"
 #include "FakeWebGraphicsContext3D.h"
 #include "GraphicsContext3D.h"
-#include "GraphicsContext3DPrivate.h"
 #include "WebCompositor.h"
 #include "cc/CCDrawQuad.h"
 #include "cc/CCSettings.h"
@@ -109,7 +108,7 @@ private:
 
 class FakeLayerRendererChromium : public LayerRendererChromium {
 public:
-    FakeLayerRendererChromium(CCRendererClient* client, PassRefPtr<GraphicsContext3D> context) : LayerRendererChromium(client, context, UnthrottledUploader) { }
+    FakeLayerRendererChromium(CCRendererClient* client, WebGraphicsContext3D* context) : LayerRendererChromium(client, context, UnthrottledUploader) { }
 
     // LayerRendererChromium methods.
 
@@ -123,9 +122,8 @@ protected:
     LayerRendererChromiumTest()
         : m_suggestHaveBackbufferYes(1, true)
         , m_suggestHaveBackbufferNo(1, false)
-        , m_context(GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FrameCountingMemoryAllocationSettingContext()), GraphicsContext3D::RenderDirectlyToHostWindow))
-        , m_mockContext(*static_cast<FrameCountingMemoryAllocationSettingContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_context.get())))
-        , m_layerRendererChromium(&m_mockClient, m_context.release())
+        , m_context(adoptPtr(new FrameCountingMemoryAllocationSettingContext))
+        , m_layerRendererChromium(&m_mockClient, m_context.get())
     {
     }
 
@@ -148,8 +146,7 @@ protected:
     WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes;
     WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo;
 
-    RefPtr<GraphicsContext3D> m_context;
-    FrameCountingMemoryAllocationSettingContext& m_mockContext;
+    OwnPtr<FrameCountingMemoryAllocationSettingContext> m_context;
     FakeCCRendererClient m_mockClient;
     FakeLayerRendererChromium m_layerRendererChromium;
     CCScopedSettings m_scopedSettings;
@@ -160,12 +157,12 @@ protected:
 // Expected: it does nothing.
 TEST_F(LayerRendererChromiumTest, SuggestBackbufferYesWhenItAlreadyExistsShouldDoNothing)
 {
-    m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferYes);
+    m_context->setMemoryAllocation(m_suggestHaveBackbufferYes);
     EXPECT_EQ(0, m_mockClient.setFullRootLayerDamageCount());
     EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded());
 
     swapBuffers();
-    EXPECT_EQ(1, m_mockContext.frameCount());
+    EXPECT_EQ(1, m_context->frameCount());
 }
 
 // Test LayerRendererChromium discardFramebuffer functionality:
@@ -174,7 +171,7 @@ TEST_F(LayerRendererChromiumTest, SuggestBackbufferYesWhenItAlreadyExistsShouldD
 TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoShouldDiscardBackbufferAndDamageRootLayerWhileNotVisible)
 {
     m_layerRendererChromium.setVisible(false);
-    m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo);
+    m_context->setMemoryAllocation(m_suggestHaveBackbufferNo);
     EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
     EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded());
 }
@@ -185,7 +182,7 @@ TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoShouldDiscardBackbufferAndD
 TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoDoNothingWhenVisible)
 {
     m_layerRendererChromium.setVisible(true);
-    m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo);
+    m_context->setMemoryAllocation(m_suggestHaveBackbufferNo);
     EXPECT_EQ(0, m_mockClient.setFullRootLayerDamageCount());
     EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded());
 }
@@ -197,11 +194,11 @@ TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoDoNothingWhenVisible)
 TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoWhenItDoesntExistShouldDoNothing)
 {
     m_layerRendererChromium.setVisible(false);
-    m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo);
+    m_context->setMemoryAllocation(m_suggestHaveBackbufferNo);
     EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
     EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded());
 
-    m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo);
+    m_context->setMemoryAllocation(m_suggestHaveBackbufferNo);
     EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
     EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded());
 }
@@ -212,7 +209,7 @@ TEST_F(LayerRendererChromiumTest, SuggestBackbufferNoWhenItDoesntExistShouldDoNo
 TEST_F(LayerRendererChromiumTest, DiscardedBackbufferIsRecreatedForScopeDuration)
 {
     m_layerRendererChromium.setVisible(false);
-    m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo);
+    m_context->setMemoryAllocation(m_suggestHaveBackbufferNo);
     EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded());
     EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
 
@@ -221,13 +218,13 @@ TEST_F(LayerRendererChromiumTest, DiscardedBackbufferIsRecreatedForScopeDuration
     EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded());
 
     swapBuffers();
-    EXPECT_EQ(1, m_mockContext.frameCount());
+    EXPECT_EQ(1, m_context->frameCount());
 }
 
 TEST_F(LayerRendererChromiumTest, FramebufferDiscardedAfterReadbackWhenNotVisible)
 {
     m_layerRendererChromium.setVisible(false);
-    m_mockContext.setMemoryAllocation(m_suggestHaveBackbufferNo);
+    m_context->setMemoryAllocation(m_suggestHaveBackbufferNo);
     EXPECT_TRUE(m_layerRendererChromium.isFramebufferDiscarded());
     EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
 
@@ -311,7 +308,8 @@ TEST(LayerRendererChromiumTest2, initializationDoesNotMakeSynchronousCalls)
 {
     CCScopedSettings scopedSettings;
     FakeCCRendererClient mockClient;
-    FakeLayerRendererChromium layerRendererChromium(&mockClient, GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ForbidSynchronousCallContext), GraphicsContext3D::RenderDirectlyToHostWindow));
+    OwnPtr<WebGraphicsContext3D> context(adoptPtr(new ForbidSynchronousCallContext));
+    FakeLayerRendererChromium layerRendererChromium(&mockClient, context.get());
 
     EXPECT_TRUE(layerRendererChromium.initialize());
 }
@@ -353,7 +351,8 @@ TEST(LayerRendererChromiumTest2, initializationWithQuicklyLostContextDoesNotAsse
 {
     CCScopedSettings scopedSettings;
     FakeCCRendererClient mockClient;
-    FakeLayerRendererChromium layerRendererChromium(&mockClient, GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new LoseContextOnFirstGetContext), GraphicsContext3D::RenderDirectlyToHostWindow));
+    OwnPtr<WebGraphicsContext3D> context(adoptPtr(new LoseContextOnFirstGetContext));
+    FakeLayerRendererChromium layerRendererChromium(&mockClient, context.get());
 
     layerRendererChromium.initialize();
 }
@@ -373,7 +372,8 @@ public:
 TEST(LayerRendererChromiumTest2, initializationWithoutGpuMemoryManagerExtensionSupportShouldDefaultToNonZeroAllocation)
 {
     FakeCCRendererClient mockClient;
-    FakeLayerRendererChromium layerRendererChromium(&mockClient, GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatDoesNotSupportMemoryManagmentExtensions), GraphicsContext3D::RenderDirectlyToHostWindow));
+    OwnPtr<WebGraphicsContext3D> context(adoptPtr(new ContextThatDoesNotSupportMemoryManagmentExtensions));
+    FakeLayerRendererChromium layerRendererChromium(&mockClient, context.get());
 
     layerRendererChromium.initialize();
 
@@ -398,8 +398,8 @@ private:
 TEST(LayerRendererChromiumTest2, opaqueBackground)
 {
     FakeCCRendererClient mockClient;
-    RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ClearCountingContext), GraphicsContext3D::RenderDirectlyToHostWindow);
-    FakeLayerRendererChromium layerRendererChromium(&mockClient, context);
+    OwnPtr<ClearCountingContext> context(adoptPtr(new ClearCountingContext));
+    FakeLayerRendererChromium layerRendererChromium(&mockClient, context.get());
 
     mockClient.rootRenderPass()->setHasTransparentBackground(false);
 
@@ -412,17 +412,17 @@ TEST(LayerRendererChromiumTest2, opaqueBackground)
     // On DEBUG builds, render passes with opaque background clear to blue to
     // easily see regions that were not drawn on the screen.
 #if defined(NDEBUG)
-    EXPECT_EQ(0, static_cast<ClearCountingContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()))->clearCount());
+    EXPECT_EQ(0, context->clearCount());
 #else
-    EXPECT_EQ(1, static_cast<ClearCountingContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()))->clearCount());
+    EXPECT_EQ(1, context->clearCount());
 #endif
 }
 
 TEST(LayerRendererChromiumTest2, transparentBackground)
 {
     FakeCCRendererClient mockClient;
-    RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ClearCountingContext), GraphicsContext3D::RenderDirectlyToHostWindow);
-    FakeLayerRendererChromium layerRendererChromium(&mockClient, context);
+    OwnPtr<ClearCountingContext> context(adoptPtr(new ClearCountingContext));
+    FakeLayerRendererChromium layerRendererChromium(&mockClient, context.get());
 
     mockClient.rootRenderPass()->setHasTransparentBackground(true);
 
@@ -432,5 +432,5 @@ TEST(LayerRendererChromiumTest2, transparentBackground)
     layerRendererChromium.drawRenderPass(mockClient.rootRenderPass(), FloatRect());
     layerRendererChromium.finishDrawingFrame();
 
-    EXPECT_EQ(1, static_cast<ClearCountingContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()))->clearCount());
+    EXPECT_EQ(1, context->clearCount());
 }
index d71b8ce..2c90c4e 100644 (file)
@@ -52,9 +52,8 @@ public:
 TEST(TextureCopierTest, testDrawArraysCopy)
 {
     GraphicsContext3D::Attributes attrs;
-    RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockContext()), GraphicsContext3D::RenderDirectlyToHostWindow);
-    MockContext& mockContext = *static_cast<MockContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()));
-    RefPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(context);
+    OwnPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(adoptPtr(new MockContext));
+    MockContext& mockContext = *static_cast<MockContext*>(ccContext->context3D());
 
     {
         InSequence sequence;
@@ -79,7 +78,7 @@ TEST(TextureCopierTest, testDrawArraysCopy)
     int sourceTextureId = 1;
     int destTextureId = 2;
     IntSize size(256, 128);
-    OwnPtr<AcceleratedTextureCopier> copier(AcceleratedTextureCopier::create(context));
+    OwnPtr<AcceleratedTextureCopier> copier(AcceleratedTextureCopier::create(ccContext->context3D()));
     copier->copyTexture(ccContext.get(), sourceTextureId, destTextureId, size);
 }
 
index 4b0dfd0..39a57d1 100644 (file)
@@ -65,11 +65,10 @@ private:
 TEST(ThrottledTextureUploaderTest, IsBusy)
 {
     GraphicsContext3D::Attributes attrs;
-    RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3DWithQueryTesting()), GraphicsContext3D::RenderDirectlyToHostWindow);
-    FakeWebGraphicsContext3DWithQueryTesting& fakeContext = *static_cast<FakeWebGraphicsContext3DWithQueryTesting*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get()));
-    OwnPtr<ThrottledTextureUploader> uploader = ThrottledTextureUploader::create(context, 2);
+    OwnPtr<FakeWebGraphicsContext3DWithQueryTesting> fakeContext(adoptPtr(new FakeWebGraphicsContext3DWithQueryTesting));
+    OwnPtr<ThrottledTextureUploader> uploader = ThrottledTextureUploader::create(fakeContext.get(), 2);
 
-    fakeContext.setResultAvailable(0);
+    fakeContext->setResultAvailable(0);
     EXPECT_FALSE(uploader->isBusy());
     uploader->beginUploads();
     uploader->endUploads();
@@ -78,7 +77,7 @@ TEST(ThrottledTextureUploaderTest, IsBusy)
     uploader->endUploads();
     EXPECT_TRUE(uploader->isBusy());
 
-    fakeContext.setResultAvailable(1);
+    fakeContext->setResultAvailable(1);
     EXPECT_FALSE(uploader->isBusy());
     uploader->beginUploads();
     uploader->endUploads();
index 9495e70..04b3c38 100644 (file)
@@ -673,8 +673,7 @@ TEST(TiledLayerChromiumTest, invalidateFromPrepare)
     FakeTextureAllocator fakeAllocator;
     FakeTextureCopier fakeCopier;
     FakeTextureUploader fakeUploader;
-    RefPtr<GraphicsContext3D> context = createCompositorMockGraphicsContext3D(GraphicsContext3D::Attributes());
-    RefPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(context);
+    OwnPtr<CCGraphicsContext> ccContext = CCGraphicsContext::create3D(WebKit::CompositorFakeWebGraphicsContext3D::create(WebKit::WebGraphicsContext3D::Attributes()));
 
     // The tile size is 100x100, so this invalidates and then paints two tiles.
     layer->setBounds(IntSize(100, 200));