OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layers/tiled_layer.h" | 5 #include "cc/layers/tiled_layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 is_tiled = auto_tiled; | 135 is_tiled = auto_tiled; |
136 | 136 |
137 gfx::Size requested_size = is_tiled ? tile_size : content_bounds(); | 137 gfx::Size requested_size = is_tiled ? tile_size : content_bounds(); |
138 const int max_size = | 138 const int max_size = |
139 layer_tree_host()->GetRendererCapabilities().max_texture_size; | 139 layer_tree_host()->GetRendererCapabilities().max_texture_size; |
140 requested_size.SetToMin(gfx::Size(max_size, max_size)); | 140 requested_size.SetToMin(gfx::Size(max_size, max_size)); |
141 SetTileSize(requested_size); | 141 SetTileSize(requested_size); |
142 } | 142 } |
143 | 143 |
144 void TiledLayer::UpdateBounds() { | 144 void TiledLayer::UpdateBounds() { |
145 gfx::Rect old_tiling_rect = tiler_->tiling_rect(); | 145 gfx::Size old_tiling_size = tiler_->tiling_size(); |
146 gfx::Rect new_tiling_rect = gfx::Rect(content_bounds()); | 146 gfx::Size new_tiling_size = content_bounds(); |
147 if (old_tiling_rect == new_tiling_rect) | 147 if (old_tiling_size == new_tiling_size) |
148 return; | 148 return; |
149 tiler_->SetTilingRect(new_tiling_rect); | 149 tiler_->SetTilingSize(new_tiling_size); |
150 | 150 |
151 // Invalidate any areas that the new bounds exposes. | 151 // Invalidate any areas that the new bounds exposes. |
152 Region old_region = old_tiling_rect; | 152 Region new_region = |
153 Region new_region = new_tiling_rect; | 153 SubtractRegions(gfx::Rect(new_tiling_size), gfx::Rect(old_tiling_size)); |
154 new_tiling_rect.Subtract(old_tiling_rect); | 154 for (Region::Iterator new_rects(new_region); new_rects.has_rect(); |
155 for (Region::Iterator new_rects(new_tiling_rect); new_rects.has_rect(); | |
156 new_rects.next()) | 155 new_rects.next()) |
157 InvalidateContentRect(new_rects.rect()); | 156 InvalidateContentRect(new_rects.rect()); |
158 } | 157 } |
159 | 158 |
160 void TiledLayer::SetTileSize(const gfx::Size& size) { | 159 void TiledLayer::SetTileSize(const gfx::Size& size) { |
161 tiler_->SetTileSize(size); | 160 tiler_->SetTileSize(size); |
162 } | 161 } |
163 | 162 |
164 void TiledLayer::SetBorderTexelOption( | 163 void TiledLayer::SetBorderTexelOption( |
165 LayerTilingData::BorderTexelOption border_texel_option) { | 164 LayerTilingData::BorderTexelOption border_texel_option) { |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 gfx::Rect prepaint_rect = visible_content_rect(); | 892 gfx::Rect prepaint_rect = visible_content_rect(); |
894 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, | 893 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, |
895 -tiler_->tile_size().height() * kPrepaintRows); | 894 -tiler_->tile_size().height() * kPrepaintRows); |
896 gfx::Rect content_rect(content_bounds()); | 895 gfx::Rect content_rect(content_bounds()); |
897 prepaint_rect.Intersect(content_rect); | 896 prepaint_rect.Intersect(content_rect); |
898 | 897 |
899 return prepaint_rect; | 898 return prepaint_rect; |
900 } | 899 } |
901 | 900 |
902 } // namespace cc | 901 } // namespace cc |
OLD | NEW |