| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <functional> | 9 #include <functional> |
| 10 | 10 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 key.target_size().width() / static_cast<float>(key.src_rect().width()); | 105 key.target_size().width() / static_cast<float>(key.src_rect().width()); |
| 106 float y_scale = | 106 float y_scale = |
| 107 key.target_size().height() / static_cast<float>(key.src_rect().height()); | 107 key.target_size().height() / static_cast<float>(key.src_rect().height()); |
| 108 return SkSize::Make(x_scale, y_scale); | 108 return SkSize::Make(x_scale, y_scale); |
| 109 } | 109 } |
| 110 | 110 |
| 111 SkFilterQuality GetDecodedFilterQuality(const ImageDecodeControllerKey& key) { | 111 SkFilterQuality GetDecodedFilterQuality(const ImageDecodeControllerKey& key) { |
| 112 return std::min(key.filter_quality(), kLow_SkFilterQuality); | 112 return std::min(key.filter_quality(), kLow_SkFilterQuality); |
| 113 } | 113 } |
| 114 | 114 |
| 115 SkColorType SkColorTypeForDecoding(ResourceFormat format) { | |
| 116 // Use kN32_SkColorType if there is no corresponding SkColorType. | |
| 117 switch (format) { | |
| 118 case RGBA_4444: | |
| 119 return kARGB_4444_SkColorType; | |
| 120 case RGBA_8888: | |
| 121 case BGRA_8888: | |
| 122 return kN32_SkColorType; | |
| 123 case ALPHA_8: | |
| 124 return kAlpha_8_SkColorType; | |
| 125 case RGB_565: | |
| 126 return kRGB_565_SkColorType; | |
| 127 case LUMINANCE_8: | |
| 128 return kGray_8_SkColorType; | |
| 129 case ETC1: | |
| 130 case RED_8: | |
| 131 case LUMINANCE_F16: | |
| 132 return kN32_SkColorType; | |
| 133 } | |
| 134 NOTREACHED(); | |
| 135 return kN32_SkColorType; | |
| 136 } | |
| 137 | |
| 138 SkImageInfo CreateImageInfo(size_t width, | 115 SkImageInfo CreateImageInfo(size_t width, |
| 139 size_t height, | 116 size_t height, |
| 140 ResourceFormat format) { | 117 ResourceFormat format) { |
| 141 return SkImageInfo::Make(width, height, SkColorTypeForDecoding(format), | 118 return SkImageInfo::Make(width, height, |
| 119 ResourceFormatToClosestSkColorType(format), |
| 142 kPremul_SkAlphaType); | 120 kPremul_SkAlphaType); |
| 143 } | 121 } |
| 144 | 122 |
| 145 } // namespace | 123 } // namespace |
| 146 | 124 |
| 147 SoftwareImageDecodeController::SoftwareImageDecodeController( | 125 SoftwareImageDecodeController::SoftwareImageDecodeController( |
| 148 ResourceFormat format) | 126 ResourceFormat format) |
| 149 : decoded_images_(ImageMRUCache::NO_AUTO_EVICT), | 127 : decoded_images_(ImageMRUCache::NO_AUTO_EVICT), |
| 150 at_raster_decoded_images_(ImageMRUCache::NO_AUTO_EVICT), | 128 at_raster_decoded_images_(ImageMRUCache::NO_AUTO_EVICT), |
| 151 locked_images_budget_(kLockedMemoryLimitBytes), | 129 locked_images_budget_(kLockedMemoryLimitBytes), |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() { | 926 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() { |
| 949 current_usage_bytes_ = 0; | 927 current_usage_bytes_ = 0; |
| 950 } | 928 } |
| 951 | 929 |
| 952 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() | 930 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() |
| 953 const { | 931 const { |
| 954 return current_usage_bytes_.ValueOrDie(); | 932 return current_usage_bytes_.ValueOrDie(); |
| 955 } | 933 } |
| 956 | 934 |
| 957 } // namespace cc | 935 } // namespace cc |
| OLD | NEW |