OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 int ComputeExpansionDelta(int num_x_edges, int num_y_edges, | 816 int ComputeExpansionDelta(int num_x_edges, int num_y_edges, |
817 int width, int height, | 817 int width, int height, |
818 int64 target_area) { | 818 int64 target_area) { |
819 // Compute coefficients for the quadratic equation: | 819 // Compute coefficients for the quadratic equation: |
820 // a*x^2 + b*x + c = 0 | 820 // a*x^2 + b*x + c = 0 |
821 int a = num_y_edges * num_x_edges; | 821 int a = num_y_edges * num_x_edges; |
822 int b = num_y_edges * width + num_x_edges * height; | 822 int b = num_y_edges * width + num_x_edges * height; |
823 int64 c = static_cast<int64>(width) * height - target_area; | 823 int64 c = static_cast<int64>(width) * height - target_area; |
824 | 824 |
825 // Compute the delta for our edges using the quadratic equation. | 825 // Compute the delta for our edges using the quadratic equation. |
826 return a == 0 ? -c / b : | 826 int delta = |
827 (-b + static_cast<int>( | 827 (a == 0) ? -c / b : (-b + static_cast<int>(std::sqrt( |
828 std::sqrt(static_cast<int64>(b) * b - 4.0 * a * c))) / (2 * a); | 828 static_cast<int64>(b) * b - 4.0 * a * c))) / |
| 829 (2 * a); |
| 830 return std::max(0, delta); |
829 } | 831 } |
830 | 832 |
831 } // namespace | 833 } // namespace |
832 | 834 |
833 gfx::Rect PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( | 835 gfx::Rect PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
834 const gfx::Rect& starting_rect, | 836 const gfx::Rect& starting_rect, |
835 int64 target_area, | 837 int64 target_area, |
836 const gfx::Rect& bounding_rect, | 838 const gfx::Rect& bounding_rect, |
837 RectExpansionCache* cache) { | 839 RectExpansionCache* cache) { |
838 if (starting_rect.IsEmpty()) | 840 if (starting_rect.IsEmpty()) |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 DCHECK(*this); | 1200 DCHECK(*this); |
1199 do { | 1201 do { |
1200 ++current_eviction_tiles_index_; | 1202 ++current_eviction_tiles_index_; |
1201 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && | 1203 } while (current_eviction_tiles_index_ != eviction_tiles_->size() && |
1202 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); | 1204 !(*eviction_tiles_)[current_eviction_tiles_index_]->HasResources()); |
1203 | 1205 |
1204 return *this; | 1206 return *this; |
1205 } | 1207 } |
1206 | 1208 |
1207 } // namespace cc | 1209 } // namespace cc |
OLD | NEW |