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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « cc/tiles/tile_manager_unittest.cc ('k') | 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <stack> 8 #include <stack>
9 #include <string> 9 #include <string>
10 10
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 const RenderSurfaceLayerList& update_list) { 926 const RenderSurfaceLayerList& update_list) {
927 size_t readback_bytes = 0; 927 size_t readback_bytes = 0;
928 size_t contents_texture_bytes = 0; 928 size_t contents_texture_bytes = 0;
929 929
930 // Start iteration at 1 to skip the root surface as it does not have a texture 930 // Start iteration at 1 to skip the root surface as it does not have a texture
931 // cost. 931 // cost.
932 for (size_t i = 1; i < update_list.size(); ++i) { 932 for (size_t i = 1; i < update_list.size(); ++i) {
933 Layer* render_surface_layer = update_list.at(i); 933 Layer* render_surface_layer = update_list.at(i);
934 RenderSurface* render_surface = render_surface_layer->render_surface(); 934 RenderSurface* render_surface = render_surface_layer->render_surface();
935 935
936 size_t bytes = 936 // We can use UncheckedMemorySizeBytes, since render surface content rect is
937 Resource::MemorySizeBytes(render_surface->content_rect().size(), 937 // limited by max texture size.
938 RGBA_8888); 938 size_t bytes = Resource::UncheckedMemorySizeBytes(
939 render_surface->content_rect().size(), RGBA_8888);
939 contents_texture_bytes += bytes; 940 contents_texture_bytes += bytes;
940 941
941 if (render_surface_layer->background_filters().IsEmpty() && 942 if (render_surface_layer->background_filters().IsEmpty() &&
942 render_surface_layer->uses_default_blend_mode()) 943 render_surface_layer->uses_default_blend_mode())
943 continue; 944 continue;
944 945
945 if (!readback_bytes) { 946 if (!readback_bytes) {
946 readback_bytes = Resource::MemorySizeBytes(device_viewport_size_, 947 // We need to use a checked size calucation here, since we don't control
947 RGBA_8888); 948 // the size of the device viewport.
949 readback_bytes =
950 Resource::CheckedMemorySizeBytes(device_viewport_size_, RGBA_8888);
948 } 951 }
949 } 952 }
950 return readback_bytes + contents_texture_bytes; 953 return readback_bytes + contents_texture_bytes;
951 } 954 }
952 955
953 void LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer, 956 void LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer,
954 ResourceUpdateQueue* queue, 957 ResourceUpdateQueue* queue,
955 bool* did_paint_content, 958 bool* did_paint_content,
956 bool* need_more_updates) { 959 bool* need_more_updates) {
957 // Note: Masks and replicas only exist for layers that own render surfaces. If 960 // Note: Masks and replicas only exist for layers that own render surfaces. If
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 const BeginFrameArgs& args) const { 1299 const BeginFrameArgs& args) const {
1297 client_->SendBeginFramesToChildren(args); 1300 client_->SendBeginFramesToChildren(args);
1298 } 1301 }
1299 1302
1300 void LayerTreeHost::SetAuthoritativeVSyncInterval( 1303 void LayerTreeHost::SetAuthoritativeVSyncInterval(
1301 const base::TimeDelta& interval) { 1304 const base::TimeDelta& interval) {
1302 proxy_->SetAuthoritativeVSyncInterval(interval); 1305 proxy_->SetAuthoritativeVSyncInterval(interval);
1303 } 1306 }
1304 1307
1305 } // namespace cc 1308 } // namespace cc
OLDNEW
« 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