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 DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?"
); |
41 | 42 |
42 static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) { | 43 static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) { |
43 SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size)); | 44 SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size)); |
44 return encoded && SkDEPRECATED_InstallDiscardablePixelRef(encoded, dst); | 45 return encoded && SkDEPRECATED_InstallDiscardablePixelRef(encoded, dst); |
45 } | 46 } |
46 | 47 |
47 namespace DM { | 48 namespace DM { |
48 | 49 |
49 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} | 50 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} |
50 | 51 |
(...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 | 232 // We will replicate the names used by CodecSrc so that images can |
232 // be compared in Gold. | 233 // be compared in Gold. |
233 if (1 == fSampleSize) { | 234 if (1 == fSampleSize) { |
234 return SkOSPath::Basename(fPath.c_str()); | 235 return SkOSPath::Basename(fPath.c_str()); |
235 } | 236 } |
236 return get_scaled_name(fPath, 1.0f / (float) fSampleSize); | 237 return get_scaled_name(fPath, 1.0f / (float) fSampleSize); |
237 } | 238 } |
238 | 239 |
239 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 240 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
240 | 241 |
| 242 static bool serial_from_path_name(const SkString& path) { |
| 243 if (!FLAGS_RAW_threading) { |
| 244 static const char* const exts[] = { |
| 245 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw"
, |
| 246 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW"
, |
| 247 }; |
| 248 const char* actualExt = strrchr(path.c_str(), '.'); |
| 249 if (actualExt) { |
| 250 actualExt++; |
| 251 for (auto* ext : exts) { |
| 252 if (0 == strcmp(ext, actualExt)) { |
| 253 return true; |
| 254 } |
| 255 } |
| 256 } |
| 257 } |
| 258 return false; |
| 259 } |
| 260 |
241 CodecSrc::CodecSrc(Path path, Mode mode, DstColorType dstColorType, SkAlphaType
dstAlphaType, | 261 CodecSrc::CodecSrc(Path path, Mode mode, DstColorType dstColorType, SkAlphaType
dstAlphaType, |
242 float scale) | 262 float scale) |
243 : fPath(path) | 263 : fPath(path) |
244 , fMode(mode) | 264 , fMode(mode) |
245 , fDstColorType(dstColorType) | 265 , fDstColorType(dstColorType) |
246 , fDstAlphaType(dstAlphaType) | 266 , fDstAlphaType(dstAlphaType) |
247 , fScale(scale) | 267 , fScale(scale) |
| 268 , fRunSerially(serial_from_path_name(path)) |
248 {} | 269 {} |
249 | 270 |
250 bool CodecSrc::veto(SinkFlags flags) const { | 271 bool CodecSrc::veto(SinkFlags flags) const { |
251 // Test CodecImageGenerator on 8888, 565, and gpu | 272 // Test CodecImageGenerator on 8888, 565, and gpu |
252 if (kGen_Mode == fMode) { | 273 if (kGen_Mode == fMode) { |
253 return (flags.type != SinkFlags::kRaster || flags.approach != SinkFlags:
:kDirect) && | 274 return (flags.type != SinkFlags::kRaster || flags.approach != SinkFlags:
:kDirect) && |
254 flags.type != SinkFlags::kGPU; | 275 flags.type != SinkFlags::kGPU; |
255 } | 276 } |
256 | 277 |
257 // Test all other modes to direct raster backends (8888 and 565). | 278 // 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 | 626 |
606 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 627 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
607 | 628 |
608 AndroidCodecSrc::AndroidCodecSrc(Path path, Mode mode, CodecSrc::DstColorType ds
tColorType, | 629 AndroidCodecSrc::AndroidCodecSrc(Path path, Mode mode, CodecSrc::DstColorType ds
tColorType, |
609 SkAlphaType dstAlphaType, int sampleSize) | 630 SkAlphaType dstAlphaType, int sampleSize) |
610 : fPath(path) | 631 : fPath(path) |
611 , fMode(mode) | 632 , fMode(mode) |
612 , fDstColorType(dstColorType) | 633 , fDstColorType(dstColorType) |
613 , fDstAlphaType(dstAlphaType) | 634 , fDstAlphaType(dstAlphaType) |
614 , fSampleSize(sampleSize) | 635 , fSampleSize(sampleSize) |
| 636 , fRunSerially(serial_from_path_name(path)) |
615 {} | 637 {} |
616 | 638 |
617 bool AndroidCodecSrc::veto(SinkFlags flags) const { | 639 bool AndroidCodecSrc::veto(SinkFlags flags) const { |
618 // No need to test decoding to non-raster or indirect backend. | 640 // No need to test decoding to non-raster or indirect backend. |
619 return flags.type != SinkFlags::kRaster | 641 return flags.type != SinkFlags::kRaster |
620 || flags.approach != SinkFlags::kDirect; | 642 || flags.approach != SinkFlags::kDirect; |
621 } | 643 } |
622 | 644 |
623 Error AndroidCodecSrc::draw(SkCanvas* canvas) const { | 645 Error AndroidCodecSrc::draw(SkCanvas* canvas) const { |
624 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(fPath.c_str())); | 646 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); | 1408 skr.visit<void>(i, drawsAsSingletonPictures); |
1387 } | 1409 } |
1388 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1410 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
1389 | 1411 |
1390 canvas->drawPicture(macroPic); | 1412 canvas->drawPicture(macroPic); |
1391 return check_against_reference(bitmap, src, fSink); | 1413 return check_against_reference(bitmap, src, fSink); |
1392 }); | 1414 }); |
1393 } | 1415 } |
1394 | 1416 |
1395 } // namespace DM | 1417 } // namespace DM |
OLD | NEW |