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" |
| 11 #include "DMSrcSinkAndroid.h" | 11 #include "DMSrcSinkAndroid.h" |
| 12 #include "OverwriteLine.h" | 12 #include "OverwriteLine.h" |
| 13 #include "ProcStats.h" | 13 #include "ProcStats.h" |
| 14 #include "SkBBHFactory.h" | 14 #include "SkBBHFactory.h" |
| 15 #include "SkChecksum.h" | 15 #include "SkChecksum.h" |
| 16 #include "SkCodecPriv.h" | |
| 16 #include "SkCommonFlags.h" | 17 #include "SkCommonFlags.h" |
| 17 #include "SkForceLinking.h" | 18 #include "SkForceLinking.h" |
| 18 #include "SkGraphics.h" | 19 #include "SkGraphics.h" |
| 19 #include "SkInstCnt.h" | 20 #include "SkInstCnt.h" |
| 20 #include "SkMD5.h" | 21 #include "SkMD5.h" |
| 21 #include "SkOSFile.h" | 22 #include "SkOSFile.h" |
| 22 #include "SkTHash.h" | 23 #include "SkTHash.h" |
| 23 #include "SkTaskGroup.h" | 24 #include "SkTaskGroup.h" |
| 24 #include "SkThreadUtils.h" | 25 #include "SkThreadUtils.h" |
| 25 #include "Test.h" | 26 #include "Test.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 SkAutoTDelete<Src> src(s); | 172 SkAutoTDelete<Src> src(s); |
| 172 if (FLAGS_src.contains(tag) && | 173 if (FLAGS_src.contains(tag) && |
| 173 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { | 174 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { |
| 174 Tagged<Src>& s = gSrcs.push_back(); | 175 Tagged<Src>& s = gSrcs.push_back(); |
| 175 s.reset(src.detach()); | 176 s.reset(src.detach()); |
| 176 s.tag = tag; | 177 s.tag = tag; |
| 177 s.options = options; | 178 s.options = options; |
| 178 } | 179 } |
| 179 } | 180 } |
| 180 | 181 |
| 182 static SkCodec* create_codec(Path path) { | |
| 183 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | |
| 184 if (!encoded) { | |
| 185 SkCodecPrintf(return SkStringPrintf("Couldn't read %s.", path.c_str())); | |
|
scroggo
2015/04/08 17:21:27
SkCodecPrintf (which I think is defined in src/cod
msarett
2015/04/08 19:35:40
Yeah that is what I meant.
| |
| 186 return NULL; | |
| 187 } | |
| 188 | |
| 189 return SkCodec::NewFromData(encoded); | |
| 190 } | |
| 191 | |
| 192 static void push_codec_srcs(Path path) { | |
| 193 // Create a codec | |
| 194 SkCodec* codec = create_codec(path); | |
| 195 if (NULL == codec) { | |
| 196 SkCodecPrintf(return SkStringPrintf("Couldn't create codec for %s.", pat h.c_str())); | |
| 197 return; | |
| 198 } | |
| 199 | |
| 200 // Build additional test cases for images that decode natively to non-canvas types | |
| 201 switch(codec->getInfo().colorType()) { | |
| 202 case kIndex_8_SkColorType: | |
| 203 push_src("image", "codec kIndex8", new CodecSrc(path, CodecSrc::kNorma l_Mode, | |
|
scroggo
2015/04/08 17:21:27
We should probably add a src for kScanline_Mode as
msarett
2015/04/08 19:35:40
Done.
| |
| 204 CodecSrc::kIndex8_Always_DstColorType, create_codec(path))); | |
|
msarett
2015/04/08 13:59:10
Can we assume that if create_codec succeeds once,
scroggo
2015/04/08 17:21:27
If it does not, that is a bug (or a disk read erro
msarett
2015/04/08 19:35:40
Acknowledged.
| |
| 205 break; | |
| 206 case kGray_8_SkColorType: | |
| 207 push_src("image", "codec kGray8", new CodecSrc(path, CodecSrc::kNormal _Mode, | |
| 208 CodecSrc::kGrayscale_Always_DstColorType, create_codec(path))) ; | |
| 209 break; | |
| 210 default: | |
| 211 // Do nothing | |
| 212 break; | |
| 213 } | |
| 214 | |
| 215 // Decode all images to the canvas color type | |
| 216 push_src("image", "codec", new CodecSrc(path, CodecSrc::kNormal_Mode, | |
| 217 CodecSrc::kGetFromCanvas_DstColorType, create_codec(path))); | |
| 218 push_src("image", "scanline", new CodecSrc( | |
| 219 path, CodecSrc::kScanline_Mode, CodecSrc::kGetFromCanvas_DstColorTyp e, codec)); | |
| 220 } | |
| 221 | |
| 181 static bool codec_supported(const char* ext) { | 222 static bool codec_supported(const char* ext) { |
| 182 // FIXME: Once other versions of SkCodec are available, we can add them to t his | 223 // 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 ). | 224 // list (and eventually we can remove this check once they are all supported ). |
| 184 static const char* const exts[] = { | 225 static const char* const exts[] = { |
| 185 "bmp", "gif", "png", "ico", "wbmp", | 226 "bmp", "gif", "png", "ico", "wbmp", |
| 186 "BMP", "GIF", "PNG", "ICO", "WBMP" | 227 "BMP", "GIF", "PNG", "ICO", "WBMP" |
| 187 }; | 228 }; |
| 188 | 229 |
| 189 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { | 230 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
| 190 if (0 == strcmp(exts[i], ext)) { | 231 if (0 == strcmp(exts[i], ext)) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 216 for (int i = 0; i < FLAGS_images.count(); i++) { | 257 for (int i = 0; i < FLAGS_images.count(); i++) { |
| 217 const char* flag = FLAGS_images[i]; | 258 const char* flag = FLAGS_images[i]; |
| 218 if (sk_isdir(flag)) { | 259 if (sk_isdir(flag)) { |
| 219 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { | 260 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { |
| 220 SkOSFile::Iter it(flag, exts[j]); | 261 SkOSFile::Iter it(flag, exts[j]); |
| 221 for (SkString file; it.next(&file); ) { | 262 for (SkString file; it.next(&file); ) { |
| 222 SkString path = SkOSPath::Join(flag, file.c_str()); | 263 SkString path = SkOSPath::Join(flag, file.c_str()); |
| 223 push_src("image", "decode", new ImageSrc(path)); // Decode e ntire image | 264 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 | 265 push_src("image", "subset", new ImageSrc(path, 2)); // Decod e into 2x2 subsets |
| 225 if (codec_supported(exts[j])) { | 266 if (codec_supported(exts[j])) { |
| 226 push_src("image", "codec", new CodecSrc(path, CodecSrc:: kNormal_Mode)); | 267 push_codec_srcs(path); |
| 227 push_src("image", "scanline", new CodecSrc(path, CodecSr c::kScanline_Mode)); | |
| 228 } | 268 } |
| 229 } | 269 } |
| 230 } | 270 } |
| 231 } else if (sk_exists(flag)) { | 271 } else if (sk_exists(flag)) { |
| 232 // assume that FLAGS_images[i] is a valid image if it is a file. | 272 // 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. | 273 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 | 274 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 )); | 275 push_codec_srcs(flag); |
| 236 push_src("image", "scanline", new CodecSrc(flag, CodecSrc::kScanline _Mode)); | |
| 237 } | 276 } |
| 238 } | 277 } |
| 239 } | 278 } |
| 240 | 279 |
| 241 static GrGLStandard get_gpu_api() { | 280 static GrGLStandard get_gpu_api() { |
| 242 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | 281 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
| 243 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | 282 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
| 244 return kNone_GrGLStandard; | 283 return kNone_GrGLStandard; |
| 245 } | 284 } |
| 246 | 285 |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 699 } | 738 } |
| 700 return 0; | 739 return 0; |
| 701 } | 740 } |
| 702 | 741 |
| 703 #if !defined(SK_BUILD_FOR_IOS) | 742 #if !defined(SK_BUILD_FOR_IOS) |
| 704 int main(int argc, char** argv) { | 743 int main(int argc, char** argv) { |
| 705 SkCommandLineFlags::Parse(argc, argv); | 744 SkCommandLineFlags::Parse(argc, argv); |
| 706 return dm_main(); | 745 return dm_main(); |
| 707 } | 746 } |
| 708 #endif | 747 #endif |
| OLD | NEW |