bsalomon@google.com | 48dd1a2 | 2011-10-31 14:18:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "gm.h" |
| 9 | using namespace skiagm; |
| 10 | |
| 11 | GM::GM() { |
| 12 | fBGColor = SK_ColorWHITE; |
| 13 | } |
| 14 | GM::~GM() {} |
| 15 | |
| 16 | void GM::draw(SkCanvas* canvas) { |
| 17 | this->drawBackground(canvas); |
| 18 | this->drawContent(canvas); |
| 19 | } |
| 20 | |
| 21 | void GM::drawContent(SkCanvas* canvas) { |
| 22 | this->onDraw(canvas); |
| 23 | } |
| 24 | |
| 25 | void GM::drawBackground(SkCanvas* canvas) { |
| 26 | this->onDrawBackground(canvas); |
| 27 | } |
| 28 | |
| 29 | const char* GM::shortName() { |
| 30 | if (fShortName.size() == 0) { |
| 31 | fShortName = this->onShortName(); |
| 32 | } |
| 33 | return fShortName.c_str(); |
| 34 | } |
| 35 | |
| 36 | void GM::setBGColor(SkColor color) { |
| 37 | fBGColor = color; |
| 38 | } |
| 39 | |
| 40 | void GM::onDrawBackground(SkCanvas* canvas) { |
| 41 | canvas->drawColor(fBGColor); |
| 42 | } |
| 43 | |
reed@google.com | 2d6ef52 | 2012-01-03 17:20:38 +0000 | [diff] [blame] | 44 | void GM::drawSizeBounds(SkCanvas* canvas, SkColor color) { |
| 45 | SkISize size = this->getISize(); |
| 46 | SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()), |
| 47 | SkIntToScalar(size.height())); |
| 48 | SkPaint paint; |
| 49 | paint.setColor(color); |
| 50 | canvas->drawRect(r, paint); |
| 51 | } |
| 52 | |
bsalomon@google.com | 48dd1a2 | 2011-10-31 14:18:20 +0000 | [diff] [blame] | 53 | // need to explicitly declare this, or we get some weird infinite loop llist |
| 54 | template GMRegistry* SkTRegistry<GM*, void*>::gHead; |