add parallel public API for recording SkLiteDL.

The API is restricted to pretty much just what Derek calls,
but it's enough that we can switch testing over to use it.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2246893002

Review-Url: https://codereview.chromium.org/2246893002
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 638af13..31e1574 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -21,8 +21,6 @@
 #include "SkImageGenerator.h"
 #include "SkImageGeneratorCG.h"
 #include "SkImageGeneratorWIC.h"
-#include "SkLiteDL.h"
-#include "SkLiteRecorder.h"
 #include "SkMallocPixelRef.h"
 #include "SkMultiPictureDraw.h"
 #include "SkNullCanvas.h"
@@ -1615,18 +1613,15 @@
 
 Error ViaLite::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkString* log) const {
     auto size = src.size();
-    SkRect bounds = {0,0, (SkScalar)size.width(), (SkScalar)size.height()};
     return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
-        sk_sp<SkLiteDL> dl = SkLiteDL::New(bounds);
-
-        SkLiteRecorder rec;
-        rec.reset(dl.get());
-
-        Error err = src.draw(&rec);
+        SkPictureRecorder_Lite recorder;
+        Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()),
+                                                     SkIntToScalar(size.height())));
         if (!err.isEmpty()) {
             return err;
         }
-        dl->draw(canvas);
+        sk_sp<SkDrawable> dl = recorder.finishRecordingAsDrawable();
+        canvas->drawDrawable(dl.get());
         return check_against_reference(bitmap, src, fSink);
     });
 }
diff --git a/include/core/SkPictureRecorder.h b/include/core/SkPictureRecorder.h
index f20a06a..96e7aa0 100644
--- a/include/core/SkPictureRecorder.h
+++ b/include/core/SkPictureRecorder.h
@@ -140,4 +140,30 @@
     typedef SkNoncopyable INHERITED;
 };
 
+class SkLiteDL;
+class SkLiteRecorder;
+
+// A similar API to SkPictureRecorder, wrapping SkLiteRecorder and SkLiteDL.
+class SK_API SkPictureRecorder_Lite : SkNoncopyable {
+public:
+     SkPictureRecorder_Lite();
+    ~SkPictureRecorder_Lite();
+
+    SkCanvas* beginRecording(const SkRect& bounds);
+    SkCanvas* beginRecording(SkScalar w, SkScalar h) {
+        return this->beginRecording(SkRect::MakeWH(w,h));
+    }
+
+    SkCanvas* getRecordingCanvas();
+
+    void optimizeFor(GrContext* ctx) { fGrContextToOptimizeFor = ctx; }
+
+    sk_sp<SkDrawable> finishRecordingAsDrawable(uint32_t ignored = 0);
+
+private:
+    std::unique_ptr<SkLiteRecorder> fRecorder;
+    sk_sp<SkLiteDL>                 fDL;
+    GrContext*                      fGrContextToOptimizeFor = nullptr;
+};
+
 #endif
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
index 8e7c7f3..00450b0 100644
--- a/src/core/SkPictureRecorder.cpp
+++ b/src/core/SkPictureRecorder.cpp
@@ -196,3 +196,26 @@
 
     return drawable;
 }
+
+#include "SkLiteDL.h"
+#include "SkLiteRecorder.h"
+
+SkPictureRecorder_Lite:: SkPictureRecorder_Lite() : fRecorder(new SkLiteRecorder) {}
+SkPictureRecorder_Lite::~SkPictureRecorder_Lite() {}
+
+SkCanvas* SkPictureRecorder_Lite::beginRecording(const SkRect& bounds) {
+    fDL = SkLiteDL::New(bounds);
+    fRecorder->reset(fDL.get());
+    return this->getRecordingCanvas();
+}
+
+SkCanvas* SkPictureRecorder_Lite::getRecordingCanvas() {
+    return fDL ? fRecorder.get() : nullptr;
+}
+
+sk_sp<SkDrawable> SkPictureRecorder_Lite::finishRecordingAsDrawable(uint32_t) {
+    if (fGrContextToOptimizeFor) {
+        fDL->optimizeFor(fGrContextToOptimizeFor);
+    }
+    return std::move(fDL);
+}