epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame^] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 8 | #ifndef skiagm_DEFINED |
| 9 | #define skiagm_DEFINED |
| 10 | |
epoger@google.com | d4af56c | 2011-07-25 16:27:59 +0000 | [diff] [blame] | 11 | #include "SkBitmap.h" |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 12 | #include "SkCanvas.h" |
epoger@google.com | d4af56c | 2011-07-25 16:27:59 +0000 | [diff] [blame] | 13 | #include "SkDevice.h" |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 14 | #include "SkPaint.h" |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 15 | #include "SkRefCnt.h" |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 16 | #include "SkSize.h" |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 17 | #include "SkString.h" |
| 18 | #include "SkTRegistry.h" |
| 19 | |
| 20 | namespace skiagm { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 21 | |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 22 | static inline SkISize make_isize(int w, int h) { |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 23 | SkISize sz; |
| 24 | sz.set(w, h); |
| 25 | return sz; |
| 26 | } |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 27 | |
| 28 | class GM { |
| 29 | public: |
| 30 | GM(); |
| 31 | virtual ~GM(); |
| 32 | |
| 33 | void draw(SkCanvas*); |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 34 | SkISize getISize() { return this->onISize(); } |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 35 | const char* shortName() { |
| 36 | if (fShortName.size() == 0) { |
| 37 | fShortName = this->onShortName(); |
| 38 | } |
| 39 | return fShortName.c_str(); |
| 40 | } |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 41 | |
| 42 | protected: |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 43 | virtual void onDraw(SkCanvas*) = 0; |
| 44 | virtual SkISize onISize() = 0; |
| 45 | virtual SkString onShortName() = 0; |
| 46 | |
| 47 | private: |
| 48 | SkString fShortName; |
reed@android.com | 00dae86 | 2009-06-10 15:38:48 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | typedef SkTRegistry<GM*, void*> GMRegistry; |
| 52 | } |
| 53 | |
| 54 | #endif |