Index: dm/DMSrcSink.h |
diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h |
index 3a7d4ee516cfa7ccb87e9a0e9c7cfbe3c7d19634..64897d20bcc7c04400d1eb54bc0397c2a8096a38 100644 |
--- a/dm/DMSrcSink.h |
+++ b/dm/DMSrcSink.h |
@@ -59,13 +59,15 @@ struct SinkFlags { |
}; |
struct Src { |
- // All Srcs must be thread safe. |
virtual ~Src() {} |
virtual Error SK_WARN_UNUSED_RESULT draw(SkCanvas*) const = 0; |
virtual SkISize size() const = 0; |
virtual Name name() const = 0; |
virtual void modifyGrContextOptions(GrContextOptions* options) const {} |
virtual bool veto(SinkFlags) const { return false; } |
+ |
+ // Force Tasks using this Src to run on the main thread? |
+ virtual bool serial() const { return false; } |
}; |
struct Sink { |
@@ -73,8 +75,9 @@ struct Sink { |
// You may write to either the bitmap or stream. If you write to log, we'll print that out. |
virtual Error SK_WARN_UNUSED_RESULT draw(const Src&, SkBitmap*, SkWStream*, SkString* log) |
const = 0; |
- // Sinks in the same enclave (except kAnyThread_Enclave) will run serially on the same thread. |
- virtual int enclave() const = 0; |
+ |
+ // Force Tasks using this Sink to run on the main thread? |
+ virtual bool serial() const { return false; } |
// File extension for the content draw() outputs, e.g. "png", "pdf". |
virtual const char* fileExtension() const = 0; |
@@ -82,9 +85,6 @@ struct Sink { |
virtual SinkFlags flags() const = 0; |
}; |
-enum { kAnyThread_Enclave, kGPU_Enclave }; |
-static const int kNumEnclaves = kGPU_Enclave + 1; |
- |
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
class GMSrc : public Src { |
@@ -200,7 +200,6 @@ public: |
NullSink() {} |
Error draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const override; |
- int enclave() const override { return kAnyThread_Enclave; } |
const char* fileExtension() const override { return ""; } |
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kNull, SinkFlags::kDirect }; } |
}; |
@@ -212,7 +211,7 @@ public: |
int samples, bool diText, bool threaded); |
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
- int enclave() const override; |
+ bool serial() const override { return !fThreaded; } |
const char* fileExtension() const override { return "png"; } |
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kGPU, SinkFlags::kDirect }; } |
private: |
@@ -228,7 +227,6 @@ public: |
PDFSink(const char* rasterizer); |
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
- int enclave() const override { return kAnyThread_Enclave; } |
const char* fileExtension() const override { return "pdf"; } |
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } |
private: |
@@ -240,7 +238,6 @@ public: |
XPSSink(); |
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
- int enclave() const override { return kAnyThread_Enclave; } |
const char* fileExtension() const override { return "xps"; } |
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } |
}; |
@@ -250,7 +247,6 @@ public: |
explicit RasterSink(SkColorType); |
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
- int enclave() const override { return kAnyThread_Enclave; } |
const char* fileExtension() const override { return "png"; } |
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kRaster, SinkFlags::kDirect }; } |
private: |
@@ -262,7 +258,6 @@ public: |
SKPSink(); |
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
- int enclave() const override { return kAnyThread_Enclave; } |
const char* fileExtension() const override { return "skp"; } |
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } |
}; |
@@ -272,7 +267,6 @@ public: |
SVGSink(); |
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override; |
- int enclave() const override { return kAnyThread_Enclave; } |
const char* fileExtension() const override { return "svg"; } |
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kVector, SinkFlags::kDirect }; } |
}; |
@@ -284,7 +278,7 @@ class Via : public Sink { |
public: |
explicit Via(Sink* sink) : fSink(sink) {} |
const char* fileExtension() const override { return fSink->fileExtension(); } |
- int enclave() const override { return fSink->enclave(); } |
+ bool serial() const override { return fSink->serial(); } |
SinkFlags flags() const override { |
SinkFlags flags = fSink->flags(); |
flags.approach = SinkFlags::kIndirect; |