summaryrefslogtreecommitdiffstats
path: root/webkit/plugins
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-25 21:54:49 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-25 21:54:49 +0000
commit16b7b2781d20602e7b58eaaf23a3c6e6ac250a55 (patch)
treeced69d77194024d772e513a8d149e1a18cadcde6 /webkit/plugins
parent16c10d7db132e781e6db49c26724006d06a54a35 (diff)
downloadchromium_src-16b7b2781d20602e7b58eaaf23a3c6e6ac250a55.zip
chromium_src-16b7b2781d20602e7b58eaaf23a3c6e6ac250a55.tar.gz
chromium_src-16b7b2781d20602e7b58eaaf23a3c6e6ac250a55.tar.bz2
PPAPI/NaCl: Make ImageData for NaCl just use shared memory
BUG=116317 TEST= TBR=ben@chromium.org ben for ui/gfx OWNERS Review URL: https://chromiumcodereview.appspot.com/10790063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148427 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc6
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc9
-rw-r--r--webkit/plugins/ppapi/ppb_image_data_impl.cc229
-rw-r--r--webkit/plugins/ppapi/ppb_image_data_impl.h125
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.cc10
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.h4
6 files changed, 320 insertions, 63 deletions
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 6fca59f..b462ce1 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -853,6 +853,10 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint(
// store when seeing if we cover the given paint bounds, since the backing
// store could be smaller than the declared plugin area.
PPB_ImageData_Impl* image_data = GetBoundGraphics2D()->image_data();
+ // ImageDatas created by NaCl don't have a PlatformImage, so can't be
+ // optimized this way.
+ if (!image_data->PlatformImage())
+ return false;
gfx::Rect plugin_backing_store_rect(
PP_ToGfxPoint(view_data_.rect.point),
gfx::Size(image_data->width(), image_data->height()));
@@ -863,7 +867,7 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint(
if (!plugin_paint_rect.Contains(paint_bounds))
return false;
- *dib = image_data->platform_image()->GetTransportDIB();
+ *dib = image_data->PlatformImage()->GetTransportDIB();
*location = plugin_backing_store_rect;
*clip = clip_page;
return true;
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index 6e4d3a8..c1d3829 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -195,7 +195,8 @@ PP_Resource PPB_Graphics2D_Impl::Create(PP_Instance instance,
bool PPB_Graphics2D_Impl::Init(int width, int height, bool is_always_opaque) {
// The underlying PPB_ImageData_Impl will validate the dimensions.
- image_data_ = new PPB_ImageData_Impl(pp_instance());
+ image_data_ = new PPB_ImageData_Impl(pp_instance(),
+ PPB_ImageData_Impl::PLATFORM);
if (!image_data_->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(),
width, height, true) ||
!image_data_->Map()) {
@@ -452,7 +453,7 @@ bool PPB_Graphics2D_Impl::ReadImageData(PP_Resource image,
// Convert the image data if the format does not match.
ConvertImageData(image_data_, src_irect, image_resource, dest_rect);
} else {
- skia::PlatformCanvas* dest_canvas = image_resource->GetPlatformCanvas();
+ SkCanvas* dest_canvas = image_resource->GetCanvas();
// We want to replace the contents of the bitmap rather than blend.
SkPaint paint;
@@ -681,7 +682,7 @@ void PPB_Graphics2D_Impl::ExecutePaintImageData(PPB_ImageData_Impl* image,
ConvertImageData(image, src_irect, image_data_, dest_rect);
} else {
// We're guaranteed to have a mapped canvas since we mapped it in Init().
- skia::PlatformCanvas* backing_canvas = image_data_->GetPlatformCanvas();
+ SkCanvas* backing_canvas = image_data_->GetCanvas();
// We want to replace the contents of the bitmap rather than blend.
SkPaint paint;
@@ -694,7 +695,7 @@ void PPB_Graphics2D_Impl::ExecutePaintImageData(PPB_ImageData_Impl* image,
void PPB_Graphics2D_Impl::ExecuteScroll(const gfx::Rect& clip,
int dx, int dy,
gfx::Rect* invalidated_rect) {
- gfx::ScrollCanvas(image_data_->GetPlatformCanvas(),
+ gfx::ScrollCanvas(image_data_->GetCanvas(),
clip, gfx::Point(dx, dy));
*invalidated_rect = clip;
}
diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.cc b/webkit/plugins/ppapi/ppb_image_data_impl.cc
index ea5f2c6..c58846a 100644
--- a/webkit/plugins/ppapi/ppb_image_data_impl.cc
+++ b/webkit/plugins/ppapi/ppb_image_data_impl.cc
@@ -25,36 +25,31 @@ using ::ppapi::thunk::PPB_ImageData_API;
namespace webkit {
namespace ppapi {
-PPB_ImageData_Impl::PPB_ImageData_Impl(PP_Instance instance)
+PPB_ImageData_Impl::PPB_ImageData_Impl(PP_Instance instance,
+ ImageDataType type)
: Resource(::ppapi::OBJECT_IS_IMPL, instance),
format_(PP_IMAGEDATAFORMAT_BGRA_PREMUL),
width_(0),
height_(0) {
+ switch (type) {
+ case PLATFORM:
+ backend_.reset(new ImageDataPlatformBackend);
+ return;
+ case NACL:
+ backend_.reset(new ImageDataNaClBackend);
+ return;
+ // No default: so that we get a compiler warning if any types are added.
+ }
+ NOTREACHED();
}
PPB_ImageData_Impl::~PPB_ImageData_Impl() {
}
-// static
-PP_Resource PPB_ImageData_Impl::Create(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));
- if (!data->Init(format, size.width, size.height, !!init_to_zero))
- return 0;
- return data->GetReference();
-}
-
-PPB_ImageData_API* PPB_ImageData_Impl::AsPPB_ImageData_API() {
- return this;
-}
-
bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format,
int width, int height,
bool init_to_zero) {
// TODO(brettw) this should be called only on the main thread!
- // TODO(brettw) use init_to_zero when we implement caching.
if (!IsImageDataFormatSupported(format))
return false; // Only support this one format for now.
if (width <= 0 || height <= 0)
@@ -63,15 +58,46 @@ bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format,
std::numeric_limits<int32>::max())
return false; // Prevent overflow of signed 32-bit ints.
- PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
- if (!plugin_delegate)
- return false;
-
- platform_image_.reset(plugin_delegate->CreateImage2D(width, height));
format_ = format;
width_ = width;
height_ = height;
- return !!platform_image_.get();
+ return backend_->Init(this, format, width, height, init_to_zero);
+}
+
+// static
+PP_Resource PPB_ImageData_Impl::CreatePlatform(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, 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));
+ if (!data->Init(format, size.width, size.height, !!init_to_zero))
+ return 0;
+ return data->GetReference();
+}
+
+PPB_ImageData_API* PPB_ImageData_Impl::AsPPB_ImageData_API() {
+ return this;
+}
+
+bool PPB_ImageData_Impl::IsMapped() const {
+ return backend_->IsMapped();
+}
+
+PluginDelegate::PlatformImage2D* PPB_ImageData_Impl::PlatformImage() const {
+ return backend_->PlatformImage();
}
PP_Bool PPB_ImageData_Impl::Describe(PP_ImageDataDesc* desc) {
@@ -83,6 +109,67 @@ PP_Bool PPB_ImageData_Impl::Describe(PP_ImageDataDesc* desc) {
}
void* PPB_ImageData_Impl::Map() {
+ return backend_->Map();
+}
+
+void PPB_ImageData_Impl::Unmap() {
+ backend_->Unmap();
+}
+
+int32_t PPB_ImageData_Impl::GetSharedMemory(int* handle, uint32_t* byte_count) {
+ return backend_->GetSharedMemory(handle, byte_count);
+}
+
+skia::PlatformCanvas* PPB_ImageData_Impl::GetPlatformCanvas() {
+ return backend_->GetPlatformCanvas();
+}
+
+SkCanvas* PPB_ImageData_Impl::GetCanvas() {
+ return backend_->GetCanvas();
+}
+
+const SkBitmap* PPB_ImageData_Impl::GetMappedBitmap() const {
+ return backend_->GetMappedBitmap();
+}
+
+void PPB_ImageData_Impl::Swap(PPB_ImageData_Impl* other) {
+ backend_.swap(other->backend_);
+ std::swap(other->format_, format_);
+ std::swap(other->width_, width_);
+ std::swap(other->height_, height_);
+}
+
+// ImageDataPlatformBackend --------------------------------------------------
+
+ImageDataPlatformBackend::ImageDataPlatformBackend() {
+}
+
+ImageDataPlatformBackend::~ImageDataPlatformBackend() {
+}
+
+bool ImageDataPlatformBackend::Init(PPB_ImageData_Impl* impl,
+ PP_ImageDataFormat format,
+ int width, int height,
+ bool init_to_zero) {
+ PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(impl);
+ if (!plugin_delegate)
+ return false;
+
+ // TODO(brettw) use init_to_zero when we implement caching.
+ platform_image_.reset(plugin_delegate->CreateImage2D(width, height));
+ return !!platform_image_.get();
+}
+
+bool ImageDataPlatformBackend::IsMapped() const {
+ return !!mapped_canvas_.get();
+}
+
+PluginDelegate::PlatformImage2D*
+ImageDataPlatformBackend::PlatformImage() const {
+ return platform_image_.get();
+}
+
+void* ImageDataPlatformBackend::Map() {
if (!mapped_canvas_.get()) {
mapped_canvas_.reset(platform_image_->Map());
if (!mapped_canvas_.get())
@@ -98,35 +185,109 @@ void* PPB_ImageData_Impl::Map() {
return bitmap.getAddr32(0, 0);
}
-void PPB_ImageData_Impl::Unmap() {
+void ImageDataPlatformBackend::Unmap() {
// This is currently unimplemented, which is OK. The data will just always
// be around once it's mapped. Chrome's TransportDIB isn't currently
// unmappable without freeing it, but this may be something we want to support
// in the future to save some memory.
}
-int32_t PPB_ImageData_Impl::GetSharedMemory(int* handle,
- uint32_t* byte_count) {
+int32_t ImageDataPlatformBackend::GetSharedMemory(int* handle,
+ uint32_t* byte_count) {
*handle = platform_image_->GetSharedMemoryHandle(byte_count);
return PP_OK;
}
-skia::PlatformCanvas* PPB_ImageData_Impl::GetPlatformCanvas() {
+skia::PlatformCanvas* ImageDataPlatformBackend::GetPlatformCanvas() {
return mapped_canvas_.get();
}
-const SkBitmap* PPB_ImageData_Impl::GetMappedBitmap() const {
+SkCanvas* ImageDataPlatformBackend::GetCanvas() {
+ return mapped_canvas_.get();
+}
+
+const SkBitmap* ImageDataPlatformBackend::GetMappedBitmap() const {
if (!mapped_canvas_.get())
return NULL;
return &skia::GetTopDevice(*mapped_canvas_)->accessBitmap(false);
}
-void PPB_ImageData_Impl::Swap(PPB_ImageData_Impl* other) {
- swap(other->platform_image_, platform_image_);
- swap(other->mapped_canvas_, mapped_canvas_);
- std::swap(other->format_, format_);
- std::swap(other->width_, width_);
- std::swap(other->height_, height_);
+// ImageDataNaClBackend ------------------------------------------------------
+
+ImageDataNaClBackend::ImageDataNaClBackend()
+ : map_count_(0) {
+}
+
+ImageDataNaClBackend::~ImageDataNaClBackend() {
+}
+
+bool ImageDataNaClBackend::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);
+ if (!plugin_delegate)
+ return false;
+ shared_memory_.reset(
+ plugin_delegate->CreateAnonymousSharedMemory(skia_bitmap_.getSize()));
+ return !!shared_memory_.get();
+}
+
+bool ImageDataNaClBackend::IsMapped() const {
+ return map_count_ > 0;
+}
+
+PluginDelegate::PlatformImage2D* ImageDataNaClBackend::PlatformImage() const {
+ return NULL;
+}
+
+void* ImageDataNaClBackend::Map() {
+ DCHECK(shared_memory_.get());
+ if (map_count_++ == 0) {
+ shared_memory_->Map(skia_bitmap_.getSize());
+ skia_bitmap_.setPixels(shared_memory_->memory());
+ // Our platform bitmaps are set to opaque by default, which we don't want.
+ skia_bitmap_.setIsOpaque(false);
+ skia_canvas_.setBitmapDevice(skia_bitmap_);
+ return skia_bitmap_.getAddr32(0, 0);
+ }
+ return shared_memory_->memory();
+}
+
+void ImageDataNaClBackend::Unmap() {
+ if (--map_count_ == 0)
+ shared_memory_->Unmap();
+}
+
+int32_t ImageDataNaClBackend::GetSharedMemory(int* handle,
+ uint32_t* byte_count) {
+ *byte_count = skia_bitmap_.getSize();
+#if defined(OS_POSIX)
+ *handle = shared_memory_->handle().fd;
+#elif defined(OS_WIN)
+ *handle = reinterpret_cast<int>(shared_memory_->handle());
+#else
+#error "Platform not supported."
+#endif
+ return PP_OK;
+}
+
+skia::PlatformCanvas* ImageDataNaClBackend::GetPlatformCanvas() {
+ return NULL;
+}
+
+SkCanvas* ImageDataNaClBackend::GetCanvas() {
+ if (!IsMapped())
+ return NULL;
+ return &skia_canvas_;
+}
+
+const SkBitmap* ImageDataNaClBackend::GetMappedBitmap() const {
+ if (!IsMapped())
+ return NULL;
+ return &skia_bitmap_;
}
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.h b/webkit/plugins/ppapi/ppb_image_data_impl.h
index 817b238..23a8f32 100644
--- a/webkit/plugins/ppapi/ppb_image_data_impl.h
+++ b/webkit/plugins/ppapi/ppb_image_data_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -11,6 +11,7 @@
#include "ppapi/shared_impl/ppb_image_data_shared.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/thunk/ppb_image_data_api.h"
+#include "third_party/skia/include/core/SkCanvas.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/webkit_plugins_export.h"
@@ -23,24 +24,54 @@ class SkBitmap;
namespace webkit {
namespace ppapi {
-class PPB_ImageData_Impl : public ::ppapi::Resource,
- public ::ppapi::PPB_ImageData_Shared,
- public ::ppapi::thunk::PPB_ImageData_API {
+class WEBKIT_PLUGINS_EXPORT PPB_ImageData_Impl
+ : public ::ppapi::Resource,
+ public ::ppapi::PPB_ImageData_Shared,
+ public NON_EXPORTED_BASE(::ppapi::thunk::PPB_ImageData_API) {
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.
+ class Backend {
+ public:
+ virtual ~Backend() {};
+ virtual bool Init(PPB_ImageData_Impl* impl, PP_ImageDataFormat format,
+ int width, int height, bool init_to_zero) = 0;
+ virtual bool IsMapped() const = 0;
+ virtual PluginDelegate::PlatformImage2D* PlatformImage() const = 0;
+ virtual void* Map() = 0;
+ virtual void Unmap() = 0;
+ virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) = 0;
+ virtual skia::PlatformCanvas* GetPlatformCanvas() = 0;
+ virtual SkCanvas* GetCanvas() = 0;
+ virtual const SkBitmap* GetMappedBitmap() const = 0;
+ };
+
// 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).
- WEBKIT_PLUGINS_EXPORT explicit PPB_ImageData_Impl(PP_Instance instance);
+ enum ImageDataType { PLATFORM, NACL };
+ PPB_ImageData_Impl(PP_Instance instance, ImageDataType type);
virtual ~PPB_ImageData_Impl();
- static PP_Resource Create(PP_Instance pp_instance,
- PP_ImageDataFormat format,
- const PP_Size& size,
- PP_Bool init_to_zero);
-
- WEBKIT_PLUGINS_EXPORT bool Init(PP_ImageDataFormat format,
- int width, int height,
- bool init_to_zero);
+ 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);
int width() const { return width_; }
int height() const { return height_; }
@@ -50,12 +81,10 @@ class PPB_ImageData_Impl : public ::ppapi::Resource,
// Returns true if this image is mapped. False means that the image is either
// invalid or not mapped. See ImageDataAutoMapper below.
- bool is_mapped() const { return !!mapped_canvas_.get(); }
-
- PluginDelegate::PlatformImage2D* platform_image() const {
- return platform_image_.get();
- }
+ bool IsMapped() const;
+ PluginDelegate::PlatformImage2D* PlatformImage() const;
+ // Resource override.
virtual ::ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() OVERRIDE;
// PPB_ImageData_API implementation.
@@ -64,6 +93,7 @@ class PPB_ImageData_Impl : public ::ppapi::Resource,
virtual void Unmap() OVERRIDE;
virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE;
virtual skia::PlatformCanvas* GetPlatformCanvas() OVERRIDE;
+ virtual SkCanvas* GetCanvas() OVERRIDE;
const SkBitmap* GetMappedBitmap() const;
@@ -71,6 +101,32 @@ class PPB_ImageData_Impl : public ::ppapi::Resource,
void Swap(PPB_ImageData_Impl* other);
private:
+ PP_ImageDataFormat format_;
+ int width_;
+ int height_;
+ scoped_ptr<Backend> backend_;
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Impl);
+};
+
+class ImageDataPlatformBackend : public PPB_ImageData_Impl::Backend {
+ public:
+ ImageDataPlatformBackend();
+ virtual ~ImageDataPlatformBackend();
+
+ // PPB_ImageData_Impl::Backend implementation.
+ virtual bool Init(PPB_ImageData_Impl* impl, PP_ImageDataFormat format,
+ int width, int height, bool init_to_zero) OVERRIDE;
+ virtual bool IsMapped() const OVERRIDE;
+ virtual PluginDelegate::PlatformImage2D* PlatformImage() const OVERRIDE;
+ virtual void* Map() OVERRIDE;
+ virtual void Unmap() OVERRIDE;
+ virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE;
+ virtual skia::PlatformCanvas* GetPlatformCanvas() OVERRIDE;
+ virtual SkCanvas* GetCanvas() OVERRIDE;
+ virtual const SkBitmap* GetMappedBitmap() const OVERRIDE;
+
+ private:
// This will be NULL before initialization, and if this PPB_ImageData_Impl is
// swapped with another.
scoped_ptr<PluginDelegate::PlatformImage2D> platform_image_;
@@ -78,11 +134,34 @@ class PPB_ImageData_Impl : public ::ppapi::Resource,
// When the device is mapped, this is the image. Null when umapped.
scoped_ptr<skia::PlatformCanvas> mapped_canvas_;
- PP_ImageDataFormat format_;
- int width_;
- int height_;
+ DISALLOW_COPY_AND_ASSIGN(ImageDataPlatformBackend);
+};
- DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Impl);
+class ImageDataNaClBackend : public PPB_ImageData_Impl::Backend {
+ public:
+ ImageDataNaClBackend();
+ virtual ~ImageDataNaClBackend();
+
+ // PPB_ImageData_Impl::Backend implementation.
+ bool Init(PPB_ImageData_Impl* impl, PP_ImageDataFormat format,
+ int width, int height, bool init_to_zero) OVERRIDE;
+ virtual bool IsMapped() const OVERRIDE;
+ PluginDelegate::PlatformImage2D* PlatformImage() const OVERRIDE;
+ virtual void* Map() OVERRIDE;
+ virtual void Unmap() OVERRIDE;
+ virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE;
+ virtual skia::PlatformCanvas* GetPlatformCanvas() OVERRIDE;
+ virtual SkCanvas* GetCanvas() OVERRIDE;
+ virtual const SkBitmap* GetMappedBitmap() const OVERRIDE;
+
+ private:
+ scoped_ptr<base::SharedMemory> shared_memory_;
+ // skia_bitmap_ is backed by shared_memory_.
+ SkBitmap skia_bitmap_;
+ SkCanvas skia_canvas_;
+ uint32 map_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImageDataNaClBackend);
};
// Manages mapping an image resource if necessary. Use this to ensure the
@@ -99,7 +178,7 @@ class ImageDataAutoMapper {
public:
explicit ImageDataAutoMapper(PPB_ImageData_Impl* image_data)
: image_data_(image_data) {
- if (image_data_->is_mapped()) {
+ if (image_data_->IsMapped()) {
is_valid_ = true;
needs_unmap_ = false;
} else {
diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc
index 3d4fd0a..6095d3b 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.cc
+++ b/webkit/plugins/ppapi/resource_creation_impl.cc
@@ -174,7 +174,15 @@ PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance instance,
PP_ImageDataFormat format,
const PP_Size& size,
PP_Bool init_to_zero) {
- return PPB_ImageData_Impl::Create(instance, format, size, 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::CreateIMEInputEvent(
diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h
index 42796ed..0a16e22 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.h
+++ b/webkit/plugins/ppapi/resource_creation_impl.h
@@ -66,6 +66,10 @@ class WEBKIT_PLUGINS_EXPORT ResourceCreationImpl
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 CreateIMEInputEvent(PP_Instance instance,
PP_InputEvent_Type type,
PP_TimeTicks time_stamp,