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

Side by Side Diff: cc/tiles/tile_manager.cc

Issue 1154393003: cc: Use CheckedNumeric for resource size calculations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: initialize var Created 5 years, 6 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 | « cc/tiles/tile.cc ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/tiles/tile_manager.h" 5 #include "cc/tiles/tile_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 10
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 } 967 }
968 968
969 TileManager::MemoryUsage::MemoryUsage(int64 memory_bytes, int resource_count) 969 TileManager::MemoryUsage::MemoryUsage(int64 memory_bytes, int resource_count)
970 : memory_bytes_(memory_bytes), resource_count_(resource_count) { 970 : memory_bytes_(memory_bytes), resource_count_(resource_count) {
971 } 971 }
972 972
973 // static 973 // static
974 TileManager::MemoryUsage TileManager::MemoryUsage::FromConfig( 974 TileManager::MemoryUsage TileManager::MemoryUsage::FromConfig(
975 const gfx::Size& size, 975 const gfx::Size& size,
976 ResourceFormat format) { 976 ResourceFormat format) {
977 return MemoryUsage(Resource::MemorySizeBytes(size, format), 1); 977 // We can use UncheckedMemorySizeBytes here since this is used with a tile
978 // size which is determined by the compositor (it's at most max texture size).
979 return MemoryUsage(Resource::UncheckedMemorySizeBytes(size, format), 1);
978 } 980 }
979 981
980 // static 982 // static
981 TileManager::MemoryUsage TileManager::MemoryUsage::FromTile(const Tile* tile) { 983 TileManager::MemoryUsage TileManager::MemoryUsage::FromTile(const Tile* tile) {
982 const TileDrawInfo& draw_info = tile->draw_info(); 984 const TileDrawInfo& draw_info = tile->draw_info();
983 if (draw_info.resource_) { 985 if (draw_info.resource_) {
984 return MemoryUsage::FromConfig(draw_info.resource_->size(), 986 return MemoryUsage::FromConfig(draw_info.resource_->size(),
985 draw_info.resource_->format()); 987 draw_info.resource_->format());
986 } 988 }
987 return MemoryUsage(); 989 return MemoryUsage();
(...skipping 19 matching lines...) Expand all
1007 result -= other; 1009 result -= other;
1008 return result; 1010 return result;
1009 } 1011 }
1010 1012
1011 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { 1013 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const {
1012 return memory_bytes_ > limit.memory_bytes_ || 1014 return memory_bytes_ > limit.memory_bytes_ ||
1013 resource_count_ > limit.resource_count_; 1015 resource_count_ > limit.resource_count_;
1014 } 1016 }
1015 1017
1016 } // namespace cc 1018 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile.cc ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698