Index: ppapi/proxy/ppb_image_data_proxy.cc |
=================================================================== |
--- ppapi/proxy/ppb_image_data_proxy.cc (revision 72517) |
+++ ppapi/proxy/ppb_image_data_proxy.cc (working copy) |
@@ -40,22 +40,23 @@ |
if (!dispatcher) |
return PP_ERROR_BADARGUMENT; |
- PP_Resource result = 0; |
+ SerializedResource result; |
std::string image_data_desc; |
ImageHandle image_handle = ImageData::NullHandle; |
dispatcher->Send(new PpapiHostMsg_PPBImageData_Create( |
INTERFACE_ID_PPB_IMAGE_DATA, instance, format, *size, init_to_zero, |
&result, &image_data_desc, &image_handle)); |
- if (result && image_data_desc.size() == sizeof(PP_ImageDataDesc)) { |
- // We serialize the PP_ImageDataDesc just by copying to a string. |
- PP_ImageDataDesc desc; |
- memcpy(&desc, image_data_desc.data(), sizeof(PP_ImageDataDesc)); |
+ if (result.is_null() || image_data_desc.size() != sizeof(PP_ImageDataDesc)) |
+ return 0; |
- linked_ptr<ImageData> object(new ImageData(instance, desc, image_handle)); |
- PluginResourceTracker::GetInstance()->AddResource(result, object); |
- } |
- return result; |
+ // We serialize the PP_ImageDataDesc just by copying to a string. |
+ PP_ImageDataDesc desc; |
+ memcpy(&desc, image_data_desc.data(), sizeof(PP_ImageDataDesc)); |
+ |
+ linked_ptr<ImageData> object(new ImageData(instance, result, desc, |
+ image_handle)); |
+ return PluginResourceTracker::GetInstance()->AddResource(object); |
} |
PP_Bool IsImageData(PP_Resource resource) { |
@@ -126,16 +127,16 @@ |
int32_t format, |
const PP_Size& size, |
PP_Bool init_to_zero, |
- PP_Resource* result, |
+ SerializedResource* result, |
std::string* image_data_desc, |
ImageHandle* result_image_handle) { |
- *result = ppb_image_data_target()->Create( |
+ PP_Resource resource = ppb_image_data_target()->Create( |
instance, static_cast<PP_ImageDataFormat>(format), &size, init_to_zero); |
*result_image_handle = ImageData::NullHandle; |
- if (*result) { |
+ if (resource) { |
// The ImageDesc is just serialized as a string. |
PP_ImageDataDesc desc; |
- if (ppb_image_data_target()->Describe(*result, &desc)) { |
+ if (ppb_image_data_target()->Describe(resource, &desc)) { |
image_data_desc->resize(sizeof(PP_ImageDataDesc)); |
memcpy(&(*image_data_desc)[0], &desc, sizeof(PP_ImageDataDesc)); |
} |
@@ -147,9 +148,11 @@ |
uint32_t byte_count = 0; |
if (trusted) { |
int32_t handle; |
- if (trusted->GetSharedMemory(*result, &handle, &byte_count) == PP_OK) |
+ if (trusted->GetSharedMemory(resource, &handle, &byte_count) == PP_OK) |
*result_image_handle = ImageData::HandleFromInt(handle); |
} |
+ |
+ result->set_host_resource(resource); |
} |
} |