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

Side by Side Diff: cc/tiles/software_image_decode_cache.cc

Issue 2870753002: SW Image Decode Cache Low to Medium Quality for Downscale (Closed)
Patch Set: rebaseline Created 3 years, 7 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
« no previous file with comments | « no previous file | cc/tiles/software_image_decode_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/tiles/software_image_decode_cache.h" 5 #include "cc/tiles/software_image_decode_cache.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 gfx::Size target_size( 914 gfx::Size target_size(
915 SkScalarRoundToInt(std::abs(src_rect.width() * scale.width())), 915 SkScalarRoundToInt(std::abs(src_rect.width() * scale.width())),
916 SkScalarRoundToInt(std::abs(src_rect.height() * scale.height()))); 916 SkScalarRoundToInt(std::abs(src_rect.height() * scale.height())));
917 917
918 // Start with the quality that was requested. 918 // Start with the quality that was requested.
919 SkFilterQuality quality = image.filter_quality(); 919 SkFilterQuality quality = image.filter_quality();
920 920
921 // If we're not going to do a scale, we can use low filter quality. Note that 921 // If we're not going to do a scale, we can use low filter quality. Note that
922 // checking if the sizes are the same is better than checking if scale is 1.f, 922 // checking if the sizes are the same is better than checking if scale is 1.f,
923 // because even non-1 scale can result in the same (rounded) width/height. 923 // because even non-1 scale can result in the same (rounded) width/height.
924 // If either dimension is a downscale, then use mipmaps (medium filter 924 // If either dimension is a downscale, and the quality is not None (in which
925 // quality). 925 // case we need to preserve the pixelated scale), then use mipmaps (medium
926 // filter quality).
926 if (target_size.width() == src_rect.width() && 927 if (target_size.width() == src_rect.width() &&
927 target_size.height() == src_rect.height()) { 928 target_size.height() == src_rect.height()) {
928 quality = std::min(quality, kLow_SkFilterQuality); 929 quality = std::min(quality, kLow_SkFilterQuality);
929 } else if (target_size.width() < src_rect.width() || 930 } else if (quality != kNone_SkFilterQuality &&
930 target_size.height() < src_rect.height()) { 931 (target_size.width() < src_rect.width() ||
931 quality = std::min(quality, kMedium_SkFilterQuality); 932 target_size.height() < src_rect.height())) {
933 quality = kMedium_SkFilterQuality;
932 } 934 }
933 935
934 // Drop from high to medium if the the matrix we applied wasn't decomposable, 936 // Drop from high to medium if the the matrix we applied wasn't decomposable,
935 // or if the scaled image will be too large. 937 // or if the scaled image will be too large.
936 if (quality == kHigh_SkFilterQuality) { 938 if (quality == kHigh_SkFilterQuality) {
937 if (!image.matrix_is_decomposable()) { 939 if (!image.matrix_is_decomposable()) {
938 quality = kMedium_SkFilterQuality; 940 quality = kMedium_SkFilterQuality;
939 } else { 941 } else {
940 base::CheckedNumeric<size_t> size = 4u; 942 base::CheckedNumeric<size_t> size = 4u;
941 size *= target_size.width(); 943 size *= target_size.width();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 } 1181 }
1180 } 1182 }
1181 } 1183 }
1182 1184
1183 void SoftwareImageDecodeCache::OnPurgeMemory() { 1185 void SoftwareImageDecodeCache::OnPurgeMemory() {
1184 base::AutoLock lock(lock_); 1186 base::AutoLock lock(lock_);
1185 ReduceCacheUsageUntilWithinLimit(0); 1187 ReduceCacheUsageUntilWithinLimit(0);
1186 } 1188 }
1187 1189
1188 } // namespace cc 1190 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/tiles/software_image_decode_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698