From 48dc8f8705214ab9388464e0102c17122ac1c34f Mon Sep 17 00:00:00 2001 From: "jamesr@google.com" Date: Fri, 24 Feb 2012 01:38:43 +0000 Subject: [PATCH] [chromium] Clean up GraphicsContext3D initialization paths https://bugs.webkit.org/show_bug.cgi?id=79321 Reviewed by Kenneth Russell. This simplifies the GraphicsContext3D initialization paths down to two simple codepaths, one for offscreen contexts initialized from WebCore and one for onscreen (compositor) contexts initialized by WebViewImpl or WebLayerTreeViewImpl. Offscreen initialization path: 1) WebCore code calls WebCore::GraphicsContext3D::create(), implemented in GraphicsContext3DChromium.cpp 2) GraphicsContext3D::create() instantiates a WebGraphicsContext3D via the static WebKitPlatformSupport interface 3) GraphicsContext3DPrivate::createGraphicsContextFromWebContext() wraps the WebGraphicsContext3D in a GraphicsContext3D's m_private pointer. Onscreen initialization path: 1) WebViewImpl or WebLayerTreeViewImpl request an onscreen WebGraphicsContext3D from either their WebViewClient or WebLayerTreeViewClient, respectively 2) GraphicsContext3DPrivate::createGraphicsContextFromWebContext() wraps the WebGraphicsContext3D in a GraphicsContext3D's m_private pointer. There are no other initialization paths. Specifically, we do not support instantiating onscreen contexts from within WebCore. * src/GraphicsContext3DChromium.cpp: (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate): (WebCore::GraphicsContext3DPrivate::createGraphicsContextFromWebContext): (WebCore): (WebCore::GraphicsContext3DPrivate::platformTexture): (WebCore::GraphicsContext3D::create): * src/GraphicsContext3DPrivate.h: (GraphicsContext3DPrivate): * src/WebLayerTreeViewImpl.cpp: (WebKit::WebLayerTreeViewImpl::createLayerTreeHostContext3D): * src/WebViewImpl.cpp: (std::getCompositorContextAttributes): (WebKit::WebViewImpl::createCompositorGraphicsContext3D): (WebKit): (WebKit::WebViewImpl::createLayerTreeHostContext3D): (WebKit::WebViewImpl::graphicsContext3D): * src/WebViewImpl.h: (WebViewImpl): * tests/CCLayerTreeHostImplTest.cpp: (WebKit::CCLayerTreeHostImplTest::createContext): (CCLayerTreeHostImplTest): (WebKit::TEST_F): * tests/CCLayerTreeHostTest.cpp: (WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D): * tests/Canvas2DLayerChromiumTest.cpp: (WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest): * tests/CompositorFakeGraphicsContext3D.h: (WebCore::createCompositorMockGraphicsContext3D): * tests/FakeGraphicsContext3DTest.cpp: (TEST): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108706 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebKit/chromium/ChangeLog | 57 +++++++++++++++ .../chromium/src/GraphicsContext3DChromium.cpp | 84 +++++++--------------- .../WebKit/chromium/src/GraphicsContext3DPrivate.h | 26 ++----- .../WebKit/chromium/src/WebLayerTreeViewImpl.cpp | 16 +---- Source/WebKit/chromium/src/WebViewImpl.cpp | 50 +++++++------ Source/WebKit/chromium/src/WebViewImpl.h | 5 +- .../chromium/tests/CCLayerTreeHostImplTest.cpp | 20 +++--- .../WebKit/chromium/tests/CCLayerTreeHostTest.cpp | 5 +- .../chromium/tests/Canvas2DLayerChromiumTest.cpp | 4 +- .../tests/CompositorFakeGraphicsContext3D.h | 5 +- .../chromium/tests/FakeGraphicsContext3DTest.cpp | 8 +-- 11 files changed, 142 insertions(+), 138 deletions(-) diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index ccabf6a..d48f25b 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,60 @@ +2012-02-23 James Robinson + + [chromium] Clean up GraphicsContext3D initialization paths + https://bugs.webkit.org/show_bug.cgi?id=79321 + + Reviewed by Kenneth Russell. + + This simplifies the GraphicsContext3D initialization paths down to two simple codepaths, one for offscreen + contexts initialized from WebCore and one for onscreen (compositor) contexts initialized by WebViewImpl or + WebLayerTreeViewImpl. + + Offscreen initialization path: + 1) WebCore code calls WebCore::GraphicsContext3D::create(), implemented in GraphicsContext3DChromium.cpp + 2) GraphicsContext3D::create() instantiates a WebGraphicsContext3D via the static WebKitPlatformSupport interface + 3) GraphicsContext3DPrivate::createGraphicsContextFromWebContext() wraps the WebGraphicsContext3D in a + GraphicsContext3D's m_private pointer. + + Onscreen initialization path: + 1) WebViewImpl or WebLayerTreeViewImpl request an onscreen WebGraphicsContext3D from either their WebViewClient + or WebLayerTreeViewClient, respectively + 2) GraphicsContext3DPrivate::createGraphicsContextFromWebContext() wraps the WebGraphicsContext3D in a + GraphicsContext3D's m_private pointer. + + There are no other initialization paths. Specifically, we do not support instantiating onscreen contexts from + within WebCore. + + * src/GraphicsContext3DChromium.cpp: + (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate): + (WebCore::GraphicsContext3DPrivate::createGraphicsContextFromWebContext): + (WebCore): + (WebCore::GraphicsContext3DPrivate::platformTexture): + (WebCore::GraphicsContext3D::create): + * src/GraphicsContext3DPrivate.h: + (GraphicsContext3DPrivate): + * src/WebLayerTreeViewImpl.cpp: + (WebKit::WebLayerTreeViewImpl::createLayerTreeHostContext3D): + * src/WebViewImpl.cpp: + (std::getCompositorContextAttributes): + (WebKit::WebViewImpl::createCompositorGraphicsContext3D): + (WebKit): + (WebKit::WebViewImpl::createLayerTreeHostContext3D): + (WebKit::WebViewImpl::graphicsContext3D): + * src/WebViewImpl.h: + (WebViewImpl): + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit::CCLayerTreeHostImplTest::createContext): + (CCLayerTreeHostImplTest): + (WebKit::TEST_F): + * tests/CCLayerTreeHostTest.cpp: + (WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D): + * tests/Canvas2DLayerChromiumTest.cpp: + (WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest): + * tests/CompositorFakeGraphicsContext3D.h: + (WebCore::createCompositorMockGraphicsContext3D): + * tests/FakeGraphicsContext3DTest.cpp: + (TEST): + 2012-02-23 Jonathan Backer [chromium] Plumb video damage to the damage tracker. diff --git a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp index 142a1b1..c7ac894 100644 --- a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp +++ b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp @@ -85,12 +85,11 @@ namespace WebCore { //---------------------------------------------------------------------- // GraphicsContext3DPrivate -GraphicsContext3DPrivate::GraphicsContext3DPrivate(WebKit::WebViewImpl* webViewImpl, PassOwnPtr webContext, GraphicsContext3D::Attributes attrs) +GraphicsContext3DPrivate::GraphicsContext3DPrivate(PassOwnPtr webContext, bool preserveDrawingBuffer) : m_impl(webContext) - , m_webViewImpl(webViewImpl) , m_initializedAvailableExtensions(false) , m_layerComposited(false) - , m_preserveDrawingBuffer(attrs.preserveDrawingBuffer) + , m_preserveDrawingBuffer(preserveDrawingBuffer) , m_resourceSafety(ResourceSafetyUnknown) #if USE(SKIA) , m_grContext(0) @@ -112,59 +111,19 @@ GraphicsContext3DPrivate::~GraphicsContext3DPrivate() #endif } - -PassOwnPtr GraphicsContext3DPrivate::create(WebKit::WebViewImpl* webViewImpl, PassOwnPtr webContext, GraphicsContext3D::Attributes attrs) -{ - return adoptPtr(new GraphicsContext3DPrivate(webViewImpl, webContext, attrs)); -} - -PassRefPtr GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr webContext, GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle, ThreadUsage threadUsage) +PassRefPtr GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr webContext, GraphicsContext3D::RenderStyle renderStyle, bool preserveDrawingBuffer) { - Chrome* chrome = static_cast(hostWindow); - WebKit::WebViewImpl* webViewImpl = chrome ? static_cast(chrome->client()->webView()) : 0; + bool renderDirectlyToHostWindow = renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow; - OwnPtr priv = GraphicsContext3DPrivate::create(webViewImpl, webContext, attrs); - if (!priv) - return 0; + RefPtr context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0, renderDirectlyToHostWindow)); - bool renderDirectlyToHostWindow = renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow; - RefPtr result = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderDirectlyToHostWindow)); - result->m_private = priv.release(); - return result.release(); + OwnPtr priv = adoptPtr(new GraphicsContext3DPrivate(webContext, preserveDrawingBuffer)); + context->m_private = priv.release(); + return context.release(); } namespace { -PassRefPtr createGraphicsContext(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle, GraphicsContext3DPrivate::ThreadUsage threadUsage) -{ - bool renderDirectlyToHostWindow = renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow; - - WebKit::WebGraphicsContext3D::Attributes webAttributes; - webAttributes.alpha = attrs.alpha; - webAttributes.depth = attrs.depth; - webAttributes.stencil = attrs.stencil; - webAttributes.antialias = attrs.antialias; - webAttributes.premultipliedAlpha = attrs.premultipliedAlpha; - webAttributes.canRecoverFromContextLoss = attrs.canRecoverFromContextLoss; - webAttributes.noExtensions = attrs.noExtensions; - webAttributes.shareResources = attrs.shareResources; - webAttributes.forUseOnAnotherThread = threadUsage == GraphicsContext3DPrivate::ForUseOnAnotherThread; - - Chrome* chrome = static_cast(hostWindow); - WebKit::WebViewImpl* webViewImpl = chrome ? static_cast(chrome->client()->webView()) : 0; - OwnPtr webContext; - if (!webViewImpl || !webViewImpl->client()) { - if (renderDirectlyToHostWindow) - return 0; - webContext = adoptPtr(WebKit::webKitPlatformSupport()->createOffscreenGraphicsContext3D(webAttributes)); - } else - webContext = adoptPtr(webViewImpl->client()->createGraphicsContext3D(webAttributes, renderDirectlyToHostWindow)); - if (!webContext) - return 0; - - return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), attrs, hostWindow, renderStyle, threadUsage); -} - void getDrawingParameters(DrawingBuffer* drawingBuffer, WebKit::WebGraphicsContext3D* graphicsContext3D, Platform3DObject* frameBufferId, int* width, int* height) { @@ -181,11 +140,6 @@ void getDrawingParameters(DrawingBuffer* drawingBuffer, WebKit::WebGraphicsConte } // anonymous namespace -PassRefPtr GraphicsContext3DPrivate::createGraphicsContextForAnotherThread(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) -{ - return createGraphicsContext(attrs, hostWindow, renderStyle, ForUseOnAnotherThread); -} - WebKit::WebGraphicsContext3D* GraphicsContext3DPrivate::extractWebGraphicsContext3D(GraphicsContext3D* context) { if (!context) @@ -200,8 +154,6 @@ PlatformGraphicsContext3D GraphicsContext3DPrivate::platformGraphicsContext3D() Platform3DObject GraphicsContext3DPrivate::platformTexture() const { - ASSERT(m_webViewImpl); - m_impl->setParentContext(m_webViewImpl->graphicsContext3D()); return m_impl->getPlatformTextureId(); } @@ -1031,9 +983,25 @@ GraphicsContext3D::~GraphicsContext3D() m_private->setGpuMemoryAllocationChangedCallbackCHROMIUM(nullptr); } -PassRefPtr GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) +PassRefPtr GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow*, GraphicsContext3D::RenderStyle renderStyle) { - return createGraphicsContext(attrs, hostWindow, renderStyle, GraphicsContext3DPrivate::ForUseOnThisThread); + ASSERT(renderStyle != GraphicsContext3D::RenderDirectlyToHostWindow); + + WebKit::WebGraphicsContext3D::Attributes webAttributes; + webAttributes.alpha = attrs.alpha; + webAttributes.depth = attrs.depth; + webAttributes.stencil = attrs.stencil; + webAttributes.antialias = attrs.antialias; + webAttributes.premultipliedAlpha = attrs.premultipliedAlpha; + webAttributes.canRecoverFromContextLoss = attrs.canRecoverFromContextLoss; + webAttributes.noExtensions = attrs.noExtensions; + webAttributes.shareResources = attrs.shareResources; + + OwnPtr webContext = adoptPtr(WebKit::webKitPlatformSupport()->createOffscreenGraphicsContext3D(webAttributes)); + if (!webContext) + return 0; + + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), renderStyle, attrs.preserveDrawingBuffer); } PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() const diff --git a/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h b/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h index f08ba58..d296eeb 100644 --- a/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h +++ b/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h @@ -41,8 +41,7 @@ class GrContext; namespace WebKit { class WebGraphicsContext3D; -class WebViewImpl; -} // namespace WebKit +} namespace WebCore { @@ -55,22 +54,10 @@ class GraphicsContext3DMemoryAllocationChangedCallbackAdapter; class GraphicsContext3DPrivate { public: - static PassOwnPtr create(WebKit::WebViewImpl*, PassOwnPtr, GraphicsContext3D::Attributes); - - enum ThreadUsage { - ForUseOnThisThread, - ForUseOnAnotherThread, - }; - - // createGraphicsContextForAnotherThread is equivalent to - // GraphicsContext3D::create, but will skip making the context - // current. Callers must make the context current before using it AND check - // that the context was created successfully via ContextLost. Once made - // current on a thread, the context cannot be used on any other thread. - static PassRefPtr createGraphicsContextForAnotherThread(GraphicsContext3D::Attributes, HostWindow*, GraphicsContext3D::RenderStyle); - - // Used in tests to create a GraphicsContext3D from a mocked WebGraphicsContext3D. - static PassRefPtr createGraphicsContextFromWebContext(PassOwnPtr, GraphicsContext3D::Attributes, HostWindow*, GraphicsContext3D::RenderStyle, ThreadUsage); + // Callers must make the context current before using it AND check that the context was created successfully + // via ContextLost before using the context in any way. Once made current on a thread, the context cannot + // be used on any other thread. + static PassRefPtr createGraphicsContextFromWebContext(PassOwnPtr, GraphicsContext3D::RenderStyle, bool preserveDrawingBuffer = false); ~GraphicsContext3DPrivate(); @@ -321,7 +308,7 @@ public: void texStorage2DEXT(GC3Denum target, GC3Dint levels, GC3Duint internalformat, GC3Dint width, GC3Dint height); private: - GraphicsContext3DPrivate(WebKit::WebViewImpl*, PassOwnPtr, GraphicsContext3D::Attributes); + GraphicsContext3DPrivate(PassOwnPtr, bool preserveDrawingBuffer); OwnPtr m_impl; OwnPtr m_extensions; @@ -329,7 +316,6 @@ private: OwnPtr m_errorMessageCallbackAdapter; OwnPtr m_swapBuffersCompleteCallbackAdapter; OwnPtr m_memoryAllocationChangedCallbackAdapter; - WebKit::WebViewImpl* m_webViewImpl; bool m_initializedAvailableExtensions; HashSet m_enabledExtensions; HashSet m_requestableExtensions; diff --git a/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp b/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp index 9814771..29d0332 100644 --- a/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp @@ -86,21 +86,7 @@ PassRefPtr WebLayerTreeViewImpl::createLayerTreeHostContext3D if (!webContext) return 0; - WebGraphicsContext3D::Attributes webAttributes = webContext->getContextAttributes(); - GraphicsContext3D::Attributes attributes; - attributes.alpha = webAttributes.alpha; - attributes.depth = webAttributes.depth; - attributes.stencil = webAttributes.stencil; - attributes.antialias = webAttributes.antialias; - attributes.premultipliedAlpha = webAttributes.premultipliedAlpha; - attributes.canRecoverFromContextLoss = webAttributes.canRecoverFromContextLoss; - attributes.noExtensions = webAttributes.noExtensions; - attributes.shareResources = webAttributes.shareResources; - attributes.preserveDrawingBuffer = false; - - GraphicsContext3D::RenderStyle style = GraphicsContext3D::RenderDirectlyToHostWindow; - GraphicsContext3DPrivate::ThreadUsage usage = CCProxy::hasImplThread() ? GraphicsContext3DPrivate::ForUseOnAnotherThread : GraphicsContext3DPrivate::ForUseOnThisThread; - return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), attributes, 0, style, usage); + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow, false /* preserveDrawingBuffer */ ); } void WebLayerTreeViewImpl::didCommitAndDrawFrame() diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp index ea4c263..55a2052 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebViewImpl.cpp @@ -170,7 +170,7 @@ using namespace std; namespace { -GraphicsContext3D::Attributes getCompositorContextAttributes() +WebKit::WebGraphicsContext3D::Attributes getCompositorContextAttributes(bool threaded) { // Explicitly disable antialiasing for the compositor. As of the time of // this writing, the only platform that supported antialiasing for the @@ -182,9 +182,10 @@ GraphicsContext3D::Attributes getCompositorContextAttributes() // be optimized to resolve directly into the IOSurface shared between the // GPU and browser processes. For these reasons and to avoid platform // disparities we explicitly disable antialiasing. - GraphicsContext3D::Attributes attributes; + WebKit::WebGraphicsContext3D::Attributes attributes; attributes.antialias = false; attributes.shareResources = true; + attributes.forUseOnAnotherThread = threaded; return attributes; } @@ -3194,15 +3195,25 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) #endif +PassRefPtr WebViewImpl::createCompositorGraphicsContext3D() +{ + WebKit::WebGraphicsContext3D::Attributes attributes = getCompositorContextAttributes(CCProxy::hasImplThread()); + OwnPtr webContext = adoptPtr(client()->createGraphicsContext3D(attributes, true /* renderDirectlyToHostWindow */)); + if (!webContext) + return 0; + + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow); +} + PassRefPtr WebViewImpl::createLayerTreeHostContext3D() { - RefPtr context = m_temporaryOnscreenGraphicsContext3D.release(); - if (!context) { - if (CCProxy::hasImplThread()) - context = GraphicsContext3DPrivate::createGraphicsContextForAnotherThread(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow); - else - context = GraphicsContext3D::create(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow); - } + RefPtr context; + + // If we've already created an onscreen context for this view, return that. + if (m_temporaryOnscreenGraphicsContext3D) + context = m_temporaryOnscreenGraphicsContext3D.release(); + else // Otherwise make a new one. + context = createCompositorGraphicsContext3D(); return context; } @@ -3295,17 +3306,16 @@ WebGraphicsContext3D* WebViewImpl::graphicsContext3D() if (webContext && !webContext->isContextLost()) return webContext; } - if (m_temporaryOnscreenGraphicsContext3D) { - WebGraphicsContext3D* webContext = GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_temporaryOnscreenGraphicsContext3D.get()); - if (webContext && !webContext->isContextLost()) - return webContext; - } - if (CCProxy::hasImplThread()) - m_temporaryOnscreenGraphicsContext3D = GraphicsContext3DPrivate::createGraphicsContextForAnotherThread(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow); - else - m_temporaryOnscreenGraphicsContext3D = GraphicsContext3D::create(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow); - - return GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_temporaryOnscreenGraphicsContext3D.get()); + // If we get here it means that some system needs access to the context the compositor will use but the compositor itself + // hasn't requested a context or it was unable to successfully instantiate a context. + // We need to return the context that the compositor will later use so we allocate a new context (if needed) and stash it + // until the compositor requests and takes ownership of the context via createLayerTreeHost3D(). + if (!m_temporaryOnscreenGraphicsContext3D) + m_temporaryOnscreenGraphicsContext3D = createCompositorGraphicsContext3D(); + + WebGraphicsContext3D* webContext = GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_temporaryOnscreenGraphicsContext3D.get()); + if (webContext && !webContext->isContextLost()) + return webContext; } #endif return 0; diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h index 3558c1d..bc7a53d 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.h +++ b/Source/WebKit/chromium/src/WebViewImpl.h @@ -446,9 +446,12 @@ public: // Returns the onscreen 3D context used by the compositor. This is // used by the renderer's code to set up resource sharing between // the compositor's context and subordinate contexts for APIs like - // WebGL. Returns 0 if compositing support is not compiled in. + // WebGL. Returns 0 if compositing support is not compiled in or + // we could not successfully instantiate a context. virtual WebGraphicsContext3D* graphicsContext3D(); + PassRefPtr createCompositorGraphicsContext3D(); + virtual void setVisibilityState(WebPageVisibilityState, bool); WebCore::PopupContainer* selectPopup() const { return m_selectPopup.get(); } diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp index 695207d..9ba1cf4 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp @@ -91,6 +91,11 @@ public: } protected: + PassRefPtr createContext() + { + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3D()), GraphicsContext3D::RenderDirectlyToHostWindow); + } + DebugScopedSetImplThread m_alwaysImplThread; OwnPtr m_hostImpl; bool m_didRequestCommit; @@ -348,8 +353,7 @@ private: TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) { -GraphicsContext3D::Attributes attrs; - RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3D()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr context = createContext(); m_hostImpl->initializeLayerRenderer(context); // Ensure visibleLayerRect for root layer is empty @@ -384,8 +388,7 @@ GraphicsContext3D::Attributes attrs; TEST_F(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers) { - GraphicsContext3D::Attributes attrs; - RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3D()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr context = createContext(); m_hostImpl->initializeLayerRenderer(context); m_hostImpl->setViewportSize(IntSize(10, 10)); @@ -486,8 +489,7 @@ private: // https://bugs.webkit.org/show_bug.cgi?id=75783 TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) { - GraphicsContext3D::Attributes attrs; - RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new BlendStateTrackerContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr context = createContext(); m_hostImpl->initializeLayerRenderer(context); m_hostImpl->setViewportSize(IntSize(10, 10)); @@ -653,9 +655,8 @@ public: // viewport size is never set. TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) { - GraphicsContext3D::Attributes attrs; ReshapeTrackerContext* reshapeTracker = new ReshapeTrackerContext(); - RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(reshapeTracker), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(reshapeTracker), GraphicsContext3D::RenderDirectlyToHostWindow); m_hostImpl->initializeLayerRenderer(context); m_hostImpl->setViewportSize(IntSize(10, 10)); @@ -697,9 +698,8 @@ private: // where it should request to swap only the subBuffer that is damaged. TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect) { - GraphicsContext3D::Attributes attrs; PartialSwapTrackerContext* partialSwapTracker = new PartialSwapTrackerContext(); - RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(partialSwapTracker), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(partialSwapTracker), GraphicsContext3D::RenderDirectlyToHostWindow); // This test creates its own CCLayerTreeHostImpl, so // that we can force partial swap enabled. diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp index 8260989..12d7141 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp @@ -246,10 +246,7 @@ public: webAttrs.alpha = attrs.alpha; OwnPtr webContext = CompositorFakeWebGraphicsContext3DWithTextureTracking::create(webAttrs); - return GraphicsContext3DPrivate::createGraphicsContextFromWebContext( - webContext.release(), attrs, 0, - GraphicsContext3D::RenderDirectlyToHostWindow, - GraphicsContext3DPrivate::ForUseOnAnotherThread); + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow); } virtual void didCommitAndDrawFrame() diff --git a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp index 4b3dd27..ec0ce0c 100644 --- a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp @@ -79,8 +79,8 @@ protected: { GraphicsContext3D::Attributes attrs; - RefPtr mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); - RefPtr implContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), GraphicsContext3D::RenderDirectlyToHostWindow); + RefPtr implContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), GraphicsContext3D::RenderDirectlyToHostWindow); MockCanvasContext& mainMock = *static_cast(GraphicsContext3DPrivate::extractWebGraphicsContext3D(mainContext.get())); MockCanvasContext& implMock = *static_cast(GraphicsContext3DPrivate::extractWebGraphicsContext3D(implContext.get())); diff --git a/Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h b/Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h index 1f08973..937b62d 100644 --- a/Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h +++ b/Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h @@ -37,10 +37,7 @@ static PassRefPtr createCompositorMockGraphicsContext3D(Graph webAttrs.alpha = attrs.alpha; OwnPtr webContext = WebKit::CompositorFakeWebGraphicsContext3D::create(webAttrs); - return GraphicsContext3DPrivate::createGraphicsContextFromWebContext( - webContext.release(), attrs, 0, - GraphicsContext3D::RenderDirectlyToHostWindow, - GraphicsContext3DPrivate::ForUseOnAnotherThread); + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow); } } diff --git a/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp b/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp index 2b76b80..71cb8ba 100644 --- a/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp +++ b/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp @@ -52,7 +52,7 @@ private: TEST(FakeGraphicsContext3DTest, CanOverrideManually) { GraphicsContext3D::Attributes attrs; - RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FrameCountingContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FrameCountingContext()), GraphicsContext3D::RenderDirectlyToHostWindow); FrameCountingContext& mockContext = *static_cast(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get())); for (int i = 0; i < 10; i++) { @@ -73,7 +73,7 @@ public: TEST(FakeGraphicsContext3DTest, CanUseGMock) { GraphicsContext3D::Attributes attrs; - RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new GMockContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new GMockContext()), GraphicsContext3D::RenderDirectlyToHostWindow); GMockContext& mockContext = *static_cast(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get())); EXPECT_CALL(mockContext, getError()) @@ -104,7 +104,7 @@ private: TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldNotMakeCurrent) { GraphicsContext3D::Attributes attrs; - RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), GraphicsContext3D::RenderDirectlyToHostWindow); EXPECT_TRUE(context); ContextThatCountsMakeCurrents& mockContext = *static_cast(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get())); EXPECT_EQ(0, mockContext.makeCurrentCount()); @@ -113,7 +113,7 @@ TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldNotMakeCurrent) TEST(FakeGraphicsContext3DTest, ContextForAnotherThreadShouldNotMakeCurrent) { GraphicsContext3D::Attributes attrs; - RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnAnotherThread); + RefPtr context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), GraphicsContext3D::RenderDirectlyToHostWindow); EXPECT_TRUE(context); ContextThatCountsMakeCurrents& mockContext = *static_cast(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get())); EXPECT_EQ(0, mockContext.makeCurrentCount()); -- 2.7.4