aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkCodecImageGenerator.cpp
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-03-07 09:16:52 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-07 09:16:52 -0800
commit1590f3b32890f6455b30494308633177b54db347 (patch)
tree5fabc87ced4a0c49bc304d87306068647e8123c2 /src/codec/SkCodecImageGenerator.cpp
parent54887a6a2e12b0f2c93e039b00678732b6518826 (diff)
Revert of Update Skia's YUV API (patchset #5 id:160001 of https://codereview.chromium.org/1716523002/ )
Reason for revert: Blimp failures with manual roll in Chrome. Original issue's description: > Update Skia's YUV API > > We should match the recently designed API in SkCodec. > https://codereview.chromium.org/1549473003/ > > This requires changes in Chromium as well. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1716523002 > > Committed: https://skia.googlesource.com/skia/+/095d31c8a0eeb5d491febf064bc3c8a44e22b94f TBR=scroggo@google.com,reed@google.com,bsalomon@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1775493002
Diffstat (limited to 'src/codec/SkCodecImageGenerator.cpp')
-rw-r--r--src/codec/SkCodecImageGenerator.cpp47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/codec/SkCodecImageGenerator.cpp b/src/codec/SkCodecImageGenerator.cpp
index e579da92f6..e6e164ef61 100644
--- a/src/codec/SkCodecImageGenerator.cpp
+++ b/src/codec/SkCodecImageGenerator.cpp
@@ -28,6 +28,9 @@ SkCodecImageGenerator::SkCodecImageGenerator(SkCodec* codec, SkData* data)
: INHERITED(make_premul(codec->getInfo()))
, fCodec(codec)
, fData(SkRef(data))
+ , fYWidth(0)
+ , fUWidth(0)
+ , fVWidth(0)
{}
SkData* SkCodecImageGenerator::onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) {
@@ -48,13 +51,47 @@ bool SkCodecImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, s
}
}
-bool SkCodecImageGenerator::onQueryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const
-{
- return fCodec->queryYUV8(sizeInfo, colorSpace);
-}
+bool SkCodecImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
+ SkYUVColorSpace* colorSpace) {
+ // TODO (msarett): Change the YUV API in ImageGenerator to match SkCodec.
+ // This function is currently a hack to match the implementation
+ // in SkCodec with the old API.
+ SkCodec::YUVSizeInfo sizeInfo;
+
+ // If planes is NULL, we just need to return the size.
+ if (nullptr == planes) {
+ bool result = fCodec->queryYUV8(&sizeInfo, colorSpace);
+ if (result) {
+ // Save the true widths
+ fYWidth = sizeInfo.fYSize.width();
+ fUWidth = sizeInfo.fUSize.width();
+ fVWidth = sizeInfo.fVSize.width();
+
+ // Set the sizes so that the client allocates enough memory
+ sizes[0].fWidth = (int) sizeInfo.fYWidthBytes;
+ sizes[0].fHeight = sizeInfo.fYSize.height();
+ sizes[1].fWidth = (int) sizeInfo.fUWidthBytes;
+ sizes[1].fHeight = sizeInfo.fUSize.height();
+ sizes[2].fWidth = (int) sizeInfo.fVWidthBytes;
+ sizes[2].fHeight = sizeInfo.fVSize.height();
+ }
+ return result;
+ }
+
+ // Set the sizeInfo with the true widths and heights
+ SkASSERT(fYWidth != 0 && fUWidth != 0 && fVWidth != 0);
+ sizeInfo.fYSize.set(fYWidth, sizes[0].height());
+ sizeInfo.fUSize.set(fUWidth, sizes[1].height());
+ sizeInfo.fVSize.set(fVWidth, sizes[2].height());
-bool SkCodecImageGenerator::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3]) {
+ // Set the sizeInfo with the allocated widths
+ sizeInfo.fYWidthBytes = sizes[0].width();
+ sizeInfo.fUWidthBytes = sizes[1].width();
+ sizeInfo.fVWidthBytes = sizes[2].width();
SkCodec::Result result = fCodec->getYUV8Planes(sizeInfo, planes);
+ if ((result == SkCodec::kSuccess || result == SkCodec::kIncompleteInput) && colorSpace) {
+ *colorSpace = kJPEG_SkYUVColorSpace;
+ }
switch (result) {
case SkCodec::kSuccess: