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

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

Issue 2690753002: cc: Move render surface ownership from layers to the effect tree (Closed)
Patch Set: Replace repeated calls to LayerImpl::render_surface Created 3 years, 10 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_impl.h" 5 #include "cc/trees/layer_tree_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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 gfx::SizeF bounds = gfx::SizeF(layer->bounds()); 373 gfx::SizeF bounds = gfx::SizeF(layer->bounds());
374 if (clip_node->clip.size() != bounds) { 374 if (clip_node->clip.size() != bounds) {
375 clip_node->clip.set_size(bounds); 375 clip_node->clip.set_size(bounds);
376 clip_tree->set_needs_update(true); 376 clip_tree->set_needs_update(true);
377 } 377 }
378 } 378 }
379 } 379 }
380 } 380 }
381 381
382 void LayerTreeImpl::SetPropertyTrees(PropertyTrees* property_trees) { 382 void LayerTreeImpl::SetPropertyTrees(PropertyTrees* property_trees) {
383 EffectTree::StableIdRenderSurfaceList stable_id_render_surface_list =
384 property_trees_.effect_tree.CreateStableIdRenderSurfaceList();
385 property_trees_ = *property_trees; 383 property_trees_ = *property_trees;
386 property_trees_.effect_tree.UpdateRenderSurfaceEffectIds(
387 stable_id_render_surface_list, this);
388 property_trees->effect_tree.PushCopyRequestsTo(&property_trees_.effect_tree); 384 property_trees->effect_tree.PushCopyRequestsTo(&property_trees_.effect_tree);
389 property_trees_.is_main_thread = false; 385 property_trees_.is_main_thread = false;
390 property_trees_.is_active = IsActiveTree(); 386 property_trees_.is_active = IsActiveTree();
391 property_trees_.transform_tree.set_source_to_parent_updates_allowed(false); 387 property_trees_.transform_tree.set_source_to_parent_updates_allowed(false);
388 if (property_trees_.effect_tree.needs_update_render_surfaces())
389 set_needs_update_draw_properties();
392 // The value of some effect node properties (like is_drawn) depends on 390 // The value of some effect node properties (like is_drawn) depends on
393 // whether we are on the active tree or not. So, we need to update the 391 // whether we are on the active tree or not. So, we need to update the
394 // effect tree. 392 // effect tree.
395 if (IsActiveTree()) 393 if (IsActiveTree())
396 property_trees_.effect_tree.set_needs_update(true); 394 property_trees_.effect_tree.set_needs_update(true);
397 } 395 }
398 396
399 void LayerTreeImpl::UpdatePropertyTreesForBoundsDelta() { 397 void LayerTreeImpl::UpdatePropertyTreesForBoundsDelta() {
400 DCHECK(IsActiveTree()); 398 DCHECK(IsActiveTree());
401 LayerImpl* inner_container = InnerViewportContainerLayer(); 399 LayerImpl* inner_container = InnerViewportContainerLayer();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 target_tree->has_ever_been_drawn_ = false; 495 target_tree->has_ever_been_drawn_ = false;
498 } 496 }
499 497
500 void LayerTreeImpl::MoveChangeTrackingToLayers() { 498 void LayerTreeImpl::MoveChangeTrackingToLayers() {
501 // We need to update the change tracking on property trees before we move it 499 // We need to update the change tracking on property trees before we move it
502 // onto the layers. 500 // onto the layers.
503 property_trees_.UpdateChangeTracking(); 501 property_trees_.UpdateChangeTracking();
504 for (auto* layer : *this) { 502 for (auto* layer : *this) {
505 if (layer->LayerPropertyChanged()) 503 if (layer->LayerPropertyChanged())
506 layer->NoteLayerPropertyChanged(); 504 layer->NoteLayerPropertyChanged();
507 if (layer->render_surface() && 505 }
508 layer->render_surface()->AncestorPropertyChanged()) 506 EffectTree& effect_tree = property_trees_.effect_tree;
509 layer->render_surface()->NoteAncestorPropertyChanged(); 507 for (int id = EffectTree::kContentsRootNodeId;
508 id < static_cast<int>(effect_tree.size()); ++id) {
509 RenderSurfaceImpl* render_surface = effect_tree.GetRenderSurface(id);
510 if (render_surface && render_surface->AncestorPropertyChanged())
511 render_surface->NoteAncestorPropertyChanged();
510 } 512 }
511 } 513 }
512 514
513 void LayerTreeImpl::ForceRecalculateRasterScales() { 515 void LayerTreeImpl::ForceRecalculateRasterScales() {
514 for (auto* layer : picture_layers_) 516 for (auto* layer : picture_layers_)
515 layer->ResetRasterScale(); 517 layer->ResetRasterScale();
516 } 518 }
517 519
518 LayerImplList::const_iterator LayerTreeImpl::begin() const { 520 LayerImplList::const_iterator LayerTreeImpl::begin() const {
519 return layer_list_.cbegin(); 521 return layer_list_.cbegin();
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 1043
1042 if (it.represents_itself()) { 1044 if (it.represents_itself()) {
1043 it->draw_properties().occlusion_in_content_space = 1045 it->draw_properties().occlusion_in_content_space =
1044 occlusion_tracker.GetCurrentOcclusionForLayer(it->DrawTransform()); 1046 occlusion_tracker.GetCurrentOcclusionForLayer(it->DrawTransform());
1045 } 1047 }
1046 1048
1047 if (it.represents_contributing_render_surface()) { 1049 if (it.represents_contributing_render_surface()) {
1048 const RenderSurfaceImpl* occlusion_surface = 1050 const RenderSurfaceImpl* occlusion_surface =
1049 occlusion_tracker.OcclusionSurfaceForContributingSurface(); 1051 occlusion_tracker.OcclusionSurfaceForContributingSurface();
1050 gfx::Transform draw_transform; 1052 gfx::Transform draw_transform;
1053 RenderSurfaceImpl* render_surface = it->render_surface();
1051 if (occlusion_surface) { 1054 if (occlusion_surface) {
1052 // We are calculating transform between two render surfaces. So, we 1055 // We are calculating transform between two render surfaces. So, we
1053 // need to apply the surface contents scale at target and remove the 1056 // need to apply the surface contents scale at target and remove the
1054 // surface contents scale at source. 1057 // surface contents scale at source.
1055 property_trees()->GetToTarget( 1058 property_trees()->GetToTarget(render_surface->TransformTreeIndex(),
1056 it->render_surface()->TransformTreeIndex(), 1059 occlusion_surface->EffectTreeIndex(),
1057 occlusion_surface->EffectTreeIndex(), &draw_transform); 1060 &draw_transform);
1058 const EffectNode* effect_node = property_trees()->effect_tree.Node( 1061 const EffectNode* effect_node = property_trees()->effect_tree.Node(
1059 it->render_surface()->EffectTreeIndex()); 1062 render_surface->EffectTreeIndex());
1060 draw_property_utils::ConcatInverseSurfaceContentsScale( 1063 draw_property_utils::ConcatInverseSurfaceContentsScale(
1061 effect_node, &draw_transform); 1064 effect_node, &draw_transform);
1062 } 1065 }
1063 1066
1064 Occlusion occlusion = 1067 Occlusion occlusion =
1065 occlusion_tracker.GetCurrentOcclusionForContributingSurface( 1068 occlusion_tracker.GetCurrentOcclusionForContributingSurface(
1066 draw_transform); 1069 draw_transform);
1067 it->render_surface()->set_occlusion_in_content_space(occlusion); 1070 render_surface->set_occlusion_in_content_space(occlusion);
1068 // Masks are used to draw the contributing surface, so should have 1071 // Masks are used to draw the contributing surface, so should have
1069 // the same occlusion as the surface (nothing inside the surface 1072 // the same occlusion as the surface (nothing inside the surface
1070 // occludes them). 1073 // occludes them).
1071 if (LayerImpl* mask = it->render_surface()->MaskLayer()) { 1074 if (LayerImpl* mask = render_surface->MaskLayer()) {
1072 mask->draw_properties().occlusion_in_content_space = 1075 mask->draw_properties().occlusion_in_content_space =
1073 occlusion_tracker.GetCurrentOcclusionForContributingSurface( 1076 occlusion_tracker.GetCurrentOcclusionForContributingSurface(
1074 draw_transform * it->DrawTransform()); 1077 draw_transform * it->DrawTransform());
1075 } 1078 }
1076 } 1079 }
1077 1080
1078 occlusion_tracker.LeaveLayer(it); 1081 occlusion_tracker.LeaveLayer(it);
1079 } 1082 }
1080 1083
1081 unoccluded_screen_space_region_ = 1084 unoccluded_screen_space_region_ =
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 return false; 1764 return false;
1762 1765
1763 return layer_space_region.Contains( 1766 return layer_space_region.Contains(
1764 gfx::ToRoundedPoint(hit_test_point_in_layer_space)); 1767 gfx::ToRoundedPoint(hit_test_point_in_layer_space));
1765 } 1768 }
1766 1769
1767 static const gfx::Transform SurfaceScreenSpaceTransform( 1770 static const gfx::Transform SurfaceScreenSpaceTransform(
1768 const LayerImpl* layer) { 1771 const LayerImpl* layer) {
1769 const PropertyTrees* property_trees = 1772 const PropertyTrees* property_trees =
1770 layer->layer_tree_impl()->property_trees(); 1773 layer->layer_tree_impl()->property_trees();
1771 DCHECK(layer->render_surface()); 1774 RenderSurfaceImpl* render_surface = layer->render_surface();
1775 DCHECK(render_surface);
1772 return layer->is_drawn_render_surface_layer_list_member() 1776 return layer->is_drawn_render_surface_layer_list_member()
1773 ? layer->render_surface()->screen_space_transform() 1777 ? render_surface->screen_space_transform()
1774 : property_trees 1778 : property_trees
1775 ->ToScreenSpaceTransformWithoutSurfaceContentsScale( 1779 ->ToScreenSpaceTransformWithoutSurfaceContentsScale(
1776 layer->render_surface()->TransformTreeIndex(), 1780 render_surface->TransformTreeIndex(),
1777 layer->render_surface()->EffectTreeIndex()); 1781 render_surface->EffectTreeIndex());
1778 } 1782 }
1779 1783
1780 static bool PointIsClippedByAncestorClipNode( 1784 static bool PointIsClippedByAncestorClipNode(
1781 const gfx::PointF& screen_space_point, 1785 const gfx::PointF& screen_space_point,
1782 const LayerImpl* layer) { 1786 const LayerImpl* layer) {
1783 // We need to visit all ancestor clip nodes to check this. Checking with just 1787 // We need to visit all ancestor clip nodes to check this. Checking with just
1784 // the combined clip stored at a clip node is not enough because parent 1788 // the combined clip stored at a clip node is not enough because parent
1785 // combined clip can sometimes be smaller than current combined clip. This can 1789 // combined clip can sometimes be smaller than current combined clip. This can
1786 // happen when we have transforms like rotation that inflate the combined 1790 // happen when we have transforms like rotation that inflate the combined
1787 // clip's bounds. Also, the point can be clipped by the content rect of an 1791 // clip's bounds. Also, the point can be clipped by the content rect of an
(...skipping 17 matching lines...) Expand all
1805 1809
1806 gfx::Transform screen_space_transform = 1810 gfx::Transform screen_space_transform =
1807 transform_tree.ToScreen(clip_node->transform_id); 1811 transform_tree.ToScreen(clip_node->transform_id);
1808 if (!PointHitsRect(screen_space_point, screen_space_transform, clip, 1812 if (!PointHitsRect(screen_space_point, screen_space_transform, clip,
1809 NULL)) { 1813 NULL)) {
1810 return true; 1814 return true;
1811 } 1815 }
1812 } 1816 }
1813 const LayerImpl* clip_node_owner = 1817 const LayerImpl* clip_node_owner =
1814 layer->layer_tree_impl()->LayerById(clip_node->owning_layer_id); 1818 layer->layer_tree_impl()->LayerById(clip_node->owning_layer_id);
1815 if (clip_node_owner->render_surface() && 1819 RenderSurfaceImpl* render_surface = clip_node_owner->render_surface();
1816 !PointHitsRect( 1820 if (render_surface &&
1817 screen_space_point, SurfaceScreenSpaceTransform(clip_node_owner), 1821 !PointHitsRect(screen_space_point,
1818 clip_node_owner->render_surface()->content_rect(), NULL)) { 1822 SurfaceScreenSpaceTransform(clip_node_owner),
1823 render_surface->content_rect(), NULL)) {
1819 return true; 1824 return true;
1820 } 1825 }
1821 } 1826 }
1822 return false; 1827 return false;
1823 } 1828 }
1824 1829
1825 static bool PointIsClippedBySurfaceOrClipRect( 1830 static bool PointIsClippedBySurfaceOrClipRect(
1826 const gfx::PointF& screen_space_point, 1831 const gfx::PointF& screen_space_point,
1827 const LayerImpl* layer) { 1832 const LayerImpl* layer) {
1828 // Walk up the layer tree and hit-test any render_surfaces and any layer 1833 // Walk up the layer tree and hit-test any render_surfaces and any layer
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 2098
2094 void LayerTreeImpl::ResetAllChangeTracking() { 2099 void LayerTreeImpl::ResetAllChangeTracking() {
2095 layers_that_should_push_properties_.clear(); 2100 layers_that_should_push_properties_.clear();
2096 // Iterate over all layers, including masks. 2101 // Iterate over all layers, including masks.
2097 for (auto& layer : *layers_) 2102 for (auto& layer : *layers_)
2098 layer->ResetChangeTracking(); 2103 layer->ResetChangeTracking();
2099 property_trees_.ResetAllChangeTracking(); 2104 property_trees_.ResetAllChangeTracking();
2100 } 2105 }
2101 2106
2102 } // namespace cc 2107 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698