blob: f9c0e6637f520c2e7403af22c8e025296f1ddd9a [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
11GM::GM() {
12 fBGColor = SK_ColorWHITE;
13}
14GM::~GM() {}
15
16void GM::draw(SkCanvas* canvas) {
17 this->drawBackground(canvas);
18 this->drawContent(canvas);
19}
20
21void GM::drawContent(SkCanvas* canvas) {
22 this->onDraw(canvas);
23}
24
25void GM::drawBackground(SkCanvas* canvas) {
26 this->onDrawBackground(canvas);
27}
28
29const char* GM::shortName() {
30 if (fShortName.size() == 0) {
31 fShortName = this->onShortName();
32 }
33 return fShortName.c_str();
34}
35
36void GM::setBGColor(SkColor color) {
37 fBGColor = color;
38}
39
40void GM::onDrawBackground(SkCanvas* canvas) {
41 canvas->drawColor(fBGColor);
42}
43
reed@google.com2d6ef522012-01-03 17:20:38 +000044void 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.com48dd1a22011-10-31 14:18:20 +000053// need to explicitly declare this, or we get some weird infinite loop llist
54template GMRegistry* SkTRegistry<GM*, void*>::gHead;