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

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

Issue 2382663004: cc: Use medium filter quality for downscales. (Closed)
Patch Set: 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 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 gfx::Size target_size( 843 gfx::Size target_size(
844 SkScalarRoundToInt(std::abs(src_rect.width() * scale.width())), 844 SkScalarRoundToInt(std::abs(src_rect.width() * scale.width())),
845 SkScalarRoundToInt(std::abs(src_rect.height() * scale.height()))); 845 SkScalarRoundToInt(std::abs(src_rect.height() * scale.height())));
846 846
847 // Start with the quality that was requested. 847 // Start with the quality that was requested.
848 SkFilterQuality quality = image.filter_quality(); 848 SkFilterQuality quality = image.filter_quality();
849 849
850 // If we're not going to do a scale, we can use low filter quality. Note that 850 // If we're not going to do a scale, we can use low filter quality. Note that
851 // checking if the sizes are the same is better than checking if scale is 1.f, 851 // checking if the sizes are the same is better than checking if scale is 1.f,
852 // because even non-1 scale can result in the same (rounded) width/height. 852 // because even non-1 scale can result in the same (rounded) width/height.
853 // If either dimension is a downscale, then use mipmaps (medium filter
854 // quality).
853 if (target_size.width() == src_rect.width() && 855 if (target_size.width() == src_rect.width() &&
854 target_size.height() == src_rect.height()) { 856 target_size.height() == src_rect.height()) {
855 quality = std::min(quality, kLow_SkFilterQuality); 857 quality = std::min(quality, kLow_SkFilterQuality);
858 } else if (target_size.width() < src_rect.width() ||
859 target_size.height() < src_rect.height()) {
860 quality = std::min(quality, kMedium_SkFilterQuality);
856 } 861 }
857 862
858 // Drop from high to medium if the the matrix we applied wasn't decomposable, 863 // Drop from high to medium if the the matrix we applied wasn't decomposable,
859 // or if the scaled image will be too large. 864 // or if the scaled image will be too large.
860 if (quality == kHigh_SkFilterQuality) { 865 if (quality == kHigh_SkFilterQuality) {
861 if (!image.matrix_is_decomposable()) { 866 if (!image.matrix_is_decomposable()) {
862 quality = kMedium_SkFilterQuality; 867 quality = kMedium_SkFilterQuality;
863 } else { 868 } else {
864 base::CheckedNumeric<size_t> size = 4u; 869 base::CheckedNumeric<size_t> size = 4u;
865 size *= target_size.width(); 870 size *= target_size.width();
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() { 1077 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() {
1073 current_usage_bytes_ = 0; 1078 current_usage_bytes_ = 0;
1074 } 1079 }
1075 1080
1076 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() 1081 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe()
1077 const { 1082 const {
1078 return current_usage_bytes_.ValueOrDie(); 1083 return current_usage_bytes_.ValueOrDie();
1079 } 1084 }
1080 1085
1081 } // namespace cc 1086 } // 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