summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gpu/demos/demos.gyp176
-rw-r--r--gpu/demos/framework/DEPS5
-rw-r--r--gpu/demos/framework/pepper.cc109
-rw-r--r--gpu/demos/gles2_book/demo_hello_triangle.cc (renamed from gpu/demos/gles2_book/hello_triangle.cc)0
-rw-r--r--gpu/demos/gles2_book/demo_mip_map_2d.cc (renamed from gpu/demos/gles2_book/mip_map_2d.cc)0
-rw-r--r--gpu/demos/gles2_book/demo_simple_texture_2d.cc (renamed from gpu/demos/gles2_book/simple_texture_2d.cc)0
-rw-r--r--gpu/demos/gles2_book/demo_simple_texture_cubemap.cc (renamed from gpu/demos/gles2_book/simple_texture_cubemap.cc)0
-rw-r--r--gpu/demos/gles2_book/demo_simple_vertex_shader.cc (renamed from gpu/demos/gles2_book/simple_vertex_shader.cc)0
-rw-r--r--gpu/demos/gles2_book/demo_stencil_test.cc (renamed from gpu/demos/gles2_book/stencil_test.cc)0
-rw-r--r--gpu/demos/gles2_book/demo_texture_wrap.cc (renamed from gpu/demos/gles2_book/texture_wrap.cc)0
-rwxr-xr-xgpu/demos/run_demo_ppapi.sh29
11 files changed, 305 insertions, 14 deletions
diff --git a/gpu/demos/demos.gyp b/gpu/demos/demos.gyp
index 682fc12..901ec7c 100644
--- a/gpu/demos/demos.gyp
+++ b/gpu/demos/demos.gyp
@@ -65,6 +65,7 @@
# If the dependent is a none-type target (like all.gyp), gyp will
# generate error due to these injected source files. Workaround this
# problem by preventing it from being selected by demos.gyp:*.
+ # TODO(neb): remove source injection and this flag.
'suppress_wildcard': 1,
'dependencies': [
'gpu_demo_framework',
@@ -122,6 +123,69 @@
},
},
{
+ 'target_name': 'gpu_demo_framework_ppapi',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'gpu_demo_framework',
+ '../../third_party/ppapi/ppapi.gyp:ppapi_cpp',
+ '../../third_party/ppapi/ppapi.gyp:ppapi_cpp_objects'
+ ],
+ 'include_dirs': [
+ '../..',
+ '../../third_party/ppapi',
+ '../../third_party/gles2_book/Common/Include',
+ ],
+ 'sources': [
+ 'framework/pepper.cc',
+ '../../third_party/gles2_book/Common/Include/esUtil.h',
+ '../../third_party/gles2_book/Common/Include/esUtil_win.h',
+ '../../third_party/gles2_book/Common/Source/esShader.c',
+ '../../third_party/gles2_book/Common/Source/esShapes.c',
+ '../../third_party/gles2_book/Common/Source/esTransform.c',
+ '../../third_party/gles2_book/Common/Source/esUtil.c',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '../../third_party',
+ '../../third_party/gles2_book/Common/Include',
+ '../../third_party/ppapi',
+ '../..'
+ ],
+ 'run_as': {
+ 'conditions': [
+ ['OS=="mac"', {
+ 'action': [
+ '<(PRODUCT_DIR)/Chromium.app/Contents/MacOS/Chromium',
+ '--enable-gpu-plugin',
+ '--register-pepper-plugins='
+ '<(PRODUCT_DIR)/$(PRODUCT_NAME).plugin;'
+ 'pepper-application/x-gpu-demo',
+ 'file://$(SOURCE_ROOT)/pepper_gpu_demo.html',
+ ],
+ }, { # OS != "mac"
+ 'action': [
+ '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)chrome<(EXECUTABLE_SUFFIX)',
+ '--enable-gpu-plugin',
+ '--register-pepper-plugins=$(TargetPath);'
+ 'pepper-application/x-gpu-demo',
+ 'file://$(ProjectDir)pepper_gpu_demo.html',
+ ],
+ }],
+ ],
+ },
+ 'conditions': [
+ ['OS=="linux"', {
+ # -gstabs, used in the official builds, causes an ICE. Remove it.
+ 'cflags!': ['-gstabs'],
+ }],
+ ['OS=="mac"', {
+ 'mac_bundle': 1,
+ 'product_extension': 'plugin',
+ }],
+ ],
+ },
+ },
+ {
'target_name': 'hello_triangle_exe',
'type': 'executable',
'dependencies': [
@@ -130,7 +194,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/hello_triangle.cc',
+ 'gles2_book/demo_hello_triangle.cc',
],
},
{
@@ -142,7 +206,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/mip_map_2d.cc',
+ 'gles2_book/demo_mip_map_2d.cc',
],
},
{
@@ -154,7 +218,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/simple_texture_2d.cc',
+ 'gles2_book/demo_simple_texture_2d.cc',
],
},
{
@@ -166,7 +230,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/simple_texture_cubemap.cc',
+ 'gles2_book/demo_simple_texture_cubemap.cc',
],
},
{
@@ -178,7 +242,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/simple_vertex_shader.cc',
+ 'gles2_book/demo_simple_vertex_shader.cc',
],
},
{
@@ -190,7 +254,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/stencil_test.cc',
+ 'gles2_book/demo_stencil_test.cc',
],
},
{
@@ -202,7 +266,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/texture_wrap.cc',
+ 'gles2_book/demo_texture_wrap.cc',
],
},
],
@@ -218,7 +282,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/hello_triangle.cc',
+ 'gles2_book/demo_hello_triangle.cc',
],
},
{
@@ -230,7 +294,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/mip_map_2d.cc',
+ 'gles2_book/demo_mip_map_2d.cc',
],
},
{
@@ -242,7 +306,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/simple_texture_2d.cc',
+ 'gles2_book/demo_simple_texture_2d.cc',
],
},
{
@@ -254,7 +318,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/simple_texture_cubemap.cc',
+ 'gles2_book/demo_simple_texture_cubemap.cc',
],
},
{
@@ -266,7 +330,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/simple_vertex_shader.cc',
+ 'gles2_book/demo_simple_vertex_shader.cc',
],
},
{
@@ -278,7 +342,7 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/stencil_test.cc',
+ 'gles2_book/demo_stencil_test.cc',
],
},
{
@@ -290,7 +354,91 @@
],
'sources': [
'gles2_book/example.h',
- 'gles2_book/texture_wrap.cc',
+ 'gles2_book/demo_texture_wrap.cc',
+ ],
+ },
+ {
+ 'target_name': 'hello_triangle_ppapi',
+ 'type': 'loadable_module',
+ 'variables': { 'chromium_code': 0, },
+ 'dependencies': [ 'gpu_demo_framework_ppapi', ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/demo_hello_triangle.cc',
+ '../../third_party/gles2_book/Chapter_2/Hello_Triangle/Hello_Triangle.c',
+ '../../third_party/gles2_book/Chapter_2/Hello_Triangle/Hello_Triangle.h',
+ ],
+ },
+ {
+ 'target_name': 'mip_map_2d_ppapi',
+ 'type': 'loadable_module',
+ 'variables': { 'chromium_code': 0, },
+ 'dependencies': [ 'gpu_demo_framework_ppapi', ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/demo_mip_map_2d.cc',
+ '../../third_party/gles2_book/Chapter_9/MipMap2D/MipMap2D.c',
+ '../../third_party/gles2_book/Chapter_9/MipMap2D/MipMap2D.h',
+ ],
+ },
+ {
+ 'target_name': 'simple_texture_2d_ppapi',
+ 'type': 'loadable_module',
+ 'variables': { 'chromium_code': 0, },
+ 'dependencies': [ 'gpu_demo_framework_ppapi', ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/demo_simple_texture_2d.cc',
+ '../../third_party/gles2_book/Chapter_9/Simple_Texture2D/Simple_Texture2D.c',
+ '../../third_party/gles2_book/Chapter_9/Simple_Texture2D/Simple_Texture2D.h',
+ ],
+ },
+ {
+ 'target_name': 'simple_texture_cubemap_ppapi',
+ 'type': 'loadable_module',
+ 'variables': { 'chromium_code': 0, },
+ 'dependencies': [ 'gpu_demo_framework_ppapi', ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/demo_simple_texture_cubemap.cc',
+ '../../third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.c',
+ '../../third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.h',
+ ],
+ },
+ {
+ 'target_name': 'simple_vertex_shader_ppapi',
+ 'type': 'loadable_module',
+ 'variables': { 'chromium_code': 0, },
+ 'dependencies': [ 'gpu_demo_framework_ppapi', ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/demo_simple_vertex_shader.cc',
+ '../../third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.c',
+ '../../third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.h',
+ ],
+ },
+ {
+ 'target_name': 'stencil_test_ppapi',
+ 'type': 'loadable_module',
+ 'variables': { 'chromium_code': 0, },
+ 'dependencies': [ 'gpu_demo_framework_ppapi', ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/demo_stencil_test.cc',
+ '../../third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.c',
+ '../../third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.h',
+ ],
+ },
+ {
+ 'target_name': 'texture_wrap_ppapi',
+ 'type': 'loadable_module',
+ 'variables': { 'chromium_code': 0, },
+ 'dependencies': [ 'gpu_demo_framework_ppapi', ],
+ 'sources': [
+ 'gles2_book/example.h',
+ 'gles2_book/demo_texture_wrap.cc',
+ '../../third_party/gles2_book/Chapter_9/TextureWrap/TextureWrap.c',
+ '../../third_party/gles2_book/Chapter_9/TextureWrap/TextureWrap.h',
],
},
],
diff --git a/gpu/demos/framework/DEPS b/gpu/demos/framework/DEPS
new file mode 100644
index 0000000..ab44782
--- /dev/null
+++ b/gpu/demos/framework/DEPS
@@ -0,0 +1,5 @@
+include_rules = [
+ "+base",
+ "+third_party/ppapi",
+ "+ppapi"
+]
diff --git a/gpu/demos/framework/pepper.cc b/gpu/demos/framework/pepper.cc
new file mode 100644
index 0000000..9bcf9b1
--- /dev/null
+++ b/gpu/demos/framework/pepper.cc
@@ -0,0 +1,109 @@
+// 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 "base/at_exit.h"
+#include "base/scoped_ptr.h"
+#include "gpu/demos/framework/demo.h"
+#include "gpu/demos/framework/demo_factory.h"
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/dev/graphics_3d_dev.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/rect.h"
+#include "ppapi/cpp/size.h"
+
+namespace gpu {
+namespace demos {
+
+class PluginInstance : public pp::Instance {
+ public:
+ PluginInstance(PP_Instance instance, pp::Module* module)
+ : pp::Instance(instance),
+ module_(module),
+ demo_(CreateDemo()) {
+ // Set the callback object outside of the initializer list to avoid a
+ // compiler warning about using "this" in an initializer list.
+ callback_factory_.Initialize(this);
+ }
+
+ ~PluginInstance() {
+ if (!graphics_.is_null()) {
+ graphics_.MakeCurrent();
+ demo_.reset();
+ pp::Graphics3D_Dev::ResetCurrent();
+ }
+ }
+
+ virtual void ViewChanged(const pp::Rect& position, const pp::Rect& /*clip*/) {
+ if (size_.IsEmpty() && !position.IsEmpty()) {
+ size_ = position.size();
+ demo_->InitWindowSize(size_.width(), size_.height());
+ graphics_ = pp::Graphics3D_Dev(*this, 0, NULL, NULL);
+ if (!graphics_.is_null()) {
+ graphics_.MakeCurrent();
+ demo_->InitGL();
+ pp::Graphics3D_Dev::ResetCurrent();
+
+ // TODO(neb): Remove this once the startup order bug (51842) is fixed.
+ if (true)
+ // if (demo_->IsAnimated())
+ Animate(0);
+ else
+ Paint();
+ }
+ }
+ }
+
+ virtual void Graphics3DContextLost() {
+ // TODO(neb): Replace this with the correct code once 53889 is fixed.
+ Paint();
+// pp::Rect fake_position(size_);
+// size_ = pp::Size();
+// ViewChanged(fake_position, fake_position);
+ }
+
+ void Paint() {
+ graphics_.MakeCurrent();
+ demo_->Draw();
+ graphics_.SwapBuffers();
+ pp::Graphics3D_Dev::ResetCurrent();
+ }
+
+ private:
+ void Animate(int delay) {
+ Paint();
+ module_->core()->CallOnMainThread(delay,
+ callback_factory_.NewCallback(&PluginInstance::Animate), delay);
+ }
+
+ pp::Module* module_;
+ scoped_ptr<Demo> demo_;
+ pp::Graphics3D_Dev graphics_;
+ pp::Size size_;
+ pp::CompletionCallbackFactory<PluginInstance> callback_factory_;
+};
+
+class PluginModule : public pp::Module {
+ public:
+ PluginModule() : pp::Module(), at_exit_manager_(new base::AtExitManager) {}
+
+ virtual pp::Instance* CreateInstance(PP_Instance instance) {
+ return new PluginInstance(instance, this);
+ }
+
+ private:
+ scoped_ptr<base::AtExitManager> at_exit_manager_;
+};
+
+} // namespace demos
+} // namespace gpu
+
+namespace pp {
+
+Module* CreateModule() {
+ return new gpu::demos::PluginModule();
+}
+
+} // namespace pp
+
diff --git a/gpu/demos/gles2_book/hello_triangle.cc b/gpu/demos/gles2_book/demo_hello_triangle.cc
index 806a0dd..806a0dd 100644
--- a/gpu/demos/gles2_book/hello_triangle.cc
+++ b/gpu/demos/gles2_book/demo_hello_triangle.cc
diff --git a/gpu/demos/gles2_book/mip_map_2d.cc b/gpu/demos/gles2_book/demo_mip_map_2d.cc
index fcb5c3b..fcb5c3b 100644
--- a/gpu/demos/gles2_book/mip_map_2d.cc
+++ b/gpu/demos/gles2_book/demo_mip_map_2d.cc
diff --git a/gpu/demos/gles2_book/simple_texture_2d.cc b/gpu/demos/gles2_book/demo_simple_texture_2d.cc
index 3f4eff6..3f4eff6 100644
--- a/gpu/demos/gles2_book/simple_texture_2d.cc
+++ b/gpu/demos/gles2_book/demo_simple_texture_2d.cc
diff --git a/gpu/demos/gles2_book/simple_texture_cubemap.cc b/gpu/demos/gles2_book/demo_simple_texture_cubemap.cc
index 6db525b..6db525b 100644
--- a/gpu/demos/gles2_book/simple_texture_cubemap.cc
+++ b/gpu/demos/gles2_book/demo_simple_texture_cubemap.cc
diff --git a/gpu/demos/gles2_book/simple_vertex_shader.cc b/gpu/demos/gles2_book/demo_simple_vertex_shader.cc
index 0f8b72e..0f8b72e 100644
--- a/gpu/demos/gles2_book/simple_vertex_shader.cc
+++ b/gpu/demos/gles2_book/demo_simple_vertex_shader.cc
diff --git a/gpu/demos/gles2_book/stencil_test.cc b/gpu/demos/gles2_book/demo_stencil_test.cc
index 66be791..66be791 100644
--- a/gpu/demos/gles2_book/stencil_test.cc
+++ b/gpu/demos/gles2_book/demo_stencil_test.cc
diff --git a/gpu/demos/gles2_book/texture_wrap.cc b/gpu/demos/gles2_book/demo_texture_wrap.cc
index a3fb3ba..a3fb3ba 100644
--- a/gpu/demos/gles2_book/texture_wrap.cc
+++ b/gpu/demos/gles2_book/demo_texture_wrap.cc
diff --git a/gpu/demos/run_demo_ppapi.sh b/gpu/demos/run_demo_ppapi.sh
new file mode 100755
index 0000000..fba5ad1
--- /dev/null
+++ b/gpu/demos/run_demo_ppapi.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+# 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.
+
+if [ -z "$1" ]; then
+ echo "Usage: $(basename "$0") <demo_name> [--debug]" >&2
+ echo >&2
+ echo "Builds and runs PPAPI demo inside Chrome." >&2
+ echo "Debug flag attaches the debugger to renderer process." >&2
+ echo >&2
+ echo "Try: $0 hello_triangle" >&2
+ echo >&2
+ exit 1
+fi
+if [ "$2" == "--debug" ]; then
+ CHROME_DEBUG="--renderer-cmd-prefix=xterm -geometry 150x40 -e gdb --args"
+else
+ CHROME_DEBUG=
+fi
+CHROME_SRC="$(dirname "$(dirname "$(dirname "$(readlink -f "$0")")")")"
+PLUGIN_LIB="$CHROME_SRC/out/Debug/lib${1}_ppapi.so"
+PLUGIN_MIME="pepper-application/x-gpu-demo"
+cd "$CHROME_SRC"
+make "${1}_ppapi" && out/Debug/chrome --use-gl=osmesa --enable-gpu-plugin \
+ "${CHROME_DEBUG}" \
+ --register-pepper-plugins="$PLUGIN_LIB;$PLUGIN_MIME" \
+ "file://$CHROME_SRC/gpu/demos/pepper_gpu_demo.html"
+