Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 760 } | 760 } |
| 761 | 761 |
| 762 static RenderPass* FindRenderPassById(const RenderPassList& list, | 762 static RenderPass* FindRenderPassById(const RenderPassList& list, |
| 763 RenderPassId id) { | 763 RenderPassId id) { |
| 764 auto it = std::find_if( | 764 auto it = std::find_if( |
| 765 list.begin(), list.end(), | 765 list.begin(), list.end(), |
| 766 [id](const std::unique_ptr<RenderPass>& p) { return p->id == id; }); | 766 [id](const std::unique_ptr<RenderPass>& p) { return p->id == id; }); |
| 767 return it == list.end() ? nullptr : it->get(); | 767 return it == list.end() ? nullptr : it->get(); |
| 768 } | 768 } |
| 769 | 769 |
| 770 DrawResult LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) { | 770 DrawResult LayerTreeHostImpl::CalculateRenderPasses( |
| 771 FrameData* frame, | |
| 772 bool handle_visibility_changed) { | |
| 771 DCHECK(frame->render_passes.empty()); | 773 DCHECK(frame->render_passes.empty()); |
| 772 DCHECK(CanDraw()); | 774 DCHECK(CanDraw()); |
| 773 DCHECK(!active_tree_->LayerListIsEmpty()); | 775 DCHECK(!active_tree_->LayerListIsEmpty()); |
| 774 | 776 |
| 775 TrackDamageForAllSurfaces(*frame->render_surface_layer_list); | 777 TrackDamageForAllSurfaces(*frame->render_surface_layer_list); |
| 776 | 778 |
| 777 // If the root render surface has no visible damage, then don't generate a | 779 // If the root render surface has no visible damage, then don't generate a |
| 778 // frame at all. | 780 // frame at all. |
| 779 RenderSurfaceImpl* root_surface = active_tree_->RootRenderSurface(); | 781 RenderSurfaceImpl* root_surface = active_tree_->RootRenderSurface(); |
| 780 bool root_surface_has_no_visible_damage = | 782 bool root_surface_has_no_visible_damage = |
| 781 !root_surface->damage_tracker()->current_damage_rect().Intersects( | 783 !root_surface->damage_tracker()->current_damage_rect().Intersects( |
| 782 root_surface->content_rect()); | 784 root_surface->content_rect()); |
| 783 bool root_surface_has_contributing_layers = | 785 bool root_surface_has_contributing_layers = |
| 784 !root_surface->layer_list().empty(); | 786 !root_surface->layer_list().empty(); |
| 785 bool hud_wants_to_draw_ = active_tree_->hud_layer() && | 787 bool hud_wants_to_draw_ = active_tree_->hud_layer() && |
| 786 active_tree_->hud_layer()->IsAnimatingHUDContents(); | 788 active_tree_->hud_layer()->IsAnimatingHUDContents(); |
| 787 bool resources_must_be_resent = | 789 bool resources_must_be_resent = |
| 788 compositor_frame_sink_->capabilities().can_force_reclaim_resources; | 790 compositor_frame_sink_->capabilities().can_force_reclaim_resources; |
| 789 if (root_surface_has_contributing_layers && | 791 if (root_surface_has_contributing_layers && |
| 790 root_surface_has_no_visible_damage && | 792 root_surface_has_no_visible_damage && |
| 791 !active_tree_->property_trees()->effect_tree.HasCopyRequests() && | 793 !active_tree_->property_trees()->effect_tree.HasCopyRequests() && |
| 792 !resources_must_be_resent && !hud_wants_to_draw_) { | 794 !resources_must_be_resent && !hud_wants_to_draw_ && |
| 795 // When touch handle visibility changes there is no visible damage | |
| 796 // because touch handles are composited in the browser. However we | |
| 797 // still want the browser to be notified that the handles changed | |
| 798 // through the |ViewHostMsg_SwapCompositorFrame| IPC so we keep | |
| 799 // track of handle visibility changes through |handle_visibility_changed|. | |
| 800 !handle_visibility_changed) { | |
| 793 TRACE_EVENT0("cc", | 801 TRACE_EVENT0("cc", |
| 794 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect"); | 802 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect"); |
| 795 frame->has_no_damage = true; | 803 frame->has_no_damage = true; |
| 796 DCHECK(!resourceless_software_draw_); | 804 DCHECK(!resourceless_software_draw_); |
| 797 return DRAW_SUCCESS; | 805 return DRAW_SUCCESS; |
| 798 } | 806 } |
| 799 | 807 |
| 800 TRACE_EVENT_BEGIN2( | 808 TRACE_EVENT_BEGIN2( |
| 801 "cc", "LayerTreeHostImpl::CalculateRenderPasses", | 809 "cc", "LayerTreeHostImpl::CalculateRenderPasses", |
| 802 "render_surface_layer_list.size()", | 810 "render_surface_layer_list.size()", |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 frame->may_contain_video = false; | 1098 frame->may_contain_video = false; |
| 1091 | 1099 |
| 1092 if (active_tree_->RootRenderSurface()) { | 1100 if (active_tree_->RootRenderSurface()) { |
| 1093 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; | 1101 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; |
| 1094 viewport_damage_rect_ = gfx::Rect(); | 1102 viewport_damage_rect_ = gfx::Rect(); |
| 1095 | 1103 |
| 1096 active_tree_->RootRenderSurface()->damage_tracker()->AddDamageNextUpdate( | 1104 active_tree_->RootRenderSurface()->damage_tracker()->AddDamageNextUpdate( |
| 1097 device_viewport_damage_rect); | 1105 device_viewport_damage_rect); |
| 1098 } | 1106 } |
| 1099 | 1107 |
| 1100 DrawResult draw_result = CalculateRenderPasses(frame); | 1108 DrawResult draw_result = CalculateRenderPasses( |
| 1109 frame, active_tree_->GetAndResetHandleVisibilityChanged()); | |
|
danakj
2016/10/21 20:53:33
can you call this from inside CalculateRenderPasse
amaralp
2016/10/26 05:03:40
Done
| |
| 1101 if (draw_result != DRAW_SUCCESS) { | 1110 if (draw_result != DRAW_SUCCESS) { |
| 1102 DCHECK(!resourceless_software_draw_); | 1111 DCHECK(!resourceless_software_draw_); |
| 1103 return draw_result; | 1112 return draw_result; |
| 1104 } | 1113 } |
| 1105 | 1114 |
| 1106 // If we return DRAW_SUCCESS, then we expect DrawLayers() to be called before | 1115 // If we return DRAW_SUCCESS, then we expect DrawLayers() to be called before |
| 1107 // this function is called again. | 1116 // this function is called again. |
| 1108 return draw_result; | 1117 return draw_result; |
| 1109 } | 1118 } |
| 1110 | 1119 |
| (...skipping 2991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4102 if (is_visible) { | 4111 if (is_visible) { |
| 4103 worker_context_visibility_ = | 4112 worker_context_visibility_ = |
| 4104 worker_context->CacheController()->ClientBecameVisible(); | 4113 worker_context->CacheController()->ClientBecameVisible(); |
| 4105 } else { | 4114 } else { |
| 4106 worker_context->CacheController()->ClientBecameNotVisible( | 4115 worker_context->CacheController()->ClientBecameNotVisible( |
| 4107 std::move(worker_context_visibility_)); | 4116 std::move(worker_context_visibility_)); |
| 4108 } | 4117 } |
| 4109 } | 4118 } |
| 4110 | 4119 |
| 4111 } // namespace cc | 4120 } // namespace cc |
| OLD | NEW |