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

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

Issue 2264293003: Remove SkPixelRef::getTexture() (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 3 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 | « src/core/SkImagePriv.h ('k') | src/image/SkImage_Gpu.cpp » ('j') | 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapCache.h" 9 #include "SkBitmapCache.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 289 }
290 290
291 //////////////////////////////////////////////////////////////////////////////// /////////////////// 291 //////////////////////////////////////////////////////////////////////////////// ///////////////////
292 292
293 sk_sp<SkImage> SkImage::MakeFromBitmap(const SkBitmap& bm) { 293 sk_sp<SkImage> SkImage::MakeFromBitmap(const SkBitmap& bm) {
294 SkPixelRef* pr = bm.pixelRef(); 294 SkPixelRef* pr = bm.pixelRef();
295 if (nullptr == pr) { 295 if (nullptr == pr) {
296 return nullptr; 296 return nullptr;
297 } 297 }
298 298
299 #if SK_SUPPORT_GPU
300 if (GrTexture* tex = pr->getTexture()) {
301 SkAutoTUnref<GrTexture> unrefCopy;
302 if (!bm.isImmutable()) {
303 tex = GrDeepCopyTexture(tex, SkBudgeted::kNo);
304 if (nullptr == tex) {
305 return nullptr;
306 }
307 unrefCopy.reset(tex);
308 }
309 const SkImageInfo info = bm.info();
310 return sk_make_sp<SkImage_Gpu>(info.width(), info.height(), bm.getGenera tionID(),
311 info.alphaType(), tex, sk_ref_sp(info.col orSpace()),
312 SkBudgeted::kNo);
313 }
314 #endif
315
316 return SkMakeImageFromRasterBitmap(bm, kIfMutable_SkCopyPixelsMode); 299 return SkMakeImageFromRasterBitmap(bm, kIfMutable_SkCopyPixelsMode);
317 } 300 }
318 301
319 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const { 302 bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const {
320 return as_IB(this)->onAsLegacyBitmap(bitmap, mode); 303 return as_IB(this)->onAsLegacyBitmap(bitmap, mode);
321 } 304 }
322 305
323 bool SkImage_Base::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) con st { 306 bool SkImage_Base::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) con st {
324 // As the base-class, all we can do is make a copy (regardless of mode). 307 // As the base-class, all we can do is make a copy (regardless of mode).
325 // Subclasses that want to be more optimal should override. 308 // Subclasses that want to be more optimal should override.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 SkASSERT(image); 505 SkASSERT(image);
523 SkASSERT(ctx); 506 SkASSERT(ctx);
524 as_IB(image)->onPinAsTexture(ctx); 507 as_IB(image)->onPinAsTexture(ctx);
525 } 508 }
526 509
527 void SkImage_unpinAsTexture(const SkImage* image, GrContext* ctx) { 510 void SkImage_unpinAsTexture(const SkImage* image, GrContext* ctx) {
528 SkASSERT(image); 511 SkASSERT(image);
529 SkASSERT(ctx); 512 SkASSERT(ctx);
530 as_IB(image)->onUnpinAsTexture(ctx); 513 as_IB(image)->onUnpinAsTexture(ctx);
531 } 514 }
OLDNEW
« no previous file with comments | « src/core/SkImagePriv.h ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698