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