OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 SkImage_DEFINED | 8 #ifndef SkImage_DEFINED |
9 #define SkImage_DEFINED | 9 #define SkImage_DEFINED |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 * | 58 * |
59 * Returns NULL if the requested Info is unsupported. | 59 * Returns NULL if the requested Info is unsupported. |
60 */ | 60 */ |
61 static SkImage* NewFromRaster(const Info&, const void* pixels, size_t rowByt es, | 61 static SkImage* NewFromRaster(const Info&, const void* pixels, size_t rowByt es, |
62 RasterReleaseProc, ReleaseContext); | 62 RasterReleaseProc, ReleaseContext); |
63 | 63 |
64 /** | 64 /** |
65 * Construct a new SkImage based on the given ImageGenerator. | 65 * Construct a new SkImage based on the given ImageGenerator. |
66 * This function will always take ownership of the passed | 66 * This function will always take ownership of the passed |
67 * ImageGenerator. Returns NULL on error. | 67 * ImageGenerator. Returns NULL on error. |
68 * | |
69 * If a subset is specified, it must be contained within the generator's bo unds. | |
68 */ | 70 */ |
69 static SkImage* NewFromGenerator(SkImageGenerator*); | 71 static SkImage* NewFromGenerator(SkImageGenerator*, const SkIRect* subset = NULL); |
70 | 72 |
71 /** | 73 /** |
72 * Construct a new SkImage based on the specified encoded data. Returns NUL L on failure, | 74 * Construct a new SkImage based on the specified encoded data. Returns NUL L on failure, |
73 * which can mean that the format of the encoded data was not recognized/su pported. | 75 * which can mean that the format of the encoded data was not recognized/su pported. |
74 * | 76 * |
77 * If a subset is specified, it must be contained within the encoded data's bounds. | |
78 * | |
75 * Regardless of success or failure, the caller is responsible for managing their ownership | 79 * Regardless of success or failure, the caller is responsible for managing their ownership |
76 * of the data. | 80 * of the data. |
77 */ | 81 */ |
78 static SkImage* NewFromData(SkData* data); | 82 static SkImage* NewFromEncoded(SkData* encoded, const SkIRect* subset = NULL ); |
83 | |
84 #ifdef SK_SUPPORT_LEGACY_IMAGE_NEWFROMDATA | |
85 static SkImage* NewFromData(SkData* data) { | |
86 return NewFromEncoded(data, NULL); | |
87 } | |
88 #endif | |
79 | 89 |
80 /** | 90 /** |
81 * Create a new image from the specified descriptor. Note - the caller is r esponsible for | 91 * Create a new image from the specified descriptor. Note - the caller is r esponsible for |
82 * managing the lifetime of the underlying platform texture. | 92 * managing the lifetime of the underlying platform texture. |
83 * | 93 * |
84 * Will return NULL if the specified descriptor is unsupported. | 94 * Will return NULL if the specified descriptor is unsupported. |
85 */ | 95 */ |
86 static SkImage* NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& d esc) { | 96 static SkImage* NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& d esc) { |
87 return NewFromTexture(ctx, desc, kPremul_SkAlphaType, NULL, NULL); | 97 return NewFromTexture(ctx, desc, kPremul_SkAlphaType, NULL, NULL); |
88 } | 98 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 * If the image has direct access to its pixels (i.e. they are in local | 154 * If the image has direct access to its pixels (i.e. they are in local |
145 * RAM) return the (const) address of those pixels, and if not null, return | 155 * RAM) return the (const) address of those pixels, and if not null, return |
146 * the ImageInfo and rowBytes. The returned address is only valid while | 156 * the ImageInfo and rowBytes. The returned address is only valid while |
147 * the image object is in scope. | 157 * the image object is in scope. |
148 * | 158 * |
149 * On failure, returns NULL and the info and rowBytes parameters are | 159 * On failure, returns NULL and the info and rowBytes parameters are |
150 * ignored. | 160 * ignored. |
151 */ | 161 */ |
152 const void* peekPixels(SkImageInfo* info, size_t* rowBytes) const; | 162 const void* peekPixels(SkImageInfo* info, size_t* rowBytes) const; |
153 | 163 |
164 /** | |
165 * If the image has direct access to its pixels (i.e. they are in local | |
166 * RAM) return the (const) address of those pixels, and if not null, return | |
167 * the true, and if pixmap is not NULL, set it to point into the image. | |
scroggo
2015/06/22 17:40:00
nit: "the" at the beginning of the line is not nee
reed1
2015/06/22 18:41:50
Done.
| |
168 * | |
169 * On failure, return false and ignore the pixmap parameter. | |
170 */ | |
171 bool peekPixels(SkPixmap* pixmap) const; | |
172 | |
154 // DEPRECATED | 173 // DEPRECATED |
155 GrTexture* getTexture() const; | 174 GrTexture* getTexture() const; |
156 | 175 |
157 /** | 176 /** |
158 * Returns true if the image is texture backed. | 177 * Returns true if the image is texture backed. |
159 */ | 178 */ |
160 bool isTextureBacked() const; | 179 bool isTextureBacked() const; |
161 | 180 |
162 /** | 181 /** |
163 * Retrieves the backend API handle of the texture. If flushPendingGrContex tReads then the | 182 * Retrieves the backend API handle of the texture. If flushPendingGrContex tReads then the |
(...skipping 16 matching lines...) Expand all Loading... | |
180 * corresponding src pixels, performing any colortype/alphatype transformat ions needed | 199 * corresponding src pixels, performing any colortype/alphatype transformat ions needed |
181 * (in the case where the src and dst have different colortypes or alphatyp es). | 200 * (in the case where the src and dst have different colortypes or alphatyp es). |
182 * | 201 * |
183 * This call can fail, returning false, for several reasons: | 202 * This call can fail, returning false, for several reasons: |
184 * - If srcR does not intersect the image bounds. | 203 * - If srcR does not intersect the image bounds. |
185 * - If the requested colortype/alphatype cannot be converted from the imag e's types. | 204 * - If the requested colortype/alphatype cannot be converted from the imag e's types. |
186 */ | 205 */ |
187 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy tes, | 206 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy tes, |
188 int srcX, int srcY) const; | 207 int srcX, int srcY) const; |
189 | 208 |
209 bool readPixels(const SkPixmap& dst, int srcX, int srcY) const; | |
210 | |
190 /** | 211 /** |
191 * Encode the image's pixels and return the result as a new SkData, which | 212 * Encode the image's pixels and return the result as a new SkData, which |
192 * the caller must manage (i.e. call unref() when they are done). | 213 * the caller must manage (i.e. call unref() when they are done). |
193 * | 214 * |
194 * If the image type cannot be encoded, or the requested encoder type is | 215 * If the image type cannot be encoded, or the requested encoder type is |
195 * not supported, this will return NULL. | 216 * not supported, this will return NULL. |
196 */ | 217 */ |
197 SkData* encode(SkImageEncoder::Type t = SkImageEncoder::kPNG_Type, | 218 SkData* encode(SkImageEncoder::Type, int quality) const; |
198 int quality = 80) const; | 219 |
220 SkData* encode() const { | |
221 return this->encode(SkImageEncoder::kPNG_Type, 100); | |
222 } | |
223 | |
224 /** | |
225 * If the image already has its contents in encoded form (e.g. PNG or JPEG) , return a ref | |
226 * to that data (which the caller must call unref() on). The caller is resp onsible for calling | |
227 * unref on the data when they are done. | |
228 * | |
229 * If the image does not already has its contents in encoded form, return N ULL. | |
230 * | |
231 * Note: to force the image to return its contents as encoded data, try cal ling encode(...). | |
232 */ | |
233 SkData* refEncoded() const; | |
199 | 234 |
200 /** | 235 /** |
201 * Return a new surface that is compatible with this image's internal repre sentation | 236 * Return a new surface that is compatible with this image's internal repre sentation |
202 * (e.g. raster or gpu). | 237 * (e.g. raster or gpu). |
203 * | 238 * |
204 * If no surfaceprops are specified, the image will attempt to match the pr ops of when it | 239 * If no surfaceprops are specified, the image will attempt to match the pr ops of when it |
205 * was created (if it came from a surface). | 240 * was created (if it came from a surface). |
206 */ | 241 */ |
207 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL) cons t; | 242 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL) cons t; |
208 | 243 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 const int fWidth; | 278 const int fWidth; |
244 const int fHeight; | 279 const int fHeight; |
245 const uint32_t fUniqueID; | 280 const uint32_t fUniqueID; |
246 | 281 |
247 static uint32_t NextUniqueID(); | 282 static uint32_t NextUniqueID(); |
248 | 283 |
249 typedef SkRefCnt INHERITED; | 284 typedef SkRefCnt INHERITED; |
250 }; | 285 }; |
251 | 286 |
252 #endif | 287 #endif |
OLD | NEW |