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

Side by Side Diff: dm/DMUtil.cpp

Issue 168653002: Change device factories to take SkImageInfo instead of SkBitmap::Config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix PdfViewer Created 6 years, 10 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') | experimental/PdfViewer/SkTrackDevice.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 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 void RecordPicture(skiagm::GM* gm, SkPicture* picture, uint32_t recordFlags) { 13 void RecordPicture(skiagm::GM* gm, SkPicture* picture, uint32_t recordFlags) {
14 const SkISize size = gm->getISize(); 14 const SkISize size = gm->getISize();
15 SkCanvas* canvas = picture->beginRecording(size.width(), size.height(), reco rdFlags); 15 SkCanvas* canvas = picture->beginRecording(size.width(), size.height(), reco rdFlags);
16 canvas->concat(gm->getInitialTransform()); 16 canvas->concat(gm->getInitialTransform());
17 gm->draw(canvas); 17 gm->draw(canvas);
18 canvas->flush(); 18 canvas->flush();
19 picture->endRecording(); 19 picture->endRecording();
20 } 20 }
21 21
22 void SetupBitmap(const SkBitmap::Config config, skiagm::GM* gm, SkBitmap* bitmap ) { 22 void SetupBitmap(const SkColorType ct, skiagm::GM* gm, SkBitmap* bitmap) {
23 const SkISize size = gm->getISize(); 23 const SkISize size = gm->getISize();
24 bitmap->setConfig(config, size.width(), size.height()); 24 bitmap->allocPixels(SkImageInfo::Make(size.width(), size.height(),
25 bitmap->allocPixels(); 25 ct, kPremul_SkAlphaType));
26 bitmap->eraseColor(0x00000000); 26 bitmap->eraseColor(0x00000000);
27 } 27 }
28 28
29 void DrawPicture(SkPicture* picture, SkBitmap* bitmap) { 29 void DrawPicture(SkPicture* picture, SkBitmap* bitmap) {
30 SkASSERT(picture != NULL); 30 SkASSERT(picture != NULL);
31 SkASSERT(bitmap != NULL); 31 SkASSERT(bitmap != NULL);
32 SkCanvas canvas(*bitmap); 32 SkCanvas canvas(*bitmap);
33 canvas.drawPicture(*picture); 33 canvas.drawPicture(*picture);
34 canvas.flush(); 34 canvas.flush();
35 } 35 }
36 36
37 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) { 37 bool BitmapsEqual(const SkBitmap& a, const SkBitmap& b) {
38 const SkAutoLockPixels lockA(a), lockB(b); 38 const SkAutoLockPixels lockA(a), lockB(b);
39 return a.getSize() == b.getSize() && 0 == memcmp(a.getPixels(), b.getPixels( ), b.getSize()); 39 return a.getSize() == b.getSize() && 0 == memcmp(a.getPixels(), b.getPixels( ), b.getSize());
40 } 40 }
41 41
42 } // namespace DM 42 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMUtil.h ('k') | experimental/PdfViewer/SkTrackDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698