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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 return; | 148 return; |
149 tiler_->SetTilingRect(new_tiling_rect); | 149 tiler_->SetTilingRect(new_tiling_rect); |
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 old_region = old_tiling_rect; |
153 Region new_region = new_tiling_rect; | 153 Region new_region = new_tiling_rect; |
154 new_tiling_rect.Subtract(old_tiling_rect); | 154 new_tiling_rect.Subtract(old_tiling_rect); |
155 for (Region::Iterator new_rects(new_tiling_rect); new_rects.has_rect(); | 155 for (Region::Iterator new_rects(new_tiling_rect); new_rects.has_rect(); |
156 new_rects.next()) | 156 new_rects.next()) |
157 InvalidateContentRect(new_rects.rect()); | 157 InvalidateContentRect(new_rects.rect()); |
| 158 UpdateDrawsContent(true); |
158 } | 159 } |
159 | 160 |
160 void TiledLayer::SetTileSize(const gfx::Size& size) { | 161 void TiledLayer::SetTileSize(const gfx::Size& size) { |
161 tiler_->SetTileSize(size); | 162 tiler_->SetTileSize(size); |
| 163 UpdateDrawsContent(true); |
162 } | 164 } |
163 | 165 |
164 void TiledLayer::SetBorderTexelOption( | 166 void TiledLayer::SetBorderTexelOption( |
165 LayerTilingData::BorderTexelOption border_texel_option) { | 167 LayerTilingData::BorderTexelOption border_texel_option) { |
166 tiler_->SetBorderTexelOption(border_texel_option); | 168 tiler_->SetBorderTexelOption(border_texel_option); |
| 169 UpdateDrawsContent(true); |
167 } | 170 } |
168 | 171 |
169 bool TiledLayer::DrawsContent() const { | 172 void TiledLayer::UpdateDrawsContent(bool draws_content) { |
170 if (!ContentsScalingLayer::DrawsContent()) | |
171 return false; | |
172 | |
173 bool has_more_than_one_tile = | 173 bool has_more_than_one_tile = |
174 tiler_->num_tiles_x() > 1 || tiler_->num_tiles_y() > 1; | 174 (tiler_->num_tiles_x() > 1) || (tiler_->num_tiles_y() > 1); |
175 if (tiling_option_ == NEVER_TILE && has_more_than_one_tile) | 175 ContentsScalingLayer::UpdateDrawsContent( |
176 return false; | 176 draws_content && |
177 | 177 !(tiling_option_ == NEVER_TILE && has_more_than_one_tile)); |
178 return true; | |
179 } | 178 } |
180 | 179 |
181 void TiledLayer::ReduceMemoryUsage() { | 180 void TiledLayer::ReduceMemoryUsage() { |
182 if (Updater()) | 181 if (Updater()) |
183 Updater()->ReduceMemoryUsage(); | 182 Updater()->ReduceMemoryUsage(); |
184 } | 183 } |
185 | 184 |
186 void TiledLayer::SetIsMask(bool is_mask) { | 185 void TiledLayer::SetIsMask(bool is_mask) { |
187 set_tiling_option(is_mask ? NEVER_TILE : AUTO_TILE); | 186 set_tiling_option(is_mask ? NEVER_TILE : AUTO_TILE); |
188 } | 187 } |
(...skipping 704 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 |