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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 */ | 61 */ |
62 SkData* refEncoded(GrContext*); | 62 SkData* refEncoded(GrContext*); |
63 | 63 |
64 // Only return true if the generate has already been cached. | 64 // Only return true if the generate has already been cached. |
65 bool lockAsBitmapOnlyIfAlreadyCached(SkBitmap*); | 65 bool lockAsBitmapOnlyIfAlreadyCached(SkBitmap*); |
66 // Call the underlying generator directly | 66 // Call the underlying generator directly |
67 bool directGeneratePixels(const SkImageInfo& dstInfo, void* dstPixels, size_
t dstRB, | 67 bool directGeneratePixels(const SkImageInfo& dstInfo, void* dstPixels, size_
t dstRB, |
68 int srcX, int srcY); | 68 int srcX, int srcY); |
69 | 69 |
70 private: | 70 private: |
71 SkImageCacherator(SkImageGenerator*, const SkImageInfo&, const SkIPoint&, ui
nt32_t uniqueID); | 71 struct Validator { |
| 72 Validator(SkImageGenerator*, const SkIRect* subset); |
| 73 |
| 74 operator bool() const { return fGenerator.get(); } |
| 75 |
| 76 std::unique_ptr<SkImageGenerator> fGenerator; |
| 77 SkImageInfo fInfo; |
| 78 SkIPoint fOrigin; |
| 79 uint32_t fUniqueID; |
| 80 }; |
| 81 |
| 82 SkImageCacherator(Validator*); |
72 | 83 |
73 bool generateBitmap(SkBitmap*); | 84 bool generateBitmap(SkBitmap*); |
74 bool tryLockAsBitmap(SkBitmap*, const SkImage*, SkImage::CachingHint); | 85 bool tryLockAsBitmap(SkBitmap*, const SkImage*, SkImage::CachingHint); |
75 #if SK_SUPPORT_GPU | 86 #if SK_SUPPORT_GPU |
76 // Returns the texture. If the cacherator is generating the texture and want
s to cache it, | 87 // Returns the texture. If the cacherator is generating the texture and want
s to cache it, |
77 // it should use the passed in key (if the key is valid). | 88 // it should use the passed in key (if the key is valid). |
78 GrTexture* lockTexture(GrContext*, const GrUniqueKey& key, const SkImage* cl
ient, | 89 GrTexture* lockTexture(GrContext*, const GrUniqueKey& key, const SkImage* cl
ient, |
79 SkImage::CachingHint, bool willBeMipped, SkSourceGamm
aTreatment); | 90 SkImage::CachingHint, bool willBeMipped, SkSourceGamm
aTreatment); |
80 #endif | 91 #endif |
81 | 92 |
(...skipping 11 matching lines...) Expand all Loading... |
93 }; | 104 }; |
94 | 105 |
95 SkMutex fMutexForGenerator; | 106 SkMutex fMutexForGenerator; |
96 SkAutoTDelete<SkImageGenerator> fNotThreadSafeGenerator; | 107 SkAutoTDelete<SkImageGenerator> fNotThreadSafeGenerator; |
97 | 108 |
98 const SkImageInfo fInfo; | 109 const SkImageInfo fInfo; |
99 const SkIPoint fOrigin; | 110 const SkIPoint fOrigin; |
100 const uint32_t fUniqueID; | 111 const uint32_t fUniqueID; |
101 | 112 |
102 friend class GrImageTextureMaker; | 113 friend class GrImageTextureMaker; |
| 114 friend class SkImage; |
| 115 friend class SkImage_Generator; |
103 }; | 116 }; |
104 | 117 |
105 #endif | 118 #endif |
OLD | NEW |