diff options
author | mtklein <mtklein@chromium.org> | 2016-02-19 14:27:14 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-19 14:27:14 -0800 |
commit | cbf897802b41d61dc35d6db0552d8d9604945fdc (patch) | |
tree | 72e6f95b3ae85c470e88ddc52ac81c2fe678a93c /dm | |
parent | 365bbff200a58a12a38631e53639c12a878b1fea (diff) |
DM: remove unnecessary use of std::function
This draw_to_canvas() function doesn't need the power of std::function.
This skips a copy or two, which is nice, and seems to clear
up most of my MSAN problems. Why? I do not know.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1718633002
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-MSAN-Trybot
Review URL: https://codereview.chromium.org/1718633002
Diffstat (limited to 'dm')
-rw-r--r-- | dm/DMSrcSink.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 366d8f860e..7ccaf223fc 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -1043,17 +1043,18 @@ Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) con // passing the Sink draw() arguments, a size, and a function draws into an SkCanvas. // Several examples below. +template <typename Fn> static Error draw_to_canvas(Sink* sink, SkBitmap* bitmap, SkWStream* stream, SkString* log, - SkISize size, std::function<Error(SkCanvas*)> draw) { + SkISize size, const Fn& draw) { class ProxySrc : public Src { public: - ProxySrc(SkISize size, std::function<Error(SkCanvas*)> draw) : fSize(size), fDraw(draw) {} + ProxySrc(SkISize size, const Fn& draw) : fSize(size), fDraw(draw) {} Error draw(SkCanvas* canvas) const override { return fDraw(canvas); } Name name() const override { sk_throw(); return ""; } // Won't be called. SkISize size() const override { return fSize; } private: - SkISize fSize; - std::function<Error(SkCanvas*)> fDraw; + SkISize fSize; + const Fn& fDraw; }; return sink->draw(ProxySrc(size, draw), bitmap, stream, log); } |