aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/images/SkImageDecoder_libpng.cpp
diff options
context:
space:
mode:
authorGravatar scroggo <scroggo@google.com>2015-10-14 07:54:34 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-14 07:54:34 -0700
commit8e48ed51baf0099d0a279474f6fc01a3ab857d60 (patch)
treed56c94d90234cc6c8cd53d677d3cec6e95cd46ac /src/images/SkImageDecoder_libpng.cpp
parent94dd7a52d3fe0632cd830f2e9cd14103c2726aac (diff)
Supply separate flags for onBuildTileIndex
Since png and jpeg's implementations of onBuildTileIndex rely on modifications to their underlying libraries, rather than whether we are running on Android, use separate flags that can be disabled independently. This will allow us to easily turn off the feature. It also is a step towards building and running on other platforms for testing (e.g. valgrind/ASAN to find memory leaks etc). Review URL: https://codereview.chromium.org/1401283003
Diffstat (limited to 'src/images/SkImageDecoder_libpng.cpp')
-rw-r--r--src/images/SkImageDecoder_libpng.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index 31ec4dd48a..aded29cd96 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -52,7 +52,9 @@ SK_CONF_DECLARE(bool, c_suppressPNGImageDecoderWarnings,
"Suppress most PNG warnings when calling image decode "
"functions.");
-
+#if defined(SK_BUILD_FOR_ANDROID) && !defined(SK_PNG_NO_INDEX_SUPPORTED)
+#define SK_PNG_INDEX_SUPPORTED
+#endif
class SkPNGImageIndex {
public:
@@ -88,7 +90,7 @@ public:
virtual ~SkPNGImageDecoder() { delete fImageIndex; }
protected:
-#ifdef SK_BUILD_FOR_ANDROID
+#ifdef SK_PNG_INDEX_SUPPORTED
bool onBuildTileIndex(SkStreamRewindable *stream, int *width, int *height) override;
bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& region) override;
#endif
@@ -132,7 +134,7 @@ static void sk_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) {
}
}
-#ifdef SK_BUILD_FOR_ANDROID
+#ifdef SK_PNG_INDEX_SUPPORTED
static void sk_seek_fn(png_structp png_ptr, png_uint_32 offset) {
SkStreamRewindable* sk_stream = (SkStreamRewindable*) png_get_io_ptr(png_ptr);
if (!sk_stream->rewind()) {
@@ -262,7 +264,7 @@ bool SkPNGImageDecoder::onDecodeInit(SkStream* sk_stream, png_structp *png_ptrp,
* png_init_io() here you would call:
*/
png_set_read_fn(png_ptr, (void *)sk_stream, sk_read_fn);
-#ifdef SK_BUILD_FOR_ANDROID
+#ifdef SK_PNG_INDEX_SUPPORTED
png_set_seek_fn(png_ptr, sk_seek_fn);
#endif
/* where user_io_ptr is a structure you want available to the callbacks */
@@ -726,7 +728,7 @@ bool SkPNGImageDecoder::decodePalette(png_structp png_ptr, png_infop info_ptr,
return true;
}
-#ifdef SK_BUILD_FOR_ANDROID
+#ifdef SK_PNG_INDEX_SUPPORTED
bool SkPNGImageDecoder::onBuildTileIndex(SkStreamRewindable* sk_stream, int *width, int *height) {
SkAutoTDelete<SkStreamRewindable> streamDeleter(sk_stream);