Make SkAndroidCodec support bmp

BUG=skia:

Review URL: https://codereview.chromium.org/1443783002
This commit is contained in:
msarett 2015-11-17 08:46:02 -08:00 committed by Commit bot
parent 195fe08421
commit 887e18e5f7
3 changed files with 41 additions and 2 deletions

View File

@ -363,8 +363,8 @@ static void push_codec_srcs(Path path) {
// The following image types are only supported by BitmapFactory,
// so we only need to test full image decodes.
static const char* fullExts[] = {
"wbmp",
"WBMP",
"wbmp", "bmp",
"WBMP", "BMP",
};
for (const char* ext : fullExts) {
if (path.endsWith(ext)) {

View File

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

View File

@ -226,6 +226,44 @@ SkCodec::Result SkSampledCodec::sampledDecode(const SkImageInfo& info, void* pix
}
return SkCodec::kSuccess;
}
case SkCodec::kBottomUp_SkScanlineOrder: {
// Note that this mode does not support subsetting.
SkASSERT(0 == subsetY && nativeSize.height() == subsetHeight);
int y;
for (y = 0; y < nativeSize.height(); y++) {
int srcY = fCodec->nextScanline();
if (is_coord_necessary(srcY, sampleY, dstHeight)) {
void* pixelPtr = SkTAddOffset<void>(pixels,
rowBytes * get_dst_coord(srcY, sampleY));
if (1 != fCodec->getScanlines(pixelPtr, 1, rowBytes)) {
break;
}
} else {
if (!fCodec->skipScanlines(1)) {
break;
}
}
}
if (nativeSize.height() == y) {
return SkCodec::kSuccess;
}
// We handle filling uninitialized memory here instead of using fCodec.
// fCodec does not know that we are sampling.
const uint32_t fillValue = fCodec->getFillValue(info.colorType(), info.alphaType());
const SkImageInfo fillInfo = info.makeWH(info.width(), 1);
for (; y < nativeSize.height(); y++) {
int srcY = fCodec->outputScanline(y);
if (!is_coord_necessary(srcY, sampleY, dstHeight)) {
continue;
}
void* rowPtr = SkTAddOffset<void>(pixels, rowBytes * get_dst_coord(srcY, sampleY));
SkSampler::Fill(fillInfo, rowPtr, rowBytes, fillValue, options.fZeroInitialized);
}
return SkCodec::kIncompleteInput;
}
case SkCodec::kNone_SkScanlineOrder: {
const int linesNeeded = subsetHeight - samplingOffsetY;
SkAutoMalloc storage(linesNeeded * rowBytes);