Chromium Code Reviews| Index: bench/BitmapRegionDecoderBench.cpp |
| diff --git a/bench/BitmapRegionDecoderBench.cpp b/bench/BitmapRegionDecoderBench.cpp |
| index 092693619bb8be5796a9de50be373dde4e9eb186..c6197a20e25c0db960645eccf077a47e356e39de 100644 |
| --- a/bench/BitmapRegionDecoderBench.cpp |
| +++ b/bench/BitmapRegionDecoderBench.cpp |
| @@ -20,6 +20,7 @@ BitmapRegionDecoderBench::BitmapRegionDecoderBench(const char* baseName, SkData* |
| , fColorType(colorType) |
| , fSampleSize(sampleSize) |
| , fSubset(subset) |
| + , fColorTable(nullptr) |
| { |
| // Choose a useful name for the region decoding strategy |
| const char* strategyName; |
| @@ -46,6 +47,11 @@ BitmapRegionDecoderBench::BitmapRegionDecoderBench(const char* baseName, SkData* |
| if (1 != sampleSize) { |
| fName.appendf("_%.3f", get_scale_from_sample_size(sampleSize)); |
| } |
| + |
| + if (kIndex_8_SkColorType == fColorType) { |
| + SkPMColor colors[256]; |
| + fColorTable.reset(new SkColorTable(colors, 256)); |
| + } |
| } |
| const char* BitmapRegionDecoderBench::onGetName() { |
| @@ -61,10 +67,23 @@ void BitmapRegionDecoderBench::onDelayedSetup() { |
| } |
| void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) { |
| - SkAutoTDelete<SkBitmap> bitmap; |
| for (int i = 0; i < n; i++) { |
| - bitmap.reset(fBRD->decodeRegion(fSubset.left(), fSubset.top(), fSubset.width(), |
| - fSubset.height(), fSampleSize, fColorType)); |
| - SkASSERT(nullptr != bitmap.get()); |
| + SkImageInfo info; |
| +#ifdef SK_DEBUG |
| + bool result = |
| +#endif |
| + fBRD->prepareRegion(fSubset, fSampleSize, fColorType, false, &info); |
|
scroggo
2015/10/27 15:00:50
You could also change this to:
SkAssertResult(f
|
| + SkASSERT(result); |
| + |
| + SkBitmap bitmap; |
| + if (SkBitmapRegionDecoderInterface::kOriginal_Strategy != fStrategy) { |
| + bitmap.allocPixels(info, nullptr, fColorTable); |
| + } |
| + |
| +#ifdef SK_DEBUG |
| + result = |
| +#endif |
| + fBRD->decodeRegion(bitmap); |
| + SkASSERT(result); |
| } |
| } |