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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 * Regarding the GrTextureParams parameter: | 146 * Regarding the GrTextureParams parameter: |
147 * | 147 * |
148 * If the context (the provided one or the generator's intrinsic one) deter mines that to | 148 * If the context (the provided one or the generator's intrinsic one) deter mines that to |
149 * support the specified usage, it must return a different sized texture it may, | 149 * support the specified usage, it must return a different sized texture it may, |
150 * so the caller must inspect the texture's width/height and compare them t o the generator's | 150 * so the caller must inspect the texture's width/height and compare them t o the generator's |
151 * getInfo() width/height. For readback usage use GrTextureParams::ClampNoF ilter() | 151 * getInfo() width/height. For readback usage use GrTextureParams::ClampNoF ilter() |
152 */ | 152 */ |
153 GrTexture* generateTexture(GrContext*, const SkIRect* subset = nullptr); | 153 GrTexture* generateTexture(GrContext*, const SkIRect* subset = nullptr); |
154 | 154 |
155 /** | 155 /** |
156 * Some generators can efficiently scale their contents. If this is support ed, the generator | |
157 * may only support certain scaled dimensions. Call this with the desired s cale factor, | |
158 * and it will return true if scaling is supported, and in supportedSizes[] it will return | |
159 * the two nearest supported dimensions... | |
160 * | |
161 * If the requested scale is exactly supported, then both entries | |
162 * supporedSizes[0] and supportedSizes[1] will hold the same dimensions. | |
163 * | |
164 * However, often the requested size may result in a fractional resulting w idth/height, | |
165 * and or not be natively supported by the generator. (e.g. the scale is 1/ 3, but the | |
166 * generator only performs native scaling on powers-of-2 fractions). In thi s case... | |
167 * - if the generator can natively scale at a smaller size (e.g. 1/4), that will be returned | |
168 * in supportedSizes[0] | |
169 * - if the generator can natively scale at a larger size (e.g. 1/2), that will be returned | |
170 * in supportedSizes[1] | |
171 * - if the generator can only natively scale smaller, or only larger, than the | |
172 * requested scale, then that 1 native size will returned in both [0] a nd [1]. | |
scroggo
2015/11/03 16:59:19
will be* returned
reed1
2015/11/30 20:38:01
Done.
| |
173 * | |
174 * If no native scaling is supported, or scale is invalid (e.g. scale <= 0 || scale > 1) | |
175 * this will return false, and supportedSizes[] will be undefined. | |
176 */ | |
177 bool computeScaledDimensions(SkScalar scale, SkISize supportedSizes[2]); | |
scroggo
2015/11/03 16:59:19
As stated in person, I'd prefer something other th
reed1
2015/11/30 20:38:01
Done.
| |
178 | |
scroggo
2015/11/03 16:59:19
Should computeScaledDimensions be const?
reed1
2015/11/30 20:38:01
None of the other methods are, though *all* are me
| |
179 /** | |
180 * Request that pixels be scaled to fit into the specified scaledInfo dimen sions. | |
181 * If scaledClip is not null, it specifies the subset of the scaled pixels that should | |
182 * be returned. It will be in the scaled coordinate system (not the origina l), and is only | |
183 * valid if it is entirely contained inside the scaled dimensions... | |
184 * | |
185 * SkIRect scaledBounds = SkIRect::MakeWH(0, 0, scaledInfo.width(), scaledI nfo.height()); | |
186 * bool valid = scaledBounds.contains(scaledClip); | |
187 * | |
188 * If the requested scaledInfo is not supported by the generator, or it enc ounters an error, | |
189 * or the scaledClip is invalid, this returns false and the contents of pix els is undefined. | |
190 */ | |
191 bool generateScaledPixels(const SkImageInfo& scaledInfo, void* pixels, size_ t rowBytes, | |
192 const SkIRect* scaledClip); | |
193 | |
194 /** | |
156 * If the default image decoder system can interpret the specified (encoded ) data, then | 195 * If the default image decoder system can interpret the specified (encoded ) data, then |
157 * this returns a new ImageGenerator for it. Otherwise this returns NULL. E ither way | 196 * this returns a new ImageGenerator for it. Otherwise this returns NULL. E ither way |
158 * the caller is still responsible for managing their ownership of the data . | 197 * the caller is still responsible for managing their ownership of the data . |
159 */ | 198 */ |
160 static SkImageGenerator* NewFromEncoded(SkData*); | 199 static SkImageGenerator* NewFromEncoded(SkData*); |
161 | 200 |
162 /** Return a new image generator backed by the specified picture. If the si ze is empty or | 201 /** Return a new image generator backed by the specified picture. If the si ze is empty or |
163 * the picture is NULL, this returns NULL. | 202 * the picture is NULL, this returns NULL. |
164 * The optional matrix and paint arguments are passed to drawPicture() at r asterization | 203 * The optional matrix and paint arguments are passed to drawPicture() at r asterization |
165 * time. | 204 * time. |
(...skipping 26 matching lines...) Expand all Loading... | |
192 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, | 231 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, |
193 SkPMColor ctable[], int* ctableCount); | 232 SkPMColor ctable[], int* ctableCount); |
194 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); | 233 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); |
195 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], | 234 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], |
196 SkYUVColorSpace* colorSpace); | 235 SkYUVColorSpace* colorSpace); |
197 | 236 |
198 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { | 237 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { |
199 return nullptr; | 238 return nullptr; |
200 } | 239 } |
201 | 240 |
241 virtual bool onComputeScaledDimensions(SkScalar scale, SkISize supportedSize s[2]) { | |
242 return false; | |
243 } | |
244 virtual bool onGenerateScaledPixels(const SkImageInfo& info, void* pixels, s ize_t rowBytes, | |
245 const SkIRect* subset) { | |
246 return false; | |
247 } | |
248 | |
202 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*); | 249 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*); |
203 | 250 |
204 private: | 251 private: |
205 const SkImageInfo fInfo; | 252 const SkImageInfo fInfo; |
206 const uint32_t fUniqueID; | 253 const uint32_t fUniqueID; |
207 | 254 |
208 // This is our default impl, which may be different on different platforms. | 255 // This is our default impl, which may be different on different platforms. |
209 // It is called from NewFromEncoded() after it has checked for any runtime f actory. | 256 // It is called from NewFromEncoded() after it has checked for any runtime f actory. |
210 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. | 257 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. |
211 static SkImageGenerator* NewFromEncodedImpl(SkData*); | 258 static SkImageGenerator* NewFromEncodedImpl(SkData*); |
212 }; | 259 }; |
213 | 260 |
214 #endif // SkImageGenerator_DEFINED | 261 #endif // SkImageGenerator_DEFINED |
OLD | NEW |