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

Side by Side Diff: dm/DM.cpp

Issue 1999103002: Stop creating CodecSrcs with unused scale (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix line length Created 4 years, 7 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 | no next file » | no next file with comments »
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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (!encoded) { 474 if (!encoded) {
475 info("Couldn't read %s.", path.c_str()); 475 info("Couldn't read %s.", path.c_str());
476 return; 476 return;
477 } 477 }
478 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); 478 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
479 if (nullptr == codec.get()) { 479 if (nullptr == codec.get()) {
480 info("Couldn't create codec for %s.", path.c_str()); 480 info("Couldn't create codec for %s.", path.c_str());
481 return; 481 return;
482 } 482 }
483 483
484 // Native Scales 484 // native scaling is only supported by WEBP and JPEG
485 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 485 bool supportsNativeScaling = false;
486 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f, 0.875f, 1.0f };
487 486
488 SkTArray<CodecSrc::Mode> nativeModes; 487 SkTArray<CodecSrc::Mode> nativeModes;
489 nativeModes.push_back(CodecSrc::kCodec_Mode); 488 nativeModes.push_back(CodecSrc::kCodec_Mode);
490 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode); 489 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode);
491 switch (codec->getEncodedFormat()) { 490 switch (codec->getEncodedFormat()) {
492 case SkEncodedFormat::kJPEG_SkEncodedFormat: 491 case SkEncodedFormat::kJPEG_SkEncodedFormat:
493 nativeModes.push_back(CodecSrc::kScanline_Mode); 492 nativeModes.push_back(CodecSrc::kScanline_Mode);
494 nativeModes.push_back(CodecSrc::kStripe_Mode); 493 nativeModes.push_back(CodecSrc::kStripe_Mode);
495 nativeModes.push_back(CodecSrc::kCroppedScanline_Mode); 494 nativeModes.push_back(CodecSrc::kCroppedScanline_Mode);
495 supportsNativeScaling = true;
496 break; 496 break;
497 case SkEncodedFormat::kWEBP_SkEncodedFormat: 497 case SkEncodedFormat::kWEBP_SkEncodedFormat:
498 nativeModes.push_back(CodecSrc::kSubset_Mode); 498 nativeModes.push_back(CodecSrc::kSubset_Mode);
499 supportsNativeScaling = true;
499 break; 500 break;
500 case SkEncodedFormat::kDNG_SkEncodedFormat: 501 case SkEncodedFormat::kDNG_SkEncodedFormat:
501 break; 502 break;
502 default: 503 default:
503 nativeModes.push_back(CodecSrc::kScanline_Mode); 504 nativeModes.push_back(CodecSrc::kScanline_Mode);
504 break; 505 break;
505 } 506 }
506 507
507 SkTArray<CodecSrc::DstColorType> colorTypes; 508 SkTArray<CodecSrc::DstColorType> colorTypes;
508 colorTypes.push_back(CodecSrc::kGetFromCanvas_DstColorType); 509 colorTypes.push_back(CodecSrc::kGetFromCanvas_DstColorType);
(...skipping 13 matching lines...) Expand all
522 } 523 }
523 524
524 SkTArray<SkAlphaType> alphaModes; 525 SkTArray<SkAlphaType> alphaModes;
525 alphaModes.push_back(kPremul_SkAlphaType); 526 alphaModes.push_back(kPremul_SkAlphaType);
526 alphaModes.push_back(kUnpremul_SkAlphaType); 527 alphaModes.push_back(kUnpremul_SkAlphaType);
527 if (codec->getInfo().alphaType() == kOpaque_SkAlphaType) { 528 if (codec->getInfo().alphaType() == kOpaque_SkAlphaType) {
528 alphaModes.push_back(kOpaque_SkAlphaType); 529 alphaModes.push_back(kOpaque_SkAlphaType);
529 } 530 }
530 531
531 for (CodecSrc::Mode mode : nativeModes) { 532 for (CodecSrc::Mode mode : nativeModes) {
532 for (float scale : nativeScales) { 533 for (CodecSrc::DstColorType colorType : colorTypes) {
533 for (CodecSrc::DstColorType colorType : colorTypes) { 534 for (SkAlphaType alphaType : alphaModes) {
534 for (SkAlphaType alphaType : alphaModes) { 535 // Only test kCroppedScanline_Mode when the alpha type is opaque . The test is
535 // Only test kCroppedScanline_Mode when the alpha type is op aque. The test is 536 // slow and won't be interestingly different with different alph a types.
536 // slow and won't be interestingly different with different alpha types. 537 if (CodecSrc::kCroppedScanline_Mode == mode &&
537 if (CodecSrc::kCroppedScanline_Mode == mode && 538 kOpaque_SkAlphaType != alphaType) {
538 kOpaque_SkAlphaType != alphaType) { 539 continue;
539 continue; 540 }
541
542 push_codec_src(path, mode, colorType, alphaType, 1.0f);
543
544 // Skip kNonNative on different native scales. It won't be inte restingly
545 // different.
546 if (supportsNativeScaling &&
547 CodecSrc::kNonNative8888_Always_DstColorType == colorTyp e) {
548 // Native Scales
549 // SkJpegCodec natively supports scaling to the following:
550 for (auto scale : { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.7 50f, 0.875f }) {
551 push_codec_src(path, mode, colorType, alphaType, scale);
540 } 552 }
541
542 // Skip kNonNative on different native scales. It won't be interestingly
543 // different.
544 if (CodecSrc::kNonNative8888_Always_DstColorType == colorTyp e && 1.0f != scale)
545 {
546 continue;
547 }
548
549 push_codec_src(path, mode, colorType, alphaType, scale);
550 } 553 }
551 } 554 }
552 } 555 }
553 } 556 }
554 557
555 if (FLAGS_simpleCodec) { 558 if (FLAGS_simpleCodec) {
556 return; 559 return;
557 } 560 }
558 561
559 const int sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; 562 const int sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 #endif 1380 #endif
1378 } 1381 }
1379 } // namespace skiatest 1382 } // namespace skiatest
1380 1383
1381 #if !defined(SK_BUILD_FOR_IOS) 1384 #if !defined(SK_BUILD_FOR_IOS)
1382 int main(int argc, char** argv) { 1385 int main(int argc, char** argv) {
1383 SkCommandLineFlags::Parse(argc, argv); 1386 SkCommandLineFlags::Parse(argc, argv);
1384 return dm_main(); 1387 return dm_main();
1385 } 1388 }
1386 #endif 1389 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698