Move SkBitmapRegionCodec into client_utils/android

Bug: skia:10154

This will make it clear that these files are for Android use and
avoid compiling them for other clients.

Update testing tools to use android::skia::BitmapRegionDecoder, but
only if SK_ENABLE_ANDROID_UTILS is defined.

Take this opportunity to clean up the class:
- The base class, which was originally designed to allow switching
  amongst different implementations, is no longer needed. Rename
  SkBitmapRegionCodec to android::skia::BitmapRegionDecoder
  (following the new convention and matching the Java API name).
  Continue to inherit from SkBitmapRegionDecoder temporarily, to
  allow Android to switch to the new API.
- Use std::unique_ptr instead of passing raw pointers.

Add a test to verify that we only create a BitmapRegionDecoder if
it is one of the supported types.

Change-Id: Ied13fc8acb105fde042553331846d95ae15d6b57
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287498
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
This commit is contained in:
Leon Scroggins III 2020-05-04 10:02:45 -04:00 committed by Skia Commit-Bot
parent 656ee7bc0f
commit 87caae61cd
17 changed files with 232 additions and 103 deletions

View File

@ -275,9 +275,16 @@ template("optional") {
optional("android_utils") {
enabled = skia_enable_android_utils
public = [ "client_utils/android/FrontBufferedStream.h" ]
public = [
"client_utils/android/BRDAllocator.h",
"client_utils/android/BitmapRegionDecoder.h",
"client_utils/android/FrontBufferedStream.h",
]
public_defines = [ "SK_ENABLE_ANDROID_UTILS" ]
sources = [ "client_utils/android/FrontBufferedStream.cpp" ]
sources = [
"client_utils/android/BitmapRegionDecoder.cpp",
"client_utils/android/FrontBufferedStream.cpp",
]
}
optional("fontmgr_android") {
@ -922,7 +929,6 @@ component("skia") {
sources += [
"src/android/SkAndroidFrameworkUtils.cpp",
"src/android/SkAnimatedImage.cpp",
"src/android/SkBitmapRegionCodec.cpp",
"src/android/SkBitmapRegionDecoder.cpp",
"src/codec/SkAndroidCodec.cpp",
"src/codec/SkAndroidCodecAdapter.cpp",

View File

@ -6,7 +6,9 @@
*/
#include "bench/BitmapRegionDecoderBench.h"
#ifdef SK_ENABLE_ANDROID_UTILS
#include "bench/CodecBenchPriv.h"
#include "client_utils/android/BitmapRegionDecoder.h"
#include "include/core/SkBitmap.h"
#include "src/core/SkOSFile.h"
@ -36,7 +38,7 @@ bool BitmapRegionDecoderBench::isSuitableFor(Backend backend) {
}
void BitmapRegionDecoderBench::onDelayedSetup() {
fBRD.reset(SkBitmapRegionDecoder::Create(fData, SkBitmapRegionDecoder::kAndroidCodec_Strategy));
fBRD = android::skia::BitmapRegionDecoder::Make(fData);
}
void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) {
@ -47,3 +49,4 @@ void BitmapRegionDecoderBench::onDraw(int n, SkCanvas* canvas) {
SkAssertResult(fBRD->decodeRegion(&bm, nullptr, fSubset, fSampleSize, ct, false, cs));
}
}
#endif // SK_ENABLE_ANDROID_UTILS

View File

@ -9,12 +9,18 @@
#define BitmapRegionDecoderBench_DEFINED
#include "bench/Benchmark.h"
#include "include/android/SkBitmapRegionDecoder.h"
#ifdef SK_ENABLE_ANDROID_UTILS
#include "include/core/SkData.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkString.h"
namespace android {
namespace skia {
class BitmapRegionDecoder;
}
}
/**
* Benchmark Android's BitmapRegionDecoder for a particular colorType, sampleSize, and subset.
*
@ -34,12 +40,13 @@ protected:
void onDelayedSetup() override;
private:
SkString fName;
std::unique_ptr<SkBitmapRegionDecoder> fBRD;
sk_sp<SkData> fData;
const SkColorType fColorType;
const uint32_t fSampleSize;
const SkIRect fSubset;
SkString fName;
std::unique_ptr<android::skia::BitmapRegionDecoder> fBRD;
sk_sp<SkData> fData;
const SkColorType fColorType;
const uint32_t fSampleSize;
const SkIRect fSubset;
typedef Benchmark INHERITED;
};
#endif // SK_ENABLE_ANDROID_UTILS
#endif // BitmapRegionDecoderBench_DEFINED

View File

@ -11,7 +11,6 @@
#include "bench/AndroidCodecBench.h"
#include "bench/Benchmark.h"
#include "bench/BitmapRegionDecoderBench.h"
#include "bench/CodecBench.h"
#include "bench/CodecBenchPriv.h"
#include "bench/GMBench.h"
@ -20,7 +19,6 @@
#include "bench/SKPAnimationBench.h"
#include "bench/SKPBench.h"
#include "bench/SkGlyphCacheBench.h"
#include "include/android/SkBitmapRegionDecoder.h"
#include "include/codec/SkAndroidCodec.h"
#include "include/codec/SkCodec.h"
#include "include/core/SkCanvas.h"
@ -52,6 +50,11 @@
#include "experimental/svg/model/SkSVGDOM.h"
#endif // SK_XML
#ifdef SK_ENABLE_ANDROID_UTILS
#include "bench/BitmapRegionDecoderBench.h"
#include "client_utils/android/BitmapRegionDecoder.h"
#endif
#include <cinttypes>
#include <stdlib.h>
#include <thread>
@ -586,10 +589,10 @@ static Target* is_enabled(Benchmark* bench, const Config& config) {
#pragma warning ( pop )
#endif
#ifdef SK_ENABLE_ANDROID_UTILS
static bool valid_brd_bench(sk_sp<SkData> encoded, SkColorType colorType, uint32_t sampleSize,
uint32_t minOutputSize, int* width, int* height) {
std::unique_ptr<SkBitmapRegionDecoder> brd(
SkBitmapRegionDecoder::Create(encoded, SkBitmapRegionDecoder::kAndroidCodec_Strategy));
auto brd = android::skia::BitmapRegionDecoder::Make(encoded);
if (nullptr == brd.get()) {
// This is indicates that subset decoding is not supported for a particular image format.
return false;
@ -607,6 +610,7 @@ static bool valid_brd_bench(sk_sp<SkData> encoded, SkColorType colorType, uint32
*height = brd->height();
return true;
}
#endif
static void cleanup_run(Target* target) {
delete target;
@ -967,6 +971,7 @@ public:
fCurrentSampleSize = 0;
}
#ifdef SK_ENABLE_ANDROID_UTILS
// Run the BRDBenches
// We intend to create benchmarks that model the use cases in
// android/libraries/social/tiledimage. In this library, an image is decoded in 512x512
@ -1050,6 +1055,7 @@ public:
}
fCurrentColorType = 0;
}
#endif // SK_ENABLE_ANDROID_UTILS
return nullptr;
}
@ -1079,6 +1085,7 @@ public:
}
private:
#ifdef SK_ENABLE_ANDROID_UTILS
enum SubsetType {
kTopLeft_SubsetType = 0,
kTopRight_SubsetType = 1,
@ -1090,6 +1097,7 @@ private:
kLast_SubsetType = kZoom_SubsetType,
kLastSingle_SubsetType = kBottomRight_SubsetType,
};
#endif
const BenchRegistry* fBenches;
const skiagm::GMRegistry* fGMs;
@ -1117,10 +1125,12 @@ private:
int fCurrentUseMPD = 0;
int fCurrentCodec = 0;
int fCurrentAndroidCodec = 0;
#ifdef SK_ENABLE_ANDROID_UTILS
int fCurrentBRDImage = 0;
int fCurrentSubsetType = 0;
#endif
int fCurrentColorType = 0;
int fCurrentAlphaType = 0;
int fCurrentSubsetType = 0;
int fCurrentSampleSize = 0;
int fCurrentAnimSKP = 0;
};

View File

@ -0,0 +1,35 @@
/*
* 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 BRDAllocator_DEFINED
#define BRDAllocator_DEFINED
#include "include/codec/SkCodec.h"
#include "include/core/SkBitmap.h"
namespace android {
namespace skia {
/**
* Abstract subclass of SkBitmap's allocator.
* Allows the allocator to indicate if the memory it allocates
* is zero initialized.
*/
class BRDAllocator : public SkBitmap::Allocator {
public:
/**
* Indicates if the memory allocated by this allocator is
* zero initialized.
*/
virtual SkCodec::ZeroInitialized zeroInit() const = 0;
};
} // namespace skia
} // namespace android
#endif // BRDAllocator_DEFINED

View File

@ -5,17 +5,40 @@
* found in the LICENSE file.
*/
#include "client_utils/android/BitmapRegionDecoder.h"
#include "client_utils/android/BitmapRegionDecoderPriv.h"
#include "include/codec/SkAndroidCodec.h"
#include "src/android/SkBitmapRegionCodec.h"
#include "src/android/SkBitmapRegionDecoderPriv.h"
#include "src/codec/SkCodecPriv.h"
SkBitmapRegionCodec::SkBitmapRegionCodec(SkAndroidCodec* codec)
namespace android {
namespace skia {
std::unique_ptr<BitmapRegionDecoder> BitmapRegionDecoder::Make(sk_sp<SkData> data) {
auto codec = SkAndroidCodec::MakeFromData(std::move(data));
if (nullptr == codec) {
SkCodecPrintf("Error: Failed to create codec.\n");
return nullptr;
}
switch (codec->getEncodedFormat()) {
case SkEncodedImageFormat::kJPEG:
case SkEncodedImageFormat::kPNG:
case SkEncodedImageFormat::kWEBP:
case SkEncodedImageFormat::kHEIF:
break;
default:
return nullptr;
}
return std::unique_ptr<BitmapRegionDecoder>(new BitmapRegionDecoder(std::move(codec)));
}
BitmapRegionDecoder::BitmapRegionDecoder(std::unique_ptr<SkAndroidCodec> codec)
: INHERITED(codec->getInfo().width(), codec->getInfo().height())
, fCodec(codec)
, fCodec(std::move(codec))
{}
bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator,
bool BitmapRegionDecoder::decodeRegion(SkBitmap* bitmap, BRDAllocator* allocator,
const SkIRect& desiredSubset, int sampleSize, SkColorType dstColorType,
bool requireUnpremul, sk_sp<SkColorSpace> dstColorSpace) {
@ -116,3 +139,6 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat
return false;
}
}
} // namespace skia
} // namespace android

