OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "DMSrcSink.h" | 8 #include "DMSrcSink.h" |
9 #include "SamplePipeControllers.h" | 9 #include "SamplePipeControllers.h" |
10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 65 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
66 | 66 |
67 CodecSrc::CodecSrc(Path path, Mode mode, DstColorType dstColorType, float scale) | 67 CodecSrc::CodecSrc(Path path, Mode mode, DstColorType dstColorType, float scale) |
68 : fPath(path) | 68 : fPath(path) |
69 , fMode(mode) | 69 , fMode(mode) |
70 , fDstColorType(dstColorType) | 70 , fDstColorType(dstColorType) |
71 , fScale(scale) | 71 , fScale(scale) |
72 {} | 72 {} |
73 | 73 |
74 bool CodecSrc::veto(SinkType type) const { | 74 bool CodecSrc::veto(SinkFlags flags) const { |
75 // No need to test decoding to non-raster backend. | 75 // No need to test decoding to non-raster or indirect backend. |
76 // TODO: Once we implement GPU paths (e.g. JPEG YUV), we should use a deferr
ed decode to | 76 // TODO: Once we implement GPU paths (e.g. JPEG YUV), we should use a deferr
ed decode to |
77 // let the GPU handle it. | 77 // let the GPU handle it. |
78 return type != kRaster_SinkType; | 78 return flags.type != SinkFlags::kRaster |
| 79 || flags.approach != SinkFlags::kDirect; |
79 } | 80 } |
80 | 81 |
81 Error CodecSrc::draw(SkCanvas* canvas) const { | 82 Error CodecSrc::draw(SkCanvas* canvas) const { |
82 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); | 83 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); |
83 if (!encoded) { | 84 if (!encoded) { |
84 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); | 85 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); |
85 } | 86 } |
86 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 87 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
87 if (NULL == codec.get()) { | 88 if (NULL == codec.get()) { |
88 return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str()); | 89 return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str()); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 return SkOSPath::Basename(fPath.c_str()); | 454 return SkOSPath::Basename(fPath.c_str()); |
454 } else { | 455 } else { |
455 return SkStringPrintf("%s_%.3f", SkOSPath::Basename(fPath.c_str()).c_str
(), fScale); | 456 return SkStringPrintf("%s_%.3f", SkOSPath::Basename(fPath.c_str()).c_str
(), fScale); |
456 } | 457 } |
457 } | 458 } |
458 | 459 |
459 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 460 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
460 | 461 |
461 ImageSrc::ImageSrc(Path path, int divisor) : fPath(path), fDivisor(divisor) {} | 462 ImageSrc::ImageSrc(Path path, int divisor) : fPath(path), fDivisor(divisor) {} |
462 | 463 |
463 bool ImageSrc::veto(SinkType type) const { | 464 bool ImageSrc::veto(SinkFlags flags) const { |
464 // No need to test decoding to non-raster backend. | 465 // No need to test decoding to non-raster or indirect backend. |
465 // TODO: Instead, use lazy decoding to allow the GPU to handle cases like YU
V. | 466 // TODO: Instead, use lazy decoding to allow the GPU to handle cases like YU
V. |
466 return type != kRaster_SinkType; | 467 return flags.type != SinkFlags::kRaster |
| 468 || flags.approach != SinkFlags::kDirect; |
467 } | 469 } |
468 | 470 |
469 Error ImageSrc::draw(SkCanvas* canvas) const { | 471 Error ImageSrc::draw(SkCanvas* canvas) const { |
470 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); | 472 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); |
471 if (!encoded) { | 473 if (!encoded) { |
472 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); | 474 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); |
473 } | 475 } |
474 const SkColorType dstColorType = canvas->imageInfo().colorType(); | 476 const SkColorType dstColorType = canvas->imageInfo().colorType(); |
475 if (fDivisor == 0) { | 477 if (fDivisor == 0) { |
476 // Decode the full image. | 478 // Decode the full image. |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 skr.visit<void>(i, drawsAsSingletonPictures); | 1069 skr.visit<void>(i, drawsAsSingletonPictures); |
1068 } | 1070 } |
1069 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1071 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
1070 | 1072 |
1071 canvas->drawPicture(macroPic); | 1073 canvas->drawPicture(macroPic); |
1072 return ""; | 1074 return ""; |
1073 }); | 1075 }); |
1074 } | 1076 } |
1075 | 1077 |
1076 } // namespace DM | 1078 } // namespace DM |
OLD | NEW |