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

Unified Diff: Source/platform/graphics/ImageFrameGenerator.cpp

Issue 544323002: Non DCTSIZE multiple width support for JPEG YUV decoding (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed some comments Created 6 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
Index: Source/platform/graphics/ImageFrameGenerator.cpp
diff --git a/Source/platform/graphics/ImageFrameGenerator.cpp b/Source/platform/graphics/ImageFrameGenerator.cpp
index b046744b31c76ce29b836f7269f4531d654130a3..4bf920c9c47d888d3e161b91e08d6b73e9b8c482 100644
--- a/Source/platform/graphics/ImageFrameGenerator.cpp
+++ b/Source/platform/graphics/ImageFrameGenerator.cpp
@@ -69,6 +69,16 @@ private:
size_t m_rowBytes;
};
+static void updateYUVComponentSizes(const ImageDecoder* decoder, SkISize componentSizes[3], ImageDecoder::SizeType sizeType)
+{
+ IntSize size = decoder->decodedYUVSize(0, sizeType);
+ componentSizes[0].set(size.width(), size.height());
+ size = decoder->decodedYUVSize(1, sizeType);
+ componentSizes[1].set(size.width(), size.height());
+ size = decoder->decodedYUVSize(2, sizeType);
+ componentSizes[2].set(size.width(), size.height());
+}
+
ImageFrameGenerator::ImageFrameGenerator(const SkISize& fullSize, PassRefPtr<SharedBuffer> data, bool allDataReceived, bool isMultiFrame)
: m_fullSize(fullSize)
, m_isMultiFrame(isMultiFrame)
@@ -133,7 +143,7 @@ bool ImageFrameGenerator::decodeAndScale(const SkImageInfo& info, size_t index,
return result;
}
-bool ImageFrameGenerator::decodeToYUV(void* planes[3], size_t rowBytes[3])
+bool ImageFrameGenerator::decodeToYUV(SkISize componentSizes[3], void* planes[3], size_t rowBytes[3])
{
// This method is called to populate a discardable memory owned by Skia.
@@ -165,6 +175,10 @@ bool ImageFrameGenerator::decodeToYUV(void* planes[3], size_t rowBytes[3])
OwnPtr<ImagePlanes> imagePlanes = adoptPtr(new ImagePlanes(planes, rowBytes));
decoder->setImagePlanes(imagePlanes.release());
+ bool sizeIsAvailable = decoder->isSizeAvailable();
+ ASSERT(sizeIsAvailable);
+ if (sizeIsAvailable)
+ updateYUVComponentSizes(decoder.get(), componentSizes, ImageDecoder::ActualSize);
bool yuvDecoded = decoder->decodeToYUV();
if (yuvDecoded)
setHasAlpha(0, false); // YUV is always opaque
@@ -319,12 +333,7 @@ bool ImageFrameGenerator::getYUVComponentSizes(SkISize componentSizes[3])
if (!decoder->isSizeAvailable() || !decoder->canDecodeToYUV())
return false;
- IntSize size = decoder->decodedYUVSize(0);
- componentSizes[0].set(size.width(), size.height());
- size = decoder->decodedYUVSize(1);
- componentSizes[1].set(size.width(), size.height());
- size = decoder->decodedYUVSize(2);
- componentSizes[2].set(size.width(), size.height());
+ updateYUVComponentSizes(decoder.get(), componentSizes, ImageDecoder::ActualSize);
return true;
}

Powered by Google App Engine
This is Rietveld 408576698