Make SkAndroidCodec support wbmp

BUG=skia:

Review URL: https://codereview.chromium.org/1445643002
This commit is contained in:
msarett 2015-11-16 13:43:40 -08:00 committed by Commit bot
parent 3257c12220
commit 33c7623324
2 changed files with 29 additions and 13 deletions

View File

@ -345,32 +345,47 @@ static void push_codec_srcs(Path path) {
}
// https://bug.skia.org/4428
static const char* const exts[] = {
bool subset = false;
// The following image types are supported by BitmapRegionDecoder,
// so we will test full image decodes and subset decodes.
static const char* const subsetExts[] = {
"jpg", "jpeg", "png", "webp",
"JPG", "JPEG", "PNG", "WEBP",
};
bool supported = false;
for (const char* ext : exts) {
for (const char* ext : subsetExts) {
if (path.endsWith(ext)) {
supported = true;
subset = true;
break;
}
}
if (!supported) {
bool full = false;
// The following image types are only supported by BitmapFactory,
// so we only need to test full image decodes.
static const char* fullExts[] = {
"wbmp",
"WBMP",
};
for (const char* ext : fullExts) {
if (path.endsWith(ext)) {
full = true;
break;
}
}
if (!full && !subset) {
return;
}
const int sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
const AndroidCodecSrc::Mode androidModes[] = {
AndroidCodecSrc::kFullImage_Mode,
AndroidCodecSrc::kDivisor_Mode,
};
for (int sampleSize : sampleSizes) {
for (AndroidCodecSrc::Mode mode : androidModes) {
for (uint32_t i = 0; i < numColorTypes; i++) {
push_android_codec_src(path, mode, colorTypes[i], sampleSize);
for (uint32_t i = 0; i < numColorTypes; i++) {
push_android_codec_src(path, AndroidCodecSrc::kFullImage_Mode, colorTypes[i],
sampleSize);
if (subset) {
push_android_codec_src(path, AndroidCodecSrc::kDivisor_Mode, colorTypes[i],
sampleSize);
}
}
}

View File

@ -31,6 +31,7 @@ SkAndroidCodec* SkAndroidCodec::NewFromStream(SkStream* stream) {
return new SkWebpAdapterCodec((SkWebpCodec*) codec.detach());
case kPNG_SkEncodedFormat:
case kJPEG_SkEncodedFormat:
case kWBMP_SkEncodedFormat:
return new SkSampledCodec(codec.detach());
default:
// FIXME: SkSampledCodec is temporarily disabled for other formats