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

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

Issue 2222783002: Avoid caching resources for volatile bitmap shaders (Closed) Base URL: https://chromium.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 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 SkImageInfo SkBitmapProvider::info() const { 42 SkImageInfo SkBitmapProvider::info() const {
43 if (fImage) { 43 if (fImage) {
44 return as_IB(fImage)->onImageInfo(); 44 return as_IB(fImage)->onImageInfo();
45 } else { 45 } else {
46 return fBitmap.info(); 46 return fBitmap.info();
47 } 47 }
48 } 48 }
49 49
50 bool SkBitmapProvider::isVolatile() const { 50 bool SkBitmapProvider::isVolatile() const {
51 if (fImage) { 51 if (fImage) {
52 return false; // add flag to images? 52 // add flag to images?
53 const SkBitmap* bm = as_IB(fImage)->onPeekBitmap();
54 return bm ? bm->isVolatile() : false;
53 } else { 55 } else {
54 return fBitmap.isVolatile(); 56 return fBitmap.isVolatile();
55 } 57 }
56 } 58 }
57 59
58 SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc(int w, int h) const { 60 SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc(int w, int h) const {
59 return fImage ? SkBitmapCacheDesc::Make(fImage, w, h) : SkBitmapCacheDesc::M ake(fBitmap, w, h); 61 return fImage ? SkBitmapCacheDesc::Make(fImage, w, h) : SkBitmapCacheDesc::M ake(fBitmap, w, h);
60 } 62 }
61 63
62 SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc() const { 64 SkBitmapCacheDesc SkBitmapProvider::makeCacheDesc() const {
63 return fImage ? SkBitmapCacheDesc::Make(fImage) : SkBitmapCacheDesc::Make(fB itmap); 65 return fImage ? SkBitmapCacheDesc::Make(fImage) : SkBitmapCacheDesc::Make(fB itmap);
64 } 66 }
65 67
66 void SkBitmapProvider::notifyAddedToCache() const { 68 void SkBitmapProvider::notifyAddedToCache() const {
67 if (fImage) { 69 if (fImage) {
68 as_IB(fImage)->notifyAddedToCache(); 70 as_IB(fImage)->notifyAddedToCache();
69 } else { 71 } else {
70 fBitmap.pixelRef()->notifyAddedToCache(); 72 fBitmap.pixelRef()->notifyAddedToCache();
71 } 73 }
72 } 74 }
73 75
74 bool SkBitmapProvider::asBitmap(SkBitmap* bm) const { 76 bool SkBitmapProvider::asBitmap(SkBitmap* bm) const {
75 if (fImage) { 77 if (fImage) {
76 return as_IB(fImage)->getROPixels(bm, SkImage::kAllow_CachingHint); 78 return as_IB(fImage)->getROPixels(bm, SkImage::kAllow_CachingHint);
77 } else { 79 } else {
78 *bm = fBitmap; 80 *bm = fBitmap;
79 return true; 81 return true;
80 } 82 }
81 } 83 }
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