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

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

Issue 246753008: cc: Unify use of DidSwapBuffers() and did_request_swap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 7 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 screen_space_rect.right() / overhang_resource_scaled_size.width(), 691 screen_space_rect.right() / overhang_resource_scaled_size.width(),
692 screen_space_rect.bottom() / 692 screen_space_rect.bottom() /
693 overhang_resource_scaled_size.height()), 693 overhang_resource_scaled_size.height()),
694 screen_background_color, 694 screen_background_color,
695 vertex_opacity, 695 vertex_opacity,
696 false); 696 false);
697 quad_culler.Append(tex_quad.PassAs<DrawQuad>()); 697 quad_culler.Append(tex_quad.PassAs<DrawQuad>());
698 } 698 }
699 } 699 }
700 700
701 DrawSwapReadbackResult::DrawResult LayerTreeHostImpl::CalculateRenderPasses( 701 DrawResult LayerTreeHostImpl::CalculateRenderPasses(
702 FrameData* frame) { 702 FrameData* frame) {
703 DCHECK(frame->render_passes.empty()); 703 DCHECK(frame->render_passes.empty());
704 DCHECK(CanDraw()); 704 DCHECK(CanDraw());
705 DCHECK(active_tree_->root_layer()); 705 DCHECK(active_tree_->root_layer());
706 706
707 TrackDamageForAllSurfaces(active_tree_->root_layer(), 707 TrackDamageForAllSurfaces(active_tree_->root_layer(),
708 *frame->render_surface_layer_list); 708 *frame->render_surface_layer_list);
709 709
710 // If the root render surface has no visible damage, then don't generate a 710 // If the root render surface has no visible damage, then don't generate a
711 // frame at all. 711 // frame at all.
712 RenderSurfaceImpl* root_surface = 712 RenderSurfaceImpl* root_surface =
713 active_tree_->root_layer()->render_surface(); 713 active_tree_->root_layer()->render_surface();
714 bool root_surface_has_no_visible_damage = 714 bool root_surface_has_no_visible_damage =
715 !root_surface->damage_tracker()->current_damage_rect().Intersects( 715 !root_surface->damage_tracker()->current_damage_rect().Intersects(
716 root_surface->content_rect()); 716 root_surface->content_rect());
717 bool root_surface_has_contributing_layers = 717 bool root_surface_has_contributing_layers =
718 !root_surface->layer_list().empty(); 718 !root_surface->layer_list().empty();
719 bool hud_wants_to_draw_ = active_tree_->hud_layer() && 719 bool hud_wants_to_draw_ = active_tree_->hud_layer() &&
720 active_tree_->hud_layer()->IsAnimatingHUDContents(); 720 active_tree_->hud_layer()->IsAnimatingHUDContents();
721 if (root_surface_has_contributing_layers && 721 if (root_surface_has_contributing_layers &&
722 root_surface_has_no_visible_damage && 722 root_surface_has_no_visible_damage &&
723 active_tree_->LayersWithCopyOutputRequest().empty() && 723 active_tree_->LayersWithCopyOutputRequest().empty() &&
724 !hud_wants_to_draw_) { 724 !hud_wants_to_draw_) {
725 TRACE_EVENT0("cc", 725 TRACE_EVENT0("cc",
726 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect"); 726 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect");
727 frame->has_no_damage = true; 727 frame->has_no_damage = true;
728 DCHECK(!output_surface_->capabilities() 728 DCHECK(!output_surface_->capabilities()
729 .draw_and_swap_full_viewport_every_frame); 729 .draw_and_swap_full_viewport_every_frame);
730 return DrawSwapReadbackResult::DRAW_SUCCESS; 730 return DRAW_SUCCESS;
731 } 731 }
732 732
733 TRACE_EVENT1("cc", 733 TRACE_EVENT1("cc",
734 "LayerTreeHostImpl::CalculateRenderPasses", 734 "LayerTreeHostImpl::CalculateRenderPasses",
735 "render_surface_layer_list.size()", 735 "render_surface_layer_list.size()",
736 static_cast<uint64>(frame->render_surface_layer_list->size())); 736 static_cast<uint64>(frame->render_surface_layer_list->size()));
737 737
738 // Create the render passes in dependency order. 738 // Create the render passes in dependency order.
739 for (int surface_index = frame->render_surface_layer_list->size() - 1; 739 for (int surface_index = frame->render_surface_layer_list->size() - 1;
740 surface_index >= 0; 740 surface_index >= 0;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 777 }
778 778
779 // Add quads to the Render passes in front-to-back order to allow for testing 779 // Add quads to the Render passes in front-to-back order to allow for testing
780 // occlusion and performing culling during the tree walk. 780 // occlusion and performing culling during the tree walk.
781 typedef LayerIterator<LayerImpl> LayerIteratorType; 781 typedef LayerIterator<LayerImpl> LayerIteratorType;
782 782
783 // Typically when we are missing a texture and use a checkerboard quad, we 783 // Typically when we are missing a texture and use a checkerboard quad, we
784 // still draw the frame. However when the layer being checkerboarded is moving 784 // still draw the frame. However when the layer being checkerboarded is moving
785 // due to an impl-animation, we drop the frame to avoid flashing due to the 785 // due to an impl-animation, we drop the frame to avoid flashing due to the
786 // texture suddenly appearing in the future. 786 // texture suddenly appearing in the future.
787 DrawSwapReadbackResult::DrawResult draw_result = 787 DrawResult draw_result = DRAW_SUCCESS;
788 DrawSwapReadbackResult::DRAW_SUCCESS;
789 // When we have a copy request for a layer, we need to draw no matter 788 // When we have a copy request for a layer, we need to draw no matter
790 // what, as the layer may disappear after this frame. 789 // what, as the layer may disappear after this frame.
791 bool have_copy_request = false; 790 bool have_copy_request = false;
792 791
793 int layers_drawn = 0; 792 int layers_drawn = 0;
794 793
795 const DrawMode draw_mode = GetDrawMode(output_surface_.get()); 794 const DrawMode draw_mode = GetDrawMode(output_surface_.get());
796 795
797 LayerIteratorType end = 796 LayerIteratorType end =
798 LayerIteratorType::End(frame->render_surface_layer_list); 797 LayerIteratorType::End(frame->render_surface_layer_list);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 865
867 rendering_stats_instrumentation_->AddVisibleContentArea( 866 rendering_stats_instrumentation_->AddVisibleContentArea(
868 append_quads_data.visible_content_area); 867 append_quads_data.visible_content_area);
869 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea( 868 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea(
870 append_quads_data.approximated_visible_content_area); 869 append_quads_data.approximated_visible_content_area);
871 870
872 if (append_quads_data.num_missing_tiles) { 871 if (append_quads_data.num_missing_tiles) {
873 bool layer_has_animating_transform = 872 bool layer_has_animating_transform =
874 it->screen_space_transform_is_animating() || 873 it->screen_space_transform_is_animating() ||
875 it->draw_transform_is_animating(); 874 it->draw_transform_is_animating();
876 if (layer_has_animating_transform) { 875 if (layer_has_animating_transform)
877 draw_result = 876 draw_result = DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
878 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
879 }
880 } 877 }
881 878
882 if (append_quads_data.had_incomplete_tile) { 879 if (append_quads_data.had_incomplete_tile) {
883 frame->contains_incomplete_tile = true; 880 frame->contains_incomplete_tile = true;
884 if (active_tree()->RequiresHighResToDraw()) 881 if (active_tree()->RequiresHighResToDraw())
885 draw_result = 882 draw_result = DRAW_ABORTED_MISSING_HIGH_RES_CONTENT;
886 DrawSwapReadbackResult::DRAW_ABORTED_MISSING_HIGH_RES_CONTENT;
887 } 883 }
888 884
889 occlusion_tracker.LeaveLayer(it); 885 occlusion_tracker.LeaveLayer(it);
890 } 886 }
891 887
892 if (have_copy_request || 888 if (have_copy_request ||
893 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) 889 output_surface_->capabilities().draw_and_swap_full_viewport_every_frame)
894 draw_result = DrawSwapReadbackResult::DRAW_SUCCESS; 890 draw_result = DRAW_SUCCESS;
895 891
896 #if DCHECK_IS_ON 892 #if DCHECK_IS_ON
897 for (size_t i = 0; i < frame->render_passes.size(); ++i) { 893 for (size_t i = 0; i < frame->render_passes.size(); ++i) {
898 for (size_t j = 0; j < frame->render_passes[i]->quad_list.size(); ++j) 894 for (size_t j = 0; j < frame->render_passes[i]->quad_list.size(); ++j)
899 DCHECK(frame->render_passes[i]->quad_list[j]->shared_quad_state); 895 DCHECK(frame->render_passes[i]->quad_list[j]->shared_quad_state);
900 DCHECK(frame->render_passes_by_id.find(frame->render_passes[i]->id) 896 DCHECK(frame->render_passes_by_id.find(frame->render_passes[i]->id)
901 != frame->render_passes_by_id.end()); 897 != frame->render_passes_by_id.end());
902 } 898 }
903 #endif 899 #endif
904 DCHECK(frame->render_passes.back()->output_rect.origin().IsOrigin()); 900 DCHECK(frame->render_passes.back()->output_rect.origin().IsOrigin());
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 // change. So, capture the iterator position from the end of the 1075 // change. So, capture the iterator position from the end of the
1080 // list, and restore it after the change. 1076 // list, and restore it after the change.
1081 size_t position_from_end = frame->render_passes.size() - it; 1077 size_t position_from_end = frame->render_passes.size() - it;
1082 RemoveRenderPassesRecursive(render_pass_quad->render_pass_id, frame); 1078 RemoveRenderPassesRecursive(render_pass_quad->render_pass_id, frame);
1083 it = frame->render_passes.size() - position_from_end; 1079 it = frame->render_passes.size() - position_from_end;
1084 DCHECK_GE(frame->render_passes.size(), position_from_end); 1080 DCHECK_GE(frame->render_passes.size(), position_from_end);
1085 } 1081 }
1086 } 1082 }
1087 } 1083 }
1088 1084
1089 DrawSwapReadbackResult::DrawResult LayerTreeHostImpl::PrepareToDraw( 1085 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame,
1090 FrameData* frame, 1086 const gfx::Rect& damage_rect) {
1091 const gfx::Rect& damage_rect) {
1092 TRACE_EVENT1("cc", 1087 TRACE_EVENT1("cc",
1093 "LayerTreeHostImpl::PrepareToDraw", 1088 "LayerTreeHostImpl::PrepareToDraw",
1094 "SourceFrameNumber", 1089 "SourceFrameNumber",
1095 active_tree_->source_frame_number()); 1090 active_tree_->source_frame_number());
1096 1091
1097 if (need_to_update_visible_tiles_before_draw_ && 1092 if (need_to_update_visible_tiles_before_draw_ &&
1098 tile_manager_ && tile_manager_->UpdateVisibleTiles()) { 1093 tile_manager_ && tile_manager_->UpdateVisibleTiles()) {
1099 DidInitializeVisibleTile(); 1094 DidInitializeVisibleTile();
1100 } 1095 }
1101 need_to_update_visible_tiles_before_draw_ = true; 1096 need_to_update_visible_tiles_before_draw_ = true;
1102 1097
1103 active_tree_->UpdateDrawProperties(); 1098 active_tree_->UpdateDrawProperties();
1104 1099
1105 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); 1100 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList();
1106 frame->render_passes.clear(); 1101 frame->render_passes.clear();
1107 frame->render_passes_by_id.clear(); 1102 frame->render_passes_by_id.clear();
1108 frame->will_draw_layers.clear(); 1103 frame->will_draw_layers.clear();
1109 frame->contains_incomplete_tile = false; 1104 frame->contains_incomplete_tile = false;
1110 frame->has_no_damage = false; 1105 frame->has_no_damage = false;
1111 1106
1112 gfx::Rect device_viewport_damage_rect(damage_rect); 1107 gfx::Rect device_viewport_damage_rect(damage_rect);
1113 if (active_tree_->root_layer()) { 1108 if (active_tree_->root_layer()) {
1114 device_viewport_damage_rect.Union(viewport_damage_rect_); 1109 device_viewport_damage_rect.Union(viewport_damage_rect_);
1115 viewport_damage_rect_ = gfx::Rect(); 1110 viewport_damage_rect_ = gfx::Rect();
1116 1111
1117 active_tree_->root_layer()->render_surface()->damage_tracker()-> 1112 active_tree_->root_layer()->render_surface()->damage_tracker()->
1118 AddDamageNextUpdate(device_viewport_damage_rect); 1113 AddDamageNextUpdate(device_viewport_damage_rect);
1119 } 1114 }
1120 1115
1121 DrawSwapReadbackResult::DrawResult draw_result = CalculateRenderPasses(frame); 1116 DrawResult draw_result = CalculateRenderPasses(frame);
1122 if (draw_result != DrawSwapReadbackResult::DRAW_SUCCESS) { 1117 if (draw_result != DRAW_SUCCESS) {
1123 DCHECK(!output_surface_->capabilities() 1118 DCHECK(!output_surface_->capabilities()
1124 .draw_and_swap_full_viewport_every_frame); 1119 .draw_and_swap_full_viewport_every_frame);
1125 return draw_result; 1120 return draw_result;
1126 } 1121 }
1127 1122
1128 // If we return DRAW_SUCCESS, then we expect DrawLayers() to be called before 1123 // If we return DRAW_SUCCESS, then we expect DrawLayers() to be called before
1129 // this function is called again. 1124 // this function is called again.
1130 return draw_result; 1125 return draw_result;
1131 } 1126 }
1132 1127
(...skipping 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after
3125 swap_promise_monitor_.erase(monitor); 3120 swap_promise_monitor_.erase(monitor);
3126 } 3121 }
3127 3122
3128 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { 3123 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() {
3129 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3124 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3130 for (; it != swap_promise_monitor_.end(); it++) 3125 for (; it != swap_promise_monitor_.end(); it++)
3131 (*it)->OnSetNeedsRedrawOnImpl(); 3126 (*it)->OnSetNeedsRedrawOnImpl();
3132 } 3127 }
3133 3128
3134 } // namespace cc 3129 } // 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