Title: [106371] trunk
Revision
106371
Author
[email protected]
Date
2012-01-31 11:11:54 -0800 (Tue, 31 Jan 2012)

Log Message

Merge WebGraphicsContext3D creation and initialization, and move it to
WebViewClient.
https://bugs.webkit.org/show_bug.cgi?id=76593

Reviewed by Darin Fisher.

Source/WebKit/chromium:

* public/WebViewClient.h:
(WebKit::WebViewClient::createGraphicsContext3D):
* public/platform/WebGraphicsContext3D.h:
(WebKit::WebGraphicsContext3D::initialize):
* public/platform/WebKitPlatformSupport.h:
* src/GraphicsContext3DChromium.cpp:

Tools:

* DumpRenderTree/chromium/TestWebPlugin.cpp:
(TestWebPlugin::TestWebPlugin):
(TestWebPlugin::initialize):
* DumpRenderTree/chromium/TestWebPlugin.h:
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::createGraphicsContext3D):
(WebViewHost::createPlugin):
* DumpRenderTree/chromium/WebViewHost.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (106370 => 106371)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-01-31 19:07:44 UTC (rev 106370)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-01-31 19:11:54 UTC (rev 106371)
@@ -1,3 +1,18 @@
+2012-01-31  Antoine Labour  <[email protected]>
+
+        Merge WebGraphicsContext3D creation and initialization, and move it to
+        WebViewClient.
+        https://bugs.webkit.org/show_bug.cgi?id=76593
+
+        Reviewed by Darin Fisher.
+
+        * public/WebViewClient.h:
+        (WebKit::WebViewClient::createGraphicsContext3D):
+        * public/platform/WebGraphicsContext3D.h:
+        (WebKit::WebGraphicsContext3D::initialize):
+        * public/platform/WebKitPlatformSupport.h:
+        * src/GraphicsContext3DChromium.cpp:
+
 2012-01-26  Hans Wennborg  <[email protected]>
 
         Speech Input: move MockSpeechInputClient into Chromium DumpRenderTree implementation

Modified: trunk/Source/WebKit/chromium/public/WebViewClient.h (106370 => 106371)


--- trunk/Source/WebKit/chromium/public/WebViewClient.h	2012-01-31 19:07:44 UTC (rev 106370)
+++ trunk/Source/WebKit/chromium/public/WebViewClient.h	2012-01-31 19:11:54 UTC (rev 106371)
@@ -42,6 +42,7 @@
 #include "WebTextDirection.h"
 #include "WebWidgetClient.h"
 #include "platform/WebColor.h"
+#include "platform/WebGraphicsContext3D.h"
 #include "platform/WebString.h"
 
 namespace WebKit {
@@ -109,6 +110,12 @@
     // Create a session storage namespace object associated with this WebView.
     virtual WebStorageNamespace* createSessionStorageNamespace(unsigned quota) { return 0; }
 
+    // Creates a graphics context associated with the client's WebView.
+    // renderDirectlyToWebView means whether the context should be setup to
+    // render directly to the WebView (e.g. compositor context), or to an
+    // offscreen surface (e.g. WebGL context).
+    virtual WebGraphicsContext3D* createGraphicsContext3D(const WebGraphicsContext3D::Attributes&, bool renderDirectlyToWebView) { return 0; }
+
     // Misc ----------------------------------------------------------------
 
     // A new message was added to the console.

Modified: trunk/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h (106370 => 106371)


--- trunk/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h	2012-01-31 19:07:44 UTC (rev 106370)
+++ trunk/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h	2012-01-31 19:11:54 UTC (rev 106371)
@@ -133,9 +133,8 @@
     // This destructor needs to be public so that using classes can destroy instances if initialization fails.
     virtual ~WebGraphicsContext3D() {}
 
-    // Initializes the graphics context; should be the first operation performed
-    // on newly-constructed instances. Returns true on success.
-    virtual bool initialize(Attributes, WebView*, bool renderDirectlyToWebView) = 0;
+    // This function is deprecated and will be removed soon.
+    virtual bool initialize(Attributes, WebView*, bool renderDirectlyToWebView) { return false; }
 
     // Makes the OpenGL context current on the current thread. Returns true on
     // success.

Modified: trunk/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h (106370 => 106371)


--- trunk/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h	2012-01-31 19:07:44 UTC (rev 106370)
+++ trunk/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h	2012-01-31 19:11:54 UTC (rev 106371)
@@ -36,6 +36,7 @@
 #include "WebCommon.h"
 #include "WebData.h"
 #include "WebGamepads.h"
+#include "WebGraphicsContext3D.h"
 #include "WebLocalizedString.h"
 #include "WebSerializedScriptValue.h"
 #include "WebString.h"
@@ -313,12 +314,12 @@
     // Callable from a background WebKit thread.
     virtual void callOnMainThread(void (*func)(void*), void* context) { }
 
-    // WebGL --------------------------------------------------------------
+    // GPU ----------------------------------------------------------------
+    //
+    // May return null if GPU is not supported.
+    // Returns newly allocated and initialized offscreen WebGraphicsContext3D instance.
+    virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&) { return 0; }
 
