OLD | NEW |
1 #include "DMUtil.h" | 1 #include "DMUtil.h" |
2 | 2 |
3 #include "SkColorPriv.h" | 3 #include "SkColorPriv.h" |
4 #include "SkPicture.h" | 4 #include "SkPicture.h" |
5 #include "SkPictureRecorder.h" | 5 #include "SkPictureRecorder.h" |
6 | 6 |
7 namespace DM { | 7 namespace DM { |
8 | 8 |
9 SkString UnderJoin(const char* a, const char* b) { | 9 SkString UnderJoin(const char* a, const char* b) { |
10 SkString s; | 10 SkString s; |
11 s.appendf("%s_%s", a, b); | 11 s.appendf("%s_%s", a, b); |
12 return s; | 12 return s; |
13 } | 13 } |
14 | 14 |
15 SkString FileToTaskName(SkString filename) { | 15 SkString FileToTaskName(SkString filename) { |
16 for (size_t i = 0; i < filename.size(); i++) { | 16 for (size_t i = 0; i < filename.size(); i++) { |
17 if ('_' == filename[i]) { filename[i] = '-'; } | 17 if ('_' == filename[i]) { filename[i] = '-'; } |
18 if ('.' == filename[i]) { filename[i] = '_'; } | 18 if ('.' == filename[i]) { filename[i] = '_'; } |
19 } | 19 } |
20 return filename; | 20 return filename; |
21 } | 21 } |
22 | 22 |
23 SkPicture* RecordPicture(skiagm::GM* gm, uint32_t recordFlags, SkBBHFactory* fac
tory) { | 23 SkPicture* RecordPicture(skiagm::GM* gm, SkBBHFactory* factory, bool skr) { |
24 const SkISize size = gm->getISize(); | 24 const int w = gm->getISize().width(), |
| 25 h = gm->getISize().height(); |
25 SkPictureRecorder recorder; | 26 SkPictureRecorder recorder; |
26 SkCanvas* canvas = recorder.beginRecording(size.width(), size.height(), fact
ory, recordFlags); | 27 |
| 28 SkCanvas* canvas = skr ? recorder.EXPERIMENTAL_beginRecording(w, h, factory) |
| 29 : recorder. beginRecording(w, h, factory)
; |
27 canvas->concat(gm->getInitialTransform()); | 30 canvas->concat(gm->getInitialTransform()); |
28 gm->draw(canvas); | 31 gm->draw(canvas); |
29 canvas->flush(); | 32 canvas->flush(); |
30 return recorder.endRecording(); | 33 return recorder.endRecording(); |
31 } | 34 } |
32 | 35 |
33 void AllocatePixels(SkColorType ct, int width, int height, SkBitmap* bitmap) { | 36 void AllocatePixels(SkColorType ct, int width, int height, SkBitmap* bitmap) { |
34 bitmap->allocPixels(SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType
)); | 37 bitmap->allocPixels(SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType
)); |
35 bitmap->eraseColor(0x00000000); | 38 bitmap->eraseColor(0x00000000); |
36 } | 39 } |
37 | 40 |
38 void AllocatePixels(const SkBitmap& reference, SkBitmap* bitmap) { | 41 void AllocatePixels(const SkBitmap& reference, SkBitmap* bitmap) { |
39 AllocatePixels(reference.colorType(), reference.width(), reference.height(),
bitmap); | 42 AllocatePixels(reference.colorType(), reference.width(), reference.height(),
bitmap); |
40 } | 43 } |
41 | 44 |
42 void DrawPicture(SkPicture* picture, SkBitmap* bitmap) { | 45 void DrawPicture(const SkPicture& picture, SkBitmap* bitmap) { |
43 SkASSERT(picture != NULL); | |
44 SkASSERT(bitmap != NULL); | 46 SkASSERT(bitmap != NULL); |
45 SkCanvas canvas(*bitmap); | 47 SkCanvas canvas(*bitmap); |
46 canvas.drawPicture(picture); | 48 canvas.drawPicture(&picture); |
47 canvas.flush(); | 49 canvas.flush(); |
48 } | 50 } |
49 | 51 |
50 static void unpack_565(uint16_t pixel, unsigned* r, unsigned* g, unsigned* b) { | 52 static void unpack_565(uint16_t pixel, unsigned* r, unsigned* g, unsigned* b) { |
51 *r = SkGetPackedR16(pixel); | 53 *r = SkGetPackedR16(pixel); |
52 *g = SkGetPackedG16(pixel); | 54 *g = SkGetPackedG16(pixel); |
53 *b = SkGetPackedB16(pixel); | 55 *b = SkGetPackedB16(pixel); |
54 } | 56 } |
55 | 57 |
56 // Returns |a-b|. | 58 // Returns |a-b|. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 95 |
94 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) { | 96 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) { |
95 if (a.info() != b.info()) { | 97 if (a.info() != b.info()) { |
96 return false; | 98 return false; |
97 } | 99 } |
98 const SkAutoLockPixels lockA(a), lockB(b); | 100 const SkAutoLockPixels lockA(a), lockB(b); |
99 return 0 == memcmp(a.getPixels(), b.getPixels(), a.getSize()); | 101 return 0 == memcmp(a.getPixels(), b.getPixels(), a.getSize()); |
100 } | 102 } |
101 | 103 |
102 } // namespace DM | 104 } // namespace DM |
OLD | NEW |