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