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

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

Issue 2361243002: cc: Use medium filter quality for downscales. (Closed)
Patch Set: Created 4 years, 3 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 | no next file » | 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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 << line; 827 << line;
828 } 828 }
829 } 829 }
830 DCHECK_GE(budget.AvailableMemoryBytes(), 830 DCHECK_GE(budget.AvailableMemoryBytes(),
831 locked_images_budget_.AvailableMemoryBytes()) 831 locked_images_budget_.AvailableMemoryBytes())
832 << line; 832 << line;
833 #endif // DCHECK_IS_ON() 833 #endif // DCHECK_IS_ON()
834 } 834 }
835 835
836 // SoftwareImageDecodeControllerKey 836 // SoftwareImageDecodeControllerKey
837 ImageDecodeControllerKey ImageDecodeControllerKey::FromDrawImage( 837 ImageDecodeControllerKey ImageDecodeControllerKey::FromDrawImage(
chrishtr 2016/09/22 21:30:27 unittest this method
vmpstr 2016/09/22 21:38:41 Good idea. Done.
838 const DrawImage& image) { 838 const DrawImage& image) {
839 const SkSize& scale = image.scale(); 839 const SkSize& scale = image.scale();
840 // If the src_rect falls outside of the image, we need to clip it since 840 // If the src_rect falls outside of the image, we need to clip it since
841 // otherwise we might end up with uninitialized memory in the decode process. 841 // otherwise we might end up with uninitialized memory in the decode process.
842 // Note that the scale is still unchanged and the target size is now a 842 // Note that the scale is still unchanged and the target size is now a
843 // function of the new src_rect. 843 // function of the new src_rect.
844 gfx::Rect src_rect = gfx::IntersectRects( 844 gfx::Rect src_rect = gfx::IntersectRects(
845 gfx::SkIRectToRect(image.src_rect()), 845 gfx::SkIRectToRect(image.src_rect()),
846 gfx::Rect(image.image()->width(), image.image()->height())); 846 gfx::Rect(image.image()->width(), image.image()->height()));
847 847
848 gfx::Size target_size( 848 gfx::Size target_size(
849 SkScalarRoundToInt(std::abs(src_rect.width() * scale.width())), 849 SkScalarRoundToInt(std::abs(src_rect.width() * scale.width())),
850 SkScalarRoundToInt(std::abs(src_rect.height() * scale.height()))); 850 SkScalarRoundToInt(std::abs(src_rect.height() * scale.height())));
851 851
852 // Start with the quality that was requested. 852 // Start with the quality that was requested.
853 SkFilterQuality quality = image.filter_quality(); 853 SkFilterQuality quality = image.filter_quality();
854 854
855 // If we're not going to do a scale, we can use low filter quality. Note that 855 // If we're not going to do a scale, we can use low filter quality. Note that
856 // checking if the sizes are the same is better than checking if scale is 1.f, 856 // checking if the sizes are the same is better than checking if scale is 1.f,
857 // because even non-1 scale can result in the same (rounded) width/height. 857 // because even non-1 scale can result in the same (rounded) width/height.
858 // If either dimension is a downscale, then use mipmaps (medium filter
859 // quality).
858 if (target_size.width() == src_rect.width() && 860 if (target_size.width() == src_rect.width() &&
859 target_size.height() == src_rect.height()) { 861 target_size.height() == src_rect.height()) {
860 quality = std::min(quality, kLow_SkFilterQuality); 862 quality = std::min(quality, kLow_SkFilterQuality);
863 } else if (target_size.width() < src_rect.width() ||
864 target_size.height() < src_rect.height()) {
865 quality = std::min(quality, kMedium_SkFilterQuality);
861 } 866 }
862 867
863 // Drop from high to medium if the the matrix we applied wasn't decomposable, 868 // Drop from high to medium if the the matrix we applied wasn't decomposable,
864 // or if the scaled image will be too large. 869 // or if the scaled image will be too large.
865 if (quality == kHigh_SkFilterQuality) { 870 if (quality == kHigh_SkFilterQuality) {
866 if (!image.matrix_is_decomposable()) { 871 if (!image.matrix_is_decomposable()) {
867 quality = kMedium_SkFilterQuality; 872 quality = kMedium_SkFilterQuality;
868 } else { 873 } else {
869 base::CheckedNumeric<size_t> size = 4u; 874 base::CheckedNumeric<size_t> size = 4u;
870 size *= target_size.width(); 875 size *= target_size.width();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 // TODO(tasak): free this component's caches as much as possible before 1102 // TODO(tasak): free this component's caches as much as possible before
1098 // suspending renderer. 1103 // suspending renderer.
1099 break; 1104 break;
1100 case base::MemoryState::UNKNOWN: 1105 case base::MemoryState::UNKNOWN:
1101 // NOT_REACHED. 1106 // NOT_REACHED.
1102 break; 1107 break;
1103 } 1108 }
1104 } 1109 }
1105 1110
1106 } // namespace cc 1111 } // namespace cc
OLDNEW
« 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