Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkImageDecoder.h" | 8 #include "SkImageDecoder.h" |
| 9 #include "SkImageEncoder.h" | 9 #include "SkImageEncoder.h" |
| 10 #include "SkColor.h" | 10 #include "SkColor.h" |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 820 bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) override; | 820 bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) override; |
| 821 private: | 821 private: |
| 822 bool doEncode(SkWStream* stream, const SkBitmap& bm, | 822 bool doEncode(SkWStream* stream, const SkBitmap& bm, |
| 823 const bool& hasAlpha, int colorType, | 823 const bool& hasAlpha, int colorType, |
| 824 int bitDepth, SkColorType ct, | 824 int bitDepth, SkColorType ct, |
| 825 png_color_8& sig_bit); | 825 png_color_8& sig_bit); |
| 826 | 826 |
| 827 typedef SkImageEncoder INHERITED; | 827 typedef SkImageEncoder INHERITED; |
| 828 }; | 828 }; |
| 829 | 829 |
| 830 bool SkPNGImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int /*quality*/) { | 830 bool SkPNGImageEncoder::onEncode(SkWStream* stream, |
| 831 const SkBitmap& originalBitmap, | |
| 832 int /*quality*/) { | |
| 833 SkBitmap copy; | |
| 834 bool useCopy = false; | |
|
scroggo
2015/12/07 17:05:45
I don't think this variable is necessary. Instead
hal.canary
2015/12/07 21:34:38
done.
| |
| 835 switch (originalBitmap.colorType()) { | |
| 836 case kIndex_8_SkColorType: | |
| 837 case kN32_SkColorType: | |
| 838 case kARGB_4444_SkColorType: | |
| 839 case kRGB_565_SkColorType: | |
| 840 break; | |
| 841 default: | |
|
scroggo
2015/12/07 17:05:45
So basically, what we are now supporting are:
- T
hal.canary
2015/12/07 21:34:38
I added TODOs and assigned them to you.
| |
| 842 if (originalBitmap.copyTo(©, kN32_SkColorType)) { | |
| 843 useCopy = true; | |
| 844 } | |
| 845 } | |
| 846 const SkBitmap& bitmap = useCopy ? copy : originalBitmap; | |
| 847 | |
| 831 SkColorType ct = bitmap.colorType(); | 848 SkColorType ct = bitmap.colorType(); |
| 832 | 849 |
| 833 const bool hasAlpha = !bitmap.isOpaque(); | 850 const bool hasAlpha = !bitmap.isOpaque(); |
| 834 int colorType = PNG_COLOR_MASK_COLOR; | 851 int colorType = PNG_COLOR_MASK_COLOR; |
| 835 int bitDepth = 8; // default for color | 852 int bitDepth = 8; // default for color |
| 836 png_color_8 sig_bit; | 853 png_color_8 sig_bit; |
| 837 | 854 |
| 838 switch (ct) { | 855 switch (ct) { |
| 839 case kIndex_8_SkColorType: | 856 case kIndex_8_SkColorType: |
| 840 colorType |= PNG_COLOR_MASK_PALETTE; | 857 colorType |= PNG_COLOR_MASK_PALETTE; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 996 return SkImageDecoder::kUnknown_Format; | 1013 return SkImageDecoder::kUnknown_Format; |
| 997 } | 1014 } |
| 998 | 1015 |
| 999 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1016 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
| 1000 return (SkImageEncoder::kPNG_Type == t) ? new SkPNGImageEncoder : nullptr; | 1017 return (SkImageEncoder::kPNG_Type == t) ? new SkPNGImageEncoder : nullptr; |
| 1001 } | 1018 } |
| 1002 | 1019 |
| 1003 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); | 1020 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); |
| 1004 static SkImageDecoder_FormatReg gFormatReg(get_format_png); | 1021 static SkImageDecoder_FormatReg gFormatReg(get_format_png); |
| 1005 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); | 1022 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); |
| OLD | NEW |