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

Unified Diff: dm/DMSrcSink.cpp

Issue 1239953004: Allow Srcs to veto Sinks based on their broad type. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: scroggo Created 5 years, 5 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') | tools/dm_flags.json » ('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 38597b6946994c06d8cc24971dc018163ff41b14..06186c2987dc496325ad6c7aed7e4267b71e882e 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -71,14 +71,14 @@ CodecSrc::CodecSrc(Path path, Mode mode, DstColorType dstColorType, float scale)
, fScale(scale)
{}
-Error CodecSrc::draw(SkCanvas* canvas) const {
- SkImageInfo canvasInfo;
- if (NULL == canvas->peekPixels(&canvasInfo, NULL)) {
- // TODO: Once we implement GPU paths (e.g. JPEG YUV), we should use a deferred decode to
- // let the GPU handle it.
- return Error::Nonfatal("No need to test decoding to non-raster backend.");
- }
+bool CodecSrc::veto(SinkType type) const {
+ // No need to test decoding to non-raster backend.
+ // TODO: Once we implement GPU paths (e.g. JPEG YUV), we should use a deferred decode to
+ // let the GPU handle it.
+ return type != kRaster_SinkType;
+}
+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());
@@ -90,7 +90,7 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
// Choose the color type to decode to
SkImageInfo decodeInfo = codec->getInfo();
- SkColorType canvasColorType = canvasInfo.colorType();
+ SkColorType canvasColorType = canvas->imageInfo().colorType();
switch (fDstColorType) {
case kIndex8_Always_DstColorType:
decodeInfo = codec->getInfo().makeColorType(kIndex_8_SkColorType);
@@ -382,18 +382,18 @@ Name CodecSrc::name() const {
ImageSrc::ImageSrc(Path path, int divisor) : fPath(path), fDivisor(divisor) {}
-Error ImageSrc::draw(SkCanvas* canvas) const {
- SkImageInfo canvasInfo;
- if (NULL == canvas->peekPixels(&canvasInfo, NULL)) {
- // TODO: Instead, use lazy decoding to allow the GPU to handle cases like YUV.
- return Error::Nonfatal("No need to test decoding to non-raster backend.");
- }
+bool ImageSrc::veto(SinkType type) const {
+ // No need to test decoding to non-raster backend.
+ // TODO: Instead, use lazy decoding to allow the GPU to handle cases like YUV.
+ return type != kRaster_SinkType;
+}
+Error ImageSrc::draw(SkCanvas* canvas) const {
SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str()));
if (!encoded) {
return SkStringPrintf("Couldn't read %s.", fPath.c_str());
}
- const SkColorType dstColorType = canvasInfo.colorType();
+ const SkColorType dstColorType = canvas->imageInfo().colorType();
if (fDivisor == 0) {
// Decode the full image.
SkBitmap bitmap;
« no previous file with comments | « dm/DMSrcSink.h ('k') | tools/dm_flags.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698