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

Unified Diff: bench/nanobench.cpp

Issue 1051973002: Test SkCodec to kIndex8 in nanobench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fStorage -> fPixelStorage Created 5 years, 9 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
« no previous file with comments | « bench/DecodingBench.cpp ('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 701128f631f8ad887da39190cb8d5eafd6a00d92..bf99a1eee14db425a5375e07e18ce538ed58314b 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -540,7 +540,7 @@ public:
// Choose the candidate color types for image decoding
const SkColorType colorTypes[] =
- { kN32_SkColorType, kRGB_565_SkColorType, kAlpha_8_SkColorType };
+ { kN32_SkColorType, kRGB_565_SkColorType, kAlpha_8_SkColorType, kIndex_8_SkColorType };
fColorTypes.push_back_n(SK_ARRAY_COUNT(colorTypes), colorTypes);
}
@@ -644,15 +644,32 @@ public:
// Nothing to time.
continue;
}
+
while (fCurrentColorType < fColorTypes.count()) {
- SkColorType colorType = fColorTypes[fCurrentColorType];
+ const SkColorType colorType = fColorTypes[fCurrentColorType];
fCurrentColorType++;
+
// Make sure we can decode to this color type.
- SkBitmap bitmap;
SkImageInfo info = codec->getInfo().makeColorType(colorType);
- bitmap.allocPixels(info);
+ SkAlphaType alphaType;
+ if (!SkColorTypeValidateAlphaType(colorType, info.alphaType(),
+ &alphaType)) {
+ continue;
+ }
+ if (alphaType != info.alphaType()) {
+ info = info.makeAlphaType(alphaType);
+ }
+
+ const size_t rowBytes = info.minRowBytes();
+ SkAutoMalloc storage(info.getSafeSize(rowBytes));
+
+ // Used if fCurrentColorType is kIndex_8_SkColorType
+ int colorCount = 256;
+ SkPMColor colors[256];
+
const SkImageGenerator::Result result = codec->getPixels(
- bitmap.info(), bitmap.getPixels(), bitmap.rowBytes());
+ info, storage.get(), rowBytes, NULL, colors,
+ &colorCount);
switch (result) {
case SkImageGenerator::kSuccess:
case SkImageGenerator::kIncompleteInput:
« no previous file with comments | « bench/DecodingBench.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698