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/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/SkColorPriv.h" | 22 #include "third_party/skia/include/core/SkColorPriv.h" |
22 #include "third_party/skia/include/core/SkDevice.h" | 23 #include "third_party/skia/include/core/SkDevice.h" |
23 #include "third_party/skia/include/core/SkPixmap.h" | 24 #include "third_party/skia/include/core/SkPixmap.h" |
24 #include "ui/surface/transport_dib.h" | 25 #include "ui/surface/transport_dib.h" |
25 | 26 |
26 using ppapi::thunk::PPB_ImageData_API; | 27 using ppapi::thunk::PPB_ImageData_API; |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 | 30 |
30 PPB_ImageData_Impl::PPB_ImageData_Impl(PP_Instance instance, | 31 PPB_ImageData_Impl::PPB_ImageData_Impl(PP_Instance instance, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 106 |
106 void* PPB_ImageData_Impl::Map() { return backend_->Map(); } | 107 void* PPB_ImageData_Impl::Map() { return backend_->Map(); } |
107 | 108 |
108 void PPB_ImageData_Impl::Unmap() { backend_->Unmap(); } | 109 void PPB_ImageData_Impl::Unmap() { backend_->Unmap(); } |
109 | 110 |
110 int32_t PPB_ImageData_Impl::GetSharedMemory(base::SharedMemory** shm, | 111 int32_t PPB_ImageData_Impl::GetSharedMemory(base::SharedMemory** shm, |
111 uint32_t* byte_count) { | 112 uint32_t* byte_count) { |
112 return backend_->GetSharedMemory(shm, byte_count); | 113 return backend_->GetSharedMemory(shm, byte_count); |
113 } | 114 } |
114 | 115 |
115 skia::PlatformCanvas* PPB_ImageData_Impl::GetPlatformCanvas() { | 116 SkCanvas* PPB_ImageData_Impl::GetPlatformCanvas() { |
116 return backend_->GetPlatformCanvas(); | 117 return backend_->GetPlatformCanvas(); |
117 } | 118 } |
118 | 119 |
119 SkCanvas* PPB_ImageData_Impl::GetCanvas() { return backend_->GetCanvas(); } | 120 SkCanvas* PPB_ImageData_Impl::GetCanvas() { return backend_->GetCanvas(); } |
120 | 121 |
121 void PPB_ImageData_Impl::SetIsCandidateForReuse() { | 122 void PPB_ImageData_Impl::SetIsCandidateForReuse() { |
122 // Nothing to do since we don't support image data re-use in-process. | 123 // Nothing to do since we don't support image data re-use in-process. |
123 } | 124 } |
124 | 125 |
125 const SkBitmap* PPB_ImageData_Impl::GetMappedBitmap() const { | 126 const SkBitmap* PPB_ImageData_Impl::GetMappedBitmap() const { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // in the future to save some memory. | 191 // in the future to save some memory. |
191 } | 192 } |
192 | 193 |
193 int32_t ImageDataPlatformBackend::GetSharedMemory(base::SharedMemory** shm, | 194 int32_t ImageDataPlatformBackend::GetSharedMemory(base::SharedMemory** shm, |
194 uint32_t* byte_count) { | 195 uint32_t* byte_count) { |
195 *byte_count = dib_->size(); | 196 *byte_count = dib_->size(); |
196 *shm = dib_->shared_memory(); | 197 *shm = dib_->shared_memory(); |
197 return PP_OK; | 198 return PP_OK; |
198 } | 199 } |
199 | 200 |
200 skia::PlatformCanvas* ImageDataPlatformBackend::GetPlatformCanvas() { | 201 SkCanvas* ImageDataPlatformBackend::GetPlatformCanvas() { |
201 return mapped_canvas_.get(); | 202 return mapped_canvas_.get(); |
202 } | 203 } |
203 | 204 |
204 SkCanvas* ImageDataPlatformBackend::GetCanvas() { return mapped_canvas_.get(); } | 205 SkCanvas* ImageDataPlatformBackend::GetCanvas() { return mapped_canvas_.get(); } |
205 | 206 |
206 const SkBitmap* ImageDataPlatformBackend::GetMappedBitmap() const { | 207 const SkBitmap* ImageDataPlatformBackend::GetMappedBitmap() const { |
207 if (!mapped_canvas_) | 208 if (!mapped_canvas_) |
208 return NULL; | 209 return NULL; |
209 return &skia::GetTopDevice(*mapped_canvas_)->accessBitmap(false); | 210 return &skia::GetTopDevice(*mapped_canvas_)->accessBitmap(false); |
210 } | 211 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 shared_memory_->Unmap(); | 252 shared_memory_->Unmap(); |
252 } | 253 } |
253 | 254 |
254 int32_t ImageDataSimpleBackend::GetSharedMemory(base::SharedMemory** shm, | 255 int32_t ImageDataSimpleBackend::GetSharedMemory(base::SharedMemory** shm, |
255 uint32_t* byte_count) { | 256 uint32_t* byte_count) { |
256 *byte_count = skia_bitmap_.getSize(); | 257 *byte_count = skia_bitmap_.getSize(); |
257 *shm = shared_memory_.get(); | 258 *shm = shared_memory_.get(); |
258 return PP_OK; | 259 return PP_OK; |
259 } | 260 } |
260 | 261 |
261 skia::PlatformCanvas* ImageDataSimpleBackend::GetPlatformCanvas() { | 262 SkCanvas* ImageDataSimpleBackend::GetPlatformCanvas() { |
262 return NULL; | 263 return NULL; |
263 } | 264 } |
264 | 265 |
265 SkCanvas* ImageDataSimpleBackend::GetCanvas() { | 266 SkCanvas* ImageDataSimpleBackend::GetCanvas() { |
266 if (!IsMapped()) | 267 if (!IsMapped()) |
267 return NULL; | 268 return NULL; |
268 return skia_canvas_.get(); | 269 return skia_canvas_.get(); |
269 } | 270 } |
270 | 271 |
271 const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const { | 272 const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const { |
272 if (!IsMapped()) | 273 if (!IsMapped()) |
273 return NULL; | 274 return NULL; |
274 return &skia_bitmap_; | 275 return &skia_bitmap_; |
275 } | 276 } |
276 | 277 |
277 } // namespace content | 278 } // namespace content |
OLD | NEW |