aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-05-07 10:53:34 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-07 10:53:34 -0700
commite44b5084d86772727826e65b8e95e17dc53ee977 (patch)
tree1764e4c586903b03a5dbaae9a2f5335586dbc48c /dm
parent4525f438a84147989de080e89cf1d97bc46eb546 (diff)
DM: use SkFunction to make required argument type clearer.
Previously it was hard to tell that DrawFn took an SkCanvas* and returned an Error. Now it's clear from the type. BUG=skia: Review URL: https://codereview.chromium.org/1125233002
Diffstat (limited to 'dm')
-rw-r--r--dm/DMSrcSink.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 79b791979f..090a24d86a 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -13,6 +13,7 @@
#include "SkDeferredCanvas.h"
#include "SkDocument.h"
#include "SkError.h"
+#include "SkFunction.h"
#include "SkImageGenerator.h"
#include "SkMultiPictureDraw.h"
#include "SkNullCanvas.h"
@@ -493,21 +494,20 @@ Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) con
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// Handy for front-patching a Src. Do whatever up-front work you need, then call draw_to_canvas(),
-// passing the Sink draw() arguments, a size, and a lambda that takes SkCanvas* and returns Error.
+// passing the Sink draw() arguments, a size, and a function draws into an SkCanvas.
// Several examples below.
-template <typename DrawFn>
static Error draw_to_canvas(Sink* sink, SkBitmap* bitmap, SkWStream* stream, SkString* log,
- SkISize size, DrawFn draw) {
+ SkISize size, SkFunction<Error(SkCanvas*)> draw) {
class ProxySrc : public Src {
public:
- ProxySrc(SkISize size, DrawFn draw) : fSize(size), fDraw(draw) {}
+ ProxySrc(SkISize size, SkFunction<Error(SkCanvas*)> 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;
- DrawFn fDraw;
+ SkISize fSize;
+ SkFunction<Error(SkCanvas*)> fDraw;
};
return sink->draw(ProxySrc(size, draw), bitmap, stream, log);
}