| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/pepper/ppb_image_data_impl.h" | 5 #include "content/renderer/pepper/ppb_image_data_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.h" |
| 13 #include "content/renderer/pepper/common.h" | 13 #include "content/renderer/pepper/common.h" |
| 14 #include "content/renderer/pepper/resource_helper.h" | 14 #include "content/renderer/pepper/resource_helper.h" |
| 15 #include "content/renderer/render_thread_impl.h" | 15 #include "content/renderer/render_thread_impl.h" |
| 16 #include "skia/ext/platform_canvas.h" | 16 #include "ppapi/c/pp_errors.h" |
| 17 #include "ppapi/c/pp_instance.h" | 17 #include "ppapi/c/pp_instance.h" |
| 18 #include "ppapi/c/pp_resource.h" | 18 #include "ppapi/c/pp_resource.h" |
| 19 #include "ppapi/c/ppb_image_data.h" | 19 #include "ppapi/c/ppb_image_data.h" |
| 20 #include "ppapi/thunk/thunk.h" | 20 #include "ppapi/thunk/thunk.h" |
| 21 #include "skia/ext/platform_canvas.h" |
| 21 #include "third_party/skia/include/core/SkColorPriv.h" | 22 #include "third_party/skia/include/core/SkColorPriv.h" |
| 22 #include "ui/surface/transport_dib.h" | 23 #include "ui/surface/transport_dib.h" |
| 23 | 24 |
| 24 using ::ppapi::thunk::PPB_ImageData_API; | 25 using ::ppapi::thunk::PPB_ImageData_API; |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 | 28 |
| 28 PPB_ImageData_Impl::PPB_ImageData_Impl(PP_Instance instance, | 29 PPB_ImageData_Impl::PPB_ImageData_Impl(PP_Instance instance, |
| 29 PPB_ImageData_Shared::ImageDataType type) | 30 PPB_ImageData_Shared::ImageDataType type) |
| 30 : Resource(::ppapi::OBJECT_IS_IMPL, instance), | 31 : Resource(::ppapi::OBJECT_IS_IMPL, instance), |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 248 |
| 248 ImageDataSimpleBackend::~ImageDataSimpleBackend() { | 249 ImageDataSimpleBackend::~ImageDataSimpleBackend() { |
| 249 } | 250 } |
| 250 | 251 |
| 251 bool ImageDataSimpleBackend::Init(PPB_ImageData_Impl* impl, | 252 bool ImageDataSimpleBackend::Init(PPB_ImageData_Impl* impl, |
| 252 PP_ImageDataFormat format, | 253 PP_ImageDataFormat format, |
| 253 int width, int height, | 254 int width, int height, |
| 254 bool init_to_zero) { | 255 bool init_to_zero) { |
| 255 skia_bitmap_.setConfig(SkBitmap::kARGB_8888_Config, | 256 skia_bitmap_.setConfig(SkBitmap::kARGB_8888_Config, |
| 256 impl->width(), impl->height()); | 257 impl->width(), impl->height()); |
| 257 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(impl); | 258 PepperPluginDelegateImpl* plugin_delegate = |
| 259 ResourceHelper::GetPluginDelegate(impl); |
| 258 if (!plugin_delegate) | 260 if (!plugin_delegate) |
| 259 return false; | 261 return false; |
| 260 shared_memory_.reset(RenderThread::Get()->HostAllocateSharedMemoryBuffer( | 262 shared_memory_.reset(RenderThread::Get()->HostAllocateSharedMemoryBuffer( |
| 261 skia_bitmap_.getSize()).release()); | 263 skia_bitmap_.getSize()).release()); |
| 262 return !!shared_memory_.get(); | 264 return !!shared_memory_.get(); |
| 263 } | 265 } |
| 264 | 266 |
| 265 bool ImageDataSimpleBackend::IsMapped() const { | 267 bool ImageDataSimpleBackend::IsMapped() const { |
| 266 return map_count_ > 0; | 268 return map_count_ > 0; |
| 267 } | 269 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 return skia_canvas_.get(); | 313 return skia_canvas_.get(); |
| 312 } | 314 } |
| 313 | 315 |
| 314 const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const { | 316 const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const { |
| 315 if (!IsMapped()) | 317 if (!IsMapped()) |
| 316 return NULL; | 318 return NULL; |
| 317 return &skia_bitmap_; | 319 return &skia_bitmap_; |
| 318 } | 320 } |
| 319 | 321 |
| 320 } // namespace content | 322 } // namespace content |
| OLD | NEW |