| OLD | NEW |
| 1 #include "DMReplayTask.h" | 1 #include "DMReplayTask.h" |
| 2 #include "DMUtil.h" | 2 #include "DMUtil.h" |
| 3 | 3 |
| 4 #include "SkPicture.h" | 4 #include "SkPicture.h" |
| 5 | 5 |
| 6 namespace DM { | 6 namespace DM { |
| 7 | 7 |
| 8 ReplayTask::ReplayTask(const char* suffix, | 8 ReplayTask::ReplayTask(const char* suffix, |
| 9 const Task& parent, | 9 const Task& parent, |
| 10 skiagm::GM* gm, | 10 skiagm::GM* gm, |
| 11 skiagm::GmResultDigest reference, | 11 skiagm::GmResultDigest reference, |
| 12 SkBitmap::Config config) | 12 SkBitmap::Config config) |
| 13 : Task(parent) | 13 : Task(parent) |
| 14 , fName(underJoin(parent.name().c_str(), suffix)) | 14 , fName(underJoin(parent.name().c_str(), suffix)) |
| 15 , fGM(gm) | 15 , fGM(gm) |
| 16 , fReference(reference) | 16 , fReference(reference) |
| 17 , fConfig(config) | 17 , fConfig(config) |
| 18 {} | 18 {} |
| 19 | 19 |
| 20 void ReplayTask::draw() { | 20 void ReplayTask::draw() { |
| 21 SkPicture picture; | 21 SkPicture picture; |
| 22 SkCanvas* canvas = picture.beginRecording(fGM->width(), fGM->height(), 0 /*f
lags*/); | 22 SkCanvas* canvas = picture.beginRecording(SkScalarCeilToInt(fGM->width()), |
| 23 SkScalarCeilToInt(fGM->height()), |
| 24 0 /*flags*/); |
| 23 | 25 |
| 24 canvas->concat(fGM->getInitialTransform()); | 26 canvas->concat(fGM->getInitialTransform()); |
| 25 fGM->draw(canvas); | 27 fGM->draw(canvas); |
| 26 canvas->flush(); | 28 canvas->flush(); |
| 27 | 29 |
| 28 picture.endRecording(); | 30 picture.endRecording(); |
| 29 | 31 |
| 30 SkBitmap bitmap; | 32 SkBitmap bitmap; |
| 31 bitmap.setConfig(fConfig, fGM->width(), fGM->height()); | 33 bitmap.setConfig(fConfig, SkScalarCeilToInt(fGM->width()), SkScalarCeilToInt
(fGM->height())); |
| 32 bitmap.allocPixels(); | 34 bitmap.allocPixels(); |
| 33 bitmap.eraseColor(0x00000000); | 35 bitmap.eraseColor(0x00000000); |
| 34 | 36 |
| 35 SkCanvas replay(bitmap); | 37 SkCanvas replay(bitmap); |
| 36 replay.drawPicture(picture); | 38 replay.drawPicture(picture); |
| 37 replay.flush(); | 39 replay.flush(); |
| 38 | 40 |
| 39 const skiagm::GmResultDigest replayDigest(bitmap); | 41 const skiagm::GmResultDigest replayDigest(bitmap); |
| 40 if (!replayDigest.equals(fReference)) { | 42 if (!replayDigest.equals(fReference)) { |
| 41 this->fail(); | 43 this->fail(); |
| 42 } | 44 } |
| 43 } | 45 } |
| 44 | 46 |
| 45 bool ReplayTask::shouldSkip() const { | 47 bool ReplayTask::shouldSkip() const { |
| 46 return fGM->getFlags() & skiagm::GM::kGPUOnly_Flag || | 48 return fGM->getFlags() & skiagm::GM::kGPUOnly_Flag || |
| 47 fGM->getFlags() & skiagm::GM::kSkipPicture_Flag; | 49 fGM->getFlags() & skiagm::GM::kSkipPicture_Flag; |
| 48 } | 50 } |
| 49 | 51 |
| 50 } // namespace | 52 } // namespace |
| OLD | NEW |