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

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

Issue 2017263002: cc: Move copy requests from layers to the effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo in comment Created 4 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
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 active_tree_->root_layer()->render_surface(); 785 active_tree_->root_layer()->render_surface();
786 bool root_surface_has_no_visible_damage = 786 bool root_surface_has_no_visible_damage =
787 !root_surface->damage_tracker()->current_damage_rect().Intersects( 787 !root_surface->damage_tracker()->current_damage_rect().Intersects(
788 root_surface->content_rect()); 788 root_surface->content_rect());
789 bool root_surface_has_contributing_layers = 789 bool root_surface_has_contributing_layers =
790 !root_surface->layer_list().empty(); 790 !root_surface->layer_list().empty();
791 bool hud_wants_to_draw_ = active_tree_->hud_layer() && 791 bool hud_wants_to_draw_ = active_tree_->hud_layer() &&
792 active_tree_->hud_layer()->IsAnimatingHUDContents(); 792 active_tree_->hud_layer()->IsAnimatingHUDContents();
793 if (root_surface_has_contributing_layers && 793 if (root_surface_has_contributing_layers &&
794 root_surface_has_no_visible_damage && 794 root_surface_has_no_visible_damage &&
795 active_tree_->LayersWithCopyOutputRequest().empty() && 795 !active_tree_->property_trees()->effect_tree.HasCopyRequests() &&
796 !output_surface_->capabilities().can_force_reclaim_resources && 796 !output_surface_->capabilities().can_force_reclaim_resources &&
797 !hud_wants_to_draw_) { 797 !hud_wants_to_draw_) {
798 TRACE_EVENT0("cc", 798 TRACE_EVENT0("cc",
799 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect"); 799 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect");
800 frame->has_no_damage = true; 800 frame->has_no_damage = true;
801 DCHECK(!resourceless_software_draw_); 801 DCHECK(!resourceless_software_draw_);
802 return DRAW_SUCCESS; 802 return DRAW_SUCCESS;
803 } 803 }
804 804
805 TRACE_EVENT_BEGIN2( 805 TRACE_EVENT_BEGIN2(
806 "cc", "LayerTreeHostImpl::CalculateRenderPasses", 806 "cc", "LayerTreeHostImpl::CalculateRenderPasses",
807 "render_surface_layer_list.size()", 807 "render_surface_layer_list.size()",
808 static_cast<uint64_t>(frame->render_surface_layer_list->size()), 808 static_cast<uint64_t>(frame->render_surface_layer_list->size()),
809 "RequiresHighResToDraw", RequiresHighResToDraw()); 809 "RequiresHighResToDraw", RequiresHighResToDraw());
810 810
811 // Create the render passes in dependency order. 811 // Create the render passes in dependency order.
812 size_t render_surface_layer_list_size = 812 size_t render_surface_layer_list_size =
813 frame->render_surface_layer_list->size(); 813 frame->render_surface_layer_list->size();
814 for (size_t i = 0; i < render_surface_layer_list_size; ++i) { 814 for (size_t i = 0; i < render_surface_layer_list_size; ++i) {
815 size_t surface_index = render_surface_layer_list_size - 1 - i; 815 size_t surface_index = render_surface_layer_list_size - 1 - i;
816 LayerImpl* render_surface_layer = 816 LayerImpl* render_surface_layer =
817 (*frame->render_surface_layer_list)[surface_index]; 817 (*frame->render_surface_layer_list)[surface_index];
818 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface(); 818 RenderSurfaceImpl* render_surface = render_surface_layer->render_surface();
819 819
820 bool should_draw_into_render_pass = 820 bool should_draw_into_render_pass =
821 active_tree_->IsRootLayer(render_surface_layer) || 821 active_tree_->IsRootLayer(render_surface_layer) ||
822 render_surface->contributes_to_drawn_surface() || 822 render_surface->contributes_to_drawn_surface() ||
823 render_surface_layer->HasCopyRequest(); 823 render_surface->HasCopyRequest();
824 if (should_draw_into_render_pass) 824 if (should_draw_into_render_pass)
825 render_surface->AppendRenderPasses(frame); 825 render_surface->AppendRenderPasses(frame);
826 } 826 }
827 827
828 // Damage rects for non-root passes aren't meaningful, so set them to be 828 // Damage rects for non-root passes aren't meaningful, so set them to be
829 // equal to the output rect. 829 // equal to the output rect.
830 for (size_t i = 0; i + 1 < frame->render_passes.size(); ++i) { 830 for (size_t i = 0; i + 1 < frame->render_passes.size(); ++i) {
831 RenderPass* pass = frame->render_passes[i].get(); 831 RenderPass* pass = frame->render_passes[i].get();
832 pass->damage_rect = pass->output_rect; 832 pass->damage_rect = pass->output_rect;
833 } 833 }
834 834
835 // When we are displaying the HUD, change the root damage rect to cover the 835 // When we are displaying the HUD, change the root damage rect to cover the
836 // entire root surface. This will disable partial-swap/scissor optimizations 836 // entire root surface. This will disable partial-swap/scissor optimizations
837 // that would prevent the HUD from updating, since the HUD does not cause 837 // that would prevent the HUD from updating, since the HUD does not cause
838 // damage itself, to prevent it from messing with damage visualizations. Since 838 // damage itself, to prevent it from messing with damage visualizations. Since
839 // damage visualizations are done off the LayerImpls and RenderSurfaceImpls, 839 // damage visualizations are done off the LayerImpls and RenderSurfaceImpls,
840 // changing the RenderPass does not affect them. 840 // changing the RenderPass does not affect them.
841 if (active_tree_->hud_layer()) { 841 if (active_tree_->hud_layer()) {
842 RenderPass* root_pass = frame->render_passes.back().get(); 842 RenderPass* root_pass = frame->render_passes.back().get();
843 root_pass->damage_rect = root_pass->output_rect; 843 root_pass->damage_rect = root_pass->output_rect;
844 } 844 }
845 845
846 // Because the active tree could be drawn again if this fails for some reason,
847 // clear all of the copy request flags so that sanity checks for the counts
848 // succeed.
849 if (!active_tree_->LayersWithCopyOutputRequest().empty()) {
850 active_tree()->property_trees()->effect_tree.ClearCopyRequests();
851 }
852
853 // Grab this region here before iterating layers. Taking copy requests from 846 // Grab this region here before iterating layers. Taking copy requests from
854 // the layers while constructing the render passes will dirty the render 847 // the layers while constructing the render passes will dirty the render
855 // surface layer list and this unoccluded region, flipping the dirty bit to 848 // surface layer list and this unoccluded region, flipping the dirty bit to
856 // true, and making us able to query for it without doing 849 // true, and making us able to query for it without doing
857 // UpdateDrawProperties again. The value inside the Region is not actually 850 // UpdateDrawProperties again. The value inside the Region is not actually
858 // changed until UpdateDrawProperties happens, so a reference to it is safe. 851 // changed until UpdateDrawProperties happens, so a reference to it is safe.
859 const Region& unoccluded_screen_space_region = 852 const Region& unoccluded_screen_space_region =
860 active_tree_->UnoccludedScreenSpaceRegion(); 853 active_tree_->UnoccludedScreenSpaceRegion();
861 854
862 // Typically when we are missing a texture and use a checkerboard quad, we 855 // Typically when we are missing a texture and use a checkerboard quad, we
863 // still draw the frame. However when the layer being checkerboarded is moving 856 // still draw the frame. However when the layer being checkerboarded is moving
864 // due to an impl-animation, we drop the frame to avoid flashing due to the 857 // due to an impl-animation, we drop the frame to avoid flashing due to the
865 // texture suddenly appearing in the future. 858 // texture suddenly appearing in the future.
866 DrawResult draw_result = DRAW_SUCCESS; 859 DrawResult draw_result = DRAW_SUCCESS;
867 860
868 int layers_drawn = 0; 861 int layers_drawn = 0;
869 862
870 const DrawMode draw_mode = GetDrawMode(); 863 const DrawMode draw_mode = GetDrawMode();
871 864
872 int num_missing_tiles = 0; 865 int num_missing_tiles = 0;
873 int num_incomplete_tiles = 0; 866 int num_incomplete_tiles = 0;
874 int64_t checkerboarded_no_recording_content_area = 0; 867 int64_t checkerboarded_no_recording_content_area = 0;
875 int64_t checkerboarded_needs_raster_content_area = 0; 868 int64_t checkerboarded_needs_raster_content_area = 0;
876 bool have_copy_request = false; 869 bool have_copy_request =
870 active_tree()->property_trees()->effect_tree.HasCopyRequests();
877 bool have_missing_animated_tiles = false; 871 bool have_missing_animated_tiles = false;
878 872
879 LayerIterator end = LayerIterator::End(frame->render_surface_layer_list); 873 LayerIterator end = LayerIterator::End(frame->render_surface_layer_list);
880 for (LayerIterator it = 874 for (LayerIterator it =
881 LayerIterator::Begin(frame->render_surface_layer_list); 875 LayerIterator::Begin(frame->render_surface_layer_list);
882 it != end; ++it) { 876 it != end; ++it) {
883 RenderPassId target_render_pass_id = 877 RenderPassId target_render_pass_id =
884 it.target_render_surface_layer()->render_surface()->GetRenderPassId(); 878 it.target_render_surface_layer()->render_surface()->GetRenderPassId();
885 RenderPass* target_render_pass = 879 RenderPass* target_render_pass =
886 FindRenderPassById(frame->render_passes, target_render_pass_id); 880 FindRenderPassById(frame->render_passes, target_render_pass_id);
887 881
888 AppendQuadsData append_quads_data; 882 AppendQuadsData append_quads_data;
889 883
890 if (it.represents_target_render_surface()) { 884 if (it.represents_target_render_surface()) {
891 if (it->HasCopyRequest()) { 885 if (it->render_surface()->HasCopyRequest()) {
892 have_copy_request = true; 886 active_tree()
893 it->TakeCopyRequestsAndTransformToTarget( 887 ->property_trees()
894 &target_render_pass->copy_requests); 888 ->effect_tree.TakeCopyRequestsAndTransformToSurface(
889 it->render_surface()->EffectTreeIndex(),
890 &target_render_pass->copy_requests);
895 } 891 }
896 } else if (it.represents_contributing_render_surface() && 892 } else if (it.represents_contributing_render_surface() &&
897 it->render_surface()->contributes_to_drawn_surface()) { 893 it->render_surface()->contributes_to_drawn_surface()) {
898 RenderPassId contributing_render_pass_id = 894 RenderPassId contributing_render_pass_id =
899 it->render_surface()->GetRenderPassId(); 895 it->render_surface()->GetRenderPassId();
900 RenderPass* contributing_render_pass = 896 RenderPass* contributing_render_pass =
901 FindRenderPassById(frame->render_passes, contributing_render_pass_id); 897 FindRenderPassById(frame->render_passes, contributing_render_pass_id);
902 AppendQuadsForRenderSurfaceLayer(target_render_pass, 898 AppendQuadsForRenderSurfaceLayer(target_render_pass,
903 *it, 899 *it,
904 contributing_render_pass, 900 contributing_render_pass,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 frame->render_passes.back()->has_transparent_background = false; 975 frame->render_passes.back()->has_transparent_background = false;
980 AppendQuadsToFillScreen( 976 AppendQuadsToFillScreen(
981 active_tree_->RootScrollLayerDeviceViewportBounds(), 977 active_tree_->RootScrollLayerDeviceViewportBounds(),
982 frame->render_passes.back().get(), active_tree_->root_layer(), 978 frame->render_passes.back().get(), active_tree_->root_layer(),
983 active_tree_->background_color(), unoccluded_screen_space_region); 979 active_tree_->background_color(), unoccluded_screen_space_region);
984 } 980 }
985 981
986 RemoveRenderPasses(frame); 982 RemoveRenderPasses(frame);
987 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); 983 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes);
988 984
989 // Any copy requests left in the tree are not going to get serviced, and 985 if (have_copy_request) {
990 // should be aborted. 986 // Any copy requests left in the tree are not going to get serviced, and
991 std::vector<std::unique_ptr<CopyOutputRequest>> requests_to_abort; 987 // should be aborted.
992 while (!active_tree_->LayersWithCopyOutputRequest().empty()) { 988 active_tree()->property_trees()->effect_tree.ClearCopyRequests();
993 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); 989
994 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); 990 // Draw properties depend on copy requests.
991 active_tree()->set_needs_update_draw_properties();
995 } 992 }
996 for (size_t i = 0; i < requests_to_abort.size(); ++i)
997 requests_to_abort[i]->SendEmptyResult();
998 993
999 // If we're making a frame to draw, it better have at least one render pass. 994 // If we're making a frame to draw, it better have at least one render pass.
1000 DCHECK(!frame->render_passes.empty()); 995 DCHECK(!frame->render_passes.empty());
1001 996
1002 if (active_tree_->has_ever_been_drawn()) { 997 if (active_tree_->has_ever_been_drawn()) {
1003 UMA_HISTOGRAM_COUNTS_100( 998 UMA_HISTOGRAM_COUNTS_100(
1004 "Compositing.RenderPass.AppendQuadData.NumMissingTiles", 999 "Compositing.RenderPass.AppendQuadData.NumMissingTiles",
1005 num_missing_tiles); 1000 num_missing_tiles);
1006 UMA_HISTOGRAM_COUNTS_100( 1001 UMA_HISTOGRAM_COUNTS_100(
1007 "Compositing.RenderPass.AppendQuadData.NumIncompleteTiles", 1002 "Compositing.RenderPass.AppendQuadData.NumIncompleteTiles",
(...skipping 3014 matching lines...) Expand 10 before | Expand all | Expand 10 after
4022 const { 4017 const {
4023 return fixed_raster_scale_attempted_scale_change_history_.count() >= 4018 return fixed_raster_scale_attempted_scale_change_history_.count() >=
4024 kFixedRasterScaleAttemptedScaleChangeThreshold; 4019 kFixedRasterScaleAttemptedScaleChangeThreshold;
4025 } 4020 }
4026 4021
4027 void LayerTreeHostImpl::SetFixedRasterScaleAttemptedToChangeScale() { 4022 void LayerTreeHostImpl::SetFixedRasterScaleAttemptedToChangeScale() {
4028 fixed_raster_scale_attempted_scale_change_history_.set(0); 4023 fixed_raster_scale_attempted_scale_change_history_.set(0);
4029 } 4024 }
4030 4025
4031 } // namespace cc 4026 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698