commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 1 | #include "DMCpuGMTask.h" |
commit-bot@chromium.org | 2d3a789 | 2013-10-28 19:51:26 +0000 | [diff] [blame] | 2 | #include "DMPipeTask.h" |
commit-bot@chromium.org | a90c680 | 2014-04-30 13:20:45 +0000 | [diff] [blame] | 3 | #include "DMQuiltTask.h" |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 4 | #include "DMSerializeTask.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 5 | #include "DMUtil.h" |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 6 | #include "DMWriteTask.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 7 | |
| 8 | namespace DM { |
| 9 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 10 | CpuGMTask::CpuGMTask(const char* config, |
| 11 | Reporter* reporter, |
| 12 | TaskRunner* taskRunner, |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 13 | skiagm::GMRegistry::Factory gmFactory, |
| 14 | SkColorType colorType) |
| 15 | : CpuTask(reporter, taskRunner) |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 16 | , fGMFactory(gmFactory) |
| 17 | , fGM(fGMFactory(NULL)) |
commit-bot@chromium.org | 38aeb0f | 2014-02-26 23:01:57 +0000 | [diff] [blame] | 18 | , fName(UnderJoin(fGM->getName(), config)) |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 19 | , fColorType(colorType) |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 20 | {} |
| 21 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 22 | void CpuGMTask::draw() { |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 23 | SkBitmap bm; |
| 24 | AllocatePixels(fColorType, fGM->getISize().width(), fGM->getISize().height(), &bm); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 25 | |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 26 | SkCanvas canvas(bm); |
mtklein | 0b36e6b | 2014-09-11 12:30:12 -0700 | [diff] [blame] | 27 | CanvasPreflight(&canvas); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 28 | canvas.concat(fGM->getInitialTransform()); |
| 29 | fGM->draw(&canvas); |
| 30 | canvas.flush(); |
| 31 | |
rmistry@google.com | d6bab02 | 2013-12-02 13:50:38 +0000 | [diff] [blame] | 32 | #define SPAWN(ChildTask, ...) this->spawnChild(SkNEW_ARGS(ChildTask, (*this, __VA_ARGS__))) |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 33 | 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); |
mtklein | 7373456 | 2014-06-24 12:28:34 -0700 | [diff] [blame] | 36 | |
mtklein | a9ceaf5 | 2014-09-29 08:44:46 -0700 | [diff] [blame] | 37 | 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.com | ee21a3e | 2013-11-26 18:52:31 +0000 | [diff] [blame] | 40 | |
mtklein | a9ceaf5 | 2014-09-29 08:44:46 -0700 | [diff] [blame] | 41 | SPAWN(SerializeTask, fGMFactory(NULL), bm); |
mtklein | 5ad6ee1 | 2014-08-11 08:08:43 -0700 | [diff] [blame] | 42 | |
mtklein | ea65bfa | 2014-09-09 07:59:46 -0700 | [diff] [blame] | 43 | SPAWN(WriteTask, "GM", bm); |
rmistry@google.com | d6bab02 | 2013-12-02 13:50:38 +0000 | [diff] [blame] | 44 | #undef SPAWN |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 45 | } |
| 46 | |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 47 | bool CpuGMTask::shouldSkip() const { |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 48 | if (kRGB_565_SkColorType == fColorType && (fGM->getFlags() & skiagm::GM::kSkip565_Flag)) { |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 49 | return true; |
| 50 | } |
| 51 | if (fGM->getFlags() & skiagm::GM::kGPUOnly_Flag) { |
| 52 | return true; |
| 53 | } |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | } // namespace DM |