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 "SkAndroidCodec.h" | 9 #include "SkAndroidCodec.h" |
10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "SkXMLWriter.h" | 31 #include "SkXMLWriter.h" |
32 #include "SkSwizzler.h" | 32 #include "SkSwizzler.h" |
33 #include <functional> | 33 #include <functional> |
34 | 34 |
35 #ifdef SK_MOJO | 35 #ifdef SK_MOJO |
36 #include "SkMojo.mojom.h" | 36 #include "SkMojo.mojom.h" |
37 #endif | 37 #endif |
38 | 38 |
39 DEFINE_bool(multiPage, false, "For document-type backends, render the source" | 39 DEFINE_bool(multiPage, false, "For document-type backends, render the source" |
40 " into multiple pages"); | 40 " into multiple pages"); |
41 #ifdef SK_CODEC_DECODES_RAW | |
mtklein
2016/02/08 21:26:55
Doesn't need an ifdef?
scroggo
2016/02/08 21:31:30
Not needed, but I think it makes sense. If it's no
mtklein
2016/02/08 21:45:47
Please no ifdefs that don't strictly matter.
scroggo
2016/02/08 21:47:48
Done.
| |
42 DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?" ); | |
43 #endif | |
41 | 44 |
42 static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) { | 45 static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) { |
43 SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size)); | 46 SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size)); |
44 return encoded && SkDEPRECATED_InstallDiscardablePixelRef(encoded, dst); | 47 return encoded && SkDEPRECATED_InstallDiscardablePixelRef(encoded, dst); |
45 } | 48 } |
46 | 49 |
47 namespace DM { | 50 namespace DM { |
48 | 51 |
49 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} | 52 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} |
50 | 53 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 // We will replicate the names used by CodecSrc so that images can | 234 // We will replicate the names used by CodecSrc so that images can |
232 // be compared in Gold. | 235 // be compared in Gold. |
233 if (1 == fSampleSize) { | 236 if (1 == fSampleSize) { |
234 return SkOSPath::Basename(fPath.c_str()); | 237 return SkOSPath::Basename(fPath.c_str()); |
235 } | 238 } |
236 return get_scaled_name(fPath, 1.0f / (float) fSampleSize); | 239 return get_scaled_name(fPath, 1.0f / (float) fSampleSize); |
237 } | 240 } |
238 | 241 |
239 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | 242 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ |
240 | 243 |
244 static bool serial_from_path_name(const SkString& path) { | |
245 #ifdef SK_CODEC_DECODES_RAW | |
mtklein
2016/02/08 21:26:55
Doesn't need an ifdef?
scroggo
2016/02/08 21:31:30
This ifdef isn't strictly necessary, but it skips
mtklein
2016/02/08 21:45:47
Ditto.
(We're not allowed to pretend we're optimi
scroggo
2016/02/08 21:47:48
Done.
| |
246 if (!FLAGS_RAW_threading) { | |
247 static const char* const exts[] = { | |
248 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw" , | |
249 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW" , | |
250 }; | |
251 const char* actualExt = strrchr(path.c_str(), '.'); | |
252 if (actualExt) { | |
253 actualExt++; | |
254 for (auto* ext : exts) { | |
255 if (0 == strcmp(ext, actualExt)) { | |
256 return true; | |
257 } | |
258 } | |
259 } | |
260 } | |
261 #endif | |
262 return false; | |
263 } | |
264 | |
241 CodecSrc::CodecSrc(Path path, Mode mode, DstColorType dstColorType, SkAlphaType dstAlphaType, | 265 CodecSrc::CodecSrc(Path path, Mode mode, DstColorType dstColorType, SkAlphaType dstAlphaType, |
242 float scale) | 266 float scale) |
243 : fPath(path) | 267 : fPath(path) |
244 , fMode(mode) | 268 , fMode(mode) |
245 , fDstColorType(dstColorType) | 269 , fDstColorType(dstColorType) |
246 , fDstAlphaType(dstAlphaType) | 270 , fDstAlphaType(dstAlphaType) |
247 , fScale(scale) | 271 , fScale(scale) |
272 , fRunSerially(serial_from_path_name(path)) | |
248 {} | 273 {} |
249 | 274 |
250 bool CodecSrc::veto(SinkFlags flags) const { | 275 bool CodecSrc::veto(SinkFlags flags) const { |
251 // Test CodecImageGenerator on 8888, 565, and gpu | 276 // Test CodecImageGenerator on 8888, 565, and gpu |
252 if (kGen_Mode == fMode) { | 277 if (kGen_Mode == fMode) { |
253 return (flags.type != SinkFlags::kRaster || flags.approach != SinkFlags: :kDirect) && | 278 return (flags.type != SinkFlags::kRaster || flags.approach != SinkFlags: :kDirect) && |
254 flags.type != SinkFlags::kGPU; | 279 flags.type != SinkFlags::kGPU; |
255 } | 280 } |
256 | 281 |
257 // Test all other modes to direct raster backends (8888 and 565). | 282 // Test all other modes to direct raster backends (8888 and 565). |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
605 | 630 |
606 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | 631 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ |
607 | 632 |
608 AndroidCodecSrc::AndroidCodecSrc(Path path, Mode mode, CodecSrc::DstColorType ds tColorType, | 633 AndroidCodecSrc::AndroidCodecSrc(Path path, Mode mode, CodecSrc::DstColorType ds tColorType, |
609 SkAlphaType dstAlphaType, int sampleSize) | 634 SkAlphaType dstAlphaType, int sampleSize) |
610 : fPath(path) | 635 : fPath(path) |
611 , fMode(mode) | 636 , fMode(mode) |
612 , fDstColorType(dstColorType) | 637 , fDstColorType(dstColorType) |
613 , fDstAlphaType(dstAlphaType) | 638 , fDstAlphaType(dstAlphaType) |
614 , fSampleSize(sampleSize) | 639 , fSampleSize(sampleSize) |
640 , fRunSerially(serial_from_path_name(path)) | |
615 {} | 641 {} |
616 | 642 |
617 bool AndroidCodecSrc::veto(SinkFlags flags) const { | 643 bool AndroidCodecSrc::veto(SinkFlags flags) const { |
618 // No need to test decoding to non-raster or indirect backend. | 644 // No need to test decoding to non-raster or indirect backend. |
619 return flags.type != SinkFlags::kRaster | 645 return flags.type != SinkFlags::kRaster |
620 || flags.approach != SinkFlags::kDirect; | 646 || flags.approach != SinkFlags::kDirect; |
621 } | 647 } |
622 | 648 |
623 Error AndroidCodecSrc::draw(SkCanvas* canvas) const { | 649 Error AndroidCodecSrc::draw(SkCanvas* canvas) const { |
624 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); | 650 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1386 skr.visit<void>(i, drawsAsSingletonPictures); | 1412 skr.visit<void>(i, drawsAsSingletonPictures); |
1387 } | 1413 } |
1388 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1414 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
1389 | 1415 |
1390 canvas->drawPicture(macroPic); | 1416 canvas->drawPicture(macroPic); |
1391 return check_against_reference(bitmap, src, fSink); | 1417 return check_against_reference(bitmap, src, fSink); |
1392 }); | 1418 }); |
1393 } | 1419 } |
1394 | 1420 |
1395 } // namespace DM | 1421 } // namespace DM |
OLD | NEW |