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

Unified Diff: dm/DMSrcSink.cpp

Issue 1125233002: DM: use SkFunction to make required argument type clearer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 | no next file » | 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 840936c894b29d7742fee8d9b07e30b06b72bc74..5676faca55a1b56fa2d885713655f87c21d89ba9 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"
@@ -505,21 +506,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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698