Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: dm/DMUtil.cpp

Issue 88543002: DM: some refactoring (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #include "DMUtil.h" 1 #include "DMUtil.h"
2 2
3 #include "SkPicture.h" 3 #include "SkPicture.h"
4 4
5 namespace DM { 5 namespace DM {
6 6
7 SkString UnderJoin(const char* a, const char* b) { 7 SkString UnderJoin(const char* a, const char* b) {
8 SkString s; 8 SkString s;
9 s.appendf("%s_%s", a, b); 9 s.appendf("%s_%s", a, b);
10 return s; 10 return s;
11 } 11 }
12 12
13 SkString Png(SkString s) { 13 SkString Png(SkString s) {
14 s.appendf(".png"); 14 s.appendf(".png");
15 return s; 15 return s;
16 } 16 }
17 17
18 bool MeetsExpectations(const skiagm::Expectations& expectations, const SkBitmap bitmap) {
19 if (expectations.ignoreFailure() || expectations.empty()) {
20 return true;
21 }
22 const skiagm::GmResultDigest digest(bitmap);
23 return expectations.match(digest);
24 }
25
26 void RecordPicture(skiagm::GM* gm, SkPicture* picture, uint32_t recordFlags) { 18 void RecordPicture(skiagm::GM* gm, SkPicture* picture, uint32_t recordFlags) {
27 SkCanvas* canvas = picture->beginRecording(SkScalarCeilToInt(gm->width()), 19 const SkISize size = gm->getISize();
28 SkScalarCeilToInt(gm->height()), 20 SkCanvas* canvas = picture->beginRecording(size.width(), size.height(), reco rdFlags);
29 recordFlags);
30 canvas->concat(gm->getInitialTransform()); 21 canvas->concat(gm->getInitialTransform());
31 gm->draw(canvas); 22 gm->draw(canvas);
32 canvas->flush(); 23 canvas->flush();
33 picture->endRecording(); 24 picture->endRecording();
34 } 25 }
35 26
36 void SetupBitmap(const SkBitmap::Config config, skiagm::GM* gm, SkBitmap* bitmap ) { 27 void SetupBitmap(const SkBitmap::Config config, skiagm::GM* gm, SkBitmap* bitmap ) {
37 bitmap->setConfig(config, SkScalarCeilToInt(gm->width()), SkScalarCeilToInt( gm->height())); 28 const SkISize size = gm->getISize();
29 bitmap->setConfig(config, size.width(), size.height());
38 bitmap->allocPixels(); 30 bitmap->allocPixels();
39 bitmap->eraseColor(0x00000000); 31 bitmap->eraseColor(0x00000000);
40 } 32 }
41 33
42 void DrawPicture(SkPicture* picture, SkBitmap* bitmap) { 34 void DrawPicture(SkPicture* picture, SkBitmap* bitmap) {
43 SkASSERT(picture != NULL); 35 SkASSERT(picture != NULL);
44 SkASSERT(bitmap != NULL); 36 SkASSERT(bitmap != NULL);
45 SkCanvas canvas(*bitmap); 37 SkCanvas canvas(*bitmap);
46 canvas.drawPicture(*picture); 38 canvas.drawPicture(*picture);
47 canvas.flush(); 39 canvas.flush();
48 } 40 }
49 41
50 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) { 42 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) {
51 const SkAutoLockPixels lockA(a), lockB(b); 43 const SkAutoLockPixels lockA(a), lockB(b);
52 return a.getSize() == b.getSize() && 0 == memcmp(a.getPixels(), b.getPixels( ), b.getSize()); 44 return a.getSize() == b.getSize() && 0 == memcmp(a.getPixels(), b.getPixels( ), b.getSize());
53 } 45 }
54 46
55 } // namespace DM 47 } // namespace DM
OLDNEW
« dm/DMSerializeTask.cpp ('K') | « dm/DMUtil.h ('k') | gyp/dm.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698