Index: dm/DMSrcSink.cpp |
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp |
index a0dcb1cfc5b08ce16c3455f5097b44ba288b233a..10ec545bbe7c491952686f509bca44f1fe77dc92 100644 |
--- a/dm/DMSrcSink.cpp |
+++ b/dm/DMSrcSink.cpp |
@@ -38,6 +38,9 @@ |
DEFINE_bool(multiPage, false, "For document-type backends, render the source" |
" into multiple pages"); |
+#ifdef SK_CODEC_DECODES_RAW |
+DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?"); |
+#endif |
static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) { |
SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, size)); |
@@ -46,6 +49,14 @@ static bool lazy_decode_bitmap(const void* src, size_t size, SkBitmap* dst) { |
namespace DM { |
+const char* SkStringExtension(const SkString& string) { |
+ int index = string.findLastOf('.'); |
+ if (index >= 0 && (size_t) ++index < string.size()) { |
+ return &string.c_str()[index]; |
+ } |
+ return ""; |
+} |
+ |
GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} |
Error GMSrc::draw(SkCanvas* canvas) const { |
@@ -238,6 +249,24 @@ Name BRDSrc::name() const { |
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
+static int enclave_from_path_name(const SkString& path) { |
+#ifdef SK_CODEC_DECODES_RAW |
+ if (!FLAGS_RAW_threading) { |
+ static const char* const exts[] = { |
+ "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw", |
+ "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW", |
+ }; |
+ const char* actualExt = SkStringExtension(path); |
+ for (auto* ext : exts) { |
+ if (0 == strcmp(ext, actualExt)) { |
+ return kRAW_Enclave; |
+ } |
+ } |
+ } |
+#endif |
+ return kAnyThread_Enclave; |
+} |
+ |
CodecSrc::CodecSrc(Path path, Mode mode, DstColorType dstColorType, SkAlphaType dstAlphaType, |
float scale) |
: fPath(path) |
@@ -245,6 +274,7 @@ CodecSrc::CodecSrc(Path path, Mode mode, DstColorType dstColorType, SkAlphaType |
, fDstColorType(dstColorType) |
, fDstAlphaType(dstAlphaType) |
, fScale(scale) |
+ , fEnclave(enclave_from_path_name(path)) |
{} |
bool CodecSrc::veto(SinkFlags flags) const { |
@@ -612,6 +642,7 @@ AndroidCodecSrc::AndroidCodecSrc(Path path, Mode mode, CodecSrc::DstColorType ds |
, fDstColorType(dstColorType) |
, fDstAlphaType(dstAlphaType) |
, fSampleSize(sampleSize) |
+ , fEnclave(enclave_from_path_name(path)) |
{} |
bool AndroidCodecSrc::veto(SinkFlags flags) const { |