Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: webkit/plugins/ppapi/ppb_image_data_impl.cc

Issue 5828003: Move the Pepper implementation from webkit/glue/plugins/pepper_* to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/ppapi/ppb_image_data_impl.h ('k') | webkit/plugins/ppapi/ppb_open_gl_es_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_image_data_impl.cc
===================================================================
--- webkit/plugins/ppapi/ppb_image_data_impl.cc (revision 0)
+++ webkit/plugins/ppapi/ppb_image_data_impl.cc (working copy)
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "webkit/glue/plugins/pepper_image_data.h"
+#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include <algorithm>
#include <limits>
@@ -16,20 +16,21 @@
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/c/trusted/ppb_image_data_trusted.h"
#include "third_party/skia/include/core/SkColorPriv.h"
-#include "webkit/glue/plugins/pepper_common.h"
-#include "webkit/glue/plugins/pepper_plugin_instance.h"
-#include "webkit/glue/plugins/pepper_plugin_module.h"
+#include "webkit/plugins/ppapi/common.h"
+#include "webkit/plugins/ppapi/plugin_instance.h"
+#include "webkit/plugins/ppapi/plugin_module.h"
-namespace pepper {
+namespace webkit {
+namespace ppapi {
namespace {
PP_ImageDataFormat GetNativeImageDataFormat() {
- return ImageData::GetNativeImageDataFormat();
+ return PPB_ImageData_Impl::GetNativeImageDataFormat();
}
PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format) {
- return BoolToPPBool(ImageData::IsImageDataFormatSupported(format));
+ return BoolToPPBool(PPB_ImageData_Impl::IsImageDataFormatSupported(format));
}
PP_Resource Create(PP_Module module_id,
@@ -40,7 +41,7 @@
if (!module)
return 0;
- scoped_refptr<ImageData> data(new ImageData(module));
+ scoped_refptr<PPB_ImageData_Impl> data(new PPB_ImageData_Impl(module));
if (!data->Init(format,
size->width,
size->height,
@@ -52,14 +53,15 @@
}
PP_Bool IsImageData(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<ImageData>(resource));
+ return BoolToPPBool(!!Resource::GetAs<PPB_ImageData_Impl>(resource));
}
PP_Bool Describe(PP_Resource resource, PP_ImageDataDesc* desc) {
// Give predictable values on failure.
memset(desc, 0, sizeof(PP_ImageDataDesc));
- scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource));
+ scoped_refptr<PPB_ImageData_Impl> image_data(
+ Resource::GetAs<PPB_ImageData_Impl>(resource));
if (!image_data)
return PP_FALSE;
image_data->Describe(desc);
@@ -67,14 +69,16 @@
}
void* Map(PP_Resource resource) {
- scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource));
+ scoped_refptr<PPB_ImageData_Impl> image_data(
+ Resource::GetAs<PPB_ImageData_Impl>(resource));
if (!image_data)
return NULL;
return image_data->Map();
}
void Unmap(PP_Resource resource) {
- scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource));
+ scoped_refptr<PPB_ImageData_Impl> image_data(
+ Resource::GetAs<PPB_ImageData_Impl>(resource));
if (image_data)
image_data->Unmap();
}
@@ -82,7 +86,8 @@
int32_t GetSharedMemory(PP_Resource resource,
int* handle,
uint32_t* byte_count) {
- scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource));
+ scoped_refptr<PPB_ImageData_Impl> image_data(
+ Resource::GetAs<PPB_ImageData_Impl>(resource));
if (image_data) {
*handle = image_data->GetSharedMemoryHandle(byte_count);
return PP_OK;
@@ -106,28 +111,28 @@
} // namespace
-ImageData::ImageData(PluginModule* module)
+PPB_ImageData_Impl::PPB_ImageData_Impl(PluginModule* module)
: Resource(module),
format_(PP_IMAGEDATAFORMAT_BGRA_PREMUL),
width_(0),
height_(0) {
}
-ImageData::~ImageData() {
+PPB_ImageData_Impl::~PPB_ImageData_Impl() {
}
// static
-const PPB_ImageData* ImageData::GetInterface() {
+const PPB_ImageData* PPB_ImageData_Impl::GetInterface() {
return &ppb_imagedata;
}
// static
-const PPB_ImageDataTrusted* ImageData::GetTrustedInterface() {
+const PPB_ImageDataTrusted* PPB_ImageData_Impl::GetTrustedInterface() {
return &ppb_imagedata_trusted;
}
// static
-PP_ImageDataFormat ImageData::GetNativeImageDataFormat() {
+PP_ImageDataFormat PPB_ImageData_Impl::GetNativeImageDataFormat() {
if (SK_B32_SHIFT == 0)
return PP_IMAGEDATAFORMAT_BGRA_PREMUL;
else if (SK_R32_SHIFT == 0)
@@ -137,14 +142,19 @@
}
// static
-bool ImageData::IsImageDataFormatSupported(PP_ImageDataFormat format) {
+bool PPB_ImageData_Impl::IsImageDataFormatSupported(
+ PP_ImageDataFormat format) {
return format == PP_IMAGEDATAFORMAT_BGRA_PREMUL ||
format == PP_IMAGEDATAFORMAT_RGBA_PREMUL;
}
-bool ImageData::Init(PP_ImageDataFormat format,
- int width, int height,
- bool init_to_zero) {
+PPB_ImageData_Impl* PPB_ImageData_Impl::AsPPB_ImageData_Impl() {
+ 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))
@@ -163,14 +173,14 @@
return !!platform_image_.get();
}
-void ImageData::Describe(PP_ImageDataDesc* desc) const {
+void PPB_ImageData_Impl::Describe(PP_ImageDataDesc* desc) const {
desc->format = format_;
desc->size.width = width_;
desc->size.height = height_;
desc->stride = width_ * 4;
}
-void* ImageData::Map() {
+void* PPB_ImageData_Impl::Map() {
if (!mapped_canvas_.get()) {
mapped_canvas_.reset(platform_image_->Map());
if (!mapped_canvas_.get())
@@ -186,24 +196,24 @@
return bitmap.getAddr32(0, 0);
}
-void ImageData::Unmap() {
+void PPB_ImageData_Impl::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.
}
-int ImageData::GetSharedMemoryHandle(uint32* byte_count) const {
+int PPB_ImageData_Impl::GetSharedMemoryHandle(uint32* byte_count) const {
return platform_image_->GetSharedMemoryHandle(byte_count);
}
-const SkBitmap* ImageData::GetMappedBitmap() const {
+const SkBitmap* PPB_ImageData_Impl::GetMappedBitmap() const {
if (!mapped_canvas_.get())
return NULL;
return &mapped_canvas_->getTopPlatformDevice().accessBitmap(false);
}
-void ImageData::Swap(ImageData* other) {
+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_);
@@ -211,4 +221,6 @@
std::swap(other->height_, height_);
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
« no previous file with comments | « webkit/plugins/ppapi/ppb_image_data_impl.h ('k') | webkit/plugins/ppapi/ppb_open_gl_es_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698