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

Unified Diff: cc/trees/layer_tree_host.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/tiles/tile_manager_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host.cc
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index a0f279a1492f5d3a5a7982fac4e50545a504f9f5..02f80350cd9939a436f1014a70c63b4ba6eaca29 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -933,9 +933,10 @@ size_t LayerTreeHost::CalculateMemoryForRenderSurfaces(
Layer* render_surface_layer = update_list.at(i);
RenderSurface* render_surface = render_surface_layer->render_surface();
- size_t bytes =
- Resource::MemorySizeBytes(render_surface->content_rect().size(),
- RGBA_8888);
+ // We can use UncheckedMemorySizeBytes, since render surface content rect is
+ // limited by max texture size.
+ size_t bytes = Resource::UncheckedMemorySizeBytes(
+ render_surface->content_rect().size(), RGBA_8888);
contents_texture_bytes += bytes;
if (render_surface_layer->background_filters().IsEmpty() &&
@@ -943,8 +944,10 @@ size_t LayerTreeHost::CalculateMemoryForRenderSurfaces(
continue;
if (!readback_bytes) {
- readback_bytes = Resource::MemorySizeBytes(device_viewport_size_,
- RGBA_8888);
+ // We need to use a checked size calucation here, since we don't control
+ // the size of the device viewport.
+ readback_bytes =
+ Resource::CheckedMemorySizeBytes(device_viewport_size_, RGBA_8888);
}
}
return readback_bytes + contents_texture_bytes;
« no previous file with comments | « cc/tiles/tile_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698