diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-22 20:57:00 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-22 20:57:00 +0000 |
commit | e18e6392bb61e5a525b87951b9e42df0f2d07c83 (patch) | |
tree | 55c67d9ffaf42151ca259e32f043030c9afa7d16 | |
parent | 627c4549e3d258ed34d896ac7910f04694cbc7b0 (diff) | |
download | chromium_src-e18e6392bb61e5a525b87951b9e42df0f2d07c83.zip chromium_src-e18e6392bb61e5a525b87951b9e42df0f2d07c83.tar.gz chromium_src-e18e6392bb61e5a525b87951b9e42df0f2d07c83.tar.bz2 |
Convert most remaining resources to use the API/thunk system. The significant
changes here are around the 3D API. Having separate files for the texture
mapping interface is no longer necessary for the proxy and the
implementation.
This also removes the uses of the "old" dynamic casting system (using
"GetAs") for other resources that I could find.
TEST=ui tests
BUG=none
Review URL: http://codereview.chromium.org/7206016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90096 0039d316-1c4b-4281-b951-d872f2087c98
67 files changed, 2180 insertions, 2071 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index 1cee782..76aafeb 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -22,6 +22,12 @@ _LICENSE = """// Copyright (c) 2011 The Chromium Authors. All rights reserved. """ +_DO_NOT_EDIT_WARNING = """// This file is auto-generated from +// gpu/command_buffer/build_gles2_cmd_buffer.py +// DO NOT EDIT! + +""" + # This string is copied directly out of the gl2.h file from GLES2.0 # # Edits: @@ -1852,9 +1858,7 @@ class CHeaderWriter(CWriter): self.guard = self._non_alnum_re.sub('_', hpath).upper() + '_' self.Write(_LICENSE) - self.Write( - "// This file is auto-generated. DO NOT EDIT!\n" - "\n") + self.Write(_DO_NOT_EDIT_WARNING) if not file_comment == None: self.Write(file_comment) self.Write("#ifndef %s\n" % self.guard) @@ -5665,18 +5669,28 @@ const size_t GLES2Util::enum_to_string_table_len_ = file = CWriter(filename) file.Write(_LICENSE) - file.Write("// This file is auto-generated. DO NOT EDIT!\n\n") + file.Write(_DO_NOT_EDIT_WARNING) file.Write("#include \"webkit/plugins/ppapi/ppb_opengles_impl.h\"\n\n") file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n") file.Write("#include \"ppapi/c/dev/ppb_opengles_dev.h\"\n") + file.Write("#include \"ppapi/shared_impl/resource_object_base.h\"\n") + file.Write("#include \"ppapi/shared_impl/tracker_base.h\"\n") file.Write("#include \"webkit/plugins/ppapi/ppb_context_3d_impl.h\"\n\n") + file.Write("using ppapi::ResourceObjectBase;\n") + file.Write("using ppapi::TrackerBase;\n\n") file.Write("namespace webkit {\n") file.Write("namespace ppapi {\n\n") file.Write("namespace {\n\n") + file.Write("gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) {\n") + file.Write(" ResourceObjectBase* base = TrackerBase::Get()->GetResourceAPI(context);\n") + file.Write(" DCHECK(base->AsPPB_Context3D_API());\n") + file.Write(" return static_cast<PPB_Context3D_Impl*>(base)->gles2_impl();\n") + file.Write("}\n\n") + for func in self.original_functions: if not func.IsCoreGLFunction(): continue @@ -5689,12 +5703,8 @@ const size_t GLES2Util::enum_to_string_table_len_ = arg = context_arg file.Write("%s %s(%s) {\n" % (func.return_type, func.name, arg)) - file.Write(""" scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); -""") - return_str = "" if func.return_type == "void" else "return " - file.Write(" %scontext->gles2_impl()->%s(%s);\n" % + file.Write(" %sGetGLES(context_id)->%s(%s);\n" % (return_str, func.original_name, func.MakeOriginalArgString(""))) file.Write("}\n\n") @@ -5724,7 +5734,7 @@ const PPB_OpenGLES2_Dev* PPB_OpenGLES_Impl::GetInterface() { file = CWriter(filename) file.Write(_LICENSE) - file.Write("// This file is auto-generated. DO NOT EDIT!\n\n") + file.Write(_DO_NOT_EDIT_WARNING) file.Write("#include \"ppapi/proxy/ppb_opengles2_proxy.h\"\n\n") @@ -5734,12 +5744,19 @@ const PPB_OpenGLES2_Dev* PPB_OpenGLES_Impl::GetInterface() { 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("#include \"ppapi/proxy/ppb_context_3d_proxy.h\"\n") + file.Write("#include \"ppapi/shared_impl/resource_object_base.h\"\n") + file.Write("#include \"ppapi/shared_impl/tracker_base.h\"\n\n") file.Write("namespace pp {\n") file.Write("namespace proxy {\n\n") file.Write("namespace {\n\n") - + file.Write("gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) {\n") + file.Write(" ppapi::ResourceObjectBase* base =\n") + file.Write(" ppapi::TrackerBase::Get()->GetResourceAPI(context);\n") + file.Write(" DCHECK(base->AsPPB_Context3D_API());\n") + file.Write(" return static_cast<Context3D*>(base)->gles2_impl();\n") + file.Write("}\n\n") for func in self.original_functions: if not func.IsCoreGLFunction(): @@ -5753,10 +5770,8 @@ const PPB_OpenGLES2_Dev* PPB_OpenGLES_Impl::GetInterface() { 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" % + file.Write(" %sGetGLES(context_id)->%s(%s);\n" % (return_str, func.original_name, func.MakeOriginalArgString(""))) file.Write("}\n\n") @@ -5811,7 +5826,7 @@ bool PPB_OpenGLES2_Proxy::OnMessageReceived(const IPC::Message& msg) { file = CWriter(filename) file.Write(_LICENSE) - file.Write("// This file is auto-generated. DO NOT EDIT!\n\n") + file.Write(_DO_NOT_EDIT_WARNING) file.Write("#include <GLES2/gl2.h>\n") file.Write("#include \"ppapi/lib/gl/gles2/gl2ext_ppapi.h\"\n\n") @@ -5840,7 +5855,7 @@ bool PPB_OpenGLES2_Proxy::OnMessageReceived(const IPC::Message& msg) { file = CWriter(filename) file.Write(_LICENSE) - file.Write("// This file is auto-generated. DO NOT EDIT!\n\n") + file.Write(_DO_NOT_EDIT_WARNING) file.Write("#include \"native_client/src/shared/ppapi_proxy" "/plugin_context_3d.h\"\n\n") diff --git a/ppapi/c/dev/ppb_context_3d_trusted_dev.h b/ppapi/c/dev/ppb_context_3d_trusted_dev.h index ce4d8d6..a57c9dd 100644 --- a/ppapi/c/dev/ppb_context_3d_trusted_dev.h +++ b/ppapi/c/dev/ppb_context_3d_trusted_dev.h @@ -15,6 +15,7 @@ #define PPB_CONTEXT_3D_TRUSTED_DEV_INTERFACE \ PPB_CONTEXT_3D_TRUSTED_DEV_INTERFACE_0_4 +// TODO(brettw) Remove these generic names from the global namespace! typedef enum { kNoError, kInvalidSize, diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index 5d63efe..1d4ba98 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -92,8 +92,6 @@ 'proxy/ppb_flash_net_connector_proxy.h', 'proxy/ppb_font_proxy.cc', 'proxy/ppb_font_proxy.h', - 'proxy/ppb_gles_chromium_texture_mapping_proxy.cc', - 'proxy/ppb_gles_chromium_texture_mapping_proxy.h', 'proxy/ppb_graphics_2d_proxy.cc', 'proxy/ppb_graphics_2d_proxy.h', 'proxy/ppb_image_data_proxy.cc', diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index dd48fe8..3c9b9f2 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -63,6 +63,9 @@ 'thunk/ppb_buffer_trusted_thunk.cc', 'thunk/ppb_char_set_api.h', 'thunk/ppb_char_set_thunk.cc', + 'thunk/ppb_context_3d_api.h', + 'thunk/ppb_context_3d_thunk.cc', + 'thunk/ppb_context_3d_trusted_thunk.cc', 'thunk/ppb_cursor_control_api.h', 'thunk/ppb_cursor_control_thunk.cc', 'thunk/ppb_directory_reader_api.h', @@ -85,16 +88,23 @@ 'thunk/ppb_font_api.h', 'thunk/ppb_font_thunk.cc', 'thunk/ppb_fullscreen_thunk.cc', + 'thunk/ppb_gles_chromium_texture_mapping_thunk.cc', 'thunk/ppb_graphics_2d_api.h', 'thunk/ppb_graphics_2d_thunk.cc', + 'thunk/ppb_graphics_3d_api.h', + 'thunk/ppb_graphics_3d_thunk.cc', 'thunk/ppb_image_data_api.h', 'thunk/ppb_image_data_thunk.cc', 'thunk/ppb_image_data_trusted_thunk.cc', 'thunk/ppb_instance_api.h', 'thunk/ppb_instance_thunk.cc', + 'thunk/ppb_layer_compositor_api.h', + 'thunk/ppb_layer_compositor_thunk.cc', 'thunk/ppb_pdf_api.h', 'thunk/ppb_surface_3d_api.h', 'thunk/ppb_surface_3d_thunk.cc', + 'thunk/ppb_transport_api.h', + 'thunk/ppb_transport_thunk.cc', 'thunk/ppb_url_loader_api.h', 'thunk/ppb_url_loader_thunk.cc', 'thunk/ppb_url_request_info_api.h', diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc index dcc40cf..35a7d67 100644 --- a/ppapi/proxy/dispatcher.cc +++ b/ppapi/proxy/dispatcher.cc @@ -62,7 +62,6 @@ #include "ppapi/proxy/ppb_flash_menu_proxy.h" #include "ppapi/proxy/ppb_flash_net_connector_proxy.h" #include "ppapi/proxy/ppb_font_proxy.h" -#include "ppapi/proxy/ppb_gles_chromium_texture_mapping_proxy.h" #include "ppapi/proxy/ppb_graphics_2d_proxy.h" #include "ppapi/proxy/ppb_image_data_proxy.h" #include "ppapi/proxy/ppb_instance_proxy.h" @@ -120,6 +119,7 @@ InterfaceList::InterfaceList() { AddPPB(PPB_CharSet_Proxy::GetInfo()); AddPPB(PPB_Console_Proxy::GetInfo()); AddPPB(PPB_Context3D_Proxy::GetInfo()); + AddPPB(PPB_Context3D_Proxy::GetTextureMappingInfo()); AddPPB(PPB_Core_Proxy::GetInfo()); AddPPB(PPB_Crypto_Proxy::GetInfo()); AddPPB(PPB_CursorControl_Proxy::GetInfo()); @@ -132,7 +132,6 @@ InterfaceList::InterfaceList() { AddPPB(PPB_Flash_Proxy::GetInfo()); AddPPB(PPB_Flash_Menu_Proxy::GetInfo()); AddPPB(PPB_Font_Proxy::GetInfo()); - AddPPB(PPB_GLESChromiumTextureMapping_Proxy::GetInfo()); AddPPB(PPB_Graphics2D_Proxy::GetInfo()); AddPPB(PPB_ImageData_Proxy::GetInfo()); AddPPB(PPB_Instance_Proxy::GetInfoPrivate()); diff --git a/ppapi/proxy/interface_id.h b/ppapi/proxy/interface_id.h index 1e4ced0..40554f5 100644 --- a/ppapi/proxy/interface_id.h +++ b/ppapi/proxy/interface_id.h @@ -34,7 +34,6 @@ enum InterfaceID { INTERFACE_ID_PPB_FLASH_MENU, INTERFACE_ID_PPB_FLASH_NETCONNECTOR, INTERFACE_ID_PPB_FONT, - INTERFACE_ID_PPB_GLES_CHROMIUM_TM, INTERFACE_ID_PPB_GRAPHICS_2D, INTERFACE_ID_PPB_IMAGE_DATA, INTERFACE_ID_PPB_INSTANCE, diff --git a/ppapi/proxy/ppb_context_3d_proxy.cc b/ppapi/proxy/ppb_context_3d_proxy.cc index 627ebba..d31ad29 100644 --- a/ppapi/proxy/ppb_context_3d_proxy.cc +++ b/ppapi/proxy/ppb_context_3d_proxy.cc @@ -11,126 +11,26 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/dev/ppb_context_3d_dev.h" #include "ppapi/c/dev/ppb_context_3d_trusted_dev.h" +#include "ppapi/proxy/enter_proxy.h" #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/plugin_resource.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/ppb_surface_3d_proxy.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/resource_creation_api.h" +#include "ppapi/thunk/thunk.h" + +using ppapi::thunk::EnterFunctionNoLock; +using ppapi::thunk::EnterResourceNoLock; +using ppapi::thunk::PPB_Context3D_API; +using ppapi::thunk::PPB_Surface3D_API; +using ppapi::thunk::ResourceCreationAPI; namespace pp { namespace proxy { namespace { -PP_Resource Create(PP_Instance instance, - PP_Config3D_Dev config, - PP_Resource share_context, - const int32_t* attrib_list) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_ERROR_BADARGUMENT; - - // TODO(alokp): Support shared context. - DCHECK_EQ(0, share_context); - if (share_context != 0) - return 0; - - std::vector<int32_t> attribs; - if (attrib_list) { - for (const int32_t* attr = attrib_list; attr; ++attr) - attribs.push_back(*attr); - } else { - attribs.push_back(0); - } - - HostResource result; - dispatcher->Send(new PpapiHostMsg_PPBContext3D_Create( - INTERFACE_ID_PPB_CONTEXT_3D, instance, config, attribs, &result)); - - if (result.is_null()) - return 0; - linked_ptr<Context3D> context_3d(new Context3D(result)); - if (!context_3d->CreateImplementation()) - return 0; - return PluginResourceTracker::GetInstance()->AddResource(context_3d); -} - -PP_Bool IsContext3D(PP_Resource resource) { - Context3D* object = PluginResource::GetAs<Context3D>(resource); - return BoolToPPBool(!!object); -} - -int32_t GetAttrib(PP_Resource context, - int32_t attribute, - int32_t* value) { - // TODO(alokp): Implement me. - return 0; -} - -int32_t BindSurfaces(PP_Resource context_id, - PP_Resource draw, - PP_Resource read) { - Context3D* object = PluginResource::GetAs<Context3D>(context_id); - if (!object) - return PP_ERROR_BADRESOURCE; - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( - object->instance()); - if (!dispatcher) - return PP_ERROR_FAILED; - - // TODO(alokp): Support separate draw-read surfaces. - DCHECK_EQ(draw, read); - if (draw != read) - return PP_GRAPHICS3DERROR_BAD_MATCH; - - Surface3D* draw_surface = PluginResource::GetAs<Surface3D>(draw); - Surface3D* read_surface = PluginResource::GetAs<Surface3D>(read); - if (draw && !draw_surface) - return PP_ERROR_BADRESOURCE; - if (read && !read_surface) - return PP_ERROR_BADRESOURCE; - HostResource host_draw = - draw_surface ? draw_surface->host_resource() : HostResource(); - HostResource host_read = - read_surface ? read_surface->host_resource() : HostResource(); - - int32_t result; - dispatcher->Send(new PpapiHostMsg_PPBContext3D_BindSurfaces( - INTERFACE_ID_PPB_CONTEXT_3D, - object->host_resource(), - host_draw, - host_read, - &result)); - - if (result == PP_OK) - object->BindSurfaces(draw_surface, read_surface); - - return result; -} - -int32_t GetBoundSurfaces(PP_Resource context, - PP_Resource* draw, - PP_Resource* read) { - Context3D* object = PluginResource::GetAs<Context3D>(context); - if (!object) - return PP_ERROR_BADRESOURCE; - - Surface3D* draw_surface = object->get_draw_surface(); - Surface3D* read_surface = object->get_read_surface(); - - *draw = draw_surface ? draw_surface->resource() : 0; - *read = read_surface ? read_surface->resource() : 0; - return PP_OK; -} - - -const PPB_Context3D_Dev context_3d_interface = { - &Create, - &IsContext3D, - &GetAttrib, - &BindSurfaces, - &GetBoundSurfaces, -}; - base::SharedMemoryHandle TransportSHMHandleFromInt(Dispatcher* dispatcher, int shm_handle) { // TODO(piman): Change trusted interface to return a PP_FileHandle, those @@ -147,6 +47,12 @@ base::SharedMemoryHandle TransportSHMHandleFromInt(Dispatcher* dispatcher, return dispatcher->ShareHandleWithRemote(source, false); } +PP_Context3DTrustedState GetErrorState() { + PP_Context3DTrustedState error_state = { 0 }; + error_state.error = kGenericError; + return error_state; +} + gpu::CommandBuffer::State GPUStateFromPPState( const PP_Context3DTrustedState& s) { gpu::CommandBuffer::State state; @@ -419,6 +325,8 @@ void PepperCommandBuffer::UpdateState(const gpu::CommandBuffer::State& state) { last_state_ = state; } +// Context3D ------------------------------------------------------------------- + Context3D::Context3D(const HostResource& resource) : PluginResource(resource), draw_(NULL), @@ -431,6 +339,10 @@ Context3D::~Context3D() { draw_->set_context(NULL); } +PPB_Context3D_API* Context3D::AsPPB_Context3D_API() { + return this; +} + bool Context3D::CreateImplementation() { PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance()); if (!dispatcher) @@ -465,28 +377,132 @@ bool Context3D::CreateImplementation() { return true; } -void Context3D::BindSurfaces(Surface3D* draw, Surface3D* read) { - if (draw != draw_) { +int32_t Context3D::GetAttrib(int32_t attribute, int32_t* value) { + // TODO(alokp): Implement me. + return 0; +} + +int32_t Context3D::BindSurfaces(PP_Resource pp_draw, PP_Resource pp_read) { + // TODO(alokp): Support separate draw-read surfaces. + DCHECK_EQ(pp_draw, pp_read); + if (pp_draw != pp_read) + return PP_GRAPHICS3DERROR_BAD_MATCH; + + EnterResourceNoLock<PPB_Surface3D_API> enter_draw(pp_draw, false); + EnterResourceNoLock<PPB_Surface3D_API> enter_read(pp_read, false); + Surface3D* draw_surface = enter_draw.succeeded() ? + static_cast<Surface3D*>(enter_draw.object()) : NULL; + Surface3D* read_surface = enter_read.succeeded() ? + static_cast<Surface3D*>(enter_read.object()) : NULL; + + if (pp_draw && !draw_surface) + return PP_ERROR_BADRESOURCE; + if (pp_read && !read_surface) + return PP_ERROR_BADRESOURCE; + HostResource host_draw = + draw_surface ? draw_surface->host_resource() : HostResource(); + HostResource host_read = + read_surface ? read_surface->host_resource() : HostResource(); + + int32_t result; + GetDispatcher()->Send(new PpapiHostMsg_PPBContext3D_BindSurfaces( + INTERFACE_ID_PPB_CONTEXT_3D, + host_resource(), host_draw, host_read, &result)); + if (result != PP_OK) + return result; + + if (draw_surface != draw_) { if (draw_) draw_->set_context(NULL); - if (draw) { - draw->set_context(this); + if (draw_surface) { + draw_surface->set_context(this); // Resize the backing texture to the size of the instance when it is // bound. // TODO(alokp): This should be the responsibility of plugins. - PluginDispatcher* dispatcher = - PluginDispatcher::GetForInstance(instance()); - DCHECK(dispatcher); - InstanceData* data = dispatcher->GetInstanceData(instance()); - DCHECK(data); + InstanceData* data = GetDispatcher()->GetInstanceData(instance()); gles2_impl()->ResizeCHROMIUM(data->position.size.width, data->position.size.height); } - draw_ = draw; + draw_ = draw_surface; } - read_ = read; + read_ = read_surface; + return PP_OK; +} + +int32_t Context3D::GetBoundSurfaces(PP_Resource* draw, PP_Resource* read) { + *draw = draw_ ? draw_->resource() : 0; + *read = read_ ? read_->resource() : 0; + return PP_OK; +} + +PP_Bool Context3D::InitializeTrusted(int32_t size) { + // Trusted interface not implemented in the proxy. + return PP_FALSE; } +PP_Bool Context3D::GetRingBuffer(int* shm_handle, + uint32_t* shm_size) { + // Trusted interface not implemented in the proxy. + return PP_FALSE; +} + +PP_Context3DTrustedState Context3D::GetState() { + // Trusted interface not implemented in the proxy. + return GetErrorState(); +} + +PP_Bool Context3D::Flush(int32_t put_offset) { + // Trusted interface not implemented in the proxy. + return PP_FALSE; +} + +PP_Context3DTrustedState Context3D::FlushSync(int32_t put_offset) { + // Trusted interface not implemented in the proxy. + return GetErrorState(); +} + +int32_t Context3D::CreateTransferBuffer(uint32_t size) { + // Trusted interface not implemented in the proxy. + return 0; +} + +PP_Bool Context3D::DestroyTransferBuffer(int32_t id) { + // Trusted interface not implemented in the proxy. + return PP_FALSE; +} + +PP_Bool Context3D::GetTransferBuffer(int32_t id, + int* shm_handle, + uint32_t* shm_size) { + // Trusted interface not implemented in the proxy. + return PP_FALSE; +} + +PP_Context3DTrustedState Context3D::FlushSyncFast(int32_t put_offset, + int32_t last_known_get) { + // Trusted interface not implemented in the proxy. + return GetErrorState(); +} + +void* Context3D::MapTexSubImage2DCHROMIUM(GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + GLenum access) { + return gles2_impl_->MapTexSubImage2DCHROMIUM( + target, level, xoffset, yoffset, width, height, format, type, access); +} + +void Context3D::UnmapTexSubImage2DCHROMIUM(const void* mem) { + gles2_impl_->UnmapTexSubImage2DCHROMIUM(mem); +} + +// PPB_Context3D_Proxy --------------------------------------------------------- + PPB_Context3D_Proxy::PPB_Context3D_Proxy(Dispatcher* dispatcher, const void* target_interface) : InterfaceProxy(dispatcher, target_interface) { @@ -498,7 +514,7 @@ PPB_Context3D_Proxy::~PPB_Context3D_Proxy() { // static const InterfaceProxy::Info* PPB_Context3D_Proxy::GetInfo() { static const Info info = { - &context_3d_interface, + ::ppapi::thunk::GetPPB_Context3D_Thunk(), PPB_CONTEXT_3D_DEV_INTERFACE, INTERFACE_ID_PPB_CONTEXT_3D, false, @@ -507,11 +523,50 @@ const InterfaceProxy::Info* PPB_Context3D_Proxy::GetInfo() { return &info; } -const PPB_Context3DTrusted_Dev* -PPB_Context3D_Proxy::ppb_context_3d_trusted() const { - return static_cast<const PPB_Context3DTrusted_Dev*>( - dispatcher()->GetLocalInterface( - PPB_CONTEXT_3D_TRUSTED_DEV_INTERFACE)); +// static +const InterfaceProxy::Info* PPB_Context3D_Proxy::GetTextureMappingInfo() { + static const Info info = { + ::ppapi::thunk::GetPPB_GLESChromiumTextureMapping_Thunk(), + PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE, + INTERFACE_ID_NONE, // CONTEXT_3D is the canonical one. + false, + &CreateContext3DProxy, + }; + return &info; +} + +// static +PP_Resource PPB_Context3D_Proxy::Create(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { + PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); + if (!dispatcher) + return PP_ERROR_BADARGUMENT; + + // TODO(alokp): Support shared context. + DCHECK_EQ(0, share_context); + if (share_context != 0) + return 0; + + std::vector<int32_t> attribs; + if (attrib_list) { + for (const int32_t* attr = attrib_list; attr; ++attr) + attribs.push_back(*attr); + } else { + attribs.push_back(0); + } + + HostResource result; + dispatcher->Send(new PpapiHostMsg_PPBContext3D_Create( + INTERFACE_ID_PPB_CONTEXT_3D, instance, config, attribs, &result)); + + if (result.is_null()) + return 0; + linked_ptr<Context3D> context_3d(new Context3D(result)); + if (!context_3d->CreateImplementation()) + return 0; + return PluginResourceTracker::GetInstance()->AddResource(context_3d); } bool PPB_Context3D_Proxy::OnMessageReceived(const IPC::Message& msg) { @@ -545,46 +600,56 @@ bool PPB_Context3D_Proxy::OnMessageReceived(const IPC::Message& msg) { void PPB_Context3D_Proxy::OnMsgCreate(PP_Instance instance, PP_Config3D_Dev config, const std::vector<int32_t>& attribs, - HostResource* result) { - DCHECK(attribs.back() == 0); - PP_Resource resource = ppb_context_3d_trusted()->CreateRaw( - instance, config, 0, &attribs.front()); - result->SetHostResource(instance, resource); + HostResource* result) { + if (attribs.empty() || attribs.back() != 0) + return; // Bad message. + EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); + if (enter.succeeded()) { + result->SetHostResource( + instance, + enter.functions()->CreateContext3DRaw(instance, config, 0, + &attribs.front())); + } } void PPB_Context3D_Proxy::OnMsgBindSurfaces(const HostResource& context, const HostResource& draw, const HostResource& read, int32_t* result) { - *result = ppb_context_3d_target()->BindSurfaces(context.host_resource(), - draw.host_resource(), - read.host_resource()); + EnterHostFromHostResource<PPB_Context3D_API> enter(context); + if (enter.succeeded()) { + *result = enter.object()->BindSurfaces(draw.host_resource(), + read.host_resource()); + } else { + *result = PP_ERROR_BADRESOURCE; + } } void PPB_Context3D_Proxy::OnMsgInitialize( const HostResource& context, int32 size, base::SharedMemoryHandle* ring_buffer) { - const PPB_Context3DTrusted_Dev* context_3d_trusted = ppb_context_3d_trusted(); *ring_buffer = base::SharedMemory::NULLHandle(); - if (!context_3d_trusted->Initialize(context.host_resource(), size)) + EnterHostFromHostResource<PPB_Context3D_API> enter(context); + if (enter.failed()) + return; + + if (!enter.object()->InitializeTrusted(size)) return; int shm_handle; uint32_t shm_size; - if (!context_3d_trusted->GetRingBuffer(context.host_resource(), - &shm_handle, - &shm_size)) { + if (!enter.object()->GetRingBuffer(&shm_handle, &shm_size)) return; - } - *ring_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); } void PPB_Context3D_Proxy::OnMsgGetState(const HostResource& context, gpu::CommandBuffer::State* state) { - PP_Context3DTrustedState pp_state = - ppb_context_3d_trusted()->GetState(context.host_resource()); + EnterHostFromHostResource<PPB_Context3D_API> enter(context); + if (enter.failed()) + return; + PP_Context3DTrustedState pp_state = enter.object()->GetState(); *state = GPUStateFromPPState(pp_state); } @@ -592,28 +657,38 @@ void PPB_Context3D_Proxy::OnMsgFlush(const HostResource& context, int32 put_offset, int32 last_known_get, gpu::CommandBuffer::State* state) { - PP_Context3DTrustedState pp_state = ppb_context_3d_trusted()->FlushSyncFast( - context.host_resource(), put_offset, last_known_get); + EnterHostFromHostResource<PPB_Context3D_API> enter(context); + if (enter.failed()) + return; + PP_Context3DTrustedState pp_state = enter.object()->FlushSyncFast( + put_offset, last_known_get); *state = GPUStateFromPPState(pp_state); } void PPB_Context3D_Proxy::OnMsgAsyncFlush(const HostResource& context, int32 put_offset) { - ppb_context_3d_trusted()->Flush(context.host_resource(), put_offset); + EnterHostFromHostResource<PPB_Context3D_API> enter(context); + if (enter.succeeded()) + enter.object()->Flush(put_offset); } void PPB_Context3D_Proxy::OnMsgCreateTransferBuffer( const HostResource& context, int32 size, int32* id) { - *id = ppb_context_3d_trusted()->CreateTransferBuffer( - context.host_resource(), size); + EnterHostFromHostResource<PPB_Context3D_API> enter(context); + if (enter.succeeded()) + *id = enter.object()->CreateTransferBuffer(size); + else + *id = 0; } void PPB_Context3D_Proxy::OnMsgDestroyTransferBuffer( const HostResource& context, int32 id) { - ppb_context_3d_trusted()->DestroyTransferBuffer(context.host_resource(), id); + EnterHostFromHostResource<PPB_Context3D_API> enter(context); + if (enter.succeeded()) + enter.object()->DestroyTransferBuffer(id); } void PPB_Context3D_Proxy::OnMsgGetTransferBuffer( @@ -622,16 +697,16 @@ void PPB_Context3D_Proxy::OnMsgGetTransferBuffer( base::SharedMemoryHandle* transfer_buffer, uint32* size) { *transfer_buffer = base::SharedMemory::NULLHandle(); - int shm_handle; - uint32_t shm_size; - if (!ppb_context_3d_trusted()->GetTransferBuffer(context.host_resource(), - id, - &shm_handle, - &shm_size)) { - return; + *size = 0; + + EnterHostFromHostResource<PPB_Context3D_API> enter(context); + int shm_handle = 0; + uint32_t shm_size = 0; + if (enter.succeeded() && + enter.object()->GetTransferBuffer(id, &shm_handle, &shm_size)) { + *transfer_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); + *size = shm_size; } - *transfer_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); - *size = shm_size; } } // namespace proxy diff --git a/ppapi/proxy/ppb_context_3d_proxy.h b/ppapi/proxy/ppb_context_3d_proxy.h index c831fbe..991b7a2 100644 --- a/ppapi/proxy/ppb_context_3d_proxy.h +++ b/ppapi/proxy/ppb_context_3d_proxy.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_PPB_CONTEXT_3D_PROXY_H_ -#define PPAPI_PPB_CONTEXT_3D_PROXY_H_ +#ifndef PPAPI_PROXY_PPB_CONTEXT_3D_PROXY_H_ +#define PPAPI_PROXY_PPB_CONTEXT_3D_PROXY_H_ #include <vector> @@ -14,6 +14,7 @@ #include "ppapi/proxy/interface_proxy.h" #include "ppapi/proxy/plugin_resource.h" #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" +#include "ppapi/thunk/ppb_context_3d_api.h" struct PPB_Context3D_Dev; struct PPB_Context3DTrusted_Dev; @@ -33,30 +34,51 @@ namespace proxy { class Surface3D; -class Context3D : public PluginResource { +class Context3D : public PluginResource, + public ppapi::thunk::PPB_Context3D_API { public: explicit Context3D(const HostResource& resource); virtual ~Context3D(); - // Resource overrides. - virtual Context3D* AsContext3D() { return this; } - - bool CreateImplementation(); - - Surface3D* get_draw_surface() const { - return draw_; - } - - Surface3D* get_read_surface() const { - return read_; - } - - void BindSurfaces(Surface3D* draw, Surface3D* read); + // ResourceObjectBase overrides. + virtual ::ppapi::thunk::PPB_Context3D_API* AsPPB_Context3D_API() OVERRIDE; gpu::gles2::GLES2Implementation* gles2_impl() const { return gles2_impl_.get(); } + // PPB_Context3D_API implementation. + virtual int32_t GetAttrib(int32_t attribute, int32_t* value) OVERRIDE; + virtual int32_t BindSurfaces(PP_Resource draw, PP_Resource read) OVERRIDE; + virtual int32_t GetBoundSurfaces(PP_Resource* draw, + PP_Resource* read) OVERRIDE; + virtual PP_Bool InitializeTrusted(int32_t size) OVERRIDE; + virtual PP_Bool GetRingBuffer(int* shm_handle, + uint32_t* shm_size) OVERRIDE; + virtual PP_Context3DTrustedState GetState() OVERRIDE; + virtual PP_Bool Flush(int32_t put_offset) OVERRIDE; + virtual PP_Context3DTrustedState FlushSync(int32_t put_offset) OVERRIDE; + virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE; + virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE; + virtual PP_Bool GetTransferBuffer(int32_t id, + int* shm_handle, + uint32_t* shm_size) OVERRIDE; + virtual PP_Context3DTrustedState FlushSyncFast( + int32_t put_offset, + int32_t last_known_get) OVERRIDE; + virtual void* MapTexSubImage2DCHROMIUM(GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + GLenum access) OVERRIDE; + virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE; + + bool CreateImplementation(); + private: Surface3D* draw_; Surface3D* read_; @@ -75,11 +97,12 @@ class PPB_Context3D_Proxy : public InterfaceProxy { virtual ~PPB_Context3D_Proxy(); static const Info* GetInfo(); + static const Info* GetTextureMappingInfo(); - const PPB_Context3D_Dev* ppb_context_3d_target() const { - return reinterpret_cast<const PPB_Context3D_Dev*>(target_interface()); - } - const PPB_Context3DTrusted_Dev* ppb_context_3d_trusted() const; + static PP_Resource Create(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list); // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -118,4 +141,4 @@ class PPB_Context3D_Proxy : public InterfaceProxy { } // namespace proxy } // namespace pp -#endif // PPAPI_PPB_CONTEXT_3D_PROXY_H_ +#endif // PPAPI_PROXY_PPB_CONTEXT_3D_PROXY_H_ diff --git a/ppapi/proxy/ppb_flash_menu_proxy.cc b/ppapi/proxy/ppb_flash_menu_proxy.cc index 70262b1..0087700 100644 --- a/ppapi/proxy/ppb_flash_menu_proxy.cc +++ b/ppapi/proxy/ppb_flash_menu_proxy.cc @@ -183,18 +183,10 @@ void PPB_Flash_Menu_Proxy::OnMsgShow(const HostResource& menu, void PPB_Flash_Menu_Proxy::OnMsgShowACK(const HostResource& menu, int32_t selected_id, int32_t result) { - PP_Resource plugin_resource = - PluginResourceTracker::GetInstance()->PluginResourceForHostResource(menu); - if (!plugin_resource) + EnterPluginFromHostResource<PPB_Flash_Menu_API> enter(menu); + if (enter.failed()) return; - FlashMenu* object = PluginResource::GetAs<FlashMenu>(plugin_resource); - if (!object) { - // The plugin has released the FlashMenu object so don't issue the - // callback. - return; - } - - object->ShowACK(selected_id, result); + static_cast<FlashMenu*>(enter.object())->ShowACK(selected_id, result); } void PPB_Flash_Menu_Proxy::SendShowACKToPlugin( diff --git a/ppapi/proxy/ppb_font_proxy.cc b/ppapi/proxy/ppb_font_proxy.cc index c8f621a..6acfe5d 100644 --- a/ppapi/proxy/ppb_font_proxy.cc +++ b/ppapi/proxy/ppb_font_proxy.cc @@ -16,6 +16,7 @@ #include "ppapi/thunk/ppb_image_data_api.h" #include "ppapi/thunk/thunk.h" +using ppapi::thunk::EnterResourceNoLock; using ppapi::thunk::PPB_ImageData_API; using ppapi::WebKitForwarding; @@ -148,14 +149,10 @@ PP_Bool Font::DrawTextAt(PP_Resource pp_image_data, const PP_Rect* clip, PP_Bool image_data_is_opaque) { // Convert to an ImageData object. - ppapi::ResourceObjectBase* image_base = - ppapi::TrackerBase::Get()->GetResourceAPI(pp_image_data); - if (!image_base) + EnterResourceNoLock<PPB_ImageData_API> enter(pp_image_data, true); + if (enter.failed()) return PP_FALSE; - PPB_ImageData_API* image_api = image_base->GetAs<PPB_ImageData_API>(); - if (!image_api) - return PP_FALSE; - ImageData* image_data = static_cast<ImageData*>(image_api); + ImageData* image_data = static_cast<ImageData*>(enter.object()); skia::PlatformCanvas* canvas = image_data->mapped_canvas(); bool needs_unmapping = false; diff --git a/ppapi/proxy/ppb_gles_chromium_texture_mapping_proxy.cc b/ppapi/proxy/ppb_gles_chromium_texture_mapping_proxy.cc deleted file mode 100644 index b6e1b51..0000000 --- a/ppapi/proxy/ppb_gles_chromium_texture_mapping_proxy.cc +++ /dev/null @@ -1,80 +0,0 @@ -// 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 "ppapi/proxy/ppb_gles_chromium_texture_mapping_proxy.h" - -#include "gpu/command_buffer/client/gles2_implementation.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/proxy/plugin_resource.h" -#include "ppapi/proxy/ppb_context_3d_proxy.h" - -namespace pp { -namespace proxy { - -namespace { - -void* MapTexSubImage2DCHROMIUM(PP_Resource context_id, - GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLenum access) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->MapTexSubImage2DCHROMIUM( - target, level, xoffset, yoffset, width, height, format, type, access); -} - -void UnmapTexSubImage2DCHROMIUM(PP_Resource context_id, const void* mem) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->UnmapTexSubImage2DCHROMIUM(mem); -} - -const struct PPB_GLESChromiumTextureMapping_Dev gles2_chromium_tm_interface = { - MapTexSubImage2DCHROMIUM, - UnmapTexSubImage2DCHROMIUM -}; - -InterfaceProxy* CreateGLESChromiumTextureMappingProxy( - Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_GLESChromiumTextureMapping_Proxy(dispatcher, target_interface); -} - -} // namespace - -PPB_GLESChromiumTextureMapping_Proxy::PPB_GLESChromiumTextureMapping_Proxy( - Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { -} - -PPB_GLESChromiumTextureMapping_Proxy::~PPB_GLESChromiumTextureMapping_Proxy() { -} - -// static -const InterfaceProxy::Info* PPB_GLESChromiumTextureMapping_Proxy::GetInfo() { - static const Info info = { - &gles2_chromium_tm_interface, - PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE, - INTERFACE_ID_PPB_GLES_CHROMIUM_TM, - false, - &CreateGLESChromiumTextureMappingProxy, - }; - return &info; -} - -bool PPB_GLESChromiumTextureMapping_Proxy::OnMessageReceived( - const IPC::Message& msg) { - return false; -} - -} // namespace proxy -} // namespace pp diff --git a/ppapi/proxy/ppb_gles_chromium_texture_mapping_proxy.h b/ppapi/proxy/ppb_gles_chromium_texture_mapping_proxy.h deleted file mode 100644 index cff6c1e..0000000 --- a/ppapi/proxy/ppb_gles_chromium_texture_mapping_proxy.h +++ /dev/null @@ -1,36 +0,0 @@ -// 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 PPAPI_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_PROXY_H_ -#define PPAPI_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_PROXY_H_ - -#include "ppapi/proxy/interface_proxy.h" - -struct PPB_GLESChromiumTextureMapping_Dev; - -namespace pp { -namespace proxy { - -class PPB_GLESChromiumTextureMapping_Proxy : public InterfaceProxy { - public: - PPB_GLESChromiumTextureMapping_Proxy(Dispatcher* dispatcher, - const void* target_interface); - virtual ~PPB_GLESChromiumTextureMapping_Proxy(); - - static const Info* GetInfo(); - - const PPB_GLESChromiumTextureMapping_Dev* - ppb_gles_chromium_tm_target() const { - return reinterpret_cast<const PPB_GLESChromiumTextureMapping_Dev*>( - target_interface()); - } - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); -}; - -} // namespace proxy -} // namespace pp - -#endif // PPAPI_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_PROXY_H_ diff --git a/ppapi/proxy/ppb_opengles2_proxy.cc b/ppapi/proxy/ppb_opengles2_proxy.cc index 4de1730..ce301c6 100644 --- a/ppapi/proxy/ppb_opengles2_proxy.cc +++ b/ppapi/proxy/ppb_opengles2_proxy.cc @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This file is auto-generated. DO NOT EDIT! +// This file is auto-generated from +// gpu/command_buffer/build_gles2_cmd_buffer.py +// DO NOT EDIT! #include "ppapi/proxy/ppb_opengles2_proxy.h" @@ -13,857 +15,747 @@ #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/plugin_resource.h" #include "ppapi/proxy/ppb_context_3d_proxy.h" +#include "ppapi/shared_impl/resource_object_base.h" +#include "ppapi/shared_impl/tracker_base.h" namespace pp { namespace proxy { namespace { +gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) { + ppapi::ResourceObjectBase* base = + ppapi::TrackerBase::Get()->GetResourceAPI(context); + DCHECK(base->AsPPB_Context3D_API()); + return static_cast<Context3D*>(base)->gles2_impl(); +} + void ActiveTexture(PP_Resource context_id, GLenum texture) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->ActiveTexture(texture); + GetGLES(context_id)->ActiveTexture(texture); } void AttachShader(PP_Resource context_id, GLuint program, GLuint shader) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->AttachShader(program, shader); + GetGLES(context_id)->AttachShader(program, shader); } void BindAttribLocation( PP_Resource context_id, GLuint program, GLuint index, const char* name) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->BindAttribLocation(program, index, name); + GetGLES(context_id)->BindAttribLocation(program, index, name); } void BindBuffer(PP_Resource context_id, GLenum target, GLuint buffer) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->BindBuffer(target, buffer); + GetGLES(context_id)->BindBuffer(target, buffer); } void BindFramebuffer( PP_Resource context_id, GLenum target, GLuint framebuffer) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->BindFramebuffer(target, framebuffer); + GetGLES(context_id)->BindFramebuffer(target, framebuffer); } void BindRenderbuffer( PP_Resource context_id, GLenum target, GLuint renderbuffer) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->BindRenderbuffer(target, renderbuffer); + GetGLES(context_id)->BindRenderbuffer(target, renderbuffer); } void BindTexture(PP_Resource context_id, GLenum target, GLuint texture) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->BindTexture(target, texture); + GetGLES(context_id)->BindTexture(target, texture); } void BlendColor( PP_Resource context_id, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->BlendColor(red, green, blue, alpha); + GetGLES(context_id)->BlendColor(red, green, blue, alpha); } void BlendEquation(PP_Resource context_id, GLenum mode) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->BlendEquation(mode); + GetGLES(context_id)->BlendEquation(mode); } void BlendEquationSeparate( PP_Resource context_id, GLenum modeRGB, GLenum modeAlpha) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->BlendEquationSeparate(modeRGB, modeAlpha); + GetGLES(context_id)->BlendEquationSeparate(modeRGB, modeAlpha); } void BlendFunc(PP_Resource context_id, GLenum sfactor, GLenum dfactor) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->BlendFunc(sfactor, dfactor); + GetGLES(context_id)->BlendFunc(sfactor, dfactor); } void BlendFuncSeparate( PP_Resource context_id, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); + GetGLES(context_id)->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); } void BufferData( PP_Resource context_id, GLenum target, GLsizeiptr size, const void* data, GLenum usage) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->BufferData(target, size, data, usage); + GetGLES(context_id)->BufferData(target, size, data, usage); } void BufferSubData( PP_Resource context_id, GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->BufferSubData(target, offset, size, data); + GetGLES(context_id)->BufferSubData(target, offset, size, data); } GLenum CheckFramebufferStatus(PP_Resource context_id, GLenum target) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->CheckFramebufferStatus(target); + return GetGLES(context_id)->CheckFramebufferStatus(target); } void Clear(PP_Resource context_id, GLbitfield mask) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Clear(mask); + GetGLES(context_id)->Clear(mask); } void ClearColor( PP_Resource context_id, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->ClearColor(red, green, blue, alpha); + GetGLES(context_id)->ClearColor(red, green, blue, alpha); } void ClearDepthf(PP_Resource context_id, GLclampf depth) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->ClearDepthf(depth); + GetGLES(context_id)->ClearDepthf(depth); } void ClearStencil(PP_Resource context_id, GLint s) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->ClearStencil(s); + GetGLES(context_id)->ClearStencil(s); } void ColorMask( PP_Resource context_id, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->ColorMask(red, green, blue, alpha); + GetGLES(context_id)->ColorMask(red, green, blue, alpha); } void CompileShader(PP_Resource context_id, GLuint shader) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->CompileShader(shader); + GetGLES(context_id)->CompileShader(shader); } void CompressedTexImage2D( PP_Resource context_id, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->CompressedTexImage2D( - target, level, internalformat, width, height, border, imageSize, data); + GetGLES( + context_id)->CompressedTexImage2D( + target, level, internalformat, width, height, border, imageSize, + data); } void CompressedTexSubImage2D( PP_Resource context_id, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->CompressedTexSubImage2D( - target, level, xoffset, yoffset, width, height, format, imageSize, data); + GetGLES( + context_id)->CompressedTexSubImage2D( + target, level, xoffset, yoffset, width, height, format, imageSize, + data); } void CopyTexImage2D( PP_Resource context_id, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->CopyTexImage2D( - target, level, internalformat, x, y, width, height, border); + GetGLES( + context_id)->CopyTexImage2D( + target, level, internalformat, x, y, width, height, border); } void CopyTexSubImage2D( PP_Resource context_id, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->CopyTexSubImage2D( - target, level, xoffset, yoffset, x, y, width, height); + GetGLES( + context_id)->CopyTexSubImage2D( + target, level, xoffset, yoffset, x, y, width, height); } GLuint CreateProgram(PP_Resource context_id) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->CreateProgram(); + return GetGLES(context_id)->CreateProgram(); } GLuint CreateShader(PP_Resource context_id, GLenum type) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->CreateShader(type); + return GetGLES(context_id)->CreateShader(type); } void CullFace(PP_Resource context_id, GLenum mode) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->CullFace(mode); + GetGLES(context_id)->CullFace(mode); } void DeleteBuffers(PP_Resource context_id, GLsizei n, const GLuint* buffers) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DeleteBuffers(n, buffers); + GetGLES(context_id)->DeleteBuffers(n, buffers); } void DeleteFramebuffers( PP_Resource context_id, GLsizei n, const GLuint* framebuffers) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DeleteFramebuffers(n, framebuffers); + GetGLES(context_id)->DeleteFramebuffers(n, framebuffers); } void DeleteProgram(PP_Resource context_id, GLuint program) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DeleteProgram(program); + GetGLES(context_id)->DeleteProgram(program); } void DeleteRenderbuffers( PP_Resource context_id, GLsizei n, const GLuint* renderbuffers) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DeleteRenderbuffers(n, renderbuffers); + GetGLES(context_id)->DeleteRenderbuffers(n, renderbuffers); } void DeleteShader(PP_Resource context_id, GLuint shader) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DeleteShader(shader); + GetGLES(context_id)->DeleteShader(shader); } void DeleteTextures( PP_Resource context_id, GLsizei n, const GLuint* textures) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DeleteTextures(n, textures); + GetGLES(context_id)->DeleteTextures(n, textures); } void DepthFunc(PP_Resource context_id, GLenum func) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DepthFunc(func); + GetGLES(context_id)->DepthFunc(func); } void DepthMask(PP_Resource context_id, GLboolean flag) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DepthMask(flag); + GetGLES(context_id)->DepthMask(flag); } void DepthRangef(PP_Resource context_id, GLclampf zNear, GLclampf zFar) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DepthRangef(zNear, zFar); + GetGLES(context_id)->DepthRangef(zNear, zFar); } void DetachShader(PP_Resource context_id, GLuint program, GLuint shader) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DetachShader(program, shader); + GetGLES(context_id)->DetachShader(program, shader); } void Disable(PP_Resource context_id, GLenum cap) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Disable(cap); + GetGLES(context_id)->Disable(cap); } void DisableVertexAttribArray(PP_Resource context_id, GLuint index) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DisableVertexAttribArray(index); + GetGLES(context_id)->DisableVertexAttribArray(index); } void DrawArrays( PP_Resource context_id, GLenum mode, GLint first, GLsizei count) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DrawArrays(mode, first, count); + GetGLES(context_id)->DrawArrays(mode, first, count); } void DrawElements( PP_Resource context_id, GLenum mode, GLsizei count, GLenum type, const void* indices) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->DrawElements(mode, count, type, indices); + GetGLES(context_id)->DrawElements(mode, count, type, indices); } void Enable(PP_Resource context_id, GLenum cap) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Enable(cap); + GetGLES(context_id)->Enable(cap); } void EnableVertexAttribArray(PP_Resource context_id, GLuint index) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->EnableVertexAttribArray(index); + GetGLES(context_id)->EnableVertexAttribArray(index); } void Finish(PP_Resource context_id) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Finish(); + GetGLES(context_id)->Finish(); } void Flush(PP_Resource context_id) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Flush(); + GetGLES(context_id)->Flush(); } void FramebufferRenderbuffer( PP_Resource context_id, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->FramebufferRenderbuffer( - target, attachment, renderbuffertarget, renderbuffer); + GetGLES( + context_id)->FramebufferRenderbuffer( + target, attachment, renderbuffertarget, renderbuffer); } void FramebufferTexture2D( PP_Resource context_id, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->FramebufferTexture2D( - target, attachment, textarget, texture, level); + GetGLES( + context_id)->FramebufferTexture2D( + target, attachment, textarget, texture, level); } void FrontFace(PP_Resource context_id, GLenum mode) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->FrontFace(mode); + GetGLES(context_id)->FrontFace(mode); } void GenBuffers(PP_Resource context_id, GLsizei n, GLuint* buffers) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GenBuffers(n, buffers); + GetGLES(context_id)->GenBuffers(n, buffers); } void GenerateMipmap(PP_Resource context_id, GLenum target) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GenerateMipmap(target); + GetGLES(context_id)->GenerateMipmap(target); } void GenFramebuffers(PP_Resource context_id, GLsizei n, GLuint* framebuffers) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GenFramebuffers(n, framebuffers); + GetGLES(context_id)->GenFramebuffers(n, framebuffers); } void GenRenderbuffers( PP_Resource context_id, GLsizei n, GLuint* renderbuffers) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GenRenderbuffers(n, renderbuffers); + GetGLES(context_id)->GenRenderbuffers(n, renderbuffers); } void GenTextures(PP_Resource context_id, GLsizei n, GLuint* textures) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GenTextures(n, textures); + GetGLES(context_id)->GenTextures(n, textures); } void GetActiveAttrib( PP_Resource context_id, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetActiveAttrib( - program, index, bufsize, length, size, type, name); + GetGLES( + context_id)->GetActiveAttrib( + program, index, bufsize, length, size, type, name); } void GetActiveUniform( PP_Resource context_id, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetActiveUniform( - program, index, bufsize, length, size, type, name); + GetGLES( + context_id)->GetActiveUniform( + program, index, bufsize, length, size, type, name); } void GetAttachedShaders( PP_Resource context_id, GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetAttachedShaders(program, maxcount, count, shaders); + GetGLES(context_id)->GetAttachedShaders(program, maxcount, count, shaders); } GLint GetAttribLocation( PP_Resource context_id, GLuint program, const char* name) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->GetAttribLocation(program, name); + return GetGLES(context_id)->GetAttribLocation(program, name); } void GetBooleanv(PP_Resource context_id, GLenum pname, GLboolean* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetBooleanv(pname, params); + GetGLES(context_id)->GetBooleanv(pname, params); } void GetBufferParameteriv( PP_Resource context_id, GLenum target, GLenum pname, GLint* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetBufferParameteriv(target, pname, params); + GetGLES(context_id)->GetBufferParameteriv(target, pname, params); } GLenum GetError(PP_Resource context_id) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->GetError(); + return GetGLES(context_id)->GetError(); } void GetFloatv(PP_Resource context_id, GLenum pname, GLfloat* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetFloatv(pname, params); + GetGLES(context_id)->GetFloatv(pname, params); } void GetFramebufferAttachmentParameteriv( PP_Resource context_id, GLenum target, GLenum attachment, GLenum pname, GLint* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetFramebufferAttachmentParameteriv( - target, attachment, pname, params); + GetGLES( + context_id)->GetFramebufferAttachmentParameteriv( + target, attachment, pname, params); } void GetIntegerv(PP_Resource context_id, GLenum pname, GLint* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetIntegerv(pname, params); + GetGLES(context_id)->GetIntegerv(pname, params); } void GetProgramiv( PP_Resource context_id, GLuint program, GLenum pname, GLint* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetProgramiv(program, pname, params); + GetGLES(context_id)->GetProgramiv(program, pname, params); } void GetProgramInfoLog( PP_Resource context_id, GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetProgramInfoLog(program, bufsize, length, infolog); + GetGLES(context_id)->GetProgramInfoLog(program, bufsize, length, infolog); } void GetRenderbufferParameteriv( PP_Resource context_id, GLenum target, GLenum pname, GLint* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetRenderbufferParameteriv(target, pname, params); + GetGLES(context_id)->GetRenderbufferParameteriv(target, pname, params); } void GetShaderiv( PP_Resource context_id, GLuint shader, GLenum pname, GLint* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetShaderiv(shader, pname, params); + GetGLES(context_id)->GetShaderiv(shader, pname, params); } void GetShaderInfoLog( PP_Resource context_id, GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetShaderInfoLog(shader, bufsize, length, infolog); + GetGLES(context_id)->GetShaderInfoLog(shader, bufsize, length, infolog); } void GetShaderPrecisionFormat( PP_Resource context_id, GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetShaderPrecisionFormat( - shadertype, precisiontype, range, precision); + GetGLES( + context_id)->GetShaderPrecisionFormat( + shadertype, precisiontype, range, precision); } void GetShaderSource( PP_Resource context_id, GLuint shader, GLsizei bufsize, GLsizei* length, char* source) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetShaderSource(shader, bufsize, length, source); + GetGLES(context_id)->GetShaderSource(shader, bufsize, length, source); } const GLubyte* GetString(PP_Resource context_id, GLenum name) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->GetString(name); + return GetGLES(context_id)->GetString(name); } void GetTexParameterfv( PP_Resource context_id, GLenum target, GLenum pname, GLfloat* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetTexParameterfv(target, pname, params); + GetGLES(context_id)->GetTexParameterfv(target, pname, params); } void GetTexParameteriv( PP_Resource context_id, GLenum target, GLenum pname, GLint* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetTexParameteriv(target, pname, params); + GetGLES(context_id)->GetTexParameteriv(target, pname, params); } void GetUniformfv( PP_Resource context_id, GLuint program, GLint location, GLfloat* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetUniformfv(program, location, params); + GetGLES(context_id)->GetUniformfv(program, location, params); } void GetUniformiv( PP_Resource context_id, GLuint program, GLint location, GLint* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetUniformiv(program, location, params); + GetGLES(context_id)->GetUniformiv(program, location, params); } GLint GetUniformLocation( PP_Resource context_id, GLuint program, const char* name) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->GetUniformLocation(program, name); + return GetGLES(context_id)->GetUniformLocation(program, name); } void GetVertexAttribfv( PP_Resource context_id, GLuint index, GLenum pname, GLfloat* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetVertexAttribfv(index, pname, params); + GetGLES(context_id)->GetVertexAttribfv(index, pname, params); } void GetVertexAttribiv( PP_Resource context_id, GLuint index, GLenum pname, GLint* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetVertexAttribiv(index, pname, params); + GetGLES(context_id)->GetVertexAttribiv(index, pname, params); } void GetVertexAttribPointerv( PP_Resource context_id, GLuint index, GLenum pname, void** pointer) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->GetVertexAttribPointerv(index, pname, pointer); + GetGLES(context_id)->GetVertexAttribPointerv(index, pname, pointer); } void Hint(PP_Resource context_id, GLenum target, GLenum mode) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Hint(target, mode); + GetGLES(context_id)->Hint(target, mode); } GLboolean IsBuffer(PP_Resource context_id, GLuint buffer) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->IsBuffer(buffer); + return GetGLES(context_id)->IsBuffer(buffer); } GLboolean IsEnabled(PP_Resource context_id, GLenum cap) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->IsEnabled(cap); + return GetGLES(context_id)->IsEnabled(cap); } GLboolean IsFramebuffer(PP_Resource context_id, GLuint framebuffer) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->IsFramebuffer(framebuffer); + return GetGLES(context_id)->IsFramebuffer(framebuffer); } GLboolean IsProgram(PP_Resource context_id, GLuint program) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->IsProgram(program); + return GetGLES(context_id)->IsProgram(program); } GLboolean IsRenderbuffer(PP_Resource context_id, GLuint renderbuffer) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->IsRenderbuffer(renderbuffer); + return GetGLES(context_id)->IsRenderbuffer(renderbuffer); } GLboolean IsShader(PP_Resource context_id, GLuint shader) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->IsShader(shader); + return GetGLES(context_id)->IsShader(shader); } GLboolean IsTexture(PP_Resource context_id, GLuint texture) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - return context->gles2_impl()->IsTexture(texture); + return GetGLES(context_id)->IsTexture(texture); } void LineWidth(PP_Resource context_id, GLfloat width) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->LineWidth(width); + GetGLES(context_id)->LineWidth(width); } void LinkProgram(PP_Resource context_id, GLuint program) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->LinkProgram(program); + GetGLES(context_id)->LinkProgram(program); } void PixelStorei(PP_Resource context_id, GLenum pname, GLint param) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->PixelStorei(pname, param); + GetGLES(context_id)->PixelStorei(pname, param); } void PolygonOffset(PP_Resource context_id, GLfloat factor, GLfloat units) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->PolygonOffset(factor, units); + GetGLES(context_id)->PolygonOffset(factor, units); } void ReadPixels( PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->ReadPixels(x, y, width, height, format, type, pixels); + GetGLES(context_id)->ReadPixels(x, y, width, height, format, type, pixels); } void ReleaseShaderCompiler(PP_Resource context_id) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->ReleaseShaderCompiler(); + GetGLES(context_id)->ReleaseShaderCompiler(); } void RenderbufferStorage( PP_Resource context_id, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->RenderbufferStorage( - target, internalformat, width, height); + GetGLES( + context_id)->RenderbufferStorage(target, internalformat, width, height); } void SampleCoverage(PP_Resource context_id, GLclampf value, GLboolean invert) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->SampleCoverage(value, invert); + GetGLES(context_id)->SampleCoverage(value, invert); } void Scissor( PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Scissor(x, y, width, height); + GetGLES(context_id)->Scissor(x, y, width, height); } void ShaderBinary( PP_Resource context_id, GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->ShaderBinary( - n, shaders, binaryformat, binary, length); + GetGLES(context_id)->ShaderBinary(n, shaders, binaryformat, binary, length); } void ShaderSource( PP_Resource context_id, GLuint shader, GLsizei count, const char** str, const GLint* length) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->ShaderSource(shader, count, str, length); + GetGLES(context_id)->ShaderSource(shader, count, str, length); } void StencilFunc(PP_Resource context_id, GLenum func, GLint ref, GLuint mask) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->StencilFunc(func, ref, mask); + GetGLES(context_id)->StencilFunc(func, ref, mask); } void StencilFuncSeparate( PP_Resource context_id, GLenum face, GLenum func, GLint ref, GLuint mask) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->StencilFuncSeparate(face, func, ref, mask); + GetGLES(context_id)->StencilFuncSeparate(face, func, ref, mask); } void StencilMask(PP_Resource context_id, GLuint mask) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->StencilMask(mask); + GetGLES(context_id)->StencilMask(mask); } void StencilMaskSeparate(PP_Resource context_id, GLenum face, GLuint mask) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->StencilMaskSeparate(face, mask); + GetGLES(context_id)->StencilMaskSeparate(face, mask); } void StencilOp( PP_Resource context_id, GLenum fail, GLenum zfail, GLenum zpass) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->StencilOp(fail, zfail, zpass); + GetGLES(context_id)->StencilOp(fail, zfail, zpass); } void StencilOpSeparate( PP_Resource context_id, GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->StencilOpSeparate(face, fail, zfail, zpass); + GetGLES(context_id)->StencilOpSeparate(face, fail, zfail, zpass); } void TexImage2D( PP_Resource context_id, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->TexImage2D( - target, level, internalformat, width, height, border, format, type, - pixels); + GetGLES( + context_id)->TexImage2D( + target, level, internalformat, width, height, border, format, type, + pixels); } void TexParameterf( PP_Resource context_id, GLenum target, GLenum pname, GLfloat param) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->TexParameterf(target, pname, param); + GetGLES(context_id)->TexParameterf(target, pname, param); } void TexParameterfv( PP_Resource context_id, GLenum target, GLenum pname, const GLfloat* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->TexParameterfv(target, pname, params); + GetGLES(context_id)->TexParameterfv(target, pname, params); } void TexParameteri( PP_Resource context_id, GLenum target, GLenum pname, GLint param) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->TexParameteri(target, pname, param); + GetGLES(context_id)->TexParameteri(target, pname, param); } void TexParameteriv( PP_Resource context_id, GLenum target, GLenum pname, const GLint* params) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->TexParameteriv(target, pname, params); + GetGLES(context_id)->TexParameteriv(target, pname, params); } void TexSubImage2D( PP_Resource context_id, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->TexSubImage2D( - target, level, xoffset, yoffset, width, height, format, type, pixels); + GetGLES( + context_id)->TexSubImage2D( + target, level, xoffset, yoffset, width, height, format, type, + pixels); } void Uniform1f(PP_Resource context_id, GLint location, GLfloat x) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform1f(location, x); + GetGLES(context_id)->Uniform1f(location, x); } void Uniform1fv( PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform1fv(location, count, v); + GetGLES(context_id)->Uniform1fv(location, count, v); } void Uniform1i(PP_Resource context_id, GLint location, GLint x) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform1i(location, x); + GetGLES(context_id)->Uniform1i(location, x); } void Uniform1iv( PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform1iv(location, count, v); + GetGLES(context_id)->Uniform1iv(location, count, v); } void Uniform2f(PP_Resource context_id, GLint location, GLfloat x, GLfloat y) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform2f(location, x, y); + GetGLES(context_id)->Uniform2f(location, x, y); } void Uniform2fv( PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform2fv(location, count, v); + GetGLES(context_id)->Uniform2fv(location, count, v); } void Uniform2i(PP_Resource context_id, GLint location, GLint x, GLint y) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform2i(location, x, y); + GetGLES(context_id)->Uniform2i(location, x, y); } void Uniform2iv( PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform2iv(location, count, v); + GetGLES(context_id)->Uniform2iv(location, count, v); } void Uniform3f( PP_Resource context_id, GLint location, GLfloat x, GLfloat y, GLfloat z) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform3f(location, x, y, z); + GetGLES(context_id)->Uniform3f(location, x, y, z); } void Uniform3fv( PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform3fv(location, count, v); + GetGLES(context_id)->Uniform3fv(location, count, v); } void Uniform3i( PP_Resource context_id, GLint location, GLint x, GLint y, GLint z) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform3i(location, x, y, z); + GetGLES(context_id)->Uniform3i(location, x, y, z); } void Uniform3iv( PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform3iv(location, count, v); + GetGLES(context_id)->Uniform3iv(location, count, v); } void Uniform4f( PP_Resource context_id, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform4f(location, x, y, z, w); + GetGLES(context_id)->Uniform4f(location, x, y, z, w); } void Uniform4fv( PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform4fv(location, count, v); + GetGLES(context_id)->Uniform4fv(location, count, v); } void Uniform4i( PP_Resource context_id, GLint location, GLint x, GLint y, GLint z, GLint w) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform4i(location, x, y, z, w); + GetGLES(context_id)->Uniform4i(location, x, y, z, w); } void Uniform4iv( PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Uniform4iv(location, count, v); + GetGLES(context_id)->Uniform4iv(location, count, v); } void UniformMatrix2fv( PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->UniformMatrix2fv(location, count, transpose, value); + GetGLES(context_id)->UniformMatrix2fv(location, count, transpose, value); } void UniformMatrix3fv( PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->UniformMatrix3fv(location, count, transpose, value); + GetGLES(context_id)->UniformMatrix3fv(location, count, transpose, value); } void UniformMatrix4fv( PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->UniformMatrix4fv(location, count, transpose, value); + GetGLES(context_id)->UniformMatrix4fv(location, count, transpose, value); } void UseProgram(PP_Resource context_id, GLuint program) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->UseProgram(program); + GetGLES(context_id)->UseProgram(program); } void ValidateProgram(PP_Resource context_id, GLuint program) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->ValidateProgram(program); + GetGLES(context_id)->ValidateProgram(program); } void VertexAttrib1f(PP_Resource context_id, GLuint indx, GLfloat x) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->VertexAttrib1f(indx, x); + GetGLES(context_id)->VertexAttrib1f(indx, x); } void VertexAttrib1fv( PP_Resource context_id, GLuint indx, const GLfloat* values) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->VertexAttrib1fv(indx, values); + GetGLES(context_id)->VertexAttrib1fv(indx, values); } void VertexAttrib2f( PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->VertexAttrib2f(indx, x, y); + GetGLES(context_id)->VertexAttrib2f(indx, x, y); } void VertexAttrib2fv( PP_Resource context_id, GLuint indx, const GLfloat* values) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->VertexAttrib2fv(indx, values); + GetGLES(context_id)->VertexAttrib2fv(indx, values); } void VertexAttrib3f( PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y, GLfloat z) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->VertexAttrib3f(indx, x, y, z); + GetGLES(context_id)->VertexAttrib3f(indx, x, y, z); } void VertexAttrib3fv( PP_Resource context_id, GLuint indx, const GLfloat* values) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->VertexAttrib3fv(indx, values); + GetGLES(context_id)->VertexAttrib3fv(indx, values); } void VertexAttrib4f( PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->VertexAttrib4f(indx, x, y, z, w); + GetGLES(context_id)->VertexAttrib4f(indx, x, y, z, w); } void VertexAttrib4fv( PP_Resource context_id, GLuint indx, const GLfloat* values) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->VertexAttrib4fv(indx, values); + GetGLES(context_id)->VertexAttrib4fv(indx, values); } void VertexAttribPointer( PP_Resource context_id, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->VertexAttribPointer( - indx, size, type, normalized, stride, ptr); + GetGLES( + context_id)->VertexAttribPointer( + indx, size, type, normalized, stride, ptr); } void Viewport( PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height) { - Context3D* context = PluginResource::GetAs<Context3D>(context_id); - context->gles2_impl()->Viewport(x, y, width, height); + GetGLES(context_id)->Viewport(x, y, width, height); +} + +void SetLatchCHROMIUM(PP_Resource context_id, GLuint latch_id) { + GetGLES(context_id)->SetLatchCHROMIUM(latch_id); +} + +void WaitLatchCHROMIUM(PP_Resource context_id, GLuint latch_id) { + GetGLES(context_id)->WaitLatchCHROMIUM(latch_id); } const struct PPB_OpenGLES2_Dev opengles2_interface = { diff --git a/ppapi/proxy/ppb_surface_3d_proxy.cc b/ppapi/proxy/ppb_surface_3d_proxy.cc index 79854f9..b515a22 100644 --- a/ppapi/proxy/ppb_surface_3d_proxy.cc +++ b/ppapi/proxy/ppb_surface_3d_proxy.cc @@ -8,117 +8,87 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/dev/ppb_surface_3d_dev.h" +#include "ppapi/proxy/enter_proxy.h" #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/plugin_resource.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/ppb_context_3d_proxy.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/resource_creation_api.h" +#include "ppapi/thunk/thunk.h" + +using ppapi::thunk::EnterFunctionNoLock; +using ppapi::thunk::PPB_Surface3D_API; +using ppapi::thunk::ResourceCreationAPI; namespace pp { namespace proxy { -Surface3D::~Surface3D() { - if (context_) - context_->BindSurfaces(NULL, NULL); -} - namespace { -PP_Resource Create(PP_Instance instance, - PP_Config3D_Dev config, - const int32_t* attrib_list) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_ERROR_BADARGUMENT; +InterfaceProxy* CreateSurface3DProxy(Dispatcher* dispatcher, + const void* target_interface) { + return new PPB_Surface3D_Proxy(dispatcher, target_interface); +} - std::vector<int32_t> attribs; - if (attrib_list) { - const int32_t* attr = attrib_list; - while(*attr != PP_GRAPHICS3DATTRIB_NONE) { - attribs.push_back(*(attr++)); // Attribute. - attribs.push_back(*(attr++)); // Value. - } - } - attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); // Always terminate. +} // namespace - HostResource result; - dispatcher->Send(new PpapiHostMsg_PPBSurface3D_Create( - INTERFACE_ID_PPB_SURFACE_3D, instance, config, attribs, &result)); +// Surface3D ------------------------------------------------------------------- - if (result.is_null()) - return 0; - linked_ptr<Surface3D> surface_3d(new Surface3D(result)); - PP_Resource resource = - PluginResourceTracker::GetInstance()->AddResource(surface_3d); - surface_3d->set_resource(resource); - return resource; +Surface3D::Surface3D(const HostResource& host_resource) + : PluginResource(host_resource), + resource_(0), + context_(NULL), + current_flush_callback_(PP_BlockUntilComplete()) { +} + +Surface3D::~Surface3D() { + if (context_) + context_->BindSurfaces(NULL, NULL); } -PP_Bool IsSurface3D(PP_Resource resource) { - Surface3D* object = PluginResource::GetAs<Surface3D>(resource); - return BoolToPPBool(!!object); +PPB_Surface3D_API* Surface3D::AsPPB_Surface3D_API() { + return this; } -int32_t SetAttrib(PP_Resource surface_id, - int32_t attribute, - int32_t value) { +int32_t Surface3D::SetAttrib(int32_t attribute, int32_t value) { // TODO(alokp): Implement me. return 0; } -int32_t GetAttrib(PP_Resource surface_id, - int32_t attribute, - int32_t* value) { +int32_t Surface3D::GetAttrib(int32_t attribute, int32_t* value) { // TODO(alokp): Implement me. return 0; } -int32_t SwapBuffers(PP_Resource surface_id, - PP_CompletionCallback callback) { - Surface3D* object = PluginResource::GetAs<Surface3D>(surface_id); - if (!object) - return PP_ERROR_BADRESOURCE; - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( - object->instance()); - if (!dispatcher) - return PP_ERROR_FAILED; - +int32_t Surface3D::SwapBuffers(PP_CompletionCallback callback) { // For now, disallow blocking calls. We'll need to add support for other // threads to this later. if (!callback.func) return PP_ERROR_BADARGUMENT; - if (object->is_flush_pending()) + if (is_flush_pending()) return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. - if (!object->context()) + if (!context_) return PP_ERROR_FAILED; - object->set_current_flush_callback(callback); + current_flush_callback_ = callback; IPC::Message* msg = new PpapiHostMsg_PPBSurface3D_SwapBuffers( - INTERFACE_ID_PPB_SURFACE_3D, object->host_resource()); + INTERFACE_ID_PPB_SURFACE_3D, host_resource()); msg->set_unblock(true); - dispatcher->Send(msg); - - object->context()->gles2_impl()->SwapBuffers(); + GetDispatcher()->Send(msg); + context_->gles2_impl()->SwapBuffers(); return PP_OK_COMPLETIONPENDING; } -const PPB_Surface3D_Dev surface_3d_interface = { - &Create, - &IsSurface3D, - &SetAttrib, - &GetAttrib, - &SwapBuffers -}; - -InterfaceProxy* CreateSurface3DProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Surface3D_Proxy(dispatcher, target_interface); +void Surface3D::SwapBuffersACK(int32_t pp_error) { + PP_RunAndClearCompletionCallback(¤t_flush_callback_, pp_error); } -} // namespace +// PPB_Surface3D_Proxy --------------------------------------------------------- PPB_Surface3D_Proxy::PPB_Surface3D_Proxy(Dispatcher* dispatcher, const void* target_interface) @@ -132,7 +102,7 @@ PPB_Surface3D_Proxy::~PPB_Surface3D_Proxy() { // static const InterfaceProxy::Info* PPB_Surface3D_Proxy::GetInfo() { static const Info info = { - &surface_3d_interface, + ::ppapi::thunk::GetPPB_Surface3D_Thunk(), PPB_SURFACE_3D_DEV_INTERFACE, INTERFACE_ID_PPB_SURFACE_3D, false, @@ -141,6 +111,38 @@ const InterfaceProxy::Info* PPB_Surface3D_Proxy::GetInfo() { return &info; } +// static +PP_Resource PPB_Surface3D_Proxy::CreateProxyResource( + PP_Instance instance, + PP_Config3D_Dev config, + const int32_t* attrib_list) { + PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); + if (!dispatcher) + return PP_ERROR_BADARGUMENT; + + std::vector<int32_t> attribs; + if (attrib_list) { + const int32_t* attr = attrib_list; + while(*attr != PP_GRAPHICS3DATTRIB_NONE) { + attribs.push_back(*(attr++)); // Attribute. + attribs.push_back(*(attr++)); // Value. + } + } + attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); // Always terminate. + + HostResource result; + dispatcher->Send(new PpapiHostMsg_PPBSurface3D_Create( + INTERFACE_ID_PPB_SURFACE_3D, instance, config, attribs, &result)); + + if (result.is_null()) + return 0; + linked_ptr<Surface3D> surface_3d(new Surface3D(result)); + PP_Resource resource = + PluginResourceTracker::GetInstance()->AddResource(surface_3d); + surface_3d->set_resource(resource); + return resource; +} + bool PPB_Surface3D_Proxy::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PPB_Surface3D_Proxy, msg) @@ -161,18 +163,27 @@ void PPB_Surface3D_Proxy::OnMsgCreate(PP_Instance instance, PP_Config3D_Dev config, const std::vector<int32_t>& attribs, HostResource* result) { - DCHECK(attribs.size() % 2 == 1); - DCHECK(attribs.back() == PP_GRAPHICS3DATTRIB_NONE); - PP_Resource resource = - ppb_surface_3d_target()->Create(instance, config, &attribs.front()); - result->SetHostResource(instance, resource); + if (attribs.empty() || + attribs.size() % 2 != 1 || + attribs.back() != PP_GRAPHICS3DATTRIB_NONE) + return; // Bad message. + + EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); + if (enter.succeeded()) { + result->SetHostResource( + instance, + enter.functions()->CreateSurface3D(instance, config, &attribs.front())); + } } void PPB_Surface3D_Proxy::OnMsgSwapBuffers(const HostResource& surface_3d) { CompletionCallback callback = callback_factory_.NewCallback( &PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin, surface_3d); - int32_t result = ppb_surface_3d_target()->SwapBuffers( - surface_3d.host_resource(), callback.pp_completion_callback()); + + EnterHostFromHostResource<PPB_Surface3D_API> enter(surface_3d); + int32_t result = PP_ERROR_BADRESOURCE; + if (enter.succeeded()) + result = enter.object()->SwapBuffers(callback.pp_completion_callback()); if (result != PP_OK_COMPLETIONPENDING) { // There was some error, so we won't get a flush callback. We need to now // issue the ACK to the plugin hears about the error. This will also clean @@ -183,23 +194,9 @@ void PPB_Surface3D_Proxy::OnMsgSwapBuffers(const HostResource& surface_3d) { void PPB_Surface3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource, int32_t pp_error) { - PP_Resource plugin_resource = - PluginResourceTracker::GetInstance()->PluginResourceForHostResource( - resource); - if (!plugin_resource) - return; - Surface3D* object = PluginResource::GetAs<Surface3D>(plugin_resource); - if (!object) { - // The plugin has released the Surface3D object so don't issue the - // callback. - return; - } - - // Be careful to make the callback NULL again before issuing the callback - // since the plugin might want to flush from within the callback. - PP_CompletionCallback callback = object->current_flush_callback(); - object->set_current_flush_callback(PP_BlockUntilComplete()); - PP_RunCompletionCallback(&callback, pp_error); + EnterPluginFromHostResource<PPB_Surface3D_API> enter(resource); + if (enter.succeeded()) + static_cast<Surface3D*>(enter.object())->SwapBuffersACK(pp_error); } void PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin( diff --git a/ppapi/proxy/ppb_surface_3d_proxy.h b/ppapi/proxy/ppb_surface_3d_proxy.h index 13e9e17..f44ad76 100644 --- a/ppapi/proxy/ppb_surface_3d_proxy.h +++ b/ppapi/proxy/ppb_surface_3d_proxy.h @@ -14,6 +14,7 @@ #include "ppapi/proxy/interface_proxy.h" #include "ppapi/proxy/plugin_resource.h" #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" +#include "ppapi/thunk/ppb_surface_3d_api.h" struct PPB_Surface3D_Dev; @@ -22,18 +23,21 @@ namespace proxy { class Context3D; -class Surface3D : public PluginResource { +class Surface3D : public PluginResource, + public ppapi::thunk::PPB_Surface3D_API { public: - explicit Surface3D(const HostResource& host_resource) - : PluginResource(host_resource), - resource_(0), - context_(NULL), - current_flush_callback_(PP_BlockUntilComplete()) { - } + explicit Surface3D(const HostResource& host_resource); virtual ~Surface3D(); - // Resource overrides. - virtual Surface3D* AsSurface3D() { return this; } + // ResourceObjectBase overrides. + virtual PPB_Surface3D_API* AsPPB_Surface3D_API() OVERRIDE; + + // PPB_Surface3D_API implementation. + virtual int32_t SetAttrib(int32_t attribute, int32_t value) OVERRIDE; + virtual int32_t GetAttrib(int32_t attribute, int32_t* value) OVERRIDE; + virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE; + + void SwapBuffersACK(int32_t pp_error); bool is_flush_pending() const { return !!current_flush_callback_.func; } @@ -41,10 +45,6 @@ class Surface3D : public PluginResource { return current_flush_callback_; } - void set_current_flush_callback(PP_CompletionCallback cb) { - current_flush_callback_ = cb; - } - void set_context(Context3D* context) { context_ = context; } @@ -57,6 +57,7 @@ class Surface3D : public PluginResource { private: PP_Resource resource_; Context3D* context_; + // In the plugin, this is the current callback set for Flushes. When the // callback function pointer is non-NULL, we're waiting for a flush ACK. PP_CompletionCallback current_flush_callback_; @@ -71,9 +72,9 @@ class PPB_Surface3D_Proxy : public InterfaceProxy { static const Info* GetInfo(); - const PPB_Surface3D_Dev* ppb_surface_3d_target() const { - return reinterpret_cast<const PPB_Surface3D_Dev*>(target_interface()); - } + static PP_Resource CreateProxyResource(PP_Instance instance, + PP_Config3D_Dev config, + const int32_t* attrib_list); // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 1e4bb8d..353aeba 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -16,6 +16,7 @@ #include "ppapi/proxy/ppb_audio_proxy.h" #include "ppapi/proxy/ppb_buffer_proxy.h" #include "ppapi/proxy/ppb_broker_proxy.h" +#include "ppapi/proxy/ppb_context_3d_proxy.h" #include "ppapi/proxy/ppb_file_chooser_proxy.h" #include "ppapi/proxy/ppb_file_ref_proxy.h" #include "ppapi/proxy/ppb_file_system_proxy.h" @@ -24,6 +25,7 @@ #include "ppapi/proxy/ppb_font_proxy.h" #include "ppapi/proxy/ppb_graphics_2d_proxy.h" #include "ppapi/proxy/ppb_image_data_proxy.h" +#include "ppapi/proxy/ppb_surface_3d_proxy.h" #include "ppapi/proxy/ppb_url_loader_proxy.h" #include "ppapi/proxy/ppb_url_request_info_proxy.h" #include "ppapi/shared_impl/font_impl.h" @@ -78,9 +80,28 @@ PP_Resource ResourceCreationProxy::CreateBuffer(PP_Instance instance, return PPB_Buffer_Proxy::CreateProxyResource(instance, size); } +PP_Resource ResourceCreationProxy::CreateContext3D( + PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { + return PPB_Context3D_Proxy::Create(instance, config, share_context, + attrib_list); +} + +PP_Resource ResourceCreationProxy::CreateContext3DRaw( + PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { + // Not proxied. The raw creation function is used only in the implementation + // of the proxy on the host side. + return 0; +} + PP_Resource ResourceCreationProxy::CreateDirectoryReader( PP_Resource directory_ref) { - // Not proxied yet. + NOTIMPLEMENTED(); // Not proxied yet. return 0; } @@ -91,7 +112,7 @@ PP_Resource ResourceCreationProxy::CreateFileChooser( } PP_Resource ResourceCreationProxy::CreateFileIO(PP_Instance instance) { - // Not proxied yet. + NOTIMPLEMENTED(); // Not proxied yet. return 0; } @@ -161,11 +182,27 @@ PP_Resource ResourceCreationProxy::CreateImageData(PP_Instance instance, return PluginResourceTracker::GetInstance()->AddResource(object); } +PP_Resource ResourceCreationProxy::CreateGraphics3D( + PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { + NOTIMPLEMENTED(); // Not proxied yet. + return 0; +} + PP_Resource ResourceCreationProxy::CreateSurface3D( PP_Instance instance, PP_Config3D_Dev config, const int32_t* attrib_list) { - NOTREACHED(); + return PPB_Surface3D_Proxy::CreateProxyResource(instance, config, + attrib_list); +} + +PP_Resource ResourceCreationProxy::CreateTransport(PP_Instance instance, + const char* name, + const char* proto) { + NOTIMPLEMENTED(); // Not proxied yet. return 0; } diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index 921e6ff..04ebc5d 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -43,6 +43,14 @@ class ResourceCreationProxy : public ::ppapi::FunctionGroupBase, virtual PP_Resource CreateBroker(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateBuffer(PP_Instance instance, uint32_t size) OVERRIDE; + virtual PP_Resource CreateContext3D(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) OVERRIDE; + virtual PP_Resource CreateContext3DRaw(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) OVERRIDE; virtual PP_Resource CreateDirectoryReader(PP_Resource directory_ref) OVERRIDE; virtual PP_Resource CreateFileChooser( PP_Instance instance, @@ -61,6 +69,10 @@ class ResourceCreationProxy : public ::ppapi::FunctionGroupBase, virtual PP_Resource CreateGraphics2D(PP_Instance pp_instance, const PP_Size& size, PP_Bool is_always_opaque) OVERRIDE; + virtual PP_Resource CreateGraphics3D(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) OVERRIDE; virtual PP_Resource CreateImageData(PP_Instance instance, PP_ImageDataFormat format, const PP_Size& size, @@ -68,6 +80,9 @@ class ResourceCreationProxy : public ::ppapi::FunctionGroupBase, virtual PP_Resource CreateSurface3D(PP_Instance instance, PP_Config3D_Dev config, const int32_t* attrib_list) OVERRIDE; + virtual PP_Resource CreateTransport(PP_Instance instance, + const char* name, + const char* proto) OVERRIDE; virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateURLRequestInfo(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateVideoDecoder(PP_Instance instance) OVERRIDE; diff --git a/ppapi/shared_impl/resource_object_base.h b/ppapi/shared_impl/resource_object_base.h index 0a405bd..d61e55b 100644 --- a/ppapi/shared_impl/resource_object_base.h +++ b/ppapi/shared_impl/resource_object_base.h @@ -14,6 +14,7 @@ F(PPB_Broker_API) \ F(PPB_Buffer_API) \ F(PPB_BufferTrusted_API) \ + F(PPB_Context3D_API) \ F(PPB_DirectoryReader_API) \ F(PPB_FileChooser_API) \ F(PPB_FileIO_API) \ @@ -24,10 +25,13 @@ F(PPB_Flash_NetConnector_API) \ F(PPB_Font_API) \ F(PPB_Graphics2D_API) \ + F(PPB_Graphics3D_API) \ F(PPB_ImageData_API) \ + F(PPB_LayerCompositor_API) \ F(PPB_PDFFont_API) \ F(PPB_Scrollbar_API) \ F(PPB_Surface3D_API) \ + F(PPB_Transport_API) \ F(PPB_URLLoader_API) \ F(PPB_URLRequestInfo_API) \ F(PPB_URLResponseInfo_API) \ diff --git a/ppapi/thunk/ppb_context_3d_api.h b/ppapi/thunk/ppb_context_3d_api.h new file mode 100644 index 0000000..959a832 --- /dev/null +++ b/ppapi/thunk/ppb_context_3d_api.h @@ -0,0 +1,53 @@ +// 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 PPAPI_THUNK_PPB_CONTEXT_3D_API_H_ +#define PPAPI_THUNK_PPB_CONTEXT_3D_API_H_ + +#include "ppapi/c/dev/ppb_context_3d_dev.h" +#include "ppapi/c/dev/ppb_context_3d_trusted_dev.h" +#include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" + +namespace ppapi { +namespace thunk { + +class PPB_Context3D_API { + public: + // Context3D. + virtual int32_t GetAttrib(int32_t attribute, int32_t* value) = 0; + virtual int32_t BindSurfaces(PP_Resource draw, PP_Resource read) = 0; + virtual int32_t GetBoundSurfaces(PP_Resource* draw, PP_Resource* read) = 0; + + // Context3DTrusted. + virtual PP_Bool InitializeTrusted(int32_t size) = 0; + virtual PP_Bool GetRingBuffer(int* shm_handle, + uint32_t* shm_size) = 0; + virtual PP_Context3DTrustedState GetState() = 0; + virtual PP_Bool Flush(int32_t put_offset) = 0; + virtual PP_Context3DTrustedState FlushSync(int32_t put_offset) = 0; + virtual int32_t CreateTransferBuffer(uint32_t size) = 0; + virtual PP_Bool DestroyTransferBuffer(int32_t id) = 0; + virtual PP_Bool GetTransferBuffer(int32_t id, + int* shm_handle, + uint32_t* shm_size) = 0; + virtual PP_Context3DTrustedState FlushSyncFast(int32_t put_offset, + int32_t last_known_get) = 0; + + // GLESChromiumTextureMapping. + virtual void* MapTexSubImage2DCHROMIUM(GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + GLenum access) = 0; + virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_CONTEXT_3D_API_H_ diff --git a/ppapi/thunk/ppb_context_3d_thunk.cc b/ppapi/thunk/ppb_context_3d_thunk.cc new file mode 100644 index 0000000..cbb035a --- /dev/null +++ b/ppapi/thunk/ppb_context_3d_thunk.cc @@ -0,0 +1,72 @@ +// 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 "ppapi/c/pp_errors.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_context_3d_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +typedef EnterResource<PPB_Context3D_API> EnterContext3D; + +PP_Resource Create(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { + EnterFunction<ResourceCreationAPI> enter(instance, true); + if (enter.failed()) + return 0; + return enter.functions()->CreateContext3D(instance, config, share_context, + attrib_list); +} + +PP_Bool IsContext3D(PP_Resource resource) { + EnterContext3D enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +int32_t GetAttrib(PP_Resource context, int32_t attribute, int32_t* value) { + EnterContext3D enter(context, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->GetAttrib(attribute, value); +} + +int32_t BindSurfaces(PP_Resource context, PP_Resource draw, PP_Resource read) { + EnterContext3D enter(context, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->BindSurfaces(draw, read); +} + +int32_t GetBoundSurfaces(PP_Resource context, + PP_Resource* draw, + PP_Resource* read) { + EnterContext3D enter(context, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->GetBoundSurfaces(draw, read); +} + +const PPB_Context3D_Dev g_ppb_context_3d_thunk = { + &Create, + &IsContext3D, + &GetAttrib, + &BindSurfaces, + &GetBoundSurfaces +}; + +} // namespace + +const PPB_Context3D_Dev* GetPPB_Context3D_Thunk() { + return &g_ppb_context_3d_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_context_3d_trusted_thunk.cc b/ppapi/thunk/ppb_context_3d_trusted_thunk.cc new file mode 100644 index 0000000..312898a --- /dev/null +++ b/ppapi/thunk/ppb_context_3d_trusted_thunk.cc @@ -0,0 +1,124 @@ +// 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 "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_context_3d_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +typedef EnterResource<PPB_Context3D_API> EnterContext3D; + +PP_Context3DTrustedState GetErrorState() { + PP_Context3DTrustedState error_state = { 0 }; + error_state.error = kGenericError; + return error_state; +} + +PP_Resource CreateRaw(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { + EnterFunction<ResourceCreationAPI> enter(instance, true); + if (enter.failed()) + return 0; + return enter.functions()->CreateContext3DRaw(instance, config, share_context, + attrib_list); +} + +PP_Bool Initialize(PP_Resource context, int32_t size) { + EnterContext3D enter(context, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->InitializeTrusted(size); +} + +PP_Bool GetRingBuffer(PP_Resource context, + int* shm_handle, + uint32_t* shm_size) { + EnterContext3D enter(context, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->GetRingBuffer(shm_handle, shm_size); +} + +PP_Context3DTrustedState GetState(PP_Resource context) { + EnterContext3D enter(context, true); + if (enter.failed()) + return GetErrorState(); + return enter.object()->GetState(); +} + +PP_Bool Flush(PP_Resource context, int32_t put_offset) { + EnterContext3D enter(context, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->Flush(put_offset); +} + +PP_Context3DTrustedState FlushSync(PP_Resource context, int32_t put_offset) { + EnterContext3D enter(context, true); + if (enter.failed()) + return GetErrorState(); + return enter.object()->FlushSync(put_offset); +} + +int32_t CreateTransferBuffer(PP_Resource context, uint32_t size) { + EnterContext3D enter(context, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->CreateTransferBuffer(size); +} + +PP_Bool DestroyTransferBuffer(PP_Resource context, int32_t id) { + EnterContext3D enter(context, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->DestroyTransferBuffer(id); +} + +PP_Bool GetTransferBuffer(PP_Resource context, + int32_t id, + int* shm_handle, + uint32_t* shm_size) { + EnterContext3D enter(context, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->GetTransferBuffer(id, shm_handle, shm_size); +} + +PP_Context3DTrustedState FlushSyncFast(PP_Resource context, + int32_t put_offset, + int32_t last_known_get) { + EnterContext3D enter(context, true); + if (enter.failed()) + return GetErrorState(); + return enter.object()->FlushSyncFast(put_offset, last_known_get); +} + +const PPB_Context3DTrusted_Dev g_ppb_context_3d_trusted_thunk = { + &CreateRaw, + &Initialize, + &GetRingBuffer, + &GetState, + &Flush, + &FlushSync, + &CreateTransferBuffer, + &DestroyTransferBuffer, + &GetTransferBuffer, + &FlushSyncFast, +}; + +} // namespace + +const PPB_Context3DTrusted_Dev* GetPPB_Context3DTrusted_Thunk() { + return &g_ppb_context_3d_trusted_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_gles_chromium_texture_mapping_thunk.cc b/ppapi/thunk/ppb_gles_chromium_texture_mapping_thunk.cc new file mode 100644 index 0000000..295190a --- /dev/null +++ b/ppapi/thunk/ppb_gles_chromium_texture_mapping_thunk.cc @@ -0,0 +1,54 @@ +// 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 "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_context_3d_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +typedef EnterResource<PPB_Context3D_API> EnterContext3D; + +void* MapTexSubImage2DCHROMIUM(PP_Resource context, + GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + GLenum access) { + EnterContext3D enter(context, true); + if (enter.failed()) + return NULL; + return enter.object()->MapTexSubImage2DCHROMIUM( + target, level, xoffset, yoffset, width, height, format, type, access); +} + +void UnmapTexSubImage2DCHROMIUM(PP_Resource context, const void* mem) { + EnterContext3D enter(context, true); + if (enter.succeeded()) + enter.object()->UnmapTexSubImage2DCHROMIUM(mem); +} + +const PPB_GLESChromiumTextureMapping_Dev +g_ppb_gles_chromium_texture_mapping_thunk = { + &MapTexSubImage2DCHROMIUM, + &UnmapTexSubImage2DCHROMIUM +}; + +} // namespace + +const PPB_GLESChromiumTextureMapping_Dev* +GetPPB_GLESChromiumTextureMapping_Thunk() { + return &g_ppb_gles_chromium_texture_mapping_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_graphics_3d_api.h b/ppapi/thunk/ppb_graphics_3d_api.h new file mode 100644 index 0000000..122e35c --- /dev/null +++ b/ppapi/thunk/ppb_graphics_3d_api.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 PPAPI_THUNK_PPB_GRAPHICS_3D_API_H_ +#define PPAPI_THUNK_PPB_GRAPHICS_3D_API_H_ + +#include "ppapi/c/dev/ppb_graphics_3d_dev.h" + +namespace ppapi { +namespace thunk { + +class PPB_Graphics3D_API { + public: + virtual int32_t GetAttribs(int32_t* attrib_list) = 0; + virtual int32_t SetAttribs(int32_t* attrib_list) = 0; + virtual int32_t SwapBuffers(PP_CompletionCallback callback) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_GRAPHICS_3D_API_H_ diff --git a/ppapi/thunk/ppb_graphics_3d_thunk.cc b/ppapi/thunk/ppb_graphics_3d_thunk.cc new file mode 100644 index 0000000..edac937 --- /dev/null +++ b/ppapi/thunk/ppb_graphics_3d_thunk.cc @@ -0,0 +1,91 @@ +// 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 "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_graphics_3d_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +typedef EnterResource<PPB_Graphics3D_API> EnterGraphics3D; + +int32_t GetConfigs(PP_Config3D_Dev* configs, + int32_t config_size, + int32_t* num_config) { + // TODO(alokp): Implement me. + return PP_ERROR_FAILED; +} + +int32_t GetConfigAttribs(PP_Config3D_Dev config, int32_t* attrib_list) { + // TODO(alokp): Implement me. + return PP_ERROR_FAILED; +} + +PP_Var GetString(int32_t name) { + // TODO(alokp): Implement me. + return PP_MakeUndefined(); +} + +PP_Resource Create(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { + EnterFunction<ResourceCreationAPI> enter(instance, true); + if (enter.failed()) + return 0; + return enter.functions()->CreateGraphics3D(instance, config, share_context, + attrib_list); +} + +PP_Bool IsGraphics3D(PP_Resource resource) { + EnterGraphics3D enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +int32_t GetAttribs(PP_Resource graphics_3d, int32_t* attrib_list) { + EnterGraphics3D enter(graphics_3d, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->GetAttribs(attrib_list); +} + +int32_t SetAttribs(PP_Resource graphics_3d, int32_t* attrib_list) { + EnterGraphics3D enter(graphics_3d, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->SetAttribs(attrib_list); +} + +int32_t SwapBuffers(PP_Resource graphics_3d, PP_CompletionCallback callback) { + EnterGraphics3D enter(graphics_3d, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->SwapBuffers(callback); +} + +const PPB_Graphics3D_Dev g_ppb_graphics_3d_thunk = { + &GetConfigs, + &GetConfigAttribs, + &GetString, + &Create, + &IsGraphics3D, + &GetAttribs, + &SetAttribs, + &SwapBuffers +}; + +} // namespace + +const PPB_Graphics3D_Dev* GetPPB_Graphics3D_Thunk() { + return &g_ppb_graphics_3d_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_layer_compositor_api.h b/ppapi/thunk/ppb_layer_compositor_api.h new file mode 100644 index 0000000..649699d --- /dev/null +++ b/ppapi/thunk/ppb_layer_compositor_api.h @@ -0,0 +1,27 @@ +// 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 PPAPI_THUNK_PPB_LAYER_COMPOSITOR_API_H_ +#define PPAPI_THUNK_PPB_LAYER_COMPOSITOR_API_H_ + +#include "ppapi/c/dev/ppb_layer_compositor_dev.h" + +namespace ppapi { +namespace thunk { + +class PPB_LayerCompositor_API { + public: + virtual PP_Bool AddLayer(PP_Resource layer) = 0; + virtual void RemoveLayer(PP_Resource layer) = 0; + virtual void SetZIndex(PP_Resource layer, int32_t index) = 0; + virtual void SetRect(PP_Resource layer, const PP_Rect* rect) = 0; + virtual void SetDisplay(PP_Resource layer, PP_Bool is_displayed) = 0; + virtual void MarkAsDirty(PP_Resource layer) = 0; + virtual int32_t SwapBuffers(PP_CompletionCallback callback) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_LAYER_COMPOSITOR_API_H_ diff --git a/ppapi/thunk/ppb_layer_compositor_thunk.cc b/ppapi/thunk/ppb_layer_compositor_thunk.cc new file mode 100644 index 0000000..3e5cbef --- /dev/null +++ b/ppapi/thunk/ppb_layer_compositor_thunk.cc @@ -0,0 +1,70 @@ +// 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 "ppapi/c/pp_errors.h" +#include "ppapi/c/dev/ppb_layer_compositor_dev.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_layer_compositor_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + return 0; +} + +PP_Bool IsLayerCompositor(PP_Resource resource) { + return PP_FALSE; +} + +PP_Bool AddLayer(PP_Resource compositor, PP_Resource layer) { + return PP_FALSE; +} + +void RemoveLayer(PP_Resource compositor, PP_Resource layer) { +} + +void SetZIndex(PP_Resource compositor, PP_Resource layer, int32_t index) { +} + +void SetRect(PP_Resource compositor, PP_Resource layer, + const struct PP_Rect* rect) { +} + +void SetDisplay(PP_Resource compositor, PP_Resource layer, + PP_Bool is_displayed) { +} + +void MarkAsDirty(PP_Resource compositor, PP_Resource layer) { +} + +int32_t SwapBuffers(PP_Resource compositor, + struct PP_CompletionCallback callback) { + return PP_ERROR_FAILED; +} + +const PPB_LayerCompositor_Dev g_ppb_layer_compositor_thunk = { + &Create, + &IsLayerCompositor, + &AddLayer, + &RemoveLayer, + &SetZIndex, + &SetRect, + &SetDisplay, + &MarkAsDirty, + &SwapBuffers, +}; + +} // namespace + +const PPB_LayerCompositor_Dev* GetPPB_LayerCompositor_Thunk() { + return &g_ppb_layer_compositor_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_transport_api.h b/ppapi/thunk/ppb_transport_api.h new file mode 100644 index 0000000..0c0b68f --- /dev/null +++ b/ppapi/thunk/ppb_transport_api.h @@ -0,0 +1,30 @@ +// 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 PPAPI_THUNK_PPB_TRANSPORT_API_H_ +#define PPAPI_THUNK_PPB_TRANSPORT_API_H_ + +#include "ppapi/c/dev/ppb_transport_dev.h" + +namespace ppapi { +namespace thunk { + +class PPB_Transport_API { + public: + virtual PP_Bool IsWritable() = 0; + virtual int32_t Connect(PP_CompletionCallback callback) = 0; + virtual int32_t GetNextAddress(PP_Var* address, + PP_CompletionCallback callback) = 0; + virtual int32_t ReceiveRemoteAddress(PP_Var address) = 0; + virtual int32_t Recv(void* data, uint32_t len, + PP_CompletionCallback callback) = 0; + virtual int32_t Send(const void* data, uint32_t len, + PP_CompletionCallback callback) = 0; + virtual int32_t Close() = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_TRANSPORT_API_H_ diff --git a/ppapi/thunk/ppb_transport_thunk.cc b/ppapi/thunk/ppb_transport_thunk.cc new file mode 100644 index 0000000..50ad4aa --- /dev/null +++ b/ppapi/thunk/ppb_transport_thunk.cc @@ -0,0 +1,102 @@ +// 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 "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_transport_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +typedef EnterResource<PPB_Transport_API> EnterTransport; + +PP_Resource Create(PP_Instance instance, const char* name, const char* proto) { + EnterFunction<ResourceCreationAPI> enter(instance, true); + if (enter.failed()) + return 0; + return enter.functions()->CreateTransport(instance, name, proto); +} + +PP_Bool IsTransport(PP_Resource resource) { + EnterTransport enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +PP_Bool IsWritable(PP_Resource transport) { + EnterTransport enter(transport, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->IsWritable(); +} + +int32_t Connect(PP_Resource transport, PP_CompletionCallback callback) { + EnterTransport enter(transport, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->Connect(callback); +} + +int32_t GetNextAddress(PP_Resource transport, PP_Var* address, + PP_CompletionCallback callback) { + EnterTransport enter(transport, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->GetNextAddress(address, callback); +} + +int32_t ReceiveRemoteAddress(PP_Resource transport, PP_Var address) { + EnterTransport enter(transport, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->ReceiveRemoteAddress(address); +} + +int32_t Recv(PP_Resource transport, void* data, uint32_t len, + PP_CompletionCallback callback) { + EnterTransport enter(transport, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->Recv(data, len, callback); +} + +int32_t Send(PP_Resource transport, const void* data, uint32_t len, + PP_CompletionCallback callback) { + EnterTransport enter(transport, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->Send(data, len, callback); +} + +int32_t Close(PP_Resource transport) { + EnterTransport enter(transport, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->Close(); +} + +const PPB_Transport_Dev g_ppb_transport_thunk = { + &Create, + &IsTransport, + &IsWritable, + &Connect, + &GetNextAddress, + &ReceiveRemoteAddress, + &Recv, + &Send, + &Close, +}; + +} // namespace + +const PPB_Transport_Dev* GetPPB_Transport_Thunk() { + return &g_ppb_transport_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index 3556cb3..ed86584 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -44,6 +44,14 @@ class ResourceCreationAPI { uint32_t sample_frame_count) = 0; virtual PP_Resource CreateBroker(PP_Instance instance) = 0; virtual PP_Resource CreateBuffer(PP_Instance instance, uint32_t size) = 0; + virtual PP_Resource CreateContext3D(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) = 0; + virtual PP_Resource CreateContext3DRaw(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) = 0; virtual PP_Resource CreateDirectoryReader(PP_Resource directory_ref) = 0; virtual PP_Resource CreateFileChooser( PP_Instance instance, @@ -63,6 +71,10 @@ class ResourceCreationAPI { virtual PP_Resource CreateGraphics2D(PP_Instance instance, const PP_Size& size, PP_Bool is_always_opaque) = 0; + virtual PP_Resource CreateGraphics3D(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) = 0; virtual PP_Resource CreateImageData(PP_Instance instance, PP_ImageDataFormat format, const PP_Size& size, @@ -70,6 +82,9 @@ class ResourceCreationAPI { virtual PP_Resource CreateSurface3D(PP_Instance instance, PP_Config3D_Dev config, const int32_t* attrib_list) = 0; + virtual PP_Resource CreateTransport(PP_Instance instance, + const char* name, + const char* proto) = 0; virtual PP_Resource CreateURLLoader(PP_Instance instance) = 0; virtual PP_Resource CreateURLRequestInfo(PP_Instance instance) = 0; virtual PP_Resource CreateVideoDecoder(PP_Instance instance) = 0; diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h index c53ef74..d9ad39e 100644 --- a/ppapi/thunk/thunk.h +++ b/ppapi/thunk/thunk.h @@ -12,6 +12,8 @@ struct PPB_BrokerTrusted; struct PPB_Buffer_Dev; struct PPB_BufferTrusted; struct PPB_CharSet_Dev; +struct PPB_Context3D_Dev; +struct PPB_Context3DTrusted_Dev; struct PPB_CursorControl_Dev; struct PPB_DirectoryReader_Dev; struct PPB_FileChooser_Dev; @@ -24,17 +26,23 @@ struct PPB_Flash_Menu; struct PPB_Flash_NetConnector; struct PPB_Font_Dev; struct PPB_Fullscreen_Dev; +struct PPB_GLESChromiumTextureMapping_Dev; struct PPB_Graphics2D; +struct PPB_Graphics3D_Dev; struct PPB_ImageData; struct PPB_ImageDataTrusted; struct PPB_Instance; struct PPB_Instance_Private; +struct PPB_LayerCompositor_Dev; +struct PPB_Surface3D_Dev; +struct PPB_Transport_Dev; struct PPB_URLLoader; struct PPB_URLLoaderTrusted; struct PPB_URLRequestInfo; struct PPB_URLResponseInfo; struct PPB_VideoDecoder_Dev; struct PPB_VideoLayer_Dev; +struct PPB_Widget_Dev; #ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING struct PPB_Instance_0_4; @@ -54,6 +62,8 @@ const PPB_BrokerTrusted* GetPPB_Broker_Thunk(); const PPB_Buffer_Dev* GetPPB_Buffer_Thunk(); const PPB_BufferTrusted* GetPPB_BufferTrusted_Thunk(); const PPB_CharSet_Dev* GetPPB_CharSet_Thunk(); +const PPB_Context3D_Dev* GetPPB_Context3D_Thunk(); +const PPB_Context3DTrusted_Dev* GetPPB_Context3DTrusted_Thunk(); const PPB_CursorControl_Dev* GetPPB_CursorControl_Thunk(); const PPB_DirectoryReader_Dev* GetPPB_DirectoryReader_Thunk(); const PPB_FileChooser_Dev* GetPPB_FileChooser_Thunk(); @@ -66,18 +76,25 @@ const PPB_Flash_Menu* GetPPB_Flash_Menu_Thunk(); const PPB_Flash_NetConnector* GetPPB_Flash_NetConnector_Thunk(); const PPB_Font_Dev* GetPPB_Font_Thunk(); const PPB_Fullscreen_Dev* GetPPB_Fullscreen_Thunk(); +const PPB_GLESChromiumTextureMapping_Dev* + GetPPB_GLESChromiumTextureMapping_Thunk(); const PPB_Graphics2D* GetPPB_Graphics2D_Thunk(); +const PPB_Graphics3D_Dev* GetPPB_Graphics3D_Thunk(); const PPB_ImageData* GetPPB_ImageData_Thunk(); const PPB_ImageDataTrusted* GetPPB_ImageDataTrusted_Thunk(); const PPB_Instance_0_4* GetPPB_Instance_0_4_Thunk(); const PPB_Instance_0_5* GetPPB_Instance_0_5_Thunk(); const PPB_Instance_Private* GetPPB_Instance_Private_Thunk(); +const PPB_LayerCompositor_Dev* GetPPB_LayerCompositor_Thunk(); +const PPB_Surface3D_Dev* GetPPB_Surface3D_Thunk(); +const PPB_Transport_Dev* GetPPB_Transport_Thunk(); const PPB_URLLoader* GetPPB_URLLoader_Thunk(); const PPB_URLLoaderTrusted* GetPPB_URLLoaderTrusted_Thunk(); const PPB_URLRequestInfo* GetPPB_URLRequestInfo_Thunk(); const PPB_URLResponseInfo* GetPPB_URLResponseInfo_Thunk(); const PPB_VideoDecoder_Dev* GetPPB_VideoDecoder_Thunk(); const PPB_VideoLayer_Dev* GetPPB_VideoLayer_Thunk(); +const PPB_Widget_Dev* GetPPB_Widget_Thunk(); } // namespace thunk } // namespace ppapi diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi index 33a9646..8446100 100644 --- a/webkit/glue/webkit_glue.gypi +++ b/webkit/glue/webkit_glue.gypi @@ -264,8 +264,6 @@ '../plugins/ppapi/ppb_flash_net_connector_impl.h', '../plugins/ppapi/ppb_font_impl.cc', '../plugins/ppapi/ppb_font_impl.h', - '../plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.cc', - '../plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h', '../plugins/ppapi/ppb_graphics_2d_impl.cc', '../plugins/ppapi/ppb_graphics_2d_impl.h', '../plugins/ppapi/ppb_graphics_3d_impl.cc', diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc index 8181c96..d9db923 100644 --- a/webkit/plugins/ppapi/plugin_module.cc +++ b/webkit/plugins/ppapi/plugin_module.cc @@ -33,6 +33,7 @@ #include "ppapi/c/dev/ppb_layer_compositor_dev.h" #include "ppapi/c/dev/ppb_opengles_dev.h" #include "ppapi/c/dev/ppb_scrollbar_dev.h" +#include "ppapi/c/dev/ppb_surface_3d_dev.h" #include "ppapi/c/dev/ppb_testing_dev.h" #include "ppapi/c/dev/ppb_transport_dev.h" #include "ppapi/c/dev/ppb_url_util_dev.h" @@ -69,6 +70,7 @@ #include "ppapi/c/trusted/ppb_buffer_trusted.h" #include "ppapi/c/trusted/ppb_image_data_trusted.h" #include "ppapi/c/trusted/ppb_url_loader_trusted.h" +#include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" #include "webkit/plugins/ppapi/callbacks.h" #include "webkit/plugins/ppapi/common.h" @@ -86,25 +88,19 @@ #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" #include "webkit/plugins/ppapi/ppb_image_data_impl.h" #include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h" +#include "webkit/plugins/ppapi/ppb_opengles_impl.h" #include "webkit/plugins/ppapi/ppb_proxy_impl.h" #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h" -#include "webkit/plugins/ppapi/ppb_transport_impl.h" #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" #include "webkit/plugins/ppapi/ppb_url_util_impl.h" #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" #include "webkit/plugins/ppapi/ppb_video_layer_impl.h" -#include "webkit/plugins/ppapi/ppb_widget_impl.h" #include "webkit/plugins/ppapi/resource_tracker.h" #include "webkit/plugins/ppapi/var.h" #include "webkit/plugins/ppapi/webkit_forwarding_impl.h" -#ifdef ENABLE_GPU -#include "webkit/plugins/ppapi/ppb_context_3d_impl.h" -#include "webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h" -#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" -#include "webkit/plugins/ppapi/ppb_opengles_impl.h" -#include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" -#endif // ENABLE_GPU +using ppapi::thunk::EnterResource; +using ppapi::thunk::PPB_Graphics2D_API; namespace webkit { namespace ppapi { @@ -188,11 +184,11 @@ const PPB_Core core_interface = { PP_Bool ReadImageData(PP_Resource device_context_2d, PP_Resource image, const PP_Point* top_left) { - scoped_refptr<PPB_Graphics2D_Impl> context( - Resource::GetAs<PPB_Graphics2D_Impl>(device_context_2d)); - if (!context.get()) + EnterResource<PPB_Graphics2D_API> enter(device_context_2d, true); + if (enter.failed()) return PP_FALSE; - return BoolToPPBool(context->ReadImageData(image, top_left)); + return BoolToPPBool(static_cast<PPB_Graphics2D_Impl*>(enter.object())-> + ReadImageData(image, top_left)); } void RunMessageLoop(PP_Instance instance) { @@ -329,7 +325,7 @@ const void* GetInterface(const char* name) { if (strcmp(name, PPB_VIDEOLAYER_DEV_INTERFACE) == 0) return ::ppapi::thunk::GetPPB_VideoLayer_Thunk(); if (strcmp(name, PPB_WIDGET_DEV_INTERFACE) == 0) - return PPB_Widget_Impl::GetInterface(); + return ::ppapi::thunk::GetPPB_Widget_Thunk(); if (strcmp(name, PPB_ZOOM_DEV_INTERFACE) == 0) return PluginInstance::GetZoomInterface(); @@ -337,19 +333,19 @@ const void* GetInterface(const char* name) { // This should really refer to switches::kDisable3DAPIs. if (!CommandLine::ForCurrentProcess()->HasSwitch("disable-3d-apis")) { if (strcmp(name, PPB_GRAPHICS_3D_DEV_INTERFACE) == 0) - return PPB_Graphics3D_Impl::GetInterface(); + return ::ppapi::thunk::GetPPB_Graphics3D_Thunk(); if (strcmp(name, PPB_CONTEXT_3D_DEV_INTERFACE) == 0) - return PPB_Context3D_Impl::GetInterface(); + return ::ppapi::thunk::GetPPB_Context3D_Thunk(); if (strcmp(name, PPB_CONTEXT_3D_TRUSTED_DEV_INTERFACE) == 0) - return PPB_Context3D_Impl::GetTrustedInterface(); + return ::ppapi::thunk::GetPPB_Context3DTrusted_Thunk(); if (strcmp(name, PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE) == 0) - return PPB_GLESChromiumTextureMapping_Impl::GetInterface(); + return ::ppapi::thunk::GetPPB_GLESChromiumTextureMapping_Thunk(); if (strcmp(name, PPB_OPENGLES2_DEV_INTERFACE) == 0) return PPB_OpenGLES_Impl::GetInterface(); if (strcmp(name, PPB_SURFACE_3D_DEV_INTERFACE) == 0) - return PPB_Surface3D_Impl::GetInterface(); + return ::ppapi::thunk::GetPPB_Surface3D_Thunk(); if (strcmp(name, PPB_LAYER_COMPOSITOR_DEV_INTERFACE) == 0) - return PPB_LayerCompositor_Impl::GetInterface(); + return ::ppapi::thunk::GetPPB_LayerCompositor_Thunk(); } #endif // ENABLE_GPU @@ -360,7 +356,7 @@ const void* GetInterface(const char* name) { #if defined(ENABLE_P2P_APIS) if (strcmp(name, PPB_TRANSPORT_DEV_INTERFACE) == 0) - return PPB_Transport_Impl::GetInterface(); + return ::ppapi::thunk::GetPPB_Transport_Thunk(); #endif // Only support the testing interface when the command line switch is diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 9809fdf..65faa07 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -85,10 +85,12 @@ #include "skia/ext/skia_utils_mac.h" #endif -using ::ppapi::thunk::EnterResourceNoLock; -using ::ppapi::thunk::PPB_Buffer_API; -using ::ppapi::thunk::PPB_Graphics2D_API; -using ::ppapi::thunk::PPB_Instance_FunctionAPI; +using ppapi::thunk::EnterResourceNoLock; +using ppapi::thunk::PPB_Buffer_API; +using ppapi::thunk::PPB_Graphics2D_API; +using ppapi::thunk::PPB_ImageData_API; +using ppapi::thunk::PPB_Instance_FunctionAPI; +using ppapi::thunk::PPB_Surface3D_API; using WebKit::WebBindings; using WebKit::WebCanvas; using WebKit::WebCursorInfo; @@ -400,10 +402,11 @@ bool PluginInstance::SetCursor(PP_CursorType_Dev type, if (!hot_spot) return false; - scoped_refptr<PPB_ImageData_Impl> image_data( - Resource::GetAs<PPB_ImageData_Impl>(custom_image)); - if (!image_data.get()) + EnterResourceNoLock<PPB_ImageData_API> enter(custom_image, true); + if (enter.failed()) return false; + PPB_ImageData_Impl* image_data = + static_cast<PPB_ImageData_Impl*>(enter.object()); if (image_data->format() != PPB_ImageData_Impl::GetNativeImageDataFormat()) { // TODO(yzshen): Handle the case that the image format is different from the @@ -1136,9 +1139,17 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output, bool PluginInstance::PrintRasterOutput(PP_Resource print_output, WebKit::WebCanvas* canvas) { - scoped_refptr<PPB_ImageData_Impl> image( - Resource::GetAs<PPB_ImageData_Impl>(print_output)); - if (!image.get() || !image->is_mapped()) + EnterResourceNoLock<PPB_ImageData_API> enter(print_output, true); + if (enter.failed()) + return false; + PPB_ImageData_Impl* image = + static_cast<PPB_ImageData_Impl*>(enter.object()); + + // TODO(brettw) this should not require the image to be mapped. It should + // instead map on demand. The DCHECK here is to remind you if you see the + // assert fire, fix the bug rather than mapping the data. + DCHECK(image->is_mapped()); + if (!image->is_mapped()) return false; const SkBitmap* bitmap = image->GetMappedBitmap(); @@ -1278,14 +1289,18 @@ PPB_Graphics2D_Impl* PluginInstance::bound_graphics_2d() const { if (bound_graphics_.get() == NULL) return NULL; - return bound_graphics_->Cast<PPB_Graphics2D_Impl>(); + if (bound_graphics_->AsPPB_Graphics2D_API()) + return static_cast<PPB_Graphics2D_Impl*>(bound_graphics_.get()); + return NULL; } PPB_Surface3D_Impl* PluginInstance::bound_graphics_3d() const { if (bound_graphics_.get() == NULL) return NULL; - return bound_graphics_->Cast<PPB_Surface3D_Impl>(); + if (bound_graphics_->AsPPB_Surface3D_API()) + return static_cast<PPB_Surface3D_Impl*>(bound_graphics_.get()); + return NULL; } void PluginInstance::setBackingTextureId(unsigned int id) { @@ -1372,9 +1387,9 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance, EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ? static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL; - // Surface3D not converted to API yet. - scoped_refptr<PPB_Surface3D_Impl> graphics_3d = - Resource::GetAs<PPB_Surface3D_Impl>(device); + EnterResourceNoLock<PPB_Surface3D_API> enter_3d(device, false); + PPB_Surface3D_Impl* graphics_3d = enter_3d.succeeded() ? + static_cast<PPB_Surface3D_Impl*>(enter_3d.object()) : NULL; if (graphics_2d) { // Refuse to bind if we're transitioning to fullscreen. diff --git a/webkit/plugins/ppapi/ppb_broker_impl.cc b/webkit/plugins/ppapi/ppb_broker_impl.cc index 7d2aec0..4646faf 100644 --- a/webkit/plugins/ppapi/ppb_broker_impl.cc +++ b/webkit/plugins/ppapi/ppb_broker_impl.cc @@ -57,10 +57,6 @@ PP_Resource PPB_Broker_Impl::Create(PP_Instance instance_id) { return broker->GetReference(); } -PPB_Broker_Impl* PPB_Broker_Impl::AsPPB_Broker_Impl() { - return this; -} - PPB_Broker_API* PPB_Broker_Impl::AsPPB_Broker_API() { return this; } diff --git a/webkit/plugins/ppapi/ppb_broker_impl.h b/webkit/plugins/ppapi/ppb_broker_impl.h index 9ae920e..d3c6295 100644 --- a/webkit/plugins/ppapi/ppb_broker_impl.h +++ b/webkit/plugins/ppapi/ppb_broker_impl.h @@ -28,9 +28,6 @@ class PPB_Broker_Impl : public Resource, static PP_Resource Create(PP_Instance instance_id); - // Resource override. - virtual PPB_Broker_Impl* AsPPB_Broker_Impl() OVERRIDE; - // ResourceObjectBase override. virtual ::ppapi::thunk::PPB_Broker_API* AsPPB_Broker_API() OVERRIDE; diff --git a/webkit/plugins/ppapi/ppb_context_3d_impl.cc b/webkit/plugins/ppapi/ppb_context_3d_impl.cc index 250f6b1..e680217 100644 --- a/webkit/plugins/ppapi/ppb_context_3d_impl.cc +++ b/webkit/plugins/ppapi/ppb_context_3d_impl.cc @@ -10,10 +10,15 @@ #include "gpu/command_buffer/client/gles2_implementation.h" #include "gpu/command_buffer/common/command_buffer.h" #include "ppapi/c/dev/ppb_context_3d_trusted_dev.h" +#include "ppapi/thunk/enter.h" #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" +using ppapi::thunk::EnterResourceNoLock; +using ppapi::thunk::PPB_Context3D_API; +using ppapi::thunk::PPB_Surface3D_API; + namespace webkit { namespace ppapi { @@ -23,21 +28,27 @@ namespace { const int32 kCommandBufferSize = 1024 * 1024; const int32 kTransferBufferSize = 1024 * 1024; -bool ShmToHandle(base::SharedMemory* shm, - size_t size, - int* shm_handle, - uint32_t* shm_size) { +PP_Bool ShmToHandle(base::SharedMemory* shm, + size_t size, + int* shm_handle, + uint32_t* shm_size) { if (!shm || !shm_handle || !shm_size) - return false; + return PP_FALSE; #if defined(OS_POSIX) - *shm_handle = shm->handle().fd; + *shm_handle = shm->handle().fd; #elif defined(OS_WIN) - *shm_handle = reinterpret_cast<int>(shm->handle()); + *shm_handle = reinterpret_cast<int>(shm->handle()); #else - #error "Platform not supported." + #error "Platform not supported." #endif - *shm_size = size; - return true; + *shm_size = size; + return PP_TRUE; +} + +PP_Context3DTrustedState GetErrorState() { + PP_Context3DTrustedState error_state = { 0 }; + error_state.error = kGenericError; + return error_state; } PP_Context3DTrustedState PPStateFromGPUState( @@ -53,16 +64,32 @@ PP_Context3DTrustedState PPStateFromGPUState( return state; } -PP_Resource Create(PP_Instance instance_id, - PP_Config3D_Dev config, - PP_Resource share_context, - const int32_t* attrib_list) { +} // namespace + +PPB_Context3D_Impl::PPB_Context3D_Impl(PluginInstance* instance) + : Resource(instance), + instance_(instance), + transfer_buffer_id_(0), + draw_surface_(NULL), + read_surface_(NULL), + callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { +} + +PPB_Context3D_Impl::~PPB_Context3D_Impl() { + Destroy(); +} + +// static +PP_Resource PPB_Context3D_Impl::Create(PP_Instance pp_instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { // TODO(alokp): Support shared context. DCHECK_EQ(0, share_context); if (share_context != 0) return 0; - PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); + PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); if (!instance) return 0; @@ -74,63 +101,17 @@ PP_Resource Create(PP_Instance instance_id, return context->GetReference(); } -PP_Bool IsContext3D(PP_Resource resource) { - return BoolToPPBool(!!Resource::GetAs<PPB_Context3D_Impl>(resource)); -} - -int32_t GetAttrib(PP_Resource context, - int32_t attribute, - int32_t* value) { - // TODO(alokp): Implement me. - return 0; -} - -int32_t BindSurfaces(PP_Resource context_id, - PP_Resource draw, - PP_Resource read) { - scoped_refptr<PPB_Context3D_Impl> context( - Resource::GetAs<PPB_Context3D_Impl>(context_id)); - if (!context.get()) - return PP_ERROR_BADRESOURCE; - - scoped_refptr<PPB_Surface3D_Impl> draw_surface( - Resource::GetAs<PPB_Surface3D_Impl>(draw)); - if (!draw_surface.get()) - return PP_ERROR_BADRESOURCE; - - scoped_refptr<PPB_Surface3D_Impl> read_surface( - Resource::GetAs<PPB_Surface3D_Impl>(read)); - if (!read_surface.get()) - return PP_ERROR_BADRESOURCE; - - return context->BindSurfaces(draw_surface.get(), read_surface.get()); -} - -int32_t GetBoundSurfaces(PP_Resource context, - PP_Resource* draw, - PP_Resource* read) { - // TODO(alokp): Implement me. - return 0; -} - -const PPB_Context3D_Dev ppb_context3d = { - &Create, - &IsContext3D, - &GetAttrib, - &BindSurfaces, - &GetBoundSurfaces, -}; - -PP_Resource CreateRaw(PP_Instance instance_id, - PP_Config3D_Dev config, - PP_Resource share_context, - const int32_t* attrib_list) { +// static +PP_Resource PPB_Context3D_Impl::CreateRaw(PP_Instance pp_instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { // TODO(alokp): Support shared context. DCHECK_EQ(0, share_context); if (share_context != 0) return 0; - PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); + PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); if (!instance) return 0; @@ -142,142 +123,157 @@ PP_Resource CreateRaw(PP_Instance instance_id, return context->GetReference(); } -PP_Bool Initialize(PP_Resource context_id, int32_t size) { - scoped_refptr<PPB_Context3D_Impl> context( - Resource::GetAs<PPB_Context3D_Impl>(context_id)); - if (!context.get() || !context->command_buffer()) - return PP_FALSE; - return context->command_buffer()->Initialize(size) ? PP_TRUE : PP_FALSE; +PPB_Context3D_API* PPB_Context3D_Impl::AsPPB_Context3D_API() { + return this; } -PP_Bool GetRingBuffer(PP_Resource context_id, - int* shm_handle, - uint32_t* shm_size) { - scoped_refptr<PPB_Context3D_Impl> context( - Resource::GetAs<PPB_Context3D_Impl>(context_id)); - if (!context.get() || !context->command_buffer()) - return PP_FALSE; +int32_t PPB_Context3D_Impl::GetAttrib(int32_t attribute, int32_t* value) { + // TODO(alokp): Implement me. + return 0; +} + +int32_t PPB_Context3D_Impl::BindSurfaces(PP_Resource draw, PP_Resource read) { + EnterResourceNoLock<PPB_Surface3D_API> enter_draw(draw, true); + if (enter_draw.failed()) + return PP_ERROR_BADRESOURCE; + PPB_Surface3D_Impl* new_draw = + static_cast<PPB_Surface3D_Impl*>(enter_draw.object()); + + EnterResourceNoLock<PPB_Surface3D_API> enter_read(read, true); + if (enter_read.failed()) + return PP_ERROR_BADRESOURCE; + PPB_Surface3D_Impl* new_read = + static_cast<PPB_Surface3D_Impl*>(enter_read.object()); - gpu::Buffer buffer = context->command_buffer()->GetRingBuffer(); + // TODO(alokp): Support separate draw-read surfaces. + DCHECK_EQ(new_draw, new_read); + if (new_draw != new_read) + return PP_GRAPHICS3DERROR_BAD_MATCH; + + if (new_draw == draw_surface_) + return PP_OK; - return ShmToHandle(buffer.shared_memory, buffer.size, shm_handle, shm_size) - ? PP_TRUE : PP_FALSE; + if (new_draw->context()) + return PP_GRAPHICS3DERROR_BAD_ACCESS; // Already bound. + + if (draw_surface_) + draw_surface_->BindToContext(NULL); + if (!new_draw->BindToContext(this)) + return PP_ERROR_NOMEMORY; + + draw_surface_ = new_draw; + read_surface_ = new_read; + return PP_OK; } -PP_Context3DTrustedState GetState(PP_Resource context_id) { - scoped_refptr<PPB_Context3D_Impl> context( - Resource::GetAs<PPB_Context3D_Impl>(context_id)); - if (!context.get() || !context->command_buffer()) { - PP_Context3DTrustedState error_state = { 0 }; - return error_state; - } +int32_t PPB_Context3D_Impl::GetBoundSurfaces(PP_Resource* draw, + PP_Resource* read) { + // TODO(alokp): Implement me. + return 0; +} - return PPStateFromGPUState(context->command_buffer()->GetState()); +PP_Bool PPB_Context3D_Impl::InitializeTrusted(int32_t size) { + if (!platform_context_.get()) + return PP_FALSE; + return PP_FromBool(platform_context_->GetCommandBuffer()->Initialize(size)); } -PP_Bool Flush(PP_Resource context_id, int32_t put_offset) { - scoped_refptr<PPB_Context3D_Impl> context( - Resource::GetAs<PPB_Context3D_Impl>(context_id)); - if (!context.get() || !context->command_buffer()) +PP_Bool PPB_Context3D_Impl::GetRingBuffer(int* shm_handle, + uint32_t* shm_size) { + if (!platform_context_.get()) return PP_FALSE; + gpu::Buffer buffer = platform_context_->GetCommandBuffer()->GetRingBuffer(); + return ShmToHandle(buffer.shared_memory, buffer.size, shm_handle, shm_size); +} - context->command_buffer()->Flush(put_offset); - return PP_TRUE; +PP_Context3DTrustedState PPB_Context3D_Impl::GetState() { + if (!platform_context_.get()) + return GetErrorState(); + return PPStateFromGPUState(platform_context_->GetCommandBuffer()->GetState()); } -PP_Context3DTrustedState FlushSync(PP_Resource context_id, int32_t put_offset) { - scoped_refptr<PPB_Context3D_Impl> context( - Resource::GetAs<PPB_Context3D_Impl>(context_id)); - if (!context.get() || !context->command_buffer()) { - PP_Context3DTrustedState error_state = { 0 }; - return error_state; - } +PP_Bool PPB_Context3D_Impl::Flush(int32_t put_offset) { + if (!platform_context_.get()) + return PP_FALSE; + platform_context_->GetCommandBuffer()->Flush(put_offset); + return PP_TRUE; +} - gpu::CommandBuffer::State state = context->command_buffer()->GetState(); +PP_Context3DTrustedState PPB_Context3D_Impl::FlushSync(int32_t put_offset) { + if (!platform_context_.get()) + return GetErrorState(); + gpu::CommandBuffer::State state = + platform_context_->GetCommandBuffer()->GetState(); return PPStateFromGPUState( - context->command_buffer()->FlushSync(put_offset, state.get_offset)); + platform_context_->GetCommandBuffer()->FlushSync(put_offset, + state.get_offset)); } -int32_t CreateTransferBuffer(PP_Resource context_id, uint32_t size) { - scoped_refptr<PPB_Context3D_Impl> context( - Resource::GetAs<PPB_Context3D_Impl>(context_id)); - if (!context.get() || !context->command_buffer()) +int32_t PPB_Context3D_Impl::CreateTransferBuffer(uint32_t size) { + if (!platform_context_.get()) return 0; - return context->command_buffer()->CreateTransferBuffer(size, -1); + return platform_context_->GetCommandBuffer()->CreateTransferBuffer(size, -1); } -PP_Bool DestroyTransferBuffer(PP_Resource context_id, int32_t id) { - scoped_refptr<PPB_Context3D_Impl> context( - Resource::GetAs<PPB_Context3D_Impl>(context_id)); - if (!context.get() || !context->command_buffer()) +PP_Bool PPB_Context3D_Impl::DestroyTransferBuffer(int32_t id) { + if (!platform_context_.get()) return PP_FALSE; - context->command_buffer()->DestroyTransferBuffer(id); + platform_context_->GetCommandBuffer()->DestroyTransferBuffer(id); return PP_TRUE; } -PP_Bool GetTransferBuffer(PP_Resource context_id, - int32_t id, - int* shm_handle, - uint32_t* shm_size) { - scoped_refptr<PPB_Context3D_Impl> context( - Resource::GetAs<PPB_Context3D_Impl>(context_id)); - if (!context.get() || !context->command_buffer()) +PP_Bool PPB_Context3D_Impl::GetTransferBuffer(int32_t id, + int* shm_handle, + uint32_t* shm_size) { + if (!platform_context_.get()) return PP_FALSE; - gpu::Buffer buffer = context->command_buffer()->GetTransferBuffer(id); - - return ShmToHandle(buffer.shared_memory, buffer.size, shm_handle, shm_size) - ? PP_TRUE : PP_FALSE; + gpu::Buffer buffer = + platform_context_->GetCommandBuffer()->GetTransferBuffer(id); + return ShmToHandle(buffer.shared_memory, buffer.size, shm_handle, shm_size); } -PP_Context3DTrustedState FlushSyncFast( - PP_Resource context_id, int32_t put_offset, int32 last_known_get) { - scoped_refptr<PPB_Context3D_Impl> context( - Resource::GetAs<PPB_Context3D_Impl>(context_id)); - if (!context.get() || !context->command_buffer()) { - PP_Context3DTrustedState error_state = { 0 }; - return error_state; - } - +PP_Context3DTrustedState PPB_Context3D_Impl::FlushSyncFast( + int32_t put_offset, + int32_t last_known_get) { + if (!platform_context_.get()) + return GetErrorState(); return PPStateFromGPUState( - context->command_buffer()->FlushSync(put_offset, last_known_get)); + platform_context_->GetCommandBuffer()->FlushSync(put_offset, + last_known_get)); } -} // namespace -PPB_Context3D_Impl::PPB_Context3D_Impl(PluginInstance* instance) - : Resource(instance), - instance_(instance), - transfer_buffer_id_(0), - draw_surface_(NULL), - read_surface_(NULL), - callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { +void* PPB_Context3D_Impl::MapTexSubImage2DCHROMIUM(GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + GLenum access) { + if (!gles2_impl_.get()) + return NULL; + return gles2_impl_->MapTexSubImage2DCHROMIUM( + target, level, xoffset, yoffset, width, height, format, type, access); } -PPB_Context3D_Impl::~PPB_Context3D_Impl() { - Destroy(); +void PPB_Context3D_Impl::UnmapTexSubImage2DCHROMIUM(const void* mem) { + if (gles2_impl_.get()) + gles2_impl_->UnmapTexSubImage2DCHROMIUM(mem); } -const PPB_Context3D_Dev* PPB_Context3D_Impl::GetInterface() { - return &ppb_context3d; -} +bool PPB_Context3D_Impl::Init(PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { + if (!InitRaw(config, share_context, attrib_list)) + return false; -const PPB_Context3DTrusted_Dev* PPB_Context3D_Impl::GetTrustedInterface() { - static const PPB_Context3DTrusted_Dev iface = { - &CreateRaw, - &Initialize, - &GetRingBuffer, - &GetState, - &Flush, - &FlushSync, - &CreateTransferBuffer, - &DestroyTransferBuffer, - &GetTransferBuffer, - &FlushSyncFast, - }; - return &iface; -} + if (!CreateImplementation()) { + Destroy(); + return false; + } -PPB_Context3D_Impl* PPB_Context3D_Impl::AsPPB_Context3D_Impl() { - return this; + return true; } bool PPB_Context3D_Impl::InitRaw(PP_Config3D_Dev config, @@ -298,20 +294,6 @@ bool PPB_Context3D_Impl::InitRaw(PP_Config3D_Dev config, return true; } -bool PPB_Context3D_Impl::Init(PP_Config3D_Dev config, - PP_Resource share_context, - const int32_t* attrib_list) { - if (!InitRaw(config, share_context, attrib_list)) - return false; - - if (!CreateImplementation()) { - Destroy(); - return false; - } - - return true; -} - bool PPB_Context3D_Impl::CreateImplementation() { gpu::CommandBuffer* command_buffer = platform_context_->GetCommandBuffer(); DCHECK(command_buffer); @@ -348,37 +330,15 @@ bool PPB_Context3D_Impl::CreateImplementation() { return true; } -int32_t PPB_Context3D_Impl::BindSurfaces(PPB_Surface3D_Impl* draw, - PPB_Surface3D_Impl* read) { - // TODO(alokp): Support separate draw-read surfaces. - DCHECK_EQ(draw, read); - if (draw != read) - return PP_GRAPHICS3DERROR_BAD_MATCH; - - if (draw == draw_surface_) - return PP_OK; - - if (draw && draw->context()) - return PP_GRAPHICS3DERROR_BAD_ACCESS; - - if (draw_surface_) - draw_surface_->BindToContext(NULL); - if (draw && !draw->BindToContext(this)) - return PP_ERROR_NOMEMORY; - - draw_surface_ = draw; - read_surface_ = read; - return PP_OK; -} - void PPB_Context3D_Impl::Destroy() { if (draw_surface_) draw_surface_->BindToContext(NULL); gles2_impl_.reset(); - if (command_buffer() && transfer_buffer_id_ != 0) { - command_buffer()->DestroyTransferBuffer(transfer_buffer_id_); + if (platform_context_.get() && transfer_buffer_id_ != 0) { + platform_context_->GetCommandBuffer()->DestroyTransferBuffer( + transfer_buffer_id_); transfer_buffer_id_ = 0; } @@ -393,9 +353,5 @@ void PPB_Context3D_Impl::OnContextLost() { read_surface_->OnContextLost(); } -gpu::CommandBuffer *PPB_Context3D_Impl::command_buffer() { - return platform_context_.get() ? platform_context_->GetCommandBuffer() : NULL; -} - } // namespace ppapi } // namespace webkit diff --git a/webkit/plugins/ppapi/ppb_context_3d_impl.h b/webkit/plugins/ppapi/ppb_context_3d_impl.h index 2b3e66e..f4660dd 100644 --- a/webkit/plugins/ppapi/ppb_context_3d_impl.h +++ b/webkit/plugins/ppapi/ppb_context_3d_impl.h @@ -7,7 +7,7 @@ #include "base/memory/scoped_callback_factory.h" #include "base/memory/scoped_ptr.h" -#include "ppapi/c/dev/ppb_context_3d_dev.h" +#include "ppapi/thunk/ppb_context_3d_api.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/resource.h" @@ -26,50 +26,81 @@ namespace ppapi { class PPB_Surface3D_Impl; -class PPB_Context3D_Impl : public Resource { +class PPB_Context3D_Impl : public Resource, + public ::ppapi::thunk::PPB_Context3D_API { public: - explicit PPB_Context3D_Impl(PluginInstance* instance); virtual ~PPB_Context3D_Impl(); - static const PPB_Context3D_Dev* GetInterface(); - static const PPB_Context3DTrusted_Dev* GetTrustedInterface(); - - // Resource override. - virtual PPB_Context3D_Impl* AsPPB_Context3D_Impl(); + static PP_Resource Create(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list); + static PP_Resource CreateRaw(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list); + + // ResourceObjectBase override. + virtual ::ppapi::thunk::PPB_Context3D_API* AsPPB_Context3D_API(); + + // PPB_Context3D_API implementation. + virtual int32_t GetAttrib(int32_t attribute, int32_t* value) OVERRIDE; + virtual int32_t BindSurfaces(PP_Resource draw, PP_Resource read) OVERRIDE; + virtual int32_t GetBoundSurfaces(PP_Resource* draw, + PP_Resource* read) OVERRIDE; + virtual PP_Bool InitializeTrusted(int32_t size) OVERRIDE; + virtual PP_Bool GetRingBuffer(int* shm_handle, + uint32_t* shm_size) OVERRIDE; + virtual PP_Context3DTrustedState GetState() OVERRIDE; + virtual PP_Bool Flush(int32_t put_offset) OVERRIDE; + virtual PP_Context3DTrustedState FlushSync(int32_t put_offset) OVERRIDE; + virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE; + virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE; + virtual PP_Bool GetTransferBuffer(int32_t id, + int* shm_handle, + uint32_t* shm_size) OVERRIDE; + virtual PP_Context3DTrustedState FlushSyncFast( + int32_t put_offset, + int32_t last_known_get) OVERRIDE; + virtual void* MapTexSubImage2DCHROMIUM(GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + GLenum access) OVERRIDE; + virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE; - bool Init(PP_Config3D_Dev config, - PP_Resource share_context, - const int32_t* attrib_list); - bool InitRaw(PP_Config3D_Dev config, - PP_Resource share_context, - const int32_t* attrib_list); - - PluginInstance* instance() { - return instance_; + gpu::gles2::GLES2Implementation* gles2_impl() { + return gles2_impl_.get(); } + // Possibly NULL if initialization fails. PluginDelegate::PlatformContext3D* platform_context() { return platform_context_.get(); } - gpu::gles2::GLES2Implementation* gles2_impl() { - return gles2_impl_.get(); - } - - gpu::CommandBuffer* command_buffer(); + private: + explicit PPB_Context3D_Impl(PluginInstance* instance); - int32_t BindSurfaces(PPB_Surface3D_Impl* draw, - PPB_Surface3D_Impl* read); + bool Init(PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list); + bool InitRaw(PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list); - private: - void Destroy(); bool CreateImplementation(); + void Destroy(); void OnContextLost(); // Plugin instance this context is associated with. PluginInstance* instance_; // PluginDelegate's 3D Context. Responsible for providing the command buffer. + // Possibly NULL. scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_; scoped_ptr<gpu::gles2::GLES2CmdHelper> helper_; diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc index cba21d5..cb95b11 100644 --- a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc +++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc @@ -73,11 +73,6 @@ PP_Resource PPB_DirectoryReader_Impl::Create(PP_Resource directory_ref) { return reader->GetReference(); } -PPB_DirectoryReader_Impl* -PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_Impl() { - return this; -} - PPB_DirectoryReader_API* PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_API() { return this; } diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.h b/webkit/plugins/ppapi/ppb_directory_reader_impl.h index 67be4a5..4c58f47 100644 --- a/webkit/plugins/ppapi/ppb_directory_reader_impl.h +++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.h @@ -29,9 +29,6 @@ class PPB_DirectoryReader_Impl static PP_Resource Create(PP_Resource directory_ref); - // Resource overrides. - virtual PPB_DirectoryReader_Impl* AsPPB_DirectoryReader_Impl() OVERRIDE; - // ResourceObjectBase overrides. virtual ::ppapi::thunk::PPB_DirectoryReader_API* AsPPB_DirectoryReader_API() OVERRIDE; diff --git a/webkit/plugins/ppapi/ppb_flash_file_impl.cc b/webkit/plugins/ppapi/ppb_flash_file_impl.cc index d285dff..bce105f 100644 --- a/webkit/plugins/ppapi/ppb_flash_file_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_file_impl.cc @@ -11,6 +11,7 @@ #include "ppapi/c/dev/pp_file_info_dev.h" #include "ppapi/c/dev/ppb_file_io_dev.h" #include "ppapi/c/private/ppb_flash_file.h" +#include "ppapi/thunk/enter.h" #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/file_path.h" #include "webkit/plugins/ppapi/file_type_conversions.h" @@ -24,6 +25,9 @@ #include "base/utf_string_conversions.h" #endif +using ppapi::thunk::EnterResource; +using ppapi::thunk::PPB_FileRef_API; + namespace webkit { namespace ppapi { @@ -214,10 +218,10 @@ int32_t OpenFileRefFile(PP_Resource file_ref_id, if (!PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || !file) return PP_ERROR_BADARGUMENT; - scoped_refptr<PPB_FileRef_Impl> file_ref( - Resource::GetAs<PPB_FileRef_Impl>(file_ref_id)); - if (!file_ref) + EnterResource<PPB_FileRef_API> enter(file_ref_id, true); + if (enter.failed()) return PP_ERROR_BADRESOURCE; + PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(enter.object()); PluginInstance* instance = file_ref->instance(); if (!instance) @@ -234,10 +238,10 @@ int32_t OpenFileRefFile(PP_Resource file_ref_id, int32_t QueryFileRefFile(PP_Resource file_ref_id, PP_FileInfo_Dev* info) { - scoped_refptr<PPB_FileRef_Impl> file_ref( - Resource::GetAs<PPB_FileRef_Impl>(file_ref_id)); - if (!file_ref) + EnterResource<PPB_FileRef_API> enter(file_ref_id, true); + if (enter.failed()) return PP_ERROR_BADRESOURCE; + PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(enter.object()); PluginInstance* instance = file_ref->instance(); if (!instance) diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc index 0898da8..46f9cd91 100644 --- a/webkit/plugins/ppapi/ppb_flash_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_impl.cc @@ -10,6 +10,7 @@ #include "base/time.h" #include "googleurl/src/gurl.h" #include "ppapi/c/private/ppb_flash.h" +#include "ppapi/thunk/enter.h" #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/plugin_module.h" @@ -18,6 +19,9 @@ #include "webkit/plugins/ppapi/resource_tracker.h" #include "webkit/plugins/ppapi/var.h" +using ppapi::thunk::EnterResource; +using ppapi::thunk::PPB_URLRequestInfo_API; + namespace webkit { namespace ppapi { @@ -48,10 +52,11 @@ PP_Var GetProxyForURL(PP_Instance pp_instance, const char* url) { int32_t Navigate(PP_Resource request_id, const char* target, bool from_user_action) { - scoped_refptr<PPB_URLRequestInfo_Impl> request( - Resource::GetAs<PPB_URLRequestInfo_Impl>(request_id)); - if (!request) + EnterResource<PPB_URLRequestInfo_API> enter(request_id, true); + if (enter.failed()) return PP_ERROR_BADRESOURCE; + PPB_URLRequestInfo_Impl* request = + static_cast<PPB_URLRequestInfo_Impl*>(enter.object()); if (!target) return PP_ERROR_BADARGUMENT; diff --git a/webkit/plugins/ppapi/ppb_flash_impl_linux.cc b/webkit/plugins/ppapi/ppb_flash_impl_linux.cc index bd554c7b..c698620 100644 --- a/webkit/plugins/ppapi/ppb_flash_impl_linux.cc +++ b/webkit/plugins/ppapi/ppb_flash_impl_linux.cc @@ -8,6 +8,7 @@ #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/dev/ppb_font_dev.h" +#include "ppapi/thunk/enter.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkMatrix.h" #include "third_party/skia/include/core/SkPaint.h" @@ -17,6 +18,9 @@ #include "webkit/plugins/ppapi/ppb_image_data_impl.h" #include "webkit/plugins/ppapi/var.h" +using ppapi::thunk::EnterResource; +using ppapi::thunk::PPB_ImageData_API; + namespace webkit { namespace ppapi { @@ -30,10 +34,12 @@ PP_Bool PPB_Flash_Impl::DrawGlyphs(PP_Instance, uint32_t glyph_count, const uint16_t glyph_indices[], const PP_Point glyph_advances[]) { - scoped_refptr<PPB_ImageData_Impl> image_resource( - Resource::GetAs<PPB_ImageData_Impl>(pp_image_data)); - if (!image_resource.get()) + EnterResource<PPB_ImageData_API> enter(pp_image_data, true); + if (enter.failed()) return PP_FALSE; + PPB_ImageData_Impl* image_resource = + static_cast<PPB_ImageData_Impl*>(enter.object()); + ImageDataAutoMapper mapper(image_resource); if (!mapper.is_valid()) return PP_FALSE; diff --git a/webkit/plugins/ppapi/ppb_font_impl.cc b/webkit/plugins/ppapi/ppb_font_impl.cc index 0da1b3a..b4c06e5 100644 --- a/webkit/plugins/ppapi/ppb_font_impl.cc +++ b/webkit/plugins/ppapi/ppb_font_impl.cc @@ -6,6 +6,7 @@ #include "ppapi/c/dev/ppb_font_dev.h" #include "ppapi/shared_impl/ppapi_preferences.h" +#include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/plugin_module.h" @@ -14,7 +15,9 @@ #include "webkit/plugins/ppapi/string.h" #include "webkit/plugins/ppapi/var.h" -using ::ppapi::WebKitForwarding; +using ppapi::thunk::EnterResource; +using ppapi::thunk::PPB_ImageData_API; +using ppapi::WebKitForwarding; namespace webkit { namespace ppapi { @@ -56,10 +59,6 @@ PPB_Font_Impl::~PPB_Font_Impl() { return this; } -PPB_Font_Impl* PPB_Font_Impl::AsPPB_Font_Impl() { - return this; -} - PP_Bool PPB_Font_Impl::Describe(PP_FontDescription_Dev* description, PP_FontMetrics_Dev* metrics) { std::string face; @@ -80,10 +79,12 @@ PP_Bool PPB_Font_Impl::DrawTextAt(PP_Resource image_data, const PP_Rect* clip, PP_Bool image_data_is_opaque) { // Get and map the image data we're painting to. - scoped_refptr<PPB_ImageData_Impl> image_resource( - Resource::GetAs<PPB_ImageData_Impl>(image_data)); - if (!image_resource.get()) + EnterResource<PPB_ImageData_API> enter(image_data, true); + if (enter.failed()) return PP_FALSE; + PPB_ImageData_Impl* image_resource = + static_cast<PPB_ImageData_Impl*>(enter.object()); + ImageDataAutoMapper mapper(image_resource); if (!mapper.is_valid()) return PP_FALSE; diff --git a/webkit/plugins/ppapi/ppb_font_impl.h b/webkit/plugins/ppapi/ppb_font_impl.h index 23416ef..4f1ffff 100644 --- a/webkit/plugins/ppapi/ppb_font_impl.h +++ b/webkit/plugins/ppapi/ppb_font_impl.h @@ -30,9 +30,6 @@ class PPB_Font_Impl : public Resource, // ResourceObjectBase. virtual ::ppapi::thunk::PPB_Font_API* AsPPB_Font_API() OVERRIDE; - // Resource overrides. - virtual PPB_Font_Impl* AsPPB_Font_Impl() OVERRIDE; - // PPB_Font implementation. virtual PP_Bool Describe(PP_FontDescription_Dev* description, PP_FontMetrics_Dev* metrics) OVERRIDE; diff --git a/webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.cc b/webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.cc deleted file mode 100644 index c6df8f8..0000000 --- a/webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.cc +++ /dev/null @@ -1,53 +0,0 @@ -// 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/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h" - -#include "gpu/command_buffer/client/gles2_implementation.h" -#include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" -#include "webkit/plugins/ppapi/ppb_context_3d_impl.h" - -namespace webkit { -namespace ppapi { - -namespace { - -void* MapTexSubImage2DCHROMIUM( - PP_Resource context_id, - GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLenum access) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->MapTexSubImage2DCHROMIUM( - target, level, xoffset, yoffset, width, height, format, type, access); -} - -void UnmapTexSubImage2DCHROMIUM(PP_Resource context_id, const void* mem) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->UnmapTexSubImage2DCHROMIUM(mem); -} - -const struct PPB_GLESChromiumTextureMapping_Dev ppb_gles_chromium_extension = { - &MapTexSubImage2DCHROMIUM, - &UnmapTexSubImage2DCHROMIUM -}; - -} // namespace - -const PPB_GLESChromiumTextureMapping_Dev* -PPB_GLESChromiumTextureMapping_Impl::GetInterface() { - return &ppb_gles_chromium_extension; -} - -} // namespace ppapi -} // namespace webkit - diff --git a/webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h b/webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h deleted file mode 100644 index ae592b4..0000000 --- a/webkit/plugins/ppapi/ppb_gles_chromium_texture_mapping_impl.h +++ /dev/null @@ -1,22 +0,0 @@ -// 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_PLUGINS_PPAPI_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_IMPL_H_ -#define WEBKIT_PLUGINS_PPAPI_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_IMPL_H_ - -struct PPB_GLESChromiumTextureMapping_Dev; - -namespace webkit { -namespace ppapi { - -class PPB_GLESChromiumTextureMapping_Impl { - public: - static const PPB_GLESChromiumTextureMapping_Dev* GetInterface(); -}; - -} // namespace ppapi -} // namespace webkit - -#endif // WEBKIT_PLUGINS_PPAPI_PPB_GLES_CHROMIUM_TEXTURE_MAPPING_IMPL_H_ - diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc index ff54442..b8f148a 100644 --- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc +++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc @@ -15,6 +15,7 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/ppb_graphics_2d.h" #include "ppapi/cpp/common.h" +#include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/blit.h" @@ -29,6 +30,9 @@ #include "base/mac/scoped_cftyperef.h" #endif +using ppapi::thunk::EnterResourceNoLock; +using ppapi::thunk::PPB_ImageData_API; + namespace webkit { namespace ppapi { @@ -199,10 +203,11 @@ void PPB_Graphics2D_Impl::PaintImageData(PP_Resource image_data, if (!top_left) return; - scoped_refptr<PPB_ImageData_Impl> image_resource( - Resource::GetAs<PPB_ImageData_Impl>(image_data)); - if (!image_resource) + EnterResourceNoLock<PPB_ImageData_API> enter(image_data, true); + if (enter.failed()) return; + PPB_ImageData_Impl* image_resource = + static_cast<PPB_ImageData_Impl*>(enter.object()); QueuedOperation operation(QueuedOperation::PAINT); operation.paint_image = image_resource; @@ -253,10 +258,12 @@ void PPB_Graphics2D_Impl::Scroll(const PP_Rect* clip_rect, } void PPB_Graphics2D_Impl::ReplaceContents(PP_Resource image_data) { - scoped_refptr<PPB_ImageData_Impl> image_resource( - Resource::GetAs<PPB_ImageData_Impl>(image_data)); - if (!image_resource) + EnterResourceNoLock<PPB_ImageData_API> enter(image_data, true); + if (enter.failed()) return; + PPB_ImageData_Impl* image_resource = + static_cast<PPB_ImageData_Impl*>(enter.object()); + if (!PPB_ImageData_Impl::IsImageDataFormatSupported( image_resource->format())) return; @@ -335,10 +342,11 @@ int32_t PPB_Graphics2D_Impl::Flush(PP_CompletionCallback callback) { bool PPB_Graphics2D_Impl::ReadImageData(PP_Resource image, const PP_Point* top_left) { // Get and validate the image object to paint into. - scoped_refptr<PPB_ImageData_Impl> image_resource( - Resource::GetAs<PPB_ImageData_Impl>(image)); - if (!image_resource) + EnterResourceNoLock<PPB_ImageData_API> enter(image, true); + if (enter.failed()) return false; + PPB_ImageData_Impl* image_resource = + static_cast<PPB_ImageData_Impl*>(enter.object()); if (!PPB_ImageData_Impl::IsImageDataFormatSupported( image_resource->format())) return false; // Must be in the right format. @@ -369,7 +377,7 @@ bool PPB_Graphics2D_Impl::ReadImageData(PP_Resource image, if (image_resource->format() != image_data_->format()) { // Convert the image data if the format does not match. - ConvertImageData(image_data_, src_irect, image_resource.get(), dest_rect); + ConvertImageData(image_data_, src_irect, image_resource, dest_rect); } else { skia::PlatformCanvas* dest_canvas = image_resource->mapped_canvas(); diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc index af98225..486c790 100644 --- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc +++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc @@ -7,96 +7,49 @@ #include "base/logging.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" -#include "webkit/plugins/ppapi/common.h" +#include "webkit/plugins/ppapi/ppapi_plugin_instance.h" +#include "webkit/plugins/ppapi/resource_tracker.h" + +using ppapi::thunk::PPB_Graphics3D_API; namespace webkit { namespace ppapi { -namespace { - -int32_t GetConfigs(PP_Config3D_Dev* configs, - int32_t config_size, - int32_t* num_config) { - // TODO(alokp): Implement me. - return PP_ERROR_FAILED; -} - -int32_t GetConfigAttribs(PP_Config3D_Dev config, int32_t* attrib_list) { - // TODO(alokp): Implement me. - return PP_ERROR_FAILED; +PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PluginInstance* instance) + : Resource(instance) { } -PP_Var GetString(int32_t name) { - // TODO(alokp): Implement me. - return PP_MakeUndefined(); +PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() { } -PP_Resource Create(PP_Instance instance_id, - PP_Config3D_Dev config, - PP_Resource share_context, - const int32_t* attrib_list) { - // TODO(alokp): Support shared context. - DCHECK_EQ(0, share_context); - if (share_context != 0) - return 0; - - PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); - if (!instance) +// static +PP_Resource PPB_Graphics3D_Impl::Create(PluginInstance* instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { + scoped_refptr<PPB_Graphics3D_Impl> t(new PPB_Graphics3D_Impl(instance)); + if (!t->Init(config, share_context, attrib_list)) return 0; - - scoped_refptr<PPB_Graphics3D_Impl> context( - new PPB_Graphics3D_Impl(instance)); - if (!context->Init(config, share_context, attrib_list)) - return 0; - - return context->GetReference(); + return t->GetReference(); } -PP_Bool IsGraphics3D(PP_Resource resource) { - return BoolToPPBool(!!Resource::GetAs<PPB_Graphics3D_Impl>(resource)); +PPB_Graphics3D_API* PPB_Graphics3D_Impl::AsPPB_Graphics3D_API() { + return this; } -int32_t GetAttribs(PP_Resource context, int32_t* attrib_list) { +int32_t PPB_Graphics3D_Impl::GetAttribs(int32_t* attrib_list) { // TODO(alokp): Implement me. - return 0; + return PP_ERROR_FAILED; } -int32_t SetAttribs(PP_Resource context, int32_t* attrib_list) { +int32_t PPB_Graphics3D_Impl::SetAttribs(int32_t* attrib_list) { // TODO(alokp): Implement me. - return 0; + return PP_ERROR_FAILED; } -int32_t SwapBuffers(PP_Resource context, PP_CompletionCallback callback) { +int32_t PPB_Graphics3D_Impl::SwapBuffers(PP_CompletionCallback callback) { // TODO(alokp): Implement me. - return 0; -} - -const PPB_Graphics3D_Dev ppb_graphics3d = { - &GetConfigs, - &GetConfigAttribs, - &GetString, - &Create, - &IsGraphics3D, - &GetAttribs, - &SetAttribs, - &SwapBuffers -}; - -} // namespace - -PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PluginInstance* instance) - : Resource(instance) { -} - -PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() { -} - -const PPB_Graphics3D_Dev* PPB_Graphics3D_Impl::GetInterface() { - return &ppb_graphics3d; -} - -PPB_Graphics3D_Impl* PPB_Graphics3D_Impl::AsPPB_Graphics3D_Impl() { - return this; + return PP_ERROR_FAILED; } bool PPB_Graphics3D_Impl::Init(PP_Config3D_Dev config, diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h index b9dbc14..8b41297 100644 --- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h +++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h @@ -5,27 +5,37 @@ #ifndef WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_ #define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_ -#include "ppapi/c/dev/ppb_graphics_3d_dev.h" +#include "ppapi/thunk/ppb_graphics_3d_api.h" #include "webkit/plugins/ppapi/resource.h" namespace webkit { namespace ppapi { -class PPB_Graphics3D_Impl : public Resource { +class PPB_Graphics3D_Impl : public Resource, + public ::ppapi::thunk::PPB_Graphics3D_API { public: - explicit PPB_Graphics3D_Impl(PluginInstance* instance); virtual ~PPB_Graphics3D_Impl(); - static const PPB_Graphics3D_Dev* GetInterface(); + static PP_Resource Create(PluginInstance* instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list); + + // ResourceObjectBase override. + virtual ::ppapi::thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() OVERRIDE; + + // PPB_Graphics3D_API implementation. + virtual int32_t GetAttribs(int32_t* attrib_list) OVERRIDE; + virtual int32_t SetAttribs(int32_t* attrib_list) OVERRIDE; + virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE; - // Resource override. - virtual PPB_Graphics3D_Impl* AsPPB_Graphics3D_Impl(); + private: + explicit PPB_Graphics3D_Impl(PluginInstance* instance); bool Init(PP_Config3D_Dev config, PP_Resource share_context, const int32_t* attrib_list); - private: DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl); }; diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.cc b/webkit/plugins/ppapi/ppb_image_data_impl.cc index 5f62f0d..4f40d01 100644 --- a/webkit/plugins/ppapi/ppb_image_data_impl.cc +++ b/webkit/plugins/ppapi/ppb_image_data_impl.cc @@ -38,10 +38,6 @@ PPB_ImageData_API* PPB_ImageData_Impl::AsPPB_ImageData_API() { return this; } -PPB_ImageData_Impl* PPB_ImageData_Impl::AsPPB_ImageData_Impl() { - return this; -} - bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format, int width, int height, bool init_to_zero) { diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.h b/webkit/plugins/ppapi/ppb_image_data_impl.h index 9d498a1..436efb0 100644 --- a/webkit/plugins/ppapi/ppb_image_data_impl.h +++ b/webkit/plugins/ppapi/ppb_image_data_impl.h @@ -50,9 +50,6 @@ class PPB_ImageData_Impl : public Resource, virtual ::ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() OVERRIDE; - // Resource overrides. - virtual PPB_ImageData_Impl* AsPPB_ImageData_Impl() OVERRIDE; - // PPB_ImageData_API implementation. virtual PP_Bool Describe(PP_ImageDataDesc* desc) OVERRIDE; virtual void* Map() OVERRIDE; diff --git a/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc b/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc index 93e3032..c8188ce 100644 --- a/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc +++ b/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc @@ -7,59 +7,11 @@ #include "ppapi/c/pp_errors.h" #include "webkit/plugins/ppapi/common.h" +using ppapi::thunk::PPB_LayerCompositor_API; + namespace webkit { namespace ppapi { -namespace { - -PP_Resource Create(PP_Instance instance) { - return 0; -} - -PP_Bool IsLayerCompositor(PP_Resource resource) { - return PP_FALSE; -} - -PP_Bool AddLayer(PP_Resource compositor, PP_Resource layer) { - return PP_FALSE; -} - -void RemoveLayer(PP_Resource compositor, PP_Resource layer) { -} - -void SetZIndex(PP_Resource compositor, PP_Resource layer, int32_t index) { -} - -void SetRect(PP_Resource compositor, PP_Resource layer, - const struct PP_Rect* rect) { -} - -void SetDisplay(PP_Resource compositor, PP_Resource layer, - PP_Bool is_displayed) { -} - -void MarkAsDirty(PP_Resource compositor, PP_Resource layer) { -} - -int32_t SwapBuffers(PP_Resource compositor, - struct PP_CompletionCallback callback) { - return PP_ERROR_FAILED; -} - -const PPB_LayerCompositor_Dev ppb_layercompositor = { - &Create, - &IsLayerCompositor, - &AddLayer, - &RemoveLayer, - &SetZIndex, - &SetRect, - &SetDisplay, - &MarkAsDirty, - &SwapBuffers, -}; - -} // namespace - PPB_LayerCompositor_Impl::PPB_LayerCompositor_Impl(PluginInstance* instance) : Resource(instance) { } @@ -67,16 +19,11 @@ PPB_LayerCompositor_Impl::PPB_LayerCompositor_Impl(PluginInstance* instance) PPB_LayerCompositor_Impl::~PPB_LayerCompositor_Impl() { } -PPB_LayerCompositor_Impl* -PPB_LayerCompositor_Impl::AsPPB_LayerCompositor_Impl() { +PPB_LayerCompositor_API* +PPB_LayerCompositor_Impl::AsPPB_LayerCompositor_API() { return this; } -// static -const PPB_LayerCompositor_Dev* PPB_LayerCompositor_Impl::GetInterface() { - return &ppb_layercompositor; -} - PP_Bool PPB_LayerCompositor_Impl::AddLayer(PP_Resource layer) { return PP_FALSE; } @@ -88,7 +35,7 @@ void PPB_LayerCompositor_Impl::SetZIndex(PP_Resource layer, int32_t index) { } void PPB_LayerCompositor_Impl::SetRect(PP_Resource layer, - const struct PP_Rect* rect) { + const PP_Rect* rect) { } void PPB_LayerCompositor_Impl::SetDisplay(PP_Resource layer, @@ -98,8 +45,7 @@ void PPB_LayerCompositor_Impl::SetDisplay(PP_Resource layer, void PPB_LayerCompositor_Impl::MarkAsDirty(PP_Resource layer) { } -int32_t PPB_LayerCompositor_Impl::SwapBuffers( - struct PP_CompletionCallback callback) { +int32_t PPB_LayerCompositor_Impl::SwapBuffers(PP_CompletionCallback callback) { return PP_ERROR_FAILED; } diff --git a/webkit/plugins/ppapi/ppb_layer_compositor_impl.h b/webkit/plugins/ppapi/ppb_layer_compositor_impl.h index 7d3a023..601cfa0 100644 --- a/webkit/plugins/ppapi/ppb_layer_compositor_impl.h +++ b/webkit/plugins/ppapi/ppb_layer_compositor_impl.h @@ -5,7 +5,7 @@ #ifndef WEBKIT_PLUGINS_PPAPI_PPB_LAYER_COMPOSITOR_IMPL_H_ #define WEBKIT_PLUGINS_PPAPI_PPB_LAYER_COMPOSITOR_IMPL_H_ -#include "ppapi/c/dev/ppb_layer_compositor_dev.h" +#include "ppapi/thunk/ppb_layer_compositor_api.h" #include "webkit/plugins/ppapi/resource.h" struct PP_Rect; @@ -16,23 +16,26 @@ namespace ppapi { class PluginInstance; -class PPB_LayerCompositor_Impl : public Resource { +class PPB_LayerCompositor_Impl + : public Resource, + public ::ppapi::thunk::PPB_LayerCompositor_API { public: explicit PPB_LayerCompositor_Impl(PluginInstance* instance); virtual ~PPB_LayerCompositor_Impl(); static const PPB_LayerCompositor_Dev* GetInterface(); - // Resource override. - virtual PPB_LayerCompositor_Impl* AsPPB_LayerCompositor_Impl(); - - PP_Bool AddLayer(PP_Resource layer); - void RemoveLayer(PP_Resource layer); - void SetZIndex(PP_Resource layer, int32_t index); - void SetRect(PP_Resource layer, const struct PP_Rect* rect); - void SetDisplay(PP_Resource layer, PP_Bool is_displayed); - void MarkAsDirty(PP_Resource layer); - int32_t SwapBuffers(struct PP_CompletionCallback callback); + // ResourceObjectBase override. + virtual PPB_LayerCompositor_API* AsPPB_LayerCompositor_API(); + + // PPB_LayerCompositor_API implementation. + virtual PP_Bool AddLayer(PP_Resource layer) OVERRIDE; + virtual void RemoveLayer(PP_Resource layer) OVERRIDE; + virtual void SetZIndex(PP_Resource layer, int32_t index) OVERRIDE; + virtual void SetRect(PP_Resource layer, const PP_Rect* rect) OVERRIDE; + virtual void SetDisplay(PP_Resource layer, PP_Bool is_displayed) OVERRIDE; + virtual void MarkAsDirty(PP_Resource layer) OVERRIDE; + virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(PPB_LayerCompositor_Impl); diff --git a/webkit/plugins/ppapi/ppb_opengles_impl.cc b/webkit/plugins/ppapi/ppb_opengles_impl.cc index df0ce19..9bd4e5c 100644 --- a/webkit/plugins/ppapi/ppb_opengles_impl.cc +++ b/webkit/plugins/ppapi/ppb_opengles_impl.cc @@ -2,1006 +2,758 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This file is auto-generated. DO NOT EDIT! +// This file is auto-generated from +// gpu/command_buffer/build_gles2_cmd_buffer.py +// DO NOT EDIT! #include "webkit/plugins/ppapi/ppb_opengles_impl.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "ppapi/c/dev/ppb_opengles_dev.h" +#include "ppapi/shared_impl/resource_object_base.h" +#include "ppapi/shared_impl/tracker_base.h" #include "webkit/plugins/ppapi/ppb_context_3d_impl.h" +using ppapi::ResourceObjectBase; +using ppapi::TrackerBase; + namespace webkit { namespace ppapi { namespace { +gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) { + ResourceObjectBase* base = TrackerBase::Get()->GetResourceAPI(context); + DCHECK(base->AsPPB_Context3D_API()); + return static_cast<PPB_Context3D_Impl*>(base)->gles2_impl(); +} + void ActiveTexture(PP_Resource context_id, GLenum texture) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->ActiveTexture(texture); + GetGLES(context_id)->ActiveTexture(texture); } void AttachShader(PP_Resource context_id, GLuint program, GLuint shader) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->AttachShader(program, shader); + GetGLES(context_id)->AttachShader(program, shader); } void BindAttribLocation( PP_Resource context_id, GLuint program, GLuint index, const char* name) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->BindAttribLocation(program, index, name); + GetGLES(context_id)->BindAttribLocation(program, index, name); } void BindBuffer(PP_Resource context_id, GLenum target, GLuint buffer) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->BindBuffer(target, buffer); + GetGLES(context_id)->BindBuffer(target, buffer); } void BindFramebuffer( PP_Resource context_id, GLenum target, GLuint framebuffer) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->BindFramebuffer(target, framebuffer); + GetGLES(context_id)->BindFramebuffer(target, framebuffer); } void BindRenderbuffer( PP_Resource context_id, GLenum target, GLuint renderbuffer) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->BindRenderbuffer(target, renderbuffer); + GetGLES(context_id)->BindRenderbuffer(target, renderbuffer); } void BindTexture(PP_Resource context_id, GLenum target, GLuint texture) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->BindTexture(target, texture); + GetGLES(context_id)->BindTexture(target, texture); } void BlendColor( PP_Resource context_id, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->BlendColor(red, green, blue, alpha); + GetGLES(context_id)->BlendColor(red, green, blue, alpha); } void BlendEquation(PP_Resource context_id, GLenum mode) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->BlendEquation(mode); + GetGLES(context_id)->BlendEquation(mode); } void BlendEquationSeparate( PP_Resource context_id, GLenum modeRGB, GLenum modeAlpha) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->BlendEquationSeparate(modeRGB, modeAlpha); + GetGLES(context_id)->BlendEquationSeparate(modeRGB, modeAlpha); } void BlendFunc(PP_Resource context_id, GLenum sfactor, GLenum dfactor) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->BlendFunc(sfactor, dfactor); + GetGLES(context_id)->BlendFunc(sfactor, dfactor); } void BlendFuncSeparate( PP_Resource context_id, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); + GetGLES(context_id)->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); } void BufferData( PP_Resource context_id, GLenum target, GLsizeiptr size, const void* data, GLenum usage) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->BufferData(target, size, data, usage); + GetGLES(context_id)->BufferData(target, size, data, usage); } void BufferSubData( PP_Resource context_id, GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->BufferSubData(target, offset, size, data); + GetGLES(context_id)->BufferSubData(target, offset, size, data); } GLenum CheckFramebufferStatus(PP_Resource context_id, GLenum target) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->CheckFramebufferStatus(target); + return GetGLES(context_id)->CheckFramebufferStatus(target); } void Clear(PP_Resource context_id, GLbitfield mask) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Clear(mask); + GetGLES(context_id)->Clear(mask); } void ClearColor( PP_Resource context_id, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->ClearColor(red, green, blue, alpha); + GetGLES(context_id)->ClearColor(red, green, blue, alpha); } void ClearDepthf(PP_Resource context_id, GLclampf depth) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->ClearDepthf(depth); + GetGLES(context_id)->ClearDepthf(depth); } void ClearStencil(PP_Resource context_id, GLint s) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->ClearStencil(s); + GetGLES(context_id)->ClearStencil(s); } void ColorMask( PP_Resource context_id, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->ColorMask(red, green, blue, alpha); + GetGLES(context_id)->ColorMask(red, green, blue, alpha); } void CompileShader(PP_Resource context_id, GLuint shader) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->CompileShader(shader); + GetGLES(context_id)->CompileShader(shader); } void CompressedTexImage2D( PP_Resource context_id, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->CompressedTexImage2D( - target, level, internalformat, width, height, border, imageSize, data); + GetGLES( + context_id)->CompressedTexImage2D( + target, level, internalformat, width, height, border, imageSize, + data); } void CompressedTexSubImage2D( PP_Resource context_id, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->CompressedTexSubImage2D( - target, level, xoffset, yoffset, width, height, format, imageSize, data); + GetGLES( + context_id)->CompressedTexSubImage2D( + target, level, xoffset, yoffset, width, height, format, imageSize, + data); } void CopyTexImage2D( PP_Resource context_id, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->CopyTexImage2D( - target, level, internalformat, x, y, width, height, border); + GetGLES( + context_id)->CopyTexImage2D( + target, level, internalformat, x, y, width, height, border); } void CopyTexSubImage2D( PP_Resource context_id, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->CopyTexSubImage2D( - target, level, xoffset, yoffset, x, y, width, height); + GetGLES( + context_id)->CopyTexSubImage2D( + target, level, xoffset, yoffset, x, y, width, height); } GLuint CreateProgram(PP_Resource context_id) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->CreateProgram(); + return GetGLES(context_id)->CreateProgram(); } GLuint CreateShader(PP_Resource context_id, GLenum type) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->CreateShader(type); + return GetGLES(context_id)->CreateShader(type); } void CullFace(PP_Resource context_id, GLenum mode) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->CullFace(mode); + GetGLES(context_id)->CullFace(mode); } void DeleteBuffers(PP_Resource context_id, GLsizei n, const GLuint* buffers) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DeleteBuffers(n, buffers); + GetGLES(context_id)->DeleteBuffers(n, buffers); } void DeleteFramebuffers( PP_Resource context_id, GLsizei n, const GLuint* framebuffers) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DeleteFramebuffers(n, framebuffers); + GetGLES(context_id)->DeleteFramebuffers(n, framebuffers); } void DeleteProgram(PP_Resource context_id, GLuint program) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DeleteProgram(program); + GetGLES(context_id)->DeleteProgram(program); } void DeleteRenderbuffers( PP_Resource context_id, GLsizei n, const GLuint* renderbuffers) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DeleteRenderbuffers(n, renderbuffers); + GetGLES(context_id)->DeleteRenderbuffers(n, renderbuffers); } void DeleteShader(PP_Resource context_id, GLuint shader) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DeleteShader(shader); + GetGLES(context_id)->DeleteShader(shader); } void DeleteTextures( PP_Resource context_id, GLsizei n, const GLuint* textures) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DeleteTextures(n, textures); + GetGLES(context_id)->DeleteTextures(n, textures); } void DepthFunc(PP_Resource context_id, GLenum func) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DepthFunc(func); + GetGLES(context_id)->DepthFunc(func); } void DepthMask(PP_Resource context_id, GLboolean flag) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DepthMask(flag); + GetGLES(context_id)->DepthMask(flag); } void DepthRangef(PP_Resource context_id, GLclampf zNear, GLclampf zFar) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DepthRangef(zNear, zFar); + GetGLES(context_id)->DepthRangef(zNear, zFar); } void DetachShader(PP_Resource context_id, GLuint program, GLuint shader) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DetachShader(program, shader); + GetGLES(context_id)->DetachShader(program, shader); } void Disable(PP_Resource context_id, GLenum cap) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Disable(cap); + GetGLES(context_id)->Disable(cap); } void DisableVertexAttribArray(PP_Resource context_id, GLuint index) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DisableVertexAttribArray(index); + GetGLES(context_id)->DisableVertexAttribArray(index); } void DrawArrays( PP_Resource context_id, GLenum mode, GLint first, GLsizei count) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DrawArrays(mode, first, count); + GetGLES(context_id)->DrawArrays(mode, first, count); } void DrawElements( PP_Resource context_id, GLenum mode, GLsizei count, GLenum type, const void* indices) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->DrawElements(mode, count, type, indices); + GetGLES(context_id)->DrawElements(mode, count, type, indices); } void Enable(PP_Resource context_id, GLenum cap) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Enable(cap); + GetGLES(context_id)->Enable(cap); } void EnableVertexAttribArray(PP_Resource context_id, GLuint index) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->EnableVertexAttribArray(index); + GetGLES(context_id)->EnableVertexAttribArray(index); } void Finish(PP_Resource context_id) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Finish(); + GetGLES(context_id)->Finish(); } void Flush(PP_Resource context_id) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Flush(); + GetGLES(context_id)->Flush(); } void FramebufferRenderbuffer( PP_Resource context_id, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->FramebufferRenderbuffer( - target, attachment, renderbuffertarget, renderbuffer); + GetGLES( + context_id)->FramebufferRenderbuffer( + target, attachment, renderbuffertarget, renderbuffer); } void FramebufferTexture2D( PP_Resource context_id, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->FramebufferTexture2D( - target, attachment, textarget, texture, level); + GetGLES( + context_id)->FramebufferTexture2D( + target, attachment, textarget, texture, level); } void FrontFace(PP_Resource context_id, GLenum mode) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->FrontFace(mode); + GetGLES(context_id)->FrontFace(mode); } void GenBuffers(PP_Resource context_id, GLsizei n, GLuint* buffers) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GenBuffers(n, buffers); + GetGLES(context_id)->GenBuffers(n, buffers); } void GenerateMipmap(PP_Resource context_id, GLenum target) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GenerateMipmap(target); + GetGLES(context_id)->GenerateMipmap(target); } void GenFramebuffers(PP_Resource context_id, GLsizei n, GLuint* framebuffers) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GenFramebuffers(n, framebuffers); + GetGLES(context_id)->GenFramebuffers(n, framebuffers); } void GenRenderbuffers( PP_Resource context_id, GLsizei n, GLuint* renderbuffers) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GenRenderbuffers(n, renderbuffers); + GetGLES(context_id)->GenRenderbuffers(n, renderbuffers); } void GenTextures(PP_Resource context_id, GLsizei n, GLuint* textures) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GenTextures(n, textures); + GetGLES(context_id)->GenTextures(n, textures); } void GetActiveAttrib( PP_Resource context_id, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetActiveAttrib( - program, index, bufsize, length, size, type, name); + GetGLES( + context_id)->GetActiveAttrib( + program, index, bufsize, length, size, type, name); } void GetActiveUniform( PP_Resource context_id, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetActiveUniform( - program, index, bufsize, length, size, type, name); + GetGLES( + context_id)->GetActiveUniform( + program, index, bufsize, length, size, type, name); } void GetAttachedShaders( PP_Resource context_id, GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetAttachedShaders(program, maxcount, count, shaders); + GetGLES(context_id)->GetAttachedShaders(program, maxcount, count, shaders); } GLint GetAttribLocation( PP_Resource context_id, GLuint program, const char* name) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->GetAttribLocation(program, name); + return GetGLES(context_id)->GetAttribLocation(program, name); } void GetBooleanv(PP_Resource context_id, GLenum pname, GLboolean* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetBooleanv(pname, params); + GetGLES(context_id)->GetBooleanv(pname, params); } void GetBufferParameteriv( PP_Resource context_id, GLenum target, GLenum pname, GLint* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetBufferParameteriv(target, pname, params); + GetGLES(context_id)->GetBufferParameteriv(target, pname, params); } GLenum GetError(PP_Resource context_id) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->GetError(); + return GetGLES(context_id)->GetError(); } void GetFloatv(PP_Resource context_id, GLenum pname, GLfloat* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetFloatv(pname, params); + GetGLES(context_id)->GetFloatv(pname, params); } void GetFramebufferAttachmentParameteriv( PP_Resource context_id, GLenum target, GLenum attachment, GLenum pname, GLint* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetFramebufferAttachmentParameteriv( - target, attachment, pname, params); + GetGLES( + context_id)->GetFramebufferAttachmentParameteriv( + target, attachment, pname, params); } void GetIntegerv(PP_Resource context_id, GLenum pname, GLint* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetIntegerv(pname, params); + GetGLES(context_id)->GetIntegerv(pname, params); } void GetProgramiv( PP_Resource context_id, GLuint program, GLenum pname, GLint* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetProgramiv(program, pname, params); + GetGLES(context_id)->GetProgramiv(program, pname, params); } void GetProgramInfoLog( PP_Resource context_id, GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetProgramInfoLog(program, bufsize, length, infolog); + GetGLES(context_id)->GetProgramInfoLog(program, bufsize, length, infolog); } void GetRenderbufferParameteriv( PP_Resource context_id, GLenum target, GLenum pname, GLint* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetRenderbufferParameteriv(target, pname, params); + GetGLES(context_id)->GetRenderbufferParameteriv(target, pname, params); } void GetShaderiv( PP_Resource context_id, GLuint shader, GLenum pname, GLint* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetShaderiv(shader, pname, params); + GetGLES(context_id)->GetShaderiv(shader, pname, params); } void GetShaderInfoLog( PP_Resource context_id, GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetShaderInfoLog(shader, bufsize, length, infolog); + GetGLES(context_id)->GetShaderInfoLog(shader, bufsize, length, infolog); } void GetShaderPrecisionFormat( PP_Resource context_id, GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetShaderPrecisionFormat( - shadertype, precisiontype, range, precision); + GetGLES( + context_id)->GetShaderPrecisionFormat( + shadertype, precisiontype, range, precision); } void GetShaderSource( PP_Resource context_id, GLuint shader, GLsizei bufsize, GLsizei* length, char* source) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetShaderSource(shader, bufsize, length, source); + GetGLES(context_id)->GetShaderSource(shader, bufsize, length, source); } const GLubyte* GetString(PP_Resource context_id, GLenum name) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->GetString(name); + return GetGLES(context_id)->GetString(name); } void GetTexParameterfv( PP_Resource context_id, GLenum target, GLenum pname, GLfloat* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetTexParameterfv(target, pname, params); + GetGLES(context_id)->GetTexParameterfv(target, pname, params); } void GetTexParameteriv( PP_Resource context_id, GLenum target, GLenum pname, GLint* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetTexParameteriv(target, pname, params); + GetGLES(context_id)->GetTexParameteriv(target, pname, params); } void GetUniformfv( PP_Resource context_id, GLuint program, GLint location, GLfloat* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetUniformfv(program, location, params); + GetGLES(context_id)->GetUniformfv(program, location, params); } void GetUniformiv( PP_Resource context_id, GLuint program, GLint location, GLint* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetUniformiv(program, location, params); + GetGLES(context_id)->GetUniformiv(program, location, params); } GLint GetUniformLocation( PP_Resource context_id, GLuint program, const char* name) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->GetUniformLocation(program, name); + return GetGLES(context_id)->GetUniformLocation(program, name); } void GetVertexAttribfv( PP_Resource context_id, GLuint index, GLenum pname, GLfloat* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetVertexAttribfv(index, pname, params); + GetGLES(context_id)->GetVertexAttribfv(index, pname, params); } void GetVertexAttribiv( PP_Resource context_id, GLuint index, GLenum pname, GLint* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetVertexAttribiv(index, pname, params); + GetGLES(context_id)->GetVertexAttribiv(index, pname, params); } void GetVertexAttribPointerv( PP_Resource context_id, GLuint index, GLenum pname, void** pointer) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->GetVertexAttribPointerv(index, pname, pointer); + GetGLES(context_id)->GetVertexAttribPointerv(index, pname, pointer); } void Hint(PP_Resource context_id, GLenum target, GLenum mode) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Hint(target, mode); + GetGLES(context_id)->Hint(target, mode); } GLboolean IsBuffer(PP_Resource context_id, GLuint buffer) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->IsBuffer(buffer); + return GetGLES(context_id)->IsBuffer(buffer); } GLboolean IsEnabled(PP_Resource context_id, GLenum cap) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->IsEnabled(cap); + return GetGLES(context_id)->IsEnabled(cap); } GLboolean IsFramebuffer(PP_Resource context_id, GLuint framebuffer) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->IsFramebuffer(framebuffer); + return GetGLES(context_id)->IsFramebuffer(framebuffer); } GLboolean IsProgram(PP_Resource context_id, GLuint program) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->IsProgram(program); + return GetGLES(context_id)->IsProgram(program); } GLboolean IsRenderbuffer(PP_Resource context_id, GLuint renderbuffer) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->IsRenderbuffer(renderbuffer); + return GetGLES(context_id)->IsRenderbuffer(renderbuffer); } GLboolean IsShader(PP_Resource context_id, GLuint shader) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->IsShader(shader); + return GetGLES(context_id)->IsShader(shader); } GLboolean IsTexture(PP_Resource context_id, GLuint texture) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - return context->gles2_impl()->IsTexture(texture); + return GetGLES(context_id)->IsTexture(texture); } void LineWidth(PP_Resource context_id, GLfloat width) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->LineWidth(width); + GetGLES(context_id)->LineWidth(width); } void LinkProgram(PP_Resource context_id, GLuint program) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->LinkProgram(program); + GetGLES(context_id)->LinkProgram(program); } void PixelStorei(PP_Resource context_id, GLenum pname, GLint param) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->PixelStorei(pname, param); + GetGLES(context_id)->PixelStorei(pname, param); } void PolygonOffset(PP_Resource context_id, GLfloat factor, GLfloat units) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->PolygonOffset(factor, units); + GetGLES(context_id)->PolygonOffset(factor, units); } void ReadPixels( PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->ReadPixels(x, y, width, height, format, type, pixels); + GetGLES(context_id)->ReadPixels(x, y, width, height, format, type, pixels); } void ReleaseShaderCompiler(PP_Resource context_id) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->ReleaseShaderCompiler(); + GetGLES(context_id)->ReleaseShaderCompiler(); } void RenderbufferStorage( PP_Resource context_id, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->RenderbufferStorage( - target, internalformat, width, height); + GetGLES( + context_id)->RenderbufferStorage(target, internalformat, width, height); } void SampleCoverage(PP_Resource context_id, GLclampf value, GLboolean invert) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->SampleCoverage(value, invert); + GetGLES(context_id)->SampleCoverage(value, invert); } void Scissor( PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Scissor(x, y, width, height); + GetGLES(context_id)->Scissor(x, y, width, height); } void ShaderBinary( PP_Resource context_id, GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->ShaderBinary( - n, shaders, binaryformat, binary, length); + GetGLES(context_id)->ShaderBinary(n, shaders, binaryformat, binary, length); } void ShaderSource( PP_Resource context_id, GLuint shader, GLsizei count, const char** str, const GLint* length) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->ShaderSource(shader, count, str, length); + GetGLES(context_id)->ShaderSource(shader, count, str, length); } void StencilFunc(PP_Resource context_id, GLenum func, GLint ref, GLuint mask) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->StencilFunc(func, ref, mask); + GetGLES(context_id)->StencilFunc(func, ref, mask); } void StencilFuncSeparate( PP_Resource context_id, GLenum face, GLenum func, GLint ref, GLuint mask) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->StencilFuncSeparate(face, func, ref, mask); + GetGLES(context_id)->StencilFuncSeparate(face, func, ref, mask); } void StencilMask(PP_Resource context_id, GLuint mask) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->StencilMask(mask); + GetGLES(context_id)->StencilMask(mask); } void StencilMaskSeparate(PP_Resource context_id, GLenum face, GLuint mask) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->StencilMaskSeparate(face, mask); + GetGLES(context_id)->StencilMaskSeparate(face, mask); } void StencilOp( PP_Resource context_id, GLenum fail, GLenum zfail, GLenum zpass) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->StencilOp(fail, zfail, zpass); + GetGLES(context_id)->StencilOp(fail, zfail, zpass); } void StencilOpSeparate( PP_Resource context_id, GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->StencilOpSeparate(face, fail, zfail, zpass); + GetGLES(context_id)->StencilOpSeparate(face, fail, zfail, zpass); } void TexImage2D( PP_Resource context_id, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->TexImage2D( - target, level, internalformat, width, height, border, format, type, - pixels); + GetGLES( + context_id)->TexImage2D( + target, level, internalformat, width, height, border, format, type, + pixels); } void TexParameterf( PP_Resource context_id, GLenum target, GLenum pname, GLfloat param) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->TexParameterf(target, pname, param); + GetGLES(context_id)->TexParameterf(target, pname, param); } void TexParameterfv( PP_Resource context_id, GLenum target, GLenum pname, const GLfloat* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->TexParameterfv(target, pname, params); + GetGLES(context_id)->TexParameterfv(target, pname, params); } void TexParameteri( PP_Resource context_id, GLenum target, GLenum pname, GLint param) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->TexParameteri(target, pname, param); + GetGLES(context_id)->TexParameteri(target, pname, param); } void TexParameteriv( PP_Resource context_id, GLenum target, GLenum pname, const GLint* params) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->TexParameteriv(target, pname, params); + GetGLES(context_id)->TexParameteriv(target, pname, params); } void TexSubImage2D( PP_Resource context_id, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->TexSubImage2D( - target, level, xoffset, yoffset, width, height, format, type, pixels); + GetGLES( + context_id)->TexSubImage2D( + target, level, xoffset, yoffset, width, height, format, type, + pixels); } void Uniform1f(PP_Resource context_id, GLint location, GLfloat x) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform1f(location, x); + GetGLES(context_id)->Uniform1f(location, x); } void Uniform1fv( PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform1fv(location, count, v); + GetGLES(context_id)->Uniform1fv(location, count, v); } void Uniform1i(PP_Resource context_id, GLint location, GLint x) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform1i(location, x); + GetGLES(context_id)->Uniform1i(location, x); } void Uniform1iv( PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform1iv(location, count, v); + GetGLES(context_id)->Uniform1iv(location, count, v); } void Uniform2f(PP_Resource context_id, GLint location, GLfloat x, GLfloat y) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform2f(location, x, y); + GetGLES(context_id)->Uniform2f(location, x, y); } void Uniform2fv( PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform2fv(location, count, v); + GetGLES(context_id)->Uniform2fv(location, count, v); } void Uniform2i(PP_Resource context_id, GLint location, GLint x, GLint y) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform2i(location, x, y); + GetGLES(context_id)->Uniform2i(location, x, y); } void Uniform2iv( PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform2iv(location, count, v); + GetGLES(context_id)->Uniform2iv(location, count, v); } void Uniform3f( PP_Resource context_id, GLint location, GLfloat x, GLfloat y, GLfloat z) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform3f(location, x, y, z); + GetGLES(context_id)->Uniform3f(location, x, y, z); } void Uniform3fv( PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform3fv(location, count, v); + GetGLES(context_id)->Uniform3fv(location, count, v); } void Uniform3i( PP_Resource context_id, GLint location, GLint x, GLint y, GLint z) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform3i(location, x, y, z); + GetGLES(context_id)->Uniform3i(location, x, y, z); } void Uniform3iv( PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform3iv(location, count, v); + GetGLES(context_id)->Uniform3iv(location, count, v); } void Uniform4f( PP_Resource context_id, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform4f(location, x, y, z, w); + GetGLES(context_id)->Uniform4f(location, x, y, z, w); } void Uniform4fv( PP_Resource context_id, GLint location, GLsizei count, const GLfloat* v) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform4fv(location, count, v); + GetGLES(context_id)->Uniform4fv(location, count, v); } void Uniform4i( PP_Resource context_id, GLint location, GLint x, GLint y, GLint z, GLint w) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform4i(location, x, y, z, w); + GetGLES(context_id)->Uniform4i(location, x, y, z, w); } void Uniform4iv( PP_Resource context_id, GLint location, GLsizei count, const GLint* v) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Uniform4iv(location, count, v); + GetGLES(context_id)->Uniform4iv(location, count, v); } void UniformMatrix2fv( PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->UniformMatrix2fv(location, count, transpose, value); + GetGLES(context_id)->UniformMatrix2fv(location, count, transpose, value); } void UniformMatrix3fv( PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->UniformMatrix3fv(location, count, transpose, value); + GetGLES(context_id)->UniformMatrix3fv(location, count, transpose, value); } void UniformMatrix4fv( PP_Resource context_id, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->UniformMatrix4fv(location, count, transpose, value); + GetGLES(context_id)->UniformMatrix4fv(location, count, transpose, value); } void UseProgram(PP_Resource context_id, GLuint program) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->UseProgram(program); + GetGLES(context_id)->UseProgram(program); } void ValidateProgram(PP_Resource context_id, GLuint program) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->ValidateProgram(program); + GetGLES(context_id)->ValidateProgram(program); } void VertexAttrib1f(PP_Resource context_id, GLuint indx, GLfloat x) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->VertexAttrib1f(indx, x); + GetGLES(context_id)->VertexAttrib1f(indx, x); } void VertexAttrib1fv( PP_Resource context_id, GLuint indx, const GLfloat* values) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->VertexAttrib1fv(indx, values); + GetGLES(context_id)->VertexAttrib1fv(indx, values); } void VertexAttrib2f( PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->VertexAttrib2f(indx, x, y); + GetGLES(context_id)->VertexAttrib2f(indx, x, y); } void VertexAttrib2fv( PP_Resource context_id, GLuint indx, const GLfloat* values) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->VertexAttrib2fv(indx, values); + GetGLES(context_id)->VertexAttrib2fv(indx, values); } void VertexAttrib3f( PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y, GLfloat z) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->VertexAttrib3f(indx, x, y, z); + GetGLES(context_id)->VertexAttrib3f(indx, x, y, z); } void VertexAttrib3fv( PP_Resource context_id, GLuint indx, const GLfloat* values) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->VertexAttrib3fv(indx, values); + GetGLES(context_id)->VertexAttrib3fv(indx, values); } void VertexAttrib4f( PP_Resource context_id, GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->VertexAttrib4f(indx, x, y, z, w); + GetGLES(context_id)->VertexAttrib4f(indx, x, y, z, w); } void VertexAttrib4fv( PP_Resource context_id, GLuint indx, const GLfloat* values) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->VertexAttrib4fv(indx, values); + GetGLES(context_id)->VertexAttrib4fv(indx, values); } void VertexAttribPointer( PP_Resource context_id, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->VertexAttribPointer( - indx, size, type, normalized, stride, ptr); + GetGLES( + context_id)->VertexAttribPointer( + indx, size, type, normalized, stride, ptr); } void Viewport( PP_Resource context_id, GLint x, GLint y, GLsizei width, GLsizei height) { - scoped_refptr<PPB_Context3D_Impl> context = - Resource::GetAs<PPB_Context3D_Impl>(context_id); - context->gles2_impl()->Viewport(x, y, width, height); + GetGLES(context_id)->Viewport(x, y, width, height); +} + +void SetLatchCHROMIUM(PP_Resource context_id, GLuint latch_id) { + GetGLES(context_id)->SetLatchCHROMIUM(latch_id); +} + +void WaitLatchCHROMIUM(PP_Resource context_id, GLuint latch_id) { + GetGLES(context_id)->WaitLatchCHROMIUM(latch_id); } diff --git a/webkit/plugins/ppapi/ppb_proxy_impl.cc b/webkit/plugins/ppapi/ppb_proxy_impl.cc index fc861af..1660b71 100644 --- a/webkit/plugins/ppapi/ppb_proxy_impl.cc +++ b/webkit/plugins/ppapi/ppb_proxy_impl.cc @@ -5,12 +5,17 @@ #include "webkit/plugins/ppapi/ppb_proxy_impl.h" #include "ppapi/c/private/ppb_proxy_private.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_image_data_api.h" #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" #include "webkit/plugins/ppapi/resource.h" #include "webkit/plugins/ppapi/resource_tracker.h" +using ppapi::thunk::EnterResource; +using ppapi::thunk::PPB_URLLoader_API; + namespace webkit { namespace ppapi { @@ -37,11 +42,10 @@ void SetReserveInstanceIDCallback(PP_Module module, } int32_t GetURLLoaderBufferedBytes(PP_Resource url_loader) { - scoped_refptr<PPB_URLLoader_Impl> loader( - Resource::GetAs<PPB_URLLoader_Impl>(url_loader)); - if (!loader) - return 0; - return loader->buffer_size(); + EnterResource<PPB_URLLoader_API> enter(url_loader, true); + if (enter.succeeded()) + return static_cast<PPB_URLLoader_Impl*>(enter.object())->buffer_size(); + return 0; } void AddRefModule(PP_Module module) { diff --git a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc index 5747fc2..1996bb8 100644 --- a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc +++ b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc @@ -166,33 +166,28 @@ void PPB_Scrollbar_Impl::ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) { scrollbar_->scroll(direction, granularity, fmultiplier); } -bool PPB_Scrollbar_Impl::Paint(const PP_Rect* rect, PPB_ImageData_Impl* image) { - gfx::Rect gfx_rect(rect->point.x, - rect->point.y, - rect->size.width, - rect->size.height); +PP_Bool PPB_Scrollbar_Impl::HandleEvent(const PP_InputEvent* event) { + scoped_ptr<WebInputEvent> web_input_event(CreateWebInputEvent(*event)); + if (!web_input_event.get()) + return PP_FALSE; + + return PP_FromBool(scrollbar_->handleInputEvent(*web_input_event.get())); +} + +PP_Bool PPB_Scrollbar_Impl::PaintInternal(const gfx::Rect& rect, + PPB_ImageData_Impl* image) { ImageDataAutoMapper mapper(image); skia::PlatformCanvas* canvas = image->mapped_canvas(); if (!canvas) - return false; - scrollbar_->paint(webkit_glue::ToWebCanvas(canvas), gfx_rect); + return PP_FALSE; + scrollbar_->paint(webkit_glue::ToWebCanvas(canvas), rect); #if defined(OS_WIN) - if (base::win::GetVersion() == base::win::VERSION_XP) { - skia::MakeOpaque(canvas, gfx_rect.x(), gfx_rect.y(), - gfx_rect.width(), gfx_rect.height()); - } + if (base::win::GetVersion() == base::win::VERSION_XP) + skia::MakeOpaque(canvas, rect.x(), rect.y(), rect.width(), rect.height()); #endif - return true; -} - -bool PPB_Scrollbar_Impl::HandleEvent(const PP_InputEvent* event) { - scoped_ptr<WebInputEvent> web_input_event(CreateWebInputEvent(*event)); - if (!web_input_event.get()) - return false; - - return scrollbar_->handleInputEvent(*web_input_event.get()); + return PP_TRUE; } void PPB_Scrollbar_Impl::SetLocationInternal(const PP_Rect* location) { diff --git a/webkit/plugins/ppapi/ppb_scrollbar_impl.h b/webkit/plugins/ppapi/ppb_scrollbar_impl.h index 88c4308..6c1ca86 100644 --- a/webkit/plugins/ppapi/ppb_scrollbar_impl.h +++ b/webkit/plugins/ppapi/ppb_scrollbar_impl.h @@ -38,19 +38,22 @@ class PPB_Scrollbar_Impl : public PPB_Widget_Impl, void SetTickMarks(const PP_Rect* tick_marks, uint32_t count); void ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier); - // PPB_Widget implementation. - virtual bool Paint(const PP_Rect* rect, PPB_ImageData_Impl* image); - virtual bool HandleEvent(const PP_InputEvent* event); - virtual void SetLocationInternal(const PP_Rect* location); + // PPB_Widget public implementation. + virtual PP_Bool HandleEvent(const PP_InputEvent* event) OVERRIDE; private: + // PPB_Widget private implementation. + virtual PP_Bool PaintInternal(const gfx::Rect& rect, + PPB_ImageData_Impl* image) OVERRIDE; + virtual void SetLocationInternal(const PP_Rect* location) OVERRIDE; + // WebKit::WebScrollbarClient implementation. - virtual void valueChanged(WebKit::WebScrollbar* scrollbar); + virtual void valueChanged(WebKit::WebScrollbar* scrollbar) OVERRIDE; virtual void invalidateScrollbarRect(WebKit::WebScrollbar* scrollbar, - const WebKit::WebRect& rect); + const WebKit::WebRect& rect) OVERRIDE; virtual void getTickmarks( WebKit::WebScrollbar* scrollbar, - WebKit::WebVector<WebKit::WebRect>* tick_marks) const; + WebKit::WebVector<WebKit::WebRect>* tick_marks) const OVERRIDE; void NotifyInvalidate(); diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc index f250fcb..ad8e9b1 100644 --- a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc +++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc @@ -14,14 +14,28 @@ #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/ppb_context_3d_impl.h" +using ppapi::thunk::PPB_Surface3D_API; + namespace webkit { namespace ppapi { -namespace { +PPB_Surface3D_Impl::PPB_Surface3D_Impl(PluginInstance* instance) + : Resource(instance), + bound_to_instance_(false), + swap_initiated_(false), + swap_callback_(PP_BlockUntilComplete()), + context_(NULL) { +} + +PPB_Surface3D_Impl::~PPB_Surface3D_Impl() { + if (context_) + context_->BindSurfaces(NULL, NULL); +} -PP_Resource Create(PP_Instance instance_id, - PP_Config3D_Dev config, - const int32_t* attrib_list) { +// static +PP_Resource PPB_Surface3D_Impl::Create(PP_Instance instance_id, + PP_Config3D_Dev config, + const int32_t* attrib_list) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) return 0; @@ -30,64 +44,43 @@ PP_Resource Create(PP_Instance instance_id, new PPB_Surface3D_Impl(instance)); if (!surface->Init(config, attrib_list)) return 0; - return surface->GetReference(); } -PP_Bool IsSurface3D(PP_Resource resource) { - return BoolToPPBool(!!Resource::GetAs<PPB_Surface3D_Impl>(resource)); +PPB_Surface3D_API* PPB_Surface3D_Impl::AsPPB_Surface3D_API() { + return this; } -int32_t SetAttrib(PP_Resource surface_id, - int32_t attribute, - int32_t value) { +int32_t PPB_Surface3D_Impl::SetAttrib(int32_t attribute, int32_t value) { // TODO(alokp): Implement me. return 0; } -int32_t GetAttrib(PP_Resource surface_id, - int32_t attribute, - int32_t* value) { +int32_t PPB_Surface3D_Impl::GetAttrib(int32_t attribute, int32_t* value) { // TODO(alokp): Implement me. return 0; } -int32_t SwapBuffers(PP_Resource surface_id, - PP_CompletionCallback callback) { - scoped_refptr<PPB_Surface3D_Impl> surface( - Resource::GetAs<PPB_Surface3D_Impl>(surface_id)); - return surface->SwapBuffers(callback); -} - -const PPB_Surface3D_Dev ppb_surface3d = { - &Create, - &IsSurface3D, - &SetAttrib, - &GetAttrib, - &SwapBuffers -}; - -} // namespace - -PPB_Surface3D_Impl::PPB_Surface3D_Impl(PluginInstance* instance) - : Resource(instance), - bound_to_instance_(false), - swap_initiated_(false), - swap_callback_(PP_BlockUntilComplete()), - context_(NULL) { -} +int32_t PPB_Surface3D_Impl::SwapBuffers(PP_CompletionCallback callback) { + if (!context_) + return PP_ERROR_FAILED; -PPB_Surface3D_Impl::~PPB_Surface3D_Impl() { - if (context_) - context_->BindSurfaces(NULL, NULL); -} + if (swap_callback_.func) { + // Already a pending SwapBuffers that hasn't returned yet. + return PP_ERROR_INPROGRESS; + } -const PPB_Surface3D_Dev* PPB_Surface3D_Impl::GetInterface() { - return &ppb_surface3d; -} + if (!callback.func) { + // Blocking SwapBuffers isn't supported (since we have to be on the main + // thread). + return PP_ERROR_BADARGUMENT; + } -PPB_Surface3D_Impl* PPB_Surface3D_Impl::AsPPB_Surface3D_Impl() { - return this; + swap_callback_ = callback; + gpu::gles2::GLES2Implementation* impl = context_->gles2_impl(); + if (impl) + context_->gles2_impl()->SwapBuffers(); + return PP_OK_COMPLETIONPENDING; } bool PPB_Surface3D_Impl::Init(PP_Config3D_Dev config, @@ -100,16 +93,14 @@ bool PPB_Surface3D_Impl::BindToInstance(bool bind) { return true; } -bool PPB_Surface3D_Impl::BindToContext( - PPB_Context3D_Impl* context) { +bool PPB_Surface3D_Impl::BindToContext(PPB_Context3D_Impl* context) { if (context == context_) return true; // Unbind from the current context. - if (context_) { + if (context_ && context_->platform_context()) context_->platform_context()->SetSwapBuffersCallback(NULL); - } - if (context) { + if (context && context->platform_context()) { // Resize the backing texture to the size of the instance when it is bound. // TODO(alokp): This should be the responsibility of plugins. gpu::gles2::GLES2Implementation* impl = context->gles2_impl(); @@ -125,29 +116,6 @@ bool PPB_Surface3D_Impl::BindToContext( return true; } -int32_t PPB_Surface3D_Impl::SwapBuffers(PP_CompletionCallback callback) { - if (!context_) - return PP_ERROR_FAILED; - - if (swap_callback_.func) { - // Already a pending SwapBuffers that hasn't returned yet. - return PP_ERROR_INPROGRESS; - } - - if (!callback.func) { - // Blocking SwapBuffers isn't supported (since we have to be on the main - // thread). - return PP_ERROR_BADARGUMENT; - } - - swap_callback_ = callback; - gpu::gles2::GLES2Implementation* impl = context_->gles2_impl(); - if (impl) { - context_->gles2_impl()->SwapBuffers(); - } - return PP_OK_COMPLETIONPENDING; -} - void PPB_Surface3D_Impl::ViewInitiatedPaint() { } diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.h b/webkit/plugins/ppapi/ppb_surface_3d_impl.h index e924e52..16b1c6f 100644 --- a/webkit/plugins/ppapi/ppb_surface_3d_impl.h +++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.h @@ -6,7 +6,7 @@ #define WEBKIT_PLUGINS_PPAPI_PPB_SURFACE_3D_IMPL_H_ #include "base/callback.h" -#include "ppapi/c/dev/ppb_surface_3d_dev.h" +#include "ppapi/thunk/ppb_surface_3d_api.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/resource.h" @@ -17,18 +17,24 @@ class Size; namespace webkit { namespace ppapi { -class PPB_Surface3D_Impl : public Resource { +class PPB_Context3D_Impl; + +class PPB_Surface3D_Impl : public Resource, + public ::ppapi::thunk::PPB_Surface3D_API { public: - explicit PPB_Surface3D_Impl(PluginInstance* instance); virtual ~PPB_Surface3D_Impl(); - static const PPB_Surface3D_Dev* GetInterface(); + static PP_Resource Create(PP_Instance instance_id, + PP_Config3D_Dev config, + const int32_t* attrib_list); - // Resource override. - virtual PPB_Surface3D_Impl* AsPPB_Surface3D_Impl(); + // ResourceObjectBase override. + virtual ::ppapi::thunk::PPB_Surface3D_API* AsPPB_Surface3D_API() OVERRIDE; - bool Init(PP_Config3D_Dev config, - const int32_t* attrib_list); + // PPB_Surface3D_API implementation. + virtual int32_t SetAttrib(int32_t attribute, int32_t value) OVERRIDE; + virtual int32_t GetAttrib(int32_t attribute, int32_t* value) OVERRIDE; + virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE; PPB_Context3D_Impl* context() const { return context_; @@ -46,13 +52,15 @@ class PPB_Surface3D_Impl : public Resource { unsigned int GetBackingTextureId(); - int32_t SwapBuffers(PP_CompletionCallback callback); - void ViewInitiatedPaint(); void ViewFlushedPaint(); void OnContextLost(); private: + explicit PPB_Surface3D_Impl(PluginInstance* instance); + + bool Init(PP_Config3D_Dev config, const int32_t* attrib_list); + // Called when SwapBuffers is complete. void OnSwapBuffers(); void SendContextLost(); diff --git a/webkit/plugins/ppapi/ppb_transport_impl.cc b/webkit/plugins/ppapi/ppb_transport_impl.cc index a37f299..54e0adf 100644 --- a/webkit/plugins/ppapi/ppb_transport_impl.cc +++ b/webkit/plugins/ppapi/ppb_transport_impl.cc @@ -17,6 +17,7 @@ #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/var.h" +using ppapi::thunk::PPB_Transport_API; using webkit_glue::P2PTransport; namespace webkit { @@ -27,81 +28,6 @@ namespace { const char kUdpProtocolName[] = "udp"; const char kTcpProtocolName[] = "tcp"; -PP_Resource CreateTransport(PP_Instance instance_id, const char* name, - const char* proto) { - PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); - if (!instance) - return 0; - - scoped_refptr<PPB_Transport_Impl> t(new PPB_Transport_Impl(instance)); - if (!t->Init(name, proto)) - return 0; - - return t->GetReference(); -} - -PP_Bool IsTransport(PP_Resource resource) { - return BoolToPPBool(Resource::GetAs<PPB_Transport_Impl>(resource) != NULL); -} - -PP_Bool IsWritable(PP_Resource resource) { - scoped_refptr<PPB_Transport_Impl> t( - Resource::GetAs<PPB_Transport_Impl>(resource)); - return BoolToPPBool((t.get()) ? t->IsWritable() : false); -} - -int32_t Connect(PP_Resource resource, PP_CompletionCallback callback) { - scoped_refptr<PPB_Transport_Impl> t( - Resource::GetAs<PPB_Transport_Impl>(resource)); - return (t.get()) ? t->Connect(callback) : PP_ERROR_BADRESOURCE; -} - -int32_t GetNextAddress(PP_Resource resource, PP_Var* address, - PP_CompletionCallback callback) { - scoped_refptr<PPB_Transport_Impl> t( - Resource::GetAs<PPB_Transport_Impl>(resource)); - return (t.get())? t->GetNextAddress(address, callback) : PP_ERROR_BADRESOURCE; -} - -int32_t ReceiveRemoteAddress(PP_Resource resource, PP_Var address) { - scoped_refptr<PPB_Transport_Impl> t( - Resource::GetAs<PPB_Transport_Impl>(resource)); - return (t.get())? t->ReceiveRemoteAddress(address) : PP_ERROR_BADRESOURCE; -} - -int32_t Recv(PP_Resource resource, void* data, uint32_t len, - PP_CompletionCallback callback) { - scoped_refptr<PPB_Transport_Impl> t( - Resource::GetAs<PPB_Transport_Impl>(resource)); - return (t.get())? t->Recv(data, len, callback) : PP_ERROR_BADRESOURCE; -} - -int32_t Send(PP_Resource resource, const void* data, uint32_t len, - PP_CompletionCallback callback) { - scoped_refptr<PPB_Transport_Impl> t( - Resource::GetAs<PPB_Transport_Impl>(resource)); - return (t.get())? t->Send(data, len, callback) : PP_ERROR_BADRESOURCE; -} - -// Disconnects from the remote peer. -int32_t Close(PP_Resource resource) { - scoped_refptr<PPB_Transport_Impl> t( - Resource::GetAs<PPB_Transport_Impl>(resource)); - return (t.get())? t->Close() : PP_ERROR_BADRESOURCE; -} - -const PPB_Transport_Dev ppb_transport = { - &CreateTransport, - &IsTransport, - &IsWritable, - &Connect, - &GetNextAddress, - &ReceiveRemoteAddress, - &Recv, - &Send, - &Close, -}; - int MapNetError(int result) { if (result > 0) return result; @@ -133,11 +59,17 @@ PPB_Transport_Impl::PPB_Transport_Impl(PluginInstance* instance) PPB_Transport_Impl::~PPB_Transport_Impl() { } -const PPB_Transport_Dev* PPB_Transport_Impl::GetInterface() { - return &ppb_transport; +// static +PP_Resource PPB_Transport_Impl::Create(PluginInstance* instance, + const char* name, + const char* proto) { + scoped_refptr<PPB_Transport_Impl> t(new PPB_Transport_Impl(instance)); + if (!t->Init(name, proto)) + return 0; + return t->GetReference(); } -PPB_Transport_Impl* PPB_Transport_Impl::AsPPB_Transport_Impl() { +PPB_Transport_API* PPB_Transport_Impl::AsPPB_Transport_API() { return this; } @@ -157,11 +89,11 @@ bool PPB_Transport_Impl::Init(const char* name, const char* proto) { return p2p_transport_.get() != NULL; } -bool PPB_Transport_Impl::IsWritable() const { +PP_Bool PPB_Transport_Impl::IsWritable() { if (!p2p_transport_.get()) - return false; + return PP_FALSE; - return writable_; + return PP_FromBool(writable_); } int32_t PPB_Transport_Impl::Connect(PP_CompletionCallback callback) { diff --git a/webkit/plugins/ppapi/ppb_transport_impl.h b/webkit/plugins/ppapi/ppb_transport_impl.h index ca4818f..e7d9760 100644 --- a/webkit/plugins/ppapi/ppb_transport_impl.h +++ b/webkit/plugins/ppapi/ppb_transport_impl.h @@ -11,7 +11,7 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "net/base/completion_callback.h" -#include "ppapi/c/dev/ppb_transport_dev.h" +#include "ppapi/thunk/ppb_transport_api.h" #include "webkit/glue/p2p_transport.h" #include "webkit/plugins/ppapi/callbacks.h" #include "webkit/plugins/ppapi/resource.h" @@ -20,25 +20,29 @@ namespace webkit { namespace ppapi { class PPB_Transport_Impl : public Resource, + public ::ppapi::thunk::PPB_Transport_API, public webkit_glue::P2PTransport::EventHandler { public: - static const PPB_Transport_Dev* GetInterface(); - - explicit PPB_Transport_Impl(PluginInstance* instance); virtual ~PPB_Transport_Impl(); - bool Init(const char* name, const char* proto); - - // Resource override. - virtual PPB_Transport_Impl* AsPPB_Transport_Impl() OVERRIDE; - - bool IsWritable() const; - int32_t Connect(PP_CompletionCallback cb); - int32_t GetNextAddress(PP_Var* address, PP_CompletionCallback cb); - int32_t ReceiveRemoteAddress(PP_Var address); - int32_t Recv(void* data, uint32_t len, PP_CompletionCallback cb); - int32_t Send(const void* data, uint32_t len, PP_CompletionCallback cb); - int32_t Close(); + static PP_Resource Create(PluginInstance* instance, + const char* name, + const char* proto); + + // ResourceObjectBase override. + virtual ::ppapi::thunk::PPB_Transport_API* AsPPB_Transport_API() OVERRIDE; + + // PPB_Transport_API implementation. + virtual PP_Bool IsWritable() OVERRIDE; + virtual int32_t Connect(PP_CompletionCallback callback) OVERRIDE; + virtual int32_t GetNextAddress(PP_Var* address, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t ReceiveRemoteAddress(PP_Var address) OVERRIDE; + virtual int32_t Recv(void* data, uint32_t len, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t Send(const void* data, uint32_t len, + PP_CompletionCallback callback) OVERRIDE; + virtual int32_t Close() OVERRIDE; // webkit_glue::P2PTransport::EventHandler implementation. virtual void OnCandidateReady(const std::string& address) OVERRIDE; @@ -46,6 +50,10 @@ class PPB_Transport_Impl : public Resource, virtual void OnError(int error) OVERRIDE; private: + explicit PPB_Transport_Impl(PluginInstance* instance); + + bool Init(const char* name, const char* proto); + void OnRead(int result); void OnWritten(int result); diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc index 6469fbe..d8afcbf 100644 --- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc +++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc @@ -23,6 +23,9 @@ #include "webkit/plugins/ppapi/resource_tracker.h" #include "webkit/plugins/ppapi/var.h" +using ppapi::thunk::EnterResourceNoLock; +using ppapi::thunk::PPB_Buffer_API; +using ppapi::thunk::PPB_Context3D_API; using ppapi::thunk::PPB_VideoDecoder_API; namespace webkit { @@ -121,11 +124,11 @@ int32_t PPB_VideoDecoder_Impl::Initialize( if (!instance()) return PP_ERROR_FAILED; - scoped_refptr<webkit::ppapi::PPB_Context3D_Impl> context3d = - webkit::ppapi::Resource::GetAs<webkit::ppapi::PPB_Context3D_Impl>( - context_id); - if (!context3d) + EnterResourceNoLock<PPB_Context3D_API> enter(context_id, true); + if (enter.failed()) return PP_ERROR_BADRESOURCE; + PPB_Context3D_Impl* context3d = + static_cast<PPB_Context3D_Impl*>(enter.object()); int command_buffer_route_id = context3d->platform_context()->GetCommandBufferRouteId(); @@ -156,8 +159,7 @@ int32_t PPB_VideoDecoder_Impl::Decode( if (!platform_video_decoder_.get()) return PP_ERROR_BADRESOURCE; - ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_Buffer_API> - enter(bitstream_buffer->data, true); + EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true); if (enter.failed()) return PP_ERROR_FAILED; @@ -351,9 +353,12 @@ GLESBuffer::GLESBuffer(const PP_GLESBuffer_Dev& buffer) SysmemBuffer::SysmemBuffer(const PP_SysmemBuffer_Dev& buffer) : BaseBuffer(buffer.info) { - scoped_refptr<webkit::ppapi::PPB_Buffer_Impl> pepper_buffer = - webkit::ppapi::Resource::GetAs<webkit::ppapi::PPB_Buffer_Impl>( - buffer.data); + // TODO(brettw) we should properly handle the errors here if the buffer + // isn't a valid image rather than CHECKing. + EnterResourceNoLock<PPB_Buffer_API> enter(buffer.data, true); + CHECK(enter.succeeded()); + webkit::ppapi::PPB_Buffer_Impl* pepper_buffer = + static_cast<webkit::ppapi::PPB_Buffer_Impl*>(enter.object()); CHECK(pepper_buffer->IsMapped()); data_ = pepper_buffer->Map(); } diff --git a/webkit/plugins/ppapi/ppb_widget_impl.cc b/webkit/plugins/ppapi/ppb_widget_impl.cc index 896ba5f..91bfea1 100644 --- a/webkit/plugins/ppapi/ppb_widget_impl.cc +++ b/webkit/plugins/ppapi/ppb_widget_impl.cc @@ -4,70 +4,19 @@ #include "webkit/plugins/ppapi/ppb_widget_impl.h" -#include "base/logging.h" -#include "ppapi/c/dev/ppb_widget_dev.h" #include "ppapi/c/dev/ppp_widget_dev.h" -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_errors.h" -#include "webkit/plugins/ppapi/common.h" +#include "ppapi/thunk/enter.h" #include "webkit/plugins/ppapi/ppb_image_data_impl.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/plugin_module.h" +using ppapi::thunk::EnterResourceNoLock; +using ppapi::thunk::PPB_ImageData_API; +using ppapi::thunk::PPB_Widget_API; + namespace webkit { namespace ppapi { -namespace { - -PP_Bool IsWidget(PP_Resource resource) { - return BoolToPPBool(!!Resource::GetAs<PPB_Widget_Impl>(resource)); -} - -PP_Bool Paint(PP_Resource resource, - const PP_Rect* rect, - PP_Resource image_id) { - scoped_refptr<PPB_Widget_Impl> widget( - Resource::GetAs<PPB_Widget_Impl>(resource)); - if (!widget) - return PP_FALSE; - - scoped_refptr<PPB_ImageData_Impl> image( - Resource::GetAs<PPB_ImageData_Impl>(image_id)); - if (!image) - return PP_FALSE; - - return BoolToPPBool(widget->Paint(rect, image)); -} - -PP_Bool HandleEvent(PP_Resource resource, const PP_InputEvent* event) { - scoped_refptr<PPB_Widget_Impl> widget( - Resource::GetAs<PPB_Widget_Impl>(resource)); - return BoolToPPBool(widget && widget->HandleEvent(event)); -} - -PP_Bool GetLocation(PP_Resource resource, PP_Rect* location) { - scoped_refptr<PPB_Widget_Impl> widget( - Resource::GetAs<PPB_Widget_Impl>(resource)); - return BoolToPPBool(widget && widget->GetLocation(location)); -} - -void SetLocation(PP_Resource resource, const PP_Rect* location) { - scoped_refptr<PPB_Widget_Impl> widget( - Resource::GetAs<PPB_Widget_Impl>(resource)); - if (widget) - widget->SetLocation(location); -} - -const PPB_Widget_Dev ppb_widget = { - &IsWidget, - &Paint, - &HandleEvent, - &GetLocation, - &SetLocation, -}; - -} // namespace - PPB_Widget_Impl::PPB_Widget_Impl(PluginInstance* instance) : Resource(instance) { memset(&location_, 0, sizeof(location_)); @@ -76,18 +25,22 @@ PPB_Widget_Impl::PPB_Widget_Impl(PluginInstance* instance) PPB_Widget_Impl::~PPB_Widget_Impl() { } -// static -const PPB_Widget_Dev* PPB_Widget_Impl::GetInterface() { - return &ppb_widget; +PPB_Widget_API* PPB_Widget_Impl::AsPPB_Widget_API() { + return this; } -PPB_Widget_Impl* PPB_Widget_Impl::AsPPB_Widget_Impl() { - return this; +PP_Bool PPB_Widget_Impl::Paint(const PP_Rect* rect, PP_Resource image_id) { + EnterResourceNoLock<PPB_ImageData_API> enter(image_id, true); + if (enter.failed()) + return PP_FALSE; + return PaintInternal(gfx::Rect(rect->point.x, rect->point.y, + rect->size.width, rect->size.height), + static_cast<PPB_ImageData_Impl*>(enter.object())); } -bool PPB_Widget_Impl::GetLocation(PP_Rect* location) { +PP_Bool PPB_Widget_Impl::GetLocation(PP_Rect* location) { *location = location_; - return true; + return PP_TRUE; } void PPB_Widget_Impl::SetLocation(const PP_Rect* location) { diff --git a/webkit/plugins/ppapi/ppb_widget_impl.h b/webkit/plugins/ppapi/ppb_widget_impl.h index 5a1aa72..2cdc333 100644 --- a/webkit/plugins/ppapi/ppb_widget_impl.h +++ b/webkit/plugins/ppapi/ppb_widget_impl.h @@ -8,40 +8,45 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "ppapi/c/pp_rect.h" +#include "ppapi/thunk/ppb_widget_api.h" #include "webkit/plugins/ppapi/resource.h" struct PPB_Widget_Dev; struct PP_InputEvent; +namespace gfx { +class Rect; +} + namespace webkit { namespace ppapi { -class PPB_ImageData_Impla; +class PPB_ImageData_Impl; class PluginInstance; -class PPB_Widget_Impl : public Resource { +class PPB_Widget_Impl : public Resource, + public ::ppapi::thunk::PPB_Widget_API { public: explicit PPB_Widget_Impl(PluginInstance* instance); virtual ~PPB_Widget_Impl(); - // Returns a pointer to the interface implementing PPB_Widget that is - // exposed to the plugin. - static const PPB_Widget_Dev* GetInterface(); - - // Resource overrides. - virtual PPB_Widget_Impl* AsPPB_Widget_Impl(); + // ResourceObjectBase overrides. + virtual ::ppapi::thunk::PPB_Widget_API* AsPPB_Widget_API() OVERRIDE; - // PPB_Widget implementation. - virtual bool Paint(const PP_Rect* rect, PPB_ImageData_Impl* image) = 0; - virtual bool HandleEvent(const PP_InputEvent* event) = 0; - bool GetLocation(PP_Rect* location); - void SetLocation(const PP_Rect* location); + // PPB_WidgetAPI implementation. + virtual PP_Bool Paint(const PP_Rect* rect, PP_Resource ) OVERRIDE; + virtual PP_Bool HandleEvent(const PP_InputEvent* event) = 0; + virtual PP_Bool GetLocation(PP_Rect* location) OVERRIDE; + virtual void SetLocation(const PP_Rect* location) OVERRIDE; // Notifies the plugin instance that the given rect needs to be repainted. void Invalidate(const PP_Rect* dirty); protected: + virtual PP_Bool PaintInternal(const gfx::Rect& rect, + PPB_ImageData_Impl* image) = 0; virtual void SetLocationInternal(const PP_Rect* location) = 0; + PP_Rect location() const { return location_; } private: diff --git a/webkit/plugins/ppapi/resource.h b/webkit/plugins/ppapi/resource.h index 0d0b151..54af4c1 100644 --- a/webkit/plugins/ppapi/resource.h +++ b/webkit/plugins/ppapi/resource.h @@ -14,35 +14,11 @@ namespace webkit { namespace ppapi { -// If you inherit from resource, make sure you add the class name here. +// Support the old way of doing resource casts for those resources that have +// not been converted to the new system. #define FOR_ALL_RESOURCES(F) \ F(MockResource) \ - F(PPB_AudioConfig_Impl) \ - F(PPB_Audio_Impl) \ - F(PPB_Broker_Impl) \ - F(PPB_Buffer_Impl) \ - F(PPB_Context3D_Impl) \ - F(PPB_DirectoryReader_Impl) \ - F(PPB_FileChooser_Impl) \ - F(PPB_FileIO_Impl) \ - F(PPB_FileRef_Impl) \ - F(PPB_FileSystem_Impl) \ - F(PPB_Flash_Menu_Impl) \ - F(PPB_Flash_NetConnector_Impl) \ - F(PPB_Font_Impl) \ - F(PPB_Graphics2D_Impl) \ - F(PPB_Graphics3D_Impl) \ - F(PPB_ImageData_Impl) \ - F(PPB_LayerCompositor_Impl) \ - F(PPB_Scrollbar_Impl) \ - F(PPB_Surface3D_Impl) \ - F(PPB_Transport_Impl) \ - F(PPB_URLLoader_Impl) \ - F(PPB_URLRequestInfo_Impl) \ - F(PPB_URLResponseInfo_Impl) \ - F(PPB_VideoDecoder_Impl) \ - F(PPB_VideoLayer_Impl) \ - F(PPB_Widget_Impl) + F(PPB_Scrollbar_Impl) // Forward declaration of Resource classes. #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE; diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc index fe9588e..fd67df5 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.cc +++ b/webkit/plugins/ppapi/resource_creation_impl.cc @@ -10,6 +10,7 @@ #include "webkit/plugins/ppapi/ppb_audio_impl.h" #include "webkit/plugins/ppapi/ppb_broker_impl.h" #include "webkit/plugins/ppapi/ppb_buffer_impl.h" +#include "webkit/plugins/ppapi/ppb_context_3d_impl.h" #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" #include "webkit/plugins/ppapi/ppb_file_chooser_impl.h" #include "webkit/plugins/ppapi/ppb_file_io_impl.h" @@ -19,8 +20,10 @@ #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" #include "webkit/plugins/ppapi/ppb_font_impl.h" #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" +#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" #include "webkit/plugins/ppapi/ppb_image_data_impl.h" #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h" +#include "webkit/plugins/ppapi/ppb_transport_impl.h" #include "webkit/plugins/ppapi/ppb_url_loader_impl.h" #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" @@ -87,6 +90,24 @@ PP_Resource ResourceCreationImpl::CreateBuffer(PP_Instance instance, return PPB_Buffer_Impl::Create(instance, size); } +PP_Resource ResourceCreationImpl::CreateContext3D( + PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { + return PPB_Context3D_Impl::Create(instance, config, share_context, + attrib_list); +} + +PP_Resource ResourceCreationImpl::CreateContext3DRaw( + PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { + return PPB_Context3D_Impl::CreateRaw(instance, config, share_context, + attrib_list); +} + PP_Resource ResourceCreationImpl::CreateDirectoryReader( PP_Resource directory_ref) { return PPB_DirectoryReader_Impl::Create(directory_ref); @@ -155,6 +176,15 @@ PP_Resource ResourceCreationImpl::CreateGraphics2D( return graphics_2d->GetReference(); } +PP_Resource ResourceCreationImpl::CreateGraphics3D( + PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) { + return PPB_Graphics3D_Impl::Create(instance_, config, share_context, + attrib_list); +} + PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance pp_instance, PP_ImageDataFormat format, const PP_Size& size, @@ -177,6 +207,12 @@ PP_Resource ResourceCreationImpl::CreateSurface3D( return 0; } +PP_Resource ResourceCreationImpl::CreateTransport(PP_Instance instance, + const char* name, + const char* proto) { + return PPB_Transport_Impl::Create(instance_, name, proto); +} + PP_Resource ResourceCreationImpl::CreateURLLoader(PP_Instance instance) { return PPB_URLLoader_Impl::Create(instance); } diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h index 7d39a7e1..9f78f39 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.h +++ b/webkit/plugins/ppapi/resource_creation_impl.h @@ -36,6 +36,14 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase, virtual PP_Resource CreateBroker(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateBuffer(PP_Instance instance, uint32_t size) OVERRIDE; + virtual PP_Resource CreateContext3D(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) OVERRIDE; + virtual PP_Resource CreateContext3DRaw(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) OVERRIDE; virtual PP_Resource CreateDirectoryReader(PP_Resource directory_ref) OVERRIDE; virtual PP_Resource CreateFileChooser( PP_Instance instance, @@ -54,6 +62,10 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase, virtual PP_Resource CreateGraphics2D(PP_Instance pp_instance, const PP_Size& size, PP_Bool is_always_opaque) OVERRIDE; + virtual PP_Resource CreateGraphics3D(PP_Instance instance, + PP_Config3D_Dev config, + PP_Resource share_context, + const int32_t* attrib_list) OVERRIDE; virtual PP_Resource CreateImageData(PP_Instance instance, PP_ImageDataFormat format, const PP_Size& size, @@ -61,6 +73,9 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase, virtual PP_Resource CreateSurface3D(PP_Instance instance, PP_Config3D_Dev config, const int32_t* attrib_list) OVERRIDE; + virtual PP_Resource CreateTransport(PP_Instance instance, + const char* name, + const char* proto) OVERRIDE; virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateURLRequestInfo(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateVideoDecoder(PP_Instance instance) OVERRIDE; |