aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2016-01-27 08:26:44 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-27 08:26:44 -0800
commit0edf1693dfd8360f5b8256e0700c2240854c010f (patch)
tree81fa016ed543c262d07d952438ad0775349d73f3 /bench
parent076d83d09a5717913cfecabac0440b6c854ca86d (diff)
Stop testing SkImageDecoder in DM/nanobench
We have already used it for comparison, and are switching forward to using SkCodec. This also allows us to simplify the code for checking the extensions we support for images. GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1641663002 Review URL: https://codereview.chromium.org/1641663002
Diffstat (limited to 'bench')
-rw-r--r--bench/DecodingBench.cpp97
-rw-r--r--bench/DecodingBench.h40
-rw-r--r--bench/nanobench.cpp26
3 files changed, 0 insertions, 163 deletions
diff --git a/bench/DecodingBench.cpp b/bench/DecodingBench.cpp
deleted file mode 100644
index 2feb7dd3ef..0000000000
--- a/bench/DecodingBench.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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 "CodecBenchPriv.h"
-#include "DecodingBench.h"
-#include "SkBitmap.h"
-#include "SkData.h"
-#include "SkImageDecoder.h"
-#include "SkMallocPixelRef.h"
-#include "SkOSFile.h"
-#include "SkStream.h"
-
-/*
- *
- * This benchmark is designed to test the performance of image decoding.
- * It is invoked from the nanobench.cpp file.
- *
- */
-DecodingBench::DecodingBench(SkString path, SkColorType colorType)
- : fColorType(colorType)
- , fData(SkData::NewFromFileName(path.c_str()))
-{
- // Parse filename and the color type to give the benchmark a useful name
- SkString baseName = SkOSPath::Basename(path.c_str());
- fName.printf("Decode_%s_%s", baseName.c_str(), color_type_to_str(colorType));
-
-#ifdef SK_DEBUG
- // Ensure that we can create a decoder.
- SkAutoTDelete<SkStreamRewindable> stream(new SkMemoryStream(fData));
- SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream));
- SkASSERT(decoder != nullptr);
-#endif
-}
-
-const char* DecodingBench::onGetName() {
- return fName.c_str();
-}
-
-bool DecodingBench::isSuitableFor(Backend backend) {
- return kNonRendering_Backend == backend;
-}
-
-void DecodingBench::onDelayedSetup() {
- // Allocate the pixels now, to remove it from the loop.
- SkAutoTDelete<SkStreamRewindable> stream(new SkMemoryStream(fData));
- SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream));
- SkBitmap bm;
-#ifdef SK_DEBUG
- SkImageDecoder::Result result =
-#endif
- decoder->decode(stream, &bm, fColorType, SkImageDecoder::kDecodeBounds_Mode);
- SkASSERT(SkImageDecoder::kFailure != result);
-
- const size_t rowBytes = bm.info().minRowBytes();
- fPixelStorage.reset(bm.info().getSafeSize(rowBytes));
-}
-
-// Allocator which just uses an existing block of memory.
-class TargetAllocator : public SkBitmap::Allocator {
-public:
- explicit TargetAllocator(void* storage)
- : fPixelStorage(storage) {}
-
- bool allocPixelRef(SkBitmap* bm, SkColorTable* ct) override {
- // We depend on the fact that this will only ever be used to
- // decode to a bitmap with the same settings used to create
- // fPixelStorage.
- bm->setPixelRef(SkMallocPixelRef::NewDirect(bm->info(),
- fPixelStorage, bm->rowBytes(), ct))->unref();
- return true;
- }
-
-private:
- void* fPixelStorage; // Unowned. DecodingBench owns this.
-};
-
-void DecodingBench::onDraw(int n, SkCanvas* canvas) {
- SkBitmap bitmap;
- // Declare the allocator before the decoder, so it will outlive the
- // decoder, which will unref it.
- TargetAllocator allocator(fPixelStorage.get());
- SkAutoTDelete<SkImageDecoder> decoder;
- SkAutoTDelete<SkStreamRewindable> stream;
- for (int i = 0; i < n; i++) {
- // create a new stream and a new decoder to mimic the behavior of
- // CodecBench.
- stream.reset(new SkMemoryStream(fData));
- decoder.reset(SkImageDecoder::Factory(stream));
- decoder->setAllocator(&allocator);
- decoder->decode(stream, &bitmap, fColorType,
- SkImageDecoder::kDecodePixels_Mode);
- }
-}
diff --git a/bench/DecodingBench.h b/bench/DecodingBench.h
deleted file mode 100644
index 196749dfba..0000000000
--- a/bench/DecodingBench.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef DecodingBench_DEFINED
-#define DecodingBench_DEFINED
-
-#include "Benchmark.h"
-#include "SkData.h"
-#include "SkImageDecoder.h"
-#include "SkRefCnt.h"
-#include "SkString.h"
-
-/*
- *
- * This benchmark is designed to test the performance of image decoding.
- * It is invoked from the nanobench.cpp file.
- *
- */
-class DecodingBench : public Benchmark {
-public:
- DecodingBench(SkString path, SkColorType colorType);
-
-protected:
- const char* onGetName() override;
- bool isSuitableFor(Backend backend) override;
- void onDraw(int n, SkCanvas* canvas) override;
- void onDelayedSetup() override;
-
-private:
- SkString fName;
- SkColorType fColorType;
- SkAutoTUnref<SkData> fData;
- SkAutoMalloc fPixelStorage;
- typedef Benchmark INHERITED;
-};
-#endif // DecodingBench_DEFINED
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index cfedc52379..d6c4c596c1 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -14,7 +14,6 @@
#include "CodecBench.h"
#include "CodecBenchPriv.h"
#include "CrashHandler.h"
-#include "DecodingBench.h"
#include "GMBench.h"
#include "ProcStats.h"
#include "ResultsWriter.h"
@@ -561,7 +560,6 @@ public:
, fCurrentSKP(0)
, fCurrentUseMPD(0)
, fCurrentCodec(0)
- , fCurrentImage(0)
, fCurrentBRDImage(0)
, fCurrentColorType(0)
, fCurrentAlphaType(0)
@@ -812,29 +810,6 @@ public:
fCurrentColorType = 0;
}
- // Run the DecodingBenches
- for (; fCurrentImage < fImages.count(); fCurrentImage++) {
- fSourceType = "image";
- fBenchType = "skimagedecoder";
- const SkString& path = fImages[fCurrentImage];
- if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) {
- continue;
- }
- while (fCurrentColorType < fColorTypes.count()) {
- SkColorType colorType = fColorTypes[fCurrentColorType];
- fCurrentColorType++;
- // Check if the image decodes to the right color type
- // before creating the benchmark
- SkBitmap bitmap;
- if (SkImageDecoder::DecodeFile(path.c_str(), &bitmap,
- colorType, SkImageDecoder::kDecodePixels_Mode)
- && bitmap.colorType() == colorType) {
- return new DecodingBench(path, colorType);
- }
- }
- fCurrentColorType = 0;
- }
-
// Run the BRDBenches
// We will benchmark multiple BRD strategies.
static const struct {
@@ -993,7 +968,6 @@ private:
int fCurrentSKP;
int fCurrentUseMPD;
int fCurrentCodec;
- int fCurrentImage;
int fCurrentBRDImage;
int fCurrentColorType;
int fCurrentAlphaType;