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

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: update 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
« cc/resources/resource.h ('K') | « 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 CHECK(Resource::VerifySizeInBytes(render_surface->content_rect().size(),
vmpstr 2015/06/04 20:52:59 I wasn't sure about this function, so I think it's
danakj 2015/06/04 20:58:44 RenderSurface content rects are bounded by the max
937 Resource::MemorySizeBytes(render_surface->content_rect().size(), 937 RGBA_8888));
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 CHECK(Resource::VerifySizeInBytes(device_viewport_size_, RGBA_8888));
danakj 2015/06/04 20:58:44 This is correct to check about I think it comes fr
947 RGBA_8888); 948 readback_bytes =
949 Resource::UncheckedMemorySizeBytes(device_viewport_size_, RGBA_8888);
948 } 950 }
949 } 951 }
950 return readback_bytes + contents_texture_bytes; 952 return readback_bytes + contents_texture_bytes;
951 } 953 }
952 954
953 void LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer, 955 void LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer,
954 ResourceUpdateQueue* queue, 956 ResourceUpdateQueue* queue,
955 bool* did_paint_content, 957 bool* did_paint_content,
956 bool* need_more_updates) { 958 bool* need_more_updates) {
957 // Note: Masks and replicas only exist for layers that own render surfaces. If 959 // 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 { 1298 const BeginFrameArgs& args) const {
1297 client_->SendBeginFramesToChildren(args); 1299 client_->SendBeginFramesToChildren(args);
1298 } 1300 }
1299 1301
1300 void LayerTreeHost::SetAuthoritativeVSyncInterval( 1302 void LayerTreeHost::SetAuthoritativeVSyncInterval(
1301 const base::TimeDelta& interval) { 1303 const base::TimeDelta& interval) {
1302 proxy_->SetAuthoritativeVSyncInterval(interval); 1304 proxy_->SetAuthoritativeVSyncInterval(interval);
1303 } 1305 }
1304 1306
1305 } // namespace cc 1307 } // namespace cc
OLDNEW
« cc/resources/resource.h ('K') | « cc/tiles/tile_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698