Add threaded backend sink to DM. Fix a scheduler bug.

The bug is spotted by the new sink. I'd expect more bugs to be revealed
and fixed using the new sink.

Bug: skia:
Change-Id: I6b0c9267079fbd6149004f0ecd55ddb179702588
Reviewed-on: https://skia-review.googlesource.com/109720
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Yuqian Li <liyuqian@google.com>
diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h
index 1ad2eca..6cc5df6 100644
--- a/dm/DMSrcSink.h
+++ b/dm/DMSrcSink.h
@@ -424,11 +424,22 @@
     Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
     const char* fileExtension() const override { return "png"; }
     SinkFlags flags() const override { return SinkFlags{ SinkFlags::kRaster, SinkFlags::kDirect }; }
-private:
+protected:
+    void allocPixels(const Src& src, SkBitmap*) const;
+
     SkColorType         fColorType;
     sk_sp<SkColorSpace> fColorSpace;
 };
 
+class ThreadedSink : public RasterSink {
+public:
+    explicit ThreadedSink(SkColorType, sk_sp<SkColorSpace> = nullptr);
+    Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
+
+private:
+    std::unique_ptr<SkExecutor> fExecutor;
+};
+
 class SKPSink : public Sink {
 public:
     SKPSink();