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 SkBitmap reference) |
12 SkBitmap::Config config) | |
13 : Task(parent) | 12 : Task(parent) |
14 , fName(underJoin(parent.name().c_str(), suffix)) | 13 , fName(underJoin(parent.name().c_str(), suffix)) |
15 , fGM(gm) | 14 , fGM(gm) |
16 , fReference(reference) | 15 , fReference(reference) |
17 , fConfig(config) | |
18 {} | 16 {} |
19 | 17 |
20 void ReplayTask::draw() { | 18 void ReplayTask::draw() { |
21 SkPicture picture; | 19 SkPicture picture; |
22 SkCanvas* canvas = picture.beginRecording(SkScalarCeilToInt(fGM->width()), | 20 SkCanvas* canvas = picture.beginRecording(SkScalarCeilToInt(fGM->width()), |
23 SkScalarCeilToInt(fGM->height()), | 21 SkScalarCeilToInt(fGM->height()), |
24 0 /*flags*/); | 22 0 /*flags*/); |
25 | 23 |
26 canvas->concat(fGM->getInitialTransform()); | 24 canvas->concat(fGM->getInitialTransform()); |
27 fGM->draw(canvas); | 25 fGM->draw(canvas); |
28 canvas->flush(); | 26 canvas->flush(); |
29 | 27 |
30 picture.endRecording(); | 28 picture.endRecording(); |
31 | 29 |
32 SkBitmap bitmap; | 30 SkBitmap bitmap; |
33 bitmap.setConfig(fConfig, SkScalarCeilToInt(fGM->width()), SkScalarCeilToInt
(fGM->height())); | 31 bitmap.setConfig(fReference.config(), |
| 32 SkScalarCeilToInt(fGM->width()), |
| 33 SkScalarCeilToInt(fGM->height())); |
34 bitmap.allocPixels(); | 34 bitmap.allocPixels(); |
35 bitmap.eraseColor(0x00000000); | 35 bitmap.eraseColor(0x00000000); |
36 | 36 |
37 SkCanvas replay(bitmap); | 37 SkCanvas replay(bitmap); |
38 replay.drawPicture(picture); | 38 replay.drawPicture(picture); |
39 replay.flush(); | 39 replay.flush(); |
40 | 40 |
41 const skiagm::GmResultDigest replayDigest(bitmap); | 41 const SkAutoLockPixels mine(bitmap), theirs(fReference); |
42 if (!replayDigest.equals(fReference)) { | 42 if (bitmap.getSize() != fReference.getSize() || |
| 43 0 != memcmp(bitmap.getPixels(), fReference.getPixels(), bitmap.getSize()
)) |
| 44 { |
43 this->fail(); | 45 this->fail(); |
44 } | 46 } |
45 } | 47 } |
46 | 48 |
47 bool ReplayTask::shouldSkip() const { | 49 bool ReplayTask::shouldSkip() const { |
48 return fGM->getFlags() & skiagm::GM::kGPUOnly_Flag || | 50 return fGM->getFlags() & skiagm::GM::kGPUOnly_Flag || |
49 fGM->getFlags() & skiagm::GM::kSkipPicture_Flag; | 51 fGM->getFlags() & skiagm::GM::kSkipPicture_Flag; |
50 } | 52 } |
51 | 53 |
52 } // namespace | 54 } // namespace |
OLD | NEW |