aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-14 12:49:15 +0000
committerGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-14 12:49:15 +0000
commit2a10318814fa9f2dd70122bf58d994b19bb9a8cf (patch)
treea41decd6cf489ee91c14a37b9e8790878590ea16
parent805ca19625ff477bf1354fa0a1c7cacebccd8940 (diff)
Simplify code for configuring suppression of ImageDecoder warnings
For images.png.suppressDecoderWarnings and images.jpeg.suppressDecoderWarnings, the default behavior is now: Debug - DON'T suppress Developer Release - suppress Release - suppress This behavior can be changed in Debug and in Developer through the SkRTConf mechanism. BUG=skia:1680 R=caryclark@google.com Review URL: https://codereview.chromium.org/26863003 git-svn-id: http://skia.googlecode.com/svn/trunk@11749 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--src/images/SkImageDecoder_libjpeg.cpp18
-rw-r--r--src/images/SkImageDecoder_libpng.cpp24
2 files changed, 19 insertions, 23 deletions
diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp
index 3e34a277fd..6430951418 100644
--- a/src/images/SkImageDecoder_libjpeg.cpp
+++ b/src/images/SkImageDecoder_libjpeg.cpp
@@ -16,12 +16,10 @@
#include "SkTemplates.h"
#include "SkTime.h"
#include "SkUtils.h"
+#include "SkRTConf.h"
#include "SkRect.h"
#include "SkCanvas.h"
-#if defined(SK_DEBUG)
-#include "SkRTConf.h" // SK_CONF_DECLARE
-#endif // defined(SK_DEBUG)
#include <stdio.h>
extern "C" {
@@ -40,10 +38,14 @@ extern "C" {
// support for two additional formats (1) JCS_RGBA_8888 and (2) JCS_RGB_565.
#if defined(SK_DEBUG)
-SK_CONF_DECLARE(bool, c_suppressJPEGImageDecoderWarnings,
- "images.jpeg.suppressDecoderWarnings", false,
- "Suppress most JPG warnings when calling decode functions.");
+#define DEFAULT_FOR_SUPPRESS_JPEG_IMAGE_DECODER_WARNINGS false
+#else // !defined(SK_DEBUG)
+#define DEFAULT_FOR_SUPPRESS_JPEG_IMAGE_DECODER_WARNINGS true
#endif // defined(SK_DEBUG)
+SK_CONF_DECLARE(bool, c_suppressJPEGImageDecoderWarnings,
+ "images.jpeg.suppressDecoderWarnings",
+ DEFAULT_FOR_SUPPRESS_JPEG_IMAGE_DECODER_WARNINGS,
+ "Suppress most JPG warnings when calling decode functions.");
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
@@ -74,7 +76,6 @@ static void initialize_info(jpeg_decompress_struct* cinfo, skjpeg_source_mgr* sr
jpeg_create_decompress(cinfo);
overwrite_mem_buffer_size(cinfo);
cinfo->src = src_mgr;
-#if defined(SK_DEBUG)
/* To suppress warnings with a SK_DEBUG binary, set the
* environment variable "skia_images_jpeg_suppressDecoderWarnings"
* to "true". Inside a program that links to skia:
@@ -82,9 +83,6 @@ static void initialize_info(jpeg_decompress_struct* cinfo, skjpeg_source_mgr* sr
if (c_suppressJPEGImageDecoderWarnings) {
cinfo->err->emit_message = &do_nothing_emit_message;
}
-#else // Always suppress in release mode.
- cinfo->err->emit_message = &do_nothing_emit_message;
-#endif // defined(SK_DEBUG)
}
#ifdef SK_BUILD_FOR_ANDROID
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index 951083b0f4..5fc9350b51 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);