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

Unified Diff: include/codec/SkCodec.h

Issue 1549473003: Add getYUV8Planes() API to SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 | resources/cropped_mandrill.jpg » ('j') | src/codec/SkJpegCodec.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/codec/SkCodec.h
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index d06c2c3399e4858e30626945948f4933f5d059c6..c4b4fd12e6c0eb45804413dc07a7a5e1b3bc411b 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -278,6 +278,45 @@ public:
Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
/**
+ * If decoding to YUV is supported, this returns true and populates "sizes" with
+ * the appropriate sizes of the Y, U, and V planes.
+ */
+ bool getYUV8Sizes(SkISize sizes[3]) const {
+ if (nullptr == sizes) {
+ return false;
+ }
+
+ return this->onGetYUV8Sizes(sizes);
+ }
+
+ /**
+ * @param sizes Sizes of each of the Y, U, and V planes
+ * @param pixels Memory for each of the Y, U, and V planes
+ * @param rowBytes Row bytes for each of the Y, U, and V planes
+ * @param colorSpace If nullptr, this parameter is ignored. Otherwise,
+ * if the decode is successful, this will bet set to
+ * kJPEG_SkYUVColorSpace (JPEG is currently the only
+ * format that supports YUV).
+ *
+ * Returns kSuccess, or another value explaining the type of failure.
+ * This always attempts to perform a full decode. If the client only
+ * wants size, it should call getYUV8Sizes().
+ */
+ Result getYUV8Planes(SkISize sizes[3], void* pixels[3], size_t rowBytes[3],
+ SkYUVColorSpace* colorSpace) {
+ if (nullptr == sizes || nullptr == pixels || nullptr == pixels[0] ||
+ nullptr == pixels[1] || nullptr == pixels[2] || nullptr == rowBytes) {
+ return kInvalidInput;
+ }
+
+ if (!this->rewindIfNeeded()) {
+ return kCouldNotRewind;
+ }
+
+ return this->onGetYUV8Planes(sizes, pixels, rowBytes, colorSpace);
+ }
+
+ /**
* Some images may initially report that they have alpha due to the format
* of the encoded data, but then never use any colors which have alpha
* less than 100%. This function can be called *after* decoding to
@@ -454,7 +493,7 @@ public:
protected:
SkCodec(const SkImageInfo&, SkStream*);
- virtual SkISize onGetScaledDimensions(float /* desiredScale */) const {
+ virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const {
msarett 2015/12/22 21:01:36 Just changing the comments here to be consistent w
// By default, scaling is not supported.
return this->getInfo().dimensions();
}
@@ -481,7 +520,16 @@ protected:
SkPMColor ctable[], int* ctableCount,
int* rowsDecoded) = 0;
- virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const {
+ virtual bool onGetYUV8Sizes(SkISize* /*sizes*/) const {
+ return false;
+ }
+
+ virtual Result onGetYUV8Planes(SkISize* /*sizes*/, void** /*pixels*/, size_t* /*rowBytes*/,
+ SkYUVColorSpace* /*colorSpace*/) {
+ return kUnimplemented;
+ }
+
+ virtual bool onGetValidSubset(SkIRect* /*desiredSubset*/) const {
// By default, subsets are not supported.
return false;
}
« no previous file with comments | « no previous file | resources/cropped_mandrill.jpg » ('j') | src/codec/SkJpegCodec.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698