-    // May return null if WebGL is not supported.
-    // Returns newly allocated WebGraphicsContext3D instance.
-    virtual WebGraphicsContext3D* createGraphicsContext3D() { return 0; }
-
     // Audio --------------------------------------------------------------
 
     virtual double audioHardwareSampleRate() { return 0; }

Modified: trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp (106370 => 106371)


--- trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp	2012-01-31 19:07:44 UTC (rev 106370)
+++ trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp	2012-01-31 19:11:54 UTC (rev 106371)
@@ -46,9 +46,10 @@
 #include "ImageBuffer.h"
 #include "ImageData.h"
 #include "WebKit.h"
-#include "platform/WebKitPlatformSupport.h"
+#include "WebViewClient.h"
 #include "WebViewImpl.h"
 #include "platform/WebGraphicsContext3D.h"
+#include "platform/WebKitPlatformSupport.h"
 
 #include <stdio.h>
 #include <wtf/FastMalloc.h>
@@ -151,14 +152,17 @@
     webAttributes.noExtensions = attrs.noExtensions;
     webAttributes.shareResources = attrs.shareResources;
     webAttributes.forUseOnAnotherThread = threadUsage == GraphicsContext3DPrivate::ForUseOnAnotherThread;
-    OwnPtr<WebKit::WebGraphicsContext3D> webContext = adoptPtr(WebKit::webKitPlatformSupport()->createGraphicsContext3D());
-    if (!webContext)
-        return 0;
 
     Chrome* chrome = static_cast<Chrome*>(hostWindow);
     WebKit::WebViewImpl* webViewImpl = chrome ? static_cast<WebKit::WebViewImpl*>(chrome->client()->webView()) : 0;
-
-    if (!webContext->initialize(webAttributes, webViewImpl, renderDirectlyToHostWindow))
+    OwnPtr<WebKit::WebGraphicsContext3D> 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);

Modified: trunk/Tools/ChangeLog (106370 => 106371)


--- trunk/Tools/ChangeLog	2012-01-31 19:07:44 UTC (rev 106370)
+++ trunk/Tools/ChangeLog	2012-01-31 19:11:54 UTC (rev 106371)
@@ -1,3 +1,20 @@
+2012-01-31  Antoine Labour  <[email protected]>
+
+        Merge WebGraphicsContext3D creation and initialization, and move it to
+        WebViewClient.
+        https://bugs.webkit.org/show_bug.cgi?id=76593
+
+        Reviewed by Darin Fisher.
+
+        * DumpRenderTree/chromium/TestWebPlugin.cpp:
+        (TestWebPlugin::TestWebPlugin):
+        (TestWebPlugin::initialize):
+        * DumpRenderTree/chromium/TestWebPlugin.h:
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::createGraphicsContext3D):
+        (WebViewHost::createPlugin):
+        * DumpRenderTree/chromium/WebViewHost.h:
+
 2012-01-31  Gabor Rapcsanyi  <[email protected]>
 
         [GTK] build-webkit warning.

Modified: trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp (106370 => 106371)


--- trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp	2012-01-31 19:07:44 UTC (rev 106370)
+++ trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp	2012-01-31 19:11:54 UTC (rev 106371)
@@ -32,6 +32,7 @@
 #include "platform/WebKitPlatformSupport.h"
 #include "WebPluginContainer.h"
 #include "WebPluginParams.h"
