aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-05-18 06:23:57 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-18 06:23:57 -0700
commitd1227a7417922ce26252d55815d0d1e98f0eb070 (patch)
treee6aa4536de96410f69247c4b3e72e8cab09429ff /bench
parent4803f9715ff02b54a8ebae24167c490181d7cc3f (diff)
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
Diffstat (limited to 'bench')
-rw-r--r--bench/BitmapRegionDecoderBench.cpp23
-rw-r--r--bench/BitmapRegionDecoderBench.h6
-rw-r--r--bench/nanobench.cpp144
3 files changed, 64 insertions, 109 deletions
diff --git a/bench/BitmapRegionDecoderBench.cpp b/bench/BitmapRegionDecoderBench.cpp
index 125c4a84cf..dd60b18296 100644
--- a/bench/BitmapRegionDecoderBench.cpp
+++ b/bench/BitmapRegionDecoderBench.cpp
@@ -11,34 +11,17 @@
#include "SkOSFile.h"
BitmapRegionDecoderBench::BitmapRegionDecoderBench(const char* baseName, SkData* encoded,
- SkBitmapRegionDecoder::Strategy strategy, SkColorType colorType,
- uint32_t sampleSize, const SkIRect& subset)
+ SkColorType colorType, uint32_t sampleSize, const SkIRect& subset)
: fBRD(nullptr)
, fData(SkRef(encoded))
- , fStrategy(strategy)
, fColorType(colorType)
, fSampleSize(sampleSize)
, fSubset(subset)
{
- // Choose a useful name for the region decoding strategy
- const char* strategyName;
- switch (strategy) {
- case SkBitmapRegionDecoder::kCanvas_Strategy:
- strategyName = "Canvas";
- break;
- case SkBitmapRegionDecoder::kAndroidCodec_Strategy:
- strategyName = "AndroidCodec";
- break;
- default:
- SkASSERT(false);
- strategyName = "";
- break;
- }
-
// Choose a useful name for the color type
const char* colorName = color_type_to_str(colorType);
- fName.printf("BRD_%s_%s_%s", baseName, strategyName, colorName);
+ fName.printf("BRD_%s_%s", baseName, colorName);
if (1 != sampleSize) {
fName.appendf("_%.3f", 1.0f / (float) sampleSize);
}
@@ -53,7 +36,7 @@ bool BitmapRegionDecoderBench::isSuitableFor(Backend backend) {
}
void BitmapRegionDecoderBench::onDelayedSetup() {
- fBRD.reset(SkBitmapRegionDecoder::Create(fData, fStrategy));
+ fBRD.reset(SkBitmapRegionDecoder::Create(fData, SkBitmapRegionDecoder::kAndroidCodec_Strategy));
}
void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) {
diff --git a/bench/BitmapRegionDecoderBench.h b/bench/BitmapRegionDecoderBench.h
index 7c331aee31..69588b24c3 100644
--- a/bench/BitmapRegionDecoderBench.h
+++ b/bench/BitmapRegionDecoderBench.h
@@ -18,16 +18,13 @@
/**
* Benchmark Android's BitmapRegionDecoder for a particular colorType, sampleSize, and subset.
*
- * fStrategy determines which of various implementations is to be used.
- *
* nanobench.cpp handles creating benchmarks for interesting scaled subsets. We strive to test
* on real use cases.
*/
class BitmapRegionDecoderBench : public Benchmark {
public:
// Calls encoded->ref()
- BitmapRegionDecoderBench(const char* basename, SkData* encoded,
- SkBitmapRegionDecoder::Strategy strategy, SkColorType colorType,
+ BitmapRegionDecoderBench(const char* basename, SkData* encoded, SkColorType colorType,
uint32_t sampleSize, const SkIRect& subset);
protected:
@@ -40,7 +37,6 @@ private:
SkString fName;
SkAutoTDelete<SkBitmapRegionDecoder> fBRD;
SkAutoTUnref<SkData> fData;
- const SkBitmapRegionDecoder::Strategy fStrategy;
const SkColorType fColorType;
const uint32_t fSampleSize;
const SkIRect fSubset;
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 8bc40cc460..4fb1ed223a 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -513,22 +513,15 @@ static Target* is_enabled(Benchmark* bench, const Config& config) {
return target;
}
-static bool valid_brd_bench(SkData* encoded, SkBitmapRegionDecoder::Strategy strategy,
- SkColorType colorType, uint32_t sampleSize, uint32_t minOutputSize, int* width,
- int* height) {
+static bool valid_brd_bench(SkData* encoded, SkColorType colorType, uint32_t sampleSize,
+ uint32_t minOutputSize, int* width, int* height) {
SkAutoTDelete<SkBitmapRegionDecoder> brd(
- SkBitmapRegionDecoder::Create(encoded, strategy));
+ SkBitmapRegionDecoder::Create(encoded, SkBitmapRegionDecoder::kAndroidCodec_Strategy));
if (nullptr == brd.get()) {
// This is indicates that subset decoding is not supported for a particular image format.
return false;
}
- SkBitmap bitmap;
- if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(0, 0, brd->width(), brd->height()),
- 1, colorType, false)) {
- return false;
- }
-
if (sampleSize * minOutputSize > (uint32_t) brd->width() || sampleSize * minOutputSize >
(uint32_t) brd->height()) {
// This indicates that the image is not large enough to decode a
@@ -568,7 +561,6 @@ public:
, fCurrentColorType(0)
, fCurrentAlphaType(0)
, fCurrentSubsetType(0)
- , fCurrentBRDStrategy(0)
, fCurrentSampleSize(0)
, fCurrentAnimSKP(0) {
for (int i = 0; i < FLAGS_skps.count(); i++) {
@@ -842,15 +834,6 @@ public:
}
// Run the BRDBenches
- // We will benchmark multiple BRD strategies.
- static const struct {
- SkBitmapRegionDecoder::Strategy fStrategy;
- const char* fName;
- } strategies[] = {
- { SkBitmapRegionDecoder::kCanvas_Strategy, "BRD_canvas" },
- { SkBitmapRegionDecoder::kAndroidCodec_Strategy, "BRD_android_codec" },
- };
-
// We intend to create benchmarks that model the use cases in
// android/libraries/social/tiledimage. In this library, an image is decoded in 512x512
// tiles. The image can be translated freely, so the location of a tile may be anywhere in
@@ -866,78 +849,72 @@ public:
const uint32_t brdSampleSizes[] = { 1, 2, 4, 8, 16 };
const uint32_t minOutputSize = 512;
for (; fCurrentBRDImage < fImages.count(); fCurrentBRDImage++) {
+ fSourceType = "image";
+ fBenchType = "BRD";
+
const SkString& path = fImages[fCurrentBRDImage];
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) {
continue;
}
- while (fCurrentBRDStrategy < (int) SK_ARRAY_COUNT(strategies)) {
- fSourceType = "image";
- fBenchType = strategies[fCurrentBRDStrategy].fName;
-
- const SkBitmapRegionDecoder::Strategy strategy =
- strategies[fCurrentBRDStrategy].fStrategy;
-
- while (fCurrentColorType < fColorTypes.count()) {
- while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(brdSampleSizes)) {
- while (fCurrentSubsetType <= kLastSingle_SubsetType) {
-
- SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
- const SkColorType colorType = fColorTypes[fCurrentColorType];
- uint32_t sampleSize = brdSampleSizes[fCurrentSampleSize];
- int currentSubsetType = fCurrentSubsetType++;
-
- int width = 0;
- int height = 0;
- if (!valid_brd_bench(encoded.get(), strategy, colorType, sampleSize,
- minOutputSize, &width, &height)) {
+
+ while (fCurrentColorType < fColorTypes.count()) {
+ while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(brdSampleSizes)) {
+ while (fCurrentSubsetType <= kLastSingle_SubsetType) {
+
+ SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
+ const SkColorType colorType = fColorTypes[fCurrentColorType];
+ uint32_t sampleSize = brdSampleSizes[fCurrentSampleSize];
+ int currentSubsetType = fCurrentSubsetType++;
+
+ int width = 0;
+ int height = 0;
+ if (!valid_brd_bench(encoded.get(), colorType, sampleSize, minOutputSize,
+ &width, &height)) {
+ break;
+ }
+
+ SkString basename = SkOSPath::Basename(path.c_str());
+ SkIRect subset;
+ const uint32_t subsetSize = sampleSize * minOutputSize;
+ switch (currentSubsetType) {
+ case kTopLeft_SubsetType:
+ basename.append("_TopLeft");
+ subset = SkIRect::MakeXYWH(0, 0, subsetSize, subsetSize);
+ break;
+ case kTopRight_SubsetType:
+ basename.append("_TopRight");
+ subset = SkIRect::MakeXYWH(width - subsetSize, 0, subsetSize,
+ subsetSize);
+ break;
+ case kMiddle_SubsetType:
+ basename.append("_Middle");
+ subset = SkIRect::MakeXYWH((width - subsetSize) / 2,
+ (height - subsetSize) / 2, subsetSize, subsetSize);
break;
- }
-
- SkString basename = SkOSPath::Basename(path.c_str());
- SkIRect subset;
- const uint32_t subsetSize = sampleSize * minOutputSize;
- switch (currentSubsetType) {
- case kTopLeft_SubsetType:
- basename.append("_TopLeft");
- subset = SkIRect::MakeXYWH(0, 0, subsetSize, subsetSize);
- break;
- case kTopRight_SubsetType:
- basename.append("_TopRight");
- subset = SkIRect::MakeXYWH(width - subsetSize, 0, subsetSize,
- subsetSize);
- break;
- case kMiddle_SubsetType:
- basename.append("_Middle");
- subset = SkIRect::MakeXYWH((width - subsetSize) / 2,
- (height - subsetSize) / 2, subsetSize, subsetSize);
- break;
- case kBottomLeft_SubsetType:
- basename.append("_BottomLeft");
- subset = SkIRect::MakeXYWH(0, height - subsetSize, subsetSize,
- subsetSize);
- break;
- case kBottomRight_SubsetType:
- basename.append("_BottomRight");
- subset = SkIRect::MakeXYWH(width - subsetSize,
- height - subsetSize, subsetSize, subsetSize);
- break;
- default:
- SkASSERT(false);
- }
-
- return new BitmapRegionDecoderBench(basename.c_str(), encoded.get(),
- strategy, colorType, sampleSize, subset);
+ case kBottomLeft_SubsetType:
+ basename.append("_BottomLeft");
+ subset = SkIRect::MakeXYWH(0, height - subsetSize, subsetSize,
+ subsetSize);
+ break;
+ case kBottomRight_SubsetType:
+ basename.append("_BottomRight");
+ subset = SkIRect::MakeXYWH(width - subsetSize,
+ height - subsetSize, subsetSize, subsetSize);
+ break;
+ default:
+ SkASSERT(false);
}
- fCurrentSubsetType = 0;
- fCurrentSampleSize++;
+
+ return new BitmapRegionDecoderBench(basename.c_str(), encoded.get(),
+ colorType, sampleSize, subset);
}
- fCurrentSampleSize = 0;
- fCurrentColorType++;
+ fCurrentSubsetType = 0;
+ fCurrentSampleSize++;
}
- fCurrentColorType = 0;
- fCurrentBRDStrategy++;
+ fCurrentSampleSize = 0;
+ fCurrentColorType++;
}
- fCurrentBRDStrategy = 0;
+ fCurrentColorType = 0;
}
return nullptr;
@@ -1001,7 +978,6 @@ private:
int fCurrentColorType;
int fCurrentAlphaType;
int fCurrentSubsetType;
- int fCurrentBRDStrategy;
int fCurrentSampleSize;
int fCurrentAnimSKP;
};