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

Unified Diff: bench/DecodingBench.cpp

Issue 1641663002: Stop testing SkImageDecoder in DM/nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reblacklist some interlaced images Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bench/DecodingBench.h ('k') | bench/nanobench.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/DecodingBench.cpp
diff --git a/bench/DecodingBench.cpp b/bench/DecodingBench.cpp
deleted file mode 100644
index 2feb7dd3efa3c17cdaecd959f1be6ffce559525a..0000000000000000000000000000000000000000
--- 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);
- }
-}
« no previous file with comments | « bench/DecodingBench.h ('k') | bench/nanobench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698