| OLD | NEW |
| 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" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 "Suppress most JPG warnings when calling decode functions."); | 50 "Suppress most JPG warnings when calling decode functions."); |
| 51 SK_CONF_DECLARE(bool, c_suppressJPEGImageDecoderErrors, | 51 SK_CONF_DECLARE(bool, c_suppressJPEGImageDecoderErrors, |
| 52 "images.jpeg.suppressDecoderErrors", | 52 "images.jpeg.suppressDecoderErrors", |
| 53 DEFAULT_FOR_SUPPRESS_JPEG_IMAGE_DECODER_ERRORS, | 53 DEFAULT_FOR_SUPPRESS_JPEG_IMAGE_DECODER_ERRORS, |
| 54 "Suppress most JPG error messages when decode " | 54 "Suppress most JPG error messages when decode " |
| 55 "function fails."); | 55 "function fails."); |
| 56 | 56 |
| 57 ////////////////////////////////////////////////////////////////////////// | 57 ////////////////////////////////////////////////////////////////////////// |
| 58 ////////////////////////////////////////////////////////////////////////// | 58 ////////////////////////////////////////////////////////////////////////// |
| 59 | 59 |
| 60 static void overwrite_mem_buffer_size(jpeg_decompress_struct* cinfo) { | |
| 61 #ifdef SK_BUILD_FOR_ANDROID | |
| 62 /* Check if the device indicates that it has a large amount of system memory | |
| 63 * if so, increase the memory allocation to 30MB instead of the default 5MB. | |
| 64 */ | |
| 65 #ifdef ANDROID_LARGE_MEMORY_DEVICE | |
| 66 cinfo->mem->max_memory_to_use = 30 * 1024 * 1024; | |
| 67 #else | |
| 68 cinfo->mem->max_memory_to_use = 5 * 1024 * 1024; | |
| 69 #endif | |
| 70 #endif // SK_BUILD_FOR_ANDROID | |
| 71 } | |
| 72 | |
| 73 ////////////////////////////////////////////////////////////////////////// | |
| 74 ////////////////////////////////////////////////////////////////////////// | |
| 75 | |
| 76 static void do_nothing_emit_message(jpeg_common_struct*, int) { | 60 static void do_nothing_emit_message(jpeg_common_struct*, int) { |
| 77 /* do nothing */ | 61 /* do nothing */ |
| 78 } | 62 } |
| 79 static void do_nothing_output_message(j_common_ptr) { | 63 static void do_nothing_output_message(j_common_ptr) { |
| 80 /* do nothing */ | 64 /* do nothing */ |
| 81 } | 65 } |
| 82 | 66 |
| 83 static void initialize_info(jpeg_decompress_struct* cinfo, skjpeg_source_mgr* sr
c_mgr) { | 67 static void initialize_info(jpeg_decompress_struct* cinfo, skjpeg_source_mgr* sr
c_mgr) { |
| 84 SkASSERT(cinfo != NULL); | 68 SkASSERT(cinfo != NULL); |
| 85 SkASSERT(src_mgr != NULL); | 69 SkASSERT(src_mgr != NULL); |
| 86 jpeg_create_decompress(cinfo); | 70 jpeg_create_decompress(cinfo); |
| 87 overwrite_mem_buffer_size(cinfo); | |
| 88 cinfo->src = src_mgr; | 71 cinfo->src = src_mgr; |
| 89 /* To suppress warnings with a SK_DEBUG binary, set the | 72 /* To suppress warnings with a SK_DEBUG binary, set the |
| 90 * environment variable "skia_images_jpeg_suppressDecoderWarnings" | 73 * environment variable "skia_images_jpeg_suppressDecoderWarnings" |
| 91 * to "true". Inside a program that links to skia: | 74 * to "true". Inside a program that links to skia: |
| 92 * SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); */ | 75 * SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); */ |
| 93 if (c_suppressJPEGImageDecoderWarnings) { | 76 if (c_suppressJPEGImageDecoderWarnings) { |
| 94 cinfo->err->emit_message = &do_nothing_emit_message; | 77 cinfo->err->emit_message = &do_nothing_emit_message; |
| 95 } | 78 } |
| 96 /* To suppress error messages with a SK_DEBUG binary, set the | 79 /* To suppress error messages with a SK_DEBUG binary, set the |
| 97 * environment variable "skia_images_jpeg_suppressDecoderErrors" | 80 * environment variable "skia_images_jpeg_suppressDecoderErrors" |
| (...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 return SkImageDecoder::kUnknown_Format; | 1449 return SkImageDecoder::kUnknown_Format; |
| 1467 } | 1450 } |
| 1468 | 1451 |
| 1469 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { | 1452 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { |
| 1470 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; | 1453 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; |
| 1471 } | 1454 } |
| 1472 | 1455 |
| 1473 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); | 1456 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); |
| 1474 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); | 1457 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); |
| 1475 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); | 1458 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); |
| OLD | NEW |