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 | |
rmistry@google.com | d6bab02 | 2013-12-02 13:50:38 +0000 | [diff] [blame] | 8 | DEFINE_bool(replay, true, "If true, run picture replay tests."); |
| 9 | DEFINE_bool(rtree, true, "If true, run picture replay tests with an rtree."); |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 10 | |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 11 | namespace DM { |
| 12 | |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 13 | ReplayTask::ReplayTask(const Task& parent, |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 14 | skiagm::GM* gm, |
commit-bot@chromium.org | c136242 | 2013-10-30 20:45:28 +0000 | [diff] [blame] | 15 | SkBitmap reference, |
| 16 | bool useRTree) |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 17 | : Task(parent) |
commit-bot@chromium.org | c136242 | 2013-10-30 20:45:28 +0000 | [diff] [blame] | 18 | , fName(UnderJoin(parent.name().c_str(), useRTree ? "rtree" : "replay")) |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 19 | , fGM(gm) |
| 20 | , fReference(reference) |
commit-bot@chromium.org | c136242 | 2013-10-30 20:45:28 +0000 | [diff] [blame] | 21 | , fUseRTree(useRTree) |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 22 | {} |
| 23 | |
| 24 | void ReplayTask::draw() { |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 25 | SkPicture recorded; |
commit-bot@chromium.org | c136242 | 2013-10-30 20:45:28 +0000 | [diff] [blame] | 26 | const uint32_t flags = fUseRTree ? SkPicture::kOptimizeForClippedPlayback_RecordingFlag : 0; |
| 27 | RecordPicture(fGM.get(), &recorded, flags); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 28 | |
| 29 | SkBitmap bitmap; |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 30 | SetupBitmap(fReference.config(), fGM.get(), &bitmap); |
| 31 | DrawPicture(&recorded, &bitmap); |
| 32 | if (!BitmapsEqual(bitmap, fReference)) { |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 33 | this->fail(); |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 34 | this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 35 | } |
| 36 | } |
| 37 | |
| 38 | bool ReplayTask::shouldSkip() const { |
commit-bot@chromium.org | c136242 | 2013-10-30 20:45:28 +0000 | [diff] [blame] | 39 | if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { |
| 40 | return true; |
| 41 | } |
| 42 | |
| 43 | if (FLAGS_rtree && fUseRTree) { |
| 44 | return false; |
| 45 | } |
| 46 | if (FLAGS_replay && !fUseRTree) { |
| 47 | return false; |
| 48 | } |
| 49 | return true; |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 50 | } |
| 51 | |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 52 | } // namespace DM |