WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch for landing
bug-67179-20110830122847.patch (text/plain), 15.90 KB, created by
Nat Duca
on 2011-08-30 12:28:48 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Nat Duca
Created:
2011-08-30 12:28:48 PDT
Size:
15.90 KB
patch
obsolete
>Subversion Revision: 94095 >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index 9d26948564156de41a6b550e9b523aa437192fc5..1011205e6677e74e46251d73a15ad7bf168c5b10 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,23 @@ >+2011-08-29 Nat Duca <nduca@chromium.org> >+ >+ [chromium] Allow GraphicsContexts to be created from MockWebGraphicsContexts >+ https://bugs.webkit.org/show_bug.cgi?id=67179 >+ >+ Reviewed by Kenneth Russell. >+ >+ * WebKit.gypi: >+ * src/GraphicsContext3DChromium.cpp: >+ (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): >+ (WebCore::GraphicsContext3DInternal::create): >+ (WebCore::GraphicsContext3DInternal::createFromWebContext): >+ (WebCore::GraphicsContext3D::create): >+ * src/GraphicsContext3DInternal.h: >+ * tests/MockGraphicsContext3DTest.cpp: Renamed from Source/WebKit/chromium/tests/MockWebGraphicsContext3DTest.cpp. >+ (FrameCountingContext::FrameCountingContext): >+ (FrameCountingContext::prepareTexture): >+ (FrameCountingContext::frameCount): >+ (TEST): >+ > 2011-08-30 Tony Chang <tony@chromium.org> > > Fix chromium compile when using clang. Another compile error due >diff --git a/Source/WebKit/chromium/WebKit.gypi b/Source/WebKit/chromium/WebKit.gypi >index beaa0820a02be8425121259028de98d1693a328e..4ca0e76a8fef83c5d457eaa332df6fd27ff00dce 100644 >--- a/Source/WebKit/chromium/WebKit.gypi >+++ b/Source/WebKit/chromium/WebKit.gypi >@@ -63,8 +63,9 @@ > 'tests/InnerGestureRecognizerTest.cpp', > 'tests/KeyboardTest.cpp', > 'tests/KURLTest.cpp', >+ 'tests/MockGraphicsContext3D.h', >+ 'tests/MockGraphicsContext3DTest.cpp', > 'tests/MockWebGraphicsContext3D.h', >- 'tests/MockWebGraphicsContext3DTest.cpp', > 'tests/PODArenaTest.cpp', > 'tests/PODIntervalTreeTest.cpp', > 'tests/PODRedBlackTreeTest.cpp', >diff --git a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp >index ab22836f47aee44be51aa26689dc8455c4ab8440..4a7561e17f03018be1566dda044545034c42071b 100644 >--- a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp >+++ b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp >@@ -83,8 +83,9 @@ namespace WebCore { > //---------------------------------------------------------------------- > // GraphicsContext3DPrivate > >-GraphicsContext3DPrivate::GraphicsContext3DPrivate() >- : m_webViewImpl(0) >+GraphicsContext3DPrivate::GraphicsContext3DPrivate(WebKit::WebViewImpl* webViewImpl, PassOwnPtr<WebKit::WebGraphicsContext3D> webContext) >+ : m_impl(webContext) >+ , m_webViewImpl(webViewImpl) > , m_initializedAvailableExtensions(false) > , m_layerComposited(false) > , m_resourceSafety(ResourceSafetyUnknown) >@@ -96,6 +97,9 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate() > #error Must port to your platform > #endif > { >+#if USE(ACCELERATED_COMPOSITING) >+ m_compositingLayer = WebGLLayerChromium::create(0); >+#endif > } > > GraphicsContext3DPrivate::~GraphicsContext3DPrivate() >@@ -108,32 +112,22 @@ GraphicsContext3DPrivate::~GraphicsContext3DPrivate() > #endif > } > >-bool GraphicsContext3DPrivate::initialize(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, bool 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<WebKit::WebGraphicsContext3D> webContext = adoptPtr(WebKit::webKitClient()->createGraphicsContext3D()); >- if (!webContext) >- return false; > >- Chrome* chrome = static_cast<Chrome*>(hostWindow); >- m_webViewImpl = chrome ? static_cast<WebKit::WebViewImpl*>(chrome->client()->webView()) : 0; >+PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(WebKit::WebViewImpl* webViewImpl, PassOwnPtr<WebKit::WebGraphicsContext3D> webContext) >+{ >+ return adoptPtr(new GraphicsContext3DPrivate(webViewImpl, webContext)); >+} > >- if (!webContext->initialize(webAttributes, m_webViewImpl, renderDirectlyToHostWindow)) >- return false; >- m_impl = webContext.release(); >+PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) >+{ >+ OwnPtr<GraphicsContext3DPrivate> priv = GraphicsContext3DPrivate::create(0, webContext); >+ if (!priv) >+ return 0; > >-#if USE(ACCELERATED_COMPOSITING) >- m_compositingLayer = WebGLLayerChromium::create(0); >-#endif >- return true; >+ bool renderDirectlyToHostWindow = renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow; >+ RefPtr<GraphicsContext3D> result = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderDirectlyToHostWindow)); >+ result->m_private = priv.release(); >+ return result.release(); > } > > WebKit::WebGraphicsContext3D* GraphicsContext3DPrivate::extractWebGraphicsContext3D(GraphicsContext3D* context) >@@ -978,13 +972,28 @@ GraphicsContext3D::~GraphicsContext3D() > > PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) > { >- OwnPtr<GraphicsContext3DPrivate> priv = adoptPtr(new GraphicsContext3DPrivate()); >- if (!priv->initialize(attrs, hostWindow, renderStyle == RenderDirectlyToHostWindow)) >+ bool renderDirectlyToHostWindow = renderStyle == 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<WebKit::WebGraphicsContext3D> webContext = adoptPtr(WebKit::webKitClient()->createGraphicsContext3D()); >+ if (!webContext) > return 0; > >- RefPtr<GraphicsContext3D> result = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderStyle == RenderDirectlyToHostWindow)); >- result->m_private = priv.release(); >- return result.release(); >+ Chrome* chrome = static_cast<Chrome*>(hostWindow); >+ WebKit::WebViewImpl* webViewImpl = chrome ? static_cast<WebKit::WebViewImpl*>(chrome->client()->webView()) : 0; >+ >+ if (!webContext->initialize(webAttributes, webViewImpl, renderDirectlyToHostWindow)) >+ return 0; >+ >+ return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), attrs, hostWindow, renderStyle); > } > > PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() const >diff --git a/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h b/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h >index 60a8223abc4e9d6990a4717ae661dbac6627ec88..8b88972c2062ee70e41fa43a18950b6febb51e6f 100644 >--- a/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h >+++ b/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h >@@ -55,7 +55,11 @@ class SwapBuffersCompleteCallbackAdapter; > > class GraphicsContext3DPrivate { > public: >- GraphicsContext3DPrivate(); >+ static PassOwnPtr<GraphicsContext3DPrivate> create(WebKit::WebViewImpl*, PassOwnPtr<WebKit::WebGraphicsContext3D>); >+ >+ // Used in tests to create a GraphicsContext3D from a mocked WebGraphicsContext3D. >+ static PassRefPtr<GraphicsContext3D> createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D>, GraphicsContext3D::Attributes, HostWindow*, GraphicsContext3D::RenderStyle); >+ > ~GraphicsContext3DPrivate(); > > bool initialize(GraphicsContext3D::Attributes, HostWindow*, bool renderDirectlyToHostWindow); >@@ -290,6 +294,8 @@ public: > GC3Denum getGraphicsResetStatusARB(); > > private: >+ GraphicsContext3DPrivate(WebKit::WebViewImpl*, PassOwnPtr<WebKit::WebGraphicsContext3D>); >+ > OwnPtr<WebKit::WebGraphicsContext3D> m_impl; > OwnPtr<Extensions3DChromium> m_extensions; > OwnPtr<GraphicsContextLostCallbackAdapter> m_contextLostCallbackAdapter; >diff --git a/Source/WebKit/chromium/tests/MockGraphicsContext3DTest.cpp b/Source/WebKit/chromium/tests/MockGraphicsContext3DTest.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..2d365379587f48d7761079c60d6195465e0ab485 >--- /dev/null >+++ b/Source/WebKit/chromium/tests/MockGraphicsContext3DTest.cpp >@@ -0,0 +1,90 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE 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 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 "GraphicsContext3D.h" >+ >+#include "GraphicsContext3DPrivate.h" >+#include "MockWebGraphicsContext3D.h" >+ >+#include <gmock/gmock.h> >+#include <gtest/gtest.h> >+ >+using namespace WebCore; >+using namespace WebKit; >+using namespace testing; >+ >+class FrameCountingContext : public MockWebGraphicsContext3D { >+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(MockGraphicsContext3DTest, CanOverrideManually) >+{ >+ GraphicsContext3D::Attributes attrs; >+ RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FrameCountingContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow); >+ FrameCountingContext& mockContext = *static_cast<FrameCountingContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get())); >+ >+ context->makeContextCurrent(); >+ 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 MockWebGraphicsContext3D { >+public: >+ MOCK_METHOD0(getError, WGC3Denum()); >+}; >+ >+TEST(MockGraphicsContext3DTest, CanUseGMock) >+{ >+ GraphicsContext3D::Attributes attrs; >+ RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new GMockContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow); >+ GMockContext& mockContext = *static_cast<GMockContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get())); >+ >+ EXPECT_CALL(mockContext, getError()) >+ .WillRepeatedly(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); >+} >diff --git a/Source/WebKit/chromium/tests/MockWebGraphicsContext3DTest.cpp b/Source/WebKit/chromium/tests/MockWebGraphicsContext3DTest.cpp >deleted file mode 100644 >index e88d4a523ea3a4581bb793367703c3c19932939e..0000000000000000000000000000000000000000 >--- a/Source/WebKit/chromium/tests/MockWebGraphicsContext3DTest.cpp >+++ /dev/null >@@ -1,100 +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 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 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 "MockWebGraphicsContext3D.h" >- >-#include <gmock/gmock.h> >-#include <gtest/gtest.h> >- >-using namespace WebKit; >-using namespace testing; >- >-TEST(MockWebGraphicsContext3DTest, BasicMockDoesNothing) >-{ >- MockWebGraphicsContext3D context; >- EXPECT_FALSE(context.makeContextCurrent()); >-} >- >-class FrameCountingContext : public MockWebGraphicsContext3D { >-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(MockWebGraphicsContext3DTest, CanOverrideManually) >-{ >- FrameCountingContext context; >- >- context.makeContextCurrent(); >- for (int i = 0; i < 10; i++) { >- context.clearColor(0, 0, 0, 1); >- context.prepareTexture(); >- } >- context.finish(); >- >- EXPECT_EQ(10, context.frameCount()); >-} >- >-class GMockContext : public MockWebGraphicsContext3D { >-public: >- MOCK_METHOD0(width, int()); >- MOCK_METHOD0(height, int()); >- MOCK_METHOD1(synthesizeGLError, void(WGC3Denum error)); >- MOCK_METHOD0(getError, WGC3Denum()); >-}; >- >-TEST(MockWebGraphicsContext3DTest, CanUseGMock) >-{ >- GMockContext context; >- >- EXPECT_CALL(context, width()) >- .WillRepeatedly(Return(512)); >- >- EXPECT_CALL(context, height()) >- .WillRepeatedly(Return(384)); >- >- EXPECT_CALL(context, synthesizeGLError(_)) // Any parameter accepted >- .Times(Exactly(10)); >- >- // No expectation for getError(), so calling that would make our test fail. >- >- for (int i = 0; i < 10; i++) { >- context.synthesizeGLError(i); >- EXPECT_EQ(512, context.width()); >- EXPECT_EQ(384, context.height()); >- >- // It's OK to call methods GMock doesn't know about. >- EXPECT_FALSE(context.makeContextCurrent()); >- } >-}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 67179
:
105579
| 105668