summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 17:08:14 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 17:08:14 +0000
commit2b4d973c90f7e7e81ef3cd1896f4e3e1ca8ba098 (patch)
tree39cc93f3450cbbdeca602c8a0fdef14328fc4554 /webkit
parentc9e1979455bd83b1d3c6d95be4c84cc7153ced7f (diff)
downloadchromium_src-2b4d973c90f7e7e81ef3cd1896f4e3e1ca8ba098.zip
chromium_src-2b4d973c90f7e7e81ef3cd1896f4e3e1ca8ba098.tar.gz
chromium_src-2b4d973c90f7e7e81ef3cd1896f4e3e1ca8ba098.tar.bz2
Changed the pepper test plugin to render a red triangle on a black background. Also removed the continuous draw loop.
Review URL: http://codereview.chromium.org/1052004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41846 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/tools/pepper_test_plugin/DEPS2
-rw-r--r--webkit/tools/pepper_test_plugin/demo_3d.cc35
-rw-r--r--webkit/tools/pepper_test_plugin/demo_3d.h44
-rw-r--r--webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp8
-rw-r--r--webkit/tools/pepper_test_plugin/plugin_object.cc23
-rw-r--r--webkit/tools/pepper_test_plugin/plugin_object.h2
6 files changed, 97 insertions, 17 deletions
diff --git a/webkit/tools/pepper_test_plugin/DEPS b/webkit/tools/pepper_test_plugin/DEPS
index fcae681..f31c40db 100644
--- a/webkit/tools/pepper_test_plugin/DEPS
+++ b/webkit/tools/pepper_test_plugin/DEPS
@@ -1,4 +1,4 @@
include_rules = [
- "+gpu/command_buffer",
"+gpu/pgl",
+ "+third_party/gles2_book",
]
diff --git a/webkit/tools/pepper_test_plugin/demo_3d.cc b/webkit/tools/pepper_test_plugin/demo_3d.cc
new file mode 100644
index 0000000..2ffb757
--- /dev/null
+++ b/webkit/tools/pepper_test_plugin/demo_3d.cc
@@ -0,0 +1,35 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/tools/pepper_test_plugin/demo_3d.h"
+
+#if !defined(INDEPENDENT_PLUGIN)
+namespace pepper {
+Demo3D::Demo3D() {
+ esInitContext(&context_);
+ memset(&user_data_, 0, sizeof(HTUserData));
+ context_.userData = &user_data_;
+}
+
+Demo3D::~Demo3D() {
+}
+
+void Demo3D::SetWindowSize(int width, int height) {
+ context_.width = width;
+ context_.height = height;
+}
+
+bool Demo3D::InitGL() {
+ return htInit(&context_);
+}
+
+void Demo3D::ReleaseGL() {
+ htShutDown(&context_);
+}
+
+void Demo3D::Draw() {
+ htDraw(&context_);
+}
+} // namespace pepper
+#endif // INDEPENDENT_PLUGIN
diff --git a/webkit/tools/pepper_test_plugin/demo_3d.h b/webkit/tools/pepper_test_plugin/demo_3d.h
new file mode 100644
index 0000000..b10533d
--- /dev/null
+++ b/webkit/tools/pepper_test_plugin/demo_3d.h
@@ -0,0 +1,44 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_TOOLS_PEPPER_TEST_PLUGIN_DEMO_3D_H_
+#define WEBKIT_TOOLS_PEPPER_TEST_PLUGIN_DEMO_3D_H_
+
+#if !defined(INDEPENDENT_PLUGIN)
+#include "base/basictypes.h"
+#include "third_party/gles2_book/Chapter_2/Hello_Triangle/Hello_Triangle.h"
+
+namespace pepper {
+class Demo3D {
+ public:
+ Demo3D();
+ virtual ~Demo3D();
+
+ // Sets the size of the window on which this demo object will render.
+ void SetWindowSize(int width, int height);
+
+ // Initializes the OpenGL state required by this demo.
+ // When this function is called, it is assumed that a rendering context has
+ // already been created and made current.
+ bool InitGL();
+
+ // Release the OpenGL resources acquired by this demo.
+ // When this function is called, it is assumed that the rendering context
+ // used to initialize the demo is current.
+ void ReleaseGL();
+
+ // Performs OpenGL rendering.
+ // When this function is called, it is assumed that the rendering context
+ // has been made current.
+ void Draw();
+
+ private:
+ ESContext context_;
+ HTUserData user_data_;
+
+ DISALLOW_COPY_AND_ASSIGN(Demo3D);
+};
+} // namespace pepper
+#endif // INDEPENDENT_PLUGIN
+#endif // WEBKIT_TOOLS_PEPPER_TEST_PLUGIN_DEMO_3D_H_
diff --git a/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp b/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp
index c7320017..2bd0041 100644
--- a/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp
+++ b/webkit/tools/pepper_test_plugin/pepper_test_plugin.gyp
@@ -17,13 +17,15 @@
'INFOPLIST_FILE': 'Info.plist',
},
'sources': [
+ 'demo_3d.cc',
+ 'demo_3d.h',
+ 'event_handler.cc',
+ 'event_handler.h',
'main.cc',
'plugin_object.cc',
'plugin_object.h',
'test_object.cc',
'test_object.h',
- 'event_handler.cc',
- 'event_handler.h'
],
'conditions': [
['OS=="win"', {
@@ -62,8 +64,8 @@
'dependencies': [
'../../../base/base.gyp:base',
'../../../skia/skia.gyp:skia',
- '../../../gpu/gpu.gyp:gles2_demo_lib',
'../../../gpu/gpu.gyp:pgl',
+ '../../../third_party/gles2_book/gles2_book.gyp:hello_triangle',
],
}],
['OS=="mac"', {
diff --git a/webkit/tools/pepper_test_plugin/plugin_object.cc b/webkit/tools/pepper_test_plugin/plugin_object.cc
index 6e755ef..bd11a8e 100644
--- a/webkit/tools/pepper_test_plugin/plugin_object.cc
+++ b/webkit/tools/pepper_test_plugin/plugin_object.cc
@@ -35,8 +35,6 @@
#else
#include "base/logging.h"
#include "build/build_config.h"
-#include "gpu/command_buffer/client/gles2_demo_cc.h"
-#include <GLES2/gl2.h> // NOLINT
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
@@ -328,8 +326,8 @@ NPClass* PluginObject::GetPluginClass() {
}
namespace {
-void Draw3DCallback(void* data) {
- static_cast<PluginObject*>(data)->Draw3D();
+void Draw3DCallback(NPP npp, NPDeviceContext3D* /* context */) {
+ static_cast<PluginObject*>(npp->pdata)->Draw3D();
}
}
@@ -383,9 +381,7 @@ void PluginObject::SetWindow(const NPWindow& window) {
#if !defined(INDEPENDENT_PLUGIN)
if (!pgl_context_)
Initialize3D();
-
- // Schedule the first call to Draw.
- browser->pluginthreadasynccall(npp_, Draw3DCallback, this);
+ demo_3d_.SetWindowSize(width_, height_);
#endif
}
@@ -415,13 +411,16 @@ void PluginObject::Initialize3D() {
NPDeviceContext3DConfig config;
config.commandBufferSize = kCommandBufferSize;
device3d_->initializeContext(npp_, &config, &context3d_);
+ context3d_.repaintCallback = Draw3DCallback;
// Create a PGL context.
pgl_context_ = pglCreateContext(npp_, device3d_, &context3d_);
// Initialize the demo GL state.
pglMakeCurrent(pgl_context_);
- GLFromCPPInit();
+ demo_3d_.SetWindowSize(width_, height_);
+ CHECK(demo_3d_.InitGL());
+
pglMakeCurrent(PGL_NO_CONTEXT);
#endif // INDEPENDENT_PLUGIN
}
@@ -430,6 +429,8 @@ void PluginObject::Destroy3D() {
#if !defined(INDEPENDENT_PLUGIN)
DCHECK(pgl_context_);
+ demo_3d_.ReleaseGL();
+
// Destroy the PGL context.
pglDestroyContext(pgl_context_);
pgl_context_ = NULL;
@@ -455,8 +456,7 @@ void PluginObject::Draw3D() {
pglMakeCurrent(pgl_context_);
}
- glViewport(0, 0, width_, height_);
- GLFromCPPDraw();
+ demo_3d_.Draw();
pglSwapBuffers();
pglMakeCurrent(PGL_NO_CONTEXT);
@@ -471,8 +471,5 @@ void PluginObject::Draw3D() {
&context3d_,
AsyncFlushCallback,
reinterpret_cast<void*>(0x3D2));
-
- // Schedule another call to Draw.
- browser->pluginthreadasynccall(npp_, Draw3DCallback, this);
#endif // INDEPENDENT_PLUGIN
}
diff --git a/webkit/tools/pepper_test_plugin/plugin_object.h b/webkit/tools/pepper_test_plugin/plugin_object.h
index 95eb389..d097709 100644
--- a/webkit/tools/pepper_test_plugin/plugin_object.h
+++ b/webkit/tools/pepper_test_plugin/plugin_object.h
@@ -31,6 +31,7 @@
#include "third_party/npapi/bindings/nphostapi.h"
#if !defined(INDEPENDENT_PLUGIN)
#include "gpu/pgl/pgl.h"
+#include "webkit/tools/pepper_test_plugin/demo_3d.h"
#endif
extern NPNetscapeFuncs* browser;
@@ -62,6 +63,7 @@ class PluginObject {
#if !defined(INDEPENDENT_PLUGIN)
PGLContext pgl_context_;
+ pepper::Demo3D demo_3d_;
#endif
NPDevice* deviceaudio_;