summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-26 23:38:14 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-26 23:38:14 +0000
commit17efd7ffaaea49cb23ff4d236ee8c806956003a1 (patch)
treeb4c6c8dedb63ee365ee01dde0aaf2c91b9c0a1db
parent8c498f4958e69746d6005839e3c8ef2460f18ae1 (diff)
downloadchromium_src-17efd7ffaaea49cb23ff4d236ee8c806956003a1.zip
chromium_src-17efd7ffaaea49cb23ff4d236ee8c806956003a1.tar.gz
chromium_src-17efd7ffaaea49cb23ff4d236ee8c806956003a1.tar.bz2
Get rid of PlatformDelegate::PlatformImage2D abstraction. It's not needed anymore now that pepper plugin code is in content.
BUG=263054 R=scottmg@chromium.org Review URL: https://codereview.chromium.org/20841002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214002 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/content_renderer.gypi2
-rw-r--r--content/content_tests.gypi4
-rw-r--r--content/renderer/pepper/mock_platform_image_2d.cc32
-rw-r--r--content/renderer/pepper/mock_platform_image_2d.h30
-rw-r--r--content/renderer/pepper/mock_plugin_delegate.cc7
-rw-r--r--content/renderer/pepper/mock_plugin_delegate.h1
-rw-r--r--content/renderer/pepper/pepper_platform_image_2d_impl.cc86
-rw-r--r--content/renderer/pepper/pepper_platform_image_2d_impl.h42
-rw-r--r--content/renderer/pepper/pepper_plugin_delegate_impl.cc6
-rw-r--r--content/renderer/pepper/pepper_plugin_delegate_impl.h1
-rw-r--r--content/renderer/pepper/pepper_plugin_instance_impl.cc6
-rw-r--r--content/renderer/pepper/pepper_plugin_instance_unittest.cc5
-rw-r--r--content/renderer/pepper/plugin_delegate.h21
-rw-r--r--content/renderer/pepper/ppb_image_data_impl.cc80
-rw-r--r--content/renderer/pepper/ppb_image_data_impl.h13
15 files changed, 78 insertions, 258 deletions
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 7522a23..d8de2d3 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -317,8 +317,6 @@
'renderer/pepper/pepper_platform_audio_output_impl.h',
'renderer/pepper/pepper_platform_context_3d_impl.cc',
'renderer/pepper/pepper_platform_context_3d_impl.h',
- 'renderer/pepper/pepper_platform_image_2d_impl.cc',
- 'renderer/pepper/pepper_platform_image_2d_impl.h',
'renderer/pepper/pepper_platform_video_capture.cc',
'renderer/pepper/pepper_platform_video_capture.h',
'renderer/pepper/pepper_plugin_delegate_impl.cc',
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 6e69912..7539b27 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -432,8 +432,6 @@
'renderer/media/webaudiosourceprovider_impl_unittest.cc',
'renderer/paint_aggregator_unittest.cc',
'renderer/pepper/host_var_tracker_unittest.cc',
- 'renderer/pepper/mock_platform_image_2d.cc',
- 'renderer/pepper/mock_platform_image_2d.h',
'renderer/pepper/mock_plugin_delegate.cc',
'renderer/pepper/mock_plugin_delegate.h',
'renderer/pepper/mock_resource.h',
@@ -853,8 +851,6 @@
'renderer/dom_serializer_browsertest.cc',
'renderer/mouse_lock_dispatcher_browsertest.cc',
'renderer/password_form_conversion_utils_browsertest.cc',
- 'renderer/pepper/mock_platform_image_2d.cc',
- 'renderer/pepper/mock_platform_image_2d.h',
'renderer/pepper/mock_plugin_delegate.cc',
'renderer/pepper/mock_plugin_delegate.h',
'renderer/pepper/mock_renderer_ppapi_host.cc',
diff --git a/content/renderer/pepper/mock_platform_image_2d.cc b/content/renderer/pepper/mock_platform_image_2d.cc
deleted file mode 100644
index 3a170be..0000000
--- a/content/renderer/pepper/mock_platform_image_2d.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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.
-
-#include "content/renderer/pepper/mock_platform_image_2d.h"
-
-#include "skia/ext/platform_canvas.h"
-
-namespace content {
-
-MockPlatformImage2D::MockPlatformImage2D(int width, int height)
- : width_(width),
- height_(height) {
-}
-
-MockPlatformImage2D::~MockPlatformImage2D() {
-}
-
-skia::PlatformCanvas* MockPlatformImage2D::Map() {
- return skia::CreatePlatformCanvas(width_, height_, true);
-}
-
-intptr_t MockPlatformImage2D::GetSharedMemoryHandle(uint32* byte_count) const {
- *byte_count = 0;
- return 0;
-}
-
-TransportDIB* MockPlatformImage2D::GetTransportDIB() const {
- return NULL;
-}
-
-} // namespace content
diff --git a/content/renderer/pepper/mock_platform_image_2d.h b/content/renderer/pepper/mock_platform_image_2d.h
deleted file mode 100644
index 19b8202..0000000
--- a/content/renderer/pepper/mock_platform_image_2d.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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.
-
-#ifndef CONTENT_RENDERER_PEPPER_MOCK_PLATFORM_IMAGE_2D_H_
-#define CONTENT_RENDERER_PEPPER_MOCK_PLATFORM_IMAGE_2D_H_
-
-#include "content/renderer/pepper/plugin_delegate.h"
-#include "skia/ext/platform_canvas.h"
-
-namespace content {
-
-class MockPlatformImage2D : public PluginDelegate::PlatformImage2D {
- public:
- MockPlatformImage2D(int width, int height);
- virtual ~MockPlatformImage2D();
-
- // PlatformImage2D implementation.
- virtual skia::PlatformCanvas* Map() OVERRIDE;
- virtual intptr_t GetSharedMemoryHandle(uint32* byte_count) const OVERRIDE;
- virtual TransportDIB* GetTransportDIB() const OVERRIDE;
-
- private:
- int width_;
- int height_;
-};
-
-} // namespace content
-
-#endif // CONTENT_RENDERER_PEPPER_MOCK_PLATFORM_IMAGE_2D_H_
diff --git a/content/renderer/pepper/mock_plugin_delegate.cc b/content/renderer/pepper/mock_plugin_delegate.cc
index 8b6660a..1065b09 100644
--- a/content/renderer/pepper/mock_plugin_delegate.cc
+++ b/content/renderer/pepper/mock_plugin_delegate.cc
@@ -6,7 +6,6 @@
#include "base/logging.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "content/renderer/pepper/mock_platform_image_2d.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/plugin_delegate.h"
#include "content/renderer/pepper/plugin_module.h"
@@ -78,12 +77,6 @@ WebKit::WebPlugin* MockPluginDelegate::CreatePluginReplacement(
return NULL;
}
-MockPluginDelegate::PlatformImage2D* MockPluginDelegate::CreateImage2D(
- int width,
- int height) {
- return new MockPlatformImage2D(width, height);
-}
-
PluginDelegate::PlatformGraphics2D* MockPluginDelegate::GetGraphics2D(
PepperPluginInstanceImpl* instance,
PP_Resource graphics_2d) {
diff --git a/content/renderer/pepper/mock_plugin_delegate.h b/content/renderer/pepper/mock_plugin_delegate.h
index f6384f3..5d3ff61 100644
--- a/content/renderer/pepper/mock_plugin_delegate.h
+++ b/content/renderer/pepper/mock_plugin_delegate.h
@@ -42,7 +42,6 @@ class MockPluginDelegate : public PluginDelegate {
virtual SkBitmap* GetSadPluginBitmap() OVERRIDE;
virtual WebKit::WebPlugin* CreatePluginReplacement(
const base::FilePath& file_path) OVERRIDE;
- virtual PlatformImage2D* CreateImage2D(int width, int height) OVERRIDE;
virtual PlatformGraphics2D* GetGraphics2D(PepperPluginInstanceImpl* instance,
PP_Resource graphics_2d) OVERRIDE;
virtual PlatformContext3D* CreateContext3D() OVERRIDE;
diff --git a/content/renderer/pepper/pepper_platform_image_2d_impl.cc b/content/renderer/pepper/pepper_platform_image_2d_impl.cc
deleted file mode 100644
index f51d234..0000000
--- a/content/renderer/pepper/pepper_platform_image_2d_impl.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// 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.
-
-#include "content/renderer/pepper/pepper_platform_image_2d_impl.h"
-
-#include "build/build_config.h"
-#include "content/common/view_messages.h"
-#include "content/renderer/render_thread_impl.h"
-#include "ui/surface/transport_dib.h"
-
-namespace content {
-
-PepperPlatformImage2DImpl::PepperPlatformImage2DImpl(int width,
- int height,
- TransportDIB* dib)
- : width_(width),
- height_(height),
- dib_(dib) {
-}
-
-// On POSIX, we have to tell the browser to free the transport DIB.
-PepperPlatformImage2DImpl::~PepperPlatformImage2DImpl() {
-#if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID)
- if (dib_) {
- RenderThreadImpl::current()->Send(
- new ViewHostMsg_FreeTransportDIB(dib_->id()));
- }
-#endif
-}
-
-// static
-PepperPlatformImage2DImpl* PepperPlatformImage2DImpl::Create(int width,
- int height) {
- uint32 buffer_size = width * height * 4;
-
- // Allocate the transport DIB and the PlatformCanvas pointing to it.
-#if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID)
- // On the Mac, shared memory has to be created in the browser in order to
- // work in the sandbox. Do this by sending a message to the browser
- // requesting a TransportDIB (see also
- // chrome/renderer/webplugin_delegate_proxy.cc, method
- // WebPluginDelegateProxy::CreateBitmap() for similar code). The TransportDIB
- // is cached in the browser, and is freed (in typical cases) by the
- // PepperPlatformImage2DImpl's destructor.
- TransportDIB::Handle dib_handle;
- IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(buffer_size,
- true,
- &dib_handle);
- if (!RenderThreadImpl::current()->Send(msg))
- return NULL;
- if (!TransportDIB::is_valid_handle(dib_handle))
- return NULL;
-
- TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle);
-#else
- static int next_dib_id = 0;
- TransportDIB* dib = TransportDIB::Create(buffer_size, next_dib_id++);
- if (!dib)
- return NULL;
-#endif
-
- return new PepperPlatformImage2DImpl(width, height, dib);
-}
-
-SkCanvas* PepperPlatformImage2DImpl::Map() {
- return dib_->GetPlatformCanvas(width_, height_);
-}
-
-intptr_t PepperPlatformImage2DImpl::GetSharedMemoryHandle(
- uint32* byte_count) const {
- *byte_count = dib_->size();
-#if defined(OS_WIN)
- return reinterpret_cast<intptr_t>(dib_->handle());
-#elif defined(TOOLKIT_GTK)
- return static_cast<intptr_t>(dib_->handle());
-#else
- return static_cast<intptr_t>(dib_->handle().fd);
-#endif
-}
-
-TransportDIB* PepperPlatformImage2DImpl::GetTransportDIB() const {
- return dib_.get();
-}
-
-} // namespace content
diff --git a/content/renderer/pepper/pepper_platform_image_2d_impl.h b/content/renderer/pepper/pepper_platform_image_2d_impl.h
deleted file mode 100644
index 3ff8de4..0000000
--- a/content/renderer/pepper/pepper_platform_image_2d_impl.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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.
-
-#ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_IMAGE_2D_IMPL_H_
-#define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_IMAGE_2D_IMPL_H_
-
-#include "base/basictypes.h"
-#include "content/renderer/pepper/plugin_delegate.h"
-
-namespace content {
-
-// Implements the Image2D using a TransportDIB.
-class PepperPlatformImage2DImpl : public PluginDelegate::PlatformImage2D {
- public:
- virtual ~PepperPlatformImage2DImpl();
-
- // Factory function that properly allocates a TransportDIB according to
- // the platform. Returns NULL on failure.
- static PepperPlatformImage2DImpl* Create(int width, int height);
-
- // PlatformImage2D implementation.
- virtual SkCanvas* Map() OVERRIDE;
- virtual intptr_t GetSharedMemoryHandle(uint32* byte_count) const OVERRIDE;
- virtual TransportDIB* GetTransportDIB() const OVERRIDE;
-
- private:
- // This constructor will take ownership of the dib pointer.
- // On Mac, we assume that the dib is cached by the browser, so on destruction
- // we'll tell the browser to free it.
- PepperPlatformImage2DImpl(int width, int height, TransportDIB* dib);
-
- int width_;
- int height_;
- scoped_ptr<TransportDIB> dib_;
-
- DISALLOW_COPY_AND_ASSIGN(PepperPlatformImage2DImpl);
-};
-
-} // namespace content
-
-#endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_IMAGE_2D_IMPL_H_
diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.cc b/content/renderer/pepper/pepper_plugin_delegate_impl.cc
index bd2b8ae..daf76ec 100644
--- a/content/renderer/pepper/pepper_plugin_delegate_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_delegate_impl.cc
@@ -50,7 +50,6 @@
#include "content/renderer/pepper/pepper_in_process_router.h"
#include "content/renderer/pepper/pepper_platform_audio_output_impl.h"
#include "content/renderer/pepper/pepper_platform_context_3d_impl.h"
-#include "content/renderer/pepper/pepper_platform_image_2d_impl.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/pepper_plugin_registry.h"
#include "content/renderer/pepper/pepper_url_loader_host.h"
@@ -628,11 +627,6 @@ WebKit::WebPlugin* PepperPluginDelegateImpl::CreatePluginReplacement(
render_view_, file_path);
}
-PluginDelegate::PlatformImage2D*
-PepperPluginDelegateImpl::CreateImage2D(int width, int height) {
- return PepperPlatformImage2DImpl::Create(width, height);
-}
-
PluginDelegate::PlatformGraphics2D*
PepperPluginDelegateImpl::GetGraphics2D(
PepperPluginInstanceImpl* instance,
diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.h b/content/renderer/pepper/pepper_plugin_delegate_impl.h
index 286ca0c..de79597 100644
--- a/content/renderer/pepper/pepper_plugin_delegate_impl.h
+++ b/content/renderer/pepper/pepper_plugin_delegate_impl.h
@@ -139,7 +139,6 @@ class PepperPluginDelegateImpl
uint32_t sample_rate,
uint32_t sample_count,
PlatformAudioOutputClient* client) OVERRIDE;
- virtual PlatformImage2D* CreateImage2D(int width, int height) OVERRIDE;
virtual PlatformGraphics2D* GetGraphics2D(
PepperPluginInstanceImpl* instance,
PP_Resource resource) OVERRIDE;
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc
index da6467a..77d9b3d 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
@@ -1049,9 +1049,9 @@ bool PepperPluginInstanceImpl::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()->ImageData();
- // ImageDatas created by NaCl don't have a PlatformImage, so can't be
+ // ImageDatas created by NaCl don't have a TransportDIB, so can't be
// optimized this way.
- if (!image_data->PlatformImage())
+ if (!image_data->GetTransportDIB())
return false;
gfx::Point plugin_origin = PP_ToGfxPoint(view_data_.rect.point);
@@ -1080,7 +1080,7 @@ bool PepperPluginInstanceImpl::GetBitmapForOptimizedPluginPaint(
return false;
}
- *dib = image_data->PlatformImage()->GetTransportDIB();
+ *dib = image_data->GetTransportDIB();
plugin_backing_store_rect.Offset(plugin_offset);
*location = plugin_backing_store_rect;
clip_page.Offset(plugin_offset);
diff --git a/content/renderer/pepper/pepper_plugin_instance_unittest.cc b/content/renderer/pepper/pepper_plugin_instance_unittest.cc
index 5aa6e4a..f0bd5a3 100644
--- a/content/renderer/pepper/pepper_plugin_instance_unittest.cc
+++ b/content/renderer/pepper/pepper_plugin_instance_unittest.cc
@@ -82,6 +82,9 @@ class PpapiPluginInstanceTest : public PpapiUnittest {
}
};
+// This matches the if condition in ImageDataPlatformBackend::Init as we can't
+// use RenderThread in the test.
+#if !(defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID))
// Test that GetBitmapForOptimizedPluginPaint doesn't return a bitmap rect
// that's bigger than the actual backing store bitmap.
@@ -122,4 +125,6 @@ TEST_F(PpapiPluginInstanceTest, GetBitmap2xScale) {
EXPECT_EQ(scale, bitmap_scale);
}
+#endif
+
} // namespace content
diff --git a/content/renderer/pepper/plugin_delegate.h b/content/renderer/pepper/plugin_delegate.h
index 3f28186..6381568 100644
--- a/content/renderer/pepper/plugin_delegate.h
+++ b/content/renderer/pepper/plugin_delegate.h
@@ -118,24 +118,6 @@ class PPB_TCPSocket_Private_Impl;
// PPAPI plugins.
class PluginDelegate {
public:
- // Represents an image. This is to allow the browser layer to supply a correct
- // image representation. In Chrome, this will be a TransportDIB.
- class PlatformImage2D {
- public:
- virtual ~PlatformImage2D() {}
-
- // Caller will own the returned pointer, returns NULL on failure.
- virtual SkCanvas* Map() = 0;
-
- // Returns the platform-specific shared memory handle of the data backing
- // this image. This is used by PPAPI proxying to send the image to the
- // out-of-process plugin. On success, the size in bytes will be placed into
- // |*bytes_count|. Returns 0 on failure.
- virtual intptr_t GetSharedMemoryHandle(uint32* byte_count) const = 0;
-
- virtual TransportDIB* GetTransportDIB() const = 0;
- };
-
class CONTENT_EXPORT PlatformGraphics2D {
public:
virtual ~PlatformGraphics2D() {}
@@ -300,9 +282,6 @@ class PluginDelegate {
virtual WebKit::WebPlugin* CreatePluginReplacement(
const base::FilePath& file_path) = 0;
- // The caller will own the pointer returned from this.
- virtual PlatformImage2D* CreateImage2D(int width, int height) = 0;
-
// Returns the internal PlatformGraphics2D implementation.
virtual PlatformGraphics2D* GetGraphics2D(PepperPluginInstanceImpl* instance,
PP_Resource graphics_2d) = 0;
diff --git a/content/renderer/pepper/ppb_image_data_impl.cc b/content/renderer/pepper/ppb_image_data_impl.cc
index a7e9895..de94152 100644
--- a/content/renderer/pepper/ppb_image_data_impl.cc
+++ b/content/renderer/pepper/ppb_image_data_impl.cc
@@ -9,14 +9,17 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "content/common/view_messages.h"
#include "content/renderer/pepper/common.h"
#include "content/renderer/pepper/resource_helper.h"
+#include "content/renderer/render_thread_impl.h"
#include "skia/ext/platform_canvas.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/thunk/thunk.h"
#include "third_party/skia/include/core/SkColorPriv.h"
+#include "ui/surface/transport_dib.h"
using ::ppapi::thunk::PPB_ImageData_API;
@@ -82,8 +85,8 @@ bool PPB_ImageData_Impl::IsMapped() const {
return backend_->IsMapped();
}
-PluginDelegate::PlatformImage2D* PPB_ImageData_Impl::PlatformImage() const {
- return backend_->PlatformImage();
+TransportDIB* PPB_ImageData_Impl::GetTransportDIB() const {
+ return backend_->GetTransportDIB();
}
PP_Bool PPB_ImageData_Impl::Describe(PP_ImageDataDesc* desc) {
@@ -124,37 +127,70 @@ const SkBitmap* PPB_ImageData_Impl::GetMappedBitmap() const {
// ImageDataPlatformBackend ----------------------------------------------------
-ImageDataPlatformBackend::ImageDataPlatformBackend() {
+ImageDataPlatformBackend::ImageDataPlatformBackend()
+ : width_(0),
+ height_(0) {
}
+// On POSIX, we have to tell the browser to free the transport DIB.
ImageDataPlatformBackend::~ImageDataPlatformBackend() {
+#if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID)
+ if (dib_) {
+ RenderThreadImpl::current()->Send(
+ new ViewHostMsg_FreeTransportDIB(dib_->id()));
+ }
+#endif
}
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)
+ PP_ImageDataFormat format,
+ int width, int height,
+ bool init_to_zero) {
+ // TODO(brettw) use init_to_zero when we implement caching.
+ width_ = width;
+ height_ = height;
+ uint32 buffer_size = width_ * height_ * 4;
+
+ // Allocate the transport DIB and the PlatformCanvas pointing to it.
+#if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID)
+ // On the Mac, shared memory has to be created in the browser in order to
+ // work in the sandbox. Do this by sending a message to the browser
+ // requesting a TransportDIB (see also
+ // chrome/renderer/webplugin_delegate_proxy.cc, method
+ // WebPluginDelegateProxy::CreateBitmap() for similar code). The TransportDIB
+ // is cached in the browser, and is freed (in typical cases) by the
+ // TransportDIB's destructor.
+ TransportDIB::Handle dib_handle;
+ IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(buffer_size,
+ true,
+ &dib_handle);
+ if (!RenderThreadImpl::current()->Send(msg))
+ return false;
+ if (!TransportDIB::is_valid_handle(dib_handle))
return false;
- // TODO(brettw) use init_to_zero when we implement caching.
- platform_image_.reset(plugin_delegate->CreateImage2D(width, height));
- return !!platform_image_.get();
+ TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle);
+#else
+ static int next_dib_id = 0;
+ TransportDIB* dib = TransportDIB::Create(buffer_size, next_dib_id++);
+ if (!dib)
+ return false;
+#endif
+ dib_.reset(dib);
+ return true;
}
bool ImageDataPlatformBackend::IsMapped() const {
return !!mapped_canvas_.get();
}
-PluginDelegate::PlatformImage2D*
-ImageDataPlatformBackend::PlatformImage() const {
- return platform_image_.get();
+TransportDIB* ImageDataPlatformBackend::GetTransportDIB() const {
+ return dib_.get();
}
void* ImageDataPlatformBackend::Map() {
if (!mapped_canvas_) {
- mapped_canvas_.reset(platform_image_->Map());
+ mapped_canvas_.reset(dib_->GetPlatformCanvas(width_, height_));
if (!mapped_canvas_)
return NULL;
}
@@ -176,8 +212,16 @@ void ImageDataPlatformBackend::Unmap() {
}
int32_t ImageDataPlatformBackend::GetSharedMemory(int* handle,
- uint32_t* byte_count) {
- *handle = platform_image_->GetSharedMemoryHandle(byte_count);
+ uint32_t* byte_count) {
+ *byte_count = dib_->size();
+#if defined(OS_WIN)
+ *handle = reinterpret_cast<intptr_t>(dib_->handle());
+#elif defined(TOOLKIT_GTK)
+ *handle = static_cast<intptr_t>(dib_->handle());
+#else
+ *handle = static_cast<intptr_t>(dib_->handle().fd);
+#endif
+
return PP_OK;
}
@@ -222,7 +266,7 @@ bool ImageDataSimpleBackend::IsMapped() const {
return map_count_ > 0;
}
-PluginDelegate::PlatformImage2D* ImageDataSimpleBackend::PlatformImage() const {
+TransportDIB* ImageDataSimpleBackend::GetTransportDIB() const {
return NULL;
}
diff --git a/content/renderer/pepper/ppb_image_data_impl.h b/content/renderer/pepper/ppb_image_data_impl.h
index 95aecea..481034e 100644
--- a/content/renderer/pepper/ppb_image_data_impl.h
+++ b/content/renderer/pepper/ppb_image_data_impl.h
@@ -17,6 +17,7 @@
class SkBitmap;
class SkCanvas;
+class TransportDIB;
namespace content {
@@ -35,7 +36,7 @@ class CONTENT_EXPORT PPB_ImageData_Impl
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 TransportDIB* GetTransportDIB() const = 0;
virtual void* Map() = 0;
virtual void Unmap() = 0;
virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) = 0;
@@ -69,7 +70,7 @@ class CONTENT_EXPORT PPB_ImageData_Impl
// Returns true if this image is mapped. False means that the image is either
// invalid or not mapped. See ImageDataAutoMapper below.
bool IsMapped() const;
- PluginDelegate::PlatformImage2D* PlatformImage() const;
+ TransportDIB* GetTransportDIB() const;
// Resource override.
virtual ::ppapi::thunk::PPB_ImageData_API* AsPPB_ImageData_API() OVERRIDE;
@@ -105,7 +106,7 @@ class ImageDataPlatformBackend : public PPB_ImageData_Impl::Backend {
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 TransportDIB* GetTransportDIB() const OVERRIDE;
virtual void* Map() OVERRIDE;
virtual void Unmap() OVERRIDE;
virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE;
@@ -116,7 +117,9 @@ class ImageDataPlatformBackend : public PPB_ImageData_Impl::Backend {
private:
// This will be NULL before initialization, and if this PPB_ImageData_Impl is
// swapped with another.
- scoped_ptr<PluginDelegate::PlatformImage2D> platform_image_;
+ int width_;
+ int height_;
+ scoped_ptr<TransportDIB> dib_;
// When the device is mapped, this is the image. Null when umapped.
scoped_ptr<SkCanvas> mapped_canvas_;
@@ -133,7 +136,7 @@ class ImageDataSimpleBackend : public PPB_ImageData_Impl::Backend {
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 TransportDIB* GetTransportDIB() const OVERRIDE;
virtual void* Map() OVERRIDE;
virtual void Unmap() OVERRIDE;
virtual int32_t GetSharedMemory(int* handle, uint32_t* byte_count) OVERRIDE;