skia2/bench/BitmapRegionDecoderBench.cpp
Leon Scroggins III 0118e9756d Remove calls to computeOutputColor- Type and Space
Bug: b/70846442
Test: I5110881203c000474116a94a48f2afc9a9b62001

These methods were already called by the client. The client may have
further overridden the SkColorType (and therefore the SkColorSpace), so
respect their final decision on both.

Change-Id: Iddcf618e474784b0a000fd516250c44285dacc6b
Reviewed-on: https://skia-review.googlesource.com/114062
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
2018-03-13 15:42:52 +00:00

50 lines
1.5 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) {
auto ct = fBRD->computeOutputColorType(fColorType);
auto cs = fBRD->computeOutputColorSpace(ct, nullptr);
for (int i = 0; i < n; i++) {
SkBitmap bm;
SkAssertResult(fBRD->decodeRegion(&bm, nullptr, fSubset, fSampleSize, ct, false, cs));
}
}