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

Unified Diff: src/images/SkImageDecoder_libjpeg.cpp

Issue 1432863002: Revert of Change quality settings on SkImageDecoder_libjpeg (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_libjpeg.cpp
diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp
index 9de17337038d47dfc1b6b2f02605d7eb18de15d7..7216239e80b14b0f6e81dad66bdbfdcc4875a6d2 100644
--- a/src/images/SkImageDecoder_libjpeg.cpp
+++ b/src/images/SkImageDecoder_libjpeg.cpp
@@ -383,11 +383,35 @@
}
/**
+ * Common code for turning off upsampling and smoothing. Turning these
+ * off helps performance without showing noticable differences in the
+ * resulting bitmap.
+ */
+static void turn_off_visual_optimizations(jpeg_decompress_struct* cinfo) {
+ SkASSERT(cinfo != nullptr);
+ /* this gives about 30% performance improvement. In theory it may
+ reduce the visual quality, in practice I'm not seeing a difference
+ */
+ cinfo->do_fancy_upsampling = 0;
+
+ /* this gives another few percents */
+ cinfo->do_block_smoothing = 0;
+}
+
+/**
* Common code for setting the dct method.
*/
static void set_dct_method(const SkImageDecoder& decoder, jpeg_decompress_struct* cinfo) {
SkASSERT(cinfo != nullptr);
+#ifdef DCT_IFAST_SUPPORTED
+ if (decoder.getPreferQualityOverSpeed()) {
+ cinfo->dct_method = JDCT_ISLOW;
+ } else {
+ cinfo->dct_method = JDCT_IFAST;
+ }
+#else
cinfo->dct_method = JDCT_ISLOW;
+#endif
}
SkColorType SkJPEGImageDecoder::getBitmapColorType(jpeg_decompress_struct* cinfo) {
@@ -556,6 +580,8 @@
SkASSERT(1 == cinfo.scale_num);
cinfo.scale_denom = sampleSize;
+ turn_off_visual_optimizations(&cinfo);
+
const SkColorType colorType = this->getBitmapColorType(&cinfo);
const SkAlphaType alphaType = kAlpha_8_SkColorType == colorType ?
kPremul_SkAlphaType : kOpaque_SkAlphaType;
@@ -881,6 +907,8 @@
SkASSERT(1 == cinfo.scale_num);
cinfo.scale_denom = 1;
+ turn_off_visual_optimizations(&cinfo);
+
#ifdef ANDROID_RGB
cinfo.dither_mode = JDITHER_NONE;
#endif
@@ -954,6 +982,8 @@
// jpeg_init_read_tile_scanline will check out_color_space again after
// that change (when it calls jinit_color_deconverter).
(void) this->getBitmapColorType(cinfo);
+
+ turn_off_visual_optimizations(cinfo);
// instead of jpeg_start_decompress() we start a tiled decompress
if (!imageIndex->startTileDecompress()) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698