aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapCache.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkBitmapCache.h')
-rw-r--r--src/core/SkBitmapCache.h37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/core/SkBitmapCache.h b/src/core/SkBitmapCache.h
index e5160ae029..907a5468b6 100644
--- a/src/core/SkBitmapCache.h
+++ b/src/core/SkBitmapCache.h
@@ -19,15 +19,27 @@ uint64_t SkMakeResourceCacheSharedIDForBitmap(uint32_t bitmapGenID);
void SkNotifyBitmapGenIDIsStale(uint32_t bitmapGenID);
struct SkBitmapCacheDesc {
- uint32_t fImageID;
- int32_t fWidth;
- int32_t fHeight;
- SkIRect fBounds;
+ uint32_t fImageID; // != 0
+ int32_t fScaledWidth; // 0 for unscaled
+ int32_t fScaledHeight; // 0 for unscaled
+ SkIRect fSubset; // always set to a valid rect (entire or subset)
- static SkBitmapCacheDesc Make(const SkBitmap&, int width, int height);
+ void validate() const {
+ SkASSERT(fImageID);
+ if (fScaledWidth || fScaledHeight) {
+ SkASSERT(fScaledWidth && fScaledHeight);
+ }
+ SkASSERT(fSubset.fLeft >= 0 && fSubset.fTop >= 0);
+ SkASSERT(fSubset.width() > 0 && fSubset.height() > 0);
+ }
+
+ static SkBitmapCacheDesc Make(const SkBitmap&, int scaledWidth, int scaledHeight);
static SkBitmapCacheDesc Make(const SkBitmap&);
- static SkBitmapCacheDesc Make(const SkImage*, int width, int height);
+ static SkBitmapCacheDesc Make(const SkImage*, int scaledWidth, int scaledHeight);
static SkBitmapCacheDesc Make(const SkImage*);
+
+ // Use with care -- width/height must match the original bitmap/image
+ static SkBitmapCacheDesc Make(uint32_t genID, int origWidth, int origHeight);
};
class SkBitmapCache {
@@ -42,22 +54,19 @@ public:
* Search based on the desc. If found, returns true and
* result will be set to the matching bitmap with its pixels already locked.
*/
- static bool FindWH(const SkBitmapCacheDesc&, SkBitmap* result,
- SkResourceCache* localCache = nullptr);
+ static bool Find(const SkBitmapCacheDesc&, SkBitmap* result,
+ SkResourceCache* localCache = nullptr);
/*
* result must be marked isImmutable()
*/
- static bool AddWH(const SkBitmapCacheDesc&, const SkBitmap& result,
- SkResourceCache* localCache = nullptr);
-
- static bool Find(uint32_t genID, SkBitmap* result, SkResourceCache* localCache = nullptr);
- // todo: eliminate the need to specify ID, since it should == the bitmap's
- static void Add(uint32_t genID, const SkBitmap&, SkResourceCache* localCache = nullptr);
+ static bool Add(const SkBitmapCacheDesc&, const SkBitmap& result,
+ SkResourceCache* localCache = nullptr);
};
class SkMipMapCache {
public:
+ // Note: the scaled width/height in desc must be 0, as any other value would not make sense.
static const SkMipMap* FindAndRef(const SkBitmapCacheDesc&, SkDestinationSurfaceColorMode,
SkResourceCache* localCache = nullptr);
static const SkMipMap* AddAndRef(const SkBitmap& src, SkDestinationSurfaceColorMode,