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

Side by Side Diff: cc/layers/tiled_layer_impl.cc

Issue 353093004: cc: add DCHECKs of tile in GPUMemoryUsageInBytes and PushPropertiesTo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add |tile| DCHECKs and remove null checks in GPUMemoryUsageInBytes and PushPropertiesTo functions Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698