mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 1 | #include "DMCpuTask.h" |
commit-bot@chromium.org | 2d3a789 | 2013-10-28 19:51:26 +0000 | [diff] [blame] | 2 | #include "DMPipeTask.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 3 | #include "DMReplayTask.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 | |
| 10 | CpuTask::CpuTask(const char* name, |
| 11 | Reporter* reporter, |
| 12 | TaskRunner* taskRunner, |
| 13 | const skiagm::ExpectationsSource& expectations, |
| 14 | skiagm::GMRegistry::Factory gmFactory, |
| 15 | SkBitmap::Config config) |
| 16 | : Task(reporter, taskRunner) |
| 17 | , fGMFactory(gmFactory) |
| 18 | , fGM(fGMFactory(NULL)) |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 19 | , fName(UnderJoin(fGM->shortName(), name)) |
| 20 | , fExpectations(expectations.get(Png(fName).c_str())) |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 21 | , fConfig(config) |
| 22 | {} |
| 23 | |
| 24 | void CpuTask::draw() { |
| 25 | SkBitmap bitmap; |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 26 | SetupBitmap(fConfig, fGM.get(), &bitmap); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 27 | |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 28 | SkCanvas canvas(bitmap); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 29 | canvas.concat(fGM->getInitialTransform()); |
| 30 | fGM->draw(&canvas); |
| 31 | canvas.flush(); |
| 32 | |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 33 | if (!MeetsExpectations(fExpectations, bitmap)) { |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 34 | this->fail(); |
| 35 | } |
| 36 | |
commit-bot@chromium.org | 2d3a789 | 2013-10-28 19:51:26 +0000 | [diff] [blame] | 37 | this->spawnChild(SkNEW_ARGS(PipeTask, (*this, fGMFactory(NULL), bitmap, false, false))); |
| 38 | this->spawnChild(SkNEW_ARGS(PipeTask, (*this, fGMFactory(NULL), bitmap, true, false))); |
| 39 | this->spawnChild(SkNEW_ARGS(PipeTask, (*this, fGMFactory(NULL), bitmap, true, true))); |
| 40 | |
commit-bot@chromium.org | c136242 | 2013-10-30 20:45:28 +0000 | [diff] [blame] | 41 | this->spawnChild(SkNEW_ARGS(ReplayTask, (*this, fGMFactory(NULL), bitmap, true))); |
| 42 | this->spawnChild(SkNEW_ARGS(ReplayTask, (*this, fGMFactory(NULL), bitmap, false))); |
| 43 | |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 44 | this->spawnChild(SkNEW_ARGS(SerializeTask, (*this, fGMFactory(NULL), bitmap))); |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 45 | this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | bool CpuTask::shouldSkip() const { |
| 49 | if (SkBitmap::kRGB_565_Config == fConfig && (fGM->getFlags() & skiagm::GM::kSkip565_Flag)) { |
| 50 | return true; |
| 51 | } |
| 52 | if (fGM->getFlags() & skiagm::GM::kGPUOnly_Flag) { |
| 53 | return true; |
| 54 | } |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | } // namespace DM |