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

Side by Side Diff: src/codec/SkJpegDecoderMgr.cpp

Issue 1103313002: Eliminate the check for ANDROID_LARGE_MEMORY in jpeg decoders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Never overwrite default memory Created 5 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
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 #include "SkJpegDecoderMgr.h" 8 #include "SkJpegDecoderMgr.h"
9 #include "SkJpegUtility.h" 9 #include "SkJpegUtility.h"
10 10
11 /* 11 /*
12 * Print information, warning, and error messages 12 * Print information, warning, and error messages
13 */ 13 */
14 static void print_message(const j_common_ptr info, const char caller[]) { 14 static void print_message(const j_common_ptr info, const char caller[]) {
15 char buffer[JMSG_LENGTH_MAX]; 15 char buffer[JMSG_LENGTH_MAX];
16 info->err->format_message(info, buffer); 16 info->err->format_message(info, buffer);
17 SkCodecPrintf("libjpeg error %d <%s> from %s\n", info->err->msg_code, buffer , caller); 17 SkCodecPrintf("libjpeg error %d <%s> from %s\n", info->err->msg_code, buffer , caller);
18 } 18 }
19 19
20 /* 20 /*
21 * Reporting functions for libjpeg 21 * Reporting functions for libjpeg
22 */ 22 */
23 static void emit_message(j_common_ptr info, int) { 23 static void emit_message(j_common_ptr info, int) {
24 print_message(info, "emit_message"); 24 print_message(info, "emit_message");
25 } 25 }
26 static void output_message(j_common_ptr info) { 26 static void output_message(j_common_ptr info) {
27 print_message(info, "output_message"); 27 print_message(info, "output_message");
28 } 28 }
29 29
30 /*
31 * Choose the size of the memory buffer on Android
32 */
33 static void overwrite_mem_buffer_size(jpeg_decompress_struct* dinfo) {
34 #ifdef SK_BUILD_FOR_ANDROID
35
36 // Use 30 MB for devices with a large amount of system memory and 5MB otherwise
37 // TODO: (msarett) This matches SkImageDecoder. Why were these values chosen?
38 #ifdef ANDROID_LARGE_MEMORY_DEVICE
39 dinfo->mem->max_memory_to_use = 30 * 1024 * 1024;
40 #else
41 dinfo->mem->max_memory_to_use = 5 * 1024 * 1024;
42 #endif
43
44 #endif // SK_BUILD_FOR_ANDROID
45 }
46
47 bool JpegDecoderMgr::returnFalse(const char caller[]) { 30 bool JpegDecoderMgr::returnFalse(const char caller[]) {
48 print_message((j_common_ptr) &fDInfo, caller); 31 print_message((j_common_ptr) &fDInfo, caller);
49 return false; 32 return false;
50 } 33 }
51 34
52 SkCodec::Result JpegDecoderMgr::returnFailure(const char caller[], SkCodec::Resu lt result) { 35 SkCodec::Result JpegDecoderMgr::returnFailure(const char caller[], SkCodec::Resu lt result) {
53 print_message((j_common_ptr) &fDInfo, caller); 36 print_message((j_common_ptr) &fDInfo, caller);
54 return result; 37 return result;
55 } 38 }
56 39
(...skipping 25 matching lines...) Expand all
82 { 65 {
83 // Error manager must be set before any calls to libjeg in order to handle f ailures 66 // Error manager must be set before any calls to libjeg in order to handle f ailures
84 fDInfo.err = jpeg_std_error(&fErrorMgr); 67 fDInfo.err = jpeg_std_error(&fErrorMgr);
85 fErrorMgr.error_exit = skjpeg_err_exit; 68 fErrorMgr.error_exit = skjpeg_err_exit;
86 } 69 }
87 70
88 void JpegDecoderMgr::init() { 71 void JpegDecoderMgr::init() {
89 jpeg_create_decompress(&fDInfo); 72 jpeg_create_decompress(&fDInfo);
90 fInit = true; 73 fInit = true;
91 fDInfo.src = &fSrcMgr; 74 fDInfo.src = &fSrcMgr;
92 overwrite_mem_buffer_size(&fDInfo);
93 fDInfo.err->emit_message = &emit_message; 75 fDInfo.err->emit_message = &emit_message;
94 fDInfo.err->output_message = &output_message; 76 fDInfo.err->output_message = &output_message;
95 } 77 }
96 78
97 JpegDecoderMgr::~JpegDecoderMgr() { 79 JpegDecoderMgr::~JpegDecoderMgr() {
98 if (fInit) { 80 if (fInit) {
99 jpeg_destroy_decompress(&fDInfo); 81 jpeg_destroy_decompress(&fDInfo);
100 } 82 }
101 } 83 }
102 84
103 jmp_buf& JpegDecoderMgr::getJmpBuf() { 85 jmp_buf& JpegDecoderMgr::getJmpBuf() {
104 return fErrorMgr.fJmpBuf; 86 return fErrorMgr.fJmpBuf;
105 } 87 }
106 88
107 jpeg_decompress_struct* JpegDecoderMgr::dinfo() { 89 jpeg_decompress_struct* JpegDecoderMgr::dinfo() {
108 return &fDInfo; 90 return &fDInfo;
109 } 91 }
OLDNEW
« no previous file with comments | « platform_tools/android/tests/expectations/Android.mk ('k') | src/images/SkImageDecoder_libjpeg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698