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

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

Issue 1838553003: cc: Always round up target image size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <functional> 9 #include <functional>
10 10
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 const SkSize& scale = image.scale(); 731 const SkSize& scale = image.scale();
732 // If the src_rect falls outside of the image, we need to clip it since 732 // If the src_rect falls outside of the image, we need to clip it since
733 // otherwise we might end up with uninitialized memory in the decode process. 733 // otherwise we might end up with uninitialized memory in the decode process.
734 // Note that the scale is still unchanged and the target size is now a 734 // Note that the scale is still unchanged and the target size is now a
735 // function of the new src_rect. 735 // function of the new src_rect.
736 gfx::Rect src_rect = gfx::IntersectRects( 736 gfx::Rect src_rect = gfx::IntersectRects(
737 gfx::SkIRectToRect(image.src_rect()), 737 gfx::SkIRectToRect(image.src_rect()),
738 gfx::Rect(image.image()->width(), image.image()->height())); 738 gfx::Rect(image.image()->width(), image.image()->height()));
739 739
740 gfx::Size target_size( 740 gfx::Size target_size(
741 SkScalarRoundToInt(std::abs(src_rect.width() * scale.width())), 741 static_cast<int>(std::ceil(std::abs(src_rect.width() * scale.width()))),
742 SkScalarRoundToInt(std::abs(src_rect.height() * scale.height()))); 742 static_cast<int>(
743 std::ceil(std::abs(src_rect.height() * scale.height()))));
743 744
744 // Start with the quality that was requested. 745 // Start with the quality that was requested.
745 SkFilterQuality quality = image.filter_quality(); 746 SkFilterQuality quality = image.filter_quality();
746 747
747 // If we're not going to do a scale, we can use low filter quality. Note that 748 // If we're not going to do a scale, we can use low filter quality. Note that
748 // checking if the sizes are the same is better than checking if scale is 1.f, 749 // checking if the sizes are the same is better than checking if scale is 1.f,
749 // because even non-1 scale can result in the same (rounded) width/height. 750 // because even non-1 scale can result in the same (rounded) width/height.
750 if (target_size.width() == src_rect.width() && 751 if (target_size.width() == src_rect.width() &&
751 target_size.height() == src_rect.height()) { 752 target_size.height() == src_rect.height()) {
752 quality = std::min(quality, kLow_SkFilterQuality); 753 quality = std::min(quality, kLow_SkFilterQuality);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() { 891 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() {
891 current_usage_bytes_ = 0; 892 current_usage_bytes_ = 0;
892 } 893 }
893 894
894 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() 895 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe()
895 const { 896 const {
896 return current_usage_bytes_.ValueOrDie(); 897 return current_usage_bytes_.ValueOrDie();
897 } 898 }
898 899
899 } // namespace cc 900 } // 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