Home | History | Annotate | Download | only in gm
      1 #ifndef skiagm_DEFINED
      2 #define skiagm_DEFINED
      3 
      4 #include "SkCanvas.h"
      5 #include "SkPaint.h"
      6 #include "SkRefCnt.h"
      7 #include "SkSize.h"
      8 #include "SkString.h"
      9 #include "SkTRegistry.h"
     10 
     11 namespace skiagm {
     12 
     13 	static inline SkISize make_isize(int w, int h) {
     14 		SkISize sz;
     15 		sz.set(w, h);
     16 		return sz;
     17 	}
     18 
     19     class GM {
     20     public:
     21         GM();
     22         virtual ~GM();
     23 
     24 		void draw(SkCanvas*);
     25 		SkISize getISize() { return this->onISize(); }
     26         const char* shortName() {
     27             if (fShortName.size() == 0) {
     28                 fShortName = this->onShortName();
     29             }
     30             return fShortName.c_str();
     31         }
     32 
     33 	protected:
     34 		virtual void onDraw(SkCanvas*) = 0;
     35 		virtual SkISize onISize() = 0;
     36         virtual SkString onShortName() = 0;
     37 
     38     private:
     39         SkString fShortName;
     40     };
     41 
     42     typedef SkTRegistry<GM*, void*> GMRegistry;
     43 }
     44 
     45 #endif
     46