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

Side by Side Diff: trunk/src/cc/base/tiling_data.cc

Issue 347493002: Revert 277964 "cc: In SyncFromActiveLayer, drop all tiles not in..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/cc/base/tiling_data.h ('k') | trunk/src/cc/base/tiling_data_unittest.cc » ('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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/tiling_data.h" 5 #include "cc/base/tiling_data.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/gfx/rect.h" 9 #include "ui/gfx/rect.h"
10 #include "ui/gfx/vector2d.h" 10 #include "ui/gfx/vector2d.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 src_position -= tiling_rect_.y(); 133 src_position -= tiling_rect_.y();
134 134
135 DCHECK_GT(max_texture_size_.height() - 2 * border_texels_, 0); 135 DCHECK_GT(max_texture_size_.height() - 2 * border_texels_, 0);
136 int inner_tile_size = max_texture_size_.height() - 2 * border_texels_; 136 int inner_tile_size = max_texture_size_.height() - 2 * border_texels_;
137 int y = src_position / inner_tile_size; 137 int y = src_position / inner_tile_size;
138 return std::min(std::max(y, 0), num_tiles_y_ - 1); 138 return std::min(std::max(y, 0), num_tiles_y_ - 1);
139 } 139 }
140 140
141 gfx::Rect TilingData::ExpandRectToTileBoundsWithBorders( 141 gfx::Rect TilingData::ExpandRectToTileBoundsWithBorders(
142 const gfx::Rect& rect) const { 142 const gfx::Rect rect) const {
143 if (!rect.Intersects(tiling_rect_) || has_empty_bounds()) 143 if (!rect.Intersects(tiling_rect_) || has_empty_bounds())
144 return gfx::Rect(); 144 return gfx::Rect();
145 int index_x = FirstBorderTileXIndexFromSrcCoord(rect.x()); 145 int index_x = FirstBorderTileXIndexFromSrcCoord(rect.x());
146 int index_y = FirstBorderTileYIndexFromSrcCoord(rect.y()); 146 int index_y = FirstBorderTileYIndexFromSrcCoord(rect.y());
147 int index_right = LastBorderTileXIndexFromSrcCoord(rect.right() - 1); 147 int index_right = LastBorderTileXIndexFromSrcCoord(rect.right());
148 int index_bottom = LastBorderTileYIndexFromSrcCoord(rect.bottom() - 1); 148 int index_bottom = LastBorderTileYIndexFromSrcCoord(rect.bottom());
149 149
150 gfx::Rect rect_top_left(TileBoundsWithBorder(index_x, index_y)); 150 gfx::Rect rect_top_left(TileBoundsWithBorder(index_x, index_y));
151 gfx::Rect rect_bottom_right(TileBoundsWithBorder(index_right, index_bottom)); 151 gfx::Rect rect_bottom_right(TileBoundsWithBorder(index_right, index_bottom));
152 152
153 return gfx::UnionRects(rect_top_left, rect_bottom_right); 153 gfx::Rect expanded(rect_top_left);
154 } 154 expanded.Union(rect_bottom_right);
155 155 return expanded;
156 gfx::Rect TilingData::ExpandRectToTileBounds(const gfx::Rect& rect) const {
157 if (!rect.Intersects(tiling_rect_) || has_empty_bounds())
158 return gfx::Rect();
159 int index_x = FirstBorderTileXIndexFromSrcCoord(rect.x());
160 int index_y = FirstBorderTileYIndexFromSrcCoord(rect.y());
161 int index_right = LastBorderTileXIndexFromSrcCoord(rect.right() - 1);
162 int index_bottom = LastBorderTileYIndexFromSrcCoord(rect.bottom() - 1);
163
164 gfx::Rect rect_top_left(TileBounds(index_x, index_y));
165 gfx::Rect rect_bottom_right(TileBounds(index_right, index_bottom));
166
167 return gfx::UnionRects(rect_top_left, rect_bottom_right);
168 } 156 }
169 157
170 gfx::Rect TilingData::TileBounds(int i, int j) const { 158 gfx::Rect TilingData::TileBounds(int i, int j) const {
171 AssertTile(i, j); 159 AssertTile(i, j);
172 int max_texture_size_x = max_texture_size_.width() - 2 * border_texels_; 160 int max_texture_size_x = max_texture_size_.width() - 2 * border_texels_;
173 int max_texture_size_y = max_texture_size_.height() - 2 * border_texels_; 161 int max_texture_size_y = max_texture_size_.height() - 2 * border_texels_;
174 162
175 int lo_x = tiling_rect_.x() + max_texture_size_x * i; 163 int lo_x = tiling_rect_.x() + max_texture_size_x * i;
176 if (i != 0) 164 if (i != 0)
177 lo_x += border_texels_; 165 lo_x += border_texels_;
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 current_step_ = 0; 669 current_step_ = 0;
682 direction_ = static_cast<Direction>((direction_ + 1) % 4); 670 direction_ = static_cast<Direction>((direction_ + 1) % 4);
683 671
684 if (direction_ == RIGHT || direction_ == LEFT) { 672 if (direction_ == RIGHT || direction_ == LEFT) {
685 ++vertical_step_count_; 673 ++vertical_step_count_;
686 ++horizontal_step_count_; 674 ++horizontal_step_count_;
687 } 675 }
688 } 676 }
689 677
690 } // namespace cc 678 } // namespace cc
OLDNEW
« no previous file with comments | « trunk/src/cc/base/tiling_data.h ('k') | trunk/src/cc/base/tiling_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698