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

Side by Side Diff: dm/DMUtil.cpp

Issue 270543004: DM: Add --skps. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: reed Created 6 years, 7 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
« no previous file with comments | « dm/DMUtil.h ('k') | dm/DMWriteTask.h » ('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" 3 #include "SkPicture.h"
4 #include "SkPictureRecorder.h" 4 #include "SkPictureRecorder.h"
5 5
6 namespace DM { 6 namespace DM {
7 7
8 SkString UnderJoin(const char* a, const char* b) { 8 SkString UnderJoin(const char* a, const char* b) {
9 SkString s; 9 SkString s;
10 s.appendf("%s_%s", a, b); 10 s.appendf("%s_%s", a, b);
11 return s; 11 return s;
12 } 12 }
13 13
14 SkPicture* RecordPicture(skiagm::GM* gm, uint32_t recordFlags, SkBBHFactory* fac tory) { 14 SkPicture* RecordPicture(skiagm::GM* gm, uint32_t recordFlags, SkBBHFactory* fac tory) {
15 const SkISize size = gm->getISize(); 15 const SkISize size = gm->getISize();
16 SkPictureRecorder recorder; 16 SkPictureRecorder recorder;
17 SkCanvas* canvas = recorder.beginRecording(size.width(), size.height(), fact ory, recordFlags); 17 SkCanvas* canvas = recorder.beginRecording(size.width(), size.height(), fact ory, recordFlags);
18 canvas->concat(gm->getInitialTransform()); 18 canvas->concat(gm->getInitialTransform());
19 gm->draw(canvas); 19 gm->draw(canvas);
20 canvas->flush(); 20 canvas->flush();
21 return recorder.endRecording(); 21 return recorder.endRecording();
22 } 22 }
23 23
24 static void setup_bitmap(SkColorType ct, int width, int height, SkBitmap* bitmap ) { 24 static void setup_bitmap(SkColorType ct, int width, int height, SkBitmap* bitmap ) {
25 bitmap->allocPixels(SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType )); 25 bitmap->allocPixels(SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType ));
26 bitmap->eraseColor(0x00000000); 26 bitmap->eraseColor(0x00000000);
27 } 27 }
28 28
29 void SetupBitmap(const SkColorType ct, skiagm::GM* gm, SkBitmap* bitmap) { 29 void SetupBitmap(SkColorType ct, skiagm::GM* gm, SkBitmap* bitmap) {
30 setup_bitmap(ct, gm->getISize().width(), gm->getISize().height(), bitmap); 30 setup_bitmap(ct, gm->getISize().width(), gm->getISize().height(), bitmap);
31 } 31 }
32 32
33 void SetupBitmap(const SkColorType ct, SkBenchmark* bench, SkBitmap* bitmap) { 33 void SetupBitmap(SkColorType ct, SkBenchmark* bench, SkBitmap* bitmap) {
34 setup_bitmap(ct, bench->getSize().x(), bench->getSize().y(), bitmap); 34 setup_bitmap(ct, bench->getSize().x(), bench->getSize().y(), bitmap);
35 } 35 }
36 36
37 void SetupBitmap(SkColorType ct, const SkPicture& pic, SkBitmap* bitmap) {
38 setup_bitmap(ct, pic.width(), pic.height(), bitmap);
39 }
40
37 void DrawPicture(SkPicture* picture, SkBitmap* bitmap) { 41 void DrawPicture(SkPicture* picture, SkBitmap* bitmap) {
38 SkASSERT(picture != NULL); 42 SkASSERT(picture != NULL);
39 SkASSERT(bitmap != NULL); 43 SkASSERT(bitmap != NULL);
40 SkCanvas canvas(*bitmap); 44 SkCanvas canvas(*bitmap);
41 canvas.drawPicture(*picture); 45 canvas.drawPicture(*picture);
42 canvas.flush(); 46 canvas.flush();
43 } 47 }
44 48
45 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) { 49 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) {
46 const SkAutoLockPixels lockA(a), lockB(b); 50 const SkAutoLockPixels lockA(a), lockB(b);
47 return a.getSize() == b.getSize() && 0 == memcmp(a.getPixels(), b.getPixels( ), b.getSize()); 51 return a.getSize() == b.getSize() && 0 == memcmp(a.getPixels(), b.getPixels( ), b.getSize());
48 } 52 }
49 53
50 } // namespace DM 54 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMUtil.h ('k') | dm/DMWriteTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698