diff options
author | jaydasika <jaydasika@chromium.org> | 2016-03-03 09:21:21 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-03 17:22:13 +0000 |
commit | c72bc6c48f298be8be59ab0531bcadb57b783c31 (patch) | |
tree | 2757d1f092615734f8e1fdd6d5c44181f6d7d573 /cc | |
parent | 4faa7714d832789e56fc2064ac86e3af61557bee (diff) | |
download | chromium_src-c72bc6c48f298be8be59ab0531bcadb57b783c31.zip chromium_src-c72bc6c48f298be8be59ab0531bcadb57b783c31.tar.gz chromium_src-c72bc6c48f298be8be59ab0531bcadb57b783c31.tar.bz2 |
cc : Remove dead code from LayerTreeHostCommon
Dead code because CDP is gone
BUG=581832
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1764483002
Cr-Commit-Position: refs/heads/master@{#379027}
Diffstat (limited to 'cc')
-rw-r--r-- | cc/trees/layer_tree_host_common.cc | 491 |
1 files changed, 0 insertions, 491 deletions
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index c8baceb..430a005 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -245,162 +245,11 @@ gfx::Rect LayerTreeHostCommon::CalculateVisibleRect( target_surface_rect, layer_bound_rect, layer_in_surface_space, transform); } -static const LayerImpl* NextTargetSurface(const LayerImpl* layer) { - return layer->parent() ? layer->parent()->render_target() : 0; -} - -// Given two layers, this function finds their respective render targets and, -// computes a change of basis translation. It does this by accumulating the -// translation components of the draw transforms of each target between the -// ancestor and descendant. These transforms must be 2D translations, and this -// requirement is enforced at every step. -static gfx::Vector2dF ComputeChangeOfBasisTranslation( - const LayerImpl& ancestor_layer, - const LayerImpl& descendant_layer) { - DCHECK(descendant_layer.HasAncestor(&ancestor_layer)); - const LayerImpl* descendant_target = descendant_layer.render_target(); - DCHECK(descendant_target); - const LayerImpl* ancestor_target = ancestor_layer.render_target(); - DCHECK(ancestor_target); - - gfx::Vector2dF translation; - for (const LayerImpl* target = descendant_target; target != ancestor_target; - target = NextTargetSurface(target)) { - const gfx::Transform& trans = target->render_surface()->draw_transform(); - // Ensure that this translation is truly 2d. - DCHECK(trans.IsIdentityOrTranslation()); - DCHECK_EQ(0.f, trans.matrix().get(2, 3)); - translation += trans.To2dTranslation(); - } - - return translation; -} - -enum TranslateRectDirection { - TRANSLATE_RECT_DIRECTION_TO_ANCESTOR, - TRANSLATE_RECT_DIRECTION_TO_DESCENDANT -}; - -static gfx::Rect TranslateRectToTargetSpace(const LayerImpl& ancestor_layer, - const LayerImpl& descendant_layer, - const gfx::Rect& rect, - TranslateRectDirection direction) { - gfx::Vector2dF translation = - ComputeChangeOfBasisTranslation(ancestor_layer, descendant_layer); - if (direction == TRANSLATE_RECT_DIRECTION_TO_DESCENDANT) - translation.Scale(-1.f); - gfx::RectF rect_f = gfx::RectF(rect); - return gfx::ToEnclosingRect( - gfx::RectF(rect_f.origin() + translation, rect_f.size())); -} - -// We collect an accumulated drawable content rect per render surface. -// Typically, a layer will contribute to only one surface, the surface -// associated with its render target. Clip children, however, may affect -// several surfaces since there may be several surfaces between the clip child -// and its parent. -// -// NB: we accumulate the layer's *clipped* drawable content rect. -struct AccumulatedSurfaceState { - explicit AccumulatedSurfaceState(LayerImpl* render_target) - : render_target(render_target) {} - - // The accumulated drawable content rect for the surface associated with the - // given |render_target|. - gfx::Rect drawable_content_rect; - - // The target owning the surface. (We hang onto the target rather than the - // surface so that we can DCHECK that the surface's draw transform is simply - // a translation when |render_target| reports that it has no unclipped - // descendants). - LayerImpl* render_target; -}; - template <typename LayerType> static inline bool IsRootLayer(LayerType* layer) { return !layer->parent(); } -void UpdateAccumulatedSurfaceState( - LayerImpl* layer, - const gfx::Rect& drawable_content_rect, - std::vector<AccumulatedSurfaceState>* accumulated_surface_state) { - if (IsRootLayer(layer)) - return; - - // We will apply our drawable content rect to the accumulated rects for all - // surfaces between us and |render_target| (inclusive). This is either our - // clip parent's target if we are a clip child, or else simply our parent's - // target. We use our parent's target because we're either the owner of a - // render surface and we'll want to add our rect to our *surface's* target, or - // we're not and our target is the same as our parent's. In both cases, the - // parent's target gives us what we want. - LayerImpl* render_target = layer->clip_parent() - ? layer->clip_parent()->render_target() - : layer->parent()->render_target(); - - // If the layer owns a surface, then the content rect is in the wrong space. - // Instead, we will use the surface's DrawableContentRect which is in target - // space as required. - gfx::Rect target_rect = drawable_content_rect; - if (layer->render_surface()) { - target_rect = - gfx::ToEnclosedRect(layer->render_surface()->DrawableContentRect()); - } - - if (render_target->is_clipped()) { - gfx::Rect clip_rect = render_target->clip_rect(); - // If the layer has a clip parent, the clip rect may be in the wrong space, - // so we'll need to transform it before it is applied. - if (layer->clip_parent()) { - clip_rect = - TranslateRectToTargetSpace(*layer->clip_parent(), *layer, clip_rect, - TRANSLATE_RECT_DIRECTION_TO_DESCENDANT); - } - target_rect.Intersect(clip_rect); - } - - // We must have at least one entry in the vector for the root. - DCHECK_LT(0ul, accumulated_surface_state->size()); - - typedef std::vector<AccumulatedSurfaceState> AccumulatedSurfaceStateVector; - typedef AccumulatedSurfaceStateVector::reverse_iterator - AccumulatedSurfaceStateIterator; - AccumulatedSurfaceStateIterator current_state = - accumulated_surface_state->rbegin(); - - // Add this rect to the accumulated content rect for all surfaces until we - // reach the target surface. - bool found_render_target = false; - for (; current_state != accumulated_surface_state->rend(); ++current_state) { - current_state->drawable_content_rect.Union(target_rect); - - // If we've reached |render_target| our work is done and we can bail. - if (current_state->render_target == render_target) { - found_render_target = true; - break; - } - - // Transform rect from the current target's space to the next. - LayerImpl* current_target = current_state->render_target; - DCHECK(current_target->render_surface()); - const gfx::Transform& current_draw_transform = - current_target->render_surface()->draw_transform(); - - // If we have unclipped descendants, the draw transform is a translation. - DCHECK(!current_target->num_unclipped_descendants() || - current_draw_transform.IsIdentityOrTranslation()); - - target_rect = - MathUtil::MapEnclosingClippedRect(current_draw_transform, target_rect); - } - - // It is an error to not reach |render_target|. If this happens, it means that - // either the clip parent is not an ancestor of the clip child or the surface - // state vector is empty, both of which should be impossible. - DCHECK(found_render_target); -} - template <typename LayerType> static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { return layer->Is3dSorted() && layer->parent() && @@ -446,11 +295,6 @@ static bool IsSurfaceBackFaceVisible(LayerImpl* layer, return false; } -template <typename LayerType> -static inline bool LayerClipsSubtree(LayerType* layer) { - return layer->masks_to_bounds() || layer->mask_layer(); -} - static bool LayerShouldBeSkipped(LayerImpl* layer, bool layer_is_drawn, const TransformTree& transform_tree) { @@ -540,228 +384,6 @@ static inline bool SubtreeShouldBeSkipped(LayerImpl* layer, return !layer->EffectiveOpacity(); } -// This function returns a translation matrix that can be applied on a vector -// that's in the layer's target surface coordinate, while the position offset is -// specified in some ancestor layer's coordinate. -gfx::Transform ComputeSizeDeltaCompensation( - LayerImpl* layer, - LayerImpl* container, - const gfx::Vector2dF& position_offset) { - gfx::Transform result_transform; - - // To apply a translate in the container's layer space, - // the following steps need to be done: - // Step 1a. transform from target surface space to the container's target - // surface space - // Step 1b. transform from container's target surface space to the - // container's layer space - // Step 2. apply the compensation - // Step 3. transform back to target surface space - - gfx::Transform target_surface_space_to_container_layer_space; - // Calculate step 1a - LayerImpl* container_target_surface = container->render_target(); - for (const LayerImpl* current_target_surface = NextTargetSurface(layer); - current_target_surface && - current_target_surface != container_target_surface; - current_target_surface = NextTargetSurface(current_target_surface)) { - // Note: Concat is used here to convert the result coordinate space from - // current render surface to the next render surface. - target_surface_space_to_container_layer_space.ConcatTransform( - current_target_surface->render_surface()->draw_transform()); - } - // Calculate step 1b - gfx::Transform container_layer_space_to_container_target_surface_space = - container->draw_properties().target_space_transform; - gfx::Transform container_target_surface_space_to_container_layer_space; - if (container_layer_space_to_container_target_surface_space.GetInverse( - &container_target_surface_space_to_container_layer_space)) { - // Note: Again, Concat is used to conver the result coordinate space from - // the container render surface to the container layer. - target_surface_space_to_container_layer_space.ConcatTransform( - container_target_surface_space_to_container_layer_space); - } - - // Apply step 3 - gfx::Transform container_layer_space_to_target_surface_space; - if (target_surface_space_to_container_layer_space.GetInverse( - &container_layer_space_to_target_surface_space)) { - result_transform.PreconcatTransform( - container_layer_space_to_target_surface_space); - } else { - // TODO(shawnsingh): A non-invertible matrix could still make meaningful - // projection. For example ScaleZ(0) is non-invertible but the layer is - // still visible. - return gfx::Transform(); - } - - // Apply step 2 - result_transform.Translate(position_offset.x(), position_offset.y()); - - // Apply step 1 - result_transform.PreconcatTransform( - target_surface_space_to_container_layer_space); - - return result_transform; -} - -void ApplyPositionAdjustment(LayerImpl* layer, - LayerImpl* container, - const gfx::Transform& scroll_compensation, - gfx::Transform* combined_transform) { - if (!layer->position_constraint().is_fixed_position()) - return; - - // Special case: this layer is a composited fixed-position layer; we need to - // explicitly compensate for all ancestors' nonzero scroll_deltas to keep - // this layer fixed correctly. - // Note carefully: this is Concat, not Preconcat - // (current_scroll_compensation * combined_transform). - combined_transform->ConcatTransform(scroll_compensation); - - // For right-edge or bottom-edge anchored fixed position layers, - // the layer should relocate itself if the container changes its size. - bool fixed_to_right_edge = - layer->position_constraint().is_fixed_to_right_edge(); - bool fixed_to_bottom_edge = - layer->position_constraint().is_fixed_to_bottom_edge(); - gfx::Vector2dF position_offset = container->FixedContainerSizeDelta(); - position_offset.set_x(fixed_to_right_edge ? position_offset.x() : 0); - position_offset.set_y(fixed_to_bottom_edge ? position_offset.y() : 0); - if (position_offset.IsZero()) - return; - - // Note: Again, this is Concat. The compensation matrix will be applied on - // the vector in target surface space. - combined_transform->ConcatTransform( - ComputeSizeDeltaCompensation(layer, container, position_offset)); -} - -gfx::Transform ComputeScrollCompensationForThisLayer( - LayerImpl* scrolling_layer, - const gfx::Transform& parent_matrix, - const gfx::Vector2dF& scroll_delta) { - // For every layer that has non-zero scroll_delta, we have to compute a - // transform that can undo the scroll_delta translation. In particular, we - // want this matrix to premultiply a fixed-position layer's parent_matrix, so - // we design this transform in three steps as follows. The steps described - // here apply from right-to-left, so Step 1 would be the right-most matrix: - // - // Step 1. transform from target surface space to the exact space where - // scroll_delta is actually applied. - // -- this is inverse of parent_matrix - // Step 2. undo the scroll_delta - // -- this is just a translation by scroll_delta. - // Step 3. transform back to target surface space. - // -- this transform is the parent_matrix - // - // These steps create a matrix that both start and end in target surface - // space. So this matrix can pre-multiply any fixed-position layer's - // draw_transform to undo the scroll_deltas -- as long as that fixed position - // layer is fixed onto the same render_target as this scrolling_layer. - // - - gfx::Transform scroll_compensation_for_this_layer = parent_matrix; // Step 3 - scroll_compensation_for_this_layer.Translate( - scroll_delta.x(), - scroll_delta.y()); // Step 2 - - gfx::Transform inverse_parent_matrix(gfx::Transform::kSkipInitialization); - if (!parent_matrix.GetInverse(&inverse_parent_matrix)) { - // TODO(shawnsingh): Either we need to handle uninvertible transforms - // here, or DCHECK that the transform is invertible. - } - scroll_compensation_for_this_layer.PreconcatTransform( - inverse_parent_matrix); // Step 1 - return scroll_compensation_for_this_layer; -} - -gfx::Transform ComputeScrollCompensationMatrixForChildren( - LayerImpl* layer, - const gfx::Transform& parent_matrix, - const gfx::Transform& current_scroll_compensation_matrix, - const gfx::Vector2dF& scroll_delta) { - // "Total scroll compensation" is the transform needed to cancel out all - // scroll_delta translations that occurred since the nearest container layer, - // even if there are render_surfaces in-between. - // - // There are some edge cases to be aware of, that are not explicit in the - // code: - // - A layer that is both a fixed-position and container should not be its - // own container, instead, that means it is fixed to an ancestor, and is a - // container for any fixed-position descendants. - // - A layer that is a fixed-position container and has a render_surface - // should behave the same as a container without a render_surface, the - // render_surface is irrelevant in that case. - // - A layer that does not have an explicit container is simply fixed to the - // viewport. (i.e. the root render_surface.) - // - If the fixed-position layer has its own render_surface, then the - // render_surface is the one who gets fixed. - // - // This function needs to be called AFTER layers create their own - // render_surfaces. - // - - // Scroll compensation restarts from identity under two possible conditions: - // - the current layer is a container for fixed-position descendants - // - the current layer is fixed-position itself, so any fixed-position - // descendants are positioned with respect to this layer. Thus, any - // fixed position descendants only need to compensate for scrollDeltas - // that occur below this layer. - bool current_layer_resets_scroll_compensation_for_descendants = - layer->IsContainerForFixedPositionLayers() || - layer->position_constraint().is_fixed_position(); - - // Avoid the overheads (including stack allocation and matrix - // initialization/copy) if we know that the scroll compensation doesn't need - // to be reset or adjusted. - if (!current_layer_resets_scroll_compensation_for_descendants && - scroll_delta.IsZero() && !layer->render_surface()) - return current_scroll_compensation_matrix; - - // Start as identity matrix. - gfx::Transform next_scroll_compensation_matrix; - - // If this layer does not reset scroll compensation, then it inherits the - // existing scroll compensations. - if (!current_layer_resets_scroll_compensation_for_descendants) - next_scroll_compensation_matrix = current_scroll_compensation_matrix; - - // If the current layer has a non-zero scroll_delta, then we should compute - // its local scroll compensation and accumulate it to the - // next_scroll_compensation_matrix. - if (!scroll_delta.IsZero()) { - gfx::Transform scroll_compensation_for_this_layer = - ComputeScrollCompensationForThisLayer( - layer, parent_matrix, scroll_delta); - next_scroll_compensation_matrix.PreconcatTransform( - scroll_compensation_for_this_layer); - } - - // If the layer created its own render_surface, we have to adjust - // next_scroll_compensation_matrix. The adjustment allows us to continue - // using the scroll compensation on the next surface. - // Step 1 (right-most in the math): transform from the new surface to the - // original ancestor surface - // Step 2: apply the scroll compensation - // Step 3: transform back to the new surface. - if (layer->render_surface() && - !next_scroll_compensation_matrix.IsIdentity()) { - gfx::Transform inverse_surface_draw_transform( - gfx::Transform::kSkipInitialization); - if (!layer->render_surface()->draw_transform().GetInverse( - &inverse_surface_draw_transform)) { - // TODO(shawnsingh): Either we need to handle uninvertible transforms - // here, or DCHECK that the transform is invertible. - } - next_scroll_compensation_matrix = - inverse_surface_draw_transform * next_scroll_compensation_matrix * - layer->render_surface()->draw_transform(); - } - - return next_scroll_compensation_matrix; -} - static inline void MarkLayerWithRenderSurfaceLayerListId( LayerImpl* layer, int current_render_surface_layer_list_id) { @@ -976,118 +598,6 @@ void LayerTreeHostCommon::PreCalculateMetaInformationForTesting( PreCalculateMetaInformationInternal(root_layer, &recursive_data); } -struct SubtreeGlobals { - int max_texture_size; - float device_scale_factor; - float page_scale_factor; - const LayerImpl* page_scale_layer; - gfx::Vector2dF elastic_overscroll; - const LayerImpl* elastic_overscroll_application_layer; - bool can_adjust_raster_scales; - bool can_render_to_separate_surface; - bool layers_always_allowed_lcd_text; -}; - -struct DataForRecursion { - // The accumulated sequence of transforms a layer will use to determine its - // own draw transform. - gfx::Transform parent_matrix; - - // The accumulated sequence of transforms a layer will use to determine its - // own screen-space transform. - gfx::Transform full_hierarchy_matrix; - - // The transform that removes all scrolling that may have occurred between a - // fixed-position layer and its container, so that the layer actually does - // remain fixed. - gfx::Transform scroll_compensation_matrix; - - // The ancestor that would be the container for any fixed-position / sticky - // layers. - LayerImpl* fixed_container; - - // This is the normal clip rect that is propagated from parent to child. - gfx::Rect clip_rect_in_target_space; - - // When the layer's children want to compute their visible content rect, they - // want to know what their target surface's clip rect will be. BUT - they - // want to know this clip rect represented in their own target space. This - // requires inverse-projecting the surface's clip rect from the surface's - // render target space down to the surface's own space. Instead of computing - // this value redundantly for each child layer, it is computed only once - // while dealing with the parent layer, and then this precomputed value is - // passed down the recursion to the children that actually use it. - gfx::Rect clip_rect_of_target_surface_in_target_space; - - // The maximum amount by which this layer will be scaled during the lifetime - // of currently running animations, considering only scales at keyframes not - // including the starting keyframe of each animation. - float maximum_animation_contents_scale; - - // The maximum amout by which this layer will be scaled during the lifetime of - // currently running animations, consdering only the starting scale of each - // animation. - float starting_animation_contents_scale; - - bool ancestor_is_animating_scale; - bool ancestor_clips_subtree; - bool in_subtree_of_page_scale_layer; - bool subtree_can_use_lcd_text; - bool subtree_is_visible_from_ancestor; -}; - -static LayerImpl* GetChildContainingLayer(const LayerImpl& parent, - LayerImpl* layer) { - for (LayerImpl* ancestor = layer; ancestor; ancestor = ancestor->parent()) { - if (ancestor->parent() == &parent) - return ancestor; - } - NOTREACHED(); - return 0; -} - -static void AddScrollParentChain(std::vector<LayerImpl*>* out, - const LayerImpl& parent, - LayerImpl* layer) { - // At a high level, this function walks up the chain of scroll parents - // recursively, and once we reach the end of the chain, we add the child - // of |parent| containing each scroll ancestor as we unwind. The result is - // an ordering of parent's children that ensures that scroll parents are - // visited before their descendants. - // Take for example this layer tree: - // - // + stacking_context - // + scroll_child (1) - // + scroll_parent_graphics_layer (*) - // | + scroll_parent_scrolling_layer - // | + scroll_parent_scrolling_content_layer (2) - // + scroll_grandparent_graphics_layer (**) - // + scroll_grandparent_scrolling_layer - // + scroll_grandparent_scrolling_content_layer (3) - // - // The scroll child is (1), its scroll parent is (2) and its scroll - // grandparent is (3). Note, this doesn't mean that (2)'s scroll parent is - // (3), it means that (*)'s scroll parent is (3). We don't want our list to - // look like [ (3), (2), (1) ], even though that does have the ancestor chain - // in the right order. Instead, we want [ (**), (*), (1) ]. That is, only want - // (1)'s siblings in the list, but we want them to appear in such an order - // that the scroll ancestors get visited in the correct order. - // - // So our first task at this step of the recursion is to determine the layer - // that we will potentionally add to the list. That is, the child of parent - // containing |layer|. - LayerImpl* child = GetChildContainingLayer(parent, layer); - if (child->sorted_for_recursion()) - return; - - if (LayerImpl* scroll_parent = child->scroll_parent()) - AddScrollParentChain(out, parent, scroll_parent); - - out->push_back(child); - bool sorted_for_recursion = true; - child->set_sorted_for_recursion(sorted_for_recursion); -} - static bool CdpPerfTracingEnabled() { bool tracing_enabled; TRACE_EVENT_CATEGORY_GROUP_ENABLED("cdp.perf", &tracing_enabled); @@ -1552,7 +1062,6 @@ void CalculateDrawPropertiesInternal( "LayerTreeHostCommon::CalculateDrawProperties"); } - std::vector<AccumulatedSurfaceState> accumulated_surface_state; DCHECK(inputs->can_render_to_separate_surface == inputs->property_trees->non_root_surfaces_enabled); CalculateRenderTarget(inputs); |