blob: b6f21f81ff01c123b1d1338018888c689999e42a [file] [log] [blame]
bsalomon@google.com48dd1a22011-10-31 14:18:20 +00001/*
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"
9using namespace skiagm;
10
robertphillips@google.com8570b5c2012-03-20 17:40:58 +000011SkString GM::gResourcePath;
12
bsalomon@google.com48dd1a22011-10-31 14:18:20 +000013GM::GM() {
14 fBGColor = SK_ColorWHITE;
15}
16GM::~GM() {}
17
18void GM::draw(SkCanvas* canvas) {
19 this->drawBackground(canvas);
20 this->drawContent(canvas);
21}
22
23void GM::drawContent(SkCanvas* canvas) {
24 this->onDraw(canvas);
25}
26
27void GM::drawBackground(SkCanvas* canvas) {
28 this->onDrawBackground(canvas);
29}
30
31const char* GM::shortName() {
32 if (fShortName.size() == 0) {
33 fShortName = this->onShortName();
34 }
35 return fShortName.c_str();
36}
37
38void GM::setBGColor(SkColor color) {
39 fBGColor = color;
40}
41
42void GM::onDrawBackground(SkCanvas* canvas) {
43 canvas->drawColor(fBGColor);
44}
45
reed@google.com2d6ef522012-01-03 17:20:38 +000046void GM::drawSizeBounds(SkCanvas* canvas, SkColor color) {
47 SkISize size = this->getISize();
48 SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()),
49 SkIntToScalar(size.height()));
50 SkPaint paint;
51 paint.setColor(color);
52 canvas->drawRect(r, paint);
53}
54
bsalomon@google.com48dd1a22011-10-31 14:18:20 +000055// need to explicitly declare this, or we get some weird infinite loop llist
56template GMRegistry* SkTRegistry<GM*, void*>::gHead;