OLD | NEW |
1 #include "DMRecordTask.h" | 1 #include "DMRecordTask.h" |
2 #include "DMUtil.h" | 2 #include "DMUtil.h" |
3 #include "DMWriteTask.h" | 3 #include "DMWriteTask.h" |
4 #include "SkCommandLineFlags.h" | 4 #include "SkCommandLineFlags.h" |
5 #include "SkRecording.h" | 5 #include "SkRecording.h" |
6 | 6 |
7 DEFINE_bool(skr, false, "If true, run SKR tests."); | 7 DEFINE_bool(skr, false, "If true, run SKR tests."); |
8 | 8 |
9 namespace DM { | 9 namespace DM { |
10 | 10 |
11 RecordTask::RecordTask(const Task& parent, skiagm::GM* gm, SkBitmap reference) | 11 RecordTask::RecordTask(const Task& parent, skiagm::GM* gm, SkBitmap reference) |
12 : CpuTask(parent) | 12 : CpuTask(parent) |
13 , fName(UnderJoin(parent.name().c_str(), "skr")) | 13 , fName(UnderJoin(parent.name().c_str(), "skr")) |
14 , fGM(gm) | 14 , fGM(gm) |
15 , fReference(reference) | 15 , fReference(reference) |
16 {} | 16 {} |
17 | 17 |
18 void RecordTask::draw() { | 18 void RecordTask::draw() { |
19 // Record the GM into an SkRecord. | 19 // Record the GM into an SkRecord. |
20 EXPERIMENTAL::SkRecording recording(fReference.width(), fReference.height())
; | 20 EXPERIMENTAL::SkRecording recording(fReference.width(), fReference.height())
; |
| 21 recording.canvas()->concat(fGM->getInitialTransform()); |
21 fGM->draw(recording.canvas()); | 22 fGM->draw(recording.canvas()); |
22 SkAutoTDelete<const EXPERIMENTAL::SkPlayback> playback(recording.releasePlay
back()); | 23 SkAutoTDelete<const EXPERIMENTAL::SkPlayback> playback(recording.releasePlay
back()); |
23 | 24 |
24 // Draw the SkRecord back into a bitmap. | 25 // Draw the SkRecord back into a bitmap. |
25 SkBitmap bitmap; | 26 SkBitmap bitmap; |
26 SetupBitmap(fReference.colorType(), fGM.get(), &bitmap); | 27 SetupBitmap(fReference.colorType(), fGM.get(), &bitmap); |
27 SkCanvas target(bitmap); | 28 SkCanvas target(bitmap); |
28 playback->draw(&target); | 29 playback->draw(&target); |
29 | 30 |
30 if (!BitmapsEqual(bitmap, fReference)) { | 31 if (!BitmapsEqual(bitmap, fReference)) { |
31 this->fail(); | 32 this->fail(); |
32 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); | 33 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
33 } | 34 } |
34 } | 35 } |
35 | 36 |
36 bool RecordTask::shouldSkip() const { | 37 bool RecordTask::shouldSkip() const { |
37 return !FLAGS_skr; | 38 return !FLAGS_skr; |
38 } | 39 } |
39 | 40 |
40 } // namespace DM | 41 } // namespace DM |
OLD | NEW |