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