summaryrefslogtreecommitdiffstats
path: root/gpu
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
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')
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py102
-rw-r--r--gpu/demos/demos.gyp16
-rw-r--r--gpu/demos/framework/pepper.cc24
3 files changed, 95 insertions, 47 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 46b6ea4..4748581 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -48,8 +48,8 @@ _GL_TYPES = {
'GLvoid': 'void',
'GLfixed': 'int',
'GLclampx': 'int',
- 'GLintptr': 'khronos_intptr_t',
- 'GLsizeiptr': 'khronos_ssize_t',
+ 'GLintptr': 'long int',
+ 'GLsizeiptr': 'long int',
}
_GL_FUNCTIONS = """
GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
@@ -1462,6 +1462,7 @@ _FUNCTION_INFO = {
'type': 'Custom',
'impl_func': False,
'unit_test': False,
+ 'extension': True,
},
'TexImage2D': {'type': 'Manual', 'immediate': True},
'TexParameterf': {'decoder_func': 'DoTexParameterf'},
@@ -4513,6 +4514,9 @@ class Function(object):
"""Adds an info."""
setattr(self.info, name, value)
+ def IsCoreGLFunction(self):
+ return not self.GetInfo('extension')
+
def GetGLFunctionName(self):
"""Gets the function to call to execute GL for this command."""
if self.GetInfo('decoder_func'):
@@ -5255,24 +5259,28 @@ class GLGenerator(object):
"""Writes the Pepper OpenGLES interface definition."""
file = CHeaderWriter(
filename,
- "// This interface is used to access common and lite profile OpenGL ES "
- "2.0\n// functions.\n",
+ "// OpenGL ES interface.\n",
3)
- file.Write("#include \"ppapi/GLES2/khrplatform.h\"\n\n")
-
- file.Write("#define PPB_OPENGLES_DEV_INTERFACE \"PPB_OpenGLES(Dev);2.0\"\n\n")
-
+ file.Write("#ifndef __gl2_h_\n")
for (k, v) in _GL_TYPES.iteritems():
file.Write("typedef %s %s;\n" % (v, k))
+ file.Write("#endif // __gl2_h_\n\n")
- file.Write("\nstruct PPB_OpenGLES_Dev {\n")
+ file.Write("#define PPB_OPENGLES2_DEV_INTERFACE \"PPB_OpenGLES(Dev);2.0\"\n")
+
+ file.Write("\nstruct PPB_OpenGLES2_Dev {\n")
for func in self.original_functions:
- if func.GetInfo('extension'):
+ if not func.IsCoreGLFunction():
continue
- file.Write(" %s (*%s)(%s);\n" %
- (func.return_type, func.name,
- func.MakeTypedOriginalArgString("")))
+
+ original_arg = func.MakeTypedOriginalArgString("")
+ context_arg = "PP_Resource context"
+ if len(original_arg):
+ arg = context_arg + ", " + original_arg
+ else:
+ arg = context_arg
+ file.Write(" %s (*%s)(%s);\n" % (func.return_type, func.name, arg))
file.Write("};\n\n")
file.Close()
@@ -5284,45 +5292,54 @@ class GLGenerator(object):
file.Write(_LICENSE)
file.Write("// This file is auto-generated. DO NOT EDIT!\n\n")
- file.Write("#include \"webkit/glue/plugins/pepper_graphics_3d.h\"\n\n")
+ file.Write("#include \"webkit/plugins/ppapi/ppb_graphics_3d_impl.h\"\n\n")
file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"")
file.Write("\n#include \"ppapi/c/dev/ppb_opengles_dev.h\"\n\n")
- file.Write("namespace pepper {\n\n")
+ file.Write("namespace webkit {\n")
+ file.Write("namespace ppapi {\n\n")
file.Write("namespace {\n\n")
for func in self.original_functions:
- if func.GetInfo('extension'):
+ if not func.IsCoreGLFunction():
continue
- file.Write("%s %s(%s) {\n" %
- (func.return_type, func.name,
- func.MakeTypedOriginalArgString("")))
- return_string = "return "
- if func.return_type == "void":
- return_string = ""
- file.Write(" %sGraphics3D::GetCurrent()->impl()->%s(%s);\n" %
- (return_string, func.original_name,
- func.MakeOriginalArgString("")))
- file.Write("}\n")
- file.Write("\nconst struct PPB_OpenGLES_Dev ppb_opengles = {\n")
+ original_arg = func.MakeTypedOriginalArgString("")
+ context_arg = "PP_Resource context"
+ if len(original_arg):
+ arg = context_arg + ", " + original_arg
+ else:
+ arg = context_arg
+ file.Write("%s %s(%s) {\n" % (func.return_type, func.name, arg))
+
+ file.Write(""" scoped_refptr<PPB_Graphics3D_Impl> graphics_3d =
+ Resource::GetAs<PPB_Graphics3D_Impl>(context);
+""")
+
+ return_str = "" if func.return_type == "void" else "return "
+ file.Write(" %sgraphics_3d->impl()->%s(%s);\n" %
+ (return_str, func.original_name,
+ func.MakeOriginalArgString("")))
+ file.Write("}\n\n")
+ file.Write("\nconst struct PPB_OpenGLES2_Dev ppb_opengles2 = {\n")
file.Write(" &")
file.Write(",\n &".join(
- f.name for f in self.original_functions if not f.GetInfo('extension')))
+ f.name for f in self.original_functions if f.IsCoreGLFunction()))
file.Write("\n")
-
file.Write("};\n\n")
+
file.Write("} // namespace\n")
file.Write("""
-const PPB_OpenGLES_Dev* Graphics3D::GetOpenGLESInterface() {
- return &ppb_opengles;
+const PPB_OpenGLES2_Dev* PPB_Graphics3D_Impl::GetOpenGLES2Interface() {
+ return &ppb_opengles2;
}
""")
- file.Write("} // namespace pepper\n\n")
+ file.Write("} // namespace ppapi\n")
+ file.Write("} // namespace webkit\n\n")
file.Close()
@@ -5333,19 +5350,28 @@ const PPB_OpenGLES_Dev* Graphics3D::GetOpenGLESInterface() {
file.Write(_LICENSE)
file.Write("// This file is auto-generated. DO NOT EDIT!\n\n")
- file.Write("#include <GLES2/gl2.h>\n\n")
+ file.Write("#include <GLES2/gl2.h>\n")
+ file.Write("#include \"ppapi/lib/gl/gles2/gl2ext_ppapi.h\"\n\n")
for func in self.original_functions:
- if func.GetInfo('extension') or func.name == 'SwapBuffers':
+ if not func.IsCoreGLFunction():
continue
file.Write("%s GL_APIENTRY gl%s(%s) {\n" %
(func.return_type, func.name,
func.MakeTypedOriginalArgString("")))
- if func.return_type != "void":
- file.Write(" return 0;\n")
+ return_str = "" if func.return_type == "void" else "return "
+ interface_str = "glGetInterfacePPAPI()"
+ original_arg = func.MakeOriginalArgString("")
+ context_arg = "glGetCurrentContextPPAPI()"
+ if len(original_arg):
+ arg = context_arg + ", " + original_arg
+ else:
+ arg = context_arg
+ file.Write(" %s%s->%s(%s);\n" %
+ (return_str, interface_str, func.name, arg))
file.Write("}\n\n")
-
+
def main(argv):
"""This is the main function."""
parser = OptionParser()
@@ -5380,7 +5406,7 @@ def main(argv):
elif options.alternate_mode == "chrome_ppapi":
gen.WritePepperGLES2Implementation(
- "webkit/glue/plugins/pepper_graphics_3d_gl.cc")
+ "webkit/plugins/ppapi/ppb_opengles_impl.cc")
else:
gen.WriteCommandIds("common/gles2_cmd_ids_autogen.h")
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);