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