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 | |
robertphillips@google.com | 770963f | 2014-04-18 18:04:41 +0000 | [diff] [blame] | 5 | #include "SkBBHFactory.h" |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 6 | #include "SkCommandLineFlags.h" |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 7 | #include "SkPicture.h" |
| 8 | |
rmistry@google.com | d6bab02 | 2013-12-02 13:50:38 +0000 | [diff] [blame] | 9 | DEFINE_bool(replay, true, "If true, run picture replay tests."); |
| 10 | 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] | 11 | |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 12 | namespace DM { |
| 13 | |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 14 | ReplayTask::ReplayTask(const Task& parent, |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 15 | skiagm::GM* gm, |
commit-bot@chromium.org | c136242 | 2013-10-30 20:45:28 +0000 | [diff] [blame] | 16 | SkBitmap reference, |
commit-bot@chromium.org | 90b5a2a | 2014-05-14 17:55:32 +0000 | [diff] [blame^] | 17 | Mode mode) |
commit-bot@chromium.org | ef57b7e | 2014-02-28 20:31:31 +0000 | [diff] [blame] | 18 | : CpuTask(parent) |
commit-bot@chromium.org | 90b5a2a | 2014-05-14 17:55:32 +0000 | [diff] [blame^] | 19 | , fUseRTree(mode == kRTree_Mode) |
| 20 | , fName(UnderJoin(parent.name().c_str(), fUseRTree ? "rtree" : "replay")) |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 21 | , fGM(gm) |
| 22 | , fReference(reference) |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 23 | {} |
| 24 | |
| 25 | void ReplayTask::draw() { |
commit-bot@chromium.org | 5fb2ce3 | 2014-04-17 23:35:06 +0000 | [diff] [blame] | 26 | SkAutoTDelete<SkBBHFactory> factory; |
commit-bot@chromium.org | d393b17 | 2014-04-16 16:02:10 +0000 | [diff] [blame] | 27 | if (fUseRTree) { |
commit-bot@chromium.org | 5fb2ce3 | 2014-04-17 23:35:06 +0000 | [diff] [blame] | 28 | factory.reset(SkNEW(SkRTreeFactory)); |
commit-bot@chromium.org | d393b17 | 2014-04-16 16:02:10 +0000 | [diff] [blame] | 29 | } |
commit-bot@chromium.org | 5fb2ce3 | 2014-04-17 23:35:06 +0000 | [diff] [blame] | 30 | SkAutoTUnref<SkPicture> recorded(RecordPicture(fGM.get(), 0, factory.get())); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 31 | |
| 32 | SkBitmap bitmap; |
commit-bot@chromium.org | 15a1405 | 2014-02-16 00:59:25 +0000 | [diff] [blame] | 33 | SetupBitmap(fReference.colorType(), fGM.get(), &bitmap); |
robertphillips@google.com | 84b18c7 | 2014-04-13 19:09:42 +0000 | [diff] [blame] | 34 | DrawPicture(recorded, &bitmap); |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 35 | if (!BitmapsEqual(bitmap, fReference)) { |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 36 | this->fail(); |
commit-bot@chromium.org | 192cbf6 | 2013-10-21 18:40:25 +0000 | [diff] [blame] | 37 | this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 38 | } |
| 39 | } |
| 40 | |
| 41 | bool ReplayTask::shouldSkip() const { |
commit-bot@chromium.org | c136242 | 2013-10-30 20:45:28 +0000 | [diff] [blame] | 42 | if (fGM->getFlags() & skiagm::GM::kSkipPicture_Flag) { |
| 43 | return true; |
| 44 | } |
| 45 | |
| 46 | if (FLAGS_rtree && fUseRTree) { |
commit-bot@chromium.org | 96eb624 | 2014-04-29 16:44:00 +0000 | [diff] [blame] | 47 | return false; |
commit-bot@chromium.org | c136242 | 2013-10-30 20:45:28 +0000 | [diff] [blame] | 48 | } |
| 49 | if (FLAGS_replay && !fUseRTree) { |
| 50 | return false; |
| 51 | } |
| 52 | return true; |
mtklein@google.com | d36522d | 2013-10-16 13:02:15 +0000 | [diff] [blame] | 53 | } |
| 54 | |
mtklein@google.com | a7a9f37 | 2013-10-18 20:52:44 +0000 | [diff] [blame] | 55 | } // namespace DM |