OLD | NEW |
---|---|
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 : client_(client), | 215 : client_(client), |
216 proxy_(proxy), | 216 proxy_(proxy), |
217 use_gpu_rasterization_(false), | 217 use_gpu_rasterization_(false), |
218 on_demand_task_graph_runner_(NULL), | 218 on_demand_task_graph_runner_(NULL), |
219 input_handler_client_(NULL), | 219 input_handler_client_(NULL), |
220 did_lock_scrolling_layer_(false), | 220 did_lock_scrolling_layer_(false), |
221 should_bubble_scrolls_(false), | 221 should_bubble_scrolls_(false), |
222 wheel_scrolling_(false), | 222 wheel_scrolling_(false), |
223 scroll_affects_scroll_handler_(false), | 223 scroll_affects_scroll_handler_(false), |
224 scroll_layer_id_when_mouse_over_scrollbar_(0), | 224 scroll_layer_id_when_mouse_over_scrollbar_(0), |
225 is_scrolling_(false), | |
225 tile_priorities_dirty_(false), | 226 tile_priorities_dirty_(false), |
226 root_layer_scroll_offset_delegate_(NULL), | 227 root_layer_scroll_offset_delegate_(NULL), |
227 settings_(settings), | 228 settings_(settings), |
228 visible_(true), | 229 visible_(true), |
229 cached_managed_memory_policy_( | 230 cached_managed_memory_policy_( |
230 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), | 231 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), |
231 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | 232 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, |
232 ManagedMemoryPolicy::kDefaultNumResourcesLimit), | 233 ManagedMemoryPolicy::kDefaultNumResourcesLimit), |
233 pinch_gesture_active_(false), | 234 pinch_gesture_active_(false), |
234 pinch_gesture_end_should_clear_scrolling_layer_(false), | 235 pinch_gesture_end_should_clear_scrolling_layer_(false), |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
771 // still draw the frame. However when the layer being checkerboarded is moving | 772 // still draw the frame. However when the layer being checkerboarded is moving |
772 // due to an impl-animation, we drop the frame to avoid flashing due to the | 773 // due to an impl-animation, we drop the frame to avoid flashing due to the |
773 // texture suddenly appearing in the future. | 774 // texture suddenly appearing in the future. |
774 DrawResult draw_result = DRAW_SUCCESS; | 775 DrawResult draw_result = DRAW_SUCCESS; |
775 // When we have a copy request for a layer, we need to draw no matter | 776 // When we have a copy request for a layer, we need to draw no matter |
776 // what, as the layer may disappear after this frame. | 777 // what, as the layer may disappear after this frame. |
777 bool have_copy_request = false; | 778 bool have_copy_request = false; |
778 | 779 |
779 int layers_drawn = 0; | 780 int layers_drawn = 0; |
780 | 781 |
782 int num_missing_tiles = 0; | |
783 int num_incomplete_tiles = 0; | |
784 | |
781 const DrawMode draw_mode = GetDrawMode(output_surface_.get()); | 785 const DrawMode draw_mode = GetDrawMode(output_surface_.get()); |
782 | 786 |
783 LayerIteratorType end = | 787 LayerIteratorType end = |
784 LayerIteratorType::End(frame->render_surface_layer_list); | 788 LayerIteratorType::End(frame->render_surface_layer_list); |
785 for (LayerIteratorType it = | 789 for (LayerIteratorType it = |
786 LayerIteratorType::Begin(frame->render_surface_layer_list); | 790 LayerIteratorType::Begin(frame->render_surface_layer_list); |
787 it != end; | 791 it != end; |
788 ++it) { | 792 ++it) { |
789 RenderPass::Id target_render_pass_id = | 793 RenderPass::Id target_render_pass_id = |
790 it.target_render_surface_layer()->render_surface()->RenderPassId(); | 794 it.target_render_surface_layer()->render_surface()->RenderPassId(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
849 | 853 |
850 ++layers_drawn; | 854 ++layers_drawn; |
851 } | 855 } |
852 | 856 |
853 rendering_stats_instrumentation_->AddVisibleContentArea( | 857 rendering_stats_instrumentation_->AddVisibleContentArea( |
854 append_quads_data.visible_content_area); | 858 append_quads_data.visible_content_area); |
855 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea( | 859 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea( |
856 append_quads_data.approximated_visible_content_area); | 860 append_quads_data.approximated_visible_content_area); |
857 | 861 |
858 if (append_quads_data.num_missing_tiles) { | 862 if (append_quads_data.num_missing_tiles) { |
863 num_missing_tiles += append_quads_data.num_missing_tiles; | |
859 bool layer_has_animating_transform = | 864 bool layer_has_animating_transform = |
860 it->screen_space_transform_is_animating() || | 865 it->screen_space_transform_is_animating() || |
861 it->draw_transform_is_animating(); | 866 it->draw_transform_is_animating(); |
862 if (layer_has_animating_transform) | 867 if (layer_has_animating_transform) |
863 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 868 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
864 } | 869 } |
865 | 870 |
866 if (append_quads_data.had_incomplete_tile) { | 871 if (append_quads_data.had_incomplete_tile) { |
872 num_incomplete_tiles += append_quads_data.num_incomplete_tiles; | |
867 frame->contains_incomplete_tile = true; | 873 frame->contains_incomplete_tile = true; |
868 if (active_tree()->RequiresHighResToDraw()) | 874 if (active_tree()->RequiresHighResToDraw()) |
869 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; | 875 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT; |
870 } | 876 } |
871 | 877 |
872 occlusion_tracker.LeaveLayer(it); | 878 occlusion_tracker.LeaveLayer(it); |
873 } | 879 } |
874 | 880 |
875 if (have_copy_request || | 881 if (have_copy_request || |
876 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) | 882 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) |
(...skipping 30 matching lines...) Expand all Loading... | |
907 while (!active_tree_->LayersWithCopyOutputRequest().empty()) { | 913 while (!active_tree_->LayersWithCopyOutputRequest().empty()) { |
908 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); | 914 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); |
909 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); | 915 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); |
910 } | 916 } |
911 for (size_t i = 0; i < requests_to_abort.size(); ++i) | 917 for (size_t i = 0; i < requests_to_abort.size(); ++i) |
912 requests_to_abort[i]->SendEmptyResult(); | 918 requests_to_abort[i]->SendEmptyResult(); |
913 | 919 |
914 // If we're making a frame to draw, it better have at least one render pass. | 920 // If we're making a frame to draw, it better have at least one render pass. |
915 DCHECK(!frame->render_passes.empty()); | 921 DCHECK(!frame->render_passes.empty()); |
916 | 922 |
923 if (is_scrolling_) { | |
924 UMA_HISTOGRAM_COUNTS("RenderPass.AppendQuadData.NumMissingTiles", | |
925 num_missing_tiles); | |
926 UMA_HISTOGRAM_COUNTS_100("RenderPass.AppendQuadData.NumIncompleteTiles", | |
927 num_incomplete_tiles); | |
928 } | |
929 | |
917 // Should only have one render pass in resourceless software mode. | 930 // Should only have one render pass in resourceless software mode. |
918 if (output_surface_->ForcedDrawToSoftwareDevice()) | 931 if (output_surface_->ForcedDrawToSoftwareDevice()) |
919 DCHECK_EQ(1u, frame->render_passes.size()); | 932 DCHECK_EQ(1u, frame->render_passes.size()); |
920 | 933 |
921 return draw_result; | 934 return draw_result; |
922 } | 935 } |
923 | 936 |
924 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { | 937 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { |
925 if (input_handler_client_) | 938 if (input_handler_client_) |
926 input_handler_client_->MainThreadHasStoppedFlinging(); | 939 input_handler_client_->MainThreadHasStoppedFlinging(); |
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2218 return ancestor == scroll_ancestor; | 2231 return ancestor == scroll_ancestor; |
2219 } | 2232 } |
2220 return false; | 2233 return false; |
2221 } | 2234 } |
2222 | 2235 |
2223 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( | 2236 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( |
2224 const gfx::Point& viewport_point, | 2237 const gfx::Point& viewport_point, |
2225 InputHandler::ScrollInputType type) { | 2238 InputHandler::ScrollInputType type) { |
2226 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); | 2239 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); |
2227 | 2240 |
2241 is_scrolling_ = true; | |
danakj
2014/07/03 16:01:45
can you use the CurrentlyScrollingLayer() instead
weiliangc
2014/07/04 21:35:53
Done.
weiliangc
2014/07/04 21:35:53
Using IsCurrentlyScrolling()
| |
2242 | |
2228 if (top_controls_manager_) | 2243 if (top_controls_manager_) |
2229 top_controls_manager_->ScrollBegin(); | 2244 top_controls_manager_->ScrollBegin(); |
2230 | 2245 |
2231 DCHECK(!CurrentlyScrollingLayer()); | 2246 DCHECK(!CurrentlyScrollingLayer()); |
2232 ClearCurrentlyScrollingLayer(); | 2247 ClearCurrentlyScrollingLayer(); |
2233 | 2248 |
2234 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, | 2249 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, |
2235 device_scale_factor_); | 2250 device_scale_factor_); |
2236 LayerImpl* layer_impl = | 2251 LayerImpl* layer_impl = |
2237 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 2252 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2544 } | 2559 } |
2545 | 2560 |
2546 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { | 2561 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { |
2547 active_tree_->ClearCurrentlyScrollingLayer(); | 2562 active_tree_->ClearCurrentlyScrollingLayer(); |
2548 did_lock_scrolling_layer_ = false; | 2563 did_lock_scrolling_layer_ = false; |
2549 scroll_affects_scroll_handler_ = false; | 2564 scroll_affects_scroll_handler_ = false; |
2550 accumulated_root_overscroll_ = gfx::Vector2dF(); | 2565 accumulated_root_overscroll_ = gfx::Vector2dF(); |
2551 } | 2566 } |
2552 | 2567 |
2553 void LayerTreeHostImpl::ScrollEnd() { | 2568 void LayerTreeHostImpl::ScrollEnd() { |
2569 is_scrolling_ = false; | |
2554 if (top_controls_manager_) | 2570 if (top_controls_manager_) |
2555 top_controls_manager_->ScrollEnd(); | 2571 top_controls_manager_->ScrollEnd(); |
2556 ClearCurrentlyScrollingLayer(); | 2572 ClearCurrentlyScrollingLayer(); |
2557 } | 2573 } |
2558 | 2574 |
2559 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 2575 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
2560 if (!active_tree_->CurrentlyScrollingLayer()) | 2576 if (!active_tree_->CurrentlyScrollingLayer()) |
2561 return ScrollIgnored; | 2577 return ScrollIgnored; |
2562 | 2578 |
2563 if (settings_.ignore_root_layer_flings && | 2579 if (settings_.ignore_root_layer_flings && |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3152 } | 3168 } |
3153 | 3169 |
3154 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3170 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3155 std::vector<PictureLayerImpl*>::iterator it = | 3171 std::vector<PictureLayerImpl*>::iterator it = |
3156 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3172 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3157 DCHECK(it != picture_layers_.end()); | 3173 DCHECK(it != picture_layers_.end()); |
3158 picture_layers_.erase(it); | 3174 picture_layers_.erase(it); |
3159 } | 3175 } |
3160 | 3176 |
3161 } // namespace cc | 3177 } // namespace cc |
OLD | NEW |