aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMSrcSink.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-08-06 12:51:51 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-06 12:51:51 -0700
commit9c5052f16b249d2b7674ea86bd24ed0038ccc61f (patch)
treedb2e05f246b2e7d65c91275943e1ada80a4856f1 /dm/DMSrcSink.h
parentc6f411e72b1fea6608f540f64a57bcacbe3378cd (diff)
SkLite*
SkLiteRecorder, a new SkCanvas, fills out SkLiteDL, a new SkDrawable. This SkDrawable is a display list similar to SkRecord and SkBigPicture / SkRecordedDrawable, but with a few new design points inspired by Android and slimming paint: 1) SkLiteDL is structured as one big contiguous array rather than the two layer structure of SkRecord. This trades away flexibility and large-op-count performance for better data locality for small to medium size pictures. 2) We keep a global freelist of SkLiteDLs, both reusing the SkLiteDL struct itself and its contiguous byte array. This keeps the expected number of mallocs per display list allocation <1 (really, ~0) for cyclical use cases. These two together mean recording is faster. Measuring against the code we use at head, SkLiteRecorder trends about ~3x faster across various size pictures, matching speed at 0 draws and beating the special-case 1-draw pictures we have today. (I.e. we won't need those special case implementations anymore, because they're slower than this new generic code.) This new strategy records 10 drawRects() in about the same time the old strategy took for 2. This strategy stays the winner until at least 500 drawRect()s on my laptop, where I stopped checking. A simpler alternative to freelisting is also possible (but not implemented here), where we allow the client to manually reset() an SkLiteDL for reuse when its refcnt is 1. That's essentially what we're doing with the freelist, except tracking what's available for reuse globally instead of making the client do it. This code is not fully capable yet, but most of the key design points are there. The internal structure of SkLiteDL is the area I expect to be most volatile (anything involving Op), but its interface and the whole of SkLiteRecorder ought to be just about done. You can run nanobench --match picture_overhead as a demo. Everything it exercises is fully fleshed out, so what it tests is an apples-to-apples comparison as far as recording costs go. I have not yet compared playback performance. It should be simple to wrap this into an SkPicture subclass if we want. I won't start proposing we replace anything old with anything new quite yet until I have more ducks in a row, but this does look pretty promising (similar to the SkRecord over old SkPicture change a couple years ago) and I'd like to land, experiment, iterate, especially with an eye toward Android. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2213333002 Review-Url: https://codereview.chromium.org/2213333002
Diffstat (limited to 'dm/DMSrcSink.h')
-rw-r--r--dm/DMSrcSink.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h
index a54ddb8d7f..086becb6f6 100644
--- a/dm/DMSrcSink.h
+++ b/dm/DMSrcSink.h
@@ -446,6 +446,12 @@ public:
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
};
+class ViaLite : public Via {
+public:
+ explicit ViaLite(Sink* sink) : Via(sink) {}
+ Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
+};
+
} // namespace DM
#endif//DMSrcSink_DEFINED