Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2717)

Unified Diff: dm/DMSrcSink.cpp

Issue 1718633002: DM: remove unnecessary use of std::function (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: optimism Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/dm_flags.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 366d8f860ebb9278e8ded9f46b4615cd16b24eb3..7ccaf223fc3a32b8e2baa867dcd575454332b6ec 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);
}
« no previous file with comments | « no previous file | tools/dm_flags.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698