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

Side by Side Diff: src/images/SkImageDecoder_libpng.cpp

Issue 1506663002: SkPNGImageEncoder encodes all SkColorTypes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(&copy, 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
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);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698