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

Side by Side Diff: src/core/SkBitmapProvider.cpp

Issue 1463373002: scaling API on SkPixmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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/SkBitmapProvider.h ('k') | src/core/SkImageCacherator.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 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "SkBitmapProvider.h" 8 #include "SkBitmapProvider.h"
9 #include "SkImage_Base.h" 9 #include "SkImage_Base.h"
10 #include "SkPixelRef.h" 10 #include "SkPixelRef.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 SkImageInfo SkBitmapProvider::info() const { 46 SkImageInfo SkBitmapProvider::info() const {
47 if (fImage) { 47 if (fImage) {
48 SkAlphaType at = fImage->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAl phaType; 48 SkAlphaType at = fImage->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAl phaType;
49 return SkImageInfo::MakeN32(fImage->width(), fImage->height(), at); 49 return SkImageInfo::MakeN32(fImage->width(), fImage->height(), at);
50 } else { 50 } else {
51 return fBitmap.info(); 51 return fBitmap.info();
52 } 52 }
53 } 53 }
54 54
55 bool SkBitmapProvider::isVolatile() const {
56 if (fImage) {
57 return false; // add flag to images?
58 } else {
59 return fBitmap.isVolatile();
60 }
61 }
62
55 SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc(int w, int h) const { 63 SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc(int w, int h) const {
56 return fImage ? SkBitmapCacheDesc::Make(fImage, w, h) : SkBitmapCacheDesc::M ake(fBitmap, w, h); 64 return fImage ? SkBitmapCacheDesc::Make(fImage, w, h) : SkBitmapCacheDesc::M ake(fBitmap, w, h);
57 } 65 }
58 66
59 SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc() const { 67 SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc() const {
60 return fImage ? SkBitmapCacheDesc::Make(fImage) : SkBitmapCacheDesc::Make(fB itmap); 68 return fImage ? SkBitmapCacheDesc::Make(fImage) : SkBitmapCacheDesc::Make(fB itmap);
61 } 69 }
62 70
63 void SkBitmapProvider::notifyAddedToCache() const { 71 void SkBitmapProvider::notifyAddedToCache() const {
64 if (fImage) { 72 if (fImage) {
65 as_IB(fImage)->notifyAddedToCache(); 73 as_IB(fImage)->notifyAddedToCache();
66 } else { 74 } else {
67 fBitmap.pixelRef()->notifyAddedToCache(); 75 fBitmap.pixelRef()->notifyAddedToCache();
68 } 76 }
69 } 77 }
70 78
71 bool SkBitmapProvider::asBitmap(SkBitmap* bm) const { 79 bool SkBitmapProvider::asBitmap(SkBitmap* bm) const {
72 if (fImage) { 80 if (fImage) {
73 return as_IB(fImage)->getROPixels(bm); 81 return as_IB(fImage)->getROPixels(bm, SkImage::kAllow_CachingHint);
74 } else { 82 } else {
75 *bm = fBitmap; 83 *bm = fBitmap;
76 return true; 84 return true;
77 } 85 }
78 } 86 }
79 87
OLDNEW
« no previous file with comments | « src/core/SkBitmapProvider.h ('k') | src/core/SkImageCacherator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698