aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/images
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-09-12 15:49:37 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-12 15:49:37 -0700
commit029819baa37f2706e6669f97badb20d309568d7c (patch)
treede48b74f3e68202b26ef0ee0717d652921311ec3 /src/images
parentcdedd0e061f3f50cd217638c28b27d798d930896 (diff)
Disable png encodes from Alpha8, Float16
These don't behave as we would want anyway. They just copy to N32, and then encode. BUG=skia:5616 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2332743003 Review-Url: https://codereview.chromium.org/2332743003
Diffstat (limited to 'src/images')
-rw-r--r--src/images/SkPNGImageEncoder.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/images/SkPNGImageEncoder.cpp b/src/images/SkPNGImageEncoder.cpp
index b30cd2509a..3925f29be7 100644
--- a/src/images/SkPNGImageEncoder.cpp
+++ b/src/images/SkPNGImageEncoder.cpp
@@ -182,11 +182,10 @@ private:
};
bool SkPNGImageEncoder::onEncode(SkWStream* stream,
- const SkBitmap& originalBitmap,
+ const SkBitmap& bitmap,
int /*quality*/) {
- SkBitmap copy;
- const SkBitmap* bitmap = &originalBitmap;
- switch (originalBitmap.colorType()) {
+ const SkColorType ct = bitmap.colorType();
+ switch (ct) {
case kIndex_8_SkColorType:
case kGray_8_SkColorType:
case kRGBA_8888_SkColorType:
@@ -195,14 +194,10 @@ bool SkPNGImageEncoder::onEncode(SkWStream* stream,
case kRGB_565_SkColorType:
break;
default:
- // TODO(scroggo): support Alpha_8 as Grayscale(black)+Alpha
- if (originalBitmap.copyTo(&copy, kN32_SkColorType)) {
- bitmap = &copy;
- }
+ return false;
}
- SkColorType ct = bitmap->colorType();
- const SkAlphaType alphaType = bitmap->alphaType();
+ const SkAlphaType alphaType = bitmap.alphaType();
switch (alphaType) {
case kUnpremul_SkAlphaType:
if (kARGB_4444_SkColorType == ct) {
@@ -262,14 +257,14 @@ bool SkPNGImageEncoder::onEncode(SkWStream* stream,
return false;
}
- SkAutoLockPixels alp(*bitmap);
+ SkAutoLockPixels alp(bitmap);
// readyToDraw checks for pixels (and colortable if that is required)
- if (!bitmap->readyToDraw()) {
+ if (!bitmap.readyToDraw()) {
return false;
}
// we must do this after we have locked the pixels
- SkColorTable* ctable = bitmap->getColorTable();
+ SkColorTable* ctable = bitmap.getColorTable();
if (ctable) {
if (ctable->count() == 0) {
return false;
@@ -278,7 +273,7 @@ bool SkPNGImageEncoder::onEncode(SkWStream* stream,
bitDepth = computeBitDepth(ctable->count());
}
- return doEncode(stream, *bitmap, alphaType, colorType, bitDepth, ct, sig_bit);
+ return doEncode(stream, bitmap, alphaType, colorType, bitDepth, ct, sig_bit);
}
bool SkPNGImageEncoder::doEncode(SkWStream* stream, const SkBitmap& bitmap,