1 #include "DMCpuGMTask.h"
2 #include "DMExpectationsTask.h"
3 #include "DMPipeTask.h"
4 #include "DMQuiltTask.h"
5 #include "DMRecordTask.h"
6 #include "DMReplayTask.h"
7 #include "DMSerializeTask.h"
8 #include "DMUtil.h"
9 #include "DMWriteTask.h"
10
11 namespace DM {
12
CpuGMTask(const char * config,Reporter * reporter,TaskRunner * taskRunner,skiagm::GMRegistry::Factory gmFactory,const Expectations & expectations,SkColorType colorType)13 CpuGMTask::CpuGMTask(const char* config,
14 Reporter* reporter,
15 TaskRunner* taskRunner,
16 skiagm::GMRegistry::Factory gmFactory,
17 const Expectations& expectations,
18 SkColorType colorType)
19 : CpuTask(reporter, taskRunner)
20 , fGMFactory(gmFactory)
21 , fGM(fGMFactory(NULL))
22 , fName(UnderJoin(fGM->getName(), config))
23 , fExpectations(expectations)
24 , fColorType(colorType)
25 {}
26
draw()27 void CpuGMTask::draw() {
28 SkBitmap bitmap;
29 AllocatePixels(fColorType, fGM->getISize().width(), fGM->getISize().height(), &bitmap);
30
31 SkCanvas canvas(bitmap);
32 canvas.concat(fGM->getInitialTransform());
33 fGM->draw(&canvas);
34 canvas.flush();
35
36 #define SPAWN(ChildTask, ...) this->spawnChild(SkNEW_ARGS(ChildTask, (*this, __VA_ARGS__)))
37 SPAWN(ExpectationsTask, fExpectations, bitmap);
38
39 SPAWN(PipeTask, fGMFactory(NULL), bitmap, PipeTask::kInProcess_Mode);
40 SPAWN(PipeTask, fGMFactory(NULL), bitmap, PipeTask::kCrossProcess_Mode);
41 SPAWN(PipeTask, fGMFactory(NULL), bitmap, PipeTask::kSharedAddress_Mode);
42 SPAWN(QuiltTask, fGMFactory(NULL), bitmap);
43 SPAWN(RecordTask, fGMFactory(NULL), bitmap, RecordTask::kOptimize_Mode);
44 SPAWN(RecordTask, fGMFactory(NULL), bitmap, RecordTask::kNoOptimize_Mode);
45 SPAWN(ReplayTask, fGMFactory(NULL), bitmap, ReplayTask::kNormal_Mode);
46 SPAWN(ReplayTask, fGMFactory(NULL), bitmap, ReplayTask::kRTree_Mode);
47 SPAWN(SerializeTask, fGMFactory(NULL), bitmap);
48
49 SPAWN(WriteTask, bitmap);
50 #undef SPAWN
51 }
52
shouldSkip() const53 bool CpuGMTask::shouldSkip() const {
54 if (kRGB_565_SkColorType == fColorType && (fGM->getFlags() & skiagm::GM::kSkip565_Flag)) {
55 return true;
56 }
57 if (fGM->getFlags() & skiagm::GM::kGPUOnly_Flag) {
58 return true;
59 }
60 return false;
61 }
62
63 } // namespace DM
64