mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 1 | #include "DMReplayTask.h" |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 2 | #include "DMWriteTask.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 3 | #include "DMUtil.h" |
| 4 | |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 5 | #include "SkCommandLineFlags.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 6 | #include "SkPicture.h" |
| 7 | |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 8 | DEFINE_bool(replay, false, "If true, run picture replay tests."); |
| 9 | |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 10 | namespace DM { |
| 11 | |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 12 | ReplayTask::ReplayTask(const Task& parent, |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 13 | skiagm::GM* gm, |
commit-bot@chromium.org | 66bb3d1 | 2013-10-16 19:13:38 +0000 | [diff] [blame] | 14 | SkBitmap reference) |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 15 | : Task(parent) |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 16 | , fName(UnderJoin(parent.name().c_str(), "replay")) |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 17 | , fGM(gm) |
| 18 | , fReference(reference) |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 19 | {} |
| 20 | |
| 21 | void ReplayTask::draw() { |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 22 | SkPicture recorded; |
| 23 | RecordPicture(fGM.get(), &recorded); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 24 | |
| 25 | SkBitmap bitmap; |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 26 | SetupBitmap(fReference.config(), fGM.get(), &bitmap); |
| 27 | DrawPicture(&recorded, &bitmap); |
| 28 | if (!BitmapsEqual(bitmap, fReference)) { |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 29 | this->fail(); |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 30 | this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 31 | } |
| 32 | } |
| 33 | |
| 34 | bool ReplayTask::shouldSkip() const { |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 35 | return !FLAGS_replay || fGM->getFlags() & skiagm::GM::kSkipPicture_Flag; |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 36 | } |
| 37 | |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 38 | } // namespace DM |