blob: 3f51c8a31897062459b694e736613719f4e7a77d [file] [log] [blame]
mtklein@google.comd36522d2013-10-16 13:02:15 +00001#include "DMCpuTask.h"
rmistry@google.comd6bab022013-12-02 13:50:38 +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"
rmistry@google.comd6bab022013-12-02 13:50:38 +00006#include "DMTileGridTask.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00007#include "DMUtil.h"
mtklein@google.coma7a9f372013-10-18 20:52:44 +00008#include "DMWriteTask.h"
mtklein@google.comd36522d2013-10-16 13:02:15 +00009
10namespace DM {
11
12CpuTask::CpuTask(const char* name,
13 Reporter* reporter,
14 TaskRunner* taskRunner,
15 const skiagm::ExpectationsSource& expectations,
16 skiagm::GMRegistry::Factory gmFactory,
17 SkBitmap::Config config)
18 : Task(reporter, taskRunner)
19 , fGMFactory(gmFactory)
20 , fGM(fGMFactory(NULL))
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000021 , fName(UnderJoin(fGM->shortName(), name))
22 , fExpectations(expectations.get(Png(fName).c_str()))
mtklein@google.comd36522d2013-10-16 13:02:15 +000023 , fConfig(config)
24 {}
25
26void CpuTask::draw() {
27 SkBitmap bitmap;
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000028 SetupBitmap(fConfig, fGM.get(), &bitmap);
mtklein@google.comd36522d2013-10-16 13:02:15 +000029
commit-bot@chromium.org192cbf62013-10-21 18:40:25 +000030 SkCanvas canvas(bitmap);
mtklein@google.comd36522d2013-10-16 13:02:15 +000031 canvas.concat(fGM->getInitialTransform());
32 fGM->draw(&canvas);
33 canvas.flush();
34
rmistry@google.comd6bab022013-12-02 13:50:38 +000035#define SPAWN(ChildTask, ...) this->spawnChild(SkNEW_ARGS(ChildTask, (*this, __VA_ARGS__)))
36 SPAWN(ChecksumTask, fExpectations, bitmap);
mtklein@google.comd36522d2013-10-16 13:02:15 +000037
rmistry@google.comd6bab022013-12-02 13:50:38 +000038 SPAWN(PipeTask, fGMFactory(NULL), bitmap, false, false);
39 SPAWN(PipeTask, fGMFactory(NULL), bitmap, true, false);
40 SPAWN(PipeTask, fGMFactory(NULL), bitmap, true, true);
41 SPAWN(ReplayTask, fGMFactory(NULL), bitmap, false);
42 SPAWN(ReplayTask, fGMFactory(NULL), bitmap, true);
43 SPAWN(SerializeTask, fGMFactory(NULL), bitmap);
44 SPAWN(TileGridTask, fGMFactory(NULL), bitmap, SkISize::Make(16,16));
mtklein@google.comee21a3e2013-11-26 18:52:31 +000045
rmistry@google.comd6bab022013-12-02 13:50:38 +000046 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