blob: 1d1d4010f7f675ad225b477ea2e036fb10f92b26 [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#include "DMCpuTask.h"
commit-bot@chromium.org2d3a7892013-10-28 19:51:26 +00002#include "DMPipeTask.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00003#include "DMReplayTask.h"
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +00004#include "DMSerializeTask.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00005#include "DMUtil.h"
mtklein@google.coma7a9f372013-10-18 20:52:44 +00006#include "DMWriteTask.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00007
8namespace DM {
9
10CpuTask::CpuTask(const char* name,
11 Reporter* reporter,
12 TaskRunner* taskRunner,
13 const skiagm::ExpectationsSource& expectations,
14 skiagm::GMRegistry::Factory gmFactory,
15 SkBitmap::Config config)
16 : Task(reporter, taskRunner)
17 , fGMFactory(gmFactory)
18 , fGM(fGMFactory(NULL))
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000019 , fName(UnderJoin(fGM->shortName(), name))
20 , fExpectations(expectations.get(Png(fName).c_str()))
mtklein@google.comd36522d2013-10-16 13:02:15 +000021 , fConfig(config)
22 {}
23
24void CpuTask::draw() {
25 SkBitmap bitmap;
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000026 SetupBitmap(fConfig, fGM.get(), &bitmap);
mtklein@google.comd36522d2013-10-16 13:02:15 +000027
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000028 SkCanvas canvas(bitmap);
mtklein@google.comd36522d2013-10-16 13:02:15 +000029 canvas.concat(fGM->getInitialTransform());
30 fGM->draw(&canvas);
31 canvas.flush();
32
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000033 if (!MeetsExpectations(fExpectations, bitmap)) {
mtklein@google.comd36522d2013-10-16 13:02:15 +000034 this->fail();
35 }
36
commit-bot@chromium.org2d3a7892013-10-28 19:51:26 +000037 this->spawnChild(SkNEW_ARGS(PipeTask, (*this, fGMFactory(NULL), bitmap, false, false)));
38 this->spawnChild(SkNEW_ARGS(PipeTask, (*this, fGMFactory(NULL), bitmap, true, false)));
39 this->spawnChild(SkNEW_ARGS(PipeTask, (*this, fGMFactory(NULL), bitmap, true, true)));
40
commit-bot@chromium.orgc1362422013-10-30 20:45:28 +000041 this->spawnChild(SkNEW_ARGS(ReplayTask, (*this, fGMFactory(NULL), bitmap, true)));
42 this->spawnChild(SkNEW_ARGS(ReplayTask, (*this, fGMFactory(NULL), bitmap, false)));
43
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000044 this->spawnChild(SkNEW_ARGS(SerializeTask, (*this, fGMFactory(NULL), bitmap)));
mtklein@google.coma7a9f372013-10-18 20:52:44 +000045 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
mtklein@google.comd36522d2013-10-16 13:02:15 +000046}
47
48bool CpuTask::shouldSkip() const {
49 if (SkBitmap::kRGB_565_Config == fConfig && (fGM->getFlags() & skiagm::GM::kSkip565_Flag)) {
50 return true;
51 }
52 if (fGM->getFlags() & skiagm::GM::kGPUOnly_Flag) {
53 return true;
54 }
55 return false;
56}
57
58} // namespace DM