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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 png_structp fPng_ptr; | 71 png_structp fPng_ptr; |
72 png_infop fInfo_ptr; | 72 png_infop fInfo_ptr; |
73 SkColorType fColorType; | 73 SkColorType fColorType; |
74 }; | 74 }; |
75 | 75 |
76 class SkPNGImageDecoder : public SkImageDecoder { | 76 class SkPNGImageDecoder : public SkImageDecoder { |
77 public: | 77 public: |
78 SkPNGImageDecoder() { | 78 SkPNGImageDecoder() { |
79 fImageIndex = NULL; | 79 fImageIndex = NULL; |
80 } | 80 } |
81 Format getFormat() const SK_OVERRIDE { | 81 Format getFormat() const override { |
82 return kPNG_Format; | 82 return kPNG_Format; |
83 } | 83 } |
84 | 84 |
85 virtual ~SkPNGImageDecoder() { | 85 virtual ~SkPNGImageDecoder() { |
86 SkDELETE(fImageIndex); | 86 SkDELETE(fImageIndex); |
87 } | 87 } |
88 | 88 |
89 protected: | 89 protected: |
90 #ifdef SK_BUILD_FOR_ANDROID | 90 #ifdef SK_BUILD_FOR_ANDROID |
91 bool onBuildTileIndex(SkStreamRewindable *stream, int *width, int *height) S
K_OVERRIDE; | 91 bool onBuildTileIndex(SkStreamRewindable *stream, int *width, int *height) o
verride; |
92 bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& region) SK_OVERRIDE; | 92 bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& region) override; |
93 #endif | 93 #endif |
94 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE; | 94 Result onDecode(SkStream* stream, SkBitmap* bm, Mode) override; |
95 | 95 |
96 private: | 96 private: |
97 SkPNGImageIndex* fImageIndex; | 97 SkPNGImageIndex* fImageIndex; |
98 | 98 |
99 bool onDecodeInit(SkStream* stream, png_structp *png_ptrp, png_infop *info_p
trp); | 99 bool onDecodeInit(SkStream* stream, png_structp *png_ptrp, png_infop *info_p
trp); |
100 bool decodePalette(png_structp png_ptr, png_infop info_ptr, int bitDepth, | 100 bool decodePalette(png_structp png_ptr, png_infop info_ptr, int bitDepth, |
101 bool * SK_RESTRICT hasAlphap, bool *reallyHasAlphap, | 101 bool * SK_RESTRICT hasAlphap, bool *reallyHasAlphap, |
102 SkColorTable **colorTablep); | 102 SkColorTable **colorTablep); |
103 bool getBitmapColorType(png_structp, png_infop, SkColorType*, bool* hasAlpha
, | 103 bool getBitmapColorType(png_structp, png_infop, SkColorType*, bool* hasAlpha
, |
104 SkPMColor* theTranspColor); | 104 SkPMColor* theTranspColor); |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 SkPMColor c = *colors++; | 1094 SkPMColor c = *colors++; |
1095 palette[i].red = SkGetPackedR32(c); | 1095 palette[i].red = SkGetPackedR32(c); |
1096 palette[i].green = SkGetPackedG32(c); | 1096 palette[i].green = SkGetPackedG32(c); |
1097 palette[i].blue = SkGetPackedB32(c); | 1097 palette[i].blue = SkGetPackedB32(c); |
1098 } | 1098 } |
1099 return num_trans; | 1099 return num_trans; |
1100 } | 1100 } |
1101 | 1101 |
1102 class SkPNGImageEncoder : public SkImageEncoder { | 1102 class SkPNGImageEncoder : public SkImageEncoder { |
1103 protected: | 1103 protected: |
1104 bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) SK_OVERRID
E; | 1104 bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) override; |
1105 private: | 1105 private: |
1106 bool doEncode(SkWStream* stream, const SkBitmap& bm, | 1106 bool doEncode(SkWStream* stream, const SkBitmap& bm, |
1107 const bool& hasAlpha, int colorType, | 1107 const bool& hasAlpha, int colorType, |
1108 int bitDepth, SkColorType ct, | 1108 int bitDepth, SkColorType ct, |
1109 png_color_8& sig_bit); | 1109 png_color_8& sig_bit); |
1110 | 1110 |
1111 typedef SkImageEncoder INHERITED; | 1111 typedef SkImageEncoder INHERITED; |
1112 }; | 1112 }; |
1113 | 1113 |
1114 bool SkPNGImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int
/*quality*/) { | 1114 bool SkPNGImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int
/*quality*/) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 return SkImageDecoder::kUnknown_Format; | 1280 return SkImageDecoder::kUnknown_Format; |
1281 } | 1281 } |
1282 | 1282 |
1283 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1283 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
1284 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; | 1284 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; |
1285 } | 1285 } |
1286 | 1286 |
1287 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); | 1287 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); |
1288 static SkImageDecoder_FormatReg gFormatReg(get_format_png); | 1288 static SkImageDecoder_FormatReg gFormatReg(get_format_png); |
1289 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); | 1289 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); |
OLD | NEW |