diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/debug/debug_rect_history.cc | 2 | ||||
-rw-r--r-- | cc/layers/contents_scaling_layer_unittest.cc | 4 | ||||
-rw-r--r-- | cc/layers/layer_iterator.h | 2 | ||||
-rw-r--r-- | cc/layers/layer_iterator_unittest.cc | 12 | ||||
-rw-r--r-- | cc/layers/solid_color_layer_impl_unittest.cc | 4 | ||||
-rw-r--r-- | cc/layers/tiled_layer_unittest.cc | 8 | ||||
-rw-r--r-- | cc/trees/damage_tracker.cc | 2 | ||||
-rw-r--r-- | cc/trees/damage_tracker_unittest.cc | 2 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.cc | 18 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common.cc | 2507 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common.h | 198 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_unittest.cc | 348 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 14 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 24 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl.cc | 12 | ||||
-rw-r--r-- | cc/trees/occlusion_tracker_unittest.cc | 4 |
16 files changed, 1775 insertions, 1386 deletions
diff --git a/cc/debug/debug_rect_history.cc b/cc/debug/debug_rect_history.cc index e7e7814..6433d8b 100644 --- a/cc/debug/debug_rect_history.cc +++ b/cc/debug/debug_rect_history.cc @@ -87,7 +87,7 @@ void DebugRectHistory::SavePropertyChangedRects( ++layer_index) { LayerImpl* layer = layer_list[layer_index]; - if (LayerTreeHostCommon::renderSurfaceContributesToTarget<LayerImpl>( + if (LayerTreeHostCommon::RenderSurfaceContributesToTarget<LayerImpl>( layer, render_surface_layer->id())) continue; diff --git a/cc/layers/contents_scaling_layer_unittest.cc b/cc/layers/contents_scaling_layer_unittest.cc index 69710d8..ec188f0 100644 --- a/cc/layers/contents_scaling_layer_unittest.cc +++ b/cc/layers/contents_scaling_layer_unittest.cc @@ -46,14 +46,14 @@ class MockContentsScalingLayer : public ContentsScalingLayer { void CalcDrawProps(Layer* root, float device_scale) { std::vector<scoped_refptr<Layer> > render_surface_layer_list; - LayerTreeHostCommon::calculateDrawProperties( + LayerTreeHostCommon::CalculateDrawProperties( root, gfx::Size(500, 500), device_scale, 1.f, 1024, false, - render_surface_layer_list); + &render_surface_layer_list); } TEST(ContentsScalingLayerTest, CheckContentsBounds) { diff --git a/cc/layers/layer_iterator.h b/cc/layers/layer_iterator.h index e13204b..3e00a63 100644 --- a/cc/layers/layer_iterator.h +++ b/cc/layers/layer_iterator.h @@ -203,7 +203,7 @@ class LayerIterator { } inline bool current_layer_represents_contributing_render_surface() const { - return LayerTreeHostCommon::renderSurfaceContributesToTarget<LayerType>( + return LayerTreeHostCommon::RenderSurfaceContributesToTarget<LayerType>( current_layer(), target_render_surface_layer()->id()); } inline bool current_layer_represents_target_render_surface() const { diff --git a/cc/layers/layer_iterator_unittest.cc b/cc/layers/layer_iterator_unittest.cc index 464c570..6815467 100644 --- a/cc/layers/layer_iterator_unittest.cc +++ b/cc/layers/layer_iterator_unittest.cc @@ -137,13 +137,13 @@ TEST(LayerIteratorTest, SimpleTree) { root_layer->AddChild(fourth); std::vector<scoped_refptr<Layer> > render_surface_layerList; - LayerTreeHostCommon::calculateDrawProperties(root_layer.get(), + LayerTreeHostCommon::CalculateDrawProperties(root_layer.get(), root_layer->bounds(), 1, 1, 256, false, - render_surface_layerList); + &render_surface_layerList); IterateBackToFront(&render_surface_layerList); EXPECT_COUNT(root_layer, 0, -1, 1); @@ -184,13 +184,13 @@ TEST(LayerIteratorTest, ComplexTree) { root23->AddChild(root231); std::vector<scoped_refptr<Layer> > render_surface_layerList; - LayerTreeHostCommon::calculateDrawProperties(root_layer.get(), + LayerTreeHostCommon::CalculateDrawProperties(root_layer.get(), root_layer->bounds(), 1, 1, 256, false, - render_surface_layerList); + &render_surface_layerList); IterateBackToFront(&render_surface_layerList); EXPECT_COUNT(root_layer, 0, -1, 1); @@ -246,13 +246,13 @@ TEST(LayerIteratorTest, ComplexTreeMultiSurface) { root23->AddChild(root231); std::vector<scoped_refptr<Layer> > render_surface_layerList; - LayerTreeHostCommon::calculateDrawProperties(root_layer.get(), + LayerTreeHostCommon::CalculateDrawProperties(root_layer.get(), root_layer->bounds(), 1, 1, 256, false, - render_surface_layerList); + &render_surface_layerList); IterateBackToFront(&render_surface_layerList); EXPECT_COUNT(root_layer, 0, -1, 1); diff --git a/cc/layers/solid_color_layer_impl_unittest.cc b/cc/layers/solid_color_layer_impl_unittest.cc index 7b86c31..0d9ac61 100644 --- a/cc/layers/solid_color_layer_impl_unittest.cc +++ b/cc/layers/solid_color_layer_impl_unittest.cc @@ -110,8 +110,8 @@ TEST(SolidColorLayerImplTest, VerifyOpaqueRect) { root->AddChild(layer); std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; - LayerTreeHostCommon::calculateDrawProperties( - root, gfx::Size(500, 500), 1, 1, 1024, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties( + root, gfx::Size(500, 500), 1, 1, 1024, false, &renderSurfaceLayerList); EXPECT_FALSE(layer->contents_opaque()); layer->SetBackgroundColor(SkColorSetARGBInline(255, 10, 20, 30)); diff --git a/cc/layers/tiled_layer_unittest.cc b/cc/layers/tiled_layer_unittest.cc index 72e7f8e..4a4d54b 100644 --- a/cc/layers/tiled_layer_unittest.cc +++ b/cc/layers/tiled_layer_unittest.cc @@ -127,14 +127,14 @@ public: m_occlusion->setRenderTarget(layer_tree_host_->root_layer()); std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; - LayerTreeHostCommon::calculateDrawProperties( + LayerTreeHostCommon::CalculateDrawProperties( layer_tree_host_->root_layer(), layer_tree_host_->device_viewport_size(), layer_tree_host_->device_scale_factor(), - 1, // page_scale_factor + 1, // page_scale_factor layer_tree_host_->GetRendererCapabilities().max_texture_size, - false, // can_use_lcd_text - renderSurfaceLayerList); + false, // can_use_lcd_text + &renderSurfaceLayerList); } bool updateAndPush(const scoped_refptr<FakeTiledLayer>& layer1, diff --git a/cc/trees/damage_tracker.cc b/cc/trees/damage_tracker.cc index 85ccbe4..e0a505f 100644 --- a/cc/trees/damage_tracker.cc +++ b/cc/trees/damage_tracker.cc @@ -190,7 +190,7 @@ gfx::RectF DamageTracker::TrackDamageFromActiveLayers( // Visit layers in back-to-front order. LayerImpl* layer = layer_list[layerIndex]; - if (LayerTreeHostCommon::renderSurfaceContributesToTarget<LayerImpl>( + if (LayerTreeHostCommon::RenderSurfaceContributesToTarget<LayerImpl>( layer, target_surface_layer_id)) ExtendDamageForRenderSurface(layer, &damage_rect); else diff --git a/cc/trees/damage_tracker_unittest.cc b/cc/trees/damage_tracker_unittest.cc index 2fc63ce..ca3bf83 100644 --- a/cc/trees/damage_tracker_unittest.cc +++ b/cc/trees/damage_tracker_unittest.cc @@ -32,7 +32,7 @@ void executeCalculateDrawProperties(LayerImpl* root, std::vector<LayerImpl*>& re ASSERT_TRUE(root->render_surface()); ASSERT_FALSE(renderSurfaceLayerList.size()); - LayerTreeHostCommon::calculateDrawProperties(root, root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root, root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); } void clearDamageForAllSurfaces(LayerImpl* layer) diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index b023f85..ea17e79 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -292,7 +292,7 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { needs_full_tree_sync_ = false; if (root_layer_ && hud_layer_) { - LayerImpl* hud_impl = LayerTreeHostCommon::findLayerInSubtree( + LayerImpl* hud_impl = LayerTreeHostCommon::FindLayerInSubtree( sync_tree->root_layer(), hud_layer_->id()); sync_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); } else { @@ -692,14 +692,14 @@ void LayerTreeHost::UpdateLayers(Layer* root_layer, UpdateHudLayer(); TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::calcDrawProps"); - LayerTreeHostCommon::calculateDrawProperties( + LayerTreeHostCommon::CalculateDrawProperties( root_layer, device_viewport_size(), device_scale_factor_, page_scale_factor_, GetRendererCapabilities().max_texture_size, settings_.can_use_lcd_text, - update_list); + &update_list); } // Reset partial texture update requests. @@ -897,18 +897,18 @@ void LayerTreeHost::ApplyScrollAndScale(const ScrollAndScaleSet& info) { for (size_t i = 0; i < info.scrolls.size(); ++i) { Layer* layer = - LayerTreeHostCommon::findLayerInSubtree(root_layer_.get(), - info.scrolls[i].layerId); + LayerTreeHostCommon::FindLayerInSubtree(root_layer_.get(), + info.scrolls[i].layer_id); if (!layer) continue; if (layer == root_scroll_layer) - root_scroll_delta += info.scrolls[i].scrollDelta; + root_scroll_delta += info.scrolls[i].scroll_delta; else layer->SetScrollOffset(layer->scroll_offset() + - info.scrolls[i].scrollDelta); + info.scrolls[i].scroll_delta); } - if (!root_scroll_delta.IsZero() || info.pageScaleDelta != 1.f) - client_->ApplyScrollAndScale(root_scroll_delta, info.pageScaleDelta); + if (!root_scroll_delta.IsZero() || info.page_scale_delta != 1.f) + client_->ApplyScrollAndScale(root_scroll_delta, info.page_scale_delta); } void LayerTreeHost::SetImplTransform(const gfx::Transform& transform) { diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index 770a408..27aeb70 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -22,1204 +22,1561 @@ namespace cc { -ScrollAndScaleSet::ScrollAndScaleSet() -{ -} +ScrollAndScaleSet::ScrollAndScaleSet() {} + +ScrollAndScaleSet::~ScrollAndScaleSet() {} -ScrollAndScaleSet::~ScrollAndScaleSet() -{ +static void SortLayers(std::vector<scoped_refptr<Layer> >::iterator forst, + std::vector<scoped_refptr<Layer> >::iterator end, + void* layer_sorter) { + NOTREACHED(); } -static void sortLayers(std::vector<scoped_refptr<Layer> >::iterator forst, std::vector<scoped_refptr<Layer> >::iterator end, void* layerSorter) -{ - NOTREACHED(); +static void SortLayers(std::vector<LayerImpl*>::iterator first, + std::vector<LayerImpl*>::iterator end, + LayerSorter* layer_sorter) { + DCHECK(layer_sorter); + TRACE_EVENT0("cc", "LayerTreeHostCommon::SortLayers"); + layer_sorter->Sort(first, end); } -static void sortLayers(std::vector<LayerImpl*>::iterator first, std::vector<LayerImpl*>::iterator end, LayerSorter* layerSorter) -{ - DCHECK(layerSorter); - TRACE_EVENT0("cc", "layer_tree_host_common::sortLayers"); - layerSorter->Sort(first, end); +inline gfx::Rect CalculateVisibleRectWithCachedLayerRect( + gfx::Rect target_surface_rect, + gfx::Rect layer_bound_rect, + gfx::Rect layer_rect_in_target_space, + const gfx::Transform& transform) { + // Is this layer fully contained within the target surface? + if (target_surface_rect.Contains(layer_rect_in_target_space)) + return layer_bound_rect; + + // If the layer doesn't fill up the entire surface, then find the part of + // the surface rect where the layer could be visible. This avoids trying to + // project surface rect points that are behind the projection point. + gfx::Rect minimal_surface_rect = target_surface_rect; + minimal_surface_rect.Intersect(layer_rect_in_target_space); + + // Project the corners of the target surface rect into the layer space. + // This bounding rectangle may be larger than it needs to be (being + // axis-aligned), but is a reasonable filter on the space to consider. + // Non-invertible transforms will create an empty rect here. + + gfx::Transform surface_to_layer(gfx::Transform::kSkipInitialization); + if (!transform.GetInverse(&surface_to_layer)) { + // TODO(shawnsingh): Either we need to handle uninvertible transforms + // here, or DCHECK that the transform is invertible. + } + gfx::Rect layer_rect = gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( + surface_to_layer, gfx::RectF(minimal_surface_rect))); + layer_rect.Intersect(layer_bound_rect); + return layer_rect; } -inline gfx::Rect calculateVisibleRectWithCachedLayerRect(const gfx::Rect& targetSurfaceRect, const gfx::Rect& layerBoundRect, const gfx::Rect& layerRectInTargetSpace, const gfx::Transform& transform) -{ - // Is this layer fully contained within the target surface? - if (targetSurfaceRect.Contains(layerRectInTargetSpace)) - return layerBoundRect; - - // If the layer doesn't fill up the entire surface, then find the part of - // the surface rect where the layer could be visible. This avoids trying to - // project surface rect points that are behind the projection point. - gfx::Rect minimalSurfaceRect = targetSurfaceRect; - minimalSurfaceRect.Intersect(layerRectInTargetSpace); - - // Project the corners of the target surface rect into the layer space. - // This bounding rectangle may be larger than it needs to be (being - // axis-aligned), but is a reasonable filter on the space to consider. - // Non-invertible transforms will create an empty rect here. - - gfx::Transform surfaceToLayer(gfx::Transform::kSkipInitialization); - if (!transform.GetInverse(&surfaceToLayer)) { - // TODO(shawnsingh): Either we need to handle uninvertible transforms - // here, or DCHECK that the transform is invertible. - } - gfx::Rect layerRect = gfx::ToEnclosingRect(MathUtil::ProjectClippedRect(surfaceToLayer, gfx::RectF(minimalSurfaceRect))); - layerRect.Intersect(layerBoundRect); - return layerRect; +gfx::Rect LayerTreeHostCommon::CalculateVisibleRect( + gfx::Rect target_surface_rect, + gfx::Rect layer_bound_rect, + const gfx::Transform& transform) { + gfx::Rect layer_in_surface_space = + MathUtil::MapClippedRect(transform, layer_bound_rect); + return CalculateVisibleRectWithCachedLayerRect( + target_surface_rect, layer_bound_rect, layer_in_surface_space, transform); } -gfx::Rect LayerTreeHostCommon::calculateVisibleRect(const gfx::Rect& targetSurfaceRect, const gfx::Rect& layerBoundRect, const gfx::Transform& transform) -{ - gfx::Rect layerInSurfaceSpace = MathUtil::MapClippedRect(transform, layerBoundRect); - return calculateVisibleRectWithCachedLayerRect(targetSurfaceRect, layerBoundRect, layerInSurfaceSpace, transform); +template <typename LayerType> static inline bool IsRootLayer(LayerType* layer) { + return !layer->parent(); } template <typename LayerType> -static inline bool isRootLayer(LayerType* layer) -{ - return !layer->parent(); +static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { + // According to current W3C spec on CSS transforms, a layer is part of an + // established 3d rendering context if its parent has transform-style of + // preserves-3d. + return layer->parent() && layer->parent()->preserves_3d(); } -template<typename LayerType> -static inline bool layerIsInExisting3DRenderingContext(LayerType* layer) -{ - // According to current W3C spec on CSS transforms, a layer is part of an established - // 3d rendering context if its parent has transform-style of preserves-3d. - return layer->parent() && layer->parent()->preserves_3d(); +template <typename LayerType> +static bool IsRootLayerOfNewRenderingContext(LayerType* layer) { + // According to current W3C spec on CSS transforms (Section 6.1), a layer is + // the beginning of 3d rendering context if its parent does not have + // transform-style: preserve-3d, but this layer itself does. + if (layer->parent()) + return !layer->parent()->preserves_3d() && layer->preserves_3d(); + + return layer->preserves_3d(); } -template<typename LayerType> -static bool isRootLayerOfNewRenderingContext(LayerType* layer) -{ - // According to current W3C spec on CSS transforms (Section 6.1), a layer is the - // beginning of 3d rendering context if its parent does not have transform-style: - // preserve-3d, but this layer itself does. - if (layer->parent()) - return !layer->parent()->preserves_3d() && layer->preserves_3d(); - - return layer->preserves_3d(); +template <typename LayerType> +static bool IsLayerBackFaceVisible(LayerType* layer) { + // The current W3C spec on CSS transforms says that backface visibility should + // be determined differently depending on whether the layer is in a "3d + // rendering context" or not. For Chromium code, we can determine whether we + // are in a 3d rendering context by checking if the parent preserves 3d. + + if (LayerIsInExisting3DRenderingContext(layer)) + return layer->draw_transform().IsBackFaceVisible(); + + // In this case, either the layer establishes a new 3d rendering context, or + // is not in a 3d rendering context at all. + return layer->transform().IsBackFaceVisible(); } -template<typename LayerType> -static bool isLayerBackFaceVisible(LayerType* layer) -{ - // The current W3C spec on CSS transforms says that backface visibility should be - // determined differently depending on whether the layer is in a "3d rendering - // context" or not. For Chromium code, we can determine whether we are in a 3d - // rendering context by checking if the parent preserves 3d. - - if (layerIsInExisting3DRenderingContext(layer)) - return layer->draw_transform().IsBackFaceVisible(); +template <typename LayerType> +static bool IsSurfaceBackFaceVisible(LayerType* layer, + const gfx::Transform& draw_transform) { + if (LayerIsInExisting3DRenderingContext(layer)) + return draw_transform.IsBackFaceVisible(); - // In this case, either the layer establishes a new 3d rendering context, or is not in - // a 3d rendering context at all. + if (IsRootLayerOfNewRenderingContext(layer)) return layer->transform().IsBackFaceVisible(); -} - -template<typename LayerType> -static bool isSurfaceBackFaceVisible(LayerType* layer, const gfx::Transform& drawTransform) -{ - if (layerIsInExisting3DRenderingContext(layer)) - return drawTransform.IsBackFaceVisible(); - if (isRootLayerOfNewRenderingContext(layer)) - return layer->transform().IsBackFaceVisible(); - - // If the renderSurface is not part of a new or existing rendering context, then the - // layers that contribute to this surface will decide back-face visibility for themselves. - return false; + // If the render_surface is not part of a new or existing rendering context, + // then the layers that contribute to this surface will decide back-face + // visibility for themselves. + return false; } -template<typename LayerType> -static inline bool layerClipsSubtree(LayerType* layer) -{ - return layer->masks_to_bounds() || layer->mask_layer(); +template <typename LayerType> +static inline bool LayerClipsSubtree(LayerType* layer) { + return layer->masks_to_bounds() || layer->mask_layer(); } -template<typename LayerType> -static gfx::Rect calculateVisibleContentRect(LayerType* layer, const gfx::Rect& ancestorClipRectInDescendantSurfaceSpace, const gfx::Rect& layerRectInTargetSpace) -{ - DCHECK(layer->render_target()); - - // Nothing is visible if the layer bounds are empty. - if (!layer->DrawsContent() || layer->content_bounds().IsEmpty() || layer->drawable_content_rect().IsEmpty()) - return gfx::Rect(); - - // Compute visible bounds in target surface space. - gfx::Rect visibleRectInTargetSurfaceSpace = layer->drawable_content_rect(); - - if (!layer->render_target()->render_surface()->clip_rect().IsEmpty()) { - // In this case the target surface does clip layers that contribute to - // it. So, we have to convert the current surface's clipRect from its - // ancestor surface space to the current (descendant) surface - // space. This conversion is done outside this function so that it can - // be cached instead of computing it redundantly for every layer. - visibleRectInTargetSurfaceSpace.Intersect(ancestorClipRectInDescendantSurfaceSpace); - } - - if (visibleRectInTargetSurfaceSpace.IsEmpty()) - return gfx::Rect(); - - return calculateVisibleRectWithCachedLayerRect(visibleRectInTargetSurfaceSpace, gfx::Rect(gfx::Point(), layer->content_bounds()), layerRectInTargetSpace, layer->draw_transform()); +template <typename LayerType> +static gfx::Rect CalculateVisibleContentRect( + LayerType* layer, + gfx::Rect ancestor_clip_rect_in_descendant_surface_space, + gfx::Rect layer_rect_in_target_space) { + DCHECK(layer->render_target()); + + // Nothing is visible if the layer bounds are empty. + if (!layer->DrawsContent() || layer->content_bounds().IsEmpty() || + layer->drawable_content_rect().IsEmpty()) + return gfx::Rect(); + + // Compute visible bounds in target surface space. + gfx::Rect visible_rect_in_target_surface_space = + layer->drawable_content_rect(); + + if (!layer->render_target()->render_surface()->clip_rect().IsEmpty()) { + // In this case the target surface does clip layers that contribute to + // it. So, we have to convert the current surface's clipRect from its + // ancestor surface space to the current (descendant) surface + // space. This conversion is done outside this function so that it can + // be cached instead of computing it redundantly for every layer. + visible_rect_in_target_surface_space.Intersect( + ancestor_clip_rect_in_descendant_surface_space); + } + + if (visible_rect_in_target_surface_space.IsEmpty()) + return gfx::Rect(); + + return CalculateVisibleRectWithCachedLayerRect( + visible_rect_in_target_surface_space, + gfx::Rect(gfx::Point(), layer->content_bounds()), + layer_rect_in_target_space, + layer->draw_transform()); } -static inline bool transformToParentIsKnown(LayerImpl*) -{ - return true; -} +static inline bool TransformToParentIsKnown(LayerImpl* layer) { return true; } -static inline bool transformToParentIsKnown(Layer* layer) -{ +static inline bool TransformToParentIsKnown(Layer* layer) { - return !layer->TransformIsAnimating(); + return !layer->TransformIsAnimating(); } -static inline bool transformToScreenIsKnown(LayerImpl*) -{ - return true; -} +static inline bool TransformToScreenIsKnown(LayerImpl* layer) { return true; } -static inline bool transformToScreenIsKnown(Layer* layer) -{ - return !layer->screen_space_transform_is_animating(); +static inline bool TransformToScreenIsKnown(Layer* layer) { + return !layer->screen_space_transform_is_animating(); } -template<typename LayerType> -static bool layerShouldBeSkipped(LayerType* layer) -{ - // Layers can be skipped if any of these conditions are met. - // - does not draw content. - // - is transparent - // - has empty bounds - // - the layer is not double-sided, but its back face is visible. - // - // Some additional conditions need to be computed at a later point after the recursion is finished. - // - the intersection of render surface content and layer clipRect is empty - // - the visibleContentRect is empty - // - // Note, if the layer should not have been drawn due to being fully transparent, - // we would have skipped the entire subtree and never made it into this function, - // so it is safe to omit this check here. - - if (!layer->DrawsContent() || layer->bounds().IsEmpty()) - return true; - - LayerType* backfaceTestLayer = layer; - if (layer->use_parent_backface_visibility()) { - DCHECK(layer->parent()); - DCHECK(!layer->parent()->use_parent_backface_visibility()); - backfaceTestLayer = layer->parent(); - } +template <typename LayerType> +static bool LayerShouldBeSkipped(LayerType* layer) { + // Layers can be skipped if any of these conditions are met. + // - does not draw content. + // - is transparent + // - has empty bounds + // - the layer is not double-sided, but its back face is visible. + // + // Some additional conditions need to be computed at a later point after the + // recursion is finished. + // - the intersection of render surface content and layer clipRect is empty + // - the visibleContentRect is empty + // + // Note, if the layer should not have been drawn due to being fully + // transparent, we would have skipped the entire subtree and never made it + // into this function, so it is safe to omit this check here. + + if (!layer->DrawsContent() || layer->bounds().IsEmpty()) + return true; - // The layer should not be drawn if (1) it is not double-sided and (2) the back of the layer is known to be facing the screen. - if (!backfaceTestLayer->double_sided() && transformToScreenIsKnown(backfaceTestLayer) && isLayerBackFaceVisible(backfaceTestLayer)) - return true; + LayerType* backface_test_layer = layer; + if (layer->use_parent_backface_visibility()) { + DCHECK(layer->parent()); + DCHECK(!layer->parent()->use_parent_backface_visibility()); + backface_test_layer = layer->parent(); + } + + // The layer should not be drawn if (1) it is not double-sided and (2) the + // back of the layer is known to be facing the screen. + if (!backface_test_layer->double_sided() && + TransformToScreenIsKnown(backface_test_layer) && + IsLayerBackFaceVisible(backface_test_layer)) + return true; - return false; + return false; } -static inline bool subtreeShouldBeSkipped(LayerImpl* layer) -{ - // The opacity of a layer always applies to its children (either implicitly - // via a render surface or explicitly if the parent preserves 3D), so the - // entire subtree can be skipped if this layer is fully transparent. - return !layer->opacity(); +static inline bool SubtreeShouldBeSkipped(LayerImpl* layer) { + // The opacity of a layer always applies to its children (either implicitly + // via a render surface or explicitly if the parent preserves 3D), so the + // entire subtree can be skipped if this layer is fully transparent. + return !layer->opacity(); } -static inline bool subtreeShouldBeSkipped(Layer* layer) -{ - // If the opacity is being animated then the opacity on the main thread is unreliable - // (since the impl thread may be using a different opacity), so it should not be trusted. - // In particular, it should not cause the subtree to be skipped. - // Similarly, for layers that might animate opacity using an impl-only - // animation, their subtree should also not be skipped. - return !layer->opacity() && !layer->OpacityIsAnimating() && - !layer->OpacityCanAnimateOnImplThread(); +static inline bool SubtreeShouldBeSkipped(Layer* layer) { + // If the opacity is being animated then the opacity on the main thread is + // unreliable (since the impl thread may be using a different opacity), so it + // should not be trusted. + // In particular, it should not cause the subtree to be skipped. + // Similarly, for layers that might animate opacity using an impl-only + // animation, their subtree should also not be skipped. + return !layer->opacity() && !layer->OpacityIsAnimating() && + !layer->OpacityCanAnimateOnImplThread(); } // Called on each layer that could be drawn after all information from // calcDrawProperties has been updated on that layer. May have some false // positives (e.g. layers get this called on them but don't actually get drawn). -static inline void updateTilePrioritiesForLayer(LayerImpl* layer) -{ - layer->UpdateTilePriorities(); - - // Mask layers don't get this call, so explicitly update them so they can - // kick off tile rasterization. - if (layer->mask_layer()) - layer->mask_layer()->UpdateTilePriorities(); - if (layer->replica_layer() && layer->replica_layer()->mask_layer()) - layer->replica_layer()->mask_layer()->UpdateTilePriorities(); +static inline void UpdateTilePrioritiesForLayer(LayerImpl* layer) { + layer->UpdateTilePriorities(); + + // Mask layers don't get this call, so explicitly update them so they can + // kick off tile rasterization. + if (layer->mask_layer()) + layer->mask_layer()->UpdateTilePriorities(); + if (layer->replica_layer() && layer->replica_layer()->mask_layer()) + layer->replica_layer()->mask_layer()->UpdateTilePriorities(); } -static inline void updateTilePrioritiesForLayer(Layer* layer) -{ -} - -template<typename LayerType> -static bool subtreeShouldRenderToSeparateSurface(LayerType* layer, bool axisAlignedWithRespectToParent) -{ - // - // A layer and its descendants should render onto a new RenderSurfaceImpl if any of these rules hold: - // - - // The root layer should always have a renderSurface. - if (isRootLayer(layer)) - return true; - - // If we force it. - if (layer->force_render_surface()) - return true; +static inline void UpdateTilePrioritiesForLayer(Layer* layer) {} - // If the layer uses a mask. - if (layer->mask_layer()) - return true; - - // If the layer has a reflection. - if (layer->replica_layer()) - return true; +template <typename LayerType> +static bool SubtreeShouldRenderToSeparateSurface( + LayerType* layer, + bool axis_aligned_with_respect_to_parent) { + // + // A layer and its descendants should render onto a new RenderSurfaceImpl if + // any of these rules hold: + // + + // The root layer should always have a render_surface. + if (IsRootLayer(layer)) + return true; - // If the layer uses a CSS filter. - if (!layer->filters().isEmpty() || !layer->background_filters().isEmpty() || layer->filter()) - return true; + // If we force it. + if (layer->force_render_surface()) + return true; - int numDescendantsThatDrawContent = layer->draw_properties().num_descendants_that_draw_content; + // If the layer uses a mask. + if (layer->mask_layer()) + return true; - // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), but it is - // treated as a 3D object by its parent (i.e. parent does preserve-3d). - if (layerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() && numDescendantsThatDrawContent > 0) { - TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface flattening"); - return true; - } + // If the layer has a reflection. + if (layer->replica_layer()) + return true; - // If the layer clips its descendants but it is not axis-aligned with respect to its parent. - bool layerClipsExternalContent = layerClipsSubtree(layer) || layer->HasDelegatedContent(); - if (layerClipsExternalContent && !axisAlignedWithRespectToParent && !layer->draw_properties().descendants_can_clip_selves) - { - TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface clipping"); - return true; - } + // If the layer uses a CSS filter. + if (!layer->filters().isEmpty() || !layer->background_filters().isEmpty() || + layer->filter()) + return true; - // If the layer has some translucency and does not have a preserves-3d transform style. - // This condition only needs a render surface if two or more layers in the - // subtree overlap. But checking layer overlaps is unnecessarily costly so - // instead we conservatively create a surface whenever at least two layers - // draw content for this subtree. - bool atLeastTwoLayersInSubtreeDrawContent = numDescendantsThatDrawContent > 0 && (layer->DrawsContent() || numDescendantsThatDrawContent > 1); + int num_descendants_that_draw_content = + layer->draw_properties().num_descendants_that_draw_content; - if (layer->opacity() != 1.f && !layer->preserves_3d() && atLeastTwoLayersInSubtreeDrawContent) { - TRACE_EVENT_INSTANT0("cc", "LayerTreeHostCommon::requireSurface opacity"); - return true; - } + // If the layer flattens its subtree (i.e. the layer doesn't preserve-3d), but + // it is treated as a 3D object by its parent (i.e. parent does preserve-3d). + if (LayerIsInExisting3DRenderingContext(layer) && !layer->preserves_3d() && + num_descendants_that_draw_content > 0) { + TRACE_EVENT_INSTANT0( + "cc", + "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface flattening"); + return true; + } + + // If the layer clips its descendants but it is not axis-aligned with respect + // to its parent. + bool layer_clips_external_content = + LayerClipsSubtree(layer) || layer->HasDelegatedContent(); + if (layer_clips_external_content && !axis_aligned_with_respect_to_parent && + !layer->draw_properties().descendants_can_clip_selves) { + TRACE_EVENT_INSTANT0( + "cc", + "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping"); + return true; + } + + // If the layer has some translucency and does not have a preserves-3d + // transform style. This condition only needs a render surface if two or more + // layers in the subtree overlap. But checking layer overlaps is unnecessarily + // costly so instead we conservatively create a surface whenever at least two + // layers draw content for this subtree. + bool at_least_two_layers_in_subtree_draw_content = + num_descendants_that_draw_content > 0 && + (layer->DrawsContent() || num_descendants_that_draw_content > 1); + + if (layer->opacity() != 1.f && !layer->preserves_3d() && + at_least_two_layers_in_subtree_draw_content) { + TRACE_EVENT_INSTANT0( + "cc", + "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface opacity"); + return true; + } - return false; + return false; } -gfx::Transform computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer, const gfx::Transform& parentMatrix) -{ - // For every layer that has non-zero scrollDelta, we have to compute a transform that can undo the - // scrollDelta translation. In particular, we want this matrix to premultiply a fixed-position layer's - // parentMatrix, 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 scrollDelta is actually applied. - // -- this is inverse of the matrix in step 3 - // Step 2. undo the scrollDelta - // -- this is just a translation by scrollDelta. - // Step 3. transform back to target surface space. - // -- this transform is the "partialLayerOriginTransform" = (parentMatrix * scale(layer->pageScaleDelta())); - // - // These steps create a matrix that both start and end in targetSurfaceSpace. So this matrix can - // pre-multiply any fixed-position layer's drawTransform to undo the scrollDeltas -- as long as - // that fixed position layer is fixed onto the same renderTarget as this scrollingLayer. - // - - gfx::Transform partialLayerOriginTransform = parentMatrix; - partialLayerOriginTransform.PreconcatTransform(scrollingLayer->impl_transform()); - - gfx::Transform scrollCompensationForThisLayer = partialLayerOriginTransform; // Step 3 - scrollCompensationForThisLayer.Translate(scrollingLayer->scroll_delta().x(), scrollingLayer->scroll_delta().y()); // Step 2 - - gfx::Transform inversePartialLayerOriginTransform(gfx::Transform::kSkipInitialization); - if (!partialLayerOriginTransform.GetInverse(&inversePartialLayerOriginTransform)) { - // TODO(shawnsingh): Either we need to handle uninvertible transforms - // here, or DCHECK that the transform is invertible. - } - scrollCompensationForThisLayer.PreconcatTransform(inversePartialLayerOriginTransform); // Step 1 - return scrollCompensationForThisLayer; +gfx::Transform ComputeScrollCompensationForThisLayer( + LayerImpl* scrolling_layer, + const gfx::Transform& parent_matrix) { + // 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 the matrix in step 3 + // 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 "partial_layer_origin_transform" = + // (parent_matrix * scale(layer->pageScaleDelta())); + // + // These steps create a matrix that both start and end in targetSurfaceSpace. + // 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 partial_layer_origin_transform = parent_matrix; + partial_layer_origin_transform.PreconcatTransform( + scrolling_layer->impl_transform()); + + gfx::Transform scroll_compensation_for_this_layer = + partial_layer_origin_transform; // Step 3 + scroll_compensation_for_this_layer.Translate( + scrolling_layer->scroll_delta().x(), + scrolling_layer->scroll_delta().y()); // Step 2 + + gfx::Transform inverse_partial_layer_origin_transform( + gfx::Transform::kSkipInitialization); + if (!partial_layer_origin_transform.GetInverse( + &inverse_partial_layer_origin_transform)) { + // TODO(shawnsingh): Either we need to handle uninvertible transforms + // here, or DCHECK that the transform is invertible. + } + scroll_compensation_for_this_layer.PreconcatTransform( + inverse_partial_layer_origin_transform); // Step 1 + return scroll_compensation_for_this_layer; } -gfx::Transform computeScrollCompensationMatrixForChildren(Layer* current_layer, const gfx::Transform& currentParentMatrix, const gfx::Transform& currentScrollCompensation) -{ - // The main thread (i.e. Layer) does not need to worry about scroll compensation. - // So we can just return an identity matrix here. - return gfx::Transform(); +gfx::Transform ComputeScrollCompensationMatrixForChildren( + Layer* current_layer, + const gfx::Transform& current_parent_matrix, + const gfx::Transform& current_scroll_compensation) { + // The main thread (i.e. Layer) does not need to worry about scroll + // compensation. So we can just return an identity matrix here. + return gfx::Transform(); } -gfx::Transform computeScrollCompensationMatrixForChildren(LayerImpl* layer, const gfx::Transform& parentMatrix, const gfx::Transform& currentScrollCompensationMatrix) -{ - // "Total scroll compensation" is the transform needed to cancel out all scrollDelta translations that - // occurred since the nearest container layer, even if there are renderSurfaces 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 renderSurface should behave the same as a container - // without a renderSurface, the renderSurface is irrelevant in that case. - // - A layer that does not have an explicit container is simply fixed to the viewport. - // (i.e. the root renderSurface.) - // - If the fixed-position layer has its own renderSurface, then the renderSurface is - // the one who gets fixed. - // - // This function needs to be called AFTER layers create their own renderSurfaces. - // - - // 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 (!layer->is_container_for_fixed_position_layers() && layer->scroll_delta().IsZero() && !layer->render_surface()) - return currentScrollCompensationMatrix; - - // Start as identity matrix. - gfx::Transform nextScrollCompensationMatrix; - - // If this layer is not a container, then it inherits the existing scroll compensations. - if (!layer->is_container_for_fixed_position_layers()) - nextScrollCompensationMatrix = currentScrollCompensationMatrix; - - // If the current layer has a non-zero scrollDelta, then we should compute its local scrollCompensation - // and accumulate it to the nextScrollCompensationMatrix. - if (!layer->scroll_delta().IsZero()) { - gfx::Transform scrollCompensationForThisLayer = computeScrollCompensationForThisLayer(layer, parentMatrix); - nextScrollCompensationMatrix.PreconcatTransform(scrollCompensationForThisLayer); - } - - // If the layer created its own renderSurface, we have to adjust nextScrollCompensationMatrix. - // The adjustment allows us to continue using the scrollCompensation 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() && !nextScrollCompensationMatrix.IsIdentity()) { - gfx::Transform inverseSurfaceDrawTransform(gfx::Transform::kSkipInitialization); - if (!layer->render_surface()->draw_transform().GetInverse(&inverseSurfaceDrawTransform)) { - // TODO(shawnsingh): Either we need to handle uninvertible transforms - // here, or DCHECK that the transform is invertible. - } - nextScrollCompensationMatrix = inverseSurfaceDrawTransform * nextScrollCompensationMatrix * layer->render_surface()->draw_transform(); +gfx::Transform ComputeScrollCompensationMatrixForChildren( + LayerImpl* layer, + const gfx::Transform& parent_matrix, + const gfx::Transform& current_scroll_compensation_matrix) { + // "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. + // + + // 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 (!layer->is_container_for_fixed_position_layers() && + layer->scroll_delta().IsZero() && !layer->render_surface()) + return current_scroll_compensation_matrix; + + // Start as identity matrix. + gfx::Transform next_scroll_compensation_matrix; + + // If this layer is not a container, then it inherits the existing scroll + // compensations. + if (!layer->is_container_for_fixed_position_layers()) + next_scroll_compensation_matrix = current_scroll_compensation_matrix; + + // If the current layer has a non-zero scroll_delta, then we should compute + // its local scrollCompensation and accumulate it to the + // next_scroll_compensation_matrix. + if (!layer->scroll_delta().IsZero()) { + gfx::Transform scroll_compensation_for_this_layer = + ComputeScrollCompensationForThisLayer(layer, parent_matrix); + 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 scrollCompensation 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 nextScrollCompensationMatrix; + return next_scroll_compensation_matrix; } -template<typename LayerType> -static inline void CalculateContentsScale(LayerType* layer, float contentsScale, bool animating_transform_to_screen) -{ - layer->CalculateContentsScale( - contentsScale, +template <typename LayerType> +static inline void CalculateContentsScale(LayerType* layer, + float contents_scale, + bool animating_transform_to_screen) { + layer->CalculateContentsScale(contents_scale, + animating_transform_to_screen, + &layer->draw_properties().contents_scale_x, + &layer->draw_properties().contents_scale_y, + &layer->draw_properties().content_bounds); + + LayerType* mask_layer = layer->mask_layer(); + if (mask_layer) { + mask_layer->CalculateContentsScale( + contents_scale, animating_transform_to_screen, - &layer->draw_properties().contents_scale_x, - &layer->draw_properties().contents_scale_y, - &layer->draw_properties().content_bounds); - - LayerType* maskLayer = layer->mask_layer(); - if (maskLayer) - { - maskLayer->CalculateContentsScale( - contentsScale, - animating_transform_to_screen, - &maskLayer->draw_properties().contents_scale_x, - &maskLayer->draw_properties().contents_scale_y, - &maskLayer->draw_properties().content_bounds); - } - - LayerType* replicaMaskLayer = layer->replica_layer() ? layer->replica_layer()->mask_layer() : 0; - if (replicaMaskLayer) - { - replicaMaskLayer->CalculateContentsScale( - contentsScale, - animating_transform_to_screen, - &replicaMaskLayer->draw_properties().contents_scale_x, - &replicaMaskLayer->draw_properties().contents_scale_y, - &replicaMaskLayer->draw_properties().content_bounds); - } + &mask_layer->draw_properties().contents_scale_x, + &mask_layer->draw_properties().contents_scale_y, + &mask_layer->draw_properties().content_bounds); + } + + LayerType* replica_mask_layer = + layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL; + if (replica_mask_layer) { + replica_mask_layer->CalculateContentsScale( + contents_scale, + animating_transform_to_screen, + &replica_mask_layer->draw_properties().contents_scale_x, + &replica_mask_layer->draw_properties().contents_scale_y, + &replica_mask_layer->draw_properties().content_bounds); + } } -static inline void updateLayerContentsScale(LayerImpl* layer, const gfx::Transform& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animating_transform_to_screen) -{ - gfx::Vector2dF transformScale = MathUtil::ComputeTransform2dScaleComponents(combinedTransform, deviceScaleFactor * pageScaleFactor); - float contentsScale = std::max(transformScale.x(), transformScale.y()); - CalculateContentsScale(layer, contentsScale, animating_transform_to_screen); +static inline void UpdateLayerContentsScale( + LayerImpl* layer, + const gfx::Transform& combined_transform, + float device_scale_factor, + float page_scale_factor, + bool animating_transform_to_screen) { + gfx::Vector2dF transform_scale = MathUtil::ComputeTransform2dScaleComponents( + combined_transform, device_scale_factor * page_scale_factor); + float contents_scale = std::max(transform_scale.x(), transform_scale.y()); + CalculateContentsScale(layer, contents_scale, animating_transform_to_screen); } -static inline void updateLayerContentsScale(Layer* layer, const gfx::Transform& combinedTransform, float deviceScaleFactor, float pageScaleFactor, bool animating_transform_to_screen) -{ - float rasterScale = layer->raster_scale(); - - if (layer->automatically_compute_raster_scale()) { - gfx::Vector2dF transformScale = MathUtil::ComputeTransform2dScaleComponents(combinedTransform, 0.f); - float combinedScale = std::max(transformScale.x(), transformScale.y()); - float idealRasterScale = combinedScale / deviceScaleFactor; - if (!layer->bounds_contain_page_scale()) - idealRasterScale /= pageScaleFactor; - - bool needToSetRasterScale = !rasterScale; - - // If we've previously saved a rasterScale but the ideal changes, things are unpredictable and we should just use 1. - if (rasterScale && rasterScale != 1.f && idealRasterScale != rasterScale) { - idealRasterScale = 1.f; - needToSetRasterScale = true; - } - - if (needToSetRasterScale) { - bool useAndSaveIdealScale = idealRasterScale >= 1.f && !animating_transform_to_screen; - if (useAndSaveIdealScale) { - rasterScale = idealRasterScale; - layer->SetRasterScale(rasterScale); - } - } - } - - if (!rasterScale) - rasterScale = 1.f; - - float contentsScale = rasterScale * deviceScaleFactor; +static inline void UpdateLayerContentsScale( + Layer* layer, + const gfx::Transform& combined_transform, + float device_scale_factor, + float page_scale_factor, + bool animating_transform_to_screen) { + float raster_scale = layer->raster_scale(); + + if (layer->automatically_compute_raster_scale()) { + gfx::Vector2dF transform_scale = + MathUtil::ComputeTransform2dScaleComponents(combined_transform, 0.f); + float combined_scale = std::max(transform_scale.x(), transform_scale.y()); + float ideal_raster_scale = combined_scale / device_scale_factor; if (!layer->bounds_contain_page_scale()) - contentsScale *= pageScaleFactor; + ideal_raster_scale /= page_scale_factor; - CalculateContentsScale(layer, contentsScale, animating_transform_to_screen); -} + bool need_to_set_raster_scale = !raster_scale; -template<typename LayerType, typename LayerList> -static inline void removeSurfaceForEarlyExit(LayerType* layerToRemove, LayerList& renderSurfaceLayerList) -{ - DCHECK(layerToRemove->render_surface()); - // Technically, we know that the layer we want to remove should be - // at the back of the renderSurfaceLayerList. However, we have had - // bugs before that added unnecessary layers here - // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes - // things to crash. So here we proactively remove any additional - // layers from the end of the list. - while (renderSurfaceLayerList.back() != layerToRemove) { - renderSurfaceLayerList.back()->ClearRenderSurface(); - renderSurfaceLayerList.pop_back(); + // If we've previously saved a raster_scale but the ideal changes, things + // are unpredictable and we should just use 1. + if (raster_scale && raster_scale != 1.f && + ideal_raster_scale != raster_scale) { + ideal_raster_scale = 1.f; + need_to_set_raster_scale = true; } - DCHECK(renderSurfaceLayerList.back() == layerToRemove); - renderSurfaceLayerList.pop_back(); - layerToRemove->ClearRenderSurface(); -} -// Recursively walks the layer tree to compute any information that is needed -// before doing the main recursion. -template<typename LayerType> -static void preCalculateMetaInformation(LayerType* layer) -{ - if (layer->HasDelegatedContent()) { - // Layers with delegated content need to be treated as if they have as many children as the number - // of layers they own delegated quads for. Since we don't know this number right now, we choose - // one that acts like infinity for our purposes. - layer->draw_properties().num_descendants_that_draw_content = 1000; - layer->draw_properties().descendants_can_clip_selves = false; - return; + if (need_to_set_raster_scale) { + bool use_and_save_ideal_scale = + ideal_raster_scale >= 1.f && !animating_transform_to_screen; + if (use_and_save_ideal_scale) { + raster_scale = ideal_raster_scale; + layer->SetRasterScale(raster_scale); + } } + } - int numDescendantsThatDrawContent = 0; - bool descendantsCanClipSelves = true; - bool sublayerTransformPreventsClip = !layer->sublayer_transform().IsPositiveScaleOrTranslation(); + if (!raster_scale) + raster_scale = 1.f; - for (size_t i = 0; i < layer->children().size(); ++i) { - LayerType* childLayer = layer->children()[i]; - preCalculateMetaInformation<LayerType>(childLayer); + float contents_scale = raster_scale * device_scale_factor; + if (!layer->bounds_contain_page_scale()) + contents_scale *= page_scale_factor; - numDescendantsThatDrawContent += childLayer->DrawsContent() ? 1 : 0; - numDescendantsThatDrawContent += childLayer->draw_properties().num_descendants_that_draw_content; + CalculateContentsScale(layer, contents_scale, animating_transform_to_screen); +} - if ((childLayer->DrawsContent() && !childLayer->CanClipSelf()) || - !childLayer->draw_properties().descendants_can_clip_selves || - sublayerTransformPreventsClip || - !childLayer->transform().IsPositiveScaleOrTranslation()) - descendantsCanClipSelves = false; - } +template <typename LayerType, typename LayerList> +static inline void RemoveSurfaceForEarlyExit( + LayerType* layer_to_remove, + LayerList& render_surface_layer_list) { + DCHECK(layer_to_remove->render_surface()); + // Technically, we know that the layer we want to remove should be + // at the back of the render_surface_layer_list. However, we have had + // bugs before that added unnecessary layers here + // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes + // things to crash. So here we proactively remove any additional + // layers from the end of the list. + while (render_surface_layer_list->back() != layer_to_remove) { + render_surface_layer_list->back()->ClearRenderSurface(); + render_surface_layer_list->pop_back(); + } + DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove); + render_surface_layer_list->pop_back(); + layer_to_remove->ClearRenderSurface(); +} - layer->draw_properties().num_descendants_that_draw_content = numDescendantsThatDrawContent; - layer->draw_properties().descendants_can_clip_selves = descendantsCanClipSelves; +// Recursively walks the layer tree to compute any information that is needed +// before doing the main recursion. +template <typename LayerType> +static void PreCalculateMetaInformation(LayerType* layer) { + if (layer->HasDelegatedContent()) { + // Layers with delegated content need to be treated as if they have as many + // children as the number of layers they own delegated quads for. Since we + // don't know this number right now, we choose one that acts like infinity + // for our purposes. + layer->draw_properties().num_descendants_that_draw_content = 1000; + layer->draw_properties().descendants_can_clip_selves = false; + return; + } + + int num_descendants_that_draw_content = 0; + bool descendants_can_clip_selves = true; + bool sublayer_transform_prevents_clip = + !layer->sublayer_transform().IsPositiveScaleOrTranslation(); + + for (size_t i = 0; i < layer->children().size(); ++i) { + LayerType* child_layer = layer->children()[i]; + PreCalculateMetaInformation<LayerType>(child_layer); + + num_descendants_that_draw_content += child_layer->DrawsContent() ? 1 : 0; + num_descendants_that_draw_content += + child_layer->draw_properties().num_descendants_that_draw_content; + + if ((child_layer->DrawsContent() && !child_layer->CanClipSelf()) || + !child_layer->draw_properties().descendants_can_clip_selves || + sublayer_transform_prevents_clip || + !child_layer->transform().IsPositiveScaleOrTranslation()) + descendants_can_clip_selves = false; + } + + layer->draw_properties().num_descendants_that_draw_content = + num_descendants_that_draw_content; + layer->draw_properties().descendants_can_clip_selves = + descendants_can_clip_selves; } -static void roundTranslationComponents(gfx::Transform* transform) -{ - transform->matrix().setDouble(0, 3, MathUtil::Round(transform->matrix().getDouble(0, 3))); - transform->matrix().setDouble(1, 3, MathUtil::Round(transform->matrix().getDouble(1, 3))); +static void RoundTranslationComponents(gfx::Transform* transform) { + transform->matrix(). + setDouble(0, 3, MathUtil::Round(transform->matrix().getDouble(0, 3))); + transform->matrix(). + setDouble(1, 3, MathUtil::Round(transform->matrix().getDouble(1, 3))); } -// Recursively walks the layer tree starting at the given node and computes all the -// necessary transformations, clipRects, render surfaces, etc. -template<typename LayerType, typename LayerList, typename RenderSurfaceType> -static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transform& parentMatrix, - const gfx::Transform& fullHierarchyMatrix, const gfx::Transform& currentScrollCompensationMatrix, - const gfx::Rect& clipRectFromAncestor, const gfx::Rect& clipRectFromAncestorInDescendantSpace, bool ancestorClipsSubtree, - RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceLayerList, LayerList& layerList, - LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool subtreeCanUseLCDText, - gfx::Rect& drawableContentRectOfSubtree, bool updateTilePriorities) -{ - // This function computes the new matrix transformations recursively for this - // layer and all its descendants. It also computes the appropriate render surfaces. - // Some important points to remember: - // - // 0. Here, transforms are notated in Matrix x Vector order, and in words we describe what - // the transform does from left to right. - // - // 1. In our terminology, the "layer origin" refers to the top-left corner of a layer, and the - // positive Y-axis points downwards. This interpretation is valid because the orthographic - // projection applied at draw time flips the Y axis appropriately. - // - // 2. The anchor point, when given as a PointF object, is specified in "unit layer space", - // where the bounds of the layer map to [0, 1]. However, as a Transform object, - // the transform to the anchor point is specified in "layer space", where the bounds - // of the layer map to [bounds.width(), bounds.height()]. - // - // 3. Definition of various transforms used: - // M[parent] is the parent matrix, with respect to the nearest render surface, passed down recursively. - // M[root] is the full hierarchy, with respect to the root, passed down recursively. - // Tr[origin] is the translation matrix from the parent's origin to this layer's origin. - // Tr[origin2anchor] is the translation from the layer's origin to its anchor point - // Tr[origin2center] is the translation from the layer's origin to its center - // M[layer] is the layer's matrix (applied at the anchor point) - // M[sublayer] is the layer's sublayer transform (also applied at the layer's anchor point) - // S[layer2content] is the ratio of a layer's ContentBounds() to its Bounds(). - // - // Some composite transforms can help in understanding the sequence of transforms: - // compositeLayerTransform = Tr[origin2anchor] * M[layer] * Tr[origin2anchor].inverse() - // compositeSublayerTransform = Tr[origin2anchor] * M[sublayer] * Tr[origin2anchor].inverse() - // - // 4. When a layer (or render surface) is drawn, it is drawn into a "target render surface". Therefore the draw - // transform does not necessarily transform from screen space to local layer space. Instead, the draw transform - // is the transform between the "target render surface space" and local layer space. Note that render surfaces, - // except for the root, also draw themselves into a different target render surface, and so their draw - // transform and origin transforms are also described with respect to the target. - // - // Using these definitions, then: - // - // The draw transform for the layer is: - // M[draw] = M[parent] * Tr[origin] * compositeLayerTransform * S[layer2content] - // = M[parent] * Tr[layer->Position() + anchor] * M[layer] * Tr[anchor2origin] * S[layer2content] - // - // Interpreting the math left-to-right, this transforms from the layer's render surface to the origin of the layer in content space. - // - // The screen space transform is: - // M[screenspace] = M[root] * Tr[origin] * compositeLayerTransform * S[layer2content] - // = M[root] * Tr[layer->Position() + anchor] * M[layer] * Tr[anchor2origin] * S[layer2content] - // - // Interpreting the math left-to-right, this transforms from the root render surface's content space to the origin of the layer in content space. - // - // The transform hierarchy that is passed on to children (i.e. the child's parentMatrix) is: - // M[parent]_for_child = M[parent] * Tr[origin] * compositeLayerTransform * compositeSublayerTransform - // = M[parent] * Tr[layer->Position() + anchor] * M[layer] * Tr[anchor2origin] * compositeSublayerTransform - // - // and a similar matrix for the full hierarchy with respect to the root. - // - // Finally, note that the final matrix used by the shader for the layer is P * M[draw] * S . This final product - // is computed in drawTexturedQuad(), where: - // P is the projection matrix - // S is the scale adjustment (to scale up a canonical quad to the layer's size) - // - // When a render surface has a replica layer, that layer's transform is used to draw a second copy of the surface. - // gfx::Transforms named here are relative to the surface, unless they specify they are relative to the replica layer. - // - // We will denote a scale by device scale S[deviceScale] - // - // The render surface draw transform to its target surface origin is: - // M[surfaceDraw] = M[owningLayer->Draw] - // - // The render surface origin transform to its the root (screen space) origin is: - // M[surface2root] = M[owningLayer->screenspace] * S[deviceScale].inverse() - // - // The replica draw transform to its target surface origin is: - // M[replicaDraw] = S[deviceScale] * M[surfaceDraw] * Tr[replica->Position() + replica->anchor()] * Tr[replica] * Tr[origin2anchor].inverse() * S[contentsScale].inverse() - // - // The replica draw transform to the root (screen space) origin is: - // M[replica2root] = M[surface2root] * Tr[replica->Position()] * Tr[replica] * Tr[origin2anchor].inverse() - // - - // If we early-exit anywhere in this function, the drawableContentRect of this subtree should be considered empty. - drawableContentRectOfSubtree = gfx::Rect(); - - // The root layer cannot skip calcDrawProperties. - if (!isRootLayer(layer) && subtreeShouldBeSkipped(layer)) - return; - - // As this function proceeds, these are the properties for the current - // layer that actually get computed. To avoid unnecessary copies - // (particularly for matrices), we do computations directly on these values - // when possible. - DrawProperties<LayerType, RenderSurfaceType>& layerDrawProperties = layer->draw_properties(); - - gfx::Rect clipRectForSubtree; - bool subtreeShouldBeClipped = false; - - // This value is cached on the stack so that we don't have to inverse-project - // the surface's clipRect redundantly for every layer. This value is the - // same as the surface's clipRect, except that instead of being described - // in the target surface space (i.e. the ancestor surface space), it is - // described in the current surface space. - gfx::Rect clipRectForSubtreeInDescendantSpace; - - float accumulatedDrawOpacity = layer->opacity(); - bool animatingOpacityToTarget = layer->OpacityIsAnimating(); - bool animatingOpacityToScreen = animatingOpacityToTarget; - if (layer->parent()) { - accumulatedDrawOpacity *= layer->parent()->draw_opacity(); - animatingOpacityToTarget |= layer->parent()->draw_opacity_is_animating(); - animatingOpacityToScreen |= layer->parent()->screen_space_opacity_is_animating(); +// Recursively walks the layer tree starting at the given node and computes all +// the necessary transformations, clipRects, render surfaces, etc. +template <typename LayerType, typename LayerList, typename RenderSurfaceType> +static void CalculateDrawPropertiesInternal( + LayerType* layer, + const gfx::Transform& parent_matrix, + const gfx::Transform& full_hierarchy_matrix, + const gfx::Transform& current_scroll_compensation_matrix, + gfx::Rect clip_rect_from_ancestor, + gfx::Rect clip_rect_from_ancestor_in_descendant_space, + bool ancestor_clips_subtree, + RenderSurfaceType* nearest_ancestor_that_moves_pixels, + LayerList* render_surface_layer_list, + LayerList* layer_list, + LayerSorter* layer_sorter, + int max_texture_size, + float device_scale_factor, + float page_scale_factor, + bool subtree_can_use_lcd_text, + gfx::Rect* drawable_content_rect_of_subtree, + bool update_tile_priorities) { + // This function computes the new matrix transformations recursively for this + // layer and all its descendants. It also computes the appropriate render + // surfaces. + // Some important points to remember: + // + // 0. Here, transforms are notated in Matrix x Vector order, and in words we + // describe what the transform does from left to right. + // + // 1. In our terminology, the "layer origin" refers to the top-left corner of + // a layer, and the positive Y-axis points downwards. This interpretation is + // valid because the orthographic projection applied at draw time flips the Y + // axis appropriately. + // + // 2. The anchor point, when given as a PointF object, is specified in "unit + // layer space", where the bounds of the layer map to [0, 1]. However, as a + // Transform object, the transform to the anchor point is specified in "layer + // space", where the bounds of the layer map to [bounds.width(), + // bounds.height()]. + // + // 3. Definition of various transforms used: + // M[parent] is the parent matrix, with respect to the nearest render + // surface, passed down recursively. + // + // M[root] is the full hierarchy, with respect to the root, passed down + // recursively. + // + // Tr[origin] is the translation matrix from the parent's origin to + // this layer's origin. + // + // Tr[origin2anchor] is the translation from the layer's origin to its + // anchor point + // + // Tr[origin2center] is the translation from the layer's origin to its + // center + // + // M[layer] is the layer's matrix (applied at the anchor point) + // + // M[sublayer] is the layer's sublayer transform (also applied at the + // layer's anchor point) + // + // S[layer2content] is the ratio of a layer's ContentBounds() to its + // Bounds(). + // + // Some composite transforms can help in understanding the sequence of + // transforms: + // compositeLayerTransform = Tr[origin2anchor] * M[layer] * + // Tr[origin2anchor].inverse() + // + // compositeSublayerTransform = Tr[origin2anchor] * M[sublayer] * + // Tr[origin2anchor].inverse() + // + // 4. When a layer (or render surface) is drawn, it is drawn into a "target + // render surface". Therefore the draw transform does not necessarily + // transform from screen space to local layer space. Instead, the draw + // transform is the transform between the "target render surface space" and + // local layer space. Note that render surfaces, except for the root, also + // draw themselves into a different target render surface, and so their draw + // transform and origin transforms are also described with respect to the + // target. + // + // Using these definitions, then: + // + // The draw transform for the layer is: + // M[draw] = M[parent] * Tr[origin] * compositeLayerTransform * + // S[layer2content] = M[parent] * Tr[layer->Position() + anchor] * + // M[layer] * Tr[anchor2origin] * S[layer2content] + // + // Interpreting the math left-to-right, this transforms from the + // layer's render surface to the origin of the layer in content space. + // + // The screen space transform is: + // M[screenspace] = M[root] * Tr[origin] * compositeLayerTransform * + // S[layer2content] + // = M[root] * Tr[layer->Position() + anchor] * M[layer] + // * Tr[anchor2origin] * S[layer2content] + // + // Interpreting the math left-to-right, this transforms from the root + // render surface's content space to the origin of the layer in content + // space. + // + // The transform hierarchy that is passed on to children (i.e. the child's + // parent_matrix) is: + // M[parent]_for_child = M[parent] * Tr[origin] * + // compositeLayerTransform * compositeSublayerTransform + // = M[parent] * Tr[layer->Position() + anchor] * + // M[layer] * Tr[anchor2origin] * + // compositeSublayerTransform + // + // and a similar matrix for the full hierarchy with respect to the + // root. + // + // Finally, note that the final matrix used by the shader for the layer is P * + // M[draw] * S . This final product is computed in drawTexturedQuad(), where: + // P is the projection matrix + // S is the scale adjustment (to scale up a canonical quad to the + // layer's size) + // + // When a render surface has a replica layer, that layer's transform is used + // to draw a second copy of the surface. gfx::Transforms named here are + // relative to the surface, unless they specify they are relative to the + // replica layer. + // + // We will denote a scale by device scale S[deviceScale] + // + // The render surface draw transform to its target surface origin is: + // M[surfaceDraw] = M[owningLayer->Draw] + // + // The render surface origin transform to its the root (screen space) origin + // is: + // M[surface2root] = M[owningLayer->screenspace] * + // S[deviceScale].inverse() + // + // The replica draw transform to its target surface origin is: + // M[replicaDraw] = S[deviceScale] * M[surfaceDraw] * + // Tr[replica->Position() + replica->anchor()] * Tr[replica] * + // Tr[origin2anchor].inverse() * S[contents_scale].inverse() + // + // The replica draw transform to the root (screen space) origin is: + // M[replica2root] = M[surface2root] * Tr[replica->Position()] * + // Tr[replica] * Tr[origin2anchor].inverse() + // + + // If we early-exit anywhere in this function, the drawableContentRect of this + // subtree should be considered empty. + *drawable_content_rect_of_subtree = gfx::Rect(); + + // The root layer cannot skip calcDrawProperties. + if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer)) + return; + + // As this function proceeds, these are the properties for the current + // layer that actually get computed. To avoid unnecessary copies + // (particularly for matrices), we do computations directly on these values + // when possible. + DrawProperties<LayerType, RenderSurfaceType>& layer_draw_properties = + layer->draw_properties(); + + gfx::Rect clip_rect_for_subtree; + bool subtree_should_be_clipped = false; + + // This value is cached on the stack so that we don't have to inverse-project + // the surface's clipRect redundantly for every layer. This value is the + // same as the surface's clipRect, except that instead of being described + // in the target surface space (i.e. the ancestor surface space), it is + // described in the current surface space. + gfx::Rect clip_rect_for_subtree_in_descendant_space; + + float accumulated_draw_opacity = layer->opacity(); + bool animating_opacity_to_target = layer->OpacityIsAnimating(); + bool animating_opacity_to_screen = animating_opacity_to_target; + if (layer->parent()) { + accumulated_draw_opacity *= layer->parent()->draw_opacity(); + animating_opacity_to_target |= layer->parent()->draw_opacity_is_animating(); + animating_opacity_to_screen |= + layer->parent()->screen_space_opacity_is_animating(); + } + + bool animating_transform_to_target = layer->TransformIsAnimating(); + bool animating_transform_to_screen = animating_transform_to_target; + if (layer->parent()) { + animating_transform_to_target |= + layer->parent()->draw_transform_is_animating(); + animating_transform_to_screen |= + layer->parent()->screen_space_transform_is_animating(); + } + + gfx::Size bounds = layer->bounds(); + gfx::PointF anchor_point = layer->anchor_point(); + gfx::PointF position = layer->position() - layer->scroll_delta(); + + gfx::Transform combined_transform = parent_matrix; + if (!layer->transform().IsIdentity()) { + // LT = Tr[origin] * Tr[origin2anchor] + combined_transform.Translate3d( + position.x() + anchor_point.x() * bounds.width(), + position.y() + anchor_point.y() * bounds.height(), + layer->anchor_point_z()); + // LT = Tr[origin] * Tr[origin2anchor] * M[layer] + combined_transform.PreconcatTransform(layer->transform()); + // LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin] + combined_transform.Translate3d(-anchor_point.x() * bounds.width(), + -anchor_point.y() * bounds.height(), + -layer->anchor_point_z()); + } else { + combined_transform.Translate(position.x(), position.y()); + } + + // The layer's contentsSize is determined from the combined_transform, which + // then informs the layer's draw_transform. + UpdateLayerContentsScale(layer, + combined_transform, + device_scale_factor, + page_scale_factor, + animating_transform_to_screen); + + // If there is a transformation from the impl thread then it should be at + // the start of the combined_transform, but we don't want it to affect the + // computation of contents_scale above. + // Note carefully: this is Concat, not Preconcat (implTransform * + // combined_transform). + combined_transform.ConcatTransform(layer->impl_transform()); + + if (!animating_transform_to_target && layer->scrollable() && + combined_transform.IsScaleOrTranslation()) { + // Align the scrollable layer's position to screen space pixels to avoid + // blurriness. To avoid side-effects, do this only if the transform is + // simple. + RoundTranslationComponents(&combined_transform); + } + + if (layer->fixed_to_container_layer()) { + // 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(current_scroll_compensation_matrix); + } + + // The draw_transform that gets computed below is effectively the layer's + // draw_transform, unless the layer itself creates a render_surface. In that + // case, the render_surface re-parents the transforms. + layer_draw_properties.target_space_transform = combined_transform; + // M[draw] = M[parent] * LT * S[layer2content] + layer_draw_properties.target_space_transform.Scale + (1.f / layer->contents_scale_x(), 1.f / layer->contents_scale_y()); + + // layerScreenSpaceTransform represents the transform between root layer's + // "screen space" and local content space. + layer_draw_properties.screen_space_transform = full_hierarchy_matrix; + if (!layer->preserves_3d()) + layer_draw_properties.screen_space_transform.FlattenTo2d(); + layer_draw_properties.screen_space_transform.PreconcatTransform + (layer_draw_properties.target_space_transform); + + // Adjusting text AA method during animation may cause repaints, which in-turn + // causes jank. + bool adjust_text_aa = + !animating_opacity_to_screen && !animating_transform_to_screen; + // To avoid color fringing, LCD text should only be used on opaque layers with + // just integral translation. + bool layer_can_use_lcd_text = + subtree_can_use_lcd_text && (accumulated_draw_opacity == 1.f) && + layer_draw_properties.target_space_transform. + IsIdentityOrIntegerTranslation(); + + gfx::RectF content_rect(gfx::PointF(), layer->content_bounds()); + + // full_hierarchy_matrix is the matrix that transforms objects between screen + // space (except projection matrix) and the most recent RenderSurfaceImpl's + // space. next_hierarchy_matrix will only change if this layer uses a new + // RenderSurfaceImpl, otherwise remains the same. + gfx::Transform next_hierarchy_matrix = full_hierarchy_matrix; + gfx::Transform sublayer_matrix; + + gfx::Vector2dF render_surface_sublayer_scale = + MathUtil::ComputeTransform2dScaleComponents( + combined_transform, device_scale_factor * page_scale_factor); + + if (SubtreeShouldRenderToSeparateSurface( + layer, combined_transform.IsScaleOrTranslation())) { + // Check back-face visibility before continuing with this surface and its + // subtree + if (!layer->double_sided() && TransformToParentIsKnown(layer) && + IsSurfaceBackFaceVisible(layer, combined_transform)) + return; + + if (!layer->render_surface()) + layer->CreateRenderSurface(); + + RenderSurfaceType* render_surface = layer->render_surface(); + render_surface->ClearLayerLists(); + + // The owning layer's draw transform has a scale from content to layer + // space which we do not want; so here we use the combined_transform + // instead of the draw_transform. However, we do need to add a different + // scale factor that accounts for the surface's pixel dimensions. + combined_transform.Scale(1.0 / render_surface_sublayer_scale.x(), + 1.0 / render_surface_sublayer_scale.y()); + render_surface->SetDrawTransform(combined_transform); + + // The owning layer's transform was re-parented by the surface, so the + // layer's new draw_transform only needs to scale the layer to surface + // space. + layer_draw_properties.target_space_transform.MakeIdentity(); + layer_draw_properties.target_space_transform. + Scale(render_surface_sublayer_scale.x() / layer->contents_scale_x(), + render_surface_sublayer_scale.y() / layer->contents_scale_y()); + + // Inside the surface's subtree, we scale everything to the owning layer's + // scale. The sublayer matrix transforms layer rects into target surface + // content space. + DCHECK(sublayer_matrix.IsIdentity()); + sublayer_matrix.Scale(render_surface_sublayer_scale.x(), + render_surface_sublayer_scale.y()); + + // The opacity value is moved from the layer to its surface, so that the + // entire subtree properly inherits opacity. + render_surface->SetDrawOpacity(accumulated_draw_opacity); + render_surface->SetDrawOpacityIsAnimating(animating_opacity_to_target); + animating_opacity_to_target = false; + layer_draw_properties.opacity = 1.f; + layer_draw_properties.opacity_is_animating = animating_opacity_to_target; + layer_draw_properties.screen_space_opacity_is_animating = + animating_opacity_to_screen; + + render_surface->SetTargetSurfaceTransformsAreAnimating( + animating_transform_to_target); + render_surface->SetScreenSpaceTransformsAreAnimating( + animating_transform_to_screen); + animating_transform_to_target = false; + layer_draw_properties.target_space_transform_is_animating = + animating_transform_to_target; + layer_draw_properties.screen_space_transform_is_animating = + animating_transform_to_screen; + + // Update the aggregate hierarchy matrix to include the transform of the + // newly created RenderSurfaceImpl. + next_hierarchy_matrix.PreconcatTransform(render_surface->draw_transform()); + + // The new render_surface here will correctly clip the entire subtree. So, + // we do not need to continue propagating the clipping state further down + // the tree. This way, we can avoid transforming clipRects from ancestor + // target surface space to current target surface space that could cause + // more w < 0 headaches. + subtree_should_be_clipped = false; + + if (layer->mask_layer()) { + DrawProperties<LayerType, RenderSurfaceType>& mask_layer_draw_properties = + layer->mask_layer()->draw_properties(); + mask_layer_draw_properties.render_target = layer; + mask_layer_draw_properties.visible_content_rect = + gfx::Rect(gfx::Point(), layer->content_bounds()); } - bool animatingTransformToTarget = layer->TransformIsAnimating(); - bool animating_transform_to_screen = animatingTransformToTarget; - if (layer->parent()) { - animatingTransformToTarget |= layer->parent()->draw_transform_is_animating(); - animating_transform_to_screen |= layer->parent()->screen_space_transform_is_animating(); + if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { + DrawProperties<LayerType, RenderSurfaceType>& + replica_mask_draw_properties = + layer->replica_layer()->mask_layer()->draw_properties(); + replica_mask_draw_properties.render_target = layer; + replica_mask_draw_properties.visible_content_rect = + gfx::Rect(gfx::Point(), layer->content_bounds()); } - gfx::Size bounds = layer->bounds(); - gfx::PointF anchorPoint = layer->anchor_point(); - gfx::PointF position = layer->position() - layer->scroll_delta(); - - gfx::Transform combinedTransform = parentMatrix; - if (!layer->transform().IsIdentity()) { - // LT = Tr[origin] * Tr[origin2anchor] - combinedTransform.Translate3d(position.x() + anchorPoint.x() * bounds.width(), position.y() + anchorPoint.y() * bounds.height(), layer->anchor_point_z()); - // LT = Tr[origin] * Tr[origin2anchor] * M[layer] - combinedTransform.PreconcatTransform(layer->transform()); - // LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin] - combinedTransform.Translate3d(-anchorPoint.x() * bounds.width(), -anchorPoint.y() * bounds.height(), -layer->anchor_point_z()); + // TODO(senorblanco): make this smarter for the SkImageFilter case (check + // for pixel-moving filters) + if (layer->filters().hasFilterThatMovesPixels() || layer->filter()) + nearest_ancestor_that_moves_pixels = render_surface; + + // The render surface clipRect is expressed in the space where this surface + // draws, i.e. the same space as clip_rect_from_ancestor. + render_surface->SetIsClipped(ancestor_clips_subtree); + if (ancestor_clips_subtree) { + render_surface->SetClipRect(clip_rect_from_ancestor); + + gfx::Transform inverse_surface_draw_transform( + gfx::Transform::kSkipInitialization); + if (!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. + } + clip_rect_for_subtree_in_descendant_space = + gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( + inverse_surface_draw_transform, render_surface->clip_rect())); } else { - combinedTransform.Translate(position.x(), position.y()); + render_surface->SetClipRect(gfx::Rect()); + clip_rect_for_subtree_in_descendant_space = + clip_rect_from_ancestor_in_descendant_space; } - // The layer's contentsSize is determined from the combinedTransform, which then informs the - // layer's drawTransform. - updateLayerContentsScale(layer, combinedTransform, deviceScaleFactor, pageScaleFactor, animating_transform_to_screen); - - // If there is a transformation from the impl thread then it should be at - // the start of the combinedTransform, but we don't want it to affect the - // computation of contentsScale above. - // Note carefully: this is Concat, not Preconcat (implTransform * combinedTransform). - combinedTransform.ConcatTransform(layer->impl_transform()); - - if (!animatingTransformToTarget && layer->scrollable() && combinedTransform.IsScaleOrTranslation()) { - // Align the scrollable layer's position to screen space pixels to avoid blurriness. - // To avoid side-effects, do this only if the transform is simple. - roundTranslationComponents(&combinedTransform); - } - - if (layer->fixed_to_container_layer()) { - // Special case: this layer is a composited fixed-position layer; we need to - // explicitly compensate for all ancestors' nonzero scrollDeltas to keep this layer - // fixed correctly. - // Note carefully: this is Concat, not Preconcat (currentScrollCompensation * combinedTransform). - combinedTransform.ConcatTransform(currentScrollCompensationMatrix); - } - - // The drawTransform that gets computed below is effectively the layer's drawTransform, unless - // the layer itself creates a renderSurface. In that case, the renderSurface re-parents the transforms. - layerDrawProperties.target_space_transform = combinedTransform; - // M[draw] = M[parent] * LT * S[layer2content] - layerDrawProperties.target_space_transform.Scale(1.0 / layer->contents_scale_x(), 1.0 / layer->contents_scale_y()); - - // layerScreenSpaceTransform represents the transform between root layer's "screen space" and local content space. - layerDrawProperties.screen_space_transform = fullHierarchyMatrix; - if (!layer->preserves_3d()) - layerDrawProperties.screen_space_transform.FlattenTo2d(); - layerDrawProperties.screen_space_transform.PreconcatTransform(layerDrawProperties.target_space_transform); - - // Adjusting text AA method during animation may cause repaints, which in-turn causes jank. - bool adjustTextAA = !animatingOpacityToScreen && !animating_transform_to_screen; - // To avoid color fringing, LCD text should only be used on opaque layers with just integral translation. - bool layerCanUseLCDText = subtreeCanUseLCDText && - (accumulatedDrawOpacity == 1.0) && - layerDrawProperties.target_space_transform.IsIdentityOrIntegerTranslation(); - - gfx::RectF contentRect(gfx::PointF(), layer->content_bounds()); - - // fullHierarchyMatrix is the matrix that transforms objects between screen space (except projection matrix) and the most recent RenderSurfaceImpl's space. - // nextHierarchyMatrix will only change if this layer uses a new RenderSurfaceImpl, otherwise remains the same. - gfx::Transform nextHierarchyMatrix = fullHierarchyMatrix; - gfx::Transform sublayerMatrix; - - gfx::Vector2dF renderSurfaceSublayerScale = MathUtil::ComputeTransform2dScaleComponents(combinedTransform, deviceScaleFactor * pageScaleFactor); - - if (subtreeShouldRenderToSeparateSurface(layer, combinedTransform.IsScaleOrTranslation())) { - // Check back-face visibility before continuing with this surface and its subtree - if (!layer->double_sided() && transformToParentIsKnown(layer) && isSurfaceBackFaceVisible(layer, combinedTransform)) - return; - - if (!layer->render_surface()) - layer->CreateRenderSurface(); - - RenderSurfaceType* renderSurface = layer->render_surface(); - renderSurface->ClearLayerLists(); - - // The owning layer's draw transform has a scale from content to layer - // space which we do not want; so here we use the combinedTransform - // instead of the drawTransform. However, we do need to add a different - // scale factor that accounts for the surface's pixel dimensions. - combinedTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y()); - renderSurface->SetDrawTransform(combinedTransform); - - // The owning layer's transform was re-parented by the surface, so the layer's new drawTransform - // only needs to scale the layer to surface space. - layerDrawProperties.target_space_transform.MakeIdentity(); - layerDrawProperties.target_space_transform.Scale(renderSurfaceSublayerScale.x() / layer->contents_scale_x(), renderSurfaceSublayerScale.y() / layer->contents_scale_y()); - - // Inside the surface's subtree, we scale everything to the owning layer's scale. - // The sublayer matrix transforms layer rects into target - // surface content space. - DCHECK(sublayerMatrix.IsIdentity()); - sublayerMatrix.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y()); - - // The opacity value is moved from the layer to its surface, so that the entire subtree properly inherits opacity. - renderSurface->SetDrawOpacity(accumulatedDrawOpacity); - renderSurface->SetDrawOpacityIsAnimating(animatingOpacityToTarget); - animatingOpacityToTarget = false; - layerDrawProperties.opacity = 1; - layerDrawProperties.opacity_is_animating = animatingOpacityToTarget; - layerDrawProperties.screen_space_opacity_is_animating = animatingOpacityToScreen; - - renderSurface->SetTargetSurfaceTransformsAreAnimating(animatingTransformToTarget); - renderSurface->SetScreenSpaceTransformsAreAnimating(animating_transform_to_screen); - animatingTransformToTarget = false; - layerDrawProperties.target_space_transform_is_animating = animatingTransformToTarget; - layerDrawProperties.screen_space_transform_is_animating = animating_transform_to_screen; - - // Update the aggregate hierarchy matrix to include the transform of the - // newly created RenderSurfaceImpl. - nextHierarchyMatrix.PreconcatTransform(renderSurface->draw_transform()); - - // The new renderSurface here will correctly clip the entire subtree. So, we do - // not need to continue propagating the clipping state further down the tree. This - // way, we can avoid transforming clipRects from ancestor target surface space to - // current target surface space that could cause more w < 0 headaches. - subtreeShouldBeClipped = false; - - if (layer->mask_layer()) { - DrawProperties<LayerType, RenderSurfaceType>& maskLayerDrawProperties = layer->mask_layer()->draw_properties(); - maskLayerDrawProperties.render_target = layer; - maskLayerDrawProperties.visible_content_rect = gfx::Rect(gfx::Point(), layer->content_bounds()); - } - - if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { - DrawProperties<LayerType, RenderSurfaceType>& replicaMaskDrawProperties = layer->replica_layer()->mask_layer()->draw_properties(); - replicaMaskDrawProperties.render_target = layer; - replicaMaskDrawProperties.visible_content_rect = gfx::Rect(gfx::Point(), layer->content_bounds()); - } - - // FIXME: make this smarter for the SkImageFilter case (check for - // pixel-moving filters) - if (layer->filters().hasFilterThatMovesPixels() || layer->filter()) - nearestAncestorThatMovesPixels = renderSurface; - - // The render surface clipRect is expressed in the space where this surface draws, i.e. the same space as clipRectFromAncestor. - renderSurface->SetIsClipped(ancestorClipsSubtree); - if (ancestorClipsSubtree) { - renderSurface->SetClipRect(clipRectFromAncestor); - - gfx::Transform inverseSurfaceDrawTransform(gfx::Transform::kSkipInitialization); - if (!renderSurface->draw_transform().GetInverse(&inverseSurfaceDrawTransform)) { - // TODO(shawnsingh): Either we need to handle uninvertible transforms - // here, or DCHECK that the transform is invertible. - } - clipRectForSubtreeInDescendantSpace = gfx::ToEnclosingRect(MathUtil::ProjectClippedRect(inverseSurfaceDrawTransform, renderSurface->clip_rect())); - } else { - renderSurface->SetClipRect(gfx::Rect()); - clipRectForSubtreeInDescendantSpace = clipRectFromAncestorInDescendantSpace; - } - - renderSurface->SetNearestAncestorThatMovesPixels(nearestAncestorThatMovesPixels); - - // If the new render surface is drawn translucent or with a non-integral translation - // then the subtree that gets drawn on this render surface cannot use LCD text. - subtreeCanUseLCDText = layerCanUseLCDText; - - renderSurfaceLayerList.push_back(layer); + render_surface->SetNearestAncestorThatMovesPixels( + nearest_ancestor_that_moves_pixels); + + // If the new render surface is drawn translucent or with a non-integral + // translation then the subtree that gets drawn on this render surface + // cannot use LCD text. + subtree_can_use_lcd_text = layer_can_use_lcd_text; + + render_surface_layer_list->push_back(layer); + } else { + DCHECK(layer->parent()); + + // Note: layer_draw_properties.target_space_transform is computed above, + // before this if-else statement. + layer_draw_properties.target_space_transform_is_animating = + animating_transform_to_target; + layer_draw_properties.screen_space_transform_is_animating = + animating_transform_to_screen; + layer_draw_properties.opacity = accumulated_draw_opacity; + layer_draw_properties.opacity_is_animating = animating_opacity_to_target; + layer_draw_properties.screen_space_opacity_is_animating = + animating_opacity_to_screen; + sublayer_matrix = combined_transform; + + layer->ClearRenderSurface(); + + // Layers without render_surfaces directly inherit the ancestor's clip + // status. + subtree_should_be_clipped = ancestor_clips_subtree; + if (ancestor_clips_subtree) + clip_rect_for_subtree = clip_rect_from_ancestor; + + // The surface's cached clipRect value propagates regardless of what + // clipping goes on between layers here. + clip_rect_for_subtree_in_descendant_space = + clip_rect_from_ancestor_in_descendant_space; + + // Layers that are not their own render_target will render into the target + // of their nearest ancestor. + layer_draw_properties.render_target = layer->parent()->render_target(); + } + + if (adjust_text_aa) + layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; + + gfx::Rect rect_in_target_space = ToEnclosingRect( + MathUtil::MapClippedRect(layer->draw_transform(), content_rect)); + + if (LayerClipsSubtree(layer)) { + subtree_should_be_clipped = true; + if (ancestor_clips_subtree && !layer->render_surface()) { + clip_rect_for_subtree = clip_rect_from_ancestor; + clip_rect_for_subtree.Intersect(rect_in_target_space); } else { - DCHECK(layer->parent()); - - // Note: layerDrawProperties.target_space_transform is computed above, - // before this if-else statement. - layerDrawProperties.target_space_transform_is_animating = animatingTransformToTarget; - layerDrawProperties.screen_space_transform_is_animating = animating_transform_to_screen; - layerDrawProperties.opacity = accumulatedDrawOpacity; - layerDrawProperties.opacity_is_animating = animatingOpacityToTarget; - layerDrawProperties.screen_space_opacity_is_animating = animatingOpacityToScreen; - sublayerMatrix = combinedTransform; - - layer->ClearRenderSurface(); - - // Layers without renderSurfaces directly inherit the ancestor's clip status. - subtreeShouldBeClipped = ancestorClipsSubtree; - if (ancestorClipsSubtree) - clipRectForSubtree = clipRectFromAncestor; - - // The surface's cached clipRect value propagates regardless of what clipping goes on between layers here. - clipRectForSubtreeInDescendantSpace = clipRectFromAncestorInDescendantSpace; - - // Layers that are not their own renderTarget will render into the target of their nearest ancestor. - layerDrawProperties.render_target = layer->parent()->render_target(); + clip_rect_for_subtree = rect_in_target_space; } - - if (adjustTextAA) - layerDrawProperties.can_use_lcd_text = layerCanUseLCDText; - - gfx::Rect rectInTargetSpace = ToEnclosingRect(MathUtil::MapClippedRect(layer->draw_transform(), contentRect)); - - if (layerClipsSubtree(layer)) { - subtreeShouldBeClipped = true; - if (ancestorClipsSubtree && !layer->render_surface()) { - clipRectForSubtree = clipRectFromAncestor; - clipRectForSubtree.Intersect(rectInTargetSpace); - } else - clipRectForSubtree = rectInTargetSpace; + } + + // Flatten to 2D if the layer doesn't preserve 3D. + if (!layer->preserves_3d()) + sublayer_matrix.FlattenTo2d(); + + // Apply the sublayer transform at the anchor point of the layer. + if (!layer->sublayer_transform().IsIdentity()) { + sublayer_matrix.Translate(layer->anchor_point().x() * bounds.width(), + layer->anchor_point().y() * bounds.height()); + sublayer_matrix.PreconcatTransform(layer->sublayer_transform()); + sublayer_matrix.Translate(-layer->anchor_point().x() * bounds.width(), + -layer->anchor_point().y() * bounds.height()); + } + + LayerList& descendants = + (layer->render_surface() ? layer->render_surface()->layer_list() + : *layer_list); + + // Any layers that are appended after this point are in the layer's subtree + // and should be included in the sorting process. + size_t sorting_start_index = descendants.size(); + + if (!LayerShouldBeSkipped(layer)) + descendants.push_back(layer); + + gfx::Transform next_scroll_compensation_matrix = + ComputeScrollCompensationMatrixForChildren( + layer, parent_matrix, current_scroll_compensation_matrix); + + gfx::Rect accumulated_drawable_content_rect_of_children; + for (size_t i = 0; i < layer->children().size(); ++i) { + LayerType* child = + LayerTreeHostCommon::get_child_as_raw_ptr(layer->children(), i); + gfx::Rect drawable_content_rect_of_child_subtree; + CalculateDrawPropertiesInternal<LayerType, LayerList, RenderSurfaceType>( + child, + sublayer_matrix, + next_hierarchy_matrix, + next_scroll_compensation_matrix, + clip_rect_for_subtree, + clip_rect_for_subtree_in_descendant_space, + subtree_should_be_clipped, + nearest_ancestor_that_moves_pixels, + render_surface_layer_list, + &descendants, + layer_sorter, + max_texture_size, + device_scale_factor, + page_scale_factor, + subtree_can_use_lcd_text, + &drawable_content_rect_of_child_subtree, + update_tile_priorities); + if (!drawable_content_rect_of_child_subtree.IsEmpty()) { + accumulated_drawable_content_rect_of_children.Union( + drawable_content_rect_of_child_subtree); + if (child->render_surface()) + descendants.push_back(child); } - - // Flatten to 2D if the layer doesn't preserve 3D. - if (!layer->preserves_3d()) - sublayerMatrix.FlattenTo2d(); - - // Apply the sublayer transform at the anchor point of the layer. - if (!layer->sublayer_transform().IsIdentity()) { - sublayerMatrix.Translate(layer->anchor_point().x() * bounds.width(), layer->anchor_point().y() * bounds.height()); - sublayerMatrix.PreconcatTransform(layer->sublayer_transform()); - sublayerMatrix.Translate(-layer->anchor_point().x() * bounds.width(), -layer->anchor_point().y() * bounds.height()); + } + + if (layer->render_surface() && !IsRootLayer(layer) && + layer->render_surface()->layer_list().empty()) { + RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); + return; + } + + // Compute the total drawableContentRect for this subtree (the rect is in + // targetSurface space). + gfx::Rect local_drawable_content_rect_of_subtree = + accumulated_drawable_content_rect_of_children; + if (layer->DrawsContent()) + local_drawable_content_rect_of_subtree.Union(rect_in_target_space); + if (subtree_should_be_clipped) + local_drawable_content_rect_of_subtree.Intersect(clip_rect_for_subtree); + + // Compute the layer's drawable content rect (the rect is in targetSurface + // space). + layer_draw_properties.drawable_content_rect = rect_in_target_space; + if (subtree_should_be_clipped) { + layer_draw_properties.drawable_content_rect. + Intersect(clip_rect_for_subtree); + } + + // Tell the layer the rect that is clipped by. In theory we could use a + // tighter clipRect here (drawableContentRect), but that actually does not + // reduce how much would be drawn, and instead it would create unnecessary + // changes to scissor state affecting GPU performance. + layer_draw_properties.is_clipped = subtree_should_be_clipped; + if (subtree_should_be_clipped) { + layer_draw_properties.clip_rect = clip_rect_for_subtree; + } else { + // Initialize the clipRect to a safe value that will not clip the + // layer, just in case clipping is still accidentally used. + layer_draw_properties.clip_rect = rect_in_target_space; + } + + // Compute the layer's visible content rect (the rect is in content space) + layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( + layer, clip_rect_for_subtree_in_descendant_space, rect_in_target_space); + + // Compute the remaining properties for the render surface, if the layer has + // one. + if (IsRootLayer(layer)) { + // The root layer's surface's content_rect is always the entire viewport. + DCHECK(layer->render_surface()); + layer->render_surface()->SetContentRect(clip_rect_from_ancestor); + } else if (layer->render_surface() && !IsRootLayer(layer)) { + RenderSurfaceType* render_surface = layer->render_surface(); + gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree; + + // Don't clip if the layer is reflected as the reflection shouldn't be + // clipped. If the layer is animating, then the surface's transform to + // its target is not known on the main thread, and we should not use it + // to clip. + if (!layer->replica_layer() && TransformToParentIsKnown(layer)) { + // Note, it is correct to use ancestor_clips_subtree here, because we are + // looking at this layer's render_surface, not the layer itself. + if (ancestor_clips_subtree && !clipped_content_rect.IsEmpty()) { + gfx::Rect surface_clip_rect = LayerTreeHostCommon::CalculateVisibleRect( + render_surface->clip_rect(), + clipped_content_rect, + render_surface->draw_transform()); + clipped_content_rect.Intersect(surface_clip_rect); + } } - LayerList& descendants = (layer->render_surface() ? layer->render_surface()->layer_list() : layerList); - - // Any layers that are appended after this point are in the layer's subtree and should be included in the sorting process. - unsigned sortingStartIndex = descendants.size(); - - if (!layerShouldBeSkipped(layer)) - descendants.push_back(layer); - - gfx::Transform nextScrollCompensationMatrix = computeScrollCompensationMatrixForChildren(layer, parentMatrix, currentScrollCompensationMatrix);; - - gfx::Rect accumulatedDrawableContentRectOfChildren; - for (size_t i = 0; i < layer->children().size(); ++i) { - LayerType* child = LayerTreeHostCommon::getChildAsRawPtr(layer->children(), i); - gfx::Rect drawableContentRectOfChildSubtree; - calculateDrawPropertiesInternal<LayerType, LayerList, RenderSurfaceType>(child, sublayerMatrix, nextHierarchyMatrix, nextScrollCompensationMatrix, - clipRectForSubtree, clipRectForSubtreeInDescendantSpace, subtreeShouldBeClipped, nearestAncestorThatMovesPixels, - renderSurfaceLayerList, descendants, layerSorter, maxTextureSize, deviceScaleFactor, pageScaleFactor, - subtreeCanUseLCDText, drawableContentRectOfChildSubtree, updateTilePriorities); - if (!drawableContentRectOfChildSubtree.IsEmpty()) { - accumulatedDrawableContentRectOfChildren.Union(drawableContentRectOfChildSubtree); - if (child->render_surface()) - descendants.push_back(child); - } + // The RenderSurfaceImpl backing texture cannot exceed the maximum supported + // texture size. + clipped_content_rect.set_width( + std::min(clipped_content_rect.width(), max_texture_size)); + clipped_content_rect.set_height( + std::min(clipped_content_rect.height(), max_texture_size)); + + if (clipped_content_rect.IsEmpty()) { + render_surface->ClearLayerLists(); + RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); + return; } - if (layer->render_surface() && !isRootLayer(layer) && !layer->render_surface()->layer_list().size()) { - removeSurfaceForEarlyExit(layer, renderSurfaceLayerList); - return; + render_surface->SetContentRect(clipped_content_rect); + + // The owning layer's screen_space_transform has a scale from content to + // layer space which we need to undo and replace with a scale from the + // surface's subtree into layer space. + gfx::Transform screen_space_transform = layer->screen_space_transform(); + screen_space_transform.Scale( + layer->contents_scale_x() / render_surface_sublayer_scale.x(), + layer->contents_scale_y() / render_surface_sublayer_scale.y()); + render_surface->SetScreenSpaceTransform(screen_space_transform); + + if (layer->replica_layer()) { + gfx::Transform surface_origin_to_replica_origin_transform; + surface_origin_to_replica_origin_transform.Scale( + render_surface_sublayer_scale.x(), render_surface_sublayer_scale.y()); + surface_origin_to_replica_origin_transform.Translate( + layer->replica_layer()->position().x() + + layer->replica_layer()->anchor_point().x() * bounds.width(), + layer->replica_layer()->position().y() + + layer->replica_layer()->anchor_point().y() * bounds.height()); + surface_origin_to_replica_origin_transform.PreconcatTransform( + layer->replica_layer()->transform()); + surface_origin_to_replica_origin_transform.Translate( + -layer->replica_layer()->anchor_point().x() * bounds.width(), + -layer->replica_layer()->anchor_point().y() * bounds.height()); + surface_origin_to_replica_origin_transform.Scale( + 1.0 / render_surface_sublayer_scale.x(), + 1.0 / render_surface_sublayer_scale.y()); + + // Compute the replica's "originTransform" that maps from the replica's + // origin space to the target surface origin space. + gfx::Transform replica_origin_transform = + layer->render_surface()->draw_transform() * + surface_origin_to_replica_origin_transform; + render_surface->SetReplicaDrawTransform(replica_origin_transform); + + // Compute the replica's "screen_space_transform" that maps from the + // replica's origin space to the screen's origin space. + gfx::Transform replica_screen_space_transform = + layer->render_surface()->screen_space_transform() * + surface_origin_to_replica_origin_transform; + render_surface->SetReplicaScreenSpaceTransform( + replica_screen_space_transform); } - - // Compute the total drawableContentRect for this subtree (the rect is in targetSurface space) - gfx::Rect localDrawableContentRectOfSubtree = accumulatedDrawableContentRectOfChildren; - if (layer->DrawsContent()) - localDrawableContentRectOfSubtree.Union(rectInTargetSpace); - if (subtreeShouldBeClipped) - localDrawableContentRectOfSubtree.Intersect(clipRectForSubtree); - - // Compute the layer's drawable content rect (the rect is in targetSurface space) - layerDrawProperties.drawable_content_rect = rectInTargetSpace; - if (subtreeShouldBeClipped) - layerDrawProperties.drawable_content_rect.Intersect(clipRectForSubtree); - - // Tell the layer the rect that is clipped by. In theory we could use a - // tighter clipRect here (drawableContentRect), but that actually does not - // reduce how much would be drawn, and instead it would create unnecessary - // changes to scissor state affecting GPU performance. - layerDrawProperties.is_clipped = subtreeShouldBeClipped; - if (subtreeShouldBeClipped) - layerDrawProperties.clip_rect = clipRectForSubtree; - else { - // Initialize the clipRect to a safe value that will not clip the - // layer, just in case clipping is still accidentally used. - layerDrawProperties.clip_rect = rectInTargetSpace; - } - - // Compute the layer's visible content rect (the rect is in content space) - layerDrawProperties.visible_content_rect = calculateVisibleContentRect(layer, clipRectForSubtreeInDescendantSpace, rectInTargetSpace); - - // Compute the remaining properties for the render surface, if the layer has one. - if (isRootLayer(layer)) { - // The root layer's surface's contentRect is always the entire viewport. - DCHECK(layer->render_surface()); - layer->render_surface()->SetContentRect(clipRectFromAncestor); - } else if (layer->render_surface() && !isRootLayer(layer)) { - RenderSurfaceType* renderSurface = layer->render_surface(); - gfx::Rect clippedContentRect = localDrawableContentRectOfSubtree; - - // Don't clip if the layer is reflected as the reflection shouldn't be - // clipped. If the layer is animating, then the surface's transform to - // its target is not known on the main thread, and we should not use it - // to clip. - if (!layer->replica_layer() && transformToParentIsKnown(layer)) { - // Note, it is correct to use ancestorClipsSubtree here, because we are looking at this layer's renderSurface, not the layer itself. - if (ancestorClipsSubtree && !clippedContentRect.IsEmpty()) { - gfx::Rect surfaceClipRect = LayerTreeHostCommon::calculateVisibleRect(renderSurface->clip_rect(), clippedContentRect, renderSurface->draw_transform()); - clippedContentRect.Intersect(surfaceClipRect); - } - } - - // The RenderSurfaceImpl backing texture cannot exceed the maximum supported - // texture size. - clippedContentRect.set_width(std::min(clippedContentRect.width(), maxTextureSize)); - clippedContentRect.set_height(std::min(clippedContentRect.height(), maxTextureSize)); - - if (clippedContentRect.IsEmpty()) { - renderSurface->ClearLayerLists(); - removeSurfaceForEarlyExit(layer, renderSurfaceLayerList); - return; - } - - renderSurface->SetContentRect(clippedContentRect); - - // The owning layer's screenSpaceTransform has a scale from content to layer space which we need to undo and - // replace with a scale from the surface's subtree into layer space. - gfx::Transform screenSpaceTransform = layer->screen_space_transform(); - screenSpaceTransform.Scale(layer->contents_scale_x() / renderSurfaceSublayerScale.x(), layer->contents_scale_y() / renderSurfaceSublayerScale.y()); - renderSurface->SetScreenSpaceTransform(screenSpaceTransform); - - if (layer->replica_layer()) { - gfx::Transform surfaceOriginToReplicaOriginTransform; - surfaceOriginToReplicaOriginTransform.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y()); - surfaceOriginToReplicaOriginTransform.Translate(layer->replica_layer()->position().x() + layer->replica_layer()->anchor_point().x() * bounds.width(), - layer->replica_layer()->position().y() + layer->replica_layer()->anchor_point().y() * bounds.height()); - surfaceOriginToReplicaOriginTransform.PreconcatTransform(layer->replica_layer()->transform()); - surfaceOriginToReplicaOriginTransform.Translate(-layer->replica_layer()->anchor_point().x() * bounds.width(), -layer->replica_layer()->anchor_point().y() * bounds.height()); - surfaceOriginToReplicaOriginTransform.Scale(1 / renderSurfaceSublayerScale.x(), 1 / renderSurfaceSublayerScale.y()); - - // Compute the replica's "originTransform" that maps from the replica's origin space to the target surface origin space. - gfx::Transform replicaOriginTransform = layer->render_surface()->draw_transform() * surfaceOriginToReplicaOriginTransform; - renderSurface->SetReplicaDrawTransform(replicaOriginTransform); - - // Compute the replica's "screenSpaceTransform" that maps from the replica's origin space to the screen's origin space. - gfx::Transform replicaScreenSpaceTransform = layer->render_surface()->screen_space_transform() * surfaceOriginToReplicaOriginTransform; - renderSurface->SetReplicaScreenSpaceTransform(replicaScreenSpaceTransform); - } - } - - if (updateTilePriorities) - updateTilePrioritiesForLayer(layer); - - // If neither this layer nor any of its children were added, early out. - if (sortingStartIndex == descendants.size()) - return; - - // If preserves-3d then sort all the descendants in 3D so that they can be - // drawn from back to front. If the preserves-3d property is also set on the parent then - // skip the sorting as the parent will sort all the descendants anyway. - if (layerSorter && descendants.size() && layer->preserves_3d() && (!layer->parent() || !layer->parent()->preserves_3d())) - sortLayers(descendants.begin() + sortingStartIndex, descendants.end(), layerSorter); - - if (layer->render_surface()) - drawableContentRectOfSubtree = gfx::ToEnclosingRect(layer->render_surface()->DrawableContentRect()); - else - drawableContentRectOfSubtree = localDrawableContentRectOfSubtree; - - if (layer->HasContributingDelegatedRenderPasses()) - layer->render_target()->render_surface()->AddContributingDelegatedRenderPassLayer(layer); + } + + if (update_tile_priorities) + UpdateTilePrioritiesForLayer(layer); + + // If neither this layer nor any of its children were added, early out. + if (sorting_start_index == descendants.size()) + return; + + // If preserves-3d then sort all the descendants in 3D so that they can be + // drawn from back to front. If the preserves-3d property is also set on the + // parent then skip the sorting as the parent will sort all the descendants + // anyway. + if (layer_sorter && descendants.size() && layer->preserves_3d() && + (!layer->parent() || !layer->parent()->preserves_3d())) { + SortLayers(descendants.begin() + sorting_start_index, + descendants.end(), + layer_sorter); + } + + if (layer->render_surface()) { + *drawable_content_rect_of_subtree = + gfx::ToEnclosingRect(layer->render_surface()->DrawableContentRect()); + } else { + *drawable_content_rect_of_subtree = local_drawable_content_rect_of_subtree; + } + + if (layer->HasContributingDelegatedRenderPasses()) { + layer->render_target()->render_surface()-> + AddContributingDelegatedRenderPassLayer(layer); + } } -void LayerTreeHostCommon::calculateDrawProperties(Layer* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, bool canUseLCDText, std::vector<scoped_refptr<Layer> >& renderSurfaceLayerList) -{ - gfx::Rect totalDrawableContentRect; - gfx::Transform identityMatrix; - gfx::Transform deviceScaleTransform; - deviceScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor); - std::vector<scoped_refptr<Layer> > dummyLayerList; - - // The root layer's renderSurface should receive the deviceViewport as the initial clipRect. - bool subtreeShouldBeClipped = true; - gfx::Rect deviceViewportRect(gfx::Point(), deviceViewportSize); - bool updateTilePriorities = false; - - // This function should have received a root layer. - DCHECK(isRootLayer(rootLayer)); - - preCalculateMetaInformation<Layer>(rootLayer); - calculateDrawPropertiesInternal<Layer, std::vector<scoped_refptr<Layer> >, RenderSurface>( - rootLayer, deviceScaleTransform, identityMatrix, identityMatrix, - deviceViewportRect, deviceViewportRect, subtreeShouldBeClipped, 0, renderSurfaceLayerList, - dummyLayerList, 0, maxTextureSize, - deviceScaleFactor, pageScaleFactor, canUseLCDText, totalDrawableContentRect, - updateTilePriorities); - - // The dummy layer list should not have been used. - DCHECK(dummyLayerList.size() == 0); - // A root layer renderSurface should always exist after calculateDrawProperties. - DCHECK(rootLayer->render_surface()); +void LayerTreeHostCommon::CalculateDrawProperties( + Layer* root_layer, + gfx::Size device_viewport_size, + float device_scale_factor, + float page_scale_factor, + int max_texture_size, + bool can_use_lcd_text, + std::vector<scoped_refptr<Layer> >* render_surface_layer_list) { + gfx::Rect total_drawable_content_rect; + gfx::Transform identity_matrix; + gfx::Transform device_scale_transform; + device_scale_transform.Scale(device_scale_factor, device_scale_factor); + std::vector<scoped_refptr<Layer> > dummy_layer_list; + + // The root layer's render_surface should receive the deviceViewport as the + // initial clipRect. + bool subtree_should_be_clipped = true; + gfx::Rect device_viewport_rect(gfx::Point(), device_viewport_size); + bool update_tile_priorities = false; + + // This function should have received a root layer. + DCHECK(IsRootLayer(root_layer)); + + PreCalculateMetaInformation<Layer>(root_layer); + CalculateDrawPropertiesInternal<Layer, + std::vector<scoped_refptr<Layer> >, + RenderSurface>(root_layer, + device_scale_transform, + identity_matrix, + identity_matrix, + device_viewport_rect, + device_viewport_rect, + subtree_should_be_clipped, + NULL, + render_surface_layer_list, + &dummy_layer_list, + NULL, + max_texture_size, + device_scale_factor, + page_scale_factor, + can_use_lcd_text, + &total_drawable_content_rect, + update_tile_priorities); + + // The dummy layer list should not have been used. + DCHECK_EQ(dummy_layer_list.size(), 0); + // A root layer render_surface should always exist after + // calculateDrawProperties. + DCHECK(root_layer->render_surface()); } -void LayerTreeHostCommon::calculateDrawProperties(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, bool canUseLCDText, std::vector<LayerImpl*>& renderSurfaceLayerList, bool updateTilePriorities) -{ - gfx::Rect totalDrawableContentRect; - gfx::Transform identityMatrix; - gfx::Transform deviceScaleTransform; - deviceScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor); - std::vector<LayerImpl*> dummyLayerList; - LayerSorter layerSorter; - - // The root layer's renderSurface should receive the deviceViewport as the initial clipRect. - bool subtreeShouldBeClipped = true; - gfx::Rect deviceViewportRect(gfx::Point(), deviceViewportSize); - - // This function should have received a root layer. - DCHECK(isRootLayer(rootLayer)); - - preCalculateMetaInformation<LayerImpl>(rootLayer); - calculateDrawPropertiesInternal<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl>( - rootLayer, deviceScaleTransform, identityMatrix, identityMatrix, - deviceViewportRect, deviceViewportRect, subtreeShouldBeClipped, 0, renderSurfaceLayerList, - dummyLayerList, &layerSorter, maxTextureSize, - deviceScaleFactor, pageScaleFactor, canUseLCDText, totalDrawableContentRect, - updateTilePriorities); - - // The dummy layer list should not have been used. - DCHECK(dummyLayerList.size() == 0); - // A root layer renderSurface should always exist after calculateDrawProperties. - DCHECK(rootLayer->render_surface()); +void LayerTreeHostCommon::CalculateDrawProperties( + LayerImpl* root_layer, + gfx::Size device_viewport_size, + float device_scale_factor, + float page_scale_factor, + int max_texture_size, + bool can_use_lcd_text, + std::vector<LayerImpl*>* render_surface_layer_list, + bool update_tile_priorities) { + gfx::Rect total_drawable_content_rect; + gfx::Transform identity_matrix; + gfx::Transform device_scale_transform; + device_scale_transform.Scale(device_scale_factor, device_scale_factor); + std::vector<LayerImpl*> dummy_layer_list; + LayerSorter layer_sorter; + + // The root layer's render_surface should receive the deviceViewport as the + // initial clipRect. + bool subtree_should_be_clipped = true; + gfx::Rect device_viewport_rect(gfx::Point(), device_viewport_size); + + // This function should have received a root layer. + DCHECK(IsRootLayer(root_layer)); + + PreCalculateMetaInformation<LayerImpl>(root_layer); + CalculateDrawPropertiesInternal<LayerImpl, + std::vector<LayerImpl*>, + RenderSurfaceImpl>( + root_layer, + device_scale_transform, + identity_matrix, + identity_matrix, + device_viewport_rect, + device_viewport_rect, + subtree_should_be_clipped, + NULL, + render_surface_layer_list, + &dummy_layer_list, + &layer_sorter, + max_texture_size, + device_scale_factor, + page_scale_factor, + can_use_lcd_text, + &total_drawable_content_rect, + update_tile_priorities); + + // The dummy layer list should not have been used. + DCHECK_EQ(dummy_layer_list.size(), 0); + // A root layer render_surface should always exist after + // calculateDrawProperties. + DCHECK(root_layer->render_surface()); } -static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const gfx::Transform& localSpaceToScreenSpaceTransform, gfx::RectF localSpaceRect) -{ - // If the transform is not invertible, then assume that this point doesn't hit this rect. - gfx::Transform inverseLocalSpaceToScreenSpace(gfx::Transform::kSkipInitialization); - if (!localSpaceToScreenSpaceTransform.GetInverse(&inverseLocalSpaceToScreenSpace)) - return false; +static bool PointHitsRect( + gfx::PointF screen_space_point, + const gfx::Transform& local_space_to_screen_space_transform, + gfx::RectF local_space_rect) { + // If the transform is not invertible, then assume that this point doesn't hit + // this rect. + gfx::Transform inverse_local_space_to_screen_space( + gfx::Transform::kSkipInitialization); + if (!local_space_to_screen_space_transform.GetInverse( + &inverse_local_space_to_screen_space)) + return false; - // Transform the hit test point from screen space to the local space of the given rect. - bool clipped = false; - gfx::PointF hitTestPointInLocalSpace = MathUtil::ProjectPoint(inverseLocalSpaceToScreenSpace, screenSpacePoint, &clipped); + // Transform the hit test point from screen space to the local space of the + // given rect. + bool clipped = false; + gfx::PointF hit_test_point_in_local_space = MathUtil::ProjectPoint( + inverse_local_space_to_screen_space, screen_space_point, &clipped); - // If projectPoint could not project to a valid value, then we assume that this point doesn't hit this rect. - if (clipped) - return false; + // If ProjectPoint could not project to a valid value, then we assume that + // this point doesn't hit this rect. + if (clipped) + return false; - return localSpaceRect.Contains(hitTestPointInLocalSpace); + return local_space_rect.Contains(hit_test_point_in_local_space); } -static bool pointHitsRegion(gfx::PointF screenSpacePoint, const gfx::Transform& screenSpaceTransform, const Region& layerSpaceRegion, float layerContentScaleX, float layerContentScaleY) -{ - // If the transform is not invertible, then assume that this point doesn't hit this region. - gfx::Transform inverseScreenSpaceTransform(gfx::Transform::kSkipInitialization); - if (!screenSpaceTransform.GetInverse(&inverseScreenSpaceTransform)) - return false; - - // Transform the hit test point from screen space to the local space of the given region. - bool clipped = false; - gfx::PointF hitTestPointInContentSpace = MathUtil::ProjectPoint(inverseScreenSpaceTransform, screenSpacePoint, &clipped); - gfx::PointF hitTestPointInLayerSpace = gfx::ScalePoint(hitTestPointInContentSpace, 1 / layerContentScaleX, 1 / layerContentScaleY); +static bool PointHitsRegion(gfx::PointF screen_space_point, + const gfx::Transform& screen_space_transform, + const Region& layer_space_region, + float layer_content_scale_x, + float layer_content_scale_y) { + // If the transform is not invertible, then assume that this point doesn't hit + // this region. + gfx::Transform inverse_screen_space_transform( + gfx::Transform::kSkipInitialization); + if (!screen_space_transform.GetInverse(&inverse_screen_space_transform)) + return false; - // If projectPoint could not project to a valid value, then we assume that this point doesn't hit this region. - if (clipped) - return false; + // Transform the hit test point from screen space to the local space of the + // given region. + bool clipped = false; + gfx::PointF hit_test_point_in_content_space = MathUtil::ProjectPoint( + inverse_screen_space_transform, screen_space_point, &clipped); + gfx::PointF hit_test_point_in_layer_space = + gfx::ScalePoint(hit_test_point_in_content_space, + 1.f / layer_content_scale_x, + 1.f / layer_content_scale_y); + + // If ProjectPoint could not project to a valid value, then we assume that + // this point doesn't hit this region. + if (clipped) + return false; - return layerSpaceRegion.Contains(gfx::ToRoundedPoint(hitTestPointInLayerSpace)); + return layer_space_region.Contains( + gfx::ToRoundedPoint(hit_test_point_in_layer_space)); } -static bool pointIsClippedBySurfaceOrClipRect(const gfx::PointF& screenSpacePoint, LayerImpl* layer) -{ - LayerImpl* current_layer = layer; - - // Walk up the layer tree and hit-test any renderSurfaces and any layer clipRects that are active. - while (current_layer) { - if (current_layer->render_surface() && !pointHitsRect(screenSpacePoint, current_layer->render_surface()->screen_space_transform(), current_layer->render_surface()->content_rect())) - return true; - - // Note that drawableContentRects are actually in targetSurface space, so the transform we - // have to provide is the target surface's screenSpaceTransform. - LayerImpl* renderTarget = current_layer->render_target(); - if (layerClipsSubtree(current_layer) && !pointHitsRect(screenSpacePoint, renderTarget->render_surface()->screen_space_transform(), current_layer->drawable_content_rect())) - return true; - - current_layer = current_layer->parent(); - } - - // If we have finished walking all ancestors without having already exited, then the point is not clipped by any ancestors. - return false; +static bool PointIsClippedBySurfaceOrClipRect(gfx::PointF screen_space_point, + LayerImpl* layer) { + LayerImpl* current_layer = layer; + + // Walk up the layer tree and hit-test any render_surfaces and any layer + // clip rects that are active. + while (current_layer) { + if (current_layer->render_surface() && + !PointHitsRect( + screen_space_point, + current_layer->render_surface()->screen_space_transform(), + current_layer->render_surface()->content_rect())) + return true; + + // Note that drawable content rects are actually in target surface space, so + // the transform we have to provide is the target surface's + // screen_space_transform. + LayerImpl* render_target = current_layer->render_target(); + if (LayerClipsSubtree(current_layer) && + !PointHitsRect( + screen_space_point, + render_target->render_surface()->screen_space_transform(), + current_layer->drawable_content_rect())) + return true; + + current_layer = current_layer->parent(); + } + + // If we have finished walking all ancestors without having already exited, + // then the point is not clipped by any ancestors. + return false; } -LayerImpl* LayerTreeHostCommon::findLayerThatIsHitByPoint(const gfx::PointF& screenSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList) -{ - LayerImpl* foundLayer = 0; - - typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType; - LayerIteratorType end = LayerIteratorType::End(&renderSurfaceLayerList); - - for (LayerIteratorType it = LayerIteratorType::Begin(&renderSurfaceLayerList); it != end; ++it) { - // We don't want to consider renderSurfaces for hit testing. - if (!it.represents_itself()) - continue; - - LayerImpl* current_layer = (*it); - - gfx::RectF contentRect(gfx::PointF(), current_layer->content_bounds()); - if (!pointHitsRect(screenSpacePoint, current_layer->screen_space_transform(), contentRect)) - continue; - - // At this point, we think the point does hit the layer, but we need to walk up - // the parents to ensure that the layer was not clipped in such a way that the - // hit point actually should not hit the layer. - if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, current_layer)) - continue; - - // Skip the HUD layer. - if (current_layer == current_layer->layer_tree_impl()->hud_layer()) - continue; - - foundLayer = current_layer; - break; - } - - // This can potentially return 0, which means the screenSpacePoint did not successfully hit test any layers, not even the root layer. - return foundLayer; +LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPoint( + gfx::PointF screen_space_point, + const std::vector<LayerImpl*>& render_surface_layer_list) { + LayerImpl* found_layer = NULL; + + typedef LayerIterator<LayerImpl, + std::vector<LayerImpl*>, + RenderSurfaceImpl, + LayerIteratorActions::FrontToBack> LayerIteratorType; + LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); + + for (LayerIteratorType + it = LayerIteratorType::Begin(&render_surface_layer_list); + it != end; + ++it) { + // We don't want to consider render_surfaces for hit testing. + if (!it.represents_itself()) + continue; + + LayerImpl* current_layer = (*it); + + gfx::RectF content_rect(gfx::PointF(), current_layer->content_bounds()); + if (!PointHitsRect(screen_space_point, + current_layer->screen_space_transform(), + content_rect)) + continue; + + // At this point, we think the point does hit the layer, but we need to walk + // up the parents to ensure that the layer was not clipped in such a way + // that the hit point actually should not hit the layer. + if (PointIsClippedBySurfaceOrClipRect(screen_space_point, current_layer)) + continue; + + // Skip the HUD layer. + if (current_layer == current_layer->layer_tree_impl()->hud_layer()) + continue; + + found_layer = current_layer; + break; + } + + // This can potentially return NULL, which means the screen_space_point did + // not successfully hit test any layers, not even the root layer. + return found_layer; } -LayerImpl* LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(const gfx::PointF& screenSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList) -{ - LayerImpl* foundLayer = 0; - - typedef LayerIterator<LayerImpl, std::vector<LayerImpl*>, RenderSurfaceImpl, LayerIteratorActions::FrontToBack> LayerIteratorType; - LayerIteratorType end = LayerIteratorType::End(&renderSurfaceLayerList); - - for (LayerIteratorType it = LayerIteratorType::Begin(&renderSurfaceLayerList); it != end; ++it) { - // We don't want to consider renderSurfaces for hit testing. - if (!it.represents_itself()) - continue; - - LayerImpl* current_layer = (*it); - - if (!layerHasTouchEventHandlersAt(screenSpacePoint, current_layer)) - continue; - - foundLayer = current_layer; - break; - } - - // This can potentially return 0, which means the screenSpacePoint did not successfully hit test any layers, not even the root layer. - return foundLayer; +LayerImpl* LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( + gfx::PointF screen_space_point, + const std::vector<LayerImpl*>& render_surface_layer_list) { + LayerImpl* found_layer = NULL; + + typedef LayerIterator<LayerImpl, + std::vector<LayerImpl*>, + RenderSurfaceImpl, + LayerIteratorActions::FrontToBack> LayerIteratorType; + LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); + + for (LayerIteratorType + it = LayerIteratorType::Begin(&render_surface_layer_list); + it != end; + ++it) { + // We don't want to consider render_surfaces for hit testing. + if (!it.represents_itself()) + continue; + + LayerImpl* current_layer = (*it); + + if (!LayerHasTouchEventHandlersAt(screen_space_point, current_layer)) + continue; + + found_layer = current_layer; + break; + } + + // This can potentially return NULL, which means the screen_space_point did + // not successfully hit test any layers, not even the root layer. + return found_layer; } -bool LayerTreeHostCommon::layerHasTouchEventHandlersAt(const gfx::PointF& screenSpacePoint, LayerImpl* layerImpl) { - if (layerImpl->touch_event_handler_region().IsEmpty()) - return false; +bool LayerTreeHostCommon::LayerHasTouchEventHandlersAt( + gfx::PointF screen_space_point, + LayerImpl* layer_impl) { + if (layer_impl->touch_event_handler_region().IsEmpty()) + return false; - if (!pointHitsRegion(screenSpacePoint, layerImpl->screen_space_transform(), layerImpl->touch_event_handler_region(), layerImpl->contents_scale_x(), layerImpl->contents_scale_y())) - return false;; + if (!PointHitsRegion(screen_space_point, + layer_impl->screen_space_transform(), + layer_impl->touch_event_handler_region(), + layer_impl->contents_scale_x(), + layer_impl->contents_scale_y())) + return false; - // At this point, we think the point does hit the touch event handler region on the layer, but we need to walk up - // the parents to ensure that the layer was not clipped in such a way that the - // hit point actually should not hit the layer. - if (pointIsClippedBySurfaceOrClipRect(screenSpacePoint, layerImpl)) - return false; + // At this point, we think the point does hit the touch event handler region + // on the layer, but we need to walk up the parents to ensure that the layer + // was not clipped in such a way that the hit point actually should not hit + // the layer. + if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) + return false; return true; } diff --git a/cc/trees/layer_tree_host_common.h b/cc/trees/layer_tree_host_common.h index 1e33c65..7644c91 100644 --- a/cc/trees/layer_tree_host_common.h +++ b/cc/trees/layer_tree_host_common.h @@ -18,99 +18,131 @@ class LayerImpl; class Layer; class CC_EXPORT LayerTreeHostCommon { -public: - static gfx::Rect calculateVisibleRect(const gfx::Rect& targetSurfaceRect, const gfx::Rect& layerBoundRect, const gfx::Transform&); - - static void calculateDrawProperties(Layer* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, bool canUseLCDText, std::vector<scoped_refptr<Layer> >& renderSurfaceLayerList); - static void calculateDrawProperties(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, bool canUseLCDText, std::vector<LayerImpl*>& renderSurfaceLayerList, bool updateTilePriorities); - - // Performs hit testing for a given renderSurfaceLayerList. - static LayerImpl* findLayerThatIsHitByPoint(const gfx::PointF& screenSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList); - - static LayerImpl* findLayerThatIsHitByPointInTouchHandlerRegion(const gfx::PointF& screenSpacePoint, const std::vector<LayerImpl*>& renderSurfaceLayerList); - - static bool layerHasTouchEventHandlersAt(const gfx::PointF& screenSpacePoint, LayerImpl* layerImpl); - - template<typename LayerType> static bool renderSurfaceContributesToTarget(LayerType*, int targetSurfaceLayerID); - - template<class Function, typename LayerType> static void callFunctionForSubtree(LayerType* rootLayer); - - // Returns a layer with the given id if one exists in the subtree starting - // from the given root layer (including mask and replica layers). - template<typename LayerType> static LayerType* findLayerInSubtree(LayerType* rootLayer, int layerId); - - static Layer* getChildAsRawPtr(const std::vector<scoped_refptr<Layer> >& children, size_t index) - { - return children[index].get(); - } - - static LayerImpl* getChildAsRawPtr(const ScopedPtrVector<LayerImpl>& children, size_t index) - { - return children[index]; - } - - struct ScrollUpdateInfo { - int layerId; - gfx::Vector2d scrollDelta; - }; + public: + static gfx::Rect CalculateVisibleRect(gfx::Rect target_surface_rect, + gfx::Rect layer_bound_rect, + const gfx::Transform& transform); + + static void CalculateDrawProperties( + Layer* root_layer, + gfx::Size device_viewport_size, + float device_scale_factor, + float page_scale_factor, + int max_texture_size, + bool can_use_lcd_text, + std::vector<scoped_refptr<Layer> >* render_surface_layer_list); + static void CalculateDrawProperties( + LayerImpl* root_layer, + gfx::Size device_viewport_size, + float device_scale_factor, + float page_scale_factor, + int max_texture_size, + bool can_use_lcd_text, + std::vector<LayerImpl*>* render_surface_layer_list, + bool update_tile_priorities); + + // Performs hit testing for a given render_surface_layer_list. + static LayerImpl* FindLayerThatIsHitByPoint( + gfx::PointF screen_space_point, + const std::vector<LayerImpl*>& render_surface_layer_list); + + static LayerImpl* FindLayerThatIsHitByPointInTouchHandlerRegion( + gfx::PointF screen_space_point, + const std::vector<LayerImpl*>& render_surface_layer_list); + + static bool LayerHasTouchEventHandlersAt(gfx::PointF screen_space_point, + LayerImpl* layer_impl); + + template <typename LayerType> + static bool RenderSurfaceContributesToTarget(LayerType*, + int target_surface_layer_id); + + template <class Function, typename LayerType> + static void CallFunctionForSubtree(LayerType* root_layer); + + // Returns a layer with the given id if one exists in the subtree starting + // from the given root layer (including mask and replica layers). + template <typename LayerType> + static LayerType* FindLayerInSubtree(LayerType* root_layer, int layer_id); + + static Layer* get_child_as_raw_ptr( + const std::vector<scoped_refptr<Layer> >& children, + size_t index) { + return children[index].get(); + } + + static LayerImpl* get_child_as_raw_ptr( + const ScopedPtrVector<LayerImpl>& children, + size_t index) { + return children[index]; + } + + struct ScrollUpdateInfo { + int layer_id; + gfx::Vector2d scroll_delta; + }; }; struct CC_EXPORT ScrollAndScaleSet { - ScrollAndScaleSet(); - ~ScrollAndScaleSet(); + ScrollAndScaleSet(); + ~ScrollAndScaleSet(); - std::vector<LayerTreeHostCommon::ScrollUpdateInfo> scrolls; - float pageScaleDelta; + std::vector<LayerTreeHostCommon::ScrollUpdateInfo> scrolls; + float page_scale_delta; }; -template<typename LayerType> -bool LayerTreeHostCommon::renderSurfaceContributesToTarget(LayerType* layer, int targetSurfaceLayerID) -{ - // A layer will either contribute its own content, or its render surface's content, to - // the target surface. The layer contributes its surface's content when both the - // following are true: - // (1) The layer actually has a renderSurface, and - // (2) The layer's renderSurface is not the same as the targetSurface. - // - // Otherwise, the layer just contributes itself to the target surface. - - return layer->render_surface() && layer->id() != targetSurfaceLayerID; +template <typename LayerType> +bool LayerTreeHostCommon::RenderSurfaceContributesToTarget( + LayerType* layer, + int target_surface_layer_id) { + // A layer will either contribute its own content, or its render surface's + // content, to the target surface. The layer contributes its surface's content + // when both the following are true: + // (1) The layer actually has a renderSurface, and + // (2) The layer's renderSurface is not the same as the targetSurface. + // + // Otherwise, the layer just contributes itself to the target surface. + + return layer->render_surface() && layer->id() != target_surface_layer_id; } -template<typename LayerType> -LayerType* LayerTreeHostCommon::findLayerInSubtree(LayerType* rootLayer, int layerId) -{ - if (rootLayer->id() == layerId) - return rootLayer; - - if (rootLayer->mask_layer() && rootLayer->mask_layer()->id() == layerId) - return rootLayer->mask_layer(); - - if (rootLayer->replica_layer() && rootLayer->replica_layer()->id() == layerId) - return rootLayer->replica_layer(); - - for (size_t i = 0; i < rootLayer->children().size(); ++i) { - if (LayerType* found = findLayerInSubtree(getChildAsRawPtr(rootLayer->children(), i), layerId)) - return found; - } - return 0; +template <typename LayerType> +LayerType* LayerTreeHostCommon::FindLayerInSubtree(LayerType* root_layer, + int layer_id) { + if (root_layer->id() == layer_id) + return root_layer; + + if (root_layer->mask_layer() && root_layer->mask_layer()->id() == layer_id) + return root_layer->mask_layer(); + + if (root_layer->replica_layer() && + root_layer->replica_layer()->id() == layer_id) + return root_layer->replica_layer(); + + for (size_t i = 0; i < root_layer->children().size(); ++i) { + if (LayerType* found = FindLayerInSubtree( + get_child_as_raw_ptr(root_layer->children(), i), layer_id)) + return found; + } + return NULL; } -template<class Function, typename LayerType> -void LayerTreeHostCommon::callFunctionForSubtree(LayerType* rootLayer) -{ - Function()(rootLayer); - - if (LayerType* maskLayer = rootLayer->mask_layer()) - Function()(maskLayer); - if (LayerType* replicaLayer = rootLayer->replica_layer()) { - Function()(replicaLayer); - if (LayerType* maskLayer = replicaLayer->mask_layer()) - Function()(maskLayer); - } - - for (size_t i = 0; i < rootLayer->children().size(); ++i) - callFunctionForSubtree<Function>(getChildAsRawPtr(rootLayer->children(), i)); +template <class Function, typename LayerType> +void LayerTreeHostCommon::CallFunctionForSubtree(LayerType* root_layer) { + Function()(root_layer); + + if (LayerType* maskLayer = root_layer->mask_layer()) + Function()(maskLayer); + if (LayerType* replicaLayer = root_layer->replica_layer()) { + Function()(replicaLayer); + if (LayerType* maskLayer = replicaLayer->mask_layer()) + Function()(maskLayer); + } + + for (size_t i = 0; i < root_layer->children().size(); ++i) { + CallFunctionForSubtree<Function>( + get_child_as_raw_ptr(root_layer->children(), i)); + } } } // namespace cc diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 4e1c4dc..4fcceb4 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -60,7 +60,7 @@ void executeCalculateDrawProperties(Layer* rootLayer, float deviceScaleFactor = // We are probably not testing what is intended if the rootLayer bounds are empty. DCHECK(!rootLayer->bounds().IsEmpty()); - LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRenderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, &dummyRenderSurfaceLayerList); } void executeCalculateDrawProperties(LayerImpl* rootLayer, float deviceScaleFactor = 1, float pageScaleFactor = 1, bool canUseLCDText = false) @@ -72,7 +72,7 @@ void executeCalculateDrawProperties(LayerImpl* rootLayer, float deviceScaleFacto // We are probably not testing what is intended if the rootLayer bounds are empty. DCHECK(!rootLayer->bounds().IsEmpty()); - LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRenderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, &dummyRenderSurfaceLayerList, false); } scoped_ptr<LayerImpl> createTreeForFixedPositionTests(LayerTreeHostImpl* hostImpl) @@ -890,7 +890,7 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipped std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); // The child layer's content is entirely outside the parent's clip rect, so the intermediate // render surface should not be listed here, even if it was forced to be created. Render surfaces without children or visible @@ -917,7 +917,7 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); // Since the layer is transparent, renderSurface1->render_surface() should not have gotten added anywhere. // Also, the drawable content rect should not have been extended by the children. @@ -949,7 +949,7 @@ TEST(LayerTreeHostCommonTest, verifyForceRenderSurface) std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); // The root layer always creates a renderSurface EXPECT_TRUE(parent->render_surface()); @@ -958,7 +958,7 @@ TEST(LayerTreeHostCommonTest, verifyForceRenderSurface) renderSurfaceLayerList.clear(); renderSurface1->SetForceRenderSurface(false); - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_TRUE(parent->render_surface()); EXPECT_FALSE(renderSurface1->render_surface()); EXPECT_EQ(1U, renderSurfaceLayerList.size()); @@ -1573,7 +1573,7 @@ TEST(LayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); ASSERT_EQ(2U, renderSurfaceLayerList.size()); EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); @@ -1620,7 +1620,7 @@ TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); // Without an animation, we should cull child and grandChild from the renderSurfaceLayerList. ASSERT_EQ(1U, renderSurfaceLayerList.size()); @@ -1634,7 +1634,7 @@ TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) grandChild->ClearRenderSurface(); renderSurfaceLayerList.clear(); - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); // With an animating transform, we should keep child and grandChild in the renderSurfaceLayerList. ASSERT_EQ(3U, renderSurfaceLayerList.size()); @@ -1686,7 +1686,7 @@ TEST(LayerTreeHostCommonTest, verifyIsClippedIsSetCorrectly) // Case 1: nothing is clipped except the root renderSurface. std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); ASSERT_TRUE(root->render_surface()); ASSERT_TRUE(child2->render_surface()); @@ -1707,7 +1707,7 @@ TEST(LayerTreeHostCommonTest, verifyIsClippedIsSetCorrectly) // that clip. renderSurfaceLayerList.clear(); parent->SetMasksToBounds(true); - LayerTreeHostCommon::calculateDrawProperties(root.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); ASSERT_TRUE(root->render_surface()); ASSERT_TRUE(child2->render_surface()); @@ -1727,7 +1727,7 @@ TEST(LayerTreeHostCommonTest, verifyIsClippedIsSetCorrectly) renderSurfaceLayerList.clear(); parent->SetMasksToBounds(false); child2->SetMasksToBounds(true); - LayerTreeHostCommon::calculateDrawProperties(root.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); ASSERT_TRUE(root->render_surface()); ASSERT_TRUE(child2->render_surface()); @@ -1786,7 +1786,7 @@ TEST(LayerTreeHostCommonTest, verifydrawable_content_rectForLayers) std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_RECT_EQ(gfx::Rect(gfx::Point(5, 5), gfx::Size(10, 10)), grandChild1->drawable_content_rect()); EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3->drawable_content_rect()); @@ -1856,7 +1856,7 @@ TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); ASSERT_TRUE(grandChild1->render_surface()); ASSERT_TRUE(grandChild2->render_surface()); @@ -2020,18 +2020,18 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform) // Case 1: Layer is contained within the surface. gfx::Rect layerContentRect = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30)); gfx::Rect expected = gfx::Rect(gfx::Point(10, 10), gfx::Size(30, 30)); - gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); // Case 2: Layer is outside the surface rect. layerContentRect = gfx::Rect(gfx::Point(120, 120), gfx::Size(30, 30)); - actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_TRUE(actual.IsEmpty()); // Case 3: Layer is partially overlapping the surface rect. layerContentRect = gfx::Rect(gfx::Point(80, 80), gfx::Size(30, 30)); expected = gfx::Rect(gfx::Point(80, 80), gfx::Size(20, 20)); - actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); } @@ -2047,20 +2047,20 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectForTranslations) layerToSurfaceTransform.MakeIdentity(); layerToSurfaceTransform.Translate(10, 10); gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); - gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); // Case 2: Layer is outside the surface rect. layerToSurfaceTransform.MakeIdentity(); layerToSurfaceTransform.Translate(120, 120); - actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_TRUE(actual.IsEmpty()); // Case 3: Layer is partially overlapping the surface rect. layerToSurfaceTransform.MakeIdentity(); layerToSurfaceTransform.Translate(80, 80); expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)); - actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); } @@ -2078,14 +2078,14 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations) layerToSurfaceTransform.Translate(50, 50); layerToSurfaceTransform.Rotate(45); gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); - gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); // Case 2: Layer is outside the surface rect. layerToSurfaceTransform.MakeIdentity(); layerToSurfaceTransform.Translate(-50, 0); layerToSurfaceTransform.Rotate(45); - actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_TRUE(actual.IsEmpty()); // Case 3: The layer is rotated about its top-left corner. In surface space, the layer @@ -2096,7 +2096,7 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations) layerToSurfaceTransform.MakeIdentity(); layerToSurfaceTransform.Rotate(45); expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(30, 30)); - actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); // Case 4: The layer is rotated about its top-left corner, and translated upwards. In @@ -2108,7 +2108,7 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor2DRotations) layerToSurfaceTransform.Translate(0, -sqrt(2.0) * 15); layerToSurfaceTransform.Rotate(45); expected = gfx::Rect(gfx::Point(15, 0), gfx::Size(15, 30)); // right half of layer bounds. - actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); } @@ -2124,7 +2124,7 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform) layerToSurfaceTransform.MakeIdentity(); layerToSurfaceTransform.RotateAboutYAxis(45); gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); - gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); // Case 2: Orthographic projection of a layer rotated about y-axis by 45 degrees, but @@ -2135,7 +2135,7 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicTransform) layerToSurfaceTransform.Translate(-halfWidthOfRotatedLayer, 0); layerToSurfaceTransform.RotateAboutYAxis(45); // rotates about the left edge of the layer expected = gfx::Rect(gfx::Point(50, 0), gfx::Size(50, 100)); // right half of the layer. - actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); } @@ -2162,7 +2162,7 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform) layerToSurfaceTransform.Translate3d(0, 0, -27); gfx::Rect expected = gfx::Rect(gfx::Point(-50, -50), gfx::Size(200, 200)); - gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); // Case 2: same projection as before, except that the layer is also translated to the @@ -2175,7 +2175,7 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveTransform) // layerToSurfaceTransform.Translate3d(-200, 0, 0); expected = gfx::Rect(gfx::Point(50, -50), gfx::Size(100, 200)); // The right half of the layer's bounding rect. - actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); } @@ -2198,7 +2198,7 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dOrthographicIsNotClippedBehi layerToSurfaceTransform.Translate(-50, 0); gfx::Rect expected = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100)); - gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); } @@ -2231,7 +2231,7 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectFor3dPerspectiveWhenClippedByW) int expectedXPosition = 0; int expectedWidth = 10; - gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_EQ(expectedXPosition, actual.x()); EXPECT_EQ(expectedWidth, actual.width()); } @@ -2264,7 +2264,7 @@ TEST(LayerTreeHostCommonTest, verifyVisibleRectForPerspectiveUnprojection) // clipped. But, the net result of rounding visible region to an axis-aligned rect is // that the entire layer should still be considered visible. gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); - gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); + gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect(targetSurfaceRect, layerContentRect, layerToSurfaceTransform); EXPECT_RECT_EQ(expected, actual); } @@ -2692,7 +2692,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d) std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); // Verify which renderSurfaces were created. EXPECT_FALSE(frontFacingChild->render_surface()); @@ -2791,7 +2791,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d) std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); // Verify which renderSurfaces were created. EXPECT_FALSE(frontFacingChild->render_surface()); @@ -2871,7 +2871,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms) std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_FALSE(child->render_surface()); EXPECT_TRUE(animatingSurface->render_surface()); @@ -2937,7 +2937,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlatteningS std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); // Verify which renderSurfaces were created. EXPECT_TRUE(frontFacingSurface->render_surface()); @@ -2966,11 +2966,11 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForEmptyLayerList) std::vector<LayerImpl*> renderSurfaceLayerList; gfx::Point testPoint(0, 0); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(10, 20); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); } @@ -2989,7 +2989,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_EQ(1u, renderSurfaceLayerList.size()); @@ -2997,21 +2997,21 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) // Hit testing for a point outside the layer should return a null pointer. gfx::Point testPoint(101, 101); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(-1, -1); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit testing for a point inside should return the root layer. testPoint = gfx::Point(1, 1); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); testPoint = gfx::Point(99, 99); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); } @@ -3040,7 +3040,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerAndHud) std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), hudBounds, 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), hudBounds, 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_EQ(1u, renderSurfaceLayerList.size()); @@ -3048,21 +3048,21 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerAndHud) // Hit testing for a point inside HUD, but outside root should return null gfx::Point testPoint(101, 101); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(-1, -1); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit testing for a point inside should return the root layer, never the HUD layer. testPoint = gfx::Point(1, 1); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); testPoint = gfx::Point(99, 99); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); } @@ -3089,7 +3089,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_EQ(1u, renderSurfaceLayerList.size()); @@ -3100,31 +3100,31 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) // accidentally ignored and treated like an identity, then the hit testing will // incorrectly hit the layer when it shouldn't. gfx::Point testPoint(1, 1); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(10, 10); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(10, 30); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(50, 50); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(67, 48); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(99, 99); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(-1, -1); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); } @@ -3143,7 +3143,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_EQ(1u, renderSurfaceLayerList.size()); @@ -3151,22 +3151,22 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) // Hit testing for a point outside the layer should return a null pointer. gfx::Point testPoint(49, 49); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Even though the layer exists at (101, 101), it should not be visible there since the root renderSurface would clamp it. testPoint = gfx::Point(101, 101); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit testing for a point inside should return the root layer. testPoint = gfx::Point(51, 51); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); testPoint = gfx::Point(99, 99); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); } @@ -3190,7 +3190,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_EQ(1u, renderSurfaceLayerList.size()); @@ -3199,26 +3199,26 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) // Hit testing for points outside the layer. // These corners would have been inside the un-transformed layer, but they should not hit the correctly transformed layer. gfx::Point testPoint(99, 99); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(1, 1); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit testing for a point inside should return the root layer. testPoint = gfx::Point(1, 50); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); // Hit testing the corners that would overlap the unclipped layer, but are outside the clipped region. testPoint = gfx::Point(50, -1); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_FALSE(resultLayer); testPoint = gfx::Point(-1, 50); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_FALSE(resultLayer); } @@ -3246,7 +3246,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_EQ(1u, renderSurfaceLayerList.size()); @@ -3255,21 +3255,21 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) // Hit testing for points outside the layer. // These corners would have been inside the un-transformed layer, but they should not hit the correctly transformed layer. gfx::Point testPoint(24, 24); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(76, 76); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit testing for a point inside should return the root layer. testPoint = gfx::Point(26, 26); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); testPoint = gfx::Point(74, 74); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); } @@ -3311,7 +3311,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerWithScaledContents) std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. // The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25. @@ -3322,25 +3322,25 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerWithScaledContents) // Hit testing for a point outside the layer should return a null pointer (the root layer does not draw content, so it will not be hit tested either). gfx::Point testPoint(101, 101); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(24, 24); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(76, 76); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit testing for a point inside should return the test layer. testPoint = gfx::Point(26, 26); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); testPoint = gfx::Point(74, 74); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); } @@ -3375,7 +3375,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_EQ(1u, renderSurfaceLayerList.size()); @@ -3385,22 +3385,22 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) // Hit testing for a point outside the layer should return a null pointer. // Despite the child layer being very large, it should be clipped to the root layer's bounds. gfx::Point testPoint(24, 24); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Even though the layer exists at (101, 101), it should not be visible there since the clippingLayer would clamp it. testPoint = gfx::Point(76, 76); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit testing for a point inside should return the child layer. testPoint = gfx::Point(26, 26); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(456, resultLayer->id()); testPoint = gfx::Point(74, 74); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(456, resultLayer->id()); } @@ -3465,7 +3465,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer) std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. // The grandChild is expected to create a renderSurface because it masksToBounds and is not axis aligned. @@ -3477,12 +3477,12 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer) // (11, 89) is close to the the bottom left corner within the clip, but it is not inside the layer. gfx::Point testPoint(11, 89); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Closer inwards from the bottom left will overlap the layer. testPoint = gfx::Point(25, 75); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(2468, resultLayer->id()); @@ -3491,24 +3491,24 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer) // visibleContentRect without considering how parent may clip the layer, then hit // testing would accidentally think that the point successfully hits the layer. testPoint = gfx::Point(4, 50); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // (11, 50) is inside the layer and within the clipped area. testPoint = gfx::Point(11, 50); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(2468, resultLayer->id()); // Around the middle, just to the right and up, would have hit the layer except that // that area should be clipped away by the parent. testPoint = gfx::Point(51, 51); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Around the middle, just to the left and down, should successfully hit the layer. testPoint = gfx::Point(49, 51); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(2468, resultLayer->id()); } @@ -3547,7 +3547,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_EQ(1u, renderSurfaceLayerList.size()); @@ -3556,21 +3556,21 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) // Hit testing for a point outside the layer should return a null pointer. gfx::Point testPoint(69, 69); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(91, 91); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit testing for a point inside should return the child layer. testPoint = gfx::Point(71, 71); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(456, resultLayer->id()); testPoint = gfx::Point(89, 89); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(456, resultLayer->id()); } @@ -3627,7 +3627,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_TRUE(child1); @@ -3642,37 +3642,37 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) // Nothing overlaps the rootLayer at (1, 1), so hit testing there should find the root layer. gfx::Point testPoint = gfx::Point(1, 1); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(1, resultLayer->id()); // At (15, 15), child1 and root are the only layers. child1 is expected to be on top. testPoint = gfx::Point(15, 15); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(2, resultLayer->id()); // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. testPoint = gfx::Point(51, 20); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(3, resultLayer->id()); // At (80, 51), child2 and grandChild1 overlap. child2 is expected to be on top. testPoint = gfx::Point(80, 51); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(3, resultLayer->id()); // At (51, 51), all layers overlap each other. child2 is expected to be on top of all other layers. testPoint = gfx::Point(51, 51); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(3, resultLayer->id()); // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to be on top. testPoint = gfx::Point(20, 51); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(4, resultLayer->id()); } @@ -3735,7 +3735,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_TRUE(child1); @@ -3756,37 +3756,37 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) // Nothing overlaps the rootLayer at (1, 1), so hit testing there should find the root layer. gfx::Point testPoint = gfx::Point(1, 1); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(1, resultLayer->id()); // At (15, 15), child1 and root are the only layers. child1 is expected to be on top. testPoint = gfx::Point(15, 15); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(2, resultLayer->id()); // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. testPoint = gfx::Point(51, 20); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(3, resultLayer->id()); // At (80, 51), child2 and grandChild1 overlap. child2 is expected to be on top. testPoint = gfx::Point(80, 51); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(3, resultLayer->id()); // At (51, 51), all layers overlap each other. child2 is expected to be on top of all other layers. testPoint = gfx::Point(51, 51); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(3, resultLayer->id()); // At (20, 51), child1 and grandChild1 overlap. grandChild1 is expected to be on top. testPoint = gfx::Point(20, 51); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPoint(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(4, resultLayer->id()); } @@ -3797,11 +3797,11 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForEmptyLayerL std::vector<LayerImpl*> renderSurfaceLayerList; gfx::Point testPoint(0, 0); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(10, 20); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); } @@ -3821,7 +3821,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_EQ(1u, renderSurfaceLayerList.size()); @@ -3829,36 +3829,36 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer // Hit checking for any point should return a null pointer for a layer without any touch event handler regions. gfx::Point testPoint(11, 11); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); root->SetTouchEventHandlerRegion(touchHandlerRegion); // Hit checking for a point outside the layer should return a null pointer. testPoint = gfx::Point(101, 101); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(-1, -1); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit checking for a point inside the layer, but outside the touch handler region should return a null pointer. testPoint = gfx::Point(1, 1); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(99, 99); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit checking for a point inside the touch event handler region should return the root layer. testPoint = gfx::Point(11, 11); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); testPoint = gfx::Point(59, 59); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); } @@ -3887,7 +3887,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_EQ(1u, renderSurfaceLayerList.size()); @@ -3898,31 +3898,31 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl // accidentally ignored and treated like an identity, then the hit testing will // incorrectly hit the layer when it shouldn't. gfx::Point testPoint(1, 1); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(10, 10); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(10, 30); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(50, 50); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(67, 48); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(99, 99); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(-1, -1); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); } @@ -3943,7 +3943,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_EQ(1u, renderSurfaceLayerList.size()); @@ -3951,27 +3951,27 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit // Hit checking for a point outside the layer should return a null pointer. gfx::Point testPoint(49, 49); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Even though the layer has a touch handler region containing (101, 101), it should not be visible there since the root renderSurface would clamp it. testPoint = gfx::Point(101, 101); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit checking for a point inside the layer, but outside the touch handler region should return a null pointer. testPoint = gfx::Point(51, 51); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit checking for a point inside the touch event handler region should return the root layer. testPoint = gfx::Point(61, 61); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); testPoint = gfx::Point(99, 99); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); } @@ -4015,7 +4015,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. // The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25. @@ -4026,34 +4026,34 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer // Hit checking for a point outside the layer should return a null pointer (the root layer does not draw content, so it will not be tested either). gfx::Point testPoint(76, 76); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit checking for a point inside the layer, but outside the touch handler region should return a null pointer. testPoint = gfx::Point(26, 26); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(34, 34); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(65, 65); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(74, 74); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit checking for a point inside the touch event handler region should return the root layer. testPoint = gfx::Point(35, 35); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); testPoint = gfx::Point(64, 64); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); } @@ -4091,7 +4091,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor); root->SetImplTransform(pageScaleTransform); // Applying the pageScaleFactor through implTransform. gfx::Size scaledBoundsForRoot = gfx::ToCeiledSize(gfx::ScaleSize(root->bounds(), deviceScaleFactor * pageScaleFactor)); - LayerTreeHostCommon::calculateDrawProperties(root.get(), scaledBoundsForRoot, deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), scaledBoundsForRoot, deviceScaleFactor, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. // The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25. @@ -4105,40 +4105,40 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer // Hit checking for a point outside the layer should return a null pointer (the root layer does not draw content, so it will not be tested either). gfx::PointF testPoint(76, 76); testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit checking for a point inside the layer, but outside the touch handler region should return a null pointer. testPoint = gfx::Point(26, 26); testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(34, 34); testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(65, 65); testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(74, 74); testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit checking for a point inside the touch event handler region should return the root layer. testPoint = gfx::Point(35, 35); testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); testPoint = gfx::Point(64, 64); testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(12345, resultLayer->id()); } @@ -4175,7 +4175,7 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp std::vector<LayerImpl*> renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); + LayerTreeHostCommon::CalculateDrawProperties(root.get(), root->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList, false); // Sanity check the scenario we just created. ASSERT_EQ(1u, renderSurfaceLayerList.size()); @@ -4185,26 +4185,26 @@ TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp // Hit checking for a point outside the layer should return a null pointer. // Despite the child layer being very large, it should be clipped to the root layer's bounds. gfx::Point testPoint(24, 24); - LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + LayerImpl* resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit checking for a point inside the layer, but outside the touch handler region should return a null pointer. testPoint = gfx::Point(35, 35); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); testPoint = gfx::Point(74, 74); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); EXPECT_FALSE(resultLayer); // Hit checking for a point inside the touch event handler region should return the root layer. testPoint = gfx::Point(25, 25); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(456, resultLayer->id()); testPoint = gfx::Point(34, 34); - resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); + resultLayer = LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(testPoint, renderSurfaceLayerList); ASSERT_TRUE(resultLayer); EXPECT_EQ(456, resultLayer->id()); } @@ -4270,7 +4270,7 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) const double deviceScaleFactor = 2.5; const double pageScaleFactor = 1; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); @@ -4365,7 +4365,7 @@ TEST(LayerTreeHostCommonTest, verifySurfaceLayerTransformsInHighDPI) pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor); parent->SetImplTransform(pageScaleTransform); - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, perspectiveSurface); @@ -4424,7 +4424,7 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi const float deviceScaleFactor = 1.7f; const float pageScaleFactor = 1; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); @@ -4529,7 +4529,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScale) pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); parent->SetSublayerTransform(pageScaleMatrix); - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, childScale); @@ -4560,7 +4560,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScale) parent->SetSublayerTransform(pageScaleMatrix); renderSurfaceLayerList.clear(); - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, childScale); @@ -4575,7 +4575,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScale) childEmpty->SetTransform(childScaleMatrix); renderSurfaceLayerList.clear(); - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childScale); @@ -4592,7 +4592,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScale) parent->SetSublayerTransform(pageScaleMatrix); renderSurfaceLayerList.clear(); - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childScale); @@ -4637,7 +4637,7 @@ TEST(LayerTreeHostCommonTest, verifySmallContentsScale) pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); parent->SetSublayerTransform(pageScaleMatrix); - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); // The child's scale is < 1, so we should not save and use that scale factor. @@ -4650,7 +4650,7 @@ TEST(LayerTreeHostCommonTest, verifySmallContentsScale) childScale->SetTransform(childScaleMatrix); renderSurfaceLayerList.clear(); - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * finalChildScale, childScale); @@ -4734,7 +4734,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); parent->SetSublayerTransform(pageScaleMatrix); - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, surfaceScale); @@ -4828,7 +4828,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer) std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; int dummyMaxTextureSize = 512; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); // The layers with animating transforms should not compute a contentsScale other than 1 until they finish animating. @@ -4837,7 +4837,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer) // Remove the animation, now it can save a raster scale. childScale->layer_animation_controller()->RemoveAnimation(animationId); - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); // The layers with animating transforms should not compute a contentsScale other than 1 until they finish animating. @@ -4874,7 +4874,7 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) int dummyMaxTextureSize = 512; const double deviceScaleFactor = 1.5; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); // We should have two render surfaces. The root's render surface and child's // render surface (it needs one because it has a replica layer). @@ -4952,7 +4952,7 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPIAccurateScal int dummyMaxTextureSize = 512; const float deviceScaleFactor = 1.7f; - LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, false, &renderSurfaceLayerList); // We should have two render surfaces. The root's render surface and child's // render surface (it needs one because it has a replica layer). @@ -4996,12 +4996,12 @@ TEST(LayerTreeHostCommonTest, verifySubtreeSearch) root->AddChild(child.get()); int nonexistentId = -1; - EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id())); - EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->id())); - EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), grandChild->id())); - EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), maskLayer->id())); - EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); - EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistentId)); + EXPECT_EQ(root, LayerTreeHostCommon::FindLayerInSubtree(root.get(), root->id())); + EXPECT_EQ(child, LayerTreeHostCommon::FindLayerInSubtree(root.get(), child->id())); + EXPECT_EQ(grandChild, LayerTreeHostCommon::FindLayerInSubtree(root.get(), grandChild->id())); + EXPECT_EQ(maskLayer, LayerTreeHostCommon::FindLayerInSubtree(root.get(), maskLayer->id())); + EXPECT_EQ(replicaLayer, LayerTreeHostCommon::FindLayerInSubtree(root.get(), replicaLayer->id())); + EXPECT_EQ(0, LayerTreeHostCommon::FindLayerInSubtree(root.get(), nonexistentId)); } TEST(LayerTreeHostCommonTest, verifyTransparentChildRenderSurfaceCreation) diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 4dee1b3..ee98af3 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -341,14 +341,14 @@ bool LayerTreeHostImpl::HaveTouchEventHandlersAt(gfx::Point viewport_point) { // First find out which layer was hit from the saved list of visible layers // in the most recent frame. - LayerImpl* layer_impl = LayerTreeHostCommon::findLayerThatIsHitByPoint( + LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( device_viewport_point, active_tree_->RenderSurfaceLayerList()); // Walk up the hierarchy and look for a layer with a touch event handler // region that the given point hits. for (; layer_impl; layer_impl = layer_impl->parent()) { - if (LayerTreeHostCommon::layerHasTouchEventHandlersAt(device_viewport_point, + if (LayerTreeHostCommon::LayerHasTouchEventHandlersAt(device_viewport_point, layer_impl)) return true; } @@ -1365,7 +1365,7 @@ InputHandlerClient::ScrollStatus LayerTreeHostImpl::ScrollBegin( // First find out which layer was hit from the saved list of visible layers // in the most recent frame. - LayerImpl* layer_impl = LayerTreeHostCommon::findLayerThatIsHitByPoint( + LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( device_viewport_point, active_tree_->RenderSurfaceLayerList()); // Walk up the hierarchy and look for a scrollable layer. @@ -1645,8 +1645,8 @@ static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, gfx::ToFlooredVector2d(layer_impl->scroll_delta()); if (!scroll_delta.IsZero()) { LayerTreeHostCommon::ScrollUpdateInfo scroll; - scroll.layerId = layer_impl->id(); - scroll.scrollDelta = scroll_delta; + scroll.layer_id = layer_impl->id(); + scroll.scroll_delta = scroll_delta; scroll_info->scrolls.push_back(scroll); layer_impl->SetSentScrollDelta(scroll_delta); } @@ -1659,8 +1659,8 @@ scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); - scroll_info->pageScaleDelta = active_tree_->page_scale_delta(); - active_tree_->set_sent_page_scale_delta(scroll_info->pageScaleDelta); + scroll_info->page_scale_delta = active_tree_->page_scale_delta(); + active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); return scroll_info.Pass(); } diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 59468ce..994de54 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -142,9 +142,9 @@ public: int timesEncountered = 0; for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { - if (scrollInfo.scrolls[i].layerId != id) + if (scrollInfo.scrolls[i].layer_id != id) continue; - EXPECT_VECTOR_EQ(scrollDelta, scrollInfo.scrolls[i].scrollDelta); + EXPECT_VECTOR_EQ(scrollDelta, scrollInfo.scrolls[i].scroll_delta); timesEncountered++; } @@ -156,7 +156,7 @@ public: int timesEncountered = 0; for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { - if (scrollInfo.scrolls[i].layerId != id) + if (scrollInfo.scrolls[i].layer_id != id) continue; timesEncountered++; } @@ -583,7 +583,7 @@ TEST_F(LayerTreeHostImplTest, implPinchZoom) EXPECT_TRUE(m_didRequestCommit); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->ProcessScrollDeltas(); - EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); + EXPECT_EQ(scrollInfo->page_scale_delta, pageScaleDelta); EXPECT_EQ(gfx::Vector2d(75, 75), m_hostImpl->active_tree()->root_layer()->max_scroll_offset()); } @@ -638,7 +638,7 @@ TEST_F(LayerTreeHostImplTest, pinchGesture) EXPECT_TRUE(m_didRequestCommit); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->ProcessScrollDeltas(); - EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); + EXPECT_EQ(scrollInfo->page_scale_delta, pageScaleDelta); } // Zoom-in clamping @@ -653,7 +653,7 @@ TEST_F(LayerTreeHostImplTest, pinchGesture) m_hostImpl->PinchGestureEnd(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->ProcessScrollDeltas(); - EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale); + EXPECT_EQ(scrollInfo->page_scale_delta, maxPageScale); } // Zoom-out clamping @@ -669,7 +669,7 @@ TEST_F(LayerTreeHostImplTest, pinchGesture) m_hostImpl->PinchGestureEnd(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->ProcessScrollDeltas(); - EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); + EXPECT_EQ(scrollInfo->page_scale_delta, minPageScale); EXPECT_TRUE(scrollInfo->scrolls.empty()); } @@ -688,7 +688,7 @@ TEST_F(LayerTreeHostImplTest, pinchGesture) m_hostImpl->PinchGestureEnd(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->ProcessScrollDeltas(); - EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); + EXPECT_EQ(scrollInfo->page_scale_delta, pageScaleDelta); EXPECT_TRUE(scrollInfo->scrolls.empty()); } @@ -709,7 +709,7 @@ TEST_F(LayerTreeHostImplTest, pinchGesture) m_hostImpl->ScrollEnd(); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->ProcessScrollDeltas(); - EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); + EXPECT_EQ(scrollInfo->page_scale_delta, pageScaleDelta); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10)); } } @@ -744,7 +744,7 @@ TEST_F(LayerTreeHostImplTest, pageScaleAnimation) EXPECT_TRUE(m_didRequestCommit); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->ProcessScrollDeltas(); - EXPECT_EQ(scrollInfo->pageScaleDelta, 2); + EXPECT_EQ(scrollInfo->page_scale_delta, 2); expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50)); } @@ -760,7 +760,7 @@ TEST_F(LayerTreeHostImplTest, pageScaleAnimation) EXPECT_TRUE(m_didRequestCommit); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->ProcessScrollDeltas(); - EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); + EXPECT_EQ(scrollInfo->page_scale_delta, minPageScale); // Pushed to (0,0) via clamping against contents layer size. expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50)); } @@ -796,7 +796,7 @@ TEST_F(LayerTreeHostImplTest, pageScaleAnimationNoOp) EXPECT_TRUE(m_didRequestCommit); scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->ProcessScrollDeltas(); - EXPECT_EQ(scrollInfo->pageScaleDelta, 1); + EXPECT_EQ(scrollInfo->page_scale_delta, 1); expectNone(*scrollInfo, scrollLayer->id()); } } diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 1ff75b3..d154839d 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -76,7 +76,7 @@ void LayerTreeImpl::FindRootScrollLayer() { root_scroll_layer_ = FindRootScrollLayerRecursive(root_layer_.get()); if (root_layer_ && scrolling_layer_id_from_previous_tree_) { - currently_scrolling_layer_ = LayerTreeHostCommon::findLayerInSubtree( + currently_scrolling_layer_ = LayerTreeHostCommon::FindLayerInSubtree( root_layer_.get(), scrolling_layer_id_from_previous_tree_); } @@ -121,7 +121,7 @@ void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { if (hud_layer()) target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( - LayerTreeHostCommon::findLayerInSubtree( + LayerTreeHostCommon::FindLayerInSubtree( target_tree->root_layer(), hud_layer()->id()))); else target_tree->set_hud_layer(NULL); @@ -270,7 +270,7 @@ void LayerTreeImpl::UpdateDrawProperties(UpdateDrawPropertiesReason reason) { if (!needs_update_draw_properties_) { if (reason == UPDATE_ACTIVE_TREE_FOR_DRAW && root_layer()) - LayerTreeHostCommon::callFunctionForSubtree<UpdateTilePrioritiesForLayer>( + LayerTreeHostCommon::CallFunctionForSubtree<UpdateTilePrioritiesForLayer>( root_layer()); return; } @@ -299,14 +299,14 @@ void LayerTreeImpl::UpdateDrawProperties(UpdateDrawPropertiesReason reason) { bool update_tile_priorities = reason == UPDATE_PENDING_TREE || reason == UPDATE_ACTIVE_TREE_FOR_DRAW; - LayerTreeHostCommon::calculateDrawProperties( + LayerTreeHostCommon::CalculateDrawProperties( root_layer(), device_viewport_size(), device_scale_factor(), total_page_scale_factor(), MaxTextureSize(), settings().can_use_lcd_text, - render_surface_layer_list_, + &render_surface_layer_list_, update_tile_priorities); } @@ -374,7 +374,7 @@ void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pendingTree) { int id = currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0; pendingTree->SetCurrentlyScrollingLayer( - LayerTreeHostCommon::findLayerInSubtree(pendingTree->root_layer(), id)); + LayerTreeHostCommon::FindLayerInSubtree(pendingTree->root_layer(), id)); } static void DidBecomeActiveRecursive(LayerImpl* layer) { diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc index 7e44feb..eed5c5d 100644 --- a/cc/trees/occlusion_tracker_unittest.cc +++ b/cc/trees/occlusion_tracker_unittest.cc @@ -276,7 +276,7 @@ protected: DCHECK(!root->render_surface()); - LayerTreeHostCommon::calculateDrawProperties(root, root->bounds(), 1, 1, dummyMaxTextureSize, false, m_renderSurfaceLayerListImpl, false); + LayerTreeHostCommon::CalculateDrawProperties(root, root->bounds(), 1, 1, dummyMaxTextureSize, false, &m_renderSurfaceLayerListImpl, false); m_layerIterator = m_layerIteratorBegin = Types::TestLayerIterator::Begin(&m_renderSurfaceLayerListImpl); } @@ -288,7 +288,7 @@ protected: DCHECK(!root->render_surface()); - LayerTreeHostCommon::calculateDrawProperties(root, root->bounds(), 1, 1, dummyMaxTextureSize, false, m_renderSurfaceLayerList); + LayerTreeHostCommon::CalculateDrawProperties(root, root->bounds(), 1, 1, dummyMaxTextureSize, false, &m_renderSurfaceLayerList); m_layerIterator = m_layerIteratorBegin = Types::TestLayerIterator::Begin(&m_renderSurfaceLayerList); } |