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

Side by Side Diff: bench/CodecBench.cpp

Issue 1051973002: Test SkCodec to kIndex8 in nanobench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove extra newline. Created 5 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "CodecBench.h" 8 #include "CodecBench.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCodec.h" 10 #include "SkCodec.h"
(...skipping 30 matching lines...) Expand all
41 const char* CodecBench::onGetName() { 41 const char* CodecBench::onGetName() {
42 return fName.c_str(); 42 return fName.c_str();
43 } 43 }
44 44
45 bool CodecBench::isSuitableFor(Backend backend) { 45 bool CodecBench::isSuitableFor(Backend backend) {
46 return kNonRendering_Backend == backend; 46 return kNonRendering_Backend == backend;
47 } 47 }
48 48
49 void CodecBench::onPreDraw() { 49 void CodecBench::onPreDraw() {
50 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fData)); 50 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fData));
51 fBitmap.allocPixels(codec->getInfo().makeColorType(fColorType)); 51
52 fInfo = codec->getInfo().makeColorType(fColorType);
53 SkAlphaType alphaType;
54 // Caller should not have created this CodecBench if the alpha type was
55 // invalid.
56 SkAssertResult(SkColorTypeValidateAlphaType(fColorType, fInfo.alphaType(),
57 &alphaType));
58 if (alphaType != fInfo.alphaType()) {
59 fInfo = fInfo.makeAlphaType(alphaType);
60 }
61
62 fStorage.reset(fInfo.getSafeSize(fInfo.minRowBytes()));
52 } 63 }
53 64
54 void CodecBench::onDraw(const int n, SkCanvas* canvas) { 65 void CodecBench::onDraw(const int n, SkCanvas* canvas) {
55 SkAutoTDelete<SkCodec> codec; 66 SkAutoTDelete<SkCodec> codec;
67 SkPMColor colorTable[256];
68 int colorCount;
56 for (int i = 0; i < n; i++) { 69 for (int i = 0; i < n; i++) {
70 colorCount = 256;
57 codec.reset(SkCodec::NewFromData(fData)); 71 codec.reset(SkCodec::NewFromData(fData));
58 #ifdef SK_DEBUG 72 #ifdef SK_DEBUG
59 const SkImageGenerator::Result result = 73 const SkImageGenerator::Result result =
60 #endif 74 #endif
61 // fBitmap.info() was set to use fColorType in onPreDraw. 75 codec->getPixels(fInfo, fStorage.get(), fInfo.minRowBytes(),
62 codec->getPixels(fBitmap.info(), fBitmap.getPixels(), fBitmap.rowBytes() ); 76 NULL, colorTable, &colorCount);
63 SkASSERT(result == SkImageGenerator::kSuccess 77 SkASSERT(result == SkImageGenerator::kSuccess
64 || result == SkImageGenerator::kIncompleteInput); 78 || result == SkImageGenerator::kIncompleteInput);
65 } 79 }
66 } 80 }
OLDNEW
« bench/CodecBench.h ('K') | « bench/CodecBench.h ('k') | bench/DecodingBench.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698