diff options
author | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-02 18:12:31 +0000 |
---|---|---|
committer | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-02 18:12:31 +0000 |
commit | f56279ca6fb81d883f77c6501c2f54dd95d4933d (patch) | |
tree | 8a69dcd6fb2c1ae6abe2985a00320f74ab2b8ab5 /gpu | |
parent | ed355815b599eecfeda838ef8e7fa7adcbb5a9a9 (diff) | |
download | chromium_src-f56279ca6fb81d883f77c6501c2f54dd95d4933d.zip chromium_src-f56279ca6fb81d883f77c6501c2f54dd95d4933d.tar.gz chromium_src-f56279ca6fb81d883f77c6501c2f54dd95d4933d.tar.bz2 |
Implement proxy for 3d-related interfaces
BUG=none
TEST=Pepper Flash
Review URL: http://codereview.chromium.org/6400007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73472 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rwxr-xr-x | gpu/command_buffer/build_gles2_cmd_buffer.py | 92 | ||||
-rw-r--r-- | gpu/gpu.gyp | 15 | ||||
-rw-r--r-- | gpu/ipc/DEPS | 4 | ||||
-rw-r--r-- | gpu/ipc/gpu_command_buffer_traits.cc | 39 | ||||
-rw-r--r-- | gpu/ipc/gpu_command_buffer_traits.h | 23 |
5 files changed, 169 insertions, 4 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index 93b13ea..3f53bdf 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -# Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 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. @@ -16,7 +16,7 @@ _SIZE_OF_UINT32 = 4 _SIZE_OF_COMMAND_HEADER = 4 _FIRST_SPECIFIC_COMMAND_ID = 256 -_LICENSE = """// Copyright (c) 2010 The Chromium Authors. All rights reserved. +_LICENSE = """// Copyright (c) 2011 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. @@ -5356,6 +5356,84 @@ const PPB_OpenGLES2_Dev* PPB_OpenGLES_Impl::GetInterface() { file.Close() + def WritePepperGLES2ProxyImplementation(self, filename): + """Writes the Pepper OpenGLES interface implementation.""" + + file = CWriter(filename) + file.Write(_LICENSE) + file.Write("// This file is auto-generated. DO NOT EDIT!\n\n") + + file.Write("#include \"ppapi/proxy/ppb_opengles2_proxy.h\"\n\n") + + file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n") + file.Write("#include \"ppapi/c/pp_errors.h\"\n") + file.Write("#include \"ppapi/c/pp_resource.h\"\n") + file.Write("#include \"ppapi/c/dev/ppb_opengles_dev.h\"\n") + file.Write("#include \"ppapi/proxy/plugin_dispatcher.h\"\n") + file.Write("#include \"ppapi/proxy/plugin_resource.h\"\n") + file.Write("#include \"ppapi/proxy/ppb_context_3d_proxy.h\"\n\n") + + file.Write("namespace pp {\n") + file.Write("namespace proxy {\n\n") + file.Write("namespace {\n\n") + + + for func in self.original_functions: + if not func.IsCoreGLFunction(): + continue + + original_arg = func.MakeTypedOriginalArgString("") + context_arg = "PP_Resource context_id" + 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(""" Context3D* context = PluginResource::GetAs<Context3D>(context_id);\n""") + + return_str = "" if func.return_type == "void" else "return " + file.Write(" %scontext->gles2_impl()->%s(%s);\n" % + (return_str, func.original_name, + func.MakeOriginalArgString(""))) + file.Write("}\n\n") + + file.Write("const struct PPB_OpenGLES2_Dev ppb_opengles2 = {\n") + file.Write(" &") + file.Write(",\n &".join( + f.name for f in self.original_functions if f.IsCoreGLFunction())) + file.Write("\n") + file.Write("};\n\n") + + file.Write("} // namespace\n") + + file.Write(""" +PPB_OpenGLES2_Proxy::PPB_OpenGLES2_Proxy(Dispatcher* dispatcher, + const void* target_interface) + : InterfaceProxy(dispatcher, target_interface) { +} + +PPB_OpenGLES2_Proxy::~PPB_OpenGLES2_Proxy() { +} + +const void* PPB_OpenGLES2_Proxy::GetSourceInterface() const { + return &ppb_opengles2; +} + +InterfaceID PPB_OpenGLES2_Proxy::GetInterfaceId() const { + return INTERFACE_ID_NONE; +} + +bool PPB_OpenGLES2_Proxy::OnMessageReceived(const IPC::Message& msg) { + return false; +} + +""") + file.Write("} // namespace proxy\n") + file.Write("} // namespace pp\n") + + file.Close() + def WriteGLES2ToPPAPIBridge(self, filename): """Connects GLES2 helper library to PPB_OpenGLES2 interface""" @@ -5399,9 +5477,11 @@ def main(argv): help="generate a docs friendly version of the command formats.") parser.add_option( "--alternate-mode", type="choice", - choices=("ppapi", "chrome_ppapi"), + choices=("ppapi", "chrome_ppapi", "chrome_ppapi_proxy"), help="generate files for other projects. \"ppapi\" will generate ppapi " - "bindings. \"chrome_ppapi\" generate chrome implementation for ppapi.") + "bindings. \"chrome_ppapi\" generate chrome implementation for ppapi. " + "\"chrome_ppapi_proxy\" will generate the glue for the chrome IPC ppapi" + "proxy.") parser.add_option( "--output-dir", help="base directory for resulting files, under chrome/src. default is " @@ -5433,6 +5513,10 @@ def main(argv): gen.WritePepperGLES2Implementation( "webkit/plugins/ppapi/ppb_opengles_impl.cc") + elif options.alternate_mode == "chrome_ppapi_proxy": + gen.WritePepperGLES2ProxyImplementation( + "ppapi/proxy/ppb_opengles2_proxy.cc") + else: os.chdir("gpu/command_buffer") gen.WriteCommandIds("common/gles2_cmd_ids_autogen.h") diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index 3a4805f..6bb7ace 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -347,6 +347,21 @@ 'pgl/pgl.h', ], }, + { + 'target_name': 'gpu_ipc', + 'type': 'static_library', + 'dependencies': [ + 'command_buffer_client', + 'gles2_c_lib', + ], + 'include_dirs': [ + '..', + ], + 'sources': [ + 'ipc/gpu_command_buffer_traits.cc', + 'ipc/gpu_command_buffer_traits.h', + ], + }, ], 'conditions': [ ['OS == "win"', diff --git a/gpu/ipc/DEPS b/gpu/ipc/DEPS new file mode 100644 index 0000000..9634ba4 --- /dev/null +++ b/gpu/ipc/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + "+base", + "+ipc", +] diff --git a/gpu/ipc/gpu_command_buffer_traits.cc b/gpu/ipc/gpu_command_buffer_traits.cc new file mode 100644 index 0000000..eecf19f --- /dev/null +++ b/gpu/ipc/gpu_command_buffer_traits.cc @@ -0,0 +1,39 @@ +// Copyright (c) 2011 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 "gpu/ipc/gpu_command_buffer_traits.h" + +namespace IPC { + +void ParamTraits<gpu::CommandBuffer::State> ::Write(Message* m, + const param_type& p) { + WriteParam(m, p.num_entries); + WriteParam(m, p.get_offset); + WriteParam(m, p.put_offset); + WriteParam(m, p.token); + WriteParam(m, static_cast<int32>(p.error)); +} + +bool ParamTraits<gpu::CommandBuffer::State> ::Read(const Message* m, + void** iter, + param_type* p) { + int32 temp; + if (ReadParam(m, iter, &p->num_entries) && + ReadParam(m, iter, &p->get_offset) && + ReadParam(m, iter, &p->put_offset) && + ReadParam(m, iter, &p->token) && + ReadParam(m, iter, &temp)) { + p->error = static_cast<gpu::error::Error>(temp); + return true; + } else { + return false; + } +} + +void ParamTraits<gpu::CommandBuffer::State> ::Log(const param_type& p, + std::string* l) { + l->append("<CommandBuffer::State>"); +} + +} // namespace IPC diff --git a/gpu/ipc/gpu_command_buffer_traits.h b/gpu/ipc/gpu_command_buffer_traits.h new file mode 100644 index 0000000..2237c1e9 --- /dev/null +++ b/gpu/ipc/gpu_command_buffer_traits.h @@ -0,0 +1,23 @@ +// Copyright (c) 2011 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 GPU_IPC_GPU_PARAM_TRAITS_H_ +#define GPU_IPC_GPU_PARAM_TRAITS_H_ + +#include "ipc/ipc_message_utils.h" +#include "gpu/command_buffer/common/command_buffer.h" + +namespace IPC { + +template <> +struct ParamTraits<gpu::CommandBuffer::State> { + typedef gpu::CommandBuffer::State param_type; + static void Write(Message* m, const param_type& p); + static bool Read(const Message* m, void** iter, param_type* p); + static void Log(const param_type& p, std::string* l); +}; + +} // namespace IPC + +#endif // GPU_IPC_GPU_PARAM_TRAITS_H_ |