| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/base/simple_enclosed_region.h" | 5 #include "cc/base/simple_enclosed_region.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include "base/logging.h" | 10 #include "base/logging.h" |
| 8 #include "cc/base/region.h" | 11 #include "cc/base/region.h" |
| 9 | 12 |
| 10 namespace cc { | 13 namespace cc { |
| 11 | 14 |
| 12 static bool RectIsLargerArea(const gfx::Rect& a, const gfx::Rect b) { | 15 static bool RectIsLargerArea(const gfx::Rect& a, const gfx::Rect b) { |
| 13 int64 a_area = static_cast<int64>(a.width()) * a.height(); | 16 int64_t a_area = static_cast<int64_t>(a.width()) * a.height(); |
| 14 int64 b_area = static_cast<int64>(b.width()) * b.height(); | 17 int64_t b_area = static_cast<int64_t>(b.width()) * b.height(); |
| 15 return a_area > b_area; | 18 return a_area > b_area; |
| 16 } | 19 } |
| 17 | 20 |
| 18 SimpleEnclosedRegion::SimpleEnclosedRegion(const Region& region) { | 21 SimpleEnclosedRegion::SimpleEnclosedRegion(const Region& region) { |
| 19 for (Region::Iterator it(region); it.has_rect(); it.next()) | 22 for (Region::Iterator it(region); it.has_rect(); it.next()) |
| 20 Union(it.rect()); | 23 Union(it.rect()); |
| 21 } | 24 } |
| 22 | 25 |
| 23 SimpleEnclosedRegion::~SimpleEnclosedRegion() { | 26 SimpleEnclosedRegion::~SimpleEnclosedRegion() { |
| 24 } | 27 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 if (RectIsLargerArea(adjusted_new_rect, rect_)) | 130 if (RectIsLargerArea(adjusted_new_rect, rect_)) |
| 128 rect_ = adjusted_new_rect; | 131 rect_ = adjusted_new_rect; |
| 129 } | 132 } |
| 130 | 133 |
| 131 gfx::Rect SimpleEnclosedRegion::GetRect(size_t i) const { | 134 gfx::Rect SimpleEnclosedRegion::GetRect(size_t i) const { |
| 132 DCHECK_LT(i, GetRegionComplexity()); | 135 DCHECK_LT(i, GetRegionComplexity()); |
| 133 return rect_; | 136 return rect_; |
| 134 } | 137 } |
| 135 | 138 |
| 136 } // namespace cc | 139 } // namespace cc |
| OLD | NEW |