skia2/dm/DMCpuTask.cpp
commit-bot@chromium.org 66bb3d1f5e DM: duh, don't calculate digests unless we're going to look at them.
This doesn't cut the runtime significantly (~6s either way) but it does cut the CPU time down from ~10s to ~6s.

BUG=
R=bungeman@google.com

Author: mtklein@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@11826 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-10-16 19:13:38 +00:00

57 lines
1.6 KiB
C++

#include "DMCpuTask.h"
#include "DMReplayTask.h"
#include "DMUtil.h"
#include "SkCommandLineFlags.h"
DEFINE_bool(replay, false, "If true, run replay tests for each CpuTask.");
// TODO(mtklein): add the other various options
namespace DM {
CpuTask::CpuTask(const char* name,
Reporter* reporter,
TaskRunner* taskRunner,
const skiagm::ExpectationsSource& expectations,
skiagm::GMRegistry::Factory gmFactory,
SkBitmap::Config config)
: Task(reporter, taskRunner)
, fGMFactory(gmFactory)
, fGM(fGMFactory(NULL))
, fName(underJoin(fGM->shortName(), name))
, fExpectations(expectations.get(png(fName).c_str()))
, fConfig(config)
{}
void CpuTask::draw() {
SkBitmap bitmap;
bitmap.setConfig(fConfig, SkScalarCeilToInt(fGM->width()), SkScalarCeilToInt(fGM->height()));
bitmap.allocPixels();
bitmap.eraseColor(0x00000000);
SkCanvas canvas(bitmap);
canvas.concat(fGM->getInitialTransform());
fGM->draw(&canvas);
canvas.flush();
if (!meetsExpectations(fExpectations, bitmap)) {
this->fail();
}
if (FLAGS_replay) {
this->spawnChild(SkNEW_ARGS(ReplayTask,
("replay", *this, fGMFactory(NULL), bitmap)));
}
}
bool CpuTask::shouldSkip() const {
if (SkBitmap::kRGB_565_Config == fConfig && (fGM->getFlags() & skiagm::GM::kSkip565_Flag)) {
return true;
}
if (fGM->getFlags() & skiagm::GM::kGPUOnly_Flag) {
return true;
}
return false;
}
} // namespace DM