blob: f6edf23407946955ee0f979dc16ba85883159df1 [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#include "DMCpuTask.h"
2#include "DMReplayTask.h"
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +00003#include "DMSerializeTask.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00004#include "DMUtil.h"
mtklein@google.coma7a9f372013-10-18 20:52:44 +00005#include "DMWriteTask.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00006
7namespace DM {
8
9CpuTask::CpuTask(const char* name,
10 Reporter* reporter,
11 TaskRunner* taskRunner,
12 const skiagm::ExpectationsSource& expectations,
13 skiagm::GMRegistry::Factory gmFactory,
14 SkBitmap::Config config)
15 : Task(reporter, taskRunner)
16 , fGMFactory(gmFactory)
17 , fGM(fGMFactory(NULL))
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000018 , fName(UnderJoin(fGM->shortName(), name))
19 , fExpectations(expectations.get(Png(fName).c_str()))
mtklein@google.comd36522d2013-10-16 13:02:15 +000020 , fConfig(config)
21 {}
22
23void CpuTask::draw() {
24 SkBitmap bitmap;
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000025 SetupBitmap(fConfig, fGM.get(), &bitmap);
mtklein@google.comd36522d2013-10-16 13:02:15 +000026
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000027 SkCanvas canvas(bitmap);
mtklein@google.comd36522d2013-10-16 13:02:15 +000028 canvas.concat(fGM->getInitialTransform());
29 fGM->draw(&canvas);
30 canvas.flush();
31
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000032 if (!MeetsExpectations(fExpectations, bitmap)) {
mtklein@google.comd36522d2013-10-16 13:02:15 +000033 this->fail();
34 }
35
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000036 this->spawnChild(SkNEW_ARGS(ReplayTask, (*this, fGMFactory(NULL), bitmap)));
37 this->spawnChild(SkNEW_ARGS(SerializeTask, (*this, fGMFactory(NULL), bitmap)));
mtklein@google.coma7a9f372013-10-18 20:52:44 +000038 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
mtklein@google.comd36522d2013-10-16 13:02:15 +000039}
40
41bool CpuTask::shouldSkip() const {
42 if (SkBitmap::kRGB_565_Config == fConfig && (fGM->getFlags() & skiagm::GM::kSkip565_Flag)) {
43 return true;
44 }
45 if (fGM->getFlags() & skiagm::GM::kGPUOnly_Flag) {
46 return true;
47 }
48 return false;
49}
50
51} // namespace DM