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

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: Clean up #includes Created 3 years, 9 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 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 const DrawMode draw_mode = GetDrawMode(); 873 const DrawMode draw_mode = GetDrawMode();
874 874
875 int num_missing_tiles = 0; 875 int num_missing_tiles = 0;
876 int num_incomplete_tiles = 0; 876 int num_incomplete_tiles = 0;
877 int64_t checkerboarded_no_recording_content_area = 0; 877 int64_t checkerboarded_no_recording_content_area = 0;
878 int64_t checkerboarded_needs_raster_content_area = 0; 878 int64_t checkerboarded_needs_raster_content_area = 0;
879 bool have_copy_request = 879 bool have_copy_request =
880 active_tree()->property_trees()->effect_tree.HasCopyRequests(); 880 active_tree()->property_trees()->effect_tree.HasCopyRequests();
881 bool have_missing_animated_tiles = false; 881 bool have_missing_animated_tiles = false;
882 882
883 LayerIterator end = LayerIterator::End(frame->render_surface_layer_list); 883 for (EffectTreeLayerListIterator it(active_tree());
884 for (LayerIterator it = 884 it.state() != EffectTreeLayerListIterator::State::END; ++it) {
885 LayerIterator::Begin(frame->render_surface_layer_list); 885 auto target_render_pass_id = it.target_render_surface()->GetRenderPassId();
886 it != end; ++it) {
887 auto target_render_pass_id =
888 it.target_render_surface_layer()->GetRenderSurface()->GetRenderPassId();
889 RenderPass* target_render_pass = 886 RenderPass* target_render_pass =
890 FindRenderPassById(frame->render_passes, target_render_pass_id); 887 FindRenderPassById(frame->render_passes, target_render_pass_id);
891 888
892 AppendQuadsData append_quads_data; 889 AppendQuadsData append_quads_data;
893 890
894 RenderSurfaceImpl* render_surface = it->GetRenderSurface(); 891 if (it.state() == EffectTreeLayerListIterator::State::TARGET_SURFACE) {
895 if (it.represents_target_render_surface()) { 892 RenderSurfaceImpl* render_surface = it.target_render_surface();
896 if (render_surface->HasCopyRequest()) { 893 if (render_surface->HasCopyRequest()) {
897 active_tree() 894 active_tree()
898 ->property_trees() 895 ->property_trees()
899 ->effect_tree.TakeCopyRequestsAndTransformToSurface( 896 ->effect_tree.TakeCopyRequestsAndTransformToSurface(
900 render_surface->EffectTreeIndex(), 897 render_surface->EffectTreeIndex(),
901 &target_render_pass->copy_requests); 898 &target_render_pass->copy_requests);
902 } 899 }
903 } else if (it.represents_contributing_render_surface() && 900 } else if (it.state() ==
904 render_surface->contributes_to_drawn_surface()) { 901 EffectTreeLayerListIterator::State::CONTRIBUTING_SURFACE) {
905 render_surface->AppendQuads(target_render_pass, &append_quads_data); 902 RenderSurfaceImpl* render_surface = it.current_render_surface();
906 } else if (it.represents_itself() && !it->visible_layer_rect().IsEmpty()) { 903 if (render_surface->contributes_to_drawn_surface())
904 render_surface->AppendQuads(target_render_pass, &append_quads_data);
905 } else if (it.state() == EffectTreeLayerListIterator::State::LAYER &&
906 !it.current_layer()->visible_layer_rect().IsEmpty()) {
907 LayerImpl* layer = it.current_layer();
907 bool occluded = 908 bool occluded =
908 it->draw_properties().occlusion_in_content_space.IsOccluded( 909 layer->draw_properties().occlusion_in_content_space.IsOccluded(
909 it->visible_layer_rect()); 910 layer->visible_layer_rect());
910 if (!occluded && it->WillDraw(draw_mode, resource_provider_.get())) { 911 if (!occluded && layer->WillDraw(draw_mode, resource_provider_.get())) {
911 DCHECK_EQ(active_tree_.get(), it->layer_tree_impl()); 912 DCHECK_EQ(active_tree_.get(), layer->layer_tree_impl());
912 913
913 frame->will_draw_layers.push_back(*it); 914 frame->will_draw_layers.push_back(layer);
914 if (it->may_contain_video()) 915 if (layer->may_contain_video())
915 frame->may_contain_video = true; 916 frame->may_contain_video = true;
916 917
917 it->AppendQuads(target_render_pass, &append_quads_data); 918 layer->AppendQuads(target_render_pass, &append_quads_data);
918 } 919 }
919 920
920 ++layers_drawn; 921 ++layers_drawn;
921 }
922 922
923 rendering_stats_instrumentation_->AddVisibleContentArea( 923 rendering_stats_instrumentation_->AddVisibleContentArea(
924 append_quads_data.visible_layer_area); 924 append_quads_data.visible_layer_area);
925 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea( 925 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea(
926 append_quads_data.approximated_visible_content_area); 926 append_quads_data.approximated_visible_content_area);
927 rendering_stats_instrumentation_->AddCheckerboardedVisibleContentArea( 927 rendering_stats_instrumentation_->AddCheckerboardedVisibleContentArea(
928 append_quads_data.checkerboarded_visible_content_area); 928 append_quads_data.checkerboarded_visible_content_area);
929 rendering_stats_instrumentation_->AddCheckerboardedNoRecordingContentArea( 929 rendering_stats_instrumentation_->AddCheckerboardedNoRecordingContentArea(
930 append_quads_data.checkerboarded_no_recording_content_area); 930 append_quads_data.checkerboarded_no_recording_content_area);
931 rendering_stats_instrumentation_->AddCheckerboardedNeedsRasterContentArea( 931 rendering_stats_instrumentation_->AddCheckerboardedNeedsRasterContentArea(
932 append_quads_data.checkerboarded_needs_raster_content_area); 932 append_quads_data.checkerboarded_needs_raster_content_area);
933 933
934 num_missing_tiles += append_quads_data.num_missing_tiles; 934 num_missing_tiles += append_quads_data.num_missing_tiles;
935 num_incomplete_tiles += append_quads_data.num_incomplete_tiles; 935 num_incomplete_tiles += append_quads_data.num_incomplete_tiles;
936 checkerboarded_no_recording_content_area += 936 checkerboarded_no_recording_content_area +=
937 append_quads_data.checkerboarded_no_recording_content_area; 937 append_quads_data.checkerboarded_no_recording_content_area;
938 checkerboarded_needs_raster_content_area += 938 checkerboarded_needs_raster_content_area +=
939 append_quads_data.checkerboarded_needs_raster_content_area; 939 append_quads_data.checkerboarded_needs_raster_content_area;
940 if (append_quads_data.num_missing_tiles > 0) { 940 if (append_quads_data.num_missing_tiles > 0) {
941 have_missing_animated_tiles |= 941 have_missing_animated_tiles |=
942 !it->was_ever_ready_since_last_transform_animation() || 942 !layer->was_ever_ready_since_last_transform_animation() ||
943 it->screen_space_transform_is_animating(); 943 layer->screen_space_transform_is_animating();
944 } else { 944 } else {
945 it->set_was_ever_ready_since_last_transform_animation(true); 945 layer->set_was_ever_ready_since_last_transform_animation(true);
946 }
jaydasika 2017/03/22 20:49:42 Lines 923-946 was common code for all three states
ajuma 2017/03/24 17:25:07 append_quads_data only gets populated in the layer
946 } 947 }
947 } 948 }
948 949
949 // If CommitToActiveTree() is true, then we wait to draw until 950 // If CommitToActiveTree() is true, then we wait to draw until
950 // NotifyReadyToDraw. That means we're in as good shape as is possible now, 951 // NotifyReadyToDraw. That means we're in as good shape as is possible now,
951 // so there's no reason to stop the draw now (and this is not supported by 952 // so there's no reason to stop the draw now (and this is not supported by
952 // SingleThreadProxy). 953 // SingleThreadProxy).
953 if (have_missing_animated_tiles && !CommitToActiveTree()) 954 if (have_missing_animated_tiles && !CommitToActiveTree())
954 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; 955 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
955 956
(...skipping 3230 matching lines...) Expand 10 before | Expand all | Expand 10 after
4186 worker_context_visibility_ = 4187 worker_context_visibility_ =
4187 worker_context->CacheController()->ClientBecameVisible(); 4188 worker_context->CacheController()->ClientBecameVisible();
4188 } else { 4189 } else {
4189 worker_context->CacheController()->ClientBecameNotVisible( 4190 worker_context->CacheController()->ClientBecameNotVisible(
4190 std::move(worker_context_visibility_)); 4191 std::move(worker_context_visibility_));
4191 } 4192 }
4192 } 4193 }
4193 } 4194 }
4194 4195
4195 } // namespace cc 4196 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698