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

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

Issue 332433003: cc: Remove EnsureRenderSurfaceLayerList, do UpdateDrawProps when needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ensurersll: checkinside Created 6 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | 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_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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // construct a DebugScopedSetImplThread object. There is no need to do 147 // construct a DebugScopedSetImplThread object. There is no need to do
148 // this in multi-threaded mode since the real thread id's will be 148 // this in multi-threaded mode since the real thread id's will be
149 // correct. In fact, setting fake thread id's interferes with the real 149 // correct. In fact, setting fake thread id's interferes with the real
150 // thread id's and causes breakage. 150 // thread id's and causes breakage.
151 scoped_ptr<DebugScopedSetImplThread> set_impl_thread; 151 scoped_ptr<DebugScopedSetImplThread> set_impl_thread;
152 if (!layer_tree_host_impl_->proxy()->HasImplThread()) { 152 if (!layer_tree_host_impl_->proxy()->HasImplThread()) {
153 set_impl_thread.reset( 153 set_impl_thread.reset(
154 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); 154 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy()));
155 } 155 }
156 156
157 // TODO(enne): This should probably happen post-animate.
158 if (layer_tree_host_impl_->pending_tree()) {
159 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties();
160 layer_tree_host_impl_->ManageTiles();
161 }
162
163 layer_tree_host_impl_->Animate( 157 layer_tree_host_impl_->Animate(
164 layer_tree_host_impl_->CurrentFrameTimeTicks()); 158 layer_tree_host_impl_->CurrentFrameTimeTicks());
165 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); 159 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true);
166 bool start_ready_animations = true; 160 bool start_ready_animations = true;
167 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 161 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
162
163 if (layer_tree_host_impl_->pending_tree()) {
164 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties();
165 layer_tree_host_impl_->ManageTiles();
166 }
167
168 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); 168 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
169 } 169 }
170 170
171 void SetActive(bool active) { 171 void SetActive(bool active) {
172 if (active != time_source_->Active()) 172 if (active != time_source_->Active())
173 time_source_->SetActive(active); 173 time_source_->SetActive(active);
174 } 174 }
175 175
176 bool Active() const { return time_source_->Active(); } 176 bool Active() const { return time_source_->Active(); }
177 177
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 client_->SetNeedsCommitOnImplThread(); 467 client_->SetNeedsCommitOnImplThread();
468 client_->RenewTreePriority(); 468 client_->RenewTreePriority();
469 } 469 }
470 470
471 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( 471 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt(
472 const gfx::Point& viewport_point, 472 const gfx::Point& viewport_point,
473 InputHandler::ScrollInputType type) { 473 InputHandler::ScrollInputType type) {
474 if (!CurrentlyScrollingLayer()) 474 if (!CurrentlyScrollingLayer())
475 return false; 475 return false;
476 476
477 if (!EnsureRenderSurfaceLayerList())
478 return false;
479
480 gfx::PointF device_viewport_point = 477 gfx::PointF device_viewport_point =
481 gfx::ScalePoint(viewport_point, device_scale_factor_); 478 gfx::ScalePoint(viewport_point, device_scale_factor_);
482 479
483 LayerImpl* layer_impl = 480 LayerImpl* layer_impl =
484 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 481 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
485 482
486 bool scroll_on_main_thread = false; 483 bool scroll_on_main_thread = false;
487 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( 484 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint(
488 device_viewport_point, type, layer_impl, &scroll_on_main_thread, NULL); 485 device_viewport_point, type, layer_impl, &scroll_on_main_thread, NULL);
489 return CurrentlyScrollingLayer() == scrolling_layer_impl; 486 return CurrentlyScrollingLayer() == scrolling_layer_impl;
490 } 487 }
491 488
492 bool LayerTreeHostImpl::HaveTouchEventHandlersAt( 489 bool LayerTreeHostImpl::HaveTouchEventHandlersAt(
493 const gfx::Point& viewport_point) { 490 const gfx::Point& viewport_point) {
494 if (!settings_.touch_hit_testing) 491 if (!settings_.touch_hit_testing)
495 return true; 492 return true;
496 if (!EnsureRenderSurfaceLayerList())
497 return false;
498 493
499 gfx::PointF device_viewport_point = 494 gfx::PointF device_viewport_point =
500 gfx::ScalePoint(viewport_point, device_scale_factor_); 495 gfx::ScalePoint(viewport_point, device_scale_factor_);
501 496
502 LayerImpl* layer_impl = 497 LayerImpl* layer_impl =
503 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( 498 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion(
504 device_viewport_point); 499 device_viewport_point);
505 500
506 return layer_impl != NULL; 501 return layer_impl != NULL;
507 } 502 }
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 "LayerTreeHostImpl::PrepareToDraw", 1082 "LayerTreeHostImpl::PrepareToDraw",
1088 "SourceFrameNumber", 1083 "SourceFrameNumber",
1089 active_tree_->source_frame_number()); 1084 active_tree_->source_frame_number());
1090 1085
1091 if (need_to_update_visible_tiles_before_draw_ && 1086 if (need_to_update_visible_tiles_before_draw_ &&
1092 tile_manager_ && tile_manager_->UpdateVisibleTiles()) { 1087 tile_manager_ && tile_manager_->UpdateVisibleTiles()) {
1093 DidInitializeVisibleTile(); 1088 DidInitializeVisibleTile();
1094 } 1089 }
1095 need_to_update_visible_tiles_before_draw_ = true; 1090 need_to_update_visible_tiles_before_draw_ = true;
1096 1091
1097 active_tree_->UpdateDrawProperties(); 1092 bool ok = active_tree_->UpdateDrawProperties();
1093 DCHECK(ok) << "UpdateDrawProperties failed during draw";
1098 1094
1099 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); 1095 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList();
1100 frame->render_passes.clear(); 1096 frame->render_passes.clear();
1101 frame->render_passes_by_id.clear(); 1097 frame->render_passes_by_id.clear();
1102 frame->will_draw_layers.clear(); 1098 frame->will_draw_layers.clear();
1103 frame->contains_incomplete_tile = false; 1099 frame->contains_incomplete_tile = false;
1104 frame->has_no_damage = false; 1100 frame->has_no_damage = false;
1105 1101
1106 if (active_tree_->root_layer()) { 1102 if (active_tree_->root_layer()) {
1107 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; 1103 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_;
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 } 2117 }
2122 2118
2123 void LayerTreeHostImpl::DidChangeTopControlsPosition() { 2119 void LayerTreeHostImpl::DidChangeTopControlsPosition() {
2124 UpdateInnerViewportContainerSize(); 2120 UpdateInnerViewportContainerSize();
2125 SetNeedsRedraw(); 2121 SetNeedsRedraw();
2126 SetNeedsAnimate(); 2122 SetNeedsAnimate();
2127 active_tree_->set_needs_update_draw_properties(); 2123 active_tree_->set_needs_update_draw_properties();
2128 SetFullRootLayerDamage(); 2124 SetFullRootLayerDamage();
2129 } 2125 }
2130 2126
2131 bool LayerTreeHostImpl::EnsureRenderSurfaceLayerList() {
2132 active_tree_->UpdateDrawProperties();
2133 return !active_tree_->RenderSurfaceLayerList().empty();
2134 }
2135
2136 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { 2127 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) {
2137 DCHECK(input_handler_client_ == NULL); 2128 DCHECK(input_handler_client_ == NULL);
2138 input_handler_client_ = client; 2129 input_handler_client_ = client;
2139 } 2130 }
2140 2131
2141 static LayerImpl* NextScrollLayer(LayerImpl* layer) { 2132 static LayerImpl* NextScrollLayer(LayerImpl* layer) {
2142 if (LayerImpl* scroll_parent = layer->scroll_parent()) 2133 if (LayerImpl* scroll_parent = layer->scroll_parent())
2143 return scroll_parent; 2134 return scroll_parent;
2144 return layer->parent(); 2135 return layer->parent();
2145 } 2136 }
2146 2137
2147 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( 2138 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint(
2148 const gfx::PointF& device_viewport_point, 2139 const gfx::PointF& device_viewport_point,
2149 InputHandler::ScrollInputType type, 2140 InputHandler::ScrollInputType type,
2150 LayerImpl* layer_impl, 2141 LayerImpl* layer_impl,
2151 bool* scroll_on_main_thread, 2142 bool* scroll_on_main_thread,
2152 bool* optional_has_ancestor_scroll_handler) const { 2143 bool* optional_has_ancestor_scroll_handler) const {
2153 DCHECK(scroll_on_main_thread); 2144 DCHECK(scroll_on_main_thread);
2154 2145
2155 // Walk up the hierarchy and look for a scrollable layer. 2146 // Walk up the hierarchy and look for a scrollable layer.
2156 LayerImpl* potentially_scrolling_layer_impl = 0; 2147 LayerImpl* potentially_scrolling_layer_impl = NULL;
2157 for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { 2148 for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) {
2158 // The content layer can also block attempts to scroll outside the main 2149 // The content layer can also block attempts to scroll outside the main
2159 // thread. 2150 // thread.
2160 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); 2151 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type);
2161 if (status == ScrollOnMainThread) { 2152 if (status == ScrollOnMainThread) {
2162 *scroll_on_main_thread = true; 2153 *scroll_on_main_thread = true;
2163 return NULL; 2154 return NULL;
2164 } 2155 }
2165 2156
2166 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); 2157 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2208 const gfx::Point& viewport_point, 2199 const gfx::Point& viewport_point,
2209 InputHandler::ScrollInputType type) { 2200 InputHandler::ScrollInputType type) {
2210 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); 2201 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin");
2211 2202
2212 if (top_controls_manager_) 2203 if (top_controls_manager_)
2213 top_controls_manager_->ScrollBegin(); 2204 top_controls_manager_->ScrollBegin();
2214 2205
2215 DCHECK(!CurrentlyScrollingLayer()); 2206 DCHECK(!CurrentlyScrollingLayer());
2216 ClearCurrentlyScrollingLayer(); 2207 ClearCurrentlyScrollingLayer();
2217 2208
2218 if (!EnsureRenderSurfaceLayerList())
2219 return ScrollIgnored;
2220
2221 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, 2209 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point,
2222 device_scale_factor_); 2210 device_scale_factor_);
2223 LayerImpl* layer_impl = 2211 LayerImpl* layer_impl =
2224 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 2212 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
2225 2213
2226 if (layer_impl) { 2214 if (layer_impl) {
2227 LayerImpl* scroll_layer_impl = 2215 LayerImpl* scroll_layer_impl =
2228 active_tree_->FindFirstScrollingLayerThatIsHitByPoint( 2216 active_tree_->FindFirstScrollingLayerThatIsHitByPoint(
2229 device_viewport_point); 2217 device_viewport_point);
2230 if (scroll_layer_impl && !HasScrollAncestor(layer_impl, scroll_layer_impl)) 2218 if (scroll_layer_impl && !HasScrollAncestor(layer_impl, scroll_layer_impl))
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2574 2562
2575 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( 2563 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect(
2576 layer_impl->screen_space_transform(), 2564 layer_impl->screen_space_transform(),
2577 layer_impl_bounds); 2565 layer_impl_bounds);
2578 2566
2579 return device_viewport_layer_impl_bounds.ManhattanDistanceToPoint( 2567 return device_viewport_layer_impl_bounds.ManhattanDistanceToPoint(
2580 device_viewport_point); 2568 device_viewport_point);
2581 } 2569 }
2582 2570
2583 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { 2571 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) {
2584 if (!EnsureRenderSurfaceLayerList())
2585 return;
2586
2587 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, 2572 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point,
2588 device_scale_factor_); 2573 device_scale_factor_);
2589 LayerImpl* layer_impl = 2574 LayerImpl* layer_impl =
2590 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 2575 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
2591 if (HandleMouseOverScrollbar(layer_impl, device_viewport_point)) 2576 if (HandleMouseOverScrollbar(layer_impl, device_viewport_point))
2592 return; 2577 return;
2593 2578
2594 if (scroll_layer_id_when_mouse_over_scrollbar_) { 2579 if (scroll_layer_id_when_mouse_over_scrollbar_) {
2595 LayerImpl* scroll_layer_impl = active_tree_->LayerById( 2580 LayerImpl* scroll_layer_impl = active_tree_->LayerById(
2596 scroll_layer_id_when_mouse_over_scrollbar_); 2581 scroll_layer_id_when_mouse_over_scrollbar_);
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
3129 swap_promise_monitor_.erase(monitor); 3114 swap_promise_monitor_.erase(monitor);
3130 } 3115 }
3131 3116
3132 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { 3117 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() {
3133 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3118 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3134 for (; it != swap_promise_monitor_.end(); it++) 3119 for (; it != swap_promise_monitor_.end(); it++)
3135 (*it)->OnSetNeedsRedrawOnImpl(); 3120 (*it)->OnSetNeedsRedrawOnImpl();
3136 } 3121 }
3137 3122
3138 } // namespace cc 3123 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698