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

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

Issue 1437413002: cc: Remove ScopedPtrVector and cc::remove_if. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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_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 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 quad->SetNew(shared_quad_state, 753 quad->SetNew(shared_quad_state,
754 screen_space_rect, 754 screen_space_rect,
755 visible_screen_space_rect, 755 visible_screen_space_rect,
756 screen_background_color, 756 screen_background_color,
757 false); 757 false);
758 } 758 }
759 } 759 }
760 760
761 static RenderPass* FindRenderPassById(const RenderPassList& list, 761 static RenderPass* FindRenderPassById(const RenderPassList& list,
762 RenderPassId id) { 762 RenderPassId id) {
763 auto it = std::find_if(list.begin(), list.end(), 763 auto it = std::find_if(
764 [id](const RenderPass* p) { return p->id == id; }); 764 list.begin(), list.end(),
765 return it == list.end() ? nullptr : *it; 765 [id](const scoped_ptr<RenderPass>& p) { return p->id == id; });
766 return it == list.end() ? nullptr : it->get();
766 } 767 }
767 768
768 DrawResult LayerTreeHostImpl::CalculateRenderPasses( 769 DrawResult LayerTreeHostImpl::CalculateRenderPasses(
769 FrameData* frame) { 770 FrameData* frame) {
770 DCHECK(frame->render_passes.empty()); 771 DCHECK(frame->render_passes.empty());
771 DCHECK(CanDraw()); 772 DCHECK(CanDraw());
772 DCHECK(active_tree_->root_layer()); 773 DCHECK(active_tree_->root_layer());
773 774
774 TrackDamageForAllSurfaces(active_tree_->root_layer(), 775 TrackDamageForAllSurfaces(active_tree_->root_layer(),
775 *frame->render_surface_layer_list); 776 *frame->render_surface_layer_list);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 render_surface->AppendRenderPasses(frame); 821 render_surface->AppendRenderPasses(frame);
821 } 822 }
822 823
823 // When we are displaying the HUD, change the root damage rect to cover the 824 // When we are displaying the HUD, change the root damage rect to cover the
824 // entire root surface. This will disable partial-swap/scissor optimizations 825 // entire root surface. This will disable partial-swap/scissor optimizations
825 // that would prevent the HUD from updating, since the HUD does not cause 826 // that would prevent the HUD from updating, since the HUD does not cause
826 // damage itself, to prevent it from messing with damage visualizations. Since 827 // damage itself, to prevent it from messing with damage visualizations. Since
827 // damage visualizations are done off the LayerImpls and RenderSurfaceImpls, 828 // damage visualizations are done off the LayerImpls and RenderSurfaceImpls,
828 // changing the RenderPass does not affect them. 829 // changing the RenderPass does not affect them.
829 if (active_tree_->hud_layer()) { 830 if (active_tree_->hud_layer()) {
830 RenderPass* root_pass = frame->render_passes.back(); 831 RenderPass* root_pass = frame->render_passes.back().get();
831 root_pass->damage_rect = root_pass->output_rect; 832 root_pass->damage_rect = root_pass->output_rect;
832 } 833 }
833 834
834 // Because the active tree could be drawn again if this fails for some reason, 835 // Because the active tree could be drawn again if this fails for some reason,
835 // clear all of the copy request flags so that sanity checks for the counts 836 // clear all of the copy request flags so that sanity checks for the counts
836 // succeed. 837 // succeed.
837 if (!active_tree_->LayersWithCopyOutputRequest().empty()) { 838 if (!active_tree_->LayersWithCopyOutputRequest().empty()) {
838 LayerTreeHostCommon::CallFunctionForSubtree( 839 LayerTreeHostCommon::CallFunctionForSubtree(
839 active_tree_->root_layer(), [](LayerImpl* layer) { 840 active_tree_->root_layer(), [](LayerImpl* layer) {
840 layer->set_num_layer_or_descendant_with_copy_request(0); 841 layer->set_num_layer_or_descendant_with_copy_request(0);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 for (const auto& quad : render_pass->quad_list) 988 for (const auto& quad : render_pass->quad_list)
988 DCHECK(quad->shared_quad_state); 989 DCHECK(quad->shared_quad_state);
989 } 990 }
990 DCHECK(frame->render_passes.back()->output_rect.origin().IsOrigin()); 991 DCHECK(frame->render_passes.back()->output_rect.origin().IsOrigin());
991 #endif 992 #endif
992 993
993 if (!active_tree_->has_transparent_background()) { 994 if (!active_tree_->has_transparent_background()) {
994 frame->render_passes.back()->has_transparent_background = false; 995 frame->render_passes.back()->has_transparent_background = false;
995 AppendQuadsToFillScreen( 996 AppendQuadsToFillScreen(
996 active_tree_->RootScrollLayerDeviceViewportBounds(), 997 active_tree_->RootScrollLayerDeviceViewportBounds(),
997 frame->render_passes.back(), active_tree_->root_layer(), 998 frame->render_passes.back().get(), active_tree_->root_layer(),
998 active_tree_->background_color(), unoccluded_screen_space_region); 999 active_tree_->background_color(), unoccluded_screen_space_region);
999 } 1000 }
1000 1001
1001 RemoveRenderPasses(frame); 1002 RemoveRenderPasses(frame);
1002 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); 1003 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes);
1003 1004
1004 // Any copy requests left in the tree are not going to get serviced, and 1005 // Any copy requests left in the tree are not going to get serviced, and
1005 // should be aborted. 1006 // should be aborted.
1006 ScopedPtrVector<CopyOutputRequest> requests_to_abort; 1007 std::vector<scoped_ptr<CopyOutputRequest>> requests_to_abort;
1007 while (!active_tree_->LayersWithCopyOutputRequest().empty()) { 1008 while (!active_tree_->LayersWithCopyOutputRequest().empty()) {
1008 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back(); 1009 LayerImpl* layer = active_tree_->LayersWithCopyOutputRequest().back();
1009 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort); 1010 layer->TakeCopyRequestsAndTransformToTarget(&requests_to_abort);
1010 } 1011 }
1011 for (size_t i = 0; i < requests_to_abort.size(); ++i) 1012 for (size_t i = 0; i < requests_to_abort.size(); ++i)
1012 requests_to_abort[i]->SendEmptyResult(); 1013 requests_to_abort[i]->SendEmptyResult();
1013 1014
1014 // If we're making a frame to draw, it better have at least one render pass. 1015 // If we're making a frame to draw, it better have at least one render pass.
1015 DCHECK(!frame->render_passes.empty()); 1016 DCHECK(!frame->render_passes.empty());
1016 1017
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 1133
1133 // A set of RenderPasses that we have seen. 1134 // A set of RenderPasses that we have seen.
1134 std::set<RenderPassId> pass_exists; 1135 std::set<RenderPassId> pass_exists;
1135 // A set of RenderPassDrawQuads that we have seen (stored by the RenderPasses 1136 // A set of RenderPassDrawQuads that we have seen (stored by the RenderPasses
1136 // they refer to). 1137 // they refer to).
1137 base::SmallMap<base::hash_map<RenderPassId, int>> pass_references; 1138 base::SmallMap<base::hash_map<RenderPassId, int>> pass_references;
1138 1139
1139 // Iterate RenderPasses in draw order, removing empty render passes (except 1140 // Iterate RenderPasses in draw order, removing empty render passes (except
1140 // the root RenderPass). 1141 // the root RenderPass).
1141 for (size_t i = 0; i < frame->render_passes.size(); ++i) { 1142 for (size_t i = 0; i < frame->render_passes.size(); ++i) {
1142 RenderPass* pass = frame->render_passes[i]; 1143 RenderPass* pass = frame->render_passes[i].get();
1143 1144
1144 // Remove orphan RenderPassDrawQuads. 1145 // Remove orphan RenderPassDrawQuads.
1145 for (auto it = pass->quad_list.begin(); it != pass->quad_list.end();) { 1146 for (auto it = pass->quad_list.begin(); it != pass->quad_list.end();) {
1146 if (it->material != DrawQuad::RENDER_PASS) { 1147 if (it->material != DrawQuad::RENDER_PASS) {
1147 ++it; 1148 ++it;
1148 continue; 1149 continue;
1149 } 1150 }
1150 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(*it); 1151 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(*it);
1151 // If the RenderPass doesn't exist, we can remove the quad. 1152 // If the RenderPass doesn't exist, we can remove the quad.
1152 if (pass_exists.count(quad->render_pass_id)) { 1153 if (pass_exists.count(quad->render_pass_id)) {
(...skipping 22 matching lines...) Expand all
1175 pass_exists.insert(pass->id); 1176 pass_exists.insert(pass->id);
1176 } 1177 }
1177 1178
1178 // Remove RenderPasses that are not referenced by any draw quads or copy 1179 // Remove RenderPasses that are not referenced by any draw quads or copy
1179 // requests (except the root RenderPass). 1180 // requests (except the root RenderPass).
1180 for (size_t i = 0; i < frame->render_passes.size() - 1; ++i) { 1181 for (size_t i = 0; i < frame->render_passes.size() - 1; ++i) {
1181 // Iterating from the back of the list to the front, skipping over the 1182 // Iterating from the back of the list to the front, skipping over the
1182 // back-most (root) pass, in order to remove each qualified RenderPass, and 1183 // back-most (root) pass, in order to remove each qualified RenderPass, and
1183 // drop references to earlier RenderPasses allowing them to be removed to. 1184 // drop references to earlier RenderPasses allowing them to be removed to.
1184 RenderPass* pass = 1185 RenderPass* pass =
1185 frame->render_passes[frame->render_passes.size() - 2 - i]; 1186 frame->render_passes[frame->render_passes.size() - 2 - i].get();
1186 if (!pass->copy_requests.empty()) 1187 if (!pass->copy_requests.empty())
1187 continue; 1188 continue;
1188 if (pass_references[pass->id]) 1189 if (pass_references[pass->id])
1189 continue; 1190 continue;
1190 1191
1191 for (auto it = pass->quad_list.begin(); it != pass->quad_list.end(); ++it) { 1192 for (auto it = pass->quad_list.begin(); it != pass->quad_list.end(); ++it) {
1192 if (it->material != DrawQuad::RENDER_PASS) 1193 if (it->material != DrawQuad::RENDER_PASS)
1193 continue; 1194 continue;
1194 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(*it); 1195 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(*it);
1195 pass_references[quad->render_pass_id]--; 1196 pass_references[quad->render_pass_id]--;
(...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after
3004 gfx::ScrollOffset scroll_delta = layer_impl->PullDeltaForMainThread(); 3005 gfx::ScrollOffset scroll_delta = layer_impl->PullDeltaForMainThread();
3005 3006
3006 if (!scroll_delta.IsZero()) { 3007 if (!scroll_delta.IsZero()) {
3007 LayerTreeHostCommon::ScrollUpdateInfo scroll; 3008 LayerTreeHostCommon::ScrollUpdateInfo scroll;
3008 scroll.layer_id = layer_impl->id(); 3009 scroll.layer_id = layer_impl->id();
3009 scroll.scroll_delta = gfx::Vector2d(scroll_delta.x(), scroll_delta.y()); 3010 scroll.scroll_delta = gfx::Vector2d(scroll_delta.x(), scroll_delta.y());
3010 scroll_info->scrolls.push_back(scroll); 3011 scroll_info->scrolls.push_back(scroll);
3011 } 3012 }
3012 3013
3013 for (size_t i = 0; i < layer_impl->children().size(); ++i) 3014 for (size_t i = 0; i < layer_impl->children().size(); ++i)
3014 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); 3015 CollectScrollDeltas(scroll_info, layer_impl->children()[i].get());
3015 } 3016 }
3016 3017
3017 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { 3018 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() {
3018 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); 3019 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet());
3019 3020
3020 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); 3021 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer());
3021 scroll_info->page_scale_delta = 3022 scroll_info->page_scale_delta =
3022 active_tree_->page_scale_factor()->PullDeltaForMainThread(); 3023 active_tree_->page_scale_factor()->PullDeltaForMainThread();
3023 scroll_info->top_controls_delta = 3024 scroll_info->top_controls_delta =
3024 active_tree()->top_controls_shown_ratio()->PullDeltaForMainThread(); 3025 active_tree()->top_controls_shown_ratio()->PullDeltaForMainThread();
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
3691 return task_runner_provider_->HasImplThread(); 3692 return task_runner_provider_->HasImplThread();
3692 } 3693 }
3693 3694
3694 bool LayerTreeHostImpl::CommitToActiveTree() const { 3695 bool LayerTreeHostImpl::CommitToActiveTree() const {
3695 // In single threaded mode we skip the pending tree and commit directly to the 3696 // In single threaded mode we skip the pending tree and commit directly to the
3696 // active tree. 3697 // active tree.
3697 return !task_runner_provider_->HasImplThread(); 3698 return !task_runner_provider_->HasImplThread();
3698 } 3699 }
3699 3700
3700 } // namespace cc 3701 } // 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