OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 SkBitmapFactory_DEFINED | 8 #ifndef SkBitmapFactory_DEFINED |
9 #define SkBitmapFactory_DEFINED | 9 #define SkBitmapFactory_DEFINED |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 /** | 33 /** |
34 * Rowbytes of the allocated memory. | 34 * Rowbytes of the allocated memory. |
35 */ | 35 */ |
36 size_t fRowBytes; | 36 size_t fRowBytes; |
37 }; | 37 }; |
38 | 38 |
39 /** | 39 /** |
40 * Signature for a function to decode an image from encoded data. | 40 * Signature for a function to decode an image from encoded data. |
41 */ | 41 */ |
42 typedef bool (*DecodeProc)(const void* data, size_t length, SkImage::Info*,
const Target*); | 42 typedef bool (*DecodeProc)(const void* data, size_t length, SkImageInfo*, co
nst Target*); |
43 | 43 |
44 /** | 44 /** |
45 * Create a bitmap factory which uses DecodeProc for decoding. | 45 * Create a bitmap factory which uses DecodeProc for decoding. |
46 * @param DecodeProc Must not be NULL. | 46 * @param DecodeProc Must not be NULL. |
47 */ | 47 */ |
48 SkBitmapFactory(DecodeProc); | 48 SkBitmapFactory(DecodeProc); |
49 | 49 |
50 ~SkBitmapFactory(); | 50 ~SkBitmapFactory(); |
51 | 51 |
52 /** | 52 /** |
53 * Set an image cache to use on pixelrefs provided by installPixelRef. Mutu
ally exclusive | 53 * Set an image cache to use on pixelrefs provided by installPixelRef. Mutu
ally exclusive |
54 * with fCacheSelector. | 54 * with fCacheSelector. |
55 */ | 55 */ |
56 void setImageCache(SkImageCache* cache); | 56 void setImageCache(SkImageCache* cache); |
57 | 57 |
58 /** | 58 /** |
59 * Sets up an SkBitmap from encoded data. On success, the SkBitmap will hav
e its Config, | 59 * Sets up an SkBitmap from encoded data. On success, the SkBitmap will hav
e its Config, |
60 * width, height, rowBytes and pixelref set. If fImageCache is non-NULL, or
if fCacheSelector | 60 * width, height, rowBytes and pixelref set. If fImageCache is non-NULL, or
if fCacheSelector |
61 * is set and returns non-NULL, the pixelref will lazily decode, and that S
kImageCache will | 61 * is set and returns non-NULL, the pixelref will lazily decode, and that S
kImageCache will |
62 * handle the pixel memory. Otherwise installPixelRef will do an immediate
decode. | 62 * handle the pixel memory. Otherwise installPixelRef will do an immediate
decode. |
63 * @param SkData Encoded data. | 63 * @param SkData Encoded data. |
64 * @param SkBitmap to install the pixel ref on. | 64 * @param SkBitmap to install the pixel ref on. |
65 * @return bool Whether or not a pixel ref was successfully installed. | 65 * @return bool Whether or not a pixel ref was successfully installed. |
66 */ | 66 */ |
67 bool installPixelRef(SkData*, SkBitmap*); | 67 bool installPixelRef(SkData*, SkBitmap*); |
68 | 68 |
69 /** | 69 /** |
70 * An object for selecting an SkImageCache to use based on an SkImage::Info
. | 70 * An object for selecting an SkImageCache to use based on an SkImageInfo. |
71 */ | 71 */ |
72 class CacheSelector : public SkRefCnt { | 72 class CacheSelector : public SkRefCnt { |
73 | 73 |
74 public: | 74 public: |
75 SK_DECLARE_INST_COUNT(CacheSelector) | 75 SK_DECLARE_INST_COUNT(CacheSelector) |
76 /** | 76 /** |
77 * Return an SkImageCache to use based on the provided SkImage::Info. I
f the caller decides | 77 * Return an SkImageCache to use based on the provided SkImageInfo. If
the caller decides |
78 * to hang on to the result, it will call ref, so the implementation sh
ould not add a ref | 78 * to hang on to the result, it will call ref, so the implementation sh
ould not add a ref |
79 * as a result of this call. | 79 * as a result of this call. |
80 */ | 80 */ |
81 virtual SkImageCache* selectCache(const SkImage::Info&) = 0; | 81 virtual SkImageCache* selectCache(const SkImageInfo&) = 0; |
82 | 82 |
83 private: | 83 private: |
84 typedef SkRefCnt INHERITED; | 84 typedef SkRefCnt INHERITED; |
85 }; | 85 }; |
86 | 86 |
87 /** | 87 /** |
88 * Set the function to be used to select which SkImageCache to use. Mutuall
y exclusive with | 88 * Set the function to be used to select which SkImageCache to use. Mutuall
y exclusive with |
89 * fImageCache. | 89 * fImageCache. |
90 */ | 90 */ |
91 void setCacheSelector(CacheSelector*); | 91 void setCacheSelector(CacheSelector*); |
92 | 92 |
93 private: | 93 private: |
94 DecodeProc fDecodeProc; | 94 DecodeProc fDecodeProc; |
95 SkImageCache* fImageCache; | 95 SkImageCache* fImageCache; |
96 CacheSelector* fCacheSelector; | 96 CacheSelector* fCacheSelector; |
97 }; | 97 }; |
98 | 98 |
99 #endif // SkBitmapFactory_DEFINED | 99 #endif // SkBitmapFactory_DEFINED |
OLD | NEW |