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

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

Issue 1310633006: Add a SkPixelSerializer SkImage encode variant (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: updated Created 5 years, 3 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
« no previous file with comments | « no previous file | src/core/SkWriteBuffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "SkFilterQuality.h" 11 #include "SkFilterQuality.h"
12 #include "SkImageInfo.h" 12 #include "SkImageInfo.h"
13 #include "SkImageEncoder.h" 13 #include "SkImageEncoder.h"
14 #include "SkRefCnt.h" 14 #include "SkRefCnt.h"
15 #include "SkScalar.h" 15 #include "SkScalar.h"
16 #include "SkShader.h" 16 #include "SkShader.h"
17 17
18 class SkData; 18 class SkData;
19 class SkCanvas; 19 class SkCanvas;
20 class SkColorTable; 20 class SkColorTable;
21 class SkImageGenerator; 21 class SkImageGenerator;
22 class SkPaint; 22 class SkPaint;
23 class SkPicture; 23 class SkPicture;
24 class SkPixelSerializer;
24 class SkString; 25 class SkString;
25 class SkSurface; 26 class SkSurface;
26 class SkSurfaceProps; 27 class SkSurfaceProps;
27 class GrContext; 28 class GrContext;
28 class GrTexture; 29 class GrTexture;
29 30
30 /** 31 /**
31 * SkImage is an abstraction for drawing a rectagle of pixels, though the 32 * SkImage is an abstraction for drawing a rectagle of pixels, though the
32 * particular type of image could be actually storing its data on the GPU, or 33 * particular type of image could be actually storing its data on the GPU, or
33 * as drawing commands (picture or PDF or otherwise), ready to be played back 34 * as drawing commands (picture or PDF or otherwise), ready to be played back
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 * - If srcR does not intersect the image bounds. 210 * - If srcR does not intersect the image bounds.
210 * - If the requested colortype/alphatype cannot be converted from the imag e's types. 211 * - If the requested colortype/alphatype cannot be converted from the imag e's types.
211 */ 212 */
212 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy tes, 213 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy tes,
213 int srcX, int srcY) const; 214 int srcX, int srcY) const;
214 215
215 bool readPixels(const SkPixmap& dst, int srcX, int srcY) const; 216 bool readPixels(const SkPixmap& dst, int srcX, int srcY) const;
216 217
217 /** 218 /**
218 * Encode the image's pixels and return the result as a new SkData, which 219 * Encode the image's pixels and return the result as a new SkData, which
219 * the caller must manage (i.e. call unref() when they are done). 220 * the caller must manage (i.e. call unref() when they are done).
reed1 2015/09/03 02:36:13 // Note: this will attempt to encode the image's p
f(malita) 2015/09/03 14:10:27 Done.
220 * 221 *
221 * If the image type cannot be encoded, or the requested encoder type is 222 * If the image type cannot be encoded, or the requested encoder type is
222 * not supported, this will return NULL. 223 * not supported, this will return NULL.
223 */ 224 */
224 SkData* encode(SkImageEncoder::Type, int quality) const; 225 SkData* encode(SkImageEncoder::Type, int quality) const;
225 226
226 SkData* encode() const { 227 /**
227 return this->encode(SkImageEncoder::kPNG_Type, 100); 228 * Encode the image's pixels using an optional SkPixelSerializer, and retur n the result
228 } 229 * as a caller-managed SkData.
230 *
231 * If the serializer is NULL, a default PNG encoder (with quality == 100) w ill be used.
reed1 2015/09/03 02:36:13 How about this as a way to organize this wackiness
f(malita) 2015/09/03 14:10:27 (this looks truncated, did you have more text whic
232 *
233 * This method may return exising encoded data (from refEncoded) if it pass es the
234 * serializer's useEncodedData() test, or the serializer itself is NULL.
235 */
236 SkData* encode(SkPixelSerializer* = nullptr) const;
229 237
230 /** 238 /**
231 * If the image already has its contents in encoded form (e.g. PNG or JPEG) , return a ref 239 * If the image already has its contents in encoded form (e.g. PNG or JPEG) , return a ref
232 * to that data (which the caller must call unref() on). The caller is resp onsible for calling 240 * to that data (which the caller must call unref() on). The caller is resp onsible for calling
233 * unref on the data when they are done. 241 * unref on the data when they are done.
234 * 242 *
235 * If the image does not already has its contents in encoded form, return N ULL. 243 * If the image does not already has its contents in encoded form, return N ULL.
236 * 244 *
237 * Note: to force the image to return its contents as encoded data, try cal ling encode(...). 245 * Note: to force the image to return its contents as encoded data, try cal ling encode(...).
238 */ 246 */
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 307
300 private: 308 private:
301 const int fWidth; 309 const int fWidth;
302 const int fHeight; 310 const int fHeight;
303 const uint32_t fUniqueID; 311 const uint32_t fUniqueID;
304 312
305 typedef SkRefCnt INHERITED; 313 typedef SkRefCnt INHERITED;
306 }; 314 };
307 315
308 #endif 316 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkWriteBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698