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 | |
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 |
52 const char* SkStringExtension(const SkString& string) { | |
53 int index = string.findLastOf('.'); | |
54 if (index >= 0 && (size_t) ++index < string.size()) { | |
55 return &string.c_str()[index]; | |
56 } | |
57 return ""; | |
58 } | |
59 | |
49 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} | 60 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} |
50 | 61 |
51 Error GMSrc::draw(SkCanvas* canvas) const { | 62 Error GMSrc::draw(SkCanvas* canvas) const { |
52 SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr)); | 63 SkAutoTDelete<skiagm::GM> gm(fFactory(nullptr)); |
53 canvas->concat(gm->getInitialTransform()); | 64 canvas->concat(gm->getInitialTransform()); |
54 gm->draw(canvas); | 65 gm->draw(canvas); |
55 return ""; | 66 return ""; |
56 } | 67 } |
57 | 68 |
58 SkISize GMSrc::size() const { | 69 SkISize GMSrc::size() const { |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 return codec->getScaledDimensions(fScale); | 607 return codec->getScaledDimensions(fScale); |
597 } | 608 } |
598 | 609 |
599 Name CodecSrc::name() const { | 610 Name CodecSrc::name() const { |
600 if (1.0f == fScale) { | 611 if (1.0f == fScale) { |
601 return SkOSPath::Basename(fPath.c_str()); | 612 return SkOSPath::Basename(fPath.c_str()); |
602 } | 613 } |
603 return get_scaled_name(fPath, fScale); | 614 return get_scaled_name(fPath, fScale); |
604 } | 615 } |
605 | 616 |
617 int CodecSrc::enclave() const { | |
msarett
2016/02/08 19:35:37
I think AndroidCodecSrc should also override encla
scroggo
2016/02/08 20:08:12
Yep. That's at least partially responsible for my
| |
618 #ifdef SK_CODEC_DECODES_RAW | |
mtklein
2016/02/08 21:26:55
Why #ifdef? Doesn't the actual logic you wrote st
| |
619 if (!FLAGS_RAW_threading) { | |
620 static const char* const exts[] = { | |
621 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw" , | |
622 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW" , | |
623 }; | |
624 const char* actualExt = SkStringExtension(fPath); | |
625 for (auto* ext : exts) { | |
626 if (0 == strcmp(ext, actualExt)) { | |
627 return kRAW_Enclave; | |
628 } | |
629 } | |
630 } | |
631 #endif | |
632 return kAnyThread_Enclave; | |
633 } | |
634 | |
606 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | 635 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ |
607 | 636 |
608 AndroidCodecSrc::AndroidCodecSrc(Path path, Mode mode, CodecSrc::DstColorType ds tColorType, | 637 AndroidCodecSrc::AndroidCodecSrc(Path path, Mode mode, CodecSrc::DstColorType ds tColorType, |
609 SkAlphaType dstAlphaType, int sampleSize) | 638 SkAlphaType dstAlphaType, int sampleSize) |
610 : fPath(path) | 639 : fPath(path) |
611 , fMode(mode) | 640 , fMode(mode) |
612 , fDstColorType(dstColorType) | 641 , fDstColorType(dstColorType) |
613 , fDstAlphaType(dstAlphaType) | 642 , fDstAlphaType(dstAlphaType) |
614 , fSampleSize(sampleSize) | 643 , fSampleSize(sampleSize) |
615 {} | 644 {} |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1390 skr.visit<void>(i, drawsAsSingletonPictures); | 1419 skr.visit<void>(i, drawsAsSingletonPictures); |
1391 } | 1420 } |
1392 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); | 1421 SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture()); |
1393 | 1422 |
1394 canvas->drawPicture(macroPic); | 1423 canvas->drawPicture(macroPic); |
1395 return check_against_reference(bitmap, src, fSink); | 1424 return check_against_reference(bitmap, src, fSink); |
1396 }); | 1425 }); |
1397 } | 1426 } |
1398 | 1427 |
1399 } // namespace DM | 1428 } // namespace DM |
OLD | NEW |