aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapCache.h
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-04-11 12:03:44 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-11 16:38:17 +0000
commit7a542c559a6e584107b94e6254ac3c7f9f24b591 (patch)
tree9186b5ae154b580e20b3dc40f437e44f546c467b /src/core/SkBitmapCache.h
parent77443974ea96912fa39079a4bf82ab791ec3c922 (diff)
Change bitmapcache to not rely on lockpixels.
The Rec in the cache is the owner of the pixel memory - discardable or - malloc Each external client has a pixelref that just points to those pixels, and whose destructor will notify the rec. This eliminates the dependency on lockPixels in pixelref, freeing us to remove that entirely from pixelref. Bug: skia: Change-Id: If45ed0ae202a1211336626364235215253e8aa7c Reviewed-on: https://skia-review.googlesource.com/10300 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/core/SkBitmapCache.h')
-rw-r--r--src/core/SkBitmapCache.h23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/core/SkBitmapCache.h b/src/core/SkBitmapCache.h
index 907a5468b6..a59dcb5a12 100644
--- a/src/core/SkBitmapCache.h
+++ b/src/core/SkBitmapCache.h
@@ -45,23 +45,20 @@ struct SkBitmapCacheDesc {
class SkBitmapCache {
public:
/**
- * Use this allocator for bitmaps, so they can use ashmem when available.
- * Returns nullptr if the ResourceCache has not been initialized with a DiscardableFactory.
- */
- static SkBitmap::Allocator* GetAllocator();
-
- /**
* 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 Find(const SkBitmapCacheDesc&, SkBitmap* result,
- SkResourceCache* localCache = nullptr);
+ static bool Find(const SkBitmapCacheDesc&, SkBitmap* result);
- /*
- * result must be marked isImmutable()
- */
- static bool Add(const SkBitmapCacheDesc&, const SkBitmap& result,
- SkResourceCache* localCache = nullptr);
+ class Rec;
+ struct RecDeleter { void operator()(Rec* r) { PrivateDeleteRec(r); } };
+ typedef std::unique_ptr<Rec, RecDeleter> RecPtr;
+
+ static RecPtr Alloc(const SkBitmapCacheDesc&, const SkImageInfo&, SkPixmap*);
+ static void Add(RecPtr, SkBitmap*);
+
+private:
+ static void PrivateDeleteRec(Rec*);
};
class SkMipMapCache {