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

Side by Side Diff: src/image/SkImage_Gpu.cpp

Issue 2223653002: use onPeekBitmap instead of asLegacyBitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkAutoPixmapStorage.h" 8 #include "SkAutoPixmapStorage.h"
9 #include "GrCaps.h" 9 #include "GrCaps.h"
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 if (GrTexture* peek = as_IB(this)->peekTexture()) { 308 if (GrTexture* peek = as_IB(this)->peekTexture()) {
309 return peek->getContext() == context ? sk_ref_sp(const_cast<SkImage*>(th is)) : nullptr; 309 return peek->getContext() == context ? sk_ref_sp(const_cast<SkImage*>(th is)) : nullptr;
310 } 310 }
311 // No way to check whether a image is premul or not? 311 // No way to check whether a image is premul or not?
312 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp e; 312 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp e;
313 313
314 if (SkImageCacherator* cacher = as_IB(this)->peekCacherator()) { 314 if (SkImageCacherator* cacher = as_IB(this)->peekCacherator()) {
315 GrImageTextureMaker maker(context, cacher, this, kDisallow_CachingHint); 315 GrImageTextureMaker maker(context, cacher, this, kDisallow_CachingHint);
316 return create_image_from_maker(&maker, at, this->uniqueID()); 316 return create_image_from_maker(&maker, at, this->uniqueID());
317 } 317 }
318 SkBitmap bmp; 318
robertphillips 2016/08/08 14:32:29 How do we know we're not in the SkImage_Generator
reed1 2016/08/08 15:19:30 Generator's have a cacherator (by definition), so
319 if (!this->asLegacyBitmap(&bmp, kRO_LegacyBitmapMode)) { 319 if (const SkBitmap* bmp = as_IB(this)->onPeekBitmap()) {
320 return nullptr; 320 GrBitmapTextureMaker maker(context, *bmp);
321 return create_image_from_maker(&maker, at, this->uniqueID());
321 } 322 }
322 GrBitmapTextureMaker maker(context, bmp); 323 return nullptr;
323 return create_image_from_maker(&maker, at, this->uniqueID());
324 } 324 }
325 325
326 sk_sp<SkImage> SkImage::makeNonTextureImage() const { 326 sk_sp<SkImage> SkImage::makeNonTextureImage() const {
327 if (!this->isTextureBacked()) { 327 if (!this->isTextureBacked()) {
328 return sk_ref_sp(const_cast<SkImage*>(this)); 328 return sk_ref_sp(const_cast<SkImage*>(this));
329 } 329 }
330 SkImageInfo info = as_IB(this)->onImageInfo(); 330 SkImageInfo info = as_IB(this)->onImageInfo();
331 size_t rowBytes = info.minRowBytes(); 331 size_t rowBytes = info.minRowBytes();
332 size_t size = info.getSafeSize(rowBytes); 332 size_t size = info.getSafeSize(rowBytes);
333 auto data = SkData::MakeUninitialized(size); 333 auto data = SkData::MakeUninitialized(size);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 return nullptr; 570 return nullptr;
571 } 571 }
572 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m ipLevelCount)); 572 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m ipLevelCount));
573 if (!texture) { 573 if (!texture) {
574 return nullptr; 574 return nullptr;
575 } 575 }
576 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew ImageUniqueID, 576 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew ImageUniqueID,
577 info.alphaType(), texture, sk_ref_sp(info.col orSpace()), 577 info.alphaType(), texture, sk_ref_sp(info.col orSpace()),
578 budgeted); 578 budgeted);
579 } 579 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698