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

Unified Diff: gm/gm.h

Issue 811703005: SIMPLE_GM generates less code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Another Patch Set Created 5 years, 11 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 | gm/gm.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gm.h
diff --git a/gm/gm.h b/gm/gm.h
index 703fc90451968d30442cc03d1448487f2565fa3c..81744e2512625261c029d2fb68e926cc5cebdbad 100644
--- a/gm/gm.h
+++ b/gm/gm.h
@@ -25,18 +25,13 @@
static skiagm::GMRegistry SK_MACRO_APPEND_LINE(R_)(SK_MACRO_APPEND_LINE(F_));
// See colorwheel.cpp for example usage.
-#define DEF_SIMPLE_GM(NAME, CANVAS, W, H) \
- class SK_MACRO_CONCAT(NAME, _GM) : public skiagm::GM { \
- void onDraw(SkCanvas* canvas) SK_OVERRIDE; \
- SkISize onISize() SK_OVERRIDE { \
- return SkISize::Make((W), (H)); \
- } \
- SkString onShortName() SK_OVERRIDE { \
- return SkString(#NAME); \
- } \
- }; \
- DEF_GM( return SkNEW(SK_MACRO_CONCAT(NAME, _GM)); ) \
- void SK_MACRO_CONCAT(NAME, _GM)::onDraw(SkCanvas* CANVAS)
+#define DEF_SIMPLE_GM(NAME, CANVAS, W, H) \
+ static void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas* CANVAS); \
+ DEF_GM( return SkNEW_ARGS(skiagm::SimpleGM, \
+ (SkString(#NAME), \
+ SK_MACRO_CONCAT(NAME, _GM), \
+ SkISize::Make(W, H))); ) \
+ void SK_MACRO_CONCAT(NAME, _GM)(SkCanvas* CANVAS)
namespace skiagm {
@@ -136,6 +131,22 @@ namespace skiagm {
};
typedef SkTRegistry<GM*(*)(void*)> GMRegistry;
+
+ class SimpleGM : public skiagm::GM {
+ public:
+ SimpleGM(const SkString& name,
mtklein 2015/01/12 23:13:35 Looks like you can simplify a little further by de
+ void (*drawProc)(SkCanvas*),
+ const SkISize& size)
+ : fName(name), fDrawProc(drawProc), fSize(size) {}
+ protected:
+ void onDraw(SkCanvas* canvas) SK_OVERRIDE;
+ SkISize onISize() SK_OVERRIDE;
+ SkString onShortName() SK_OVERRIDE;
+ private:
+ SkString fName;
+ void (*fDrawProc)(SkCanvas*);
+ SkISize fSize;
+ };
}
#endif
« no previous file with comments | « no previous file | gm/gm.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698