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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 375093002: Initial attempt at counting layers in the compositor thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add UMA for number of layers in a compositor frame 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
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_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return GL_TEXTURE_2D; 107 return GL_TEXTURE_2D;
108 108
109 if (context_provider->ContextCapabilities().gpu.egl_image_external) 109 if (context_provider->ContextCapabilities().gpu.egl_image_external)
110 return GL_TEXTURE_EXTERNAL_OES; 110 return GL_TEXTURE_EXTERNAL_OES;
111 if (context_provider->ContextCapabilities().gpu.texture_rectangle) 111 if (context_provider->ContextCapabilities().gpu.texture_rectangle)
112 return GL_TEXTURE_RECTANGLE_ARB; 112 return GL_TEXTURE_RECTANGLE_ARB;
113 113
114 return GL_TEXTURE_2D; 114 return GL_TEXTURE_2D;
115 } 115 }
116 116
117 void LayerCounter(size_t* counter, cc::LayerImpl* /* layer */) {
danakj 2014/07/10 18:03:41 we don't comment out parameter names in chrome
118 (*counter)++;
119 }
120
117 } // namespace 121 } // namespace
118 122
119 namespace cc { 123 namespace cc {
120 124
121 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { 125 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient {
122 public: 126 public:
123 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> Create( 127 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> Create(
124 LayerTreeHostImpl* layer_tree_host_impl, 128 LayerTreeHostImpl* layer_tree_host_impl,
125 scoped_refptr<DelayBasedTimeSource> time_source) { 129 scoped_refptr<DelayBasedTimeSource> time_source) {
126 return make_scoped_ptr( 130 return make_scoped_ptr(
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), 252 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()),
249 animation_registrar_(AnimationRegistrar::Create()), 253 animation_registrar_(AnimationRegistrar::Create()),
250 rendering_stats_instrumentation_(rendering_stats_instrumentation), 254 rendering_stats_instrumentation_(rendering_stats_instrumentation),
251 micro_benchmark_controller_(this), 255 micro_benchmark_controller_(this),
252 need_to_update_visible_tiles_before_draw_(false), 256 need_to_update_visible_tiles_before_draw_(false),
253 #if DCHECK_IS_ON 257 #if DCHECK_IS_ON
254 did_lose_called_(false), 258 did_lose_called_(false),
255 #endif 259 #endif
256 shared_bitmap_manager_(manager), 260 shared_bitmap_manager_(manager),
257 id_(id), 261 id_(id),
258 transfer_buffer_memory_limit_(0u) { 262 transfer_buffer_memory_limit_(0u),
263 num_layers_(0u) {
259 DCHECK(proxy_->IsImplThread()); 264 DCHECK(proxy_->IsImplThread());
260 DidVisibilityChange(this, visible_); 265 DidVisibilityChange(this, visible_);
261 animation_registrar_->set_supports_scroll_animations( 266 animation_registrar_->set_supports_scroll_animations(
262 proxy_->SupportsImplScrolling()); 267 proxy_->SupportsImplScrolling());
263 268
264 SetDebugState(settings.initial_debug_state); 269 SetDebugState(settings.initial_debug_state);
265 270
266 if (settings.calculate_top_controls_position) { 271 if (settings.calculate_top_controls_position) {
267 top_controls_manager_ = 272 top_controls_manager_ =
268 TopControlsManager::Create(this, 273 TopControlsManager::Create(this,
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 "LayerTreeHostImpl::PrepareToDraw", 1097 "LayerTreeHostImpl::PrepareToDraw",
1093 "SourceFrameNumber", 1098 "SourceFrameNumber",
1094 active_tree_->source_frame_number()); 1099 active_tree_->source_frame_number());
1095 1100
1096 if (need_to_update_visible_tiles_before_draw_ && 1101 if (need_to_update_visible_tiles_before_draw_ &&
1097 tile_manager_ && tile_manager_->UpdateVisibleTiles()) { 1102 tile_manager_ && tile_manager_->UpdateVisibleTiles()) {
1098 DidInitializeVisibleTile(); 1103 DidInitializeVisibleTile();
1099 } 1104 }
1100 need_to_update_visible_tiles_before_draw_ = true; 1105 need_to_update_visible_tiles_before_draw_ = true;
1101 1106
1107 {
1108 // Count the number of layers. See http://crbug.com/253919
1109 // A large number of layers might slow down rendering.
1110 num_layers_ = 0;
danakj 2014/07/10 18:03:41 While I love tests, I don't think we need to add a
Ian Vollick 2014/07/10 18:09:50 Ah, cool! That's a great idea. If we can use that
dneto 2014/07/10 18:44:16 Yes, that's smart! I don't know the data structur
1111 LayerTreeHostCommon::CallFunctionForSubtree<LayerImpl>(
1112 active_tree_->root_layer(), base::Bind(LayerCounter, &num_layers_));
Ian Vollick 2014/07/10 03:16:23 I'm a bit worried about doing an extra tree walk e
dneto 2014/07/10 18:44:16 I'll rework it one way or another.
1113 UMA_HISTOGRAM_CUSTOM_COUNTS(
1114 "Compositing.NumLayers", num_layers_, 1, 1000, 50);
dneto 2014/07/10 01:29:03 Also not sure if range of 1000 and width-20 bucket
Ian Vollick 2014/07/10 03:16:22 This is probably ok. width-10 buckets might be nic
dneto 2014/07/10 18:44:16 Ok. I'll make width-10 buckets with a range up t
1115 }
1116
1102 bool ok = active_tree_->UpdateDrawProperties(); 1117 bool ok = active_tree_->UpdateDrawProperties();
1103 DCHECK(ok) << "UpdateDrawProperties failed during draw"; 1118 DCHECK(ok) << "UpdateDrawProperties failed during draw";
1104 1119
1105 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); 1120 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList();
1106 frame->render_passes.clear(); 1121 frame->render_passes.clear();
1107 frame->render_passes_by_id.clear(); 1122 frame->render_passes_by_id.clear();
1108 frame->will_draw_layers.clear(); 1123 frame->will_draw_layers.clear();
1109 frame->contains_incomplete_tile = false; 1124 frame->contains_incomplete_tile = false;
1110 frame->has_no_damage = false; 1125 frame->has_no_damage = false;
1111 1126
(...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after
3182 } 3197 }
3183 3198
3184 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { 3199 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) {
3185 std::vector<PictureLayerImpl*>::iterator it = 3200 std::vector<PictureLayerImpl*>::iterator it =
3186 std::find(picture_layers_.begin(), picture_layers_.end(), layer); 3201 std::find(picture_layers_.begin(), picture_layers_.end(), layer);
3187 DCHECK(it != picture_layers_.end()); 3202 DCHECK(it != picture_layers_.end());
3188 picture_layers_.erase(it); 3203 picture_layers_.erase(it);
3189 } 3204 }
3190 3205
3191 } // namespace cc 3206 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698