aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapCache.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-08-26 09:08:04 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-26 09:08:04 -0700
commit680fb9e8f10d24b5fe35c90338de37c57392f1aa (patch)
treef973f7d37ccd4deb5a23eb57c8b0a0b7e514ad3f /src/core/SkBitmapCache.h
parent97b49478cfbcdb9cac6de2ab0d44f975311ef631 (diff)
retool image cache to be generic cache, allowing the client to subclass "Rec", so they can provide a custom Key and arbitrary Value.
Follow-on CLs - rename ScaledimageCache to something like GeneralCache - explore if we can use call-backs or some mechanism to completely hide "lock/unlock", by forcing all clients to support "copying" their value out of the cache as the result of a Find. R=mtklein@google.com, senorblanco@google.com, bsalomon@google.com, qiankun.miao@intel.com, senorblanco@chromium.org Author: reed@google.com Review URL: https://codereview.chromium.org/507483002
Diffstat (limited to 'src/core/SkBitmapCache.h')
-rw-r--r--src/core/SkBitmapCache.h45
1 files changed, 20 insertions, 25 deletions
diff --git a/src/core/SkBitmapCache.h b/src/core/SkBitmapCache.h
index ebade0ebd9..2b2dfbbea4 100644
--- a/src/core/SkBitmapCache.h
+++ b/src/core/SkBitmapCache.h
@@ -8,38 +8,33 @@
#ifndef SkBitmapCache_DEFINED
#define SkBitmapCache_DEFINED
-#include "SkScaledImageCache.h"
+#include "SkScalar.h"
+
+class SkBitmap;
+class SkMipMap;
class SkBitmapCache {
public:
- typedef SkScaledImageCache::ID ID;
-
- static void Unlock(ID* id) {
- SkScaledImageCache::Unlock(id);
- }
-
- /* Input: bitmap+inverse_scale */
- static ID* FindAndLock(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY,
- SkBitmap* result);
- static ID* AddAndLock(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY,
- const SkBitmap& result);
-
- /* Input: bitmap_genID+width+height */
- static ID* FindAndLock(uint32_t genID, int width, int height, SkBitmap* result);
-
- static ID* AddAndLock(uint32_t genID, int width, int height, const SkBitmap& result);
+ /**
+ * Search based on the src bitmap and inverse scales in X and Y. If found, returns true and
+ * result will be set to the matching bitmap with its pixels already locked.
+ */
+ static bool Find(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY, SkBitmap* result);
+ static void Add(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY,
+ const SkBitmap& result);
+
+ /**
+ * Search based on the bitmap's genID, width, height. If found, returns true and
+ * result will be set to the matching bitmap with its pixels already locked.
+ */
+ static bool Find(uint32_t genID, int width, int height, SkBitmap* result);
+ static void Add(uint32_t genID, int width, int height, const SkBitmap& result);
};
class SkMipMapCache {
public:
- typedef SkScaledImageCache::ID ID;
-
- static void Unlock(ID* id) {
- SkScaledImageCache::Unlock(id);
- }
-
- static ID* FindAndLock(const SkBitmap& src, const SkMipMap** result);
- static ID* AddAndLock(const SkBitmap& src, const SkMipMap* result);
+ static const SkMipMap* FindAndRef(const SkBitmap& src);
+ static void Add(const SkBitmap& src, const SkMipMap* result);
};
#endif