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

Side by Side Diff: src/images/SkImageDecoder_libjpeg.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2007 The Android Open Source Project 2 * Copyright 2007 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 8
9 #include "SkImageDecoder.h" 9 #include "SkImageDecoder.h"
10 #include "SkImageEncoder.h" 10 #include "SkImageEncoder.h"
11 #include "SkJpegUtility.h" 11 #include "SkJpegUtility.h"
12 #include "SkColorPriv.h" 12 #include "SkColorPriv.h"
13 #include "SkDither.h" 13 #include "SkDither.h"
14 #include "SkScaledBitmapSampler.h" 14 #include "SkScaledBitmapSampler.h"
15 #include "SkStream.h" 15 #include "SkStream.h"
16 #include "SkTemplates.h" 16 #include "SkTemplates.h"
17 #include "SkTime.h" 17 #include "SkTime.h"
18 #include "SkUtils.h" 18 #include "SkUtils.h"
19 #include "SkRTConf.h"
19 #include "SkRect.h" 20 #include "SkRect.h"
20 #include "SkCanvas.h" 21 #include "SkCanvas.h"
21 22
22 #if defined(SK_DEBUG)
23 #include "SkRTConf.h" // SK_CONF_DECLARE
24 #endif // defined(SK_DEBUG)
25 23
26 #include <stdio.h> 24 #include <stdio.h>
27 extern "C" { 25 extern "C" {
28 #include "jpeglib.h" 26 #include "jpeglib.h"
29 #include "jerror.h" 27 #include "jerror.h"
30 } 28 }
31 29
32 // These enable timing code that report milliseconds for an encoding/decoding 30 // These enable timing code that report milliseconds for an encoding/decoding
33 //#define TIME_ENCODE 31 //#define TIME_ENCODE
34 //#define TIME_DECODE 32 //#define TIME_DECODE
35 33
36 // this enables our rgb->yuv code, which is faster than libjpeg on ARM 34 // this enables our rgb->yuv code, which is faster than libjpeg on ARM
37 #define WE_CONVERT_TO_YUV 35 #define WE_CONVERT_TO_YUV
38 36
39 // If ANDROID_RGB is defined by in the jpeg headers it indicates that jpeg offer s 37 // If ANDROID_RGB is defined by in the jpeg headers it indicates that jpeg offer s
40 // support for two additional formats (1) JCS_RGBA_8888 and (2) JCS_RGB_565. 38 // support for two additional formats (1) JCS_RGBA_8888 and (2) JCS_RGB_565.
41 39
42 #if defined(SK_DEBUG) 40 #if defined(SK_DEBUG)
41 #define DEFAULT_FOR_SUPPRESS_JPEG_IMAGE_DECODER_WARNINGS false
42 #else // !defined(SK_DEBUG)
43 #define DEFAULT_FOR_SUPPRESS_JPEG_IMAGE_DECODER_WARNINGS true
44 #endif // defined(SK_DEBUG)
43 SK_CONF_DECLARE(bool, c_suppressJPEGImageDecoderWarnings, 45 SK_CONF_DECLARE(bool, c_suppressJPEGImageDecoderWarnings,
44 "images.jpeg.suppressDecoderWarnings", false, 46 "images.jpeg.suppressDecoderWarnings",
45 "Suppress most JPG warnings when calling decode functions."); 47 DEFAULT_FOR_SUPPRESS_JPEG_IMAGE_DECODER_WARNINGS,
46 #endif // defined(SK_DEBUG) 48 "Suppress most JPG warnings when calling decode functions.");
47 49
48 ////////////////////////////////////////////////////////////////////////// 50 //////////////////////////////////////////////////////////////////////////
49 ////////////////////////////////////////////////////////////////////////// 51 //////////////////////////////////////////////////////////////////////////
50 52
51 static void overwrite_mem_buffer_size(jpeg_decompress_struct* cinfo) { 53 static void overwrite_mem_buffer_size(jpeg_decompress_struct* cinfo) {
52 #ifdef SK_BUILD_FOR_ANDROID 54 #ifdef SK_BUILD_FOR_ANDROID
53 /* Check if the device indicates that it has a large amount of system memory 55 /* Check if the device indicates that it has a large amount of system memory
54 * if so, increase the memory allocation to 30MB instead of the default 5MB. 56 * if so, increase the memory allocation to 30MB instead of the default 5MB.
55 */ 57 */
56 #ifdef ANDROID_LARGE_MEMORY_DEVICE 58 #ifdef ANDROID_LARGE_MEMORY_DEVICE
(...skipping 10 matching lines...) Expand all
67 static void do_nothing_emit_message(jpeg_common_struct*, int) { 69 static void do_nothing_emit_message(jpeg_common_struct*, int) {
68 /* do nothing */ 70 /* do nothing */
69 } 71 }
70 72
71 static void initialize_info(jpeg_decompress_struct* cinfo, skjpeg_source_mgr* sr c_mgr) { 73 static void initialize_info(jpeg_decompress_struct* cinfo, skjpeg_source_mgr* sr c_mgr) {
72 SkASSERT(cinfo != NULL); 74 SkASSERT(cinfo != NULL);
73 SkASSERT(src_mgr != NULL); 75 SkASSERT(src_mgr != NULL);
74 jpeg_create_decompress(cinfo); 76 jpeg_create_decompress(cinfo);
75 overwrite_mem_buffer_size(cinfo); 77 overwrite_mem_buffer_size(cinfo);
76 cinfo->src = src_mgr; 78 cinfo->src = src_mgr;
77 #if defined(SK_DEBUG)
78 /* To suppress warnings with a SK_DEBUG binary, set the 79 /* To suppress warnings with a SK_DEBUG binary, set the
79 * environment variable "skia_images_jpeg_suppressDecoderWarnings" 80 * environment variable "skia_images_jpeg_suppressDecoderWarnings"
80 * to "true". Inside a program that links to skia: 81 * to "true". Inside a program that links to skia:
81 * SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); */ 82 * SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); */
82 if (c_suppressJPEGImageDecoderWarnings) { 83 if (c_suppressJPEGImageDecoderWarnings) {
83 cinfo->err->emit_message = &do_nothing_emit_message; 84 cinfo->err->emit_message = &do_nothing_emit_message;
84 } 85 }
85 #else // Always suppress in release mode.
86 cinfo->err->emit_message = &do_nothing_emit_message;
87 #endif // defined(SK_DEBUG)
88 } 86 }
89 87
90 #ifdef SK_BUILD_FOR_ANDROID 88 #ifdef SK_BUILD_FOR_ANDROID
91 class SkJPEGImageIndex { 89 class SkJPEGImageIndex {
92 public: 90 public:
93 SkJPEGImageIndex(SkStreamRewindable* stream, SkImageDecoder* decoder) 91 SkJPEGImageIndex(SkStreamRewindable* stream, SkImageDecoder* decoder)
94 : fSrcMgr(stream, decoder) 92 : fSrcMgr(stream, decoder)
95 , fInfoInitialized(false) 93 , fInfoInitialized(false)
96 , fHuffmanCreated(false) 94 , fHuffmanCreated(false)
97 , fDecompressStarted(false) 95 , fDecompressStarted(false)
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 return SkImageDecoder::kUnknown_Format; 1198 return SkImageDecoder::kUnknown_Format;
1201 } 1199 }
1202 1200
1203 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { 1201 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) {
1204 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; 1202 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL;
1205 } 1203 }
1206 1204
1207 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); 1205 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory);
1208 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); 1206 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg);
1209 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); 1207 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory);
OLDNEW
« no previous file with comments | « no previous file | src/images/SkImageDecoder_libpng.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698