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

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: moar comment tweaks 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 int srcX, int srcY) const; 228 int srcX, int srcY) const;
228 229
229 bool readPixels(const SkPixmap& dst, int srcX, int srcY) const; 230 bool readPixels(const SkPixmap& dst, int srcX, int srcY) const;
230 231
231 /** 232 /**
232 * Encode the image's pixels and return the result as a new SkData, which 233 * Encode the image's pixels and return the result as a new SkData, which
233 * the caller must manage (i.e. call unref() when they are done). 234 * the caller must manage (i.e. call unref() when they are done).
234 * 235 *
235 * If the image type cannot be encoded, or the requested encoder type is 236 * If the image type cannot be encoded, or the requested encoder type is
236 * not supported, this will return NULL. 237 * not supported, this will return NULL.
238 *
239 * Note: this will attempt to encode the image's pixels in the specified fo rmat,
240 * even if the image returns a data from refEncoded(). That data will be ig nored.
237 */ 241 */
238 SkData* encode(SkImageEncoder::Type, int quality) const; 242 SkData* encode(SkImageEncoder::Type, int quality) const;
239 243
240 SkData* encode() const { 244 /**
241 return this->encode(SkImageEncoder::kPNG_Type, 100); 245 * Encode the image and return the result as a caller-managed SkData. This will
242 } 246 * attempt to reuse existing encoded data (as returned by refEncoded).
247 *
248 * We defer to the SkPixelSerializer both for vetting existing encoded data
249 * (useEncodedData) and for encoding the image (encodePixels) when no such data is
250 * present or is rejected by the serializer.
251 *
252 * If not specified, we use a default serializer which 1) always accepts ex isting data
253 * (in any format) and 2) encodes to PNG.
254 *
255 * If no compatible encoded data exists and encoding fails, this method wil l also
256 * fail (return NULL).
257 */
258 SkData* encode(SkPixelSerializer* = nullptr) const;
243 259
244 /** 260 /**
245 * If the image already has its contents in encoded form (e.g. PNG or JPEG) , return a ref 261 * If the image already has its contents in encoded form (e.g. PNG or JPEG) , return a ref
246 * to that data (which the caller must call unref() on). The caller is resp onsible for calling 262 * to that data (which the caller must call unref() on). The caller is resp onsible for calling
247 * unref on the data when they are done. 263 * unref on the data when they are done.
248 * 264 *
249 * If the image does not already has its contents in encoded form, return N ULL. 265 * If the image does not already has its contents in encoded form, return N ULL.
250 * 266 *
251 * Note: to force the image to return its contents as encoded data, try cal ling encode(...). 267 * Note: to force the image to return its contents as encoded data, try cal ling encode(...).
252 */ 268 */
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 329
314 private: 330 private:
315 const int fWidth; 331 const int fWidth;
316 const int fHeight; 332 const int fHeight;
317 const uint32_t fUniqueID; 333 const uint32_t fUniqueID;
318 334
319 typedef SkRefCnt INHERITED; 335 typedef SkRefCnt INHERITED;
320 }; 336 };
321 337
322 #endif 338 #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