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

Unified Diff: bench/CodecBench.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/CodecBench.h ('k') | bench/DecodingBench.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/CodecBench.cpp
diff --git a/bench/CodecBench.cpp b/bench/CodecBench.cpp
index e68c5de6faff673c2da387b8f63e1264bc71b326..debda712b7bd2a12e2e53d370c9f1aecad81752f 100644
--- a/bench/CodecBench.cpp
+++ b/bench/CodecBench.cpp
@@ -48,18 +48,32 @@ bool CodecBench::isSuitableFor(Backend backend) {
void CodecBench::onPreDraw() {
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fData));
- fBitmap.allocPixels(codec->getInfo().makeColorType(fColorType));
+
+ fInfo = codec->getInfo().makeColorType(fColorType);
+ SkAlphaType alphaType;
+ // Caller should not have created this CodecBench if the alpha type was
+ // invalid.
+ SkAssertResult(SkColorTypeValidateAlphaType(fColorType, fInfo.alphaType(),
+ &alphaType));
+ if (alphaType != fInfo.alphaType()) {
+ fInfo = fInfo.makeAlphaType(alphaType);
+ }
+
+ fPixelStorage.reset(fInfo.getSafeSize(fInfo.minRowBytes()));
}
void CodecBench::onDraw(const int n, SkCanvas* canvas) {
SkAutoTDelete<SkCodec> codec;
+ SkPMColor colorTable[256];
+ int colorCount;
for (int i = 0; i < n; i++) {
+ colorCount = 256;
codec.reset(SkCodec::NewFromData(fData));
#ifdef SK_DEBUG
const SkImageGenerator::Result result =
#endif
- // fBitmap.info() was set to use fColorType in onPreDraw.
- codec->getPixels(fBitmap.info(), fBitmap.getPixels(), fBitmap.rowBytes());
+ codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(),
+ NULL, colorTable, &colorCount);
SkASSERT(result == SkImageGenerator::kSuccess
|| result == SkImageGenerator::kIncompleteInput);
}
« no previous file with comments | « bench/CodecBench.h ('k') | bench/DecodingBench.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698