Modified: trunk/Tools/ChangeLog (110074 => 110075)
--- trunk/Tools/ChangeLog 2012-03-07 19:12:40 UTC (rev 110074)
+++ trunk/Tools/ChangeLog 2012-03-07 19:18:09 UTC (rev 110075)
@@ -1,3 +1,27 @@
+2012-03-07 James Robinson <jam...@chromium.org>
+
+ [chromium] Remove the TestWebPlugin's use of implicit FBO for offscreen contexts
+ https://bugs.webkit.org/show_bug.cgi?id=80521
+
+ Reviewed by Kenneth Russell.
+
+ Switches TestWebPlugin from using a context created by WebViewClient::createGraphicsContext3D(..., false) over
+ to an explicitly offscreen context with explicitly managed texture / FBO, so we can deprecate the
+ renderDirectlyToHostWindow flag from WebViewClient::createGraphicsContext3D.
+
+ Covered by platform/chromium/compositing/plugins/*
+
+ * DumpRenderTree/chromium/TestWebPlugin.cpp:
+ (TestWebPlugin::TestWebPlugin):
+ (TestWebPlugin::initialize):
+ (TestWebPlugin::updateGeometry):
+ (TestWebPlugin::initScene):
+ (TestWebPlugin::destroyScene):
+ * DumpRenderTree/chromium/TestWebPlugin.h:
+ (TestWebPlugin):
+ * DumpRenderTree/chromium/WebViewHost.cpp:
+ (WebViewHost::createPlugin):
+
2012-03-07 Philippe Normand <pnorm...@igalia.com>
[GTK] remove webkitpy dependency in run-gtk-tests
Modified: trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp (110074 => 110075)
--- trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp 2012-03-07 19:12:40 UTC (rev 110074)
+++ trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp 2012-03-07 19:18:09 UTC (rev 110075)
@@ -32,7 +32,6 @@
#include "platform/WebKitPlatformSupport.h"
#include "WebPluginContainer.h"
#include "WebPluginParams.h"
-#include "WebViewClient.h"
#include <wtf/Assertions.h>
#include <wtf/text/CString.h>
@@ -44,15 +43,29 @@
#define GL_ONE 1
#define GL_TRIANGLES 0x0004
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_DEPTH_TEST 0x0B71
#define GL_BLEND 0x0BE2
+#define GL_SCISSOR_TEST 0x0B90
+#define GL_TEXTURE_2D 0x0DE1
#define GL_FLOAT 0x1406
+#define GL_RGBA 0x1908
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+#define GL_NEAREST 0x2600
#define GL_COLOR_BUFFER_BIT 0x4000
+#define GL_CLAMP_TO_EDGE 0x812F
#define GL_ARRAY_BUFFER 0x8892
#define GL_STATIC_DRAW 0x88E4
#define GL_FRAGMENT_SHADER 0x8B30
#define GL_VERTEX_SHADER 0x8B31
#define GL_COMPILE_STATUS 0x8B81
#define GL_LINK_STATUS 0x8B82
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#define GL_FRAMEBUFFER 0x8D40
static void premultiplyAlpha(const unsigned colorIn[3], float alpha, float colorOut[4])
{
@@ -62,11 +75,9 @@
colorOut[3] = alpha;
}
-TestWebPlugin::TestWebPlugin(WebKit::WebViewClient* webViewClient,
- WebKit::WebFrame* frame,
+TestWebPlugin::TestWebPlugin(WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params)
- : m_webViewClient(webViewClient)
- , m_frame(frame)
+ : m_frame(frame)
, m_container(0)
, m_context(0)
{
@@ -105,7 +116,7 @@
bool TestWebPlugin::initialize(WebPluginContainer* container)
{
WebGraphicsContext3D::Attributes attrs;
- m_context = m_webViewClient->createGraphicsContext3D(attrs, false);
+ m_context = webKitPlatformSupport()->createOffscreenGraphicsContext3D(attrs);
if (!m_context)
return false;
@@ -116,7 +127,7 @@
return false;
m_container = container;
- m_container->setBackingTextureId(m_context->getPlatformTextureId());
+ m_container->setBackingTextureId(m_colorTexture);
return true;
}
@@ -141,9 +152,20 @@
m_rect = clipRect;
m_context->reshape(m_rect.width, m_rect.height);
+ m_context->viewport(0, 0, m_rect.width, m_rect.height);
+
+ m_context->bindTexture(GL_TEXTURE_2D, m_colorTexture);
+ m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ m_context->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_rect.width, m_rect.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+ m_context->bindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
+ m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_colorTexture, 0);
+
drawScene();
- m_context->prepareTexture();
+ m_context->flush();
m_container->commitBackingTexture();
}
@@ -189,6 +211,14 @@
{
float color[4];
premultiplyAlpha(m_scene.backgroundColor, m_scene.opacity, color);
+
+ m_colorTexture = m_context->createTexture();
+ m_framebuffer = m_context->createFramebuffer();
+
+ m_context->viewport(0, 0, m_rect.width, m_rect.height);
+ m_context->disable(GL_DEPTH_TEST);
+ m_context->disable(GL_SCISSOR_TEST);
+
m_context->clearColor(color[0], color[1], color[2], color[3]);
m_context->enable(GL_BLEND);
@@ -216,6 +246,16 @@
m_context->deleteBuffer(m_scene.vbo);
m_scene.vbo = 0;
}
+
+ if (m_framebuffer) {
+ m_context->deleteFramebuffer(m_framebuffer);
+ m_framebuffer = 0;
+ }
+
+ if (m_colorTexture) {
+ m_context->deleteTexture(m_colorTexture);
+ m_colorTexture = 0;
+ }
}
bool TestWebPlugin::initProgram()
Modified: trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.h (110074 => 110075)
--- trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.h 2012-03-07 19:12:40 UTC (rev 110074)
+++ trunk/Tools/DumpRenderTree/chromium/TestWebPlugin.h 2012-03-07 19:18:09 UTC (rev 110075)
@@ -31,7 +31,6 @@
namespace WebKit {
class WebGraphicsContext3D;
-class WebViewClient;
}
// A fake implemention of WebKit::WebPlugin for testing purposes.
@@ -45,7 +44,7 @@
// opacity: [0.0 - 1.0]. Default is 1.0.
class TestWebPlugin : public WebKit::WebPlugin {
public:
- TestWebPlugin(WebKit::WebViewClient*, WebKit::WebFrame*, const WebKit::WebPluginParams&);
+ TestWebPlugin(WebKit::WebFrame*, const WebKit::WebPluginParams&);
virtual ~TestWebPlugin();
static const WebKit::WebString& mimeType();
@@ -116,12 +115,13 @@
unsigned loadProgram(const WTF::CString& vertexSource,
const WTF::CString& fragmentSource);
- WebKit::WebViewClient* m_webViewClient;
WebKit::WebFrame* m_frame;
WebKit::WebPluginContainer* m_container;
WebKit::WebRect m_rect;
WebKit::WebGraphicsContext3D* m_context;
+ unsigned m_colorTexture;
+ unsigned m_framebuffer;
Scene m_scene;
};
Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp (110074 => 110075)
--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp 2012-03-07 19:12:40 UTC (rev 110074)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp 2012-03-07 19:18:09 UTC (rev 110075)
@@ -933,7 +933,7 @@
WebPlugin* WebViewHost::createPlugin(WebFrame* frame, const WebPluginParams& params)
{
if (params.mimeType == TestWebPlugin::mimeType())
- return new TestWebPlugin(this, frame, params);
+ return new TestWebPlugin(frame, params);
return webkit_support::CreateWebPlugin(frame, params);
}