8321f7585b
This reverts commit 742a3e298f
.
Reason for revert: Breaking Android roll:
frameworks/base/core/jni/android/graphics/BitmapFactory.cpp:453:18: error: no member named 'fColorPtr' in 'SkAndroidCodec::AndroidOptions'
codecOptions.fColorPtr = colorPtr;
~~~~~~~~~~~~ ^
frameworks/base/core/jni/android/graphics/BitmapFactory.cpp:454:18: error: no member named 'fColorCount' in 'SkAndroidCodec::AndroidOptions'
codecOptions.fColorCount = colorCount;
~~~~~~~~~~~~ ^
Original change's description:
> Remove support for decoding to kIndex_8
>
> Fix up callsites, and remove tests that no longer make sense.
>
> Bug: skia:6828
> Change-Id: I2548c4b7528b7b1be7412563156f27b52c9d4295
> Reviewed-on: https://skia-review.googlesource.com/21664
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Commit-Queue: Leon Scroggins <scroggo@google.com>
TBR=djsollen@google.com,scroggo@google.com
Change-Id: I1bc669441f250690884e75a9a61427fdf75c6907
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:6828
Reviewed-on: https://skia-review.googlesource.com/22120
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
72 lines
2.2 KiB
C++
72 lines
2.2 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 "CodecBench.h"
|
|
#include "CodecBenchPriv.h"
|
|
#include "SkBitmap.h"
|
|
#include "SkCodec.h"
|
|
#include "SkCommandLineFlags.h"
|
|
#include "SkOSFile.h"
|
|
|
|
// Actually zeroing the memory would throw off timing, so we just lie.
|
|
DEFINE_bool(zero_init, false, "Pretend our destination is zero-intialized, simulating Android?");
|
|
|
|
CodecBench::CodecBench(SkString baseName, SkData* encoded, SkColorType colorType,
|
|
SkAlphaType alphaType)
|
|
: fColorType(colorType)
|
|
, fAlphaType(alphaType)
|
|
, fData(SkRef(encoded))
|
|
{
|
|
// Parse filename and the color type to give the benchmark a useful name
|
|
fName.printf("Codec_%s_%s%s", baseName.c_str(), color_type_to_str(colorType),
|
|
alpha_type_to_str(alphaType));
|
|
#ifdef SK_DEBUG
|
|
// Ensure that we can create an SkCodec from this data.
|
|
std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(fData));
|
|
SkASSERT(codec);
|
|
#endif
|
|
}
|
|
|
|
const char* CodecBench::onGetName() {
|
|
return fName.c_str();
|
|
}
|
|
|
|
bool CodecBench::isSuitableFor(Backend backend) {
|
|
return kNonRendering_Backend == backend;
|
|
}
|
|
|
|
void CodecBench::onDelayedSetup() {
|
|
std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(fData));
|
|
|
|
fInfo = codec->getInfo().makeColorType(fColorType)
|
|
.makeAlphaType(fAlphaType)
|
|
.makeColorSpace(nullptr);
|
|
|
|
fPixelStorage.reset(fInfo.getSafeSize(fInfo.minRowBytes()));
|
|
}
|
|
|
|
void CodecBench::onDraw(int n, SkCanvas* canvas) {
|
|
std::unique_ptr<SkCodec> codec;
|
|
SkPMColor colorTable[256];
|
|
int colorCount;
|
|
SkCodec::Options options;
|
|
if (FLAGS_zero_init) {
|
|
options.fZeroInitialized = SkCodec::kYes_ZeroInitialized;
|
|
}
|
|
for (int i = 0; i < n; i++) {
|
|
colorCount = 256;
|
|
codec.reset(SkCodec::NewFromData(fData));
|
|
#ifdef SK_DEBUG
|
|
const SkCodec::Result result =
|
|
#endif
|
|
codec->getPixels(fInfo, fPixelStorage.get(), fInfo.minRowBytes(),
|
|
&options, colorTable, &colorCount);
|
|
SkASSERT(result == SkCodec::kSuccess
|
|
|| result == SkCodec::kIncompleteInput);
|
|
}
|
|
}
|