+#include "WebViewClient.h"
 #include <wtf/Assertions.h>
 #include <wtf/text/CString.h>
 
@@ -61,9 +62,11 @@
     colorOut[3] = alpha;
 }
 
-TestWebPlugin::TestWebPlugin(WebKit::WebFrame* frame,
+TestWebPlugin::TestWebPlugin(WebKit::WebViewClient* webViewClient,
+                             WebKit::WebFrame* frame,
                              const WebKit::WebPluginParams& params)
-    : m_frame(frame)
+    : m_webViewClient(webViewClient)
+    , m_frame(frame)
     , m_container(0)
     , m_context(0)
 {
@@ -101,14 +104,11 @@
 
 bool TestWebPlugin::initialize(WebPluginContainer* container)
 {
-    m_context = webKitPlatformSupport()->createGraphicsContext3D();
+    WebGraphicsContext3D::Attributes attrs;
+    m_context = m_webViewClient->createGraphicsContext3D(attrs, false);
     if (!m_context)
         return false;
 
-    WebGraphicsContext3D::Attributes attrs;
-    if (!m_context->initialize(attrs, m_frame->view(), false))
-        return false;
-
     if (!m_context->makeContextCurrent())
         return false;
 

Modified: trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.h (106370 => 106371)


--- trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.h	2012-01-31 19:07:44 UTC (rev 106370)
+++ trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.h	2012-01-31 19:11:54 UTC (rev 106371)
@@ -31,6 +31,7 @@
 
 namespace WebKit {
 class WebGraphicsContext3D;
+class WebViewClient;
 }
 
 // A fake implemention of WebKit::WebPlugin for testing purposes.
@@ -44,7 +45,7 @@
 // opacity: [0.0 - 1.0]. Default is 1.0.
 class TestWebPlugin : public WebKit::WebPlugin {
 public:
-    TestWebPlugin(WebKit::WebFrame*, const WebKit::WebPluginParams&);
+    TestWebPlugin(WebKit::WebViewClient*, WebKit::WebFrame*, const WebKit::WebPluginParams&);
     virtual ~TestWebPlugin();
 
     static const WebKit::WebString& mimeType();
@@ -115,6 +116,7 @@
     unsigned loadProgram(const WTF::CString& vertexSource,
                          const WTF::CString& fragmentSource);
 
+    WebKit::WebViewClient* m_webViewClient;
     WebKit::WebFrame* m_frame;
     WebKit::WebPluginContainer* m_container;
 

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp (106370 => 106371)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-01-31 19:07:44 UTC (rev 106370)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-01-31 19:11:54 UTC (rev 106371)
@@ -272,6 +272,13 @@
     return WebKit::WebStorageNamespace::createSessionStorageNamespace(quota);
 }
 
+WebKit::WebGraphicsContext3D* WebViewHost::createGraphicsContext3D(const WebKit::WebGraphicsContext3D::Attributes& attributes, bool direct)
+{
+    if (!webView())
+        return 0;
+    return webkit_support::CreateGraphicsContext3D(attributes, webView(), direct);
+}
+
 void WebViewHost::didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine)
 {
     // This matches win DumpRenderTree's UIDelegate.cpp.
@@ -906,7 +913,7 @@
 WebPlugin* WebViewHost::createPlugin(WebFrame* frame, const WebPluginParams& params)
 {
     if (params.mimeType == TestWebPlugin::mimeType())
-        return new TestWebPlugin(frame, params);
+        return new TestWebPlugin(this, frame, params);
 
     return webkit_support::CreateWebPlugin(frame, params);
 }

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.h (106370 => 106371)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2012-01-31 19:07:44 UTC (rev 106370)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2012-01-31 19:11:54 UTC (rev 106371)
@@ -129,6 +129,7 @@
     virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType);
     virtual WebKit::WebWidget* createPopupMenu(const WebKit::WebPopupMenuInfo&);
     virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(unsigned quota);
+    virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D(const WebKit::WebGraphicsContext3D::Attributes&, bool direct);
     virtual void didAddMessageToConsole(const WebKit::WebConsoleMessage&, const WebKit::WebString& sourceName, unsigned sourceLine);
     virtual void didStartLoading();
     virtual void didStopLoading();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to