Chromium Code Reviews

Unified Diff: src/images/SkDecodingImageGenerator.cpp

Issue 399683007: JPEG YUV Decoding (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: src/images/SkDecodingImageGenerator.cpp
diff --git a/src/images/SkDecodingImageGenerator.cpp b/src/images/SkDecodingImageGenerator.cpp
index dfa093becc5d5ff7162727729d04e175fe1d18f0..975a93aa035a4fd38e7bc34edb3d5285f44d15e3 100644
--- a/src/images/SkDecodingImageGenerator.cpp
+++ b/src/images/SkDecodingImageGenerator.cpp
@@ -45,6 +45,7 @@ protected:
virtual bool onGetPixels(const SkImageInfo& info,
void* pixels, size_t rowBytes,
SkPMColor ctable[], int* ctableCount) SK_OVERRIDE;
+ virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]) SK_OVERRIDE;
private:
typedef SkImageGenerator INHERITED;
@@ -209,6 +210,26 @@ bool DecodingImageGenerator::onGetPixels(const SkImageInfo& info,
return true;
}
+bool DecodingImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3],
+ size_t rowBytes[3]) {
+ if (!fStream->rewind()) {
+ return false;
+ }
+
+ SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
+ if (NULL == decoder.get()) {
+ return false;
+ }
+
+ if (planes && (NULL != planes[0]) && (NULL != planes[1]) && (NULL != planes[2]) &&
+ rowBytes && (0 != rowBytes[0]) && (0 != rowBytes[1]) && (0 != rowBytes[2])) {
+ decoder->setYUVBuffers(planes, rowBytes);
+ return this->onGetPixels(fInfo, NULL, 0, NULL, NULL);
+ }
+
+ return decoder->getComponentSizes(fStream, sizes);
+}
+
// A contructor-type function that returns NULL on failure. This
// prevents the returned SkImageGenerator from ever being in a bad
// state. Called by both Create() functions

Powered by Google App Engine