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

Side by Side Diff: cc/base/index_rect.cc

Issue 2067213002: cc: Implement tile iteration order based on pyramid sequence. [old] Base URL: https://chromium.googlesource.com/chromium/src.git@tiling_data_fix
Patch Set: rebase -> used for smoothness tests Created 3 years, 10 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 | « cc/base/index_rect.h ('k') | cc/base/pyramid_sequence.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/index_rect.h" 5 #include "cc/base/index_rect.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/numerics/saturated_arithmetic.h"
9 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
10 11
11 namespace cc { 12 namespace cc {
12 13
13 void IndexRect::ClampTo(const IndexRect& other) { 14 void IndexRect::ClampTo(const IndexRect& other) {
14 left_ = std::max(left_, other.left()); 15 left_ = std::max(left_, other.left());
15 top_ = std::max(top_, other.top()); 16 top_ = std::max(top_, other.top());
16 right_ = std::min(right_, other.right()); 17 right_ = std::min(right_, other.right());
17 bottom_ = std::min(bottom_, other.bottom()); 18 bottom_ = std::min(bottom_, other.bottom());
18 } 19 }
19 20
20 bool IndexRect::Contains(int index_x, int index_y) const { 21 bool IndexRect::Contains(int index_x, int index_y) const {
21 return index_x >= left_ && index_x <= right_ && index_y >= top_ && 22 return index_x >= left_ && index_x <= right_ && index_y >= top_ &&
22 index_y <= bottom_; 23 index_y <= bottom_;
23 } 24 }
24 25
26 void IndexRect::Inset(int left, int right, int top, int bottom) {
27 left_ = base::SaturatedAddition(left_, left);
28 right_ = base::SaturatedSubtraction(right_, right);
29 top_ = base::SaturatedAddition(top_, top);
30 bottom_ = base::SaturatedSubtraction(bottom_, bottom);
31 }
32
25 std::string IndexRect::ToString() const { 33 std::string IndexRect::ToString() const {
26 return base::StringPrintf("%d,%d,%d,%d", left(), right(), top(), bottom()); 34 return base::StringPrintf("%d,%d,%d,%d", left(), right(), top(), bottom());
27 } 35 }
28 36
29 } // namespace cc 37 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/index_rect.h ('k') | cc/base/pyramid_sequence.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698