| 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 SkMipMap; | 14 class SkMipMap; |
| 15 | 15 |
| 16 class SkBitmapCache { | 16 class SkBitmapCache { |
| 17 public: | 17 public: |
| 18 /** | 18 /** |
| 19 * Use this allocator for bitmaps, so they can use ashmem when available. | 19 * Use this allocator for bitmaps, so they can use ashmem when available. |
| 20 * Returns NULL if the ResourceCache has not been initialized with a Discard
ableFactory. |
| 20 */ | 21 */ |
| 21 static SkBitmap::Allocator* GetAllocator(); | 22 static SkBitmap::Allocator* GetAllocator(); |
| 22 | 23 |
| 23 /** | 24 /** |
| 24 * Search based on the src bitmap and inverse scales in X and Y. If found,
returns true and | 25 * Search based on the src bitmap and inverse scales in X and Y. If found,
returns true and |
| 25 * result will be set to the matching bitmap with its pixels already locked
. | 26 * result will be set to the matching bitmap with its pixels already locked
. |
| 26 */ | 27 */ |
| 27 static bool Find(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY
, SkBitmap* result); | 28 static bool Find(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY
, SkBitmap* result); |
| 28 | 29 |
| 29 /* | 30 /* |
| 30 * result must be marked isImmutable() | 31 * result must be marked isImmutable() |
| 31 */ | 32 */ |
| 32 static void Add(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY, | 33 static void Add(const SkBitmap& src, SkScalar invScaleX, SkScalar invScaleY, |
| 33 const SkBitmap& result); | 34 const SkBitmap& result); |
| 34 | 35 |
| 35 /** | 36 /** |
| 36 * Search based on the bitmap's genID, width, height. If found, returns tru
e and | 37 * Search based on the bitmap's genID, width, height. If found, returns tru
e and |
| 37 * result will be set to the matching bitmap with its pixels already locked
. | 38 * result will be set to the matching bitmap with its pixels already locked
. |
| 38 */ | 39 */ |
| 39 static bool Find(uint32_t genID, int width, int height, SkBitmap* result); | 40 static bool Find(uint32_t genID, int width, int height, SkBitmap* result); |
| 40 | 41 |
| 41 /* | 42 /* |
| 42 * result must be marked isImmutable() | 43 * result must be marked isImmutable() |
| 43 */ | 44 */ |
| 44 static void Add(uint32_t genID, int width, int height, const SkBitmap& resul
t); | 45 static void Add(uint32_t genID, int width, int height, const SkBitmap& resul
t); |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 class SkMipMapCache { | 48 class SkMipMapCache { |
| 48 public: | 49 public: |
| 49 static const SkMipMap* FindAndRef(const SkBitmap& src); | 50 static const SkMipMap* FindAndRef(const SkBitmap& src); |
| 50 static void Add(const SkBitmap& src, const SkMipMap* result); | 51 static void Add(const SkBitmap& src, const SkMipMap* result); |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 #endif | 54 #endif |
| OLD | NEW |