blob: ab92ff6b3e4198f6e708c9b7e42034b5ed669f4e [file] [log] [blame]
reed@android.com00dae862009-06-10 15:38:48 +00001#ifndef skiagm_DEFINED
2#define skiagm_DEFINED
3
reed@android.comdd0ac282009-06-20 02:38:16 +00004#include "SkCanvas.h"
5#include "SkPaint.h"
reed@android.com00dae862009-06-10 15:38:48 +00006#include "SkRefCnt.h"
reed@android.comdd0ac282009-06-20 02:38:16 +00007#include "SkSize.h"
reed@android.com00dae862009-06-10 15:38:48 +00008#include "SkString.h"
9#include "SkTRegistry.h"
10
11namespace skiagm {
reed@android.comdd0ac282009-06-20 02:38:16 +000012
reed@android.com8015dd82009-06-21 00:49:18 +000013 static inline SkISize make_isize(int w, int h) {
reed@android.comdd0ac282009-06-20 02:38:16 +000014 SkISize sz;
15 sz.set(w, h);
16 return sz;
17 }
reed@android.com00dae862009-06-10 15:38:48 +000018
19 class GM {
20 public:
21 GM();
22 virtual ~GM();
23
24 void draw(SkCanvas*);
reed@android.comdd0ac282009-06-20 02:38:16 +000025 SkISize getISize() { return this->onISize(); }
reed@android.com8015dd82009-06-21 00:49:18 +000026 const char* shortName() {
27 if (fShortName.size() == 0) {
28 fShortName = this->onShortName();
29 }
30 return fShortName.c_str();
31 }
reed@android.com00dae862009-06-10 15:38:48 +000032
33 protected:
reed@android.com8015dd82009-06-21 00:49:18 +000034 virtual void onDraw(SkCanvas*) = 0;
35 virtual SkISize onISize() = 0;
36 virtual SkString onShortName() = 0;
37
38 private:
39 SkString fShortName;
reed@android.com00dae862009-06-10 15:38:48 +000040 };
41
42 typedef SkTRegistry<GM*, void*> GMRegistry;
43}
44
45#endif