OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 SkImageCacherator_DEFINED | 8 #ifndef SkImageCacherator_DEFINED |
9 #define SkImageCacherator_DEFINED | 9 #define SkImageCacherator_DEFINED |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 const SkImageInfo& info() const { return fInfo; } | 29 const SkImageInfo& info() const { return fInfo; } |
30 uint32_t uniqueID() const { return fUniqueID; } | 30 uint32_t uniqueID() const { return fUniqueID; } |
31 | 31 |
32 /** | 32 /** |
33 * On success (true), bitmap will point to the pixels for this generator. I
f this returns | 33 * On success (true), bitmap will point to the pixels for this generator. I
f this returns |
34 * false, the bitmap will be reset to empty. | 34 * false, the bitmap will be reset to empty. |
35 * | 35 * |
36 * If not NULL, the client will be notified (->notifyAddedToCache()) when r
esources are | 36 * If not NULL, the client will be notified (->notifyAddedToCache()) when r
esources are |
37 * added to the cache on its behalf. | 37 * added to the cache on its behalf. |
38 */ | 38 */ |
39 bool lockAsBitmap(SkBitmap*, const SkImage* client); | 39 bool lockAsBitmap(SkBitmap*, const SkImage* client, SkScalar scaleHint = SK_
Scalar1); |
40 | 40 |
41 /** | 41 /** |
42 * Returns a ref() on the texture produced by this generator. The caller mu
st call unref() | 42 * Returns a ref() on the texture produced by this generator. The caller mu
st call unref() |
43 * when it is done. Will return nullptr on failure. | 43 * when it is done. Will return nullptr on failure. |
44 * | 44 * |
45 * If not NULL, the client will be notified (->notifyAddedToCache()) when r
esources are | 45 * If not NULL, the client will be notified (->notifyAddedToCache()) when r
esources are |
46 * added to the cache on its behalf. | 46 * added to the cache on its behalf. |
47 * | 47 * |
48 * The caller is responsible for calling texture->unref() when they are don
e. | 48 * The caller is responsible for calling texture->unref() when they are don
e. |
49 */ | 49 */ |
50 GrTexture* lockAsTexture(GrContext*, const GrTextureParams&, const SkImage*
client); | 50 GrTexture* lockAsTexture(GrContext*, const GrTextureParams&, const SkImage*
client); |
51 | 51 |
52 /** | 52 /** |
53 * If the underlying src naturally is represented by an encoded blob (in Sk
Data), this returns | 53 * If the underlying src naturally is represented by an encoded blob (in Sk
Data), this returns |
54 * a ref to that data. If not, it returns null. | 54 * a ref to that data. If not, it returns null. |
55 */ | 55 */ |
56 SkData* refEncoded(); | 56 SkData* refEncoded(); |
57 | 57 |
58 private: | 58 private: |
59 SkImageCacherator(SkImageGenerator*, const SkImageInfo&, const SkIPoint&, ui
nt32_t uniqueID); | 59 SkImageCacherator(SkImageGenerator*, const SkImageInfo&, const SkIPoint&, ui
nt32_t uniqueID); |
60 | 60 |
61 bool generateBitmap(SkBitmap*); | 61 bool generateBitmap(SkBitmap*, SkScalar scaleHint); |
62 bool tryLockAsBitmap(SkBitmap*, const SkImage*); | 62 bool tryLockAsBitmap(SkBitmap*, const SkImage*, SkScalar scaleHint = SK_Scal
ar1); |
63 #if SK_SUPPORT_GPU | 63 #if SK_SUPPORT_GPU |
64 // Returns the texture. If the cacherator is generating the texture and want
s to cache it, | 64 // Returns the texture. If the cacherator is generating the texture and want
s to cache it, |
65 // it should use the passed in key (if the key is valid). | 65 // it should use the passed in key (if the key is valid). |
66 GrTexture* lockTexture(GrContext*, const GrUniqueKey& key, const SkImage* cl
ient); | 66 GrTexture* lockTexture(GrContext*, const GrUniqueKey& key, const SkImage* cl
ient); |
67 #endif | 67 #endif |
68 | 68 |
69 class ScopedGenerator { | 69 class ScopedGenerator { |
70 SkImageCacherator* fCacher; | 70 SkImageCacherator* fCacher; |
71 public: | 71 public: |
72 ScopedGenerator(SkImageCacherator* cacher) : fCacher(cacher) { | 72 ScopedGenerator(SkImageCacherator* cacher) : fCacher(cacher) { |
(...skipping 10 matching lines...) Expand all Loading... |
83 SkAutoTDelete<SkImageGenerator> fNotThreadSafeGenerator; | 83 SkAutoTDelete<SkImageGenerator> fNotThreadSafeGenerator; |
84 | 84 |
85 const SkImageInfo fInfo; | 85 const SkImageInfo fInfo; |
86 const SkIPoint fOrigin; | 86 const SkIPoint fOrigin; |
87 const uint32_t fUniqueID; | 87 const uint32_t fUniqueID; |
88 | 88 |
89 friend class Cacherator_GrTextureParamsAdjuster; | 89 friend class Cacherator_GrTextureParamsAdjuster; |
90 }; | 90 }; |
91 | 91 |
92 #endif | 92 #endif |
OLD | NEW |