diff --git a/chrome/renderer/pepper/pepper_pdf_host.cc b/chrome/renderer/pepper/pepper_pdf_host.cc index 4bacddb8be33d0..66af0902e8017a 100644 --- a/chrome/renderer/pepper/pepper_pdf_host.cc +++ b/chrome/renderer/pepper/pepper_pdf_host.cc @@ -382,7 +382,7 @@ bool PepperPDFHost::CreateImageData( return false; PP_Resource resource = enter.functions()->CreateImageData(instance, format, - size, PP_FALSE); + &size, PP_FALSE); if (!resource) return false; result->SetHostResource(instance, resource); diff --git a/ppapi/api/ppb_image_data.idl b/ppapi/api/ppb_image_data.idl index 4934f796be41b8..8e1d09dc2634a4 100644 --- a/ppapi/api/ppb_image_data.idl +++ b/ppapi/api/ppb_image_data.idl @@ -8,9 +8,11 @@ * a browser handles image data. */ - label Chrome { - M14 = 1.0 - }; +[generate_thunk] + +label Chrome { + M14 = 1.0 +}; /** * PP_ImageDataFormat is an enumeration of the different types of @@ -157,6 +159,7 @@ interface PPB_ImageData { * PP_FALSE, the desc structure will be filled * with 0. */ + [always_set_output_parameters] PP_Bool Describe( [in] PP_Resource image_data, [out] PP_ImageDataDesc desc); diff --git a/ppapi/generators/idl_thunk.py b/ppapi/generators/idl_thunk.py index 11fa736023ed57..6c28c9a24e3e1b 100755 --- a/ppapi/generators/idl_thunk.py +++ b/ppapi/generators/idl_thunk.py @@ -90,9 +90,8 @@ def _GetThunkFileName(filenode, relpath): return name -def _AddApiHeader(filenode, meta): - """Adds an API header for the given file to the ThunkBodyMetadata.""" - # The API header matches the file name, not the interface name. +def _StripFileName(filenode): + """Strips path and dev, trusted, and private suffixes from the file name.""" api_basename = _GetBaseFileName(filenode) if api_basename.endswith('_dev'): api_basename = api_basename[:-len('_dev')] @@ -100,20 +99,24 @@ def _AddApiHeader(filenode, meta): api_basename = api_basename[:-len('_trusted')] if api_basename.endswith('_private'): api_basename = api_basename[:-len('_private')] - meta.AddApi(api_basename + '_api') + return api_basename -def _MakeEnterLine(filenode, interface, member, arg, handle_errors, callback, - meta): - """Returns an EnterInstance/EnterResource string for a function.""" - api_name = interface.GetName() +def _StripApiName(api_name): + """Strips Dev, Private, and Trusted suffixes from the API name.""" if api_name.endswith('Trusted'): api_name = api_name[:-len('Trusted')] if api_name.endswith('_Dev'): api_name = api_name[:-len('_Dev')] if api_name.endswith('_Private'): api_name = api_name[:-len('_Private')] - api_name += '_API' + return api_name + + +def _MakeEnterLine(filenode, interface, member, arg, handle_errors, callback, + meta): + """Returns an EnterInstance/EnterResource string for a function.""" + api_name = _StripApiName(interface.GetName()) + '_API' if member.GetProperty('api'): # Override API name. manually_provided_api = True # TODO(teravest): Automatically guess the API header file. @@ -128,14 +131,14 @@ def _MakeEnterLine(filenode, interface, member, arg, handle_errors, callback, arg_string = '%s, %s' % (arg[1], callback) if interface.GetProperty('singleton') or member.GetProperty('singleton'): if not manually_provided_api: - _AddApiHeader(filenode, meta) + meta.AddApi('ppapi/thunk/%s_api.h' % _StripFileName(filenode)) return 'EnterInstanceAPI<%s> enter(%s);' % (api_name, arg_string) else: return 'EnterInstance enter(%s);' % arg_string elif arg[0] == 'PP_Resource': enter_type = 'EnterResource<%s>' % api_name if not manually_provided_api: - _AddApiHeader(filenode, meta) + meta.AddApi('ppapi/thunk/%s_api.h' % _StripFileName(filenode)) if callback is None: return '%s enter(%s, %s);' % (enter_type, arg[1], str(handle_errors).lower()) @@ -180,6 +183,7 @@ def _GetDefaultFailureValue(t): 'uint16_t': '0', 'uint32_t': '0', 'uint64_t': '0', + 'void*': 'NULL' } if t in values: return values[t] @@ -256,6 +260,14 @@ def _MakeNormalMemberBody(filenode, release, node, member, rtype, args, include_version - whether to include the version in the invocation meta - ThunkBodyMetadata for header hints """ + if len(args) == 0: + # Calling into the "Shared" code for the interface seems like a reasonable + # heuristic when we don't have any arguments; some thunk code follows this + # convention today. + meta.AddApi('ppapi/shared_impl/%s_shared.h' % _StripFileName(filenode)) + return 'return %s::%s();' % (_StripApiName(node.GetName()) + '_Shared', + member.GetName()) + is_callback_func = args[len(args) - 1][0] == 'struct PP_CompletionCallback' if is_callback_func: @@ -267,9 +279,17 @@ def _MakeNormalMemberBody(filenode, release, node, member, rtype, args, if args[0][0] == 'PP_Instance': call_arglist = ', '.join(a[1] for a in call_args) function_container = 'functions' - else: + elif args[0][0] == 'PP_Resource': call_arglist = ', '.join(a[1] for a in call_args[1:]) function_container = 'object' + else: + # Calling into the "Shared" code for the interface seems like a reasonable + # heuristic when the first argument isn't a PP_Instance or a PP_Resource; + # some thunk code follows this convention today. + meta.AddApi('ppapi/shared_impl/%s_shared.h' % _StripFileName(filenode)) + return 'return %s::%s(%s);' % (_StripApiName(node.GetName()) + '_Shared', + member.GetName(), + ', '.join(a[1] for a in args)) function_name = member.GetName() if include_version: @@ -443,7 +463,7 @@ def WriteHead(self, out, filenode, releases, options, meta): 'ppapi/thunk/thunk.h'] includes.append(_GetHeaderFileName(filenode)) for api in meta.Apis(): - includes.append('ppapi/thunk/%s.h' % api.lower()) + includes.append('%s' % api.lower()) for i in meta.Includes(): includes.append(i) for include in sorted(includes): diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc index 02628551cd212a..bd9c7560471c9d 100644 --- a/ppapi/proxy/ppb_image_data_proxy.cc +++ b/ppapi/proxy/ppb_image_data_proxy.cc @@ -533,7 +533,7 @@ void PPB_ImageData_Proxy::OnHostMsgCreate(PP_Instance instance, return; PP_Resource resource = enter.functions()->CreateImageData( - instance, static_cast(format), size, init_to_zero); + instance, static_cast(format), &size, init_to_zero); if (!resource) return; result->SetHostResource(instance, resource); @@ -577,7 +577,7 @@ void PPB_ImageData_Proxy::OnHostMsgCreateNaCl( return; PP_Resource resource = enter.functions()->CreateImageDataNaCl( - instance, static_cast(format), size, init_to_zero); + instance, static_cast(format), &size, init_to_zero); if (!resource) return; result->SetHostResource(instance, resource); diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 2aaed0703d7382..74f907cf571f91 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -256,16 +256,16 @@ PP_Resource ResourceCreationProxy::CreateHostResolverPrivate( PP_Resource ResourceCreationProxy::CreateImageData(PP_Instance instance, PP_ImageDataFormat format, - const PP_Size& size, + const PP_Size* size, PP_Bool init_to_zero) { - return PPB_ImageData_Proxy::CreateProxyResource(instance, format, size, + return PPB_ImageData_Proxy::CreateProxyResource(instance, format, *size, init_to_zero); } PP_Resource ResourceCreationProxy::CreateImageDataNaCl( PP_Instance instance, PP_ImageDataFormat format, - const PP_Size& size, + const PP_Size* size, PP_Bool init_to_zero) { // These really only are different on the host side. On the plugin side, we // always request a "platform" ImageData if we're trusted, or a "NaCl" one diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index fa7fe5a3f5c098..85f2ddd4dbf4d0 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -120,11 +120,11 @@ class ResourceCreationProxy : public InterfaceProxy, virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateImageData(PP_Instance instance, PP_ImageDataFormat format, - const PP_Size& size, + const PP_Size* size, PP_Bool init_to_zero) OVERRIDE; virtual PP_Resource CreateImageDataNaCl(PP_Instance instance, PP_ImageDataFormat format, - const PP_Size& size, + const PP_Size* size, PP_Bool init_to_zero) OVERRIDE; virtual PP_Resource CreateNetworkMonitor( PP_Instance instance, diff --git a/ppapi/shared_impl/ppb_image_data_shared.cc b/ppapi/shared_impl/ppb_image_data_shared.cc index abdea60e270f63..4201a1ed19e0c1 100644 --- a/ppapi/shared_impl/ppb_image_data_shared.cc +++ b/ppapi/shared_impl/ppb_image_data_shared.cc @@ -36,10 +36,10 @@ PP_ImageDataFormat PPB_ImageData_Shared::GetNativeImageDataFormat() { } // static -bool PPB_ImageData_Shared::IsImageDataFormatSupported( +PP_Bool PPB_ImageData_Shared::IsImageDataFormatSupported( PP_ImageDataFormat format) { - return format == PP_IMAGEDATAFORMAT_BGRA_PREMUL || - format == PP_IMAGEDATAFORMAT_RGBA_PREMUL; + return PP_FromBool(format == PP_IMAGEDATAFORMAT_BGRA_PREMUL || + format == PP_IMAGEDATAFORMAT_RGBA_PREMUL); } } // namespace ppapi diff --git a/ppapi/shared_impl/ppb_image_data_shared.h b/ppapi/shared_impl/ppb_image_data_shared.h index 4f9a4d5f2b1450..0f1f4bbaa584ec 100644 --- a/ppapi/shared_impl/ppb_image_data_shared.h +++ b/ppapi/shared_impl/ppb_image_data_shared.h @@ -23,7 +23,7 @@ namespace ppapi { class PPAPI_SHARED_EXPORT PPB_ImageData_Shared { public: static PP_ImageDataFormat GetNativeImageDataFormat(); - static bool IsImageDataFormatSupported(PP_ImageDataFormat format); + static PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format); }; } // namespace ppapi diff --git a/ppapi/thunk/ppb_image_data_thunk.cc b/ppapi/thunk/ppb_image_data_thunk.cc index f50842e87a7e8c..d26904a985c762 100644 --- a/ppapi/thunk/ppb_image_data_thunk.cc +++ b/ppapi/thunk/ppb_image_data_thunk.cc @@ -2,11 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// From ppb_image_data.idl modified Thu Apr 25 14:42:27 2013. + +#include + #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_image_data.h" #include "ppapi/shared_impl/ppb_image_data_shared.h" +#include "ppapi/shared_impl/tracked_callback.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_image_data_api.h" +#include "ppapi/thunk/ppb_instance_api.h" #include "ppapi/thunk/resource_creation_api.h" #include "ppapi/thunk/thunk.h" @@ -15,69 +21,76 @@ namespace thunk { namespace { -PP_ImageDataFormat GetNativeImageDataFormat() { - return ppapi::PPB_ImageData_Shared::GetNativeImageDataFormat(); +PP_ImageDataFormat GetNativeImageDataFormat(void) { + VLOG(4) << "PPB_ImageData::GetNativeImageDataFormat()"; + return PPB_ImageData_Shared::GetNativeImageDataFormat(); } PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format) { - return ppapi::PPB_ImageData_Shared::IsImageDataFormatSupported(format) - ? PP_TRUE : PP_FALSE; + VLOG(4) << "PPB_ImageData::IsImageDataFormatSupported()"; + return PPB_ImageData_Shared::IsImageDataFormatSupported(format); } PP_Resource Create(PP_Instance instance, PP_ImageDataFormat format, - const PP_Size* size, + const struct PP_Size* size, PP_Bool init_to_zero) { + VLOG(4) << "PPB_ImageData::Create()"; EnterResourceCreation enter(instance); if (enter.failed()) return 0; - return enter.functions()->CreateImageData(instance, format, - *size, init_to_zero); + return enter.functions()->CreateImageData(instance, + format, + size, + init_to_zero); } -PP_Bool IsImageData(PP_Resource resource) { - EnterResource enter(resource, false); - return enter.succeeded() ? PP_TRUE : PP_FALSE; +PP_Bool IsImageData(PP_Resource image_data) { + VLOG(4) << "PPB_ImageData::IsImageData()"; + EnterResource enter(image_data, false); + return PP_FromBool(enter.succeeded()); } -PP_Bool Describe(PP_Resource resource, PP_ImageDataDesc* desc) { - // Give predictable values on failure. - memset(desc, 0, sizeof(PP_ImageDataDesc)); - - EnterResource enter(resource, true); - if (enter.failed()) +PP_Bool Describe(PP_Resource image_data, struct PP_ImageDataDesc* desc) { + VLOG(4) << "PPB_ImageData::Describe()"; + EnterResource enter(image_data, true); + if (enter.failed()) { + memset(desc, 0, sizeof(*desc)); return PP_FALSE; + } return enter.object()->Describe(desc); } -void* Map(PP_Resource resource) { - EnterResource enter(resource, true); +void* Map(PP_Resource image_data) { + VLOG(4) << "PPB_ImageData::Map()"; + EnterResource enter(image_data, true); if (enter.failed()) return NULL; return enter.object()->Map(); } -void Unmap(PP_Resource resource) { - EnterResource enter(resource, true); +void Unmap(PP_Resource image_data) { + VLOG(4) << "PPB_ImageData::Unmap()"; + EnterResource enter(image_data, true); if (enter.failed()) return; enter.object()->Unmap(); } -const PPB_ImageData g_ppb_image_data_thunk = { +const PPB_ImageData_1_0 g_ppb_imagedata_thunk_1_0 = { &GetNativeImageDataFormat, &IsImageDataFormatSupported, &Create, &IsImageData, &Describe, &Map, - &Unmap, + &Unmap }; } // namespace const PPB_ImageData_1_0* GetPPB_ImageData_1_0_Thunk() { - return &g_ppb_image_data_thunk; + return &g_ppb_imagedata_thunk_1_0; } } // namespace thunk diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index cd9a8ffd31560c..1a4713e9f2b67f 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -130,11 +130,11 @@ class ResourceCreationAPI { virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) = 0; virtual PP_Resource CreateImageData(PP_Instance instance, PP_ImageDataFormat format, - const PP_Size& size, + const PP_Size* size, PP_Bool init_to_zero) = 0; virtual PP_Resource CreateImageDataNaCl(PP_Instance instance, PP_ImageDataFormat format, - const PP_Size& size, + const PP_Size* size, PP_Bool init_to_zero) = 0; virtual PP_Resource CreateNetworkMonitor( PP_Instance instance, diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc index b6af9761ceb278..d2bf5c3833b924 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.cc +++ b/webkit/plugins/ppapi/resource_creation_impl.cc @@ -132,17 +132,17 @@ PP_Resource ResourceCreationImpl::CreateHostResolverPrivate( PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance instance, PP_ImageDataFormat format, - const PP_Size& size, + const PP_Size* size, PP_Bool init_to_zero) { - return PPB_ImageData_Impl::CreatePlatform(instance, format, size, + return PPB_ImageData_Impl::CreatePlatform(instance, format, *size, init_to_zero); } PP_Resource ResourceCreationImpl::CreateImageDataNaCl(PP_Instance instance, PP_ImageDataFormat format, - const PP_Size& size, + const PP_Size* size, PP_Bool init_to_zero) { - return PPB_ImageData_Impl::CreateNaCl(instance, format, size, init_to_zero); + return PPB_ImageData_Impl::CreateNaCl(instance, format, *size, init_to_zero); } PP_Resource ResourceCreationImpl::CreateIMEInputEvent( diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h index fde180bc18439e..db42e7af513baf 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.h +++ b/webkit/plugins/ppapi/resource_creation_impl.h @@ -56,11 +56,11 @@ class WEBKIT_PLUGINS_EXPORT ResourceCreationImpl virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateImageData(PP_Instance instance, PP_ImageDataFormat format, - const PP_Size& size, + const PP_Size* size, PP_Bool init_to_zero) OVERRIDE; virtual PP_Resource CreateImageDataNaCl(PP_Instance instance, PP_ImageDataFormat format, - const PP_Size& size, + const PP_Size* size, PP_Bool init_to_zero) OVERRIDE; virtual PP_Resource CreateIMEInputEvent(PP_Instance instance, PP_InputEvent_Type type,