skia2/gm/gm.cpp
epoger@google.com 3a882dda07 GM: Allow ignored-tests.txt to list configs as well as tests (and combinations too)
BUG=skia:1657

This will allow us to ignore poppler failures until bug 1657 is resolved
(but this CL doesn't actually make that change to ignored-tests.txt yet)

R=scroggo@google.com

Review URL: https://codereview.chromium.org/26294004

git-svn-id: http://skia.googlecode.com/svn/trunk@11639 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-10-07 18:55:09 +00:00

81 lines
2.0 KiB
C++

/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
using namespace skiagm;
SkString GM::gResourcePath;
GM::GM() {
fBGColor = SK_ColorWHITE;
fCanvasIsDeferred = false;
fHaveCalledOnceBeforeDraw = false;
fStarterMatrix.reset();
}
GM::~GM() {}
void GM::draw(SkCanvas* canvas) {
this->drawBackground(canvas);
this->drawContent(canvas);
}
void GM::drawContent(SkCanvas* canvas) {
if (!fHaveCalledOnceBeforeDraw) {
fHaveCalledOnceBeforeDraw = true;
this->onOnceBeforeDraw();
}
this->onDraw(canvas);
}
void GM::drawBackground(SkCanvas* canvas) {
if (!fHaveCalledOnceBeforeDraw) {
fHaveCalledOnceBeforeDraw = true;
this->onOnceBeforeDraw();
}
this->onDrawBackground(canvas);
}
const char* GM::shortName() {
if (fShortName.size() == 0) {
fShortName = this->onShortName();
}
return fShortName.c_str();
}
void GM::setBGColor(SkColor color) {
fBGColor = color;
}
void GM::onDrawBackground(SkCanvas* canvas) {
canvas->drawColor(fBGColor, SkXfermode::kSrc_Mode);
}
void GM::drawSizeBounds(SkCanvas* canvas, SkColor color) {
SkISize size = this->getISize();
SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()),
SkIntToScalar(size.height()));
SkPaint paint;
paint.setColor(color);
canvas->drawRect(r, paint);
}
#if SK_SUPPORT_GPU
// canvas could almost be a const&, but accessRenderTarget isn't const.
/*static*/ GrContext* GM::GetGr(SkCanvas* canvas) {
SkASSERT(NULL != canvas);
SkBaseDevice* device = canvas->getTopDevice();
GrRenderTarget* renderTarget = device->accessRenderTarget();
if (NULL != renderTarget) {
return renderTarget->getContext();
}
return NULL;
}
#endif
// need to explicitly declare this, or we get some weird infinite loop llist
template GMRegistry* SkTRegistry<GM*(*)(void*)>::gHead;