Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: src/codec/SkCodec_libpng.cpp

Issue 947283002: Bmp Image Decoding (Closed) Base URL: https://skia.googlesource.com/skia.git@decode-leon-3
Patch Set: Various fixes from Leon's comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/codec/SkCodec_libpng.cpp
diff --git a/src/codec/SkCodec_libpng.cpp b/src/codec/SkCodec_libpng.cpp
index 8e7ee33a9554bce341cf8681b2db86d334bfae1b..d97aeab847df37a04ca7cd039e869eb4c6d228ca 100644
--- a/src/codec/SkCodec_libpng.cpp
+++ b/src/codec/SkCodec_libpng.cpp
@@ -346,10 +346,6 @@ SkPngCodec::~SkPngCodec() {
// Getting the pixels
///////////////////////////////////////////////////////////////////////////////
-static bool premul_and_unpremul(SkAlphaType A, SkAlphaType B) {
- return kPremul_SkAlphaType == A && kUnpremul_SkAlphaType == B;
-}
-
static bool conversion_possible(const SkImageInfo& A, const SkImageInfo& B) {
// TODO: Support other conversions
if (A.colorType() != B.colorType()) {
@@ -361,8 +357,8 @@ static bool conversion_possible(const SkImageInfo& A, const SkImageInfo& B) {
if (A.alphaType() == B.alphaType()) {
return true;
}
- return premul_and_unpremul(A.alphaType(), B.alphaType())
- || premul_and_unpremul(B.alphaType(), A.alphaType());
+ return SkCodec::premul_and_unpremul(A.alphaType(), B.alphaType())
+ || SkCodec::premul_and_unpremul(B.alphaType(), A.alphaType());
}
SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void* dst,
@@ -466,7 +462,7 @@ SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void*
// Now swizzle it.
uint8_t* row = base;
for (int y = 0; y < height; y++) {
- reallyHasAlpha |= swizzler->next(row);
+ reallyHasAlpha |= !SkSwizzler::IsOpaque(swizzler->next(row));
row += rowBytes;
}
} else {
@@ -474,7 +470,7 @@ SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& requestedInfo, void*
uint8_t* srcRow = static_cast<uint8_t*>(storage.get());
for (int y = 0; y < requestedInfo.height(); y++) {
png_read_rows(fPng_ptr, &srcRow, png_bytepp_NULL, 1);
- reallyHasAlpha |= swizzler->next(srcRow);
+ reallyHasAlpha |= !SkSwizzler::IsOpaque(swizzler->next(srcRow));
}
}

Powered by Google App Engine
This is Rietveld 408576698