Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 SkAutoTDelete<Src> src(s); | 171 SkAutoTDelete<Src> src(s); |
| 172 if (FLAGS_src.contains(tag) && | 172 if (FLAGS_src.contains(tag) && |
| 173 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { | 173 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { |
| 174 Tagged<Src>& s = gSrcs.push_back(); | 174 Tagged<Src>& s = gSrcs.push_back(); |
| 175 s.reset(src.detach()); | 175 s.reset(src.detach()); |
| 176 s.tag = tag; | 176 s.tag = tag; |
| 177 s.options = options; | 177 s.options = options; |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 static void push_codec_srcs(Path path) { | |
| 182 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | |
| 183 if (!encoded) { | |
| 184 SkDebugf("Couldn't read %s.", path.c_str()); | |
| 185 return; | |
| 186 } | |
| 187 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | |
| 188 if (NULL == codec.get()) { | |
| 189 SkDebugf("Couldn't create codec for %s.", path.c_str()); | |
| 190 return; | |
| 191 } | |
| 192 | |
| 193 // Build additional test cases for images that decode natively to non-canvas types | |
| 194 switch(codec->getInfo().colorType()) { | |
| 195 case kIndex_8_SkColorType: | |
| 196 push_src("image", "codec kIndex8", new CodecSrc(path, CodecSrc::kNorma l_Mode, | |
| 197 CodecSrc::kIndex8_Always_DstColorType)); | |
| 198 push_src("image", "scanline kIndex8", new CodecSrc(path, CodecSrc::kSc anline_Mode, | |
| 199 CodecSrc::kIndex8_Always_DstColorType)); | |
| 200 break; | |
| 201 case kGray_8_SkColorType: | |
|
scroggo
2015/04/08 20:37:37
What do you think about my proposal to swap these,
msarett
2015/04/09 13:02:47
I'm uncertain about the proposal because some jpeg
| |
| 202 push_src("image", "codec kGray8", new CodecSrc(path, CodecSrc::kNormal _Mode, | |
| 203 CodecSrc::kGrayscale_Always_DstColorType)); | |
| 204 push_src("image", "scanline kGray8", new CodecSrc(path, CodecSrc::kSca nline_Mode, | |
| 205 CodecSrc::kGrayscale_Always_DstColorType)); | |
| 206 break; | |
| 207 default: | |
| 208 // Do nothing | |
| 209 break; | |
| 210 } | |
| 211 | |
| 212 // Decode all images to the canvas color type | |
| 213 push_src("image", "codec", new CodecSrc(path, CodecSrc::kNormal_Mode, | |
| 214 CodecSrc::kGetFromCanvas_DstColorType)); | |
| 215 push_src("image", "scanline", new CodecSrc(path, CodecSrc::kScanline_Mode, | |
| 216 CodecSrc::kGetFromCanvas_DstColorType)); | |
| 217 } | |
| 218 | |
| 181 static bool codec_supported(const char* ext) { | 219 static bool codec_supported(const char* ext) { |
| 182 // FIXME: Once other versions of SkCodec are available, we can add them to t his | 220 // FIXME: Once other versions of SkCodec are available, we can add them to t his |
| 183 // list (and eventually we can remove this check once they are all supported ). | 221 // list (and eventually we can remove this check once they are all supported ). |
| 184 static const char* const exts[] = { | 222 static const char* const exts[] = { |
| 185 "bmp", "gif", "png", "ico", "wbmp", | 223 "bmp", "gif", "png", "ico", "wbmp", |
| 186 "BMP", "GIF", "PNG", "ICO", "WBMP" | 224 "BMP", "GIF", "PNG", "ICO", "WBMP" |
| 187 }; | 225 }; |
| 188 | 226 |
| 189 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { | 227 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
| 190 if (0 == strcmp(exts[i], ext)) { | 228 if (0 == strcmp(exts[i], ext)) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 216 for (int i = 0; i < FLAGS_images.count(); i++) { | 254 for (int i = 0; i < FLAGS_images.count(); i++) { |
| 217 const char* flag = FLAGS_images[i]; | 255 const char* flag = FLAGS_images[i]; |
| 218 if (sk_isdir(flag)) { | 256 if (sk_isdir(flag)) { |
| 219 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { | 257 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { |
| 220 SkOSFile::Iter it(flag, exts[j]); | 258 SkOSFile::Iter it(flag, exts[j]); |
| 221 for (SkString file; it.next(&file); ) { | 259 for (SkString file; it.next(&file); ) { |
| 222 SkString path = SkOSPath::Join(flag, file.c_str()); | 260 SkString path = SkOSPath::Join(flag, file.c_str()); |
| 223 push_src("image", "decode", new ImageSrc(path)); // Decode e ntire image | 261 push_src("image", "decode", new ImageSrc(path)); // Decode e ntire image |
| 224 push_src("image", "subset", new ImageSrc(path, 2)); // Decod e into 2x2 subsets | 262 push_src("image", "subset", new ImageSrc(path, 2)); // Decod e into 2x2 subsets |
| 225 if (codec_supported(exts[j])) { | 263 if (codec_supported(exts[j])) { |
| 226 push_src("image", "codec", new CodecSrc(path, CodecSrc:: kNormal_Mode)); | 264 push_codec_srcs(path); |
| 227 push_src("image", "scanline", new CodecSrc(path, CodecSr c::kScanline_Mode)); | |
| 228 } | 265 } |
| 229 } | 266 } |
| 230 } | 267 } |
| 231 } else if (sk_exists(flag)) { | 268 } else if (sk_exists(flag)) { |
| 232 // assume that FLAGS_images[i] is a valid image if it is a file. | 269 // assume that FLAGS_images[i] is a valid image if it is a file. |
| 233 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im age. | 270 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im age. |
| 234 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets | 271 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets |
| 235 push_src("image", "codec", new CodecSrc(flag, CodecSrc::kNormal_Mode )); | 272 push_codec_srcs(flag); |
| 236 push_src("image", "scanline", new CodecSrc(flag, CodecSrc::kScanline _Mode)); | |
| 237 } | 273 } |
| 238 } | 274 } |
| 239 } | 275 } |
| 240 | 276 |
| 241 static GrGLStandard get_gpu_api() { | 277 static GrGLStandard get_gpu_api() { |
| 242 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | 278 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
| 243 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | 279 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
| 244 return kNone_GrGLStandard; | 280 return kNone_GrGLStandard; |
| 245 } | 281 } |
| 246 | 282 |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 705 } | 741 } |
| 706 return 0; | 742 return 0; |
| 707 } | 743 } |
| 708 | 744 |
| 709 #if !defined(SK_BUILD_FOR_IOS) | 745 #if !defined(SK_BUILD_FOR_IOS) |
| 710 int main(int argc, char** argv) { | 746 int main(int argc, char** argv) { |
| 711 SkCommandLineFlags::Parse(argc, argv); | 747 SkCommandLineFlags::Parse(argc, argv); |
| 712 return dm_main(); | 748 return dm_main(); |
| 713 } | 749 } |
| 714 #endif | 750 #endif |
| OLD | NEW |