summaryrefslogtreecommitdiffstats
path: root/gpu/demos
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-21 17:12:55 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-21 17:12:55 +0000
commit3e9d8aa0bbf6e2ed8d093e17c92cacff383c7e4f (patch)
treeab4483673b5886ee5b821bccb8ecbee2c5922ffd /gpu/demos
parente5b826e46e8a435945f94370bd50bc7ee1749607 (diff)
downloadchromium_src-3e9d8aa0bbf6e2ed8d093e17c92cacff383c7e4f.zip
chromium_src-3e9d8aa0bbf6e2ed8d093e17c92cacff383c7e4f.tar.gz
chromium_src-3e9d8aa0bbf6e2ed8d093e17c92cacff383c7e4f.tar.bz2
Moved the logic of maintaining the current context to gles2 helper library.
Review URL: http://codereview.chromium.org/5927002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69838 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/demos')
-rw-r--r--gpu/demos/demos.gyp16
-rw-r--r--gpu/demos/framework/pepper.cc24
2 files changed, 31 insertions, 9 deletions
diff --git a/gpu/demos/demos.gyp b/gpu/demos/demos.gyp
index ab24d2a..3997863 100644
--- a/gpu/demos/demos.gyp
+++ b/gpu/demos/demos.gyp
@@ -3,6 +3,9 @@
# found in the LICENSE file.
{
+ 'includes': [
+ '../../ppapi/ppapi.gypi',
+ ],
'variables': {
'chromium_code': 1,
'conditions': [
@@ -127,12 +130,13 @@
'type': 'static_library',
'dependencies': [
'gpu_demo_framework',
- '../../ppapi/ppapi.gyp:ppapi_cpp',
- '../../ppapi/ppapi.gyp:ppapi_cpp_objects'
+ '../../ppapi/ppapi.gyp:ppapi_cpp_objects',
+ '../../ppapi/ppapi.gyp:ppapi_gles2',
],
'include_dirs': [
'../..',
'../../ppapi',
+ '../../ppapi/lib/gl/include',
'../../third_party/gles2_book/Common/Include',
],
'sources': [
@@ -149,6 +153,7 @@
'../../third_party',
'../../third_party/gles2_book/Common/Include',
'../../ppapi',
+ '../../ppapi/lib/gl/include',
'../..'
],
'run_as': {
@@ -363,6 +368,7 @@
'variables': { 'chromium_code': 0, },
'dependencies': [ 'gpu_demo_framework_ppapi', ],
'sources': [
+ '<@(ppp_entrypoints_sources)',
'gles2_book/example.h',
'gles2_book/demo_hello_triangle.cc',
'../../third_party/gles2_book/Chapter_2/Hello_Triangle/Hello_Triangle.c',
@@ -375,6 +381,7 @@
'variables': { 'chromium_code': 0, },
'dependencies': [ 'gpu_demo_framework_ppapi', ],
'sources': [
+ '<@(ppp_entrypoints_sources)',
'gles2_book/example.h',
'gles2_book/demo_mip_map_2d.cc',
'../../third_party/gles2_book/Chapter_9/MipMap2D/MipMap2D.c',
@@ -387,6 +394,7 @@
'variables': { 'chromium_code': 0, },
'dependencies': [ 'gpu_demo_framework_ppapi', ],
'sources': [
+ '<@(ppp_entrypoints_sources)',
'gles2_book/example.h',
'gles2_book/demo_simple_texture_2d.cc',
'../../third_party/gles2_book/Chapter_9/Simple_Texture2D/Simple_Texture2D.c',
@@ -399,6 +407,7 @@
'variables': { 'chromium_code': 0, },
'dependencies': [ 'gpu_demo_framework_ppapi', ],
'sources': [
+ '<@(ppp_entrypoints_sources)',
'gles2_book/example.h',
'gles2_book/demo_simple_texture_cubemap.cc',
'../../third_party/gles2_book/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap.c',
@@ -411,6 +420,7 @@
'variables': { 'chromium_code': 0, },
'dependencies': [ 'gpu_demo_framework_ppapi', ],
'sources': [
+ '<@(ppp_entrypoints_sources)',
'gles2_book/example.h',
'gles2_book/demo_simple_vertex_shader.cc',
'../../third_party/gles2_book/Chapter_8/Simple_VertexShader/Simple_VertexShader.c',
@@ -423,6 +433,7 @@
'variables': { 'chromium_code': 0, },
'dependencies': [ 'gpu_demo_framework_ppapi', ],
'sources': [
+ '<@(ppp_entrypoints_sources)',
'gles2_book/example.h',
'gles2_book/demo_stencil_test.cc',
'../../third_party/gles2_book/Chapter_11/Stencil_Test/Stencil_Test.c',
@@ -435,6 +446,7 @@
'variables': { 'chromium_code': 0, },
'dependencies': [ 'gpu_demo_framework_ppapi', ],
'sources': [
+ '<@(ppp_entrypoints_sources)',
'gles2_book/example.h',
'gles2_book/demo_texture_wrap.cc',
'../../third_party/gles2_book/Chapter_9/TextureWrap/TextureWrap.c',
diff --git a/gpu/demos/framework/pepper.cc b/gpu/demos/framework/pepper.cc
index 2d3d50b..ca19e0f 100644
--- a/gpu/demos/framework/pepper.cc
+++ b/gpu/demos/framework/pepper.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <GLES2/gl2.h>
+
#include "base/at_exit.h"
#include "base/scoped_ptr.h"
#include "gpu/demos/framework/demo.h"
@@ -12,6 +14,7 @@
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/size.h"
+#include "ppapi/lib/gl/gles2/gl2ext_ppapi.h"
namespace gpu {
namespace demos {
@@ -29,9 +32,9 @@ class PluginInstance : public pp::Instance {
~PluginInstance() {
if (!graphics_.is_null()) {
- graphics_.MakeCurrent();
+ glSetCurrentContextPPAPI(graphics_.pp_resource());
demo_.reset();
- pp::Graphics3D_Dev::ResetCurrent();
+ glSetCurrentContextPPAPI(0);
}
}
@@ -51,9 +54,9 @@ class PluginInstance : public pp::Instance {
if (!pp::Instance::BindGraphics(graphics_))
return;
- graphics_.MakeCurrent();
+ glSetCurrentContextPPAPI(graphics_.pp_resource());
demo_->InitGL();
- pp::Graphics3D_Dev::ResetCurrent();
+ glSetCurrentContextPPAPI(0);
}
if (demo_->IsAnimated())
@@ -63,10 +66,10 @@ class PluginInstance : public pp::Instance {
}
void Paint() {
- graphics_.MakeCurrent();
+ glSetCurrentContextPPAPI(graphics_.pp_resource());
demo_->Draw();
graphics_.SwapBuffers();
- pp::Graphics3D_Dev::ResetCurrent();
+ glSetCurrentContextPPAPI(0);
}
private:
@@ -85,7 +88,14 @@ class PluginInstance : public pp::Instance {
class PluginModule : public pp::Module {
public:
- PluginModule() : pp::Module(), at_exit_manager_(new base::AtExitManager) {}
+ PluginModule() : at_exit_manager_(new base::AtExitManager) {}
+ ~PluginModule() {
+ glTerminatePPAPI();
+ }
+
+ virtual bool Init() {
+ return glInitializePPAPI(get_browser_interface()) == GL_TRUE ? true : false;
+ }
virtual pp::Instance* CreateInstance(PP_Instance instance) {
return new PluginInstance(instance, this);