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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 switch (mode) { | 232 switch (mode) { |
| 233 case CodecSrc::kCodec_Mode: | 233 case CodecSrc::kCodec_Mode: |
| 234 folder.append("codec"); | 234 folder.append("codec"); |
| 235 break; | 235 break; |
| 236 case CodecSrc::kCodecZeroInit_Mode: | 236 case CodecSrc::kCodecZeroInit_Mode: |
| 237 folder.append("codec_zero_init"); | 237 folder.append("codec_zero_init"); |
| 238 break; | 238 break; |
| 239 case CodecSrc::kScanline_Mode: | 239 case CodecSrc::kScanline_Mode: |
| 240 folder.append("scanline"); | 240 folder.append("scanline"); |
| 241 break; | 241 break; |
| 242 case CodecSrc::kStripe_Mode: | 242 case CodecSrc::kTile_Mode: |
| 243 folder.append("stripe"); | 243 folder.append("tile"); |
| 244 break; | 244 break; |
| 245 case CodecSrc::kSubset_Mode: | 245 case CodecSrc::kSubset_Mode: |
| 246 folder.append("codec_subset"); | 246 folder.append("codec_subset"); |
| 247 break; | 247 break; |
| 248 case CodecSrc::kGen_Mode: | 248 case CodecSrc::kGen_Mode: |
| 249 folder.append("gen"); | 249 folder.append("gen"); |
| 250 break; | 250 break; |
| 251 } | 251 } |
| 252 | 252 |
| 253 switch (dstColorType) { | 253 switch (dstColorType) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 SkDebugf("Couldn't create codec for %s.", path.c_str()); | 339 SkDebugf("Couldn't create codec for %s.", path.c_str()); |
| 340 return; | 340 return; |
| 341 } | 341 } |
| 342 | 342 |
| 343 // Native Scales | 343 // Native Scales |
| 344 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co mpare with these | 344 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co mpare with these |
| 345 // tests. SkImageDecoder supports downscales by integer fac tors. | 345 // tests. SkImageDecoder supports downscales by integer fac tors. |
| 346 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 | 346 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 |
| 347 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f }; | 347 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f }; |
| 348 | 348 |
| 349 const CodecSrc::Mode nativeModes[] = { CodecSrc::kCodec_Mode, CodecSrc::kCod ecZeroInit_Mode, | 349 CodecSrc::Mode nativeModes[5]; |
|
scroggo
2016/02/22 15:55:03
nit: As long as you're rewriting this code, why no
msarett
2016/02/22 17:38:15
Agreed that's better. I'll fix the color types as
| |
| 350 CodecSrc::kScanline_Mode, CodecSrc::kStripe_Mode, CodecSrc::kSubset_ Mode, | 350 nativeModes[0] = CodecSrc::kCodec_Mode; |
| 351 CodecSrc::kGen_Mode }; | 351 nativeModes[1] = CodecSrc::kCodecZeroInit_Mode; |
| 352 nativeModes[2] = CodecSrc::kGen_Mode; | |
| 353 uint32_t numNativeModes; | |
| 354 switch (codec->getEncodedFormat()) { | |
| 355 case SkEncodedFormat::kJPEG_SkEncodedFormat: | |
| 356 nativeModes[3] = CodecSrc::kScanline_Mode; | |
| 357 nativeModes[4] = CodecSrc::kTile_Mode; | |
| 358 numNativeModes = 5; | |
| 359 break; | |
| 360 case SkEncodedFormat::kWEBP_SkEncodedFormat: | |
| 361 nativeModes[3] = CodecSrc::kSubset_Mode; | |
| 362 numNativeModes = 4; | |
| 363 break; | |
| 364 default: | |
| 365 nativeModes[3] = CodecSrc::kScanline_Mode; | |
| 366 numNativeModes = 4; | |
| 367 break; | |
| 368 } | |
| 352 | 369 |
| 353 CodecSrc::DstColorType colorTypes[3]; | 370 CodecSrc::DstColorType colorTypes[3]; |
| 354 uint32_t numColorTypes; | 371 uint32_t numColorTypes; |
| 355 switch (codec->getInfo().colorType()) { | 372 switch (codec->getInfo().colorType()) { |
| 356 case kGray_8_SkColorType: | 373 case kGray_8_SkColorType: |
| 357 colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType; | 374 colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType; |
| 358 colorTypes[1] = CodecSrc::kGrayscale_Always_DstColorType; | 375 colorTypes[1] = CodecSrc::kGrayscale_Always_DstColorType; |
| 359 if (kWBMP_SkEncodedFormat == codec->getEncodedFormat()) { | 376 if (kWBMP_SkEncodedFormat == codec->getEncodedFormat()) { |
| 360 colorTypes[2] = CodecSrc::kIndex8_Always_DstColorType; | 377 colorTypes[2] = CodecSrc::kIndex8_Always_DstColorType; |
| 361 numColorTypes = 3; | 378 numColorTypes = 3; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 374 break; | 391 break; |
| 375 } | 392 } |
| 376 | 393 |
| 377 SkTArray<SkAlphaType> alphaModes; | 394 SkTArray<SkAlphaType> alphaModes; |
| 378 alphaModes.push_back(kPremul_SkAlphaType); | 395 alphaModes.push_back(kPremul_SkAlphaType); |
| 379 alphaModes.push_back(kUnpremul_SkAlphaType); | 396 alphaModes.push_back(kUnpremul_SkAlphaType); |
| 380 if (codec->getInfo().alphaType() == kOpaque_SkAlphaType) { | 397 if (codec->getInfo().alphaType() == kOpaque_SkAlphaType) { |
| 381 alphaModes.push_back(kOpaque_SkAlphaType); | 398 alphaModes.push_back(kOpaque_SkAlphaType); |
| 382 } | 399 } |
| 383 | 400 |
| 384 for (CodecSrc::Mode mode : nativeModes) { | 401 for (uint32_t j = 0; j < numNativeModes; j++) { |
| 385 // SkCodecImageGenerator only runs for the default colorType | 402 // SkCodecImageGenerator only runs for the default colorType |
| 386 // recommended by SkCodec. There is no need to generate multiple | 403 // recommended by SkCodec. There is no need to generate multiple |
| 387 // tests for different colorTypes. | 404 // tests for different colorTypes. |
| 388 // TODO (msarett): Add scaling support to SkCodecImageGenerator. | 405 // TODO (msarett): Add scaling support to SkCodecImageGenerator. |
| 389 if (CodecSrc::kGen_Mode == mode) { | 406 if (CodecSrc::kGen_Mode == nativeModes[j]) { |
| 390 // FIXME: The gpu backend does not draw kGray sources correctly. (sk bug.com/4822) | 407 // FIXME: The gpu backend does not draw kGray sources correctly. (sk bug.com/4822) |
| 391 if (kGray_8_SkColorType != codec->getInfo().colorType()) { | 408 if (kGray_8_SkColorType != codec->getInfo().colorType()) { |
| 392 push_codec_src(path, mode, CodecSrc::kGetFromCanvas_DstColorType , | 409 push_codec_src(path, CodecSrc::kGen_Mode, CodecSrc::kGetFromCanv as_DstColorType, |
| 393 codec->getInfo().alphaType(), 1.0f); | 410 codec->getInfo().alphaType(), 1.0f); |
| 394 } | 411 } |
| 395 continue; | 412 continue; |
| 396 } | 413 } |
| 397 | 414 |
| 398 for (float scale : nativeScales) { | 415 for (float scale : nativeScales) { |
| 399 for (uint32_t i = 0; i < numColorTypes; i++) { | 416 for (uint32_t i = 0; i < numColorTypes; i++) { |
| 400 for (SkAlphaType alphaType : alphaModes) { | 417 for (SkAlphaType alphaType : alphaModes) { |
| 401 push_codec_src(path, mode, colorTypes[i], alphaType, scale); | 418 push_codec_src(path, nativeModes[j], colorTypes[i], alphaTyp e, scale); |
| 402 } | 419 } |
| 403 } | 420 } |
| 404 } | 421 } |
| 405 } | 422 } |
| 406 | 423 |
| 407 // https://bug.skia.org/4428 | 424 // https://bug.skia.org/4428 |
| 408 bool subset = false; | 425 bool subset = false; |
| 409 // The following image types are supported by BitmapRegionDecoder, | 426 // The following image types are supported by BitmapRegionDecoder, |
| 410 // so we will test full image decodes and subset decodes. | 427 // so we will test full image decodes and subset decodes. |
| 411 static const char* const exts[] = { | 428 static const char* const exts[] = { |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1274 Reporter* reporter, | 1291 Reporter* reporter, |
| 1275 GrContextFactory* fac tory); | 1292 GrContextFactory* fac tory); |
| 1276 } // namespace skiatest | 1293 } // namespace skiatest |
| 1277 | 1294 |
| 1278 #if !defined(SK_BUILD_FOR_IOS) | 1295 #if !defined(SK_BUILD_FOR_IOS) |
| 1279 int main(int argc, char** argv) { | 1296 int main(int argc, char** argv) { |
| 1280 SkCommandLineFlags::Parse(argc, argv); | 1297 SkCommandLineFlags::Parse(argc, argv); |
| 1281 return dm_main(); | 1298 return dm_main(); |
| 1282 } | 1299 } |
| 1283 #endif | 1300 #endif |
| OLD | NEW |