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

Side by Side Diff: dm/DMUtil.cpp

Issue 32613003: DM: add --serialize (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: no-find-copies Created 7 years, 2 months 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
« no previous file with comments | « dm/DMUtil.h ('k') | dm/DMWriteTask.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
OLDNEW
« no previous file with comments | « dm/DMUtil.h ('k') | dm/DMWriteTask.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698