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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 * | 145 * |
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 struct SupportedSizes { | |
156 SkISize fSizes[2]; | |
157 }; | |
158 | |
159 /** | |
160 * Some generators can efficiently scale their contents. If this is support ed, the generator | |
161 * may only support certain scaled dimensions. Call this with the desired s cale factor, | |
162 * and it will return true if scaling is supported, and in supportedSizes[] it will return | |
163 * the nearest supported dimensions. | |
164 * | |
165 * If no native scaling is supported, or scale is invalid (e.g. scale <= 0 || scale > 1) | |
166 * this will return false, and the supportedsizes will be undefined. | |
167 */ | |
168 bool computeScaledDimensions(SkScalar scale, SupportedSizes*); | |
msarett
2015/11/30 21:24:26
I remember that we wanted fSizes[0] to be smaller
reed1
2015/11/30 21:29:19
I'm not sure what "smaller" means anymore, since t
| |
169 | |
170 /** | |
171 * Scale the generator's pixels to fit into scaledSize. | |
172 * This routine also support retrieving only a subset of the pixels. That s ubset is specified | |
173 * by the following rectangle (in the scaled space): | |
174 * | |
175 * subset = SkIRect::MakeXYWH(subsetOrigin.x(), subsetOrigin.y(), | |
176 * subsetPixels.width(), subsetPixels.height ()) | |
177 * | |
178 * If subset is not contained inside the scaledSize, this returns false. | |
179 * | |
180 * whole = SkIRect::MakeWH(scaledSize.width(), scaledSize.height()) | |
181 * if (!whole.contains(subset)) { | |
182 * return false; | |
183 * } | |
184 * | |
185 * If the requested colortype/alphatype in pixels is not supported, | |
186 * or the requested scaledSize is not supported, or the generator encounter s an error, | |
187 * this returns false. | |
188 */ | |
189 bool generateScaledPixels(const SkISize& scaledSize, const SkIPoint& subsetO rigin, | |
190 const SkPixmap& subsetPixels); | |
191 | |
192 bool generateScaledPixels(const SkPixmap& scaledPixels) { | |
193 return this->generateScaledPixels(SkISize::Make(scaledPixels.width(), | |
194 scaledPixels.height()), | |
195 SkIPoint::Make(0, 0), scaledPixels); | |
196 } | |
197 | |
155 /** | 198 /** |
156 * If the default image decoder system can interpret the specified (encoded ) data, then | 199 * 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 | 200 * 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 . | 201 * the caller is still responsible for managing their ownership of the data . |
159 */ | 202 */ |
160 static SkImageGenerator* NewFromEncoded(SkData*); | 203 static SkImageGenerator* NewFromEncoded(SkData*); |
161 | 204 |
162 /** Return a new image generator backed by the specified picture. If the si ze is empty or | 205 /** 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. | 206 * the picture is NULL, this returns NULL. |
164 * The optional matrix and paint arguments are passed to drawPicture() at r asterization | 207 * The optional matrix and paint arguments are passed to drawPicture() at r asterization |
(...skipping 27 matching lines...) Expand all Loading... | |
192 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, | 235 virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBy tes, |
193 SkPMColor ctable[], int* ctableCount); | 236 SkPMColor ctable[], int* ctableCount); |
194 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3]); | 237 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], | 238 virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBy tes[3], |
196 SkYUVColorSpace* colorSpace); | 239 SkYUVColorSpace* colorSpace); |
197 | 240 |
198 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { | 241 virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) { |
199 return nullptr; | 242 return nullptr; |
200 } | 243 } |
201 | 244 |
245 virtual bool onComputeScaledDimensions(SkScalar, SupportedSizes*) { | |
246 return false; | |
247 } | |
248 virtual bool onGenerateScaledPixels(const SkISize&, const SkIPoint&, const S kPixmap&) { | |
249 return false; | |
250 } | |
251 | |
202 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*); | 252 bool tryGenerateBitmap(SkBitmap* bm, const SkImageInfo* optionalInfo, SkBitm ap::Allocator*); |
203 | 253 |
204 private: | 254 private: |
205 const SkImageInfo fInfo; | 255 const SkImageInfo fInfo; |
206 const uint32_t fUniqueID; | 256 const uint32_t fUniqueID; |
207 | 257 |
208 // This is our default impl, which may be different on different platforms. | 258 // 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. | 259 // 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. | 260 // The SkData will never be NULL, as that will have been checked by NewFromE ncoded. |
211 static SkImageGenerator* NewFromEncodedImpl(SkData*); | 261 static SkImageGenerator* NewFromEncodedImpl(SkData*); |
212 }; | 262 }; |
213 | 263 |
214 #endif // SkImageGenerator_DEFINED | 264 #endif // SkImageGenerator_DEFINED |
OLD | NEW |