| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 if (status != JPEG_HEADER_OK) { | 261 if (status != JPEG_HEADER_OK) { |
| 262 return return_false(cinfo, *bm, "read_header"); | 262 return return_false(cinfo, *bm, "read_header"); |
| 263 } | 263 } |
| 264 | 264 |
| 265 /* Try to fulfill the requested sampleSize. Since jpeg can do it (when it | 265 /* Try to fulfill the requested sampleSize. Since jpeg can do it (when it |
| 266 can) much faster that we, just use their num/denom api to approximate | 266 can) much faster that we, just use their num/denom api to approximate |
| 267 the size. | 267 the size. |
| 268 */ | 268 */ |
| 269 int sampleSize = this->getSampleSize(); | 269 int sampleSize = this->getSampleSize(); |
| 270 | 270 |
| 271 #ifdef DCT_IFAST_SUPPORTED |
| 271 if (this->getPreferQualityOverSpeed()) { | 272 if (this->getPreferQualityOverSpeed()) { |
| 272 cinfo.dct_method = JDCT_ISLOW; | 273 cinfo.dct_method = JDCT_ISLOW; |
| 273 } else { | 274 } else { |
| 274 cinfo.dct_method = JDCT_IFAST; | 275 cinfo.dct_method = JDCT_IFAST; |
| 275 } | 276 } |
| 277 #else |
| 278 cinfo.dct_method = JDCT_ISLOW; |
| 279 #endif |
| 276 | 280 |
| 277 cinfo.scale_num = 1; | 281 cinfo.scale_num = 1; |
| 278 cinfo.scale_denom = sampleSize; | 282 cinfo.scale_denom = sampleSize; |
| 279 | 283 |
| 280 /* this gives about 30% performance improvement. In theory it may | 284 /* this gives about 30% performance improvement. In theory it may |
| 281 reduce the visual quality, in practice I'm not seeing a difference | 285 reduce the visual quality, in practice I'm not seeing a difference |
| 282 */ | 286 */ |
| 283 cinfo.do_fancy_upsampling = 0; | 287 cinfo.do_fancy_upsampling = 0; |
| 284 | 288 |
| 285 /* this gives another few percents */ | 289 /* this gives another few percents */ |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 return SkNEW(SkJPEGImageDecoder); | 1014 return SkNEW(SkJPEGImageDecoder); |
| 1011 } | 1015 } |
| 1012 | 1016 |
| 1013 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { | 1017 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { |
| 1014 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; | 1018 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; |
| 1015 } | 1019 } |
| 1016 | 1020 |
| 1017 | 1021 |
| 1018 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libjpeg_dfactory); | 1022 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libjpeg_dfactory); |
| 1019 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libjpeg_efact
ory); | 1023 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libjpeg_efact
ory); |
| OLD | NEW |