Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1101)

Side by Side Diff: include/core/SkImage.h

Issue 1199473002: change old picture serialization to really handle images (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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.
168 *
169 * On failure, return false and ignore the pixmap parameter.
170 */
171 bool peekPixmap(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 27 matching lines...) Expand all
191 * Encode the image's pixels and return the result as a new SkData, which 210 * 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). 211 * the caller must manage (i.e. call unref() when they are done).
193 * 212 *
194 * If the image type cannot be encoded, or the requested encoder type is 213 * If the image type cannot be encoded, or the requested encoder type is
195 * not supported, this will return NULL. 214 * not supported, this will return NULL.
196 */ 215 */
197 SkData* encode(SkImageEncoder::Type t = SkImageEncoder::kPNG_Type, 216 SkData* encode(SkImageEncoder::Type t = SkImageEncoder::kPNG_Type,
198 int quality = 80) const; 217 int quality = 80) const;
199 218
200 /** 219 /**
220 * If the image already has its contents in encoded form (e.g. PNG or JPEG) , return a ref
221 * to that data (which the caller must call unref() on) and return the X,Y offset from the
222 * left-top pixels in the encoded data where this image begins.
223 *
224 * If the image does not already has its contents in encoded form, return N ULL and ignore
225 * the origin parameter.
226 */
227 SkData* refEncodedData(SkIPoint* origin) const;
228
229 /**
201 * Return a new surface that is compatible with this image's internal repre sentation 230 * Return a new surface that is compatible with this image's internal repre sentation
202 * (e.g. raster or gpu). 231 * (e.g. raster or gpu).
203 * 232 *
204 * If no surfaceprops are specified, the image will attempt to match the pr ops of when it 233 * 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). 234 * was created (if it came from a surface).
206 */ 235 */
207 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL) cons t; 236 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps* = NULL) cons t;
208 237
209 const char* toString(SkString*) const; 238 const char* toString(SkString*) const;
210 239
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 const int fWidth; 272 const int fWidth;
244 const int fHeight; 273 const int fHeight;
245 const uint32_t fUniqueID; 274 const uint32_t fUniqueID;
246 275
247 static uint32_t NextUniqueID(); 276 static uint32_t NextUniqueID();
248 277
249 typedef SkRefCnt INHERITED; 278 typedef SkRefCnt INHERITED;
250 }; 279 };
251 280
252 #endif 281 #endif
OLDNEW
« gm/factory.cpp ('K') | « include/c/sk_types.h ('k') | include/core/SkPicture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698