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_impl.h" | 5 #include "cc/layers/tiled_layer_impl.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/debug/debug_colors.h" | 10 #include "cc/debug/debug_colors.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 105 } |
106 | 106 |
107 size_t TiledLayerImpl::GPUMemoryUsageInBytes() const { | 107 size_t TiledLayerImpl::GPUMemoryUsageInBytes() const { |
108 size_t amount = 0; | 108 size_t amount = 0; |
109 const size_t kMemoryUsagePerTileInBytes = | 109 const size_t kMemoryUsagePerTileInBytes = |
110 4 * tiler_->tile_size().width() * tiler_->tile_size().height(); | 110 4 * tiler_->tile_size().width() * tiler_->tile_size().height(); |
111 for (LayerTilingData::TileMap::const_iterator iter = tiler_->tiles().begin(); | 111 for (LayerTilingData::TileMap::const_iterator iter = tiler_->tiles().begin(); |
112 iter != tiler_->tiles().end(); | 112 iter != tiler_->tiles().end(); |
113 ++iter) { | 113 ++iter) { |
114 const DrawableTile* tile = static_cast<DrawableTile*>(iter->second); | 114 const DrawableTile* tile = static_cast<DrawableTile*>(iter->second); |
115 if (!tile || !tile->resource_id()) | 115 DCHECK(tile); |
| 116 if (!tile->resource_id()) |
116 continue; | 117 continue; |
117 amount += kMemoryUsagePerTileInBytes; | 118 amount += kMemoryUsagePerTileInBytes; |
118 } | 119 } |
119 return amount; | 120 return amount; |
120 } | 121 } |
121 | 122 |
122 void TiledLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 123 void TiledLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
123 LayerImpl::PushPropertiesTo(layer); | 124 LayerImpl::PushPropertiesTo(layer); |
124 | 125 |
125 TiledLayerImpl* tiled_layer = static_cast<TiledLayerImpl*>(layer); | 126 TiledLayerImpl* tiled_layer = static_cast<TiledLayerImpl*>(layer); |
126 | 127 |
127 tiled_layer->set_skips_draw(skips_draw_); | 128 tiled_layer->set_skips_draw(skips_draw_); |
128 tiled_layer->SetTilingData(*tiler_); | 129 tiled_layer->SetTilingData(*tiler_); |
129 | 130 |
130 for (LayerTilingData::TileMap::const_iterator iter = tiler_->tiles().begin(); | 131 for (LayerTilingData::TileMap::const_iterator iter = tiler_->tiles().begin(); |
131 iter != tiler_->tiles().end(); | 132 iter != tiler_->tiles().end(); |
132 ++iter) { | 133 ++iter) { |
133 int i = iter->first.first; | 134 int i = iter->first.first; |
134 int j = iter->first.second; | 135 int j = iter->first.second; |
135 DrawableTile* tile = static_cast<DrawableTile*>(iter->second); | 136 DrawableTile* tile = static_cast<DrawableTile*>(iter->second); |
136 | 137 DCHECK(tile); |
137 tiled_layer->PushTileProperties(i, | 138 tiled_layer->PushTileProperties(i, |
138 j, | 139 j, |
139 tile->resource_id(), | 140 tile->resource_id(), |
140 tile->opaque_rect(), | 141 tile->opaque_rect(), |
141 tile->contents_swizzled()); | 142 tile->contents_swizzled()); |
142 } | 143 } |
143 } | 144 } |
144 | 145 |
145 bool TiledLayerImpl::WillDraw(DrawMode draw_mode, | 146 bool TiledLayerImpl::WillDraw(DrawMode draw_mode, |
146 ResourceProvider* resource_provider) { | 147 ResourceProvider* resource_provider) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 308 |
308 void TiledLayerImpl::ReleaseResources() { | 309 void TiledLayerImpl::ReleaseResources() { |
309 tiler_->reset(); | 310 tiler_->reset(); |
310 } | 311 } |
311 | 312 |
312 const char* TiledLayerImpl::LayerTypeAsString() const { | 313 const char* TiledLayerImpl::LayerTypeAsString() const { |
313 return "cc::TiledLayerImpl"; | 314 return "cc::TiledLayerImpl"; |
314 } | 315 } |
315 | 316 |
316 } // namespace cc | 317 } // namespace cc |
OLD | NEW |