| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #ifndef SkBitmapCache_DEFINED | 8 #ifndef SkBitmapCache_DEFINED |
| 9 #define SkBitmapCache_DEFINED | 9 #define SkBitmapCache_DEFINED |
| 10 | 10 |
| 11 #include "SkScalar.h" | 11 #include "SkScalar.h" |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 | 13 |
| 14 class SkResourceCache; | 14 class SkResourceCache; |
| 15 class SkMipMap; | 15 class SkMipMap; |
| 16 | 16 |
| 17 uint64_t SkMakeResourceCacheSharedIDForBitmap(uint32_t bitmapGenID); | 17 uint64_t SkMakeResourceCacheSharedIDForBitmap(uint32_t bitmapGenID); |
| 18 | 18 |
| 19 void SkNotifyBitmapGenIDIsStale(uint32_t bitmapGenID); | 19 void SkNotifyBitmapGenIDIsStale(uint32_t bitmapGenID); |
| 20 | 20 |
| 21 class SkBitmapCache { | 21 class SkBitmapCache { |
| 22 public: | 22 public: |
| 23 /** | 23 /** |
| 24 * Use this allocator for bitmaps, so they can use ashmem when available. | 24 * Use this allocator for bitmaps, so they can use ashmem when available. |
| 25 * Returns nullptr if the ResourceCache has not been initialized with a Disc
ardableFactory. | 25 * Returns nullptr if the ResourceCache has not been initialized with a Disc
ardableFactory. |
| 26 */ | 26 */ |
| 27 static SkBitmap::Allocator* GetAllocator(); | 27 static SkBitmap::Allocator* GetAllocator(); |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Search based on the src bitmap and inverse scales in X and Y. If found,
returns true and | 30 * Search based on the src bitmap and scaled width/height. If found, return
s true and |
| 31 * result will be set to the matching bitmap with its pixels already locked
. | 31 * result will be set to the matching bitmap with its pixels already locked
. |
| 32 */ | 32 */ |
| 33 static bool Find(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY
, SkBitmap* result, | 33 static bool FindWH(const SkBitmap& src, int width, int height, SkBitmap* res
ult, |
| 34 SkResourceCache* localCache = nullptr); | 34 SkResourceCache* localCache = nullptr); |
| 35 | 35 |
| 36 /* | 36 /* |
| 37 * result must be marked isImmutable() | 37 * result must be marked isImmutable() |
| 38 */ | 38 */ |
| 39 static void Add(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY, | 39 static void AddWH(const SkBitmap& src, int width, int height, const SkBitmap
& result, |
| 40 const SkBitmap& result, SkResourceCache* localCache = nullptr); | 40 SkResourceCache* localCache = nullptr); |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Search based on the bitmap's genID and subset. If found, returns true an
d | 43 * Search based on the bitmap's genID and subset. If found, returns true an
d |
| 44 * result will be set to the matching bitmap with its pixels already locked
. | 44 * result will be set to the matching bitmap with its pixels already locked
. |
| 45 */ | 45 */ |
| 46 static bool Find(uint32_t genID, const SkIRect& subset, SkBitmap* result, | 46 static bool Find(uint32_t genID, const SkIRect& subset, SkBitmap* result, |
| 47 SkResourceCache* localCache = nullptr); | 47 SkResourceCache* localCache = nullptr); |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * The width and the height of the provided subset must be the same as the r
esult bitmap ones. | 50 * The width and the height of the provided subset must be the same as the r
esult bitmap ones. |
| 51 * result must be marked isImmutable() | 51 * result must be marked isImmutable() |
| 52 */ | 52 */ |
| 53 static bool Add(SkPixelRef*, const SkIRect& subset, const SkBitmap& result, | 53 static bool Add(SkPixelRef*, const SkIRect& subset, const SkBitmap& result, |
| 54 SkResourceCache* localCache = nullptr); | 54 SkResourceCache* localCache = nullptr); |
| 55 | 55 |
| 56 static bool Find(uint32_t genID, SkBitmap* result, SkResourceCache* localCac
he = nullptr); | 56 static bool Find(uint32_t genID, SkBitmap* result, SkResourceCache* localCac
he = nullptr); |
| 57 // todo: eliminate the need to specify ID, since it should == the bitmap's | 57 // todo: eliminate the need to specify ID, since it should == the bitmap's |
| 58 static void Add(uint32_t genID, const SkBitmap&, SkResourceCache* localCache
= nullptr); | 58 static void Add(uint32_t genID, const SkBitmap&, SkResourceCache* localCache
= nullptr); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 class SkMipMapCache { | 61 class SkMipMapCache { |
| 62 public: | 62 public: |
| 63 static const SkMipMap* FindAndRef(const SkBitmap& src, SkResourceCache* loca
lCache = nullptr); | 63 static const SkMipMap* FindAndRef(const SkBitmap& src, SkResourceCache* loca
lCache = nullptr); |
| 64 static const SkMipMap* AddAndRef(const SkBitmap& src, SkResourceCache* local
Cache = nullptr); | 64 static const SkMipMap* AddAndRef(const SkBitmap& src, SkResourceCache* local
Cache = nullptr); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 #endif | 67 #endif |
| OLD | NEW |