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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 // If we're going to use the original decode, then the target size should be | 811 // If we're going to use the original decode, then the target size should be |
812 // the full image size, since that will allow for proper memory accounting. | 812 // the full image size, since that will allow for proper memory accounting. |
813 // Note we skip the decode if the target size is empty altogether, so don't | 813 // Note we skip the decode if the target size is empty altogether, so don't |
814 // update the target size in that case. | 814 // update the target size in that case. |
815 if (can_use_original_decode && !target_size.IsEmpty()) | 815 if (can_use_original_decode && !target_size.IsEmpty()) |
816 target_size = gfx::Size(image.image()->width(), image.image()->height()); | 816 target_size = gfx::Size(image.image()->width(), image.image()->height()); |
817 | 817 |
818 if (quality == kMedium_SkFilterQuality && !target_size.IsEmpty()) { | 818 if (quality == kMedium_SkFilterQuality && !target_size.IsEmpty()) { |
819 SkSize mip_target_size = | 819 SkSize mip_target_size = |
820 MipMapUtil::GetScaleAdjustmentForSize(src_rect.size(), target_size); | 820 MipMapUtil::GetScaleAdjustmentForSize(src_rect.size(), target_size); |
821 DCHECK(mip_target_size.width() != -1.f && mip_target_size.height() != -1.f); | |
822 target_size.set_width(src_rect.width() * mip_target_size.width()); | 821 target_size.set_width(src_rect.width() * mip_target_size.width()); |
823 target_size.set_height(src_rect.height() * mip_target_size.height()); | 822 target_size.set_height(src_rect.height() * mip_target_size.height()); |
824 } | 823 } |
825 | 824 |
826 return ImageDecodeControllerKey(image.image()->uniqueID(), src_rect, | 825 return ImageDecodeControllerKey(image.image()->uniqueID(), src_rect, |
827 target_size, quality, | 826 target_size, quality, |
828 can_use_original_decode); | 827 can_use_original_decode); |
829 } | 828 } |
830 | 829 |
831 ImageDecodeControllerKey::ImageDecodeControllerKey( | 830 ImageDecodeControllerKey::ImageDecodeControllerKey( |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() { | 971 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() { |
973 current_usage_bytes_ = 0; | 972 current_usage_bytes_ = 0; |
974 } | 973 } |
975 | 974 |
976 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() | 975 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() |
977 const { | 976 const { |
978 return current_usage_bytes_.ValueOrDie(); | 977 return current_usage_bytes_.ValueOrDie(); |
979 } | 978 } |
980 | 979 |
981 } // namespace cc | 980 } // namespace cc |
OLD | NEW |