diff options
author | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-12 00:18:13 +0000 |
---|---|---|
committer | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-12 00:18:13 +0000 |
commit | 4e1b91e07236c42f35c24029064aac623722d536 (patch) | |
tree | b3b9da25061a740e45f6964e3a074b82a82d8883 | |
parent | b54c253e8aa966ee9ef5c053096e1d45cfd21ae5 (diff) | |
download | chromium_src-4e1b91e07236c42f35c24029064aac623722d536.zip chromium_src-4e1b91e07236c42f35c24029064aac623722d536.tar.gz chromium_src-4e1b91e07236c42f35c24029064aac623722d536.tar.bz2 |
Clean up Pepper ImageData resource class.
-This change introduces an abstract ImageData class, and two subclasses.
-PlatformImageData allows access to the platform-specific canvas and handles.
-SimpleImageData is platform independent, suitable for use in the NaCl proxy.
-Also changes ImageData creation messages to use PP_ImageDataDesc instead of
serializing to std::string.
-Remove NaCl-isms in naming.
BUG=230980
Review URL: https://chromiumcodereview.appspot.com/16605006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205681 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/pepper/pepper_pdf_host.cc | 2 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_video_source_host.cc | 2 | ||||
-rw-r--r-- | ppapi/proxy/handle_converter.cc | 2 | ||||
-rw-r--r-- | ppapi/proxy/pdf_resource.cc | 4 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 8 | ||||
-rw-r--r-- | ppapi/proxy/ppb_image_data_proxy.cc | 293 | ||||
-rw-r--r-- | ppapi/proxy/ppb_image_data_proxy.h | 136 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.cc | 17 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.h | 5 | ||||
-rw-r--r-- | ppapi/proxy/video_source_resource.cc | 5 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_image_data_shared.h | 12 | ||||
-rw-r--r-- | ppapi/thunk/ppb_image_data_thunk.cc | 5 | ||||
-rw-r--r-- | ppapi/thunk/resource_creation_api.h | 6 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_image_data_impl.cc | 63 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_image_data_impl.h | 34 | ||||
-rw-r--r-- | webkit/plugins/ppapi/resource_creation_impl.cc | 21 | ||||
-rw-r--r-- | webkit/plugins/ppapi/resource_creation_impl.h | 14 |
17 files changed, 331 insertions, 298 deletions
diff --git a/chrome/renderer/pepper/pepper_pdf_host.cc b/chrome/renderer/pepper/pepper_pdf_host.cc index eecdea6..58b725e 100644 --- a/chrome/renderer/pepper/pepper_pdf_host.cc +++ b/chrome/renderer/pepper/pepper_pdf_host.cc @@ -363,9 +363,9 @@ bool PepperPDFHost::CreateImageData( uint32_t* out_byte_count) { PP_Resource resource = ppapi::proxy::PPB_ImageData_Proxy::CreateImageData( instance, + ppapi::PPB_ImageData_Shared::PLATFORM, format, size, false /* init_to_zero */, - false /* is_nacl_plugin */, out_image_data_desc, out_image_handle, out_byte_count); if (!resource) return false; diff --git a/content/renderer/pepper/pepper_video_source_host.cc b/content/renderer/pepper/pepper_video_source_host.cc index 47b5033..1bde2cc 100644 --- a/content/renderer/pepper/pepper_video_source_host.cc +++ b/content/renderer/pepper/pepper_video_source_host.cc @@ -145,10 +145,10 @@ void PepperVideoSourceHost::SendGetFrameReply() { ppapi::ScopedPPResource::PassRef(), ppapi::proxy::PPB_ImageData_Proxy::CreateImageData( pp_instance(), + ppapi::PPB_ImageData_Shared::PLATFORM, PP_IMAGEDATAFORMAT_BGRA_PREMUL, PP_MakeSize(width, height), false /* init_to_zero */, - false /* is_nacl_plugin */, &image_desc, &image_handle, &byte_count)); if (!resource.get()) { SendGetFrameErrorReply(PP_ERROR_FAILED); diff --git a/ppapi/proxy/handle_converter.cc b/ppapi/proxy/handle_converter.cc index 4c7d282..b77ee49 100644 --- a/ppapi/proxy/handle_converter.cc +++ b/ppapi/proxy/handle_converter.cc @@ -259,7 +259,7 @@ bool HandleConverter::ConvertNativeHandlesToPosix( pending_sync_msgs_.erase(iter); switch (type) { CASE_FOR_REPLY(PpapiHostMsg_PPBGraphics3D_GetTransferBuffer) - CASE_FOR_REPLY(PpapiHostMsg_PPBImageData_CreateNaCl) + CASE_FOR_REPLY(PpapiHostMsg_PPBImageData_CreateSimple) CASE_FOR_REPLY(PpapiHostMsg_ResourceSyncCall) CASE_FOR_REPLY(PpapiHostMsg_SharedMemory_CreateSharedMemory) default: diff --git a/ppapi/proxy/pdf_resource.cc b/ppapi/proxy/pdf_resource.cc index 3da1070..474cfd8 100644 --- a/ppapi/proxy/pdf_resource.cc +++ b/ppapi/proxy/pdf_resource.cc @@ -183,12 +183,12 @@ PP_Resource PDFResource::GetResourceImageForScale(PP_ResourceImage image_id, // This is compiled into android for tests only. return 0; #elif defined(TOOLKIT_GTK) - return (new ImageData(resource, image_desc, fd))->GetReference(); + return (new PlatformImageData(resource, image_desc, fd))->GetReference(); #elif defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MACOSX) base::SharedMemoryHandle handle; if (!reply_params.TakeSharedMemoryHandleAtIndex(0, &handle)) return 0; - return (new ImageData(resource, image_desc, handle))->GetReference(); + return (new PlatformImageData(resource, image_desc, handle))->GetReference(); #else #error Not implemented. #endif diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 382ec7a..cbe45e20 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -880,21 +880,21 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBGraphics3D_InsertSyncPoint, uint32 /* sync_point */) // PPB_ImageData. -IPC_SYNC_MESSAGE_ROUTED4_3(PpapiHostMsg_PPBImageData_Create, +IPC_SYNC_MESSAGE_ROUTED4_3(PpapiHostMsg_PPBImageData_CreatePlatform, PP_Instance /* instance */, int32 /* format */, PP_Size /* size */, PP_Bool /* init_to_zero */, ppapi::HostResource /* result_resource */, - std::string /* image_data_desc */, + PP_ImageDataDesc /* image_data_desc */, ppapi::proxy::ImageHandle /* result */) -IPC_SYNC_MESSAGE_ROUTED4_3(PpapiHostMsg_PPBImageData_CreateNaCl, +IPC_SYNC_MESSAGE_ROUTED4_3(PpapiHostMsg_PPBImageData_CreateSimple, PP_Instance /* instance */, int32 /* format */, PP_Size /* size */, PP_Bool /* init_to_zero */, ppapi::HostResource /* result_resource */, - std::string /* image_data_desc */, + PP_ImageDataDesc /* image_data_desc */, ppapi::proxy::SerializedHandle /* result */) // PPB_Instance. diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc index 999ab81..ce7d548 100644 --- a/ppapi/proxy/ppb_image_data_proxy.cc +++ b/ppapi/proxy/ppb_image_data_proxy.cc @@ -120,7 +120,8 @@ class ImageDataInstanceCache { ImageDataInstanceCache() : next_insertion_point_(0) {} // These functions have the same spec as the ones in ImageDataCache. - scoped_refptr<ImageData> Get(int width, int height, + scoped_refptr<ImageData> Get(PPB_ImageData_Shared::ImageDataType type, + int width, int height, PP_ImageDataFormat format); void Add(ImageData* image_data); void ImageDataUsable(ImageData* image_data); @@ -142,12 +143,15 @@ class ImageDataInstanceCache { }; scoped_refptr<ImageData> ImageDataInstanceCache::Get( + PPB_ImageData_Shared::ImageDataType type, int width, int height, PP_ImageDataFormat format) { // Just do a brute-force search since the cache is so small. for (int i = 0; i < kCacheSize; i++) { if (!images_[i].usable) continue; + if (!images_[i].image->type() == type) + continue; const PP_ImageDataDesc& desc = images_[i].image->desc(); if (desc.format == format && desc.size.width == width && desc.size.height == height) { @@ -223,9 +227,10 @@ class ImageDataCache { static ImageDataCache* GetInstance(); - // Retrieves an image data from the cache of the specified size and format if - // one exists. If one doesn't exist, this will return a null refptr. + // Retrieves an image data from the cache of the specified type, size and + // format if one exists. If one doesn't exist, this will return a null refptr. scoped_refptr<ImageData> Get(PP_Instance instance, + PPB_ImageData_Shared::ImageDataType type, int width, int height, PP_ImageDataFormat format); @@ -262,13 +267,15 @@ ImageDataCache* ImageDataCache::GetInstance() { LeakySingletonTraits<ImageDataCache> >::get(); } -scoped_refptr<ImageData> ImageDataCache::Get(PP_Instance instance, - int width, int height, - PP_ImageDataFormat format) { +scoped_refptr<ImageData> ImageDataCache::Get( + PP_Instance instance, + PPB_ImageData_Shared::ImageDataType type, + int width, int height, + PP_ImageDataFormat format) { CacheMap::iterator found = cache_.find(instance); if (found == cache_.end()) return scoped_refptr<ImageData>(); - return found->second.Get(width, height, format); + return found->second.Get(type, width, height, format); } void ImageDataCache::Add(ImageData* image_data) { @@ -307,32 +314,14 @@ void ImageDataCache::OnTimer(PP_Instance instance) { // ImageData ------------------------------------------------------------------- -#if !defined(OS_NACL) ImageData::ImageData(const HostResource& resource, - const PP_ImageDataDesc& desc, - ImageHandle handle) + PPB_ImageData_Shared::ImageDataType type, + const PP_ImageDataDesc& desc) : Resource(OBJECT_IS_PROXY, resource), + type_(type), desc_(desc), is_candidate_for_reuse_(false) { -#if defined(OS_WIN) - transport_dib_.reset(TransportDIB::CreateWithHandle(handle)); -#else - transport_dib_.reset(TransportDIB::Map(handle)); -#endif // defined(OS_WIN) } -#else // !defined(OS_NACL) - -ImageData::ImageData(const HostResource& resource, - const PP_ImageDataDesc& desc, - const base::SharedMemoryHandle& handle) - : Resource(OBJECT_IS_PROXY, resource), - desc_(desc), - shm_(handle, false /* read_only */), - size_(desc.size.width * desc.size.height * 4), - map_count_(0), - is_candidate_for_reuse_(false) { -} -#endif // else, !defined(OS_NACL) ImageData::~ImageData() { } @@ -358,12 +347,44 @@ PP_Bool ImageData::Describe(PP_ImageDataDesc* desc) { return PP_TRUE; } -void* ImageData::Map() { -#if defined(OS_NACL) - if (map_count_++ == 0) - shm_.Map(size_); - return shm_.memory(); +int32_t ImageData::GetSharedMemory(int* /* handle */, + uint32_t* /* byte_count */) { + // Not supported in the proxy (this method is for actually implementing the + // proxy in the host). + return PP_ERROR_NOACCESS; +} + +void ImageData::SetIsCandidateForReuse() { + is_candidate_for_reuse_ = true; +} + +void ImageData::RecycleToPlugin(bool zero_contents) { + is_candidate_for_reuse_ = false; + if (zero_contents) { + void* data = Map(); + memset(data, 0, desc_.stride * desc_.size.height); + Unmap(); + } +} + +// PlatformImageData ----------------------------------------------------------- + +#if !defined(OS_NACL) +PlatformImageData::PlatformImageData(const HostResource& resource, + const PP_ImageDataDesc& desc, + ImageHandle handle) + : ImageData(resource, PPB_ImageData_Shared::PLATFORM, desc) { +#if defined(OS_WIN) + transport_dib_.reset(TransportDIB::CreateWithHandle(handle)); #else + transport_dib_.reset(TransportDIB::Map(handle)); +#endif // defined(OS_WIN) +} + +PlatformImageData::~PlatformImageData() { +} + +void* PlatformImageData::Map() { if (!mapped_canvas_.get()) { mapped_canvas_.reset(transport_dib_->GetPlatformCanvas(desc_.size.width, desc_.size.height)); @@ -375,59 +396,24 @@ void* ImageData::Map() { bitmap.lockPixels(); return bitmap.getAddr(0, 0); -#endif } -void ImageData::Unmap() { -#if defined(OS_NACL) - if (--map_count_ == 0) - shm_.Unmap(); -#else +void PlatformImageData::Unmap() { // TODO(brettw) have a way to unmap a TransportDIB. Currently this isn't // possible since deleting the TransportDIB also frees all the handles. // We need to add a method to TransportDIB to release the handles. -#endif } -int32_t ImageData::GetSharedMemory(int* /* handle */, - uint32_t* /* byte_count */) { - // Not supported in the proxy (this method is for actually implementing the - // proxy in the host). - return PP_ERROR_NOACCESS; -} - -SkCanvas* ImageData::GetPlatformCanvas() { -#if defined(OS_NACL) - return NULL; // No canvas in NaCl. -#else +SkCanvas* PlatformImageData::GetPlatformCanvas() { return mapped_canvas_.get(); -#endif } -SkCanvas* ImageData::GetCanvas() { -#if defined(OS_NACL) - return NULL; // No canvas in NaCl. -#else +SkCanvas* PlatformImageData::GetCanvas() { return mapped_canvas_.get(); -#endif } -void ImageData::SetIsCandidateForReuse() { - is_candidate_for_reuse_ = true; -} - -void ImageData::RecycleToPlugin(bool zero_contents) { - is_candidate_for_reuse_ = false; - if (zero_contents) { - void* data = Map(); - memset(data, 0, desc_.stride * desc_.size.height); - Unmap(); - } -} - -#if !defined(OS_NACL) // static -ImageHandle ImageData::NullHandle() { +ImageHandle PlatformImageData::NullHandle() { #if defined(OS_WIN) return NULL; #elif defined(TOOLKIT_GTK) @@ -437,7 +423,7 @@ ImageHandle ImageData::NullHandle() { #endif } -ImageHandle ImageData::HandleFromInt(int32_t i) { +ImageHandle PlatformImageData::HandleFromInt(int32_t i) { #if defined(OS_WIN) return reinterpret_cast<ImageHandle>(i); #elif defined(TOOLKIT_GTK) @@ -448,6 +434,39 @@ ImageHandle ImageData::HandleFromInt(int32_t i) { } #endif // !defined(OS_NACL) +// SimpleImageData ------------------------------------------------------------- + +SimpleImageData::SimpleImageData(const HostResource& resource, + const PP_ImageDataDesc& desc, + const base::SharedMemoryHandle& handle) + : ImageData(resource, PPB_ImageData_Shared::SIMPLE, desc), + shm_(handle, false /* read_only */), + size_(desc.size.width * desc.size.height * 4), + map_count_(0) { +} + +SimpleImageData::~SimpleImageData() { +} + +void* SimpleImageData::Map() { + if (map_count_++ == 0) + shm_.Map(size_); + return shm_.memory(); +} + +void SimpleImageData::Unmap() { + if (--map_count_ == 0) + shm_.Unmap(); +} + +SkCanvas* SimpleImageData::GetPlatformCanvas() { + return NULL; // No canvas available. +} + +SkCanvas* SimpleImageData::GetCanvas() { + return NULL; // No canvas available. +} + // PPB_ImageData_Proxy --------------------------------------------------------- PPB_ImageData_Proxy::PPB_ImageData_Proxy(Dispatcher* dispatcher) @@ -458,18 +477,20 @@ PPB_ImageData_Proxy::~PPB_ImageData_Proxy() { } // static -PP_Resource PPB_ImageData_Proxy::CreateProxyResource(PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size& size, - PP_Bool init_to_zero) { +PP_Resource PPB_ImageData_Proxy::CreateProxyResource( + PP_Instance instance, + PPB_ImageData_Shared::ImageDataType type, + PP_ImageDataFormat format, + const PP_Size& size, + PP_Bool init_to_zero) { PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); if (!dispatcher) return 0; // Check the cache. scoped_refptr<ImageData> cached_image_data = - ImageDataCache::GetInstance()->Get(instance, size.width, size.height, - format); + ImageDataCache::GetInstance()->Get(instance, type, + size.width, size.height, format); if (cached_image_data.get()) { // We have one we can re-use rather than allocating a new one. cached_image_data->RecycleToPlugin(PP_ToBool(init_to_zero)); @@ -477,39 +498,49 @@ PP_Resource PPB_ImageData_Proxy::CreateProxyResource(PP_Instance instance, } HostResource result; - std::string image_data_desc; -#if defined(OS_NACL) - ppapi::proxy::SerializedHandle image_handle_wrapper; - dispatcher->Send(new PpapiHostMsg_PPBImageData_CreateNaCl( - kApiID, instance, format, size, init_to_zero, - &result, &image_data_desc, &image_handle_wrapper)); - if (!image_handle_wrapper.is_shmem()) - return 0; - base::SharedMemoryHandle image_handle = image_handle_wrapper.shmem(); + PP_ImageDataDesc desc; + switch (type) { + case PPB_ImageData_Shared::SIMPLE: { + ppapi::proxy::SerializedHandle image_handle_wrapper; + dispatcher->Send(new PpapiHostMsg_PPBImageData_CreateSimple( + kApiID, instance, format, size, init_to_zero, + &result, &desc, &image_handle_wrapper)); + if (image_handle_wrapper.is_shmem()) { + base::SharedMemoryHandle image_handle = image_handle_wrapper.shmem(); + if (!result.is_null()) + return + (new SimpleImageData(result, desc, image_handle))->GetReference(); + } + break; + } + case PPB_ImageData_Shared::PLATFORM: { +#if !defined(OS_NACL) + ImageHandle image_handle = PlatformImageData::NullHandle(); + dispatcher->Send(new PpapiHostMsg_PPBImageData_CreatePlatform( + kApiID, instance, format, size, init_to_zero, + &result, &desc, &image_handle)); + if (!result.is_null()) + return + (new PlatformImageData(result, desc, image_handle))->GetReference(); #else - ImageHandle image_handle = ImageData::NullHandle(); - dispatcher->Send(new PpapiHostMsg_PPBImageData_Create( - kApiID, instance, format, size, init_to_zero, - &result, &image_data_desc, &image_handle)); + // PlatformImageData shouldn't be created in untrusted code. + NOTREACHED(); #endif + break; + } + } - if (result.is_null() || image_data_desc.size() != sizeof(PP_ImageDataDesc)) - return 0; - - // We serialize the PP_ImageDataDesc just by copying to a string. - PP_ImageDataDesc desc; - memcpy(&desc, image_data_desc.data(), sizeof(PP_ImageDataDesc)); - - return (new ImageData(result, desc, image_handle))->GetReference(); + return 0; } bool PPB_ImageData_Proxy::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PPB_ImageData_Proxy, msg) #if !defined(OS_NACL) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBImageData_Create, OnHostMsgCreate) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBImageData_CreateNaCl, - OnHostMsgCreateNaCl) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBImageData_CreatePlatform, + OnHostMsgCreatePlatform) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBImageData_CreateSimple, + OnHostMsgCreateSimple) #endif IPC_MESSAGE_HANDLER(PpapiMsg_PPBImageData_NotifyUnusedImageData, OnPluginMsgNotifyUnusedImageData) @@ -523,10 +554,10 @@ bool PPB_ImageData_Proxy::OnMessageReceived(const IPC::Message& msg) { // static PP_Resource PPB_ImageData_Proxy::CreateImageData( PP_Instance instance, + PPB_ImageData_Shared::ImageDataType type, PP_ImageDataFormat format, const PP_Size& size, bool init_to_zero, - bool is_nacl_plugin, PP_ImageDataDesc* desc, IPC::PlatformFileForTransit* image_handle, uint32_t* byte_count) { @@ -541,11 +572,8 @@ PP_Resource PPB_ImageData_Proxy::CreateImageData( PP_Bool pp_init_to_zero = init_to_zero ? PP_TRUE : PP_FALSE; ppapi::ScopedPPResource resource( ppapi::ScopedPPResource::PassRef(), - is_nacl_plugin ? - enter.functions()->CreateImageDataNaCl(instance, format, &size, - pp_init_to_zero) : - enter.functions()->CreateImageData(instance, format, &size, - pp_init_to_zero)); + enter.functions()->CreateImageData(instance, type, + format, &size, pp_init_to_zero)); if (!resource.get()) return 0; @@ -567,11 +595,13 @@ PP_Resource PPB_ImageData_Proxy::CreateImageData( *image_handle = dispatcher->ShareHandleWithRemote( reinterpret_cast<HANDLE>(static_cast<intptr_t>(local_fd)), false); #elif defined(TOOLKIT_GTK) - // On X Windows, a non-nacl handle is a SysV shared memory key. - if (is_nacl_plugin) - *image_handle = dispatcher->ShareHandleWithRemote(local_fd, false); - else + // On X Windows, a PlatformImageData is backed by a SysV shared memory key, + // so embed that in a fake PlatformFileForTransit and don't share it across + // processes. + if (type == PPB_ImageData_Shared::PLATFORM) *image_handle = IPC::PlatformFileForTransit(local_fd, false); + else + *image_handle = dispatcher->ShareHandleWithRemote(local_fd, false); #elif defined(OS_POSIX) *image_handle = dispatcher->ShareHandleWithRemote(local_fd, false); #else @@ -581,27 +611,25 @@ PP_Resource PPB_ImageData_Proxy::CreateImageData( return resource.Release(); } -void PPB_ImageData_Proxy::OnHostMsgCreate(PP_Instance instance, - int32_t format, - const PP_Size& size, - PP_Bool init_to_zero, - HostResource* result, - std::string* image_data_desc, - ImageHandle* result_image_handle) { - PP_ImageDataDesc desc; +void PPB_ImageData_Proxy::OnHostMsgCreatePlatform( + PP_Instance instance, + int32_t format, + const PP_Size& size, + PP_Bool init_to_zero, + HostResource* result, + PP_ImageDataDesc* desc, + ImageHandle* result_image_handle) { IPC::PlatformFileForTransit image_handle; uint32_t byte_count; PP_Resource resource = CreateImageData(instance, + PPB_ImageData_Shared::PLATFORM, static_cast<PP_ImageDataFormat>(format), size, true /* init_to_zero */, - false /* is_nacl_plugin */, - &desc, &image_handle, &byte_count); + desc, &image_handle, &byte_count); result->SetHostResource(instance, resource); if (resource) { - image_data_desc->resize(sizeof(PP_ImageDataDesc)); - memcpy(&(*image_data_desc)[0], &desc, sizeof(PP_ImageDataDesc)); #if defined(TOOLKIT_GTK) // On X Windows ImageHandle is a SysV shared memory key. *result_image_handle = image_handle.fd; @@ -609,37 +637,32 @@ void PPB_ImageData_Proxy::OnHostMsgCreate(PP_Instance instance, *result_image_handle = image_handle; #endif } else { - image_data_desc->clear(); - *result_image_handle = ImageData::NullHandle(); + *result_image_handle = PlatformImageData::NullHandle(); } } -void PPB_ImageData_Proxy::OnHostMsgCreateNaCl( +void PPB_ImageData_Proxy::OnHostMsgCreateSimple( PP_Instance instance, int32_t format, const PP_Size& size, PP_Bool init_to_zero, HostResource* result, - std::string* image_data_desc, + PP_ImageDataDesc* desc, ppapi::proxy::SerializedHandle* result_image_handle) { - PP_ImageDataDesc desc; IPC::PlatformFileForTransit image_handle; uint32_t byte_count; PP_Resource resource = CreateImageData(instance, + PPB_ImageData_Shared::SIMPLE, static_cast<PP_ImageDataFormat>(format), size, true /* init_to_zero */, - true /* is_nacl_plugin */, - &desc, &image_handle, &byte_count); + desc, &image_handle, &byte_count); result->SetHostResource(instance, resource); if (resource) { - image_data_desc->resize(sizeof(PP_ImageDataDesc)); - memcpy(&(*image_data_desc)[0], &desc, sizeof(PP_ImageDataDesc)); result_image_handle->set_shmem(image_handle, byte_count); } else { - image_data_desc->clear(); result_image_handle->set_null_shmem(); } } diff --git a/ppapi/proxy/ppb_image_data_proxy.h b/ppapi/proxy/ppb_image_data_proxy.h index 2f2cd60..f85a7e4 100644 --- a/ppapi/proxy/ppb_image_data_proxy.h +++ b/ppapi/proxy/ppb_image_data_proxy.h @@ -31,26 +31,14 @@ namespace proxy { class SerializedHandle; -// The proxied image data resource. Unlike most resources, this needs to be -// public in the header since a number of other resources need to access it. +// ImageData is an abstract base class for image data resources. Unlike most +// resources, ImageData must be public in the header since a number of other +// resources need to access it. class PPAPI_PROXY_EXPORT ImageData : public ppapi::Resource, public NON_EXPORTED_BASE(ppapi::thunk::PPB_ImageData_API), public ppapi::PPB_ImageData_Shared { public: -#if !defined(OS_NACL) - ImageData(const ppapi::HostResource& resource, - const PP_ImageDataDesc& desc, - ImageHandle handle); -#else - // In NaCl, we only allow creating an ImageData using a SharedMemoryHandle. - // ImageHandle can differ by host platform. We need something that is - // more consistent across platforms for NaCl, so that we can communicate to - // the host OS in a consistent way. - ImageData(const ppapi::HostResource& resource, - const PP_ImageDataDesc& desc, - const base::SharedMemoryHandle& handle); -#endif virtual ~ImageData(); // Resource overrides. @@ -60,42 +48,82 @@ class PPAPI_PROXY_EXPORT ImageData // PPB_ImageData API. virtual PP_Bool Describe(PP_ImageDataDesc* desc) OVERRIDE; - virtual void* Map() OVERRIDE; - virtual void Unmap() OVERRIDE; virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE; - virtual SkCanvas* GetPlatformCanvas() OVERRIDE; - virtual SkCanvas* GetCanvas() OVERRIDE; virtual void SetIsCandidateForReuse() OVERRIDE; + PPB_ImageData_Shared::ImageDataType type() const { return type_; } const PP_ImageDataDesc& desc() const { return desc_; } - // Prepares this image data to be recycled to the plugin. The contents will be - // cleared if zero_contents is set. + // Prepares this image data to be recycled to the plugin. Clears the contents + // if zero_contents is true. void RecycleToPlugin(bool zero_contents); + protected: + ImageData(const ppapi::HostResource& resource, + PPB_ImageData_Shared::ImageDataType type, + const PP_ImageDataDesc& desc); + + PPB_ImageData_Shared::ImageDataType type_; + PP_ImageDataDesc desc_; + + // Set to true when this ImageData is a good candidate for reuse. + bool is_candidate_for_reuse_; + + DISALLOW_COPY_AND_ASSIGN(ImageData); +}; + +// PlatformImageData is a full featured image data resource which can access +// the underlying platform-specific canvas and ImageHandle. This can't be used +// by NaCl apps. #if !defined(OS_NACL) +class PPAPI_PROXY_EXPORT PlatformImageData : public ImageData { + public: + PlatformImageData(const ppapi::HostResource& resource, + const PP_ImageDataDesc& desc, + ImageHandle handle); + virtual ~PlatformImageData(); + + // PPB_ImageData API. + virtual void* Map() OVERRIDE; + virtual void Unmap() OVERRIDE; + virtual SkCanvas* GetPlatformCanvas() OVERRIDE; + virtual SkCanvas* GetCanvas() OVERRIDE; + static ImageHandle NullHandle(); static ImageHandle HandleFromInt(int32_t i); -#endif private: - PP_ImageDataDesc desc_; - -#if defined(OS_NACL) - base::SharedMemory shm_; - uint32 size_; - int map_count_; -#else scoped_ptr<TransportDIB> transport_dib_; // Null when the image isn't mapped. scoped_ptr<SkCanvas> mapped_canvas_; -#endif - // Set to true when this ImageData is a good candidate for reuse. - bool is_candidate_for_reuse_; + DISALLOW_COPY_AND_ASSIGN(PlatformImageData); +}; +#endif // !defined(OS_NACL) - DISALLOW_COPY_AND_ASSIGN(ImageData); +// SimpleImageData is a simple, platform-independent image data resource which +// can be used by NaCl. It can also be used by trusted apps when access to the +// platform canvas isn't needed. +class PPAPI_PROXY_EXPORT SimpleImageData : public ImageData { + public: + SimpleImageData(const ppapi::HostResource& resource, + const PP_ImageDataDesc& desc, + const base::SharedMemoryHandle& handle); + virtual ~SimpleImageData(); + + // PPB_ImageData API. + virtual void* Map() OVERRIDE; + virtual void Unmap() OVERRIDE; + virtual SkCanvas* GetPlatformCanvas() OVERRIDE; + virtual SkCanvas* GetCanvas() OVERRIDE; + + private: + base::SharedMemory shm_; + uint32 size_; + int map_count_; + + DISALLOW_COPY_AND_ASSIGN(SimpleImageData); }; class PPB_ImageData_Proxy : public InterfaceProxy { @@ -103,10 +131,12 @@ class PPB_ImageData_Proxy : public InterfaceProxy { PPB_ImageData_Proxy(Dispatcher* dispatcher); virtual ~PPB_ImageData_Proxy(); - static PP_Resource CreateProxyResource(PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size& size, - PP_Bool init_to_zero); + static PP_Resource CreateProxyResource( + PP_Instance instance, + PPB_ImageData_Shared::ImageDataType type, + PP_ImageDataFormat format, + const PP_Size& size, + PP_Bool init_to_zero); // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -121,10 +151,10 @@ class PPB_ImageData_Proxy : public InterfaceProxy { // to avoid leaking sensitive data to a less privileged process. PPAPI_PROXY_EXPORT static PP_Resource CreateImageData( PP_Instance instance, + PPB_ImageData_Shared::ImageDataType type, PP_ImageDataFormat format, const PP_Size& size, bool init_to_zero, - bool is_nacl_plugin, PP_ImageDataDesc* desc, IPC::PlatformFileForTransit* image_handle, uint32_t* byte_count); @@ -133,20 +163,22 @@ class PPB_ImageData_Proxy : public InterfaceProxy { private: // Plugin->Host message handlers. - void OnHostMsgCreate(PP_Instance instance, - int32_t format, - const PP_Size& size, - PP_Bool init_to_zero, - HostResource* result, - std::string* image_data_desc, - ImageHandle* result_image_handle); - void OnHostMsgCreateNaCl(PP_Instance instance, - int32_t format, - const PP_Size& size, - PP_Bool init_to_zero, - HostResource* result, - std::string* image_data_desc, - ppapi::proxy::SerializedHandle* result_image_handle); + void OnHostMsgCreatePlatform( + PP_Instance instance, + int32_t format, + const PP_Size& size, + PP_Bool init_to_zero, + HostResource* result, + PP_ImageDataDesc* desc, + ImageHandle* result_image_handle); + void OnHostMsgCreateSimple( + PP_Instance instance, + int32_t format, + const PP_Size& size, + PP_Bool init_to_zero, + HostResource* result, + PP_ImageDataDesc* desc, + ppapi::proxy::SerializedHandle* result_image_handle); // Host->Plugin message handlers. void OnPluginMsgNotifyUnusedImageData(const HostResource& old_image_data); diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index c157d07..3448ce7 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -254,23 +254,14 @@ PP_Resource ResourceCreationProxy::CreateHostResolverPrivate( GetConnection(), instance))->GetReference(); } -PP_Resource ResourceCreationProxy::CreateImageData(PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size* size, - PP_Bool init_to_zero) { - return PPB_ImageData_Proxy::CreateProxyResource(instance, format, *size, - init_to_zero); -} - -PP_Resource ResourceCreationProxy::CreateImageDataNaCl( +PP_Resource ResourceCreationProxy::CreateImageData( PP_Instance instance, + PPB_ImageData_Shared::ImageDataType type, PP_ImageDataFormat format, 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 - // if we're untrusted (see PPB_ImageData_Proxy::CreateProxyResource()). - return CreateImageData(instance, format, size, init_to_zero); + return PPB_ImageData_Proxy::CreateProxyResource(instance, type, + format, *size, init_to_zero); } PP_Resource ResourceCreationProxy::CreateNetAddressFromIPv4Address( diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index 485fe88..3dd514d 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -118,13 +118,10 @@ class ResourceCreationProxy : public InterfaceProxy, const int32_t* attrib_list) OVERRIDE; virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateImageData(PP_Instance instance, + PPB_ImageData_Shared::ImageDataType type, PP_ImageDataFormat format, const PP_Size* size, PP_Bool init_to_zero) OVERRIDE; - virtual PP_Resource CreateImageDataNaCl(PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size* size, - PP_Bool init_to_zero) OVERRIDE; virtual PP_Resource CreateNetAddressFromIPv4Address( PP_Instance instance, const PP_NetAddress_IPv4_Dev* ipv4_addr) OVERRIDE; diff --git a/ppapi/proxy/video_source_resource.cc b/ppapi/proxy/video_source_resource.cc index 0c3b192..f6c5fdc 100644 --- a/ppapi/proxy/video_source_resource.cc +++ b/ppapi/proxy/video_source_resource.cc @@ -111,13 +111,14 @@ void VideoSourceResource::OnPluginMsgGetFrameComplete( frame->image_data = 0; #elif defined(TOOLKIT_GTK) frame->image_data = - (new ImageData(image_data, image_desc, fd))->GetReference(); + (new PlatformImageData(image_data, image_desc, fd))->GetReference(); #elif defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MACOSX) base::SharedMemoryHandle handle; if (!reply_params.TakeSharedMemoryHandleAtIndex(0, &handle)) frame->image_data = 0; frame->image_data = - (new ImageData(image_data, image_desc, handle))->GetReference(); + (new PlatformImageData( + image_data, image_desc, handle))->GetReference(); #else #error Not implemented. #endif diff --git a/ppapi/shared_impl/ppb_image_data_shared.h b/ppapi/shared_impl/ppb_image_data_shared.h index 45cd875..6f0c19b 100644 --- a/ppapi/shared_impl/ppb_image_data_shared.h +++ b/ppapi/shared_impl/ppb_image_data_shared.h @@ -22,6 +22,18 @@ namespace ppapi { // settings. class PPAPI_SHARED_EXPORT PPB_ImageData_Shared { public: + enum ImageDataType { + // An ImageData backed by a PlatformCanvas. You must create this type if + // you intend the ImageData to be usable in platform-specific APIs (like + // font rendering or rendering widgets like scrollbars). This type is not + // available in untrusted (NaCl) plugins. + PLATFORM, + // An ImageData that doesn't need access to the platform-specific canvas. + // This is backed by a simple shared memory buffer. This is the only type + // of ImageData that can be used by untrusted (NaCl) plugins. + SIMPLE + }; + static PP_ImageDataFormat GetNativeImageDataFormat(); static PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format); static PP_Bool IsImageDataDescValid(const PP_ImageDataDesc& desc); diff --git a/ppapi/thunk/ppb_image_data_thunk.cc b/ppapi/thunk/ppb_image_data_thunk.cc index d26904a..b16c9c0 100644 --- a/ppapi/thunk/ppb_image_data_thunk.cc +++ b/ppapi/thunk/ppb_image_data_thunk.cc @@ -40,6 +40,11 @@ PP_Resource Create(PP_Instance instance, if (enter.failed()) return 0; return enter.functions()->CreateImageData(instance, +#if !defined(OS_NACL) + PPB_ImageData_Shared::PLATFORM, +#else + PPB_ImageData_Shared::SIMPLE, +#endif format, size, init_to_zero); diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index fb126bf..38b6d12 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -21,6 +21,7 @@ #include "ppapi/c/private/pp_private_font_charset.h" #include "ppapi/c/private/ppb_network_monitor_private.h" #include "ppapi/shared_impl/api_id.h" +#include "ppapi/shared_impl/ppb_image_data_shared.h" struct PP_Flash_Menu; struct PP_FontDescription_Dev; @@ -130,13 +131,10 @@ class ResourceCreationAPI { const int32_t* attrib_list) = 0; virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) = 0; virtual PP_Resource CreateImageData(PP_Instance instance, + PPB_ImageData_Shared::ImageDataType type, PP_ImageDataFormat format, const PP_Size* size, PP_Bool init_to_zero) = 0; - virtual PP_Resource CreateImageDataNaCl(PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size* size, - PP_Bool init_to_zero) = 0; virtual PP_Resource CreateNetAddressFromIPv4Address( PP_Instance instance, const PP_NetAddress_IPv4_Dev* ipv4_addr) = 0; diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.cc b/webkit/plugins/ppapi/ppb_image_data_impl.cc index 4913a06..631989c 100644 --- a/webkit/plugins/ppapi/ppb_image_data_impl.cc +++ b/webkit/plugins/ppapi/ppb_image_data_impl.cc @@ -25,17 +25,17 @@ namespace webkit { namespace ppapi { PPB_ImageData_Impl::PPB_ImageData_Impl(PP_Instance instance, - ImageDataType type) + PPB_ImageData_Shared::ImageDataType type) : Resource(::ppapi::OBJECT_IS_IMPL, instance), format_(PP_IMAGEDATAFORMAT_BGRA_PREMUL), width_(0), height_(0) { switch (type) { - case PLATFORM: + case PPB_ImageData_Shared::PLATFORM: backend_.reset(new ImageDataPlatformBackend); return; - case NACL: - backend_.reset(new ImageDataNaClBackend); + case PPB_ImageData_Shared::SIMPLE: + backend_.reset(new ImageDataSimpleBackend); return; // No default: so that we get a compiler warning if any types are added. } @@ -64,24 +64,13 @@ bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format, } // static -PP_Resource PPB_ImageData_Impl::CreatePlatform(PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size& size, - PP_Bool init_to_zero) { +PP_Resource PPB_ImageData_Impl::Create(PP_Instance instance, + PPB_ImageData_Shared::ImageDataType type, + PP_ImageDataFormat format, + const PP_Size& size, + PP_Bool init_to_zero) { scoped_refptr<PPB_ImageData_Impl> - data(new PPB_ImageData_Impl(instance, PLATFORM)); - if (!data->Init(format, size.width, size.height, !!init_to_zero)) - return 0; - return data->GetReference(); -} - -// static -PP_Resource PPB_ImageData_Impl::CreateNaCl(PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size& size, - PP_Bool init_to_zero) { - scoped_refptr<PPB_ImageData_Impl> - data(new PPB_ImageData_Impl(instance, NACL)); + data(new PPB_ImageData_Impl(instance, type)); if (!data->Init(format, size.width, size.height, !!init_to_zero)) return 0; return data->GetReference(); @@ -135,7 +124,7 @@ const SkBitmap* PPB_ImageData_Impl::GetMappedBitmap() const { return backend_->GetMappedBitmap(); } -// ImageDataPlatformBackend -------------------------------------------------- +// ImageDataPlatformBackend ---------------------------------------------------- ImageDataPlatformBackend::ImageDataPlatformBackend() { } @@ -208,19 +197,19 @@ const SkBitmap* ImageDataPlatformBackend::GetMappedBitmap() const { return &skia::GetTopDevice(*mapped_canvas_)->accessBitmap(false); } -// ImageDataNaClBackend ------------------------------------------------------ +// ImageDataSimpleBackend ------------------------------------------------------ -ImageDataNaClBackend::ImageDataNaClBackend() +ImageDataSimpleBackend::ImageDataSimpleBackend() : map_count_(0) { } -ImageDataNaClBackend::~ImageDataNaClBackend() { +ImageDataSimpleBackend::~ImageDataSimpleBackend() { } -bool ImageDataNaClBackend::Init(PPB_ImageData_Impl* impl, - PP_ImageDataFormat format, - int width, int height, - bool init_to_zero) { +bool ImageDataSimpleBackend::Init(PPB_ImageData_Impl* impl, + PP_ImageDataFormat format, + int width, int height, + bool init_to_zero) { skia_bitmap_.setConfig(SkBitmap::kARGB_8888_Config, impl->width(), impl->height()); PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(impl); @@ -231,15 +220,15 @@ bool ImageDataNaClBackend::Init(PPB_ImageData_Impl* impl, return !!shared_memory_.get(); } -bool ImageDataNaClBackend::IsMapped() const { +bool ImageDataSimpleBackend::IsMapped() const { return map_count_ > 0; } -PluginDelegate::PlatformImage2D* ImageDataNaClBackend::PlatformImage() const { +PluginDelegate::PlatformImage2D* ImageDataSimpleBackend::PlatformImage() const { return NULL; } -void* ImageDataNaClBackend::Map() { +void* ImageDataSimpleBackend::Map() { DCHECK(shared_memory_.get()); if (map_count_++ == 0) { shared_memory_->Map(skia_bitmap_.getSize()); @@ -252,12 +241,12 @@ void* ImageDataNaClBackend::Map() { return shared_memory_->memory(); } -void ImageDataNaClBackend::Unmap() { +void ImageDataSimpleBackend::Unmap() { if (--map_count_ == 0) shared_memory_->Unmap(); } -int32_t ImageDataNaClBackend::GetSharedMemory(int* handle, +int32_t ImageDataSimpleBackend::GetSharedMemory(int* handle, uint32_t* byte_count) { *byte_count = skia_bitmap_.getSize(); #if defined(OS_POSIX) @@ -270,17 +259,17 @@ int32_t ImageDataNaClBackend::GetSharedMemory(int* handle, return PP_OK; } -skia::PlatformCanvas* ImageDataNaClBackend::GetPlatformCanvas() { +skia::PlatformCanvas* ImageDataSimpleBackend::GetPlatformCanvas() { return NULL; } -SkCanvas* ImageDataNaClBackend::GetCanvas() { +SkCanvas* ImageDataSimpleBackend::GetCanvas() { if (!IsMapped()) return NULL; return skia_canvas_.get(); } -const SkBitmap* ImageDataNaClBackend::GetMappedBitmap() const { +const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const { if (!IsMapped()) return NULL; return &skia_bitmap_; diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.h b/webkit/plugins/ppapi/ppb_image_data_impl.h index bbcf7e6..733fcf0 100644 --- a/webkit/plugins/ppapi/ppb_image_data_impl.h +++ b/webkit/plugins/ppapi/ppb_image_data_impl.h @@ -28,7 +28,8 @@ class WEBKIT_PLUGINS_EXPORT PPB_ImageData_Impl public: // We delegate most of our implementation to a back-end class that either uses // a PlatformCanvas (for most trusted stuff) or bare shared memory (for use by - // NaCl). This makes it cheap & easy to implement Swap. + // NaCl, or trusted plugins when the PlatformCanvas isn't needed). This makes + // it cheap & easy to implement Swap. class Backend { public: virtual ~Backend() {}; @@ -47,28 +48,19 @@ class WEBKIT_PLUGINS_EXPORT PPB_ImageData_Impl // If you call this constructor, you must also call Init before use. Normally // you should use the static Create function, but this constructor is needed // for some internal uses of ImageData (like Graphics2D). - enum ImageDataType { PLATFORM, NACL }; - PPB_ImageData_Impl(PP_Instance instance, ImageDataType type); + PPB_ImageData_Impl(PP_Instance instance, + PPB_ImageData_Shared::ImageDataType type); virtual ~PPB_ImageData_Impl(); bool Init(PP_ImageDataFormat format, int width, int height, bool init_to_zero); - // Create an ImageData backed by a PlatformCanvas. You must use this if you - // intend the ImageData to be usable in platform-specific APIs (like font - // rendering or rendering widgets like scrollbars). - static PP_Resource CreatePlatform(PP_Instance pp_instance, - PP_ImageDataFormat format, - const PP_Size& size, - PP_Bool init_to_zero); - - // Use this to create an ImageData for use with NaCl. This is backed by a - // simple shared memory buffer. - static PP_Resource CreateNaCl(PP_Instance pp_instance, - PP_ImageDataFormat format, - const PP_Size& size, - PP_Bool init_to_zero); + static PP_Resource Create(PP_Instance pp_instance, + PPB_ImageData_Shared::ImageDataType type, + PP_ImageDataFormat format, + const PP_Size& size, + PP_Bool init_to_zero); int width() const { return width_; } int height() const { return height_; } @@ -132,10 +124,10 @@ class ImageDataPlatformBackend : public PPB_ImageData_Impl::Backend { DISALLOW_COPY_AND_ASSIGN(ImageDataPlatformBackend); }; -class ImageDataNaClBackend : public PPB_ImageData_Impl::Backend { +class ImageDataSimpleBackend : public PPB_ImageData_Impl::Backend { public: - ImageDataNaClBackend(); - virtual ~ImageDataNaClBackend(); + ImageDataSimpleBackend(); + virtual ~ImageDataSimpleBackend(); // PPB_ImageData_Impl::Backend implementation. bool Init(PPB_ImageData_Impl* impl, PP_ImageDataFormat format, @@ -156,7 +148,7 @@ class ImageDataNaClBackend : public PPB_ImageData_Impl::Backend { scoped_ptr<SkCanvas> skia_canvas_; uint32 map_count_; - DISALLOW_COPY_AND_ASSIGN(ImageDataNaClBackend); + DISALLOW_COPY_AND_ASSIGN(ImageDataSimpleBackend); }; // Manages mapping an image resource if necessary. Use this to ensure the diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc index 3a0053b..ddbfcf7 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.cc +++ b/webkit/plugins/ppapi/resource_creation_impl.cc @@ -130,19 +130,14 @@ PP_Resource ResourceCreationImpl::CreateHostResolverPrivate( return 0; // Not supported in-process. } -PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size* size, - PP_Bool init_to_zero) { - 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, - PP_Bool init_to_zero) { - return PPB_ImageData_Impl::CreateNaCl(instance, format, *size, init_to_zero); +PP_Resource ResourceCreationImpl::CreateImageData( + PP_Instance instance, + ::ppapi::PPB_ImageData_Shared::ImageDataType type, + PP_ImageDataFormat format, + const PP_Size* size, + PP_Bool init_to_zero) { + return PPB_ImageData_Impl::Create(instance, type, + 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 5ced023..0303a53 100644 --- a/webkit/plugins/ppapi/resource_creation_impl.h +++ b/webkit/plugins/ppapi/resource_creation_impl.h @@ -58,14 +58,12 @@ class WEBKIT_PLUGINS_EXPORT ResourceCreationImpl PP_Resource share_context, const int32_t* attrib_list) OVERRIDE; virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateImageData(PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size* size, - PP_Bool init_to_zero) OVERRIDE; - virtual PP_Resource CreateImageDataNaCl(PP_Instance instance, - PP_ImageDataFormat format, - const PP_Size* size, - PP_Bool init_to_zero) OVERRIDE; + virtual PP_Resource CreateImageData( + PP_Instance instance, + ::ppapi::PPB_ImageData_Shared::ImageDataType type, + PP_ImageDataFormat format, + const PP_Size* size, + PP_Bool init_to_zero) OVERRIDE; virtual PP_Resource CreateIMEInputEvent(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, |