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

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

Issue 2476113002: Change call-sites now that SkCanvas is not ref-counted (Closed)
Patch Set: try fixing win again Created 4 years, 1 month 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
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 #include <memory> 9 #include <memory>
10 10
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return !!mapped_canvas_.get(); 164 return !!mapped_canvas_.get();
165 } 165 }
166 166
167 TransportDIB* ImageDataPlatformBackend::GetTransportDIB() const { 167 TransportDIB* ImageDataPlatformBackend::GetTransportDIB() const {
168 return dib_.get(); 168 return dib_.get();
169 } 169 }
170 170
171 void* ImageDataPlatformBackend::Map() { 171 void* ImageDataPlatformBackend::Map() {
172 if (!mapped_canvas_) { 172 if (!mapped_canvas_) {
173 const bool is_opaque = false; 173 const bool is_opaque = false;
174 mapped_canvas_ = 174 mapped_canvas_ = dib_->GetPlatformCanvas(width_, height_, is_opaque);
175 sk_sp<SkCanvas>(dib_->GetPlatformCanvas(width_, height_, is_opaque));
176 if (!mapped_canvas_) 175 if (!mapped_canvas_)
177 return NULL; 176 return NULL;
178 } 177 }
179 SkPixmap pixmap; 178 SkPixmap pixmap;
180 skia::GetWritablePixels(mapped_canvas_.get(), &pixmap); 179 skia::GetWritablePixels(mapped_canvas_.get(), &pixmap);
181 DCHECK(pixmap.addr()); 180 DCHECK(pixmap.addr());
182 // SkPixmap does not manage the lifetime of this pointer, so it remains 181 // SkPixmap does not manage the lifetime of this pointer, so it remains
183 // valid after the object goes out of scope. It will become invalid if 182 // valid after the object goes out of scope. It will become invalid if
184 // the canvas' backing is destroyed or a pending saveLayer() is resolved. 183 // the canvas' backing is destroyed or a pending saveLayer() is resolved.
185 return pixmap.writable_addr32(0, 0); 184 return pixmap.writable_addr32(0, 0);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 242
244 TransportDIB* ImageDataSimpleBackend::GetTransportDIB() const { return NULL; } 243 TransportDIB* ImageDataSimpleBackend::GetTransportDIB() const { return NULL; }
245 244
246 void* ImageDataSimpleBackend::Map() { 245 void* ImageDataSimpleBackend::Map() {
247 DCHECK(shared_memory_.get()); 246 DCHECK(shared_memory_.get());
248 if (map_count_++ == 0) { 247 if (map_count_++ == 0) {
249 shared_memory_->Map(skia_bitmap_.getSize()); 248 shared_memory_->Map(skia_bitmap_.getSize());
250 skia_bitmap_.setPixels(shared_memory_->memory()); 249 skia_bitmap_.setPixels(shared_memory_->memory());
251 // Our platform bitmaps are set to opaque by default, which we don't want. 250 // Our platform bitmaps are set to opaque by default, which we don't want.
252 skia_bitmap_.setAlphaType(kPremul_SkAlphaType); 251 skia_bitmap_.setAlphaType(kPremul_SkAlphaType);
253 skia_canvas_ = sk_make_sp<SkCanvas>(skia_bitmap_); 252 skia_canvas_ = base::MakeUnique<SkCanvas>(skia_bitmap_);
254 return skia_bitmap_.getAddr32(0, 0); 253 return skia_bitmap_.getAddr32(0, 0);
255 } 254 }
256 return shared_memory_->memory(); 255 return shared_memory_->memory();
257 } 256 }
258 257
259 void ImageDataSimpleBackend::Unmap() { 258 void ImageDataSimpleBackend::Unmap() {
260 if (--map_count_ == 0) 259 if (--map_count_ == 0)
261 shared_memory_->Unmap(); 260 shared_memory_->Unmap();
262 } 261 }
263 262
(...skipping 14 matching lines...) Expand all
278 return skia_canvas_.get(); 277 return skia_canvas_.get();
279 } 278 }
280 279
281 SkBitmap ImageDataSimpleBackend::GetMappedBitmap() const { 280 SkBitmap ImageDataSimpleBackend::GetMappedBitmap() const {
282 if (!IsMapped()) 281 if (!IsMapped())
283 return SkBitmap(); 282 return SkBitmap();
284 return skia_bitmap_; 283 return skia_bitmap_;
285 } 284 }
286 285
287 } // namespace content 286 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698