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

Unified Diff: dm/DMSrcSink.cpp

Issue 1549473003: Add getYUV8Planes() API to SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « dm/DMSrcSink.h ('k') | include/codec/SkCodec.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index bbfa5199e61f06bead0549fad66d11fa40313a23..8598de781c9bd48b16a716d006be24015ad4161d 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -8,6 +8,7 @@
#include "DMSrcSink.h"
#include "SkAndroidCodec.h"
#include "SkCodec.h"
+#include "SkCodecImageGenerator.h"
#include "SkCommonFlags.h"
#include "SkData.h"
#include "SkDocument.h"
@@ -240,11 +241,14 @@ CodecSrc::CodecSrc(Path path, Mode mode, DstColorType dstColorType, float scale)
{}
bool CodecSrc::veto(SinkFlags flags) const {
- // No need to test decoding to non-raster or indirect backend.
- // TODO: Once we implement GPU paths (e.g. JPEG YUV), we should use a deferred decode to
- // let the GPU handle it.
- return flags.type != SinkFlags::kRaster
- || flags.approach != SinkFlags::kDirect;
+ // Test CodecImageGenerator on 8888, 565, and gpu
+ if (kGen_Mode == fMode) {
+ return (flags.type != SinkFlags::kRaster || flags.approach != SinkFlags::kDirect) &&
+ flags.type != SinkFlags::kGPU;
+ }
+
+ // Test all other modes to direct raster backends (8888 and 565).
+ return flags.type != SinkFlags::kRaster || flags.approach != SinkFlags::kDirect;
}
bool get_decode_info(SkImageInfo* decodeInfo, const SkImageInfo& defaultInfo,
@@ -274,11 +278,37 @@ bool get_decode_info(SkImageInfo* decodeInfo, const SkImageInfo& defaultInfo,
return true;
}
+Error test_gen(SkCanvas* canvas, SkData* data) {
+ SkImageGenerator* gen = SkCodecImageGenerator::NewFromEncodedCodec(data);
+ if (!gen) {
+ return "Could not create image generator.";
+ }
+
+ // FIXME: The gpu backend does not draw kGray sources correctly. (skbug.com/4822)
+ // Currently, we will avoid creating a CodecSrc for this case (see DM.cpp).
+ SkASSERT(kGray_8_SkColorType != gen->getInfo().colorType());
+
+ SkAutoTDelete<SkImage> image(SkImage::NewFromGenerator(gen, nullptr));
+ if (!image) {
+ return "Could not create image from codec image generator.";
+ }
+
+ canvas->drawImage(image, 0, 0);
+ return "";
+}
+
Error CodecSrc::draw(SkCanvas* canvas) const {
SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
if (!encoded) {
return SkStringPrintf("Couldn't read %s.", fPath.c_str());
}
+
+ // The CodecImageGenerator test does not share much code with the other tests,
+ // so we will handle it in its own function.
+ if (kGen_Mode == fMode) {
+ return test_gen(canvas, encoded);
+ }
+
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
if (nullptr == codec.get()) {
return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str());
@@ -509,6 +539,9 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
}
return "";
}
+ default:
+ SkASSERT(false);
+ return "Invalid fMode";
}
return "";
}
@@ -541,8 +574,6 @@ AndroidCodecSrc::AndroidCodecSrc(Path path, Mode mode, CodecSrc::DstColorType ds
bool AndroidCodecSrc::veto(SinkFlags flags) const {
// No need to test decoding to non-raster or indirect backend.
- // TODO: Once we implement GPU paths (e.g. JPEG YUV), we should use a deferred decode to
- // let the GPU handle it.
return flags.type != SinkFlags::kRaster
|| flags.approach != SinkFlags::kDirect;
}
« no previous file with comments | « dm/DMSrcSink.h ('k') | include/codec/SkCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698