| 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" | |
| 15 #include "content/renderer/render_thread_impl.h" | 14 #include "content/renderer/render_thread_impl.h" |
| 16 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
| 17 #include "ppapi/c/pp_instance.h" | 16 #include "ppapi/c/pp_instance.h" |
| 18 #include "ppapi/c/pp_resource.h" | 17 #include "ppapi/c/pp_resource.h" |
| 19 #include "ppapi/c/ppb_image_data.h" | 18 #include "ppapi/c/ppb_image_data.h" |
| 20 #include "ppapi/thunk/thunk.h" | 19 #include "ppapi/thunk/thunk.h" |
| 21 #include "skia/ext/platform_canvas.h" | 20 #include "skia/ext/platform_canvas.h" |
| 22 #include "third_party/skia/include/core/SkColorPriv.h" | 21 #include "third_party/skia/include/core/SkColorPriv.h" |
| 23 #include "ui/surface/transport_dib.h" | 22 #include "ui/surface/transport_dib.h" |
| 24 | 23 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 247 |
| 249 ImageDataSimpleBackend::~ImageDataSimpleBackend() { | 248 ImageDataSimpleBackend::~ImageDataSimpleBackend() { |
| 250 } | 249 } |
| 251 | 250 |
| 252 bool ImageDataSimpleBackend::Init(PPB_ImageData_Impl* impl, | 251 bool ImageDataSimpleBackend::Init(PPB_ImageData_Impl* impl, |
| 253 PP_ImageDataFormat format, | 252 PP_ImageDataFormat format, |
| 254 int width, int height, | 253 int width, int height, |
| 255 bool init_to_zero) { | 254 bool init_to_zero) { |
| 256 skia_bitmap_.setConfig(SkBitmap::kARGB_8888_Config, | 255 skia_bitmap_.setConfig(SkBitmap::kARGB_8888_Config, |
| 257 impl->width(), impl->height()); | 256 impl->width(), impl->height()); |
| 258 PepperHelperImpl* plugin_delegate = ResourceHelper::GetHelper(impl); | |
| 259 if (!plugin_delegate) | |
| 260 return false; | |
| 261 shared_memory_.reset(RenderThread::Get()->HostAllocateSharedMemoryBuffer( | 257 shared_memory_.reset(RenderThread::Get()->HostAllocateSharedMemoryBuffer( |
| 262 skia_bitmap_.getSize()).release()); | 258 skia_bitmap_.getSize()).release()); |
| 263 return !!shared_memory_.get(); | 259 return !!shared_memory_.get(); |
| 264 } | 260 } |
| 265 | 261 |
| 266 bool ImageDataSimpleBackend::IsMapped() const { | 262 bool ImageDataSimpleBackend::IsMapped() const { |
| 267 return map_count_ > 0; | 263 return map_count_ > 0; |
| 268 } | 264 } |
| 269 | 265 |
| 270 TransportDIB* ImageDataSimpleBackend::GetTransportDIB() const { | 266 TransportDIB* ImageDataSimpleBackend::GetTransportDIB() const { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 return skia_canvas_.get(); | 308 return skia_canvas_.get(); |
| 313 } | 309 } |
| 314 | 310 |
| 315 const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const { | 311 const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const { |
| 316 if (!IsMapped()) | 312 if (!IsMapped()) |
| 317 return NULL; | 313 return NULL; |
| 318 return &skia_bitmap_; | 314 return &skia_bitmap_; |
| 319 } | 315 } |
| 320 | 316 |
| 321 } // namespace content | 317 } // namespace content |
| OLD | NEW |