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

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

Issue 2361243002: cc: Use medium filter quality for downscales. (Closed)
Patch Set: update Created 4 years, 2 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_controller_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_controller.h" 5 #include "cc/tiles/software_image_decode_controller.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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 gfx::Size target_size( 853 gfx::Size target_size(
854 SkScalarRoundToInt(std::abs(src_rect.width() * scale.width())), 854 SkScalarRoundToInt(std::abs(src_rect.width() * scale.width())),
855 SkScalarRoundToInt(std::abs(src_rect.height() * scale.height()))); 855 SkScalarRoundToInt(std::abs(src_rect.height() * scale.height())));
856 856
857 // Start with the quality that was requested. 857 // Start with the quality that was requested.
858 SkFilterQuality quality = image.filter_quality(); 858 SkFilterQuality quality = image.filter_quality();
859 859
860 // If we're not going to do a scale, we can use low filter quality. Note that 860 // If we're not going to do a scale, we can use low filter quality. Note that
861 // checking if the sizes are the same is better than checking if scale is 1.f, 861 // checking if the sizes are the same is better than checking if scale is 1.f,
862 // because even non-1 scale can result in the same (rounded) width/height. 862 // because even non-1 scale can result in the same (rounded) width/height.
863 // If either dimension is a downscale, then use mipmaps (medium filter
864 // quality).
863 if (target_size.width() == src_rect.width() && 865 if (target_size.width() == src_rect.width() &&
864 target_size.height() == src_rect.height()) { 866 target_size.height() == src_rect.height()) {
865 quality = std::min(quality, kLow_SkFilterQuality); 867 quality = std::min(quality, kLow_SkFilterQuality);
868 } else if (target_size.width() < src_rect.width() ||
869 target_size.height() < src_rect.height()) {
870 quality = std::min(quality, kMedium_SkFilterQuality);
866 } 871 }
867 872
868 // Drop from high to medium if the the matrix we applied wasn't decomposable, 873 // Drop from high to medium if the the matrix we applied wasn't decomposable,
869 // or if the scaled image will be too large. 874 // or if the scaled image will be too large.
870 if (quality == kHigh_SkFilterQuality) { 875 if (quality == kHigh_SkFilterQuality) {
871 if (!image.matrix_is_decomposable()) { 876 if (!image.matrix_is_decomposable()) {
872 quality = kMedium_SkFilterQuality; 877 quality = kMedium_SkFilterQuality;
873 } else { 878 } else {
874 base::CheckedNumeric<size_t> size = 4u; 879 base::CheckedNumeric<size_t> size = 4u;
875 size *= target_size.width(); 880 size *= target_size.width();
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 break; 1109 break;
1105 case base::MemoryState::UNKNOWN: 1110 case base::MemoryState::UNKNOWN:
1106 NOTREACHED(); 1111 NOTREACHED();
1107 return; 1112 return;
1108 } 1113 }
1109 } 1114 }
1110 ReduceCacheUsage(); 1115 ReduceCacheUsage();
1111 } 1116 }
1112 1117
1113 } // namespace cc 1118 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/tiles/software_image_decode_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698