OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 SkImageGenerator_DEFINED | 8 #ifndef SkImageGenerator_DEFINED |
9 #define SkImageGenerator_DEFINED | 9 #define SkImageGenerator_DEFINED |
10 | 10 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 static SkImageGenerator* NewFromEncoded(SkData*); | 158 static SkImageGenerator* NewFromEncoded(SkData*); |
159 | 159 |
160 /** Return a new image generator backed by the specified picture. If the si
ze is empty or | 160 /** Return a new image generator backed by the specified picture. If the si
ze is empty or |
161 * the picture is NULL, this returns NULL. | 161 * the picture is NULL, this returns NULL. |
162 * The optional matrix and paint arguments are passed to drawPicture() at r
asterization | 162 * The optional matrix and paint arguments are passed to drawPicture() at r
asterization |
163 * time. | 163 * time. |
164 */ | 164 */ |
165 static SkImageGenerator* NewFromPicture(const SkISize&, const SkPicture*, co
nst SkMatrix*, | 165 static SkImageGenerator* NewFromPicture(const SkISize&, const SkPicture*, co
nst SkMatrix*, |
166 const SkPaint*); | 166 const SkPaint*); |
167 | 167 |
| 168 bool tryGenerateBitmap(SkBitmap* bm) { |
| 169 return this->tryGenerateBitmap(bm, nullptr); |
| 170 } |
| 171 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo& info) { |
| 172 return this->tryGenerateBitmap(bm, &info); |
| 173 } |
| 174 void generateBitmap(SkBitmap* bm) { |
| 175 if (!this->tryGenerateBitmap(bm, nullptr)) { |
| 176 sk_throw(); |
| 177 } |
| 178 } |
| 179 void generateBitmap(SkBitmap* bm, const SkImageInfo& info) { |
| 180 if (!this->tryGenerateBitmap(bm, &info)) { |
| 181 sk_throw(); |
| 182 } |
| 183 } |
| 184 |
168 protected: | 185 protected: |
169 SkImageGenerator(const SkImageInfo& info); | 186 SkImageGenerator(const SkImageInfo& info); |
170 | 187 |
171 virtual SkData* onRefEncodedData(); | 188 virtual SkData* onRefEncodedData(); |
172 | 189 |
173 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy
tes, | 190 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy
tes, |
174 SkPMColor ctable[], int* ctableCount); | 191 SkPMColor ctable[], int* ctableCount); |
175 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3]); | 192 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3]); |
176 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], | 193 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy
tes[3], |
177 SkYUVColorSpace* colorSpace); | 194 SkYUVColorSpace* colorSpace); |
178 | 195 |
179 virtual GrTexture* onGenerateTexture(GrContext*, SkImageUsageType, const SkI
Rect*) { | 196 virtual GrTexture* onGenerateTexture(GrContext*, SkImageUsageType, const SkI
Rect*) { |
180 return nullptr; | 197 return nullptr; |
181 } | 198 } |
182 | 199 |
| 200 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo); |
| 201 |
183 private: | 202 private: |
184 const SkImageInfo fInfo; | 203 const SkImageInfo fInfo; |
185 const uint32_t fUniqueID; | 204 const uint32_t fUniqueID; |
186 | 205 |
187 // This is our default impl, which may be different on different platforms. | 206 // This is our default impl, which may be different on different platforms. |
188 // It is called from NewFromEncoded() after it has checked for any runtime f
actory. | 207 // It is called from NewFromEncoded() after it has checked for any runtime f
actory. |
189 // The SkData will never be NULL, as that will have been checked by NewFromE
ncoded. | 208 // The SkData will never be NULL, as that will have been checked by NewFromE
ncoded. |
190 static SkImageGenerator* NewFromEncodedImpl(SkData*); | 209 static SkImageGenerator* NewFromEncodedImpl(SkData*); |
191 }; | 210 }; |
192 | 211 |
193 #endif // SkImageGenerator_DEFINED | 212 #endif // SkImageGenerator_DEFINED |
OLD | NEW |