OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 if (0 != theTranspColor) { | 428 if (0 != theTranspColor) { |
429 reallyHasAlpha |= substituteTranspColor(decodedBitmap, theTranspColor); | 429 reallyHasAlpha |= substituteTranspColor(decodedBitmap, theTranspColor); |
430 } | 430 } |
431 if (reallyHasAlpha && this->getRequireUnpremultipliedColors() && | 431 if (reallyHasAlpha && this->getRequireUnpremultipliedColors() && |
432 SkBitmap::kARGB_8888_Config != decodedBitmap->config()) { | 432 SkBitmap::kARGB_8888_Config != decodedBitmap->config()) { |
433 // If the caller wants an unpremultiplied bitmap, and we let them get | 433 // If the caller wants an unpremultiplied bitmap, and we let them get |
434 // away with a config other than 8888, and it has alpha after all, | 434 // away with a config other than 8888, and it has alpha after all, |
435 // return false, since the result will have premultiplied colors. | 435 // return false, since the result will have premultiplied colors. |
436 return false; | 436 return false; |
437 } | 437 } |
438 if (SkBitmap::kA8_Config == decodedBitmap->config()) { | |
reed1
2013/10/08 16:25:57
Shouldn't this block be done before line 431?
| |
439 reallyHasAlpha = true; | |
reed1
2013/10/04 08:56:27
I thought this variable was set when we actually s
scroggo
2013/10/04 19:45:53
Setting the image to be opaque is an optimization
reed1
2013/10/07 13:31:39
Ah, I think I see. You're saying we don't always p
scroggo
2013/10/07 22:10:29
Sounds good to me. Uploaded https://codereview.chr
| |
440 } | |
438 decodedBitmap->setIsOpaque(!reallyHasAlpha); | 441 decodedBitmap->setIsOpaque(!reallyHasAlpha); |
439 return true; | 442 return true; |
440 } | 443 } |
441 | 444 |
442 | 445 |
443 | 446 |
444 bool SkPNGImageDecoder::getBitmapConfig(png_structp png_ptr, png_infop info_ptr, | 447 bool SkPNGImageDecoder::getBitmapConfig(png_structp png_ptr, png_infop info_ptr, |
445 SkBitmap::Config* SK_RESTRICT configp, | 448 SkBitmap::Config* SK_RESTRICT configp, |
446 bool* SK_RESTRICT hasAlphap, | 449 bool* SK_RESTRICT hasAlphap, |
447 SkPMColor* SK_RESTRICT theTranspColorp) { | 450 SkPMColor* SK_RESTRICT theTranspColorp) { |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
881 if (y < height - 1) { | 884 if (y < height - 1) { |
882 skip_src_rows(png_ptr, srcRow, sampler.srcDY() - 1); | 885 skip_src_rows(png_ptr, srcRow, sampler.srcDY() - 1); |
883 } | 886 } |
884 } | 887 } |
885 } | 888 } |
886 } | 889 } |
887 | 890 |
888 if (0 != theTranspColor) { | 891 if (0 != theTranspColor) { |
889 reallyHasAlpha |= substituteTranspColor(&decodedBitmap, theTranspColor); | 892 reallyHasAlpha |= substituteTranspColor(&decodedBitmap, theTranspColor); |
890 } | 893 } |
894 if (SkBitmap::kA8_Config == decodedBitmap.config()) { | |
895 reallyHasAlpha = true; | |
896 } | |
891 decodedBitmap.setIsOpaque(!reallyHasAlpha); | 897 decodedBitmap.setIsOpaque(!reallyHasAlpha); |
892 | 898 |
893 if (swapOnly) { | 899 if (swapOnly) { |
894 bm->swap(decodedBitmap); | 900 bm->swap(decodedBitmap); |
895 return true; | 901 return true; |
896 } | 902 } |
897 return this->cropBitmap(bm, &decodedBitmap, sampleSize, region.x(), region.y (), | 903 return this->cropBitmap(bm, &decodedBitmap, sampleSize, region.x(), region.y (), |
898 region.width(), region.height(), 0, rect.y()); | 904 region.width(), region.height(), 0, rect.y()); |
899 } | 905 } |
900 #endif | 906 #endif |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1196 return SkImageDecoder::kUnknown_Format; | 1202 return SkImageDecoder::kUnknown_Format; |
1197 } | 1203 } |
1198 | 1204 |
1199 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1205 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
1200 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; | 1206 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; |
1201 } | 1207 } |
1202 | 1208 |
1203 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); | 1209 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); |
1204 static SkImageDecoder_FormatReg gFormatReg(get_format_png); | 1210 static SkImageDecoder_FormatReg gFormatReg(get_format_png); |
1205 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); | 1211 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); |
OLD | NEW |