| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (old_tiling_size == new_tiling_size) | 147 if (old_tiling_size == new_tiling_size) |
| 148 return; | 148 return; |
| 149 tiler_->SetTilingSize(new_tiling_size); | 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 new_region = | 152 Region new_region = |
| 153 SubtractRegions(gfx::Rect(new_tiling_size), gfx::Rect(old_tiling_size)); | 153 SubtractRegions(gfx::Rect(new_tiling_size), gfx::Rect(old_tiling_size)); |
| 154 for (Region::Iterator new_rects(new_region); new_rects.has_rect(); | 154 for (Region::Iterator new_rects(new_region); new_rects.has_rect(); |
| 155 new_rects.next()) | 155 new_rects.next()) |
| 156 InvalidateContentRect(new_rects.rect()); | 156 InvalidateContentRect(new_rects.rect()); |
| 157 UpdateDrawsContent(HasDrawableContent()); |
| 157 } | 158 } |
| 158 | 159 |
| 159 void TiledLayer::SetTileSize(const gfx::Size& size) { | 160 void TiledLayer::SetTileSize(const gfx::Size& size) { |
| 160 tiler_->SetTileSize(size); | 161 tiler_->SetTileSize(size); |
| 162 UpdateDrawsContent(HasDrawableContent()); |
| 161 } | 163 } |
| 162 | 164 |
| 163 void TiledLayer::SetBorderTexelOption( | 165 void TiledLayer::SetBorderTexelOption( |
| 164 LayerTilingData::BorderTexelOption border_texel_option) { | 166 LayerTilingData::BorderTexelOption border_texel_option) { |
| 165 tiler_->SetBorderTexelOption(border_texel_option); | 167 tiler_->SetBorderTexelOption(border_texel_option); |
| 168 UpdateDrawsContent(HasDrawableContent()); |
| 166 } | 169 } |
| 167 | 170 |
| 168 bool TiledLayer::DrawsContent() const { | 171 bool TiledLayer::HasDrawableContent() const { |
| 169 if (!ContentsScalingLayer::DrawsContent()) | 172 bool has_more_than_one_tile = |
| 170 return false; | 173 (tiler_->num_tiles_x() > 1) || (tiler_->num_tiles_y() > 1); |
| 171 | 174 |
| 172 bool has_more_than_one_tile = | 175 return !(tiling_option_ == NEVER_TILE && has_more_than_one_tile) && |
| 173 tiler_->num_tiles_x() > 1 || tiler_->num_tiles_y() > 1; | 176 ContentsScalingLayer::HasDrawableContent(); |
| 174 if (tiling_option_ == NEVER_TILE && has_more_than_one_tile) | |
| 175 return false; | |
| 176 | |
| 177 return true; | |
| 178 } | 177 } |
| 179 | 178 |
| 180 void TiledLayer::ReduceMemoryUsage() { | 179 void TiledLayer::ReduceMemoryUsage() { |
| 181 if (Updater()) | 180 if (Updater()) |
| 182 Updater()->ReduceMemoryUsage(); | 181 Updater()->ReduceMemoryUsage(); |
| 183 } | 182 } |
| 184 | 183 |
| 185 void TiledLayer::SetIsMask(bool is_mask) { | 184 void TiledLayer::SetIsMask(bool is_mask) { |
| 186 set_tiling_option(is_mask ? NEVER_TILE : AUTO_TILE); | 185 set_tiling_option(is_mask ? NEVER_TILE : AUTO_TILE); |
| 187 } | 186 } |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 gfx::Rect prepaint_rect = visible_content_rect(); | 891 gfx::Rect prepaint_rect = visible_content_rect(); |
| 893 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, | 892 prepaint_rect.Inset(-tiler_->tile_size().width() * kPrepaintColumns, |
| 894 -tiler_->tile_size().height() * kPrepaintRows); | 893 -tiler_->tile_size().height() * kPrepaintRows); |
| 895 gfx::Rect content_rect(content_bounds()); | 894 gfx::Rect content_rect(content_bounds()); |
| 896 prepaint_rect.Intersect(content_rect); | 895 prepaint_rect.Intersect(content_rect); |
| 897 | 896 |
| 898 return prepaint_rect; | 897 return prepaint_rect; |
| 899 } | 898 } |
| 900 | 899 |
| 901 } // namespace cc | 900 } // namespace cc |
| OLD | NEW |