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

Side by Side Diff: content/renderer/pepper/ppb_image_data_impl.cc

Issue 1145893009: Change transport dib API to not make copies of SharedMemoryHandle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared_memory_pepper_rename
Patch Set: Comments from jbauman. Created 5 years, 6 months 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 unified diff | Download patch
« no previous file with comments | « content/renderer/pepper/ppb_image_data_impl.h ('k') | ppapi/proxy/ppb_image_data_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 desc->size.width = width_; 98 desc->size.width = width_;
99 desc->size.height = height_; 99 desc->size.height = height_;
100 desc->stride = width_ * 4; 100 desc->stride = width_ * 4;
101 return PP_TRUE; 101 return PP_TRUE;
102 } 102 }
103 103
104 void* PPB_ImageData_Impl::Map() { return backend_->Map(); } 104 void* PPB_ImageData_Impl::Map() { return backend_->Map(); }
105 105
106 void PPB_ImageData_Impl::Unmap() { backend_->Unmap(); } 106 void PPB_ImageData_Impl::Unmap() { backend_->Unmap(); }
107 107
108 int32_t PPB_ImageData_Impl::GetSharedMemory(base::SharedMemoryHandle* handle, 108 int32_t PPB_ImageData_Impl::GetSharedMemory(base::SharedMemory** shm,
109 uint32_t* byte_count) { 109 uint32_t* byte_count) {
110 return backend_->GetSharedMemory(handle, byte_count); 110 return backend_->GetSharedMemory(shm, byte_count);
111 } 111 }
112 112
113 skia::PlatformCanvas* PPB_ImageData_Impl::GetPlatformCanvas() { 113 skia::PlatformCanvas* PPB_ImageData_Impl::GetPlatformCanvas() {
114 return backend_->GetPlatformCanvas(); 114 return backend_->GetPlatformCanvas();
115 } 115 }
116 116
117 SkCanvas* PPB_ImageData_Impl::GetCanvas() { return backend_->GetCanvas(); } 117 SkCanvas* PPB_ImageData_Impl::GetCanvas() { return backend_->GetCanvas(); }
118 118
119 void PPB_ImageData_Impl::SetIsCandidateForReuse() { 119 void PPB_ImageData_Impl::SetIsCandidateForReuse() {
120 // Nothing to do since we don't support image data re-use in-process. 120 // Nothing to do since we don't support image data re-use in-process.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return bitmap.getAddr32(0, 0); 181 return bitmap.getAddr32(0, 0);
182 } 182 }
183 183
184 void ImageDataPlatformBackend::Unmap() { 184 void ImageDataPlatformBackend::Unmap() {
185 // This is currently unimplemented, which is OK. The data will just always 185 // This is currently unimplemented, which is OK. The data will just always
186 // be around once it's mapped. Chrome's TransportDIB isn't currently 186 // be around once it's mapped. Chrome's TransportDIB isn't currently
187 // unmappable without freeing it, but this may be something we want to support 187 // unmappable without freeing it, but this may be something we want to support
188 // in the future to save some memory. 188 // in the future to save some memory.
189 } 189 }
190 190
191 int32_t ImageDataPlatformBackend::GetSharedMemory( 191 int32_t ImageDataPlatformBackend::GetSharedMemory(base::SharedMemory** shm,
192 base::SharedMemoryHandle* handle, 192 uint32_t* byte_count) {
193 uint32_t* byte_count) {
194 *byte_count = dib_->size(); 193 *byte_count = dib_->size();
195 *handle = dib_->handle(); 194 *shm = dib_->shared_memory();
196 return PP_OK; 195 return PP_OK;
197 } 196 }
198 197
199 skia::PlatformCanvas* ImageDataPlatformBackend::GetPlatformCanvas() { 198 skia::PlatformCanvas* ImageDataPlatformBackend::GetPlatformCanvas() {
200 return mapped_canvas_.get(); 199 return mapped_canvas_.get();
201 } 200 }
202 201
203 SkCanvas* ImageDataPlatformBackend::GetCanvas() { return mapped_canvas_.get(); } 202 SkCanvas* ImageDataPlatformBackend::GetCanvas() { return mapped_canvas_.get(); }
204 203
205 const SkBitmap* ImageDataPlatformBackend::GetMappedBitmap() const { 204 const SkBitmap* ImageDataPlatformBackend::GetMappedBitmap() const {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 return skia_bitmap_.getAddr32(0, 0); 242 return skia_bitmap_.getAddr32(0, 0);
244 } 243 }
245 return shared_memory_->memory(); 244 return shared_memory_->memory();
246 } 245 }
247 246
248 void ImageDataSimpleBackend::Unmap() { 247 void ImageDataSimpleBackend::Unmap() {
249 if (--map_count_ == 0) 248 if (--map_count_ == 0)
250 shared_memory_->Unmap(); 249 shared_memory_->Unmap();
251 } 250 }
252 251
253 int32_t ImageDataSimpleBackend::GetSharedMemory( 252 int32_t ImageDataSimpleBackend::GetSharedMemory(base::SharedMemory** shm,
254 base::SharedMemoryHandle* handle, 253 uint32_t* byte_count) {
255 uint32_t* byte_count) {
256 *byte_count = skia_bitmap_.getSize(); 254 *byte_count = skia_bitmap_.getSize();
257 *handle = shared_memory_->handle(); 255 *shm = shared_memory_.get();
258 return PP_OK; 256 return PP_OK;
259 } 257 }
260 258
261 skia::PlatformCanvas* ImageDataSimpleBackend::GetPlatformCanvas() { 259 skia::PlatformCanvas* ImageDataSimpleBackend::GetPlatformCanvas() {
262 return NULL; 260 return NULL;
263 } 261 }
264 262
265 SkCanvas* ImageDataSimpleBackend::GetCanvas() { 263 SkCanvas* ImageDataSimpleBackend::GetCanvas() {
266 if (!IsMapped()) 264 if (!IsMapped())
267 return NULL; 265 return NULL;
268 return skia_canvas_.get(); 266 return skia_canvas_.get();
269 } 267 }
270 268
271 const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const { 269 const SkBitmap* ImageDataSimpleBackend::GetMappedBitmap() const {
272 if (!IsMapped()) 270 if (!IsMapped())
273 return NULL; 271 return NULL;
274 return &skia_bitmap_; 272 return &skia_bitmap_;
275 } 273 }
276 274
277 } // namespace content 275 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/ppb_image_data_impl.h ('k') | ppapi/proxy/ppb_image_data_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698