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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkWriteBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkImage.h
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 2bcb90b5d3bebec7adb0b79d5dc4dde4c108f7c2..b302792c58227f1461fc409e7a35659d941a84dd 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
« 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