diff options
author | fmalita <fmalita@chromium.org> | 2015-09-03 07:17:25 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-03 07:17:25 -0700 |
commit | 2be7125f3274a4b661f50e992fc0eb3c14c24f05 (patch) | |
tree | de15270f9114db847f7f8d317c050f5b83062b52 /include | |
parent | 1a9cafff044e5a352c60065e44d64e9d0eb8f92a (diff) |
Add a SkPixelSerializer SkImage encode variant
R=reed@google.com
BUG=skia:4285
Review URL: https://codereview.chromium.org/1310633006
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkImage.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/include/core/SkImage.h b/include/core/SkImage.h index 2bcb90b5d3..b302792c58 100644 --- a/include/core/SkImage.h +++ b/include/core/SkImage.h @@ -21,6 +21,7 @@ class SkColorTable; class SkImageGenerator; class SkPaint; class SkPicture; +class SkPixelSerializer; class SkString; class SkSurface; class SkSurfaceProps; @@ -234,12 +235,27 @@ public: * * If the image type cannot be encoded, or the requested encoder type is * not supported, this will return NULL. + * + * Note: this will attempt to encode the image's pixels in the specified format, + * even if the image returns a data from refEncoded(). That data will be ignored. */ SkData* encode(SkImageEncoder::Type, int quality) const; - SkData* encode() const { - return this->encode(SkImageEncoder::kPNG_Type, 100); - } + /** + * Encode the image and return the result as a caller-managed SkData. This will + * attempt to reuse existing encoded data (as returned by refEncoded). + * + * We defer to the SkPixelSerializer both for vetting existing encoded data + * (useEncodedData) and for encoding the image (encodePixels) when no such data is + * present or is rejected by the serializer. + * + * If not specified, we use a default serializer which 1) always accepts existing data + * (in any format) and 2) encodes to PNG. + * + * If no compatible encoded data exists and encoding fails, this method will also + * fail (return NULL). + */ + SkData* encode(SkPixelSerializer* = nullptr) const; /** * If the image already has its contents in encoded form (e.g. PNG or JPEG), return a ref |