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