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

Unified Diff: src/images/SkImageDecoder_libpng.cpp

Issue 14645018: Support for libpng > 1.2. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Avoid touching png_ptr->pass on Android w/ libpng > 1.2. Created 7 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libpng.cpp
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index aec89489459fec613d04aa88b8fce632885e134f..0e02ccf08d1679e68716f7019e876b97fccd92f5 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -23,6 +23,23 @@ extern "C" {
#include "png.h"
}
+/* These were dropped in libpng >= 1.4 */
+#ifndef png_infopp_NULL
+#define png_infopp_NULL NULL
+#endif
+
+#ifndef png_bytepp_NULL
+#define png_bytepp_NULL NULL
+#endif
+
+#ifndef int_p_NULL
+#define int_p_NULL NULL
+#endif
+
+#ifndef png_flush_ptr_NULL
+#define png_flush_ptr_NULL NULL
+#endif
+
class SkPNGImageIndex {
public:
SkPNGImageIndex(png_structp png_ptr, png_infop info_ptr) {
@@ -90,7 +107,7 @@ private:
};
static void sk_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) {
- SkStream* sk_stream = (SkStream*) png_ptr->io_ptr;
+ SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr);
size_t bytes = sk_stream->read(data, length);
if (bytes != length) {
png_error(png_ptr, "Read Error!");
@@ -99,7 +116,7 @@ static void sk_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) {
#ifdef SK_BUILD_FOR_ANDROID
static void sk_seek_fn(png_structp png_ptr, png_uint_32 offset) {
- SkStream* sk_stream = (SkStream*) png_ptr->io_ptr;
+ SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr);
sk_stream->rewind();
(void)sk_stream->skip(offset);
}
@@ -240,7 +257,7 @@ bool SkPNGImageDecoder::onDecodeInit(SkStream* sk_stream, png_structp *png_ptrp,
}
/* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
if (colorType == PNG_COLOR_TYPE_GRAY && bitDepth < 8) {
- png_set_gray_1_2_4_to_8(png_ptr);
+ png_set_expand_gray_1_2_4_to_8(png_ptr);
}
/* Make a grayscale image into RGB. */
@@ -437,16 +454,16 @@ bool SkPNGImageDecoder::getBitmapConfig(png_structp png_ptr, png_infop info_ptr,
// check for sBIT chunk data, in case we should disable dithering because
// our data is not truely 8bits per component
- if (*doDitherp) {
+ png_color_8p sig_bit;
+ if (*doDitherp && png_get_sBIT(png_ptr, info_ptr, &sig_bit)) {
#if 0
- SkDebugf("----- sBIT %d %d %d %d\n", info_ptr->sig_bit.red,
- info_ptr->sig_bit.green, info_ptr->sig_bit.blue,
- info_ptr->sig_bit.alpha);
+ SkDebugf("----- sBIT %d %d %d %d\n", sig_bit->red, sig_bit->green,
+ sig_bit->blue, sig_bit->alpha);
#endif
// 0 seems to indicate no information available
- if (pos_le(info_ptr->sig_bit.red, SK_R16_BITS) &&
- pos_le(info_ptr->sig_bit.green, SK_G16_BITS) &&
- pos_le(info_ptr->sig_bit.blue, SK_B16_BITS)) {
+ if (pos_le(sig_bit->red, SK_R16_BITS) &&
+ pos_le(sig_bit->green, SK_G16_BITS) &&
+ pos_le(sig_bit->blue, SK_B16_BITS)) {
*doDitherp = false;
}
}
@@ -709,7 +726,14 @@ bool SkPNGImageDecoder::onDecodeRegion(SkBitmap* bm, const SkIRect& region) {
* and update info structure. REQUIRED if you are expecting libpng to
* update the palette for you (ie you selected such a transform above).
*/
+
+ // Direct access to png_ptr fields is deprecated in libpng > 1.2.
+#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
png_ptr->pass = 0;
scroggo 2013/05/02 15:06:37 There is a function call png_set_interlaced_pass,
+#else
+ // FIXME: Figure out what (if anything) to do when Android moves to
+ // libpng > 1.2.
+#endif
png_read_update_info(png_ptr, info_ptr);
int actualTop = rect.fTop;
@@ -817,7 +841,7 @@ bool SkPNGImageDecoder::onDecodeRegion(SkBitmap* bm, const SkIRect& region) {
#include "SkUnPreMultiply.h"
static void sk_write_fn(png_structp png_ptr, png_bytep data, png_size_t len) {
- SkWStream* sk_stream = (SkWStream*)png_ptr->io_ptr;
+ SkWStream* sk_stream = (SkWStream*)png_get_io_ptr(png_ptr);
if (!sk_stream->write(data, len)) {
png_error(png_ptr, "sk_write_fn Error!");
}
« 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