View File

@ -5,25 +5,24 @@
* found in the LICENSE file.
*/
#ifndef SkBitmapRegionCodec_DEFINED
#define SkBitmapRegionCodec_DEFINED
#ifndef BitmapRegionDecoder_DEFINED
#define BitmapRegionDecoder_DEFINED
#include "client_utils/android/BRDAllocator.h"
// Temporary, until Android switches to the new class.
#include "include/android/SkBitmapRegionDecoder.h"
#include "include/codec/SkAndroidCodec.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkData.h"
/*
* This class implements SkBitmapRegionDecoder using an SkAndroidCodec.
*/
class SkBitmapRegionCodec : public SkBitmapRegionDecoder {
namespace android {
namespace skia {
class BitmapRegionDecoder final : public SkBitmapRegionDecoder {
public:
static std::unique_ptr<BitmapRegionDecoder> Make(sk_sp<SkData> data);
/*
* Takes ownership of pointer to codec
*/
SkBitmapRegionCodec(SkAndroidCodec* codec);
bool decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator,
bool decodeRegion(SkBitmap* bitmap, BRDAllocator* allocator,
const SkIRect& desiredSubset, int sampleSize,
SkColorType colorType, bool requireUnpremul,
sk_sp<SkColorSpace> prefColorSpace) override;
@ -40,10 +39,14 @@ public:
}
private:
BitmapRegionDecoder(std::unique_ptr<SkAndroidCodec> codec);
std::unique_ptr<SkAndroidCodec> fCodec;
typedef SkBitmapRegionDecoder INHERITED;
};
#endif // SkBitmapRegionCodec_DEFINED
} // namespace skia
} // namespace android
#endif // BitmapRegionDecoder_DEFINED

