| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |