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

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

Issue 2751783002: cc: Replace LayerIterator with iterator that walks layer list and effect tree (Closed)
Patch Set: Rebase Created 3 years, 8 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 19 matching lines...) Expand all
30 #include "cc/benchmarks/benchmark_instrumentation.h" 30 #include "cc/benchmarks/benchmark_instrumentation.h"
31 #include "cc/debug/rendering_stats_instrumentation.h" 31 #include "cc/debug/rendering_stats_instrumentation.h"
32 #include "cc/debug/traced_value.h" 32 #include "cc/debug/traced_value.h"
33 #include "cc/input/browser_controls_offset_manager.h" 33 #include "cc/input/browser_controls_offset_manager.h"
34 #include "cc/input/main_thread_scrolling_reason.h" 34 #include "cc/input/main_thread_scrolling_reason.h"
35 #include "cc/input/page_scale_animation.h" 35 #include "cc/input/page_scale_animation.h"
36 #include "cc/input/scroll_elasticity_helper.h" 36 #include "cc/input/scroll_elasticity_helper.h"
37 #include "cc/input/scroll_state.h" 37 #include "cc/input/scroll_state.h"
38 #include "cc/input/scrollbar_animation_controller.h" 38 #include "cc/input/scrollbar_animation_controller.h"
39 #include "cc/layers/append_quads_data.h" 39 #include "cc/layers/append_quads_data.h"
40 #include "cc/layers/effect_tree_layer_list_iterator.h"
40 #include "cc/layers/heads_up_display_layer_impl.h" 41 #include "cc/layers/heads_up_display_layer_impl.h"
41 #include "cc/layers/layer_impl.h" 42 #include "cc/layers/layer_impl.h"
42 #include "cc/layers/layer_iterator.h"
43 #include "cc/layers/painted_scrollbar_layer_impl.h" 43 #include "cc/layers/painted_scrollbar_layer_impl.h"
44 #include "cc/layers/render_surface_impl.h" 44 #include "cc/layers/render_surface_impl.h"
45 #include "cc/layers/scrollbar_layer_impl_base.h" 45 #include "cc/layers/scrollbar_layer_impl_base.h"
46 #include "cc/layers/surface_layer_impl.h" 46 #include "cc/layers/surface_layer_impl.h"
47 #include "cc/layers/viewport.h" 47 #include "cc/layers/viewport.h"
48 #include "cc/output/compositor_frame.h" 48 #include "cc/output/compositor_frame.h"
49 #include "cc/output/compositor_frame_metadata.h" 49 #include "cc/output/compositor_frame_metadata.h"
50 #include "cc/output/compositor_frame_sink.h" 50 #include "cc/output/compositor_frame_sink.h"
51 #include "cc/output/copy_output_request.h" 51 #include "cc/output/copy_output_request.h"
52 #include "cc/quads/render_pass_draw_quad.h" 52 #include "cc/quads/render_pass_draw_quad.h"
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 const DrawMode draw_mode = GetDrawMode(); 899 const DrawMode draw_mode = GetDrawMode();
900 900
901 int num_missing_tiles = 0; 901 int num_missing_tiles = 0;
902 int num_incomplete_tiles = 0; 902 int num_incomplete_tiles = 0;
903 int64_t checkerboarded_no_recording_content_area = 0; 903 int64_t checkerboarded_no_recording_content_area = 0;
904 int64_t checkerboarded_needs_raster_content_area = 0; 904 int64_t checkerboarded_needs_raster_content_area = 0;
905 bool have_copy_request = 905 bool have_copy_request =
906 active_tree()->property_trees()->effect_tree.HasCopyRequests(); 906 active_tree()->property_trees()->effect_tree.HasCopyRequests();
907 bool have_missing_animated_tiles = false; 907 bool have_missing_animated_tiles = false;
908 908
909 LayerIterator end = LayerIterator::End(frame->render_surface_layer_list); 909 for (EffectTreeLayerListIterator it(active_tree());
910 for (LayerIterator it = 910 it.state() != EffectTreeLayerListIterator::State::END; ++it) {
911 LayerIterator::Begin(frame->render_surface_layer_list); 911 auto target_render_pass_id = it.target_render_surface()->GetRenderPassId();
912 it != end; ++it) {
913 auto target_render_pass_id =
914 it.target_render_surface_layer()->GetRenderSurface()->GetRenderPassId();
915 RenderPass* target_render_pass = 912 RenderPass* target_render_pass =
916 FindRenderPassById(frame->render_passes, target_render_pass_id); 913 FindRenderPassById(frame->render_passes, target_render_pass_id);
917 914
918 AppendQuadsData append_quads_data; 915 AppendQuadsData append_quads_data;
919 916
920 RenderSurfaceImpl* render_surface = it->GetRenderSurface(); 917 if (it.state() == EffectTreeLayerListIterator::State::TARGET_SURFACE) {
921 if (it.represents_target_render_surface()) { 918 RenderSurfaceImpl* render_surface = it.target_render_surface();
922 if (render_surface->HasCopyRequest()) { 919 if (render_surface->HasCopyRequest()) {
923 active_tree() 920 active_tree()
924 ->property_trees() 921 ->property_trees()
925 ->effect_tree.TakeCopyRequestsAndTransformToSurface( 922 ->effect_tree.TakeCopyRequestsAndTransformToSurface(
926 render_surface->EffectTreeIndex(), 923 render_surface->EffectTreeIndex(),
927 &target_render_pass->copy_requests); 924 &target_render_pass->copy_requests);
928 } 925 }
929 } else if (it.represents_contributing_render_surface() && 926 } else if (it.state() ==
930 render_surface->contributes_to_drawn_surface()) { 927 EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE) {
931 render_surface->AppendQuads(target_render_pass, &append_quads_data); 928 RenderSurfaceImpl* render_surface = it.current_render_surface();
932 } else if (it.represents_itself() && !it->visible_layer_rect().IsEmpty()) { 929 if (render_surface->contributes_to_drawn_surface())
930 render_surface->AppendQuads(target_render_pass, &append_quads_data);
931 } else if (it.state() == EffectTreeLayerListIterator::State::LAYER &&
932 !it.current_layer()->visible_layer_rect().IsEmpty()) {
933 LayerImpl* layer = it.current_layer();
933 bool occluded = 934 bool occluded =
934 it->draw_properties().occlusion_in_content_space.IsOccluded( 935 layer->draw_properties().occlusion_in_content_space.IsOccluded(
935 it->visible_layer_rect()); 936 layer->visible_layer_rect());
936 if (!occluded && it->WillDraw(draw_mode, resource_provider_.get())) { 937 if (!occluded && layer->WillDraw(draw_mode, resource_provider_.get())) {
937 DCHECK_EQ(active_tree_.get(), it->layer_tree_impl()); 938 DCHECK_EQ(active_tree_.get(), layer->layer_tree_impl());
938 939
939 frame->will_draw_layers.push_back(*it); 940 frame->will_draw_layers.push_back(layer);
940 if (it->may_contain_video()) 941 if (layer->may_contain_video())
941 frame->may_contain_video = true; 942 frame->may_contain_video = true;
942 943
943 it->AppendQuads(target_render_pass, &append_quads_data); 944 layer->AppendQuads(target_render_pass, &append_quads_data);
944 } 945 }
945 946
946 ++layers_drawn; 947 ++layers_drawn;
947 }
948 948
949 rendering_stats_instrumentation_->AddVisibleContentArea( 949 rendering_stats_instrumentation_->AddVisibleContentArea(
950 append_quads_data.visible_layer_area); 950 append_quads_data.visible_layer_area);
951 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea( 951 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea(
952 append_quads_data.approximated_visible_content_area); 952 append_quads_data.approximated_visible_content_area);
953 rendering_stats_instrumentation_->AddCheckerboardedVisibleContentArea( 953 rendering_stats_instrumentation_->AddCheckerboardedVisibleContentArea(
954 append_quads_data.checkerboarded_visible_content_area); 954 append_quads_data.checkerboarded_visible_content_area);
955 rendering_stats_instrumentation_->AddCheckerboardedNoRecordingContentArea( 955 rendering_stats_instrumentation_->AddCheckerboardedNoRecordingContentArea(
956 append_quads_data.checkerboarded_no_recording_content_area); 956 append_quads_data.checkerboarded_no_recording_content_area);
957 rendering_stats_instrumentation_->AddCheckerboardedNeedsRasterContentArea( 957 rendering_stats_instrumentation_->AddCheckerboardedNeedsRasterContentArea(
958 append_quads_data.checkerboarded_needs_raster_content_area); 958 append_quads_data.checkerboarded_needs_raster_content_area);
959 959
960 num_missing_tiles += append_quads_data.num_missing_tiles; 960 num_missing_tiles += append_quads_data.num_missing_tiles;
961 num_incomplete_tiles += append_quads_data.num_incomplete_tiles; 961 num_incomplete_tiles += append_quads_data.num_incomplete_tiles;
962 checkerboarded_no_recording_content_area += 962 checkerboarded_no_recording_content_area +=
963 append_quads_data.checkerboarded_no_recording_content_area; 963 append_quads_data.checkerboarded_no_recording_content_area;
964 checkerboarded_needs_raster_content_area += 964 checkerboarded_needs_raster_content_area +=
965 append_quads_data.checkerboarded_needs_raster_content_area; 965 append_quads_data.checkerboarded_needs_raster_content_area;
966 if (append_quads_data.num_missing_tiles > 0) { 966 if (append_quads_data.num_missing_tiles > 0) {
967 have_missing_animated_tiles |= 967 have_missing_animated_tiles |=
968 !it->was_ever_ready_since_last_transform_animation() || 968 !layer->was_ever_ready_since_last_transform_animation() ||
969 it->screen_space_transform_is_animating(); 969 layer->screen_space_transform_is_animating();
970 } else { 970 } else {
971 it->set_was_ever_ready_since_last_transform_animation(true); 971 layer->set_was_ever_ready_since_last_transform_animation(true);
972 }
972 } 973 }
973 } 974 }
974 975
975 // If CommitToActiveTree() is true, then we wait to draw until 976 // If CommitToActiveTree() is true, then we wait to draw until
976 // NotifyReadyToDraw. That means we're in as good shape as is possible now, 977 // NotifyReadyToDraw. That means we're in as good shape as is possible now,
977 // so there's no reason to stop the draw now (and this is not supported by 978 // so there's no reason to stop the draw now (and this is not supported by
978 // SingleThreadProxy). 979 // SingleThreadProxy).
979 if (have_missing_animated_tiles && !CommitToActiveTree()) 980 if (have_missing_animated_tiles && !CommitToActiveTree())
980 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; 981 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
981 982
(...skipping 3289 matching lines...) Expand 10 before | Expand all | Expand 10 after
4271 } 4272 }
4272 4273
4273 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { 4274 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) {
4274 if (is_wheel_scroll) 4275 if (is_wheel_scroll)
4275 has_scrolled_by_wheel_ = true; 4276 has_scrolled_by_wheel_ = true;
4276 else 4277 else
4277 has_scrolled_by_touch_ = true; 4278 has_scrolled_by_touch_ = true;
4278 } 4279 }
4279 4280
4280 } // namespace cc 4281 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_copyrequest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698