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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 key.target_size().width() / static_cast<float>(key.src_rect().width()); | 100 key.target_size().width() / static_cast<float>(key.src_rect().width()); |
101 float y_scale = | 101 float y_scale = |
102 key.target_size().height() / static_cast<float>(key.src_rect().height()); | 102 key.target_size().height() / static_cast<float>(key.src_rect().height()); |
103 return SkSize::Make(x_scale, y_scale); | 103 return SkSize::Make(x_scale, y_scale); |
104 } | 104 } |
105 | 105 |
106 SkFilterQuality GetDecodedFilterQuality(const ImageDecodeControllerKey& key) { | 106 SkFilterQuality GetDecodedFilterQuality(const ImageDecodeControllerKey& key) { |
107 return std::min(key.filter_quality(), kLow_SkFilterQuality); | 107 return std::min(key.filter_quality(), kLow_SkFilterQuality); |
108 } | 108 } |
109 | 109 |
110 SkColorType SkColorTypeForDecoding(ResourceFormat format) { | |
111 // Use kN32_SkColorType if there is no corresponding SkColorType. | |
112 switch (format) { | |
113 case RGBA_4444: | |
114 return kARGB_4444_SkColorType; | |
115 case RGBA_8888: | |
116 case BGRA_8888: | |
117 return kN32_SkColorType; | |
118 case ALPHA_8: | |
119 return kAlpha_8_SkColorType; | |
120 case RGB_565: | |
121 return kRGB_565_SkColorType; | |
122 case LUMINANCE_8: | |
123 return kGray_8_SkColorType; | |
124 case ETC1: | |
125 case RED_8: | |
126 case LUMINANCE_F16: | |
127 return kN32_SkColorType; | |
128 } | |
129 NOTREACHED(); | |
130 return kN32_SkColorType; | |
131 } | |
132 | |
133 SkImageInfo CreateImageInfo(size_t width, | 110 SkImageInfo CreateImageInfo(size_t width, |
134 size_t height, | 111 size_t height, |
135 ResourceFormat format) { | 112 ResourceFormat format) { |
136 return SkImageInfo::Make(width, height, SkColorTypeForDecoding(format), | 113 return SkImageInfo::Make(width, height, |
114 ResourceFormatToClosestSkColorType(format), | |
vmpstr
2016/03/28 23:55:53
Thanks!
| |
137 kPremul_SkAlphaType); | 115 kPremul_SkAlphaType); |
138 } | 116 } |
139 | 117 |
140 } // namespace | 118 } // namespace |
141 | 119 |
142 SoftwareImageDecodeController::SoftwareImageDecodeController( | 120 SoftwareImageDecodeController::SoftwareImageDecodeController( |
143 ResourceFormat format) | 121 ResourceFormat format) |
144 : decoded_images_(ImageMRUCache::NO_AUTO_EVICT), | 122 : decoded_images_(ImageMRUCache::NO_AUTO_EVICT), |
145 at_raster_decoded_images_(ImageMRUCache::NO_AUTO_EVICT), | 123 at_raster_decoded_images_(ImageMRUCache::NO_AUTO_EVICT), |
146 locked_images_budget_(kLockedMemoryLimitBytes), | 124 locked_images_budget_(kLockedMemoryLimitBytes), |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
890 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() { | 868 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() { |
891 current_usage_bytes_ = 0; | 869 current_usage_bytes_ = 0; |
892 } | 870 } |
893 | 871 |
894 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() | 872 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() |
895 const { | 873 const { |
896 return current_usage_bytes_.ValueOrDie(); | 874 return current_usage_bytes_.ValueOrDie(); |
897 } | 875 } |
898 | 876 |
899 } // namespace cc | 877 } // namespace cc |
OLD | NEW |