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

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

Issue 914403003: cc: Add main frame timing info to frame timing tracker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests Created 5 years, 10 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_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
(...skipping 16 matching lines...) Expand all
27 #include "cc/layers/scrollbar_layer_impl_base.h" 27 #include "cc/layers/scrollbar_layer_impl_base.h"
28 #include "cc/resources/ui_resource_request.h" 28 #include "cc/resources/ui_resource_request.h"
29 #include "cc/trees/layer_tree_host_common.h" 29 #include "cc/trees/layer_tree_host_common.h"
30 #include "cc/trees/layer_tree_host_impl.h" 30 #include "cc/trees/layer_tree_host_impl.h"
31 #include "cc/trees/occlusion_tracker.h" 31 #include "cc/trees/occlusion_tracker.h"
32 #include "ui/gfx/geometry/point_conversions.h" 32 #include "ui/gfx/geometry/point_conversions.h"
33 #include "ui/gfx/geometry/size_conversions.h" 33 #include "ui/gfx/geometry/size_conversions.h"
34 #include "ui/gfx/geometry/vector2d_conversions.h" 34 #include "ui/gfx/geometry/vector2d_conversions.h"
35 35
36 namespace cc { 36 namespace cc {
37 namespace {
38
39 template <typename Lambda>
40 void ProcessLayersRecursive(LayerImpl* current, const Lambda& lambda) {
enne (OOO) 2015/02/12 23:41:07 Maybe add a LayerTreeHostCommon::CallFunctionForSu
vmpstr 2015/03/03 18:56:46 Done.
41 DCHECK(current);
42 lambda(current);
43 if (current->mask_layer())
44 ProcessLayersRecursive(current->mask_layer(), lambda);
45 if (current->replica_layer())
46 ProcessLayersRecursive(current->replica_layer(), lambda);
47 for (size_t i = 0; i < current->children().size(); ++i)
48 ProcessLayersRecursive(current->children()[i], lambda);
49 }
50
51 } // namespace
37 52
38 // This class exists to split the LayerScrollOffsetDelegate between the 53 // This class exists to split the LayerScrollOffsetDelegate between the
39 // InnerViewportScrollLayer and the OuterViewportScrollLayer in a manner 54 // InnerViewportScrollLayer and the OuterViewportScrollLayer in a manner
40 // that never requires the embedder or LayerImpl to know about. 55 // that never requires the embedder or LayerImpl to know about.
41 class LayerScrollOffsetDelegateProxy : public LayerImpl::ScrollOffsetDelegate { 56 class LayerScrollOffsetDelegateProxy : public LayerImpl::ScrollOffsetDelegate {
42 public: 57 public:
43 LayerScrollOffsetDelegateProxy(LayerImpl* layer, 58 LayerScrollOffsetDelegateProxy(LayerImpl* layer,
44 LayerScrollOffsetDelegate* delegate, 59 LayerScrollOffsetDelegate* delegate,
45 LayerTreeImpl* layer_tree) 60 LayerTreeImpl* layer_tree)
46 : layer_(layer), delegate_(delegate), layer_tree_impl_(layer_tree) {} 61 : layer_(layer), delegate_(delegate), layer_tree_impl_(layer_tree) {}
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. 129 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor.
115 DCHECK(!root_layer_); 130 DCHECK(!root_layer_);
116 DCHECK(layers_with_copy_output_request_.empty()); 131 DCHECK(layers_with_copy_output_request_.empty());
117 } 132 }
118 133
119 void LayerTreeImpl::Shutdown() { 134 void LayerTreeImpl::Shutdown() {
120 root_layer_ = nullptr; 135 root_layer_ = nullptr;
121 } 136 }
122 137
123 void LayerTreeImpl::ReleaseResources() { 138 void LayerTreeImpl::ReleaseResources() {
124 if (root_layer_) 139 if (!root_layer_)
125 ProcessLayersRecursive(root_layer_.get(), &LayerImpl::ReleaseResources); 140 return;
141
142 ProcessLayersRecursive(root_layer_.get(),
143 [](LayerImpl* layer) { layer->ReleaseResources(); });
126 } 144 }
127 145
128 void LayerTreeImpl::RecreateResources() { 146 void LayerTreeImpl::RecreateResources() {
129 if (root_layer_) 147 if (!root_layer_)
130 ProcessLayersRecursive(root_layer_.get(), &LayerImpl::RecreateResources); 148 return;
149
150 ProcessLayersRecursive(root_layer_.get(),
151 [](LayerImpl* layer) { layer->RecreateResources(); });
152 }
153
154 void LayerTreeImpl::GatherFrameTimingRequestIds(
155 std::vector<int64_t>* request_ids) {
156 if (!root_layer_)
157 return;
158
159 // TODO(vmpstr): Early out if there are no requests on any of the layers. For
160 // that, we need to inform LayerTreeImpl whenever there are requests when we
161 // get them.
162 ProcessLayersRecursive(root_layer_.get(), [&request_ids](LayerImpl* layer) {
163 layer->GatherFrameTimingRequestIds(request_ids);
164 });
131 } 165 }
132 166
133 void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { 167 void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) {
134 if (inner_viewport_scroll_layer_) 168 if (inner_viewport_scroll_layer_)
135 inner_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); 169 inner_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL);
136 if (outer_viewport_scroll_layer_) 170 if (outer_viewport_scroll_layer_)
137 outer_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); 171 outer_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL);
138 inner_viewport_scroll_delegate_proxy_ = nullptr; 172 inner_viewport_scroll_delegate_proxy_ = nullptr;
139 outer_viewport_scroll_delegate_proxy_ = nullptr; 173 outer_viewport_scroll_delegate_proxy_ = nullptr;
140 174
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 1233
1200 const std::vector<LayerImpl*>& LayerTreeImpl::LayersWithCopyOutputRequest() 1234 const std::vector<LayerImpl*>& LayerTreeImpl::LayersWithCopyOutputRequest()
1201 const { 1235 const {
1202 // Only the active tree needs to know about layers with copy requests, as 1236 // Only the active tree needs to know about layers with copy requests, as
1203 // they are aborted if not serviced during draw. 1237 // they are aborted if not serviced during draw.
1204 DCHECK(IsActiveTree()); 1238 DCHECK(IsActiveTree());
1205 1239
1206 return layers_with_copy_output_request_; 1240 return layers_with_copy_output_request_;
1207 } 1241 }
1208 1242
1209 void LayerTreeImpl::ProcessLayersRecursive(LayerImpl* current,
1210 void (LayerImpl::*function)()) {
1211 DCHECK(current);
1212 (current->*function)();
1213 if (current->mask_layer())
1214 ProcessLayersRecursive(current->mask_layer(), function);
1215 if (current->replica_layer())
1216 ProcessLayersRecursive(current->replica_layer(), function);
1217 for (size_t i = 0; i < current->children().size(); ++i)
1218 ProcessLayersRecursive(current->children()[i], function);
1219 }
1220
1221 template <typename LayerType> 1243 template <typename LayerType>
1222 static inline bool LayerClipsSubtree(LayerType* layer) { 1244 static inline bool LayerClipsSubtree(LayerType* layer) {
1223 return layer->masks_to_bounds() || layer->mask_layer(); 1245 return layer->masks_to_bounds() || layer->mask_layer();
1224 } 1246 }
1225 1247
1226 static bool PointHitsRect( 1248 static bool PointHitsRect(
1227 const gfx::PointF& screen_space_point, 1249 const gfx::PointF& screen_space_point,
1228 const gfx::Transform& local_space_to_screen_space_transform, 1250 const gfx::Transform& local_space_to_screen_space_transform,
1229 const gfx::RectF& local_space_rect, 1251 const gfx::RectF& local_space_rect,
1230 float* distance_to_camera) { 1252 float* distance_to_camera) {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 scoped_ptr<PendingPageScaleAnimation> pending_animation) { 1612 scoped_ptr<PendingPageScaleAnimation> pending_animation) {
1591 pending_page_scale_animation_ = pending_animation.Pass(); 1613 pending_page_scale_animation_ = pending_animation.Pass();
1592 } 1614 }
1593 1615
1594 scoped_ptr<PendingPageScaleAnimation> 1616 scoped_ptr<PendingPageScaleAnimation>
1595 LayerTreeImpl::TakePendingPageScaleAnimation() { 1617 LayerTreeImpl::TakePendingPageScaleAnimation() {
1596 return pending_page_scale_animation_.Pass(); 1618 return pending_page_scale_animation_.Pass();
1597 } 1619 }
1598 1620
1599 } // namespace cc 1621 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698