summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/pepper/pepper_pdf_host.cc35
-rw-r--r--ppapi/proxy/pdf_resource.cc14
-rw-r--r--ppapi/proxy/pdf_resource_unittest.cc3
-rw-r--r--ppapi/proxy/ppapi_messages.h10
4 files changed, 16 insertions, 46 deletions
diff --git a/chrome/renderer/pepper/pepper_pdf_host.cc b/chrome/renderer/pepper/pepper_pdf_host.cc
index dfc06e1..45ea1d3 100644
--- a/chrome/renderer/pepper/pepper_pdf_host.cc
+++ b/chrome/renderer/pepper/pepper_pdf_host.cc
@@ -20,11 +20,11 @@
#include "ppapi/proxy/ppb_image_data_proxy.h"
#include "ppapi/shared_impl/scoped_pp_resource.h"
#include "ppapi/thunk/enter.h"
-#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebElement.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebPluginContainer.h"
+#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
@@ -318,29 +318,12 @@ int32_t PepperPDFHost::OnHostMsgGetResourceImage(
ppapi::host::ReplyMessageContext reply_context =
context->MakeReplyMessageContext();
-#if defined(TOOLKIT_GTK)
- // For GTK, we pass the SysV shared memory key in the message.
- PpapiPluginMsg_PDF_GetResourceImageReply reply_msg(host_resource,
- image_data_desc,
- image_handle.fd);
-#elif defined(OS_POSIX) || defined(OS_WIN)
ppapi::proxy::SerializedHandle serialized_handle;
- PpapiPluginMsg_PDF_GetResourceImageReply reply_msg(host_resource,
- image_data_desc,
- 0);
serialized_handle.set_shmem(image_handle, byte_count);
reply_context.params.AppendHandle(serialized_handle);
-#else
- // Not supported on the other platforms.
- // This is a stub reply_msg not to break the build.
- PpapiPluginMsg_PDF_GetResourceImageReply reply_msg(host_resource,
- image_data_desc,
- 0);
- NOTIMPLEMENTED();
- return PP_ERROR_NOTSUPPORTED;
-#endif
-
- SendReply(reply_context, reply_msg);
+ SendReply(reply_context,
+ PpapiPluginMsg_PDF_GetResourceImageReply(host_resource,
+ image_data_desc));
// Keep a reference to the resource only if the function succeeds.
image_data_resource.Release();
@@ -363,7 +346,7 @@ bool PepperPDFHost::CreateImageData(
uint32_t* out_byte_count) {
PP_Resource resource = ppapi::proxy::PPB_ImageData_Proxy::CreateImageData(
instance,
- ppapi::PPB_ImageData_Shared::PLATFORM,
+ ppapi::PPB_ImageData_Shared::SIMPLE,
format, size,
false /* init_to_zero */,
out_image_data_desc, out_image_handle, out_byte_count);
@@ -384,10 +367,10 @@ bool PepperPDFHost::CreateImageData(
if (!mapper.is_valid())
return false;
- skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas();
- // Note: Do not skBitmap::copyTo the canvas bitmap directly because it will
- // ignore the allocated pixels in shared memory and re-allocate a new buffer.
- canvas->writePixels(pixels_to_write, 0, 0);
+ const SkBitmap* bitmap = image_data->GetMappedBitmap();
+ pixels_to_write.copyPixelsTo(bitmap->getPixels(),
+ bitmap->getSize(),
+ bitmap->rowBytes());
return true;
}
diff --git a/ppapi/proxy/pdf_resource.cc b/ppapi/proxy/pdf_resource.cc
index 474cfd8..122b88c6 100644
--- a/ppapi/proxy/pdf_resource.cc
+++ b/ppapi/proxy/pdf_resource.cc
@@ -168,9 +168,8 @@ PP_Resource PDFResource::GetResourceImageForScale(PP_ResourceImage image_id,
HostResource resource;
PP_ImageDataDesc image_desc;
- int fd;
if (!UnpackMessage<PpapiPluginMsg_PDF_GetResourceImageReply>(
- reply, &resource, &image_desc, &fd)) {
+ reply, &resource, &image_desc)) {
return 0;
}
@@ -179,19 +178,10 @@ PP_Resource PDFResource::GetResourceImageForScale(PP_ResourceImage image_id,
if (!PPB_ImageData_Shared::IsImageDataDescValid(image_desc))
return 0;
-#if defined(OS_ANDROID)
- // This is compiled into android for tests only.
- return 0;
-#elif defined(TOOLKIT_GTK)
- 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 PlatformImageData(resource, image_desc, handle))->GetReference();
-#else
-#error Not implemented.
-#endif
+ return (new SimpleImageData(resource, image_desc, handle))->GetReference();
}
PP_Resource PDFResource::GetResourceImage(PP_ResourceImage image_id) {
diff --git a/ppapi/proxy/pdf_resource_unittest.cc b/ppapi/proxy/pdf_resource_unittest.cc
index 14b7d33..3ac60d6 100644
--- a/ppapi/proxy/pdf_resource_unittest.cc
+++ b/ppapi/proxy/pdf_resource_unittest.cc
@@ -168,8 +168,7 @@ TEST_F(PDFResourceTest, GetResourceImageForScale) {
};
SerializedHandle serialized_handle(SerializedHandle::SHARED_MEMORY);
PpapiPluginMsg_PDF_GetResourceImageReply reply_msg(expected_resource,
- expected_desc,
- 0);
+ expected_desc);
ResourceSyncCallHandler handler(
&sink(),
PpapiHostMsg_PDF_GetResourceImage::ID,
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 5e89785..a54a9560 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -1868,15 +1868,13 @@ IPC_MESSAGE_CONTROL0(PpapiHostMsg_PDF_SaveAs)
IPC_MESSAGE_CONTROL2(PpapiHostMsg_PDF_GetResourceImage,
PP_ResourceImage /* image_id */,
float /* scale */)
+
// Reply for PpapiHostMsg_PDF_GetResourceImage containing the host resource id
// of the image and a PP_ImageDataDesc which describes the image. Also carries
-// a shared memory handle pointing to the memory containg the image. On linux,
-// the handle is transmitted in this message as |fd|. This is due to the
-// unfortunate way that ImageHandles are defined for use with PPB_ImageData.
-IPC_MESSAGE_CONTROL3(PpapiPluginMsg_PDF_GetResourceImageReply,
+// a shared memory handle pointing to the memory containg the image.
+IPC_MESSAGE_CONTROL2(PpapiPluginMsg_PDF_GetResourceImageReply,
ppapi::HostResource /* resource_id */,
- PP_ImageDataDesc /* image_data_desc */,
- int /* fd */)
+ PP_ImageDataDesc /* image_data_desc */)
// VideoCapture_Dev, plugin -> host
IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoCapture_Create)