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: Remove random extra file :) 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 {
scroggo 2016/01/04 18:29:15 crrev.com/863053002 proposed suggesting both a log
msarett 2016/01/04 21:46:46 I think this is the hard question for this API. I
msarett 2016/01/12 14:25:27 I have invented "widthBytes" which almost means th
+ if (nullptr == sizes) {
+ return false;
+ }
+
+ return this->onGetYUV8Sizes(sizes);
+ }
+
+ /**
scroggo 2016/01/04 18:29:15 nit: Typically the first line will describe genera
msarett 2016/01/12 14:25:27 Done.
+ * @param sizes Sizes of each of the Y, U, and V planes
+ * @param pixels Memory for each of the Y, U, and V planes
scroggo 2016/01/04 18:29:15 Maybe this is just due to my lack of knowledge abo
msarett 2016/01/04 21:46:46 Will add comments. Each Y, U, or V sample is a si
msarett 2016/01/12 14:25:27 Added more detail.
+ * @param rowBytes Row bytes for each of the Y, U, and V planes
+ * @param colorSpace If nullptr, this parameter is ignored. Otherwise,
scroggo 2016/01/04 18:29:15 Do we need this here? In https://codereview.chromi
msarett 2016/01/04 21:46:46 Happy to add this to the query step. What is this
+ * 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],
reed1 2016/01/04 15:50:55 can sizes[] be const? Seems much simplier if they
scroggo 2016/01/04 18:29:15 Looks like rowBytes can also be const? Alternativ
msarett 2016/01/04 21:46:46 Depends on how we choose to deal with AllocatedSiz
msarett 2016/01/12 14:25:27 Using structs now. "sizes" and "widthBytes" are c
+ 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 {
// 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*/,
scroggo 2016/01/04 18:29:15 Why does this use different notations from getYUV8
+ 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