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

Side by Side Diff: dm/DM.cpp

Issue 1059513002: Update DM to allow Src's to have optional options. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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 | « no previous file | dm/DMJsonWriter.h » ('j') | dm/DMJsonWriter.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "CrashHandler.h" 8 #include "CrashHandler.h"
9 #include "DMJsonWriter.h" 9 #include "DMJsonWriter.h"
10 #include "DMSrcSink.h" 10 #include "DMSrcSink.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 path.append("/dm.json"); 126 path.append("/dm.json");
127 if (!JsonWriter::ReadJson(path.c_str(), add_gold)) { 127 if (!JsonWriter::ReadJson(path.c_str(), add_gold)) {
128 fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_s tr())); 128 fail(SkStringPrintf("Couldn't read %s for golden results.", path.c_s tr()));
129 } 129 }
130 } 130 }
131 } 131 }
132 132
133 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 133 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
134 134
135 template <typename T> 135 template <typename T>
136 struct Tagged : public SkAutoTDelete<T> { const char* tag; }; 136 struct Tagged : public SkAutoTDelete<T> {
137 const char* tag;
138 const char* options;
djsollen 2015/04/02 17:25:07 I'm thinking of storing an SkString on this struct
mtklein 2015/04/02 17:48:08 Let's leave them apart for now, given that we're n
139 };
137 140
138 static const bool kMemcpyOK = true; 141 static const bool kMemcpyOK = true;
139 142
140 static SkTArray<Tagged<Src>, kMemcpyOK> gSrcs; 143 static SkTArray<Tagged<Src>, kMemcpyOK> gSrcs;
141 static SkTArray<Tagged<Sink>, kMemcpyOK> gSinks; 144 static SkTArray<Tagged<Sink>, kMemcpyOK> gSinks;
142 145
143 static void push_src(const char* tag, Src* s) { 146 static void push_src(const char* tag, Src* s, const char* options = nullptr) {
mtklein 2015/04/02 17:48:09 Let's pass this as the second argument and explici
144 SkAutoTDelete<Src> src(s); 147 SkAutoTDelete<Src> src(s);
145 if (FLAGS_src.contains(tag) && 148 if (FLAGS_src.contains(tag) &&
146 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { 149 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) {
147 Tagged<Src>& s = gSrcs.push_back(); 150 Tagged<Src>& s = gSrcs.push_back();
148 s.reset(src.detach()); 151 s.reset(src.detach());
149 s.tag = tag; 152 s.tag = tag;
153 s.options = options;
150 } 154 }
151 } 155 }
152 156
153 static bool codec_supported(const char* ext) { 157 static bool codec_supported(const char* ext) {
154 // FIXME: Once other versions of SkCodec are available, we can add them to t his 158 // FIXME: Once other versions of SkCodec are available, we can add them to t his
155 // list (and eventually we can remove this check once they are all supported ). 159 // list (and eventually we can remove this check once they are all supported ).
156 static const char* const exts[] = { 160 static const char* const exts[] = {
157 "bmp", "gif", "png", "ico", "wbmp", 161 "bmp", "gif", "png", "ico", "wbmp",
158 "BMP", "GIF", "PNG", "ICO", "WBMP" 162 "BMP", "GIF", "PNG", "ICO", "WBMP"
159 }; 163 };
(...skipping 25 matching lines...) Expand all
185 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico" , 189 "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico" ,
186 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO" , 190 "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO" ,
187 }; 191 };
188 for (int i = 0; i < FLAGS_images.count(); i++) { 192 for (int i = 0; i < FLAGS_images.count(); i++) {
189 const char* flag = FLAGS_images[i]; 193 const char* flag = FLAGS_images[i];
190 if (sk_isdir(flag)) { 194 if (sk_isdir(flag)) {
191 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { 195 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) {
192 SkOSFile::Iter it(flag, exts[j]); 196 SkOSFile::Iter it(flag, exts[j]);
193 for (SkString file; it.next(&file); ) { 197 for (SkString file; it.next(&file); ) {
194 SkString path = SkOSPath::Join(flag, file.c_str()); 198 SkString path = SkOSPath::Join(flag, file.c_str());
195 push_src("image", new ImageSrc(path)); // Decode entire image. 199 push_src("image", new ImageSrc(path), "image"); // Decod e entire image
mtklein 2015/04/02 17:48:08 Might want this "image" to be "default" so we don'
196 push_src("subset", new ImageSrc(path, 2)); // Decode into 2 x 2 subsets 200 push_src("image", new ImageSrc(path, 2), "subset"); // Decod e into 2x2 subsets
197 if (codec_supported(exts[j])) { 201 if (codec_supported(exts[j])) {
198 push_src("codec", new CodecSrc(path, CodecSrc::kNormal_M ode)); 202 push_src("image", new CodecSrc(path, CodecSrc::kNormal_M ode), "codec");
199 push_src("scanline", new CodecSrc(path, CodecSrc::kScanl ine_Mode)); 203 push_src("image", new CodecSrc(path, CodecSrc::kScanline _Mode), "scanline");
200 } 204 }
201 } 205 }
202 } 206 }
203 } else if (sk_exists(flag)) { 207 } else if (sk_exists(flag)) {
204 // assume that FLAGS_images[i] is a valid image if it is a file. 208 // assume that FLAGS_images[i] is a valid image if it is a file.
205 push_src("image", new ImageSrc(flag)); // Decode entire image. 209 push_src("image", new ImageSrc(flag), "image"); // Decode entire image.
206 push_src("subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subs ets 210 push_src("image", new ImageSrc(flag, 2), "subset"); // Decode into 2 x 2 subsets
207 push_src("codec", new CodecSrc(flag, CodecSrc::kNormal_Mode)); 211 push_src("image", new CodecSrc(flag, CodecSrc::kNormal_Mode), "codec ");
208 push_src("scanline", new CodecSrc(flag, CodecSrc::kScanline_Mode)); 212 push_src("image", new CodecSrc(flag, CodecSrc::kScanline_Mode), "sca nline");
209 } 213 }
210 } 214 }
211 } 215 }
212 216
213 static GrGLStandard get_gpu_api() { 217 static GrGLStandard get_gpu_api() {
214 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } 218 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; }
215 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } 219 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; }
216 return kNone_GrGLStandard; 220 return kNone_GrGLStandard;
217 } 221 }
218 222
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 timer.end(); 435 timer.end();
432 done(timer.fWall, task->sink.tag, task->src.tag, name, note, log); 436 done(timer.fWall, task->sink.tag, task->src.tag, name, note, log);
433 } 437 }
434 438
435 static void WriteToDisk(const Task& task, 439 static void WriteToDisk(const Task& task,
436 SkString md5, 440 SkString md5,
437 const char* ext, 441 const char* ext,
438 SkStream* data, size_t len, 442 SkStream* data, size_t len,
439 const SkBitmap* bitmap) { 443 const SkBitmap* bitmap) {
440 JsonWriter::BitmapResult result; 444 JsonWriter::BitmapResult result;
441 result.name = task.src->name(); 445 result.name = task.src->name();
442 result.config = task.sink.tag; 446 result.config = task.sink.tag;
443 result.sourceType = task.src.tag; 447 result.sourceType = task.src.tag;
444 result.ext = ext; 448 result.sourceOptions = task.src.options;
445 result.md5 = md5; 449 result.ext = ext;
450 result.md5 = md5;
446 JsonWriter::AddBitmapResult(result); 451 JsonWriter::AddBitmapResult(result);
447 452
448 const char* dir = FLAGS_writePath[0]; 453 const char* dir = FLAGS_writePath[0];
449 if (0 == strcmp(dir, "@")) { // Needed for iOS. 454 if (0 == strcmp(dir, "@")) { // Needed for iOS.
450 dir = FLAGS_resourcePath[0]; 455 dir = FLAGS_resourcePath[0];
451 } 456 }
452 sk_mkdir(dir); 457 sk_mkdir(dir);
453 458
454 SkString path; 459 SkString path;
455 if (FLAGS_nameByHash) { 460 if (FLAGS_nameByHash) {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 } 661 }
657 return 0; 662 return 0;
658 } 663 }
659 664
660 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 665 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
661 int main(int argc, char** argv) { 666 int main(int argc, char** argv) {
662 SkCommandLineFlags::Parse(argc, argv); 667 SkCommandLineFlags::Parse(argc, argv);
663 return dm_main(); 668 return dm_main();
664 } 669 }
665 #endif 670 #endif
OLDNEW
« no previous file with comments | « no previous file | dm/DMJsonWriter.h » ('j') | dm/DMJsonWriter.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698