OLD | NEW |
1 #include "DMUtil.h" | 1 #include "DMUtil.h" |
2 | 2 |
| 3 #include "SkPicture.h" |
| 4 |
3 namespace DM { | 5 namespace DM { |
4 | 6 |
5 SkString underJoin(const char* a, const char* b) { | 7 SkString UnderJoin(const char* a, const char* b) { |
6 SkString s; | 8 SkString s; |
7 s.appendf("%s_%s", a, b); | 9 s.appendf("%s_%s", a, b); |
8 return s; | 10 return s; |
9 } | 11 } |
10 | 12 |
11 SkString png(SkString s) { | 13 SkString Png(SkString s) { |
12 s.appendf(".png"); | 14 s.appendf(".png"); |
13 return s; | 15 return s; |
14 } | 16 } |
15 | 17 |
16 bool meetsExpectations(const skiagm::Expectations& expectations, const SkBitmap
bitmap) { | 18 bool MeetsExpectations(const skiagm::Expectations& expectations, const SkBitmap
bitmap) { |
17 if (expectations.ignoreFailure() || expectations.empty()) { | 19 if (expectations.ignoreFailure() || expectations.empty()) { |
18 return true; | 20 return true; |
19 } | 21 } |
20 const skiagm::GmResultDigest digest(bitmap); | 22 const skiagm::GmResultDigest digest(bitmap); |
21 return expectations.match(digest); | 23 return expectations.match(digest); |
22 } | 24 } |
23 | 25 |
| 26 void RecordPicture(skiagm::GM* gm, SkPicture* picture) { |
| 27 SkCanvas* canvas = picture->beginRecording(SkScalarCeilToInt(gm->width()), |
| 28 SkScalarCeilToInt(gm->height()), |
| 29 0 /*flags*/); |
| 30 canvas->concat(gm->getInitialTransform()); |
| 31 gm->draw(canvas); |
| 32 canvas->flush(); |
| 33 picture->endRecording(); |
| 34 } |
| 35 |
| 36 void SetupBitmap(const SkBitmap::Config config, skiagm::GM* gm, SkBitmap* bitmap
) { |
| 37 bitmap->setConfig(config, SkScalarCeilToInt(gm->width()), SkScalarCeilToInt(
gm->height())); |
| 38 bitmap->allocPixels(); |
| 39 bitmap->eraseColor(0x00000000); |
| 40 } |
| 41 |
| 42 void DrawPicture(SkPicture* picture, SkBitmap* bitmap) { |
| 43 SkASSERT(picture != NULL); |
| 44 SkASSERT(bitmap != NULL); |
| 45 SkCanvas canvas(*bitmap); |
| 46 canvas.drawPicture(*picture); |
| 47 canvas.flush(); |
| 48 } |
| 49 |
| 50 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) { |
| 51 const SkAutoLockPixels lockA(a), lockB(b); |
| 52 return a.getSize() == b.getSize() && 0 == memcmp(a.getPixels(), b.getPixels(
), b.getSize()); |
| 53 } |
| 54 |
24 } // namespace DM | 55 } // namespace DM |
OLD | NEW |