View File

@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
#ifndef SkBitmapRegionDecoderPriv_DEFINED
#define SkBitmapRegionDecoderPriv_DEFINED
#ifndef BitmapRegionDecoderPriv_DEFINED
#define BitmapRegionDecoderPriv_DEFINED
#include "include/core/SkRect.h"
@ -58,4 +58,4 @@ inline SubsetType adjust_subset_rect(const SkISize& imageDims, SkIRect* subset,
return SubsetType::kFullyInside_SubsetType;
}
#endif // SkBitmapRegionDecoderPriv_DEFINED
#endif // BitmapRegionDecoderPriv_DEFINED

View File

@ -611,6 +611,7 @@ static void push_image_gen_src(Path path, ImageGenSrc::Mode mode, SkAlphaType al
push_src("image", folder, src);
}
#ifdef SK_ENABLE_ANDROID_UTILS
static void push_brd_src(Path path, CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode,
uint32_t sampleSize) {
SkString folder("brd_android_codec");
@ -669,6 +670,7 @@ static void push_brd_srcs(Path path, bool gray) {
}
}
}
#endif // SK_ENABLE_ANDROID_UTILS
static void push_codec_srcs(Path path) {
sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
@ -797,6 +799,7 @@ static void push_codec_srcs(Path path) {
}
}
#ifdef SK_ENABLE_ANDROID_UTILS
static const char* const brdExts[] = {
"jpg", "jpeg", "png", "webp",
"JPG", "JPEG", "PNG", "WEBP",
@ -808,6 +811,7 @@ static void push_codec_srcs(Path path) {
break;
}
}
#endif
}
// Push image generator GPU test.

View File

@ -68,6 +68,10 @@
#include "include/svg/SkSVGCanvas.h"
#include "src/xml/SkXMLWriter.h"
#endif
#if defined(SK_ENABLE_ANDROID_UTILS)
#include "client_utils/android/BitmapRegionDecoder.h"
#endif
#include "tests/TestUtils.h"
#include <cmath>
@ -120,6 +124,11 @@ std::unique_ptr<skiagm::verifiers::VerifierList> GMSrc::getVerifiers() const {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static SkString get_scaled_name(const Path& path, float scale) {
return SkStringPrintf("%s_%.3f", SkOSPath::Basename(path.c_str()).c_str(), scale);
}
#ifdef SK_ENABLE_ANDROID_UTILS
BRDSrc::BRDSrc(Path path, Mode mode, CodecSrc::DstColorType dstColorType, uint32_t sampleSize)
: fPath(path)
, fMode(mode)
@ -133,12 +142,9 @@ bool BRDSrc::veto(SinkFlags flags) const {
|| flags.approach != SinkFlags::kDirect;
}
static SkBitmapRegionDecoder* create_brd(Path path) {
static std::unique_ptr<android::skia::BitmapRegionDecoder> create_brd(Path path) {
sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
if (!encoded) {
return nullptr;
}
return SkBitmapRegionDecoder::Create(encoded, SkBitmapRegionDecoder::kAndroidCodec_Strategy);
return android::skia::BitmapRegionDecoder::Make(encoded);
}
static inline void alpha8_to_gray8(SkBitmap* bitmap) {
@ -169,7 +175,7 @@ Result BRDSrc::draw(SkCanvas* canvas) const {
break;
}
std::unique_ptr<SkBitmapRegionDecoder> brd(create_brd(fPath));
auto brd = create_brd(fPath);
if (nullptr == brd.get()) {
return Result::Skip("Could not create brd for %s.", fPath.c_str());
}
@ -273,7 +279,7 @@ Result BRDSrc::draw(SkCanvas* canvas) const {
}
SkISize BRDSrc::size() const {
std::unique_ptr<SkBitmapRegionDecoder> brd(create_brd(fPath));
auto brd = create_brd(fPath);
if (brd) {
return {std::max(1, brd->width() / (int)fSampleSize),
std::max(1, brd->height() / (int)fSampleSize)};
@ -281,10 +287,6 @@ SkISize BRDSrc::size() const {
return {0, 0};
}
static SkString get_scaled_name(const Path& path, float scale) {
return SkStringPrintf("%s_%.3f", SkOSPath::Basename(path.c_str()).c_str(), scale);
}
Name BRDSrc::name() const {
// We will replicate the names used by CodecSrc so that images can
// be compared in Gold.
@ -294,6 +296,8 @@ Name BRDSrc::name() const {
return get_scaled_name(fPath, 1.0f / (float) fSampleSize);
}
#endif // SK_ENABLE_ANDROID_UTILS
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static bool serial_from_path_name(const SkString& path) {

View File

@ -9,7 +9,6 @@
#define DMSrcSink_DEFINED
#include "gm/gm.h"
#include "include/android/SkBitmapRegionDecoder.h"
#include "include/core/SkBBHFactory.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
@ -194,6 +193,7 @@ private:
bool fRunSerially;
};
#ifdef SK_ENABLE_ANDROID_UTILS
// Allows for testing of various implementations of Android's BitmapRegionDecoder
class BRDSrc : public Src {
public:
@ -219,6 +219,7 @@ private:
CodecSrc::DstColorType fDstColorType;
uint32_t fSampleSize;
};
#endif
class ImageGenSrc : public Src {
public:

View File

@ -15,6 +15,7 @@ tests_sources = [
"$_tests/ApplyGammaTest.cpp",
"$_tests/ArenaAllocTest.cpp",
"$_tests/AsADashTest.cpp",
"$_tests/BRDTest.cpp",
"$_tests/BackendAllocationTest.cpp",
"$_tests/BadIcoTest.cpp",
"$_tests/BitSetTest.cpp",

View File

@ -8,22 +8,9 @@
#ifndef SkBRDAllocator_DEFINED
#define SkBRDAllocator_DEFINED
#include "include/codec/SkCodec.h"
#include "include/core/SkBitmap.h"
#include "client_utils/android/BRDAllocator.h"
/**
* Abstract subclass of SkBitmap's allocator.
* Allows the allocator to indicate if the memory it allocates
* is zero initialized.
*/
class SkBRDAllocator : public SkBitmap::Allocator {
public:
/**
* Indicates if the memory allocated by this allocator is
* zero initialized.
*/
virtual SkCodec::ZeroInitialized zeroInit() const = 0;
};
// Temporary until Android switches over to BRDAllocator directly.
class SkBRDAllocator : public android::skia::BRDAllocator {};
#endif // SkBRDAllocator_DEFINED

View File

@ -24,13 +24,6 @@ public:
kAndroidCodec_Strategy, // Uses SkAndroidCodec for scaling and subsetting
};
/*
* @param data Refs the data while this object exists, unrefs on destruction
* @param strategy Strategy used for scaling and subsetting
* @return Tries to create an SkBitmapRegionDecoder, returns NULL on failure
*/
static SkBitmapRegionDecoder* Create(sk_sp<SkData>, Strategy strategy);
/*
* @param stream Takes ownership of the stream
* @param strategy Strategy used for scaling and subsetting
@ -59,7 +52,7 @@ public:
* decode into. Otherwise, we will choose a default.
*
*/
virtual bool decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator,
virtual bool decodeRegion(SkBitmap* bitmap, android::skia::BRDAllocator* allocator,
const SkIRect& desiredSubset, int sampleSize,
SkColorType colorType, bool requireUnpremul,
sk_sp<SkColorSpace> prefColorSpace = nullptr) = 0;

View File

@ -15,8 +15,7 @@
'../../build/fuchsia',
'../../build_overrides',
'../../buildtools',
'../../client_utils/android/FrontBufferedStream.cpp',
'../../client_utils/android/FrontBufferedStream.h',
'../../client_utils/android',
'../../dm',
'../../docs/examples',
'../../example',

View File

@ -5,43 +5,43 @@
* found in the LICENSE file.
*/
#include "include/core/SkTypes.h"
#ifdef SK_ENABLE_ANDROID_UTILS
#include "client_utils/android/BitmapRegionDecoder.h"
#include "include/android/SkBitmapRegionDecoder.h"
#include "include/codec/SkAndroidCodec.h"
#include "include/codec/SkCodec.h"
#include "src/android/SkBitmapRegionCodec.h"
#include "include/core/SkData.h"
#include "include/core/SkStream.h"
#include "src/codec/SkCodecPriv.h"
SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
sk_sp<SkData> data, Strategy strategy) {
return SkBitmapRegionDecoder::Create(new SkMemoryStream(data),
strategy);
// Note: This file is only temporary while we switch Android over to BitmapRegionDecoder
// directly.
namespace {
struct Context {
std::unique_ptr<SkStreamRewindable> stream;
};
}
void release_proc(const void* ptr, void* context) {
delete reinterpret_cast<Context*>(context);
}
SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
SkStreamRewindable* stream, Strategy strategy) {
std::unique_ptr<SkStreamRewindable> streamDeleter(stream);
switch (strategy) {
case kAndroidCodec_Strategy: {
auto codec = SkAndroidCodec::MakeFromStream(std::move(streamDeleter));
if (nullptr == codec) {
SkCodecPrintf("Error: Failed to create codec.\n");
return nullptr;
}
switch ((SkEncodedImageFormat)codec->getEncodedFormat()) {
case SkEncodedImageFormat::kJPEG:
case SkEncodedImageFormat::kPNG:
case SkEncodedImageFormat::kWEBP:
case SkEncodedImageFormat::kHEIF:
break;
default:
return nullptr;
}
return new SkBitmapRegionCodec(codec.release());
}
default:
SkASSERT(false);
return nullptr;
const void* memoryBase = streamDeleter->getMemoryBase();
if (!memoryBase) {
// All existing clients use an SkMemoryStream.
SkASSERT(false);
SkCodecPrintf("Error: Need an SkMemoryStream to create an SkBitmapRegionDecoder!");
return nullptr;
}
Context* context = new Context;
context->stream = std::move(streamDeleter);
auto data = SkData::MakeWithProc(memoryBase, context->stream->getLength(), release_proc,
context);
return android::skia::BitmapRegionDecoder::Make(std::move(data)).release();
}
#endif // SK_ENABLE_ANDROID_UTILS

50
tests/BRDTest.cpp Normal file
View File

@ -0,0 +1,50 @@
/*
* Copyright 2020 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
// Make sure SkUserConfig.h is included so #defines are available on
// Android.
#include "include/core/SkTypes.h"
#ifdef SK_ENABLE_ANDROID_UTILS
#include "client_utils/android/BitmapRegionDecoder.h"
#include "include/codec/SkAndroidCodec.h"
#include "include/codec/SkCodec.h"
#include "tests/Test.h"
#include "tools/Resources.h"
DEF_TEST(BRD_types, r) {
static const struct {
const char* name;
bool supported;
} gRec[] = {
{ "images/arrow.png", true },
{ "images/box.gif", false },
{ "images/baby_tux.webp", true },
{ "images/brickwork-texture.jpg", true },
{ "images/color_wheel.ico", false },
#ifdef SK_CODEC_DECODES_RAW
{ "images/sample_1mp.dng", false },
#endif
{ "images/mandrill.wbmp", false },
{ "images/randPixels.bmp", false },
};
for (const auto& rec : gRec) {
auto data = GetResourceAsData(rec.name);
if (!data) return;
REPORTER_ASSERT(r, SkCodec::MakeFromData(data) != nullptr);
REPORTER_ASSERT(r, SkAndroidCodec::MakeFromData(data) != nullptr);
auto brd = android::skia::BitmapRegionDecoder::Make(data);
if (rec.supported) {
if (!brd) ERRORF(r, "Failed to create BRD from %s", rec.name);
} else {
if (brd) ERRORF(r, "Should *not* create BRD from %s", rec.name);
}
}
}
#endif // SK_ENABLE_ANDROID_UTILS