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

Unified Diff: bench/nanobench.cpp

Issue 1568913002: Make CodecBench test kPremul and kUnpremul (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Silent for opaque images Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« bench/CodecBench.cpp ('K') | « bench/CodecBenchPriv.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/nanobench.cpp
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 5a83860713b05deca1507221918045efaaf9a4d3..b791ab7db7e22c0e4ae6a27b1a71159d7a2ddcdc 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -564,6 +564,7 @@ public:
, fCurrentImage(0)
, fCurrentBRDImage(0)
, fCurrentColorType(0)
+ , fCurrentAlphaType(0)
, fCurrentSubsetType(0)
, fCurrentBRDStrategy(0)
, fCurrentBRDSampleSize(0)
@@ -752,19 +753,35 @@ public:
while (fCurrentColorType < fColorTypes.count()) {
const SkColorType colorType = fColorTypes[fCurrentColorType];
- fCurrentColorType++;
- // Make sure we can decode to this color type.
- SkImageInfo info = codec->getInfo().makeColorType(colorType);
- SkAlphaType alphaType;
- if (!SkColorTypeValidateAlphaType(colorType, info.alphaType(),
- &alphaType)) {
- continue;
- }
- if (alphaType != info.alphaType()) {
- info = info.makeAlphaType(alphaType);
+ SkAlphaType alphaType = codec->getInfo().alphaType();
+ switch (alphaType) {
+ case kOpaque_SkAlphaType:
+ // We only need to test one alpha type (opaque).
+ fCurrentColorType++;
+ break;
+ case kUnpremul_SkAlphaType:
+ case kPremul_SkAlphaType:
+ if (0 == fCurrentAlphaType) {
+ // Test unpremul first.
+ alphaType = kUnpremul_SkAlphaType;
+ fCurrentAlphaType++;
+ } else {
+ // Test premul.
+ alphaType = kPremul_SkAlphaType;
+ fCurrentAlphaType = 0;
+ fCurrentColorType++;
+ }
+ break;
+ default:
+ SkASSERT(false);
+ fCurrentColorType++;
+ break;
}
+ // Make sure we can decode to this color type and alpha type.
+ SkImageInfo info =
+ codec->getInfo().makeColorType(colorType).makeAlphaType(alphaType);
const size_t rowBytes = info.minRowBytes();
SkAutoMalloc storage(info.getSafeSize(rowBytes));
@@ -779,7 +796,7 @@ public:
case SkCodec::kSuccess:
case SkCodec::kIncompleteInput:
return new CodecBench(SkOSPath::Basename(path.c_str()),
- encoded, colorType);
+ encoded, colorType, alphaType);
case SkCodec::kInvalidConversion:
// This is okay. Not all conversions are valid.
break;
@@ -972,6 +989,7 @@ private:
int fCurrentImage;
int fCurrentBRDImage;
int fCurrentColorType;
+ int fCurrentAlphaType;
int fCurrentSubsetType;
int fCurrentBRDStrategy;
int fCurrentBRDSampleSize;
« bench/CodecBench.cpp ('K') | « bench/CodecBenchPriv.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698