blob: 8163133af4d014cbbc37fa12aa1dbc24245c5973 [file] [log] [blame]
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +00001#include "DMCpuGMTask.h"
commit-bot@chromium.org2d3a7892013-10-28 19:51:26 +00002#include "DMPipeTask.h"
commit-bot@chromium.orga90c6802014-04-30 13:20:45 +00003#include "DMQuiltTask.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
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000010CpuGMTask::CpuGMTask(const char* config,
11 Reporter* reporter,
12 TaskRunner* taskRunner,
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000013 skiagm::GMRegistry::Factory gmFactory,
14 SkColorType colorType)
15 : CpuTask(reporter, taskRunner)
mtklein@google.comd36522d2013-10-16 13:02:15 +000016 , fGMFactory(gmFactory)
17 , fGM(fGMFactory(NULL))
commit-bot@chromium.org38aeb0f2014-02-26 23:01:57 +000018 , fName(UnderJoin(fGM->getName(), config))
commit-bot@chromium.org15a14052014-02-16 00:59:25 +000019 , fColorType(colorType)
mtklein@google.comd36522d2013-10-16 13:02:15 +000020 {}
21
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000022void CpuGMTask::draw() {
mtklein5ad6ee12014-08-11 08:08:43 -070023 SkBitmap bm;
24 AllocatePixels(fColorType, fGM->getISize().width(), fGM->getISize().height(), &bm);
mtklein@google.comd36522d2013-10-16 13:02:15 +000025
mtklein5ad6ee12014-08-11 08:08:43 -070026 SkCanvas canvas(bm);
mtklein0b36e6b2014-09-11 12:30:12 -070027 CanvasPreflight(&canvas);
mtklein@google.comd36522d2013-10-16 13:02:15 +000028 canvas.concat(fGM->getInitialTransform());
29 fGM->draw(&canvas);
30 canvas.flush();
31
rmistry@google.comd6bab022013-12-02 13:50:38 +000032#define SPAWN(ChildTask, ...) this->spawnChild(SkNEW_ARGS(ChildTask, (*this, __VA_ARGS__)))
mtklein5ad6ee12014-08-11 08:08:43 -070033 SPAWN(PipeTask, fGMFactory(NULL), bm, PipeTask::kInProcess_Mode);
34 SPAWN(PipeTask, fGMFactory(NULL), bm, PipeTask::kCrossProcess_Mode);
35 SPAWN(PipeTask, fGMFactory(NULL), bm, PipeTask::kSharedAddress_Mode);
mtklein73734562014-06-24 12:28:34 -070036
mtkleina9ceaf52014-09-29 08:44:46 -070037 SPAWN(QuiltTask, fGMFactory(NULL), bm, QuiltTask::kNone_BBH);
38 SPAWN(QuiltTask, fGMFactory(NULL), bm, QuiltTask::kRTree_BBH);
39 SPAWN(QuiltTask, fGMFactory(NULL), bm, QuiltTask::kTileGrid_BBH);
mtklein@google.comee21a3e2013-11-26 18:52:31 +000040
mtkleina9ceaf52014-09-29 08:44:46 -070041 SPAWN(SerializeTask, fGMFactory(NULL), bm);
mtklein5ad6ee12014-08-11 08:08:43 -070042
mtkleinea65bfa2014-09-09 07:59:46 -070043 SPAWN(WriteTask, "GM", bm);
rmistry@google.comd6bab022013-12-02 13:50:38 +000044#undef SPAWN
mtklein@google.comd36522d2013-10-16 13:02:15 +000045}
46
commit-bot@chromium.orgef57b7e2014-02-28 20:31:31 +000047bool CpuGMTask::shouldSkip() const {
commit-bot@chromium.org15a14052014-02-16 00:59:25 +000048 if (kRGB_565_SkColorType == fColorType && (fGM->getFlags() & skiagm::GM::kSkip565_Flag)) {
mtklein@google.comd36522d2013-10-16 13:02:15 +000049 return true;
50 }
51 if (fGM->getFlags() & skiagm::GM::kGPUOnly_Flag) {
52 return true;
53 }
54 return false;
55}
56
57} // namespace DM