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

Unified Diff: src/images/SkImageDecoder_libpng.cpp

Issue 26863003: Simplify code for configuring suppression of ImageDecoder warnings (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebased again Created 7 years, 2 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 | « src/images/SkImageDecoder_libjpeg.cpp ('k') | 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 951083b0f467d4ad9e31889447f05009f6090916..5fc9350b519e23d691bb368aac9cef8d3a0d726b 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -13,16 +13,12 @@
#include "SkColorPriv.h"
#include "SkDither.h"
#include "SkMath.h"
+#include "SkRTConf.h"
#include "SkScaledBitmapSampler.h"
#include "SkStream.h"
#include "SkTemplates.h"
#include "SkUtils.h"
#include "transform_scanline.h"
-
-#if defined(SK_DEBUG)
-#include "SkRTConf.h" // SK_CONF_DECLARE
-#endif // defined(SK_DEBUG)
-
extern "C" {
#include "png.h"
}
@@ -45,10 +41,16 @@ extern "C" {
#endif
#if defined(SK_DEBUG)
-SK_CONF_DECLARE(bool, c_suppressPNGImageDecoderWarnings,
- "images.png.suppressDecoderWarnings", false,
- "Suppress most PNG warnings when calling image decode functions.");
+#define DEFAULT_FOR_SUPPRESS_PNG_IMAGE_DECODER_WARNINGS false
+#else // !defined(SK_DEBUG)
+#define DEFAULT_FOR_SUPPRESS_PNG_IMAGE_DECODER_WARNINGS true
#endif // defined(SK_DEBUG)
+SK_CONF_DECLARE(bool, c_suppressPNGImageDecoderWarnings,
+ "images.png.suppressDecoderWarnings",
+ DEFAULT_FOR_SUPPRESS_PNG_IMAGE_DECODER_WARNINGS,
+ "Suppress most PNG warnings when calling image decode "
+ "functions.");
+
class SkPNGImageIndex {
@@ -222,18 +224,14 @@ bool SkPNGImageDecoder::onDecodeInit(SkStream* sk_stream, png_structp *png_ptrp,
* the compiler header file version, so that we know if the application
* was compiled with a compatible version of the library. */
-#if defined(SK_DEBUG)
png_error_ptr user_warning_fn =
(c_suppressPNGImageDecoderWarnings) ? (&do_nothing_warning_fn) : NULL;
/* NULL means to leave as default library behavior. */
- /* c_suppressPNGImageDecoderWarnings defaults to false. */
+ /* c_suppressPNGImageDecoderWarnings default depends on SK_DEBUG. */
/* To suppress warnings with a SK_DEBUG binary, set the
* environment variable "skia_images_png_suppressDecoderWarnings"
* to "true". Inside a program that links to skia:
* SK_CONF_SET("images.png.suppressDecoderWarnings", true); */
-#else // Always suppress in release mode
- png_error_ptr user_warning_fn = &do_nothing_warning_fn;
-#endif // defined(SK_DEBUG)
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
NULL, sk_error_fn, user_warning_fn);
« no previous file with comments | « src/images/SkImageDecoder_libjpeg.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698