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

Side by Side Diff: dm/DMWriteTask.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.cpp ('k') | dm/README » ('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 "DMWriteTask.h" 1 #include "DMWriteTask.h"
2 2
3 #include "DMUtil.h" 3 #include "DMUtil.h"
4 #include "SkCommandLineFlags.h" 4 #include "SkCommandLineFlags.h"
5 #include "SkImageEncoder.h" 5 #include "SkImageEncoder.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 DEFINE_string2(writePath, w, "", "If set, write GMs here as .pngs."); 9 DEFINE_string2(writePath, w, "", "If set, write GMs here as .pngs.");
10 10
11 namespace DM { 11 namespace DM {
12 12
13 WriteTask::WriteTask(const Task& parent, SkBitmap bitmap) 13 WriteTask::WriteTask(const Task& parent, SkBitmap bitmap)
14 : Task(parent) 14 : Task(parent)
15 , fBitmap(bitmap) { 15 , fBitmap(bitmap) {
16 // Split parent's name <gmName>_<config> into gmName and config. 16 // Split parent's name <gmName>_<config> into gmName and config.
17 const char* parentName = parent.name().c_str(); 17 const char* parentName = parent.name().c_str();
18 const char* fromLastUnderscore = strrchr(parentName, '_'); 18 const char* fromLastUnderscore = strrchr(parentName, '_');
19 const ptrdiff_t gmNameLength = fromLastUnderscore - parentName; 19 const ptrdiff_t gmNameLength = fromLastUnderscore - parentName;
20 20
21 fConfig.set(fromLastUnderscore+1); 21 fConfig.set(fromLastUnderscore+1);
22 fGmName.set(parentName, gmNameLength); 22 fGmName.set(parentName, gmNameLength);
23 } 23 }
24 24
25 void WriteTask::draw() { 25 void WriteTask::draw() {
26 const char* root = FLAGS_writePath[0]; 26 const char* root = FLAGS_writePath[0];
27 const SkString dir = SkOSPath::SkPathJoin(root, fConfig.c_str()); 27 const SkString dir = SkOSPath::SkPathJoin(root, fConfig.c_str());
28 if (!sk_mkdir(root) || 28 if (!sk_mkdir(root) ||
29 !sk_mkdir(dir.c_str()) || 29 !sk_mkdir(dir.c_str()) ||
30 !SkImageEncoder::EncodeFile(png(SkOSPath::SkPathJoin(dir.c_str(), fGmNam e.c_str())).c_str(), 30 !SkImageEncoder::EncodeFile(Png(SkOSPath::SkPathJoin(dir.c_str(), fGmNam e.c_str())).c_str(),
31 fBitmap, 31 fBitmap,
32 SkImageEncoder::kPNG_Type, 32 SkImageEncoder::kPNG_Type,
33 100/*quality*/)) 33 100/*quality*/))
34 { 34 {
35 this->fail(); 35 this->fail();
36 } 36 }
37 } 37 }
38 38
39 SkString WriteTask::name() const { 39 SkString WriteTask::name() const {
40 return SkStringPrintf("writing %s/%s.png", fConfig.c_str(), fGmName.c_str()) ; 40 return SkStringPrintf("writing %s/%s.png", fConfig.c_str(), fGmName.c_str()) ;
41 } 41 }
42 42
43 bool WriteTask::shouldSkip() const { 43 bool WriteTask::shouldSkip() const {
44 return FLAGS_writePath.isEmpty(); 44 return FLAGS_writePath.isEmpty();
45 } 45 }
46 46
47 } // namespace DM 47 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMUtil.cpp ('k') | dm/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698