skia2/bench/BitmapRegionDecoderBench.cpp
msarett d1227a7417 Delete SkBitmapRegionCanvas
This was an approach we considered for implementing Android's
BitmapRegionDecoder.

It was useful for testing and comparison, but now is no longer worth
maintaining and testing.

The approach to subset/scaled decodes (clipped decode, then scale)
may be worth reconsidering at some point.

BUG=skia:5307
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1990543002

Review-Url: https://codereview.chromium.org/1990543002
2016-05-18 06:23:57 -07:00

48 lines
1.3 KiB
C++

/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "BitmapRegionDecoderBench.h"
#include "CodecBenchPriv.h"
#include "SkBitmap.h"
#include "SkOSFile.h"
BitmapRegionDecoderBench::BitmapRegionDecoderBench(const char* baseName, SkData* encoded,
SkColorType colorType, uint32_t sampleSize, const SkIRect& subset)
: fBRD(nullptr)
, fData(SkRef(encoded))
, fColorType(colorType)
, fSampleSize(sampleSize)
, fSubset(subset)
{
// Choose a useful name for the color type
const char* colorName = color_type_to_str(colorType);
fName.printf("BRD_%s_%s", baseName, colorName);
if (1 != sampleSize) {
fName.appendf("_%.3f", 1.0f / (float) sampleSize);
}
}
const char* BitmapRegionDecoderBench::onGetName() {
return fName.c_str();
}
bool BitmapRegionDecoderBench::isSuitableFor(Backend backend) {
return kNonRendering_Backend == backend;
}
void BitmapRegionDecoderBench::onDelayedSetup() {
fBRD.reset(SkBitmapRegionDecoder::Create(fData, SkBitmapRegionDecoder::kAndroidCodec_Strategy));
}
void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) {
for (int i = 0; i < n; i++) {
SkBitmap bm;
SkAssertResult(fBRD->decodeRegion(&bm, nullptr, fSubset, fSampleSize, fColorType, false));
}
}