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 #include <memory> |
9 | 10 |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "content/common/pepper_file_util.h" | 12 #include "content/common/pepper_file_util.h" |
13 #include "content/common/view_messages.h" | 13 #include "content/common/view_messages.h" |
14 #include "content/renderer/render_thread_impl.h" | 14 #include "content/renderer/render_thread_impl.h" |
15 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
16 #include "ppapi/c/pp_instance.h" | 16 #include "ppapi/c/pp_instance.h" |
17 #include "ppapi/c/pp_resource.h" | 17 #include "ppapi/c/pp_resource.h" |
18 #include "ppapi/c/ppb_image_data.h" | 18 #include "ppapi/c/ppb_image_data.h" |
19 #include "ppapi/thunk/thunk.h" | 19 #include "ppapi/thunk/thunk.h" |
20 #include "skia/ext/platform_canvas.h" | 20 #include "skia/ext/platform_canvas.h" |
21 #include "third_party/skia/include/core/SkCanvas.h" | 21 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 bool ImageDataPlatformBackend::Init(PPB_ImageData_Impl* impl, | 138 bool ImageDataPlatformBackend::Init(PPB_ImageData_Impl* impl, |
139 PP_ImageDataFormat format, | 139 PP_ImageDataFormat format, |
140 int width, | 140 int width, |
141 int height, | 141 int height, |
142 bool init_to_zero) { | 142 bool init_to_zero) { |
143 // TODO(brettw) use init_to_zero when we implement caching. | 143 // TODO(brettw) use init_to_zero when we implement caching. |
144 width_ = width; | 144 width_ = width; |
145 height_ = height; | 145 height_ = height; |
146 uint32_t buffer_size = width_ * height_ * 4; | 146 uint32_t buffer_size = width_ * height_ * 4; |
147 scoped_ptr<base::SharedMemory> shared_memory = | 147 std::unique_ptr<base::SharedMemory> shared_memory = |
148 RenderThread::Get()->HostAllocateSharedMemoryBuffer(buffer_size); | 148 RenderThread::Get()->HostAllocateSharedMemoryBuffer(buffer_size); |
149 if (!shared_memory) | 149 if (!shared_memory) |
150 return false; | 150 return false; |
151 | 151 |
152 // The TransportDIB is always backed by shared memory, so give the shared | 152 // The TransportDIB is always backed by shared memory, so give the shared |
153 // memory handle to it. | 153 // memory handle to it. |
154 base::SharedMemoryHandle handle; | 154 base::SharedMemoryHandle handle; |
155 if (!shared_memory->GiveToProcess(base::GetCurrentProcessHandle(), &handle)) | 155 if (!shared_memory->GiveToProcess(base::GetCurrentProcessHandle(), &handle)) |
156 return false; | 156 return false; |
157 | 157 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 return skia_canvas_.get(); | 270 return skia_canvas_.get(); |
271 } | 271 } |
272 | 272 |
273 const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const { | 273 const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const { |
274 if (!IsMapped()) | 274 if (!IsMapped()) |
275 return NULL; | 275 return NULL; |
276 return &skia_bitmap_; | 276 return &skia_bitmap_; |
277 } | 277 } |
278 | 278 |
279 } // namespace content | 279 } // namespace content |
OLD | NEW |