diff options
author | awoloszyn <awoloszyn@chromium.org> | 2014-12-22 07:40:00 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-22 15:40:46 +0000 |
commit | e83f28ca816694be553baed069f784eb286d8170 (patch) | |
tree | d574779de5f809f7760ceb9d90bd86496469fe29 | |
parent | 73b32fca8ed133af29af871d2108f9ea5de7f0bf (diff) | |
download | chromium_src-e83f28ca816694be553baed069f784eb286d8170.zip chromium_src-e83f28ca816694be553baed069f784eb286d8170.tar.gz chromium_src-e83f28ca816694be553baed069f784eb286d8170.tar.bz2 |
Move RenderSurface creation outside of CalcDrawProps
BUG=386788
Review URL: https://codereview.chromium.org/465853004
Cr-Commit-Position: refs/heads/master@{#309428}
39 files changed, 681 insertions, 926 deletions
diff --git a/cc/animation/animation_curve.h b/cc/animation/animation_curve.h index f4c697c..74ce11b 100644 --- a/cc/animation/animation_curve.h +++ b/cc/animation/animation_curve.h @@ -82,6 +82,9 @@ class CC_EXPORT TransformAnimationCurve : public AnimationCurve { // Returns true if this animation is a translation. virtual bool IsTranslation() const = 0; + // Returns true if this animation preserves axis alignment. + virtual bool PreservesAxisAlignment() const = 0; + // Set |max_scale| to the maximum scale along any dimension at the end of // intermediate animation target points (eg keyframe end points). When // |forward_direction| is true, the animation curve assumes it plays from diff --git a/cc/animation/keyframed_animation_curve.cc b/cc/animation/keyframed_animation_curve.cc index 9642329..bf65df8 100644 --- a/cc/animation/keyframed_animation_curve.cc +++ b/cc/animation/keyframed_animation_curve.cc @@ -363,6 +363,14 @@ bool KeyframedTransformAnimationCurve::AffectsScale() const { return false; } +bool KeyframedTransformAnimationCurve::PreservesAxisAlignment() const { + for (size_t i = 0; i < keyframes_.size(); ++i) { + if (!keyframes_[i]->Value().PreservesAxisAlignment()) + return false; + } + return true; +} + bool KeyframedTransformAnimationCurve::IsTranslation() const { for (size_t i = 0; i < keyframes_.size(); ++i) { if (!keyframes_[i]->Value().IsTranslation() && diff --git a/cc/animation/keyframed_animation_curve.h b/cc/animation/keyframed_animation_curve.h index e68f4f8..131c930c 100644 --- a/cc/animation/keyframed_animation_curve.h +++ b/cc/animation/keyframed_animation_curve.h @@ -194,6 +194,7 @@ class CC_EXPORT KeyframedTransformAnimationCurve bool AnimatedBoundsForBox(const gfx::BoxF& box, gfx::BoxF* bounds) const override; bool AffectsScale() const override; + bool PreservesAxisAlignment() const override; bool IsTranslation() const override; bool MaximumTargetScale(bool forward_direction, float* max_scale) const override; diff --git a/cc/animation/layer_animation_controller.cc b/cc/animation/layer_animation_controller.cc index c9d81cf..1f9e112 100644 --- a/cc/animation/layer_animation_controller.cc +++ b/cc/animation/layer_animation_controller.cc @@ -501,6 +501,21 @@ bool LayerAnimationController::HasOnlyTranslationTransforms() const { return true; } +bool LayerAnimationController::AnimationsPreserveAxisAlignment() const { + for (size_t i = 0; i < animations_.size(); ++i) { + if (animations_[i]->is_finished() || + animations_[i]->target_property() != Animation::Transform) + continue; + + const TransformAnimationCurve* transform_animation_curve = + animations_[i]->curve()->ToTransformAnimationCurve(); + if (!transform_animation_curve->PreservesAxisAlignment()) + return false; + } + + return true; +} + bool LayerAnimationController::MaximumTargetScale(float* max_scale) const { *max_scale = 0.f; for (size_t i = 0; i < animations_.size(); ++i) { diff --git a/cc/animation/layer_animation_controller.h b/cc/animation/layer_animation_controller.h index 01fce98..22c57b5 100644 --- a/cc/animation/layer_animation_controller.h +++ b/cc/animation/layer_animation_controller.h @@ -134,6 +134,8 @@ class CC_EXPORT LayerAnimationController bool HasOnlyTranslationTransforms() const; + bool AnimationsPreserveAxisAlignment() const; + // Sets |max_scale| to the maximum scale along any dimension at any // destination in active animations. Returns false if the maximum scale cannot // be computed. diff --git a/cc/animation/transform_operations.cc b/cc/animation/transform_operations.cc index 7bc4ce2..d9d58f2 100644 --- a/cc/animation/transform_operations.cc +++ b/cc/animation/transform_operations.cc @@ -94,6 +94,27 @@ bool TransformOperations::AffectsScale() const { return false; } +bool TransformOperations::PreservesAxisAlignment() const { + for (size_t i = 0; i < operations_.size(); ++i) { + switch (operations_[i].type) { + case TransformOperation::TransformOperationIdentity: + case TransformOperation::TransformOperationTranslate: + case TransformOperation::TransformOperationScale: + continue; + case TransformOperation::TransformOperationMatrix: + if (!operations_[i].matrix.IsIdentity() && + !operations_[i].matrix.IsScaleOrTranslation()) + return false; + continue; + case TransformOperation::TransformOperationRotate: + case TransformOperation::TransformOperationSkew: + case TransformOperation::TransformOperationPerspective: + return false; + } + } + return true; +} + bool TransformOperations::IsTranslation() const { for (size_t i = 0; i < operations_.size(); ++i) { switch (operations_[i].type) { diff --git a/cc/animation/transform_operations.h b/cc/animation/transform_operations.h index 1c110ff..65f8511 100644 --- a/cc/animation/transform_operations.h +++ b/cc/animation/transform_operations.h @@ -63,6 +63,9 @@ class CC_EXPORT TransformOperations { // Returns true if these operations are only translations. bool IsTranslation() const; + // Returns false if the operations affect 2d axis alignment. + bool PreservesAxisAlignment() const; + // Returns true if this operation and its descendants have the same types // as other and its descendants. bool MatchesTypes(const TransformOperations& other) const; diff --git a/cc/layers/delegated_renderer_layer_impl_unittest.cc b/cc/layers/delegated_renderer_layer_impl_unittest.cc index 5a797f9..395d361 100644 --- a/cc/layers/delegated_renderer_layer_impl_unittest.cc +++ b/cc/layers/delegated_renderer_layer_impl_unittest.cc @@ -67,18 +67,19 @@ class DelegatedRendererLayerImplTestSimple host_impl_->SetViewportSize(gfx::Size(100, 100)); root_layer->SetBounds(gfx::Size(100, 100)); + root_layer->SetHasRenderSurface(true); layer_before->SetPosition(gfx::Point(20, 20)); layer_before->SetBounds(gfx::Size(14, 14)); layer_before->SetContentBounds(gfx::Size(14, 14)); layer_before->SetDrawsContent(true); - layer_before->SetForceRenderSurface(true); + layer_before->SetHasRenderSurface(true); layer_after->SetPosition(gfx::Point(5, 5)); layer_after->SetBounds(gfx::Size(15, 15)); layer_after->SetContentBounds(gfx::Size(15, 15)); layer_after->SetDrawsContent(true); - layer_after->SetForceRenderSurface(true); + layer_after->SetHasRenderSurface(true); delegated_renderer_layer->SetPosition(gfx::Point(3, 3)); delegated_renderer_layer->SetBounds(gfx::Size(10, 10)); @@ -297,61 +298,12 @@ TEST_F(DelegatedRendererLayerImplTestSimple, RenderPassTransformIsModified) { host_impl_->DidDrawAllLayers(frame); } -TEST_F(DelegatedRendererLayerImplTestSimple, DoesNotOwnARenderSurface) { - LayerTreeHostImpl::FrameData frame; - EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); - - // If the DelegatedRendererLayer is axis aligned and has opacity 1, then it - // has no need to be a RenderSurface for the quads it carries. - EXPECT_FALSE(delegated_renderer_layer_->render_surface()); - - host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); - host_impl_->DidDrawAllLayers(frame); -} - -TEST_F(DelegatedRendererLayerImplTestSimple, DoesOwnARenderSurfaceForOpacity) { - delegated_renderer_layer_->SetOpacity(0.5f); - - LayerTreeHostImpl::FrameData frame; - FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( - host_impl_->active_tree()->root_layer()); - EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); - - // This test case has quads from multiple layers in the delegated renderer, so - // if the DelegatedRendererLayer has opacity < 1, it should end up with a - // render surface. - EXPECT_TRUE(delegated_renderer_layer_->render_surface()); - - host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); - host_impl_->DidDrawAllLayers(frame); -} - -TEST_F(DelegatedRendererLayerImplTestSimple, - DoesOwnARenderSurfaceForTransform) { - gfx::Transform rotation; - rotation.RotateAboutZAxis(30.0); - delegated_renderer_layer_->SetTransform(rotation); - - LayerTreeHostImpl::FrameData frame; - FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( - host_impl_->active_tree()->root_layer()); - EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); - - // This test case has quads from multiple layers in the delegated renderer, so - // if the DelegatedRendererLayer has opacity < 1, it should end up with a - // render surface. - EXPECT_TRUE(delegated_renderer_layer_->render_surface()); - - host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); - host_impl_->DidDrawAllLayers(frame); -} - class DelegatedRendererLayerImplTestOwnSurface : public DelegatedRendererLayerImplTestSimple { public: DelegatedRendererLayerImplTestOwnSurface() : DelegatedRendererLayerImplTestSimple() { - delegated_renderer_layer_->SetForceRenderSurface(true); + delegated_renderer_layer_->SetHasRenderSurface(true); } }; @@ -507,6 +459,7 @@ class DelegatedRendererLayerImplTestTransform host_impl_->SetViewportSize(gfx::Size(200, 200)); root_layer->SetBounds(gfx::Size(100, 100)); + root_layer->SetHasRenderSurface(true); delegated_renderer_layer->SetPosition(gfx::Point(20, 20)); delegated_renderer_layer->SetBounds(gfx::Size(75, 75)); @@ -803,7 +756,7 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsUnclipped_Surface) { root_delegated_render_pass_is_clipped_ = false; SetUpTest(); - delegated_renderer_layer_->SetForceRenderSurface(true); + delegated_renderer_layer_->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -851,7 +804,7 @@ TEST_F(DelegatedRendererLayerImplTestTransform, QuadsClipped_Surface) { root_delegated_render_pass_is_clipped_ = true; SetUpTest(); - delegated_renderer_layer_->SetForceRenderSurface(true); + delegated_renderer_layer_->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -948,6 +901,7 @@ class DelegatedRendererLayerImplTestClip host_impl_->SetViewportSize(gfx::Size(100, 100)); root_layer->SetBounds(gfx::Size(100, 100)); + root_layer->SetHasRenderSurface(true); delegated_renderer_layer->SetPosition(gfx::Point(20, 20)); delegated_renderer_layer->SetBounds(gfx::Size(50, 50)); @@ -1216,7 +1170,7 @@ TEST_F(DelegatedRendererLayerImplTestClip, clip_delegated_renderer_layer_ = false; SetUpTest(); - delegated_renderer_layer_->SetForceRenderSurface(true); + delegated_renderer_layer_->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -1245,7 +1199,7 @@ TEST_F(DelegatedRendererLayerImplTestClip, clip_delegated_renderer_layer_ = false; SetUpTest(); - delegated_renderer_layer_->SetForceRenderSurface(true); + delegated_renderer_layer_->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -1275,7 +1229,7 @@ TEST_F(DelegatedRendererLayerImplTestClip, clip_delegated_renderer_layer_ = true; SetUpTest(); - delegated_renderer_layer_->SetForceRenderSurface(true); + delegated_renderer_layer_->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -1303,7 +1257,7 @@ TEST_F(DelegatedRendererLayerImplTestClip, QuadsClipped_LayerClipped_Surface) { clip_delegated_renderer_layer_ = true; SetUpTest(); - delegated_renderer_layer_->SetForceRenderSurface(true); + delegated_renderer_layer_->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -1336,6 +1290,7 @@ TEST_F(DelegatedRendererLayerImplTest, InvalidRenderPassDrawQuad) { FakeDelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 4); host_impl_->SetViewportSize(gfx::Size(100, 100)); + root_layer->SetHasRenderSurface(true); delegated_renderer_layer->SetPosition(gfx::Point(3, 3)); delegated_renderer_layer->SetBounds(gfx::Size(10, 10)); diff --git a/cc/layers/draw_properties.h b/cc/layers/draw_properties.h index 2e54083..5c78000 100644 --- a/cc/layers/draw_properties.h +++ b/cc/layers/draw_properties.h @@ -79,9 +79,6 @@ struct CC_EXPORT DrawProperties { // ancestor of this layer. LayerType* render_target; - // The surface that this layer and its subtree would contribute to. - scoped_ptr<typename LayerType::RenderSurfaceType> render_surface; - // This rect is in the layer's content space. gfx::Rect visible_content_rect; diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index 7c0341b..fb72c73 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -594,6 +594,10 @@ void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { SetNeedsCommit(); } +bool Layer::AnimationsPreserveAxisAlignment() const { + return layer_animation_controller_->AnimationsPreserveAxisAlignment(); +} + bool Layer::TransformIsAnimating() const { return layer_animation_controller_->IsAnimatingProperty(Animation::Transform); } @@ -881,9 +885,9 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { layer->SetDoubleSided(double_sided_); layer->SetDrawCheckerboardForMissingTiles( draw_checkerboard_for_missing_tiles_); - layer->SetForceRenderSurface(force_render_surface_); layer->SetDrawsContent(DrawsContent()); layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); + layer->SetHasRenderSurface(has_render_surface_); if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) layer->SetFilters(filters_); DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); @@ -1084,19 +1088,27 @@ scoped_refptr<base::debug::ConvertableToTraceFormat> Layer::TakeDebugInfo() { return nullptr; } +void Layer::SetHasRenderSurface(bool has_render_surface) { + if (has_render_surface_ == has_render_surface) + return; + has_render_surface_ = has_render_surface; + // We do not need SetNeedsCommit here, since this is only ever called + // during a commit, from CalculateDrawProperties. + SetNeedsPushProperties(); +} + void Layer::CreateRenderSurface() { - DCHECK(!draw_properties_.render_surface); - draw_properties_.render_surface = make_scoped_ptr(new RenderSurface(this)); - draw_properties_.render_target = this; + DCHECK(!render_surface_); + render_surface_ = make_scoped_ptr(new RenderSurface(this)); } void Layer::ClearRenderSurface() { - draw_properties_.render_surface = nullptr; + render_surface_ = nullptr; } void Layer::ClearRenderSurfaceLayerList() { - if (draw_properties_.render_surface) - draw_properties_.render_surface->layer_list().clear(); + if (render_surface_) + render_surface_->ClearLayerLists(); } gfx::ScrollOffset Layer::ScrollOffsetForAnimation() const { diff --git a/cc/layers/layer.h b/cc/layers/layer.h index 7714315..017df68 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -57,6 +57,7 @@ class LayerAnimationEventObserver; class LayerClient; class LayerImpl; class LayerTreeHost; +class LayerTreeHostCommon; class LayerTreeImpl; class PriorityCalculator; class RenderingStatsInstrumentation; @@ -178,6 +179,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, void SetTransform(const gfx::Transform& transform); const gfx::Transform& transform() const { return transform_; } bool TransformIsAnimating() const; + bool AnimationsPreserveAxisAlignment() const; bool transform_is_invertible() const { return transform_is_invertible_; } void SetTransformOrigin(const gfx::Point3F&); @@ -256,13 +258,11 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, draw_properties_.render_target->render_surface()); return draw_properties_.render_target; } - RenderSurface* render_surface() const { - return draw_properties_.render_surface.get(); - } int num_unclipped_descendants() const { return draw_properties_.num_unclipped_descendants; } + RenderSurface* render_surface() const { return render_surface_.get(); } void SetScrollOffset(const gfx::ScrollOffset& scroll_offset); gfx::ScrollOffset scroll_offset() const { return scroll_offset_; } void SetScrollOffsetFromImplSide(const gfx::ScrollOffset& scroll_offset); @@ -377,6 +377,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, void CreateRenderSurface(); void ClearRenderSurface(); + void ClearRenderSurfaceLayerList(); // The contents scale converts from logical, non-page-scaled pixels to target @@ -503,9 +504,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, bool has_render_surface() const { return has_render_surface_; } - void SetHasRenderSurface(bool has_render_surface) { - has_render_surface_ = has_render_surface; - } protected: friend class LayerImpl; @@ -586,10 +584,14 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, private: friend class base::RefCounted<Layer>; - + friend class LayerTreeHostCommon; void SetParent(Layer* layer); bool DescendantIsFixedToContainerLayer() const; + // This should only be called during BeginMainFrame since it does not + // trigger a Commit. + void SetHasRenderSurface(bool has_render_surface); + // Returns the index of the child or -1 if not found. int IndexOfChild(const Layer* reference); @@ -690,6 +692,9 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, DrawProperties<Layer> draw_properties_; PaintProperties paint_properties_; + // TODO(awoloszyn): This is redundant with has_render_surface_, + // and should get removed once it is no longer needed on main thread. + scoped_ptr<RenderSurface> render_surface_; gfx::Rect visible_rect_from_property_trees_; DISALLOW_COPY_AND_ASSIGN(Layer); diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index 6793d12..c5c759c 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -60,7 +60,6 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) draw_checkerboard_for_missing_tiles_(false), draws_content_(false), hide_layer_and_subtree_(false), - force_render_surface_(false), transform_is_invertible_(true), is_container_for_fixed_position_layers_(false), background_color_(0), @@ -204,7 +203,7 @@ void LayerImpl::SetClipChildren(std::set<LayerImpl*>* children) { void LayerImpl::PassCopyRequests(ScopedPtrVector<CopyOutputRequest>* requests) { if (requests->empty()) return; - + DCHECK(render_surface()); bool was_empty = copy_requests_.empty(); copy_requests_.insert_and_take(copy_requests_.end(), requests); requests->clear(); @@ -218,6 +217,7 @@ void LayerImpl::TakeCopyRequestsAndTransformToTarget( ScopedPtrVector<CopyOutputRequest>* requests) { DCHECK(!copy_requests_.empty()); DCHECK(layer_tree_impl()->IsActiveTree()); + DCHECK_EQ(render_target(), this); size_t first_inserted_request = requests->size(); requests->insert_and_take(requests->end(), ©_requests_); @@ -238,20 +238,9 @@ void LayerImpl::TakeCopyRequestsAndTransformToTarget( layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); } -void LayerImpl::CreateRenderSurface() { - DCHECK(!draw_properties_.render_surface); - draw_properties_.render_surface = - make_scoped_ptr(new RenderSurfaceImpl(this)); - draw_properties_.render_target = this; -} - -void LayerImpl::ClearRenderSurface() { - draw_properties_.render_surface = nullptr; -} - void LayerImpl::ClearRenderSurfaceLayerList() { - if (draw_properties_.render_surface) - draw_properties_.render_surface->layer_list().clear(); + if (render_surface_) + render_surface_->ClearLayerLists(); } void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { @@ -519,9 +508,9 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { layer->SetDoubleSided(double_sided_); layer->SetDrawCheckerboardForMissingTiles( draw_checkerboard_for_missing_tiles_); - layer->SetForceRenderSurface(force_render_surface_); layer->SetDrawsContent(DrawsContent()); layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); + layer->SetHasRenderSurface(!!render_surface()); layer->SetFilters(filters()); layer->SetBackgroundFilters(background_filters()); layer->SetMasksToBounds(masks_to_bounds_); @@ -740,8 +729,8 @@ void LayerImpl::ResetAllChangeTrackingForSubtree() { update_rect_ = gfx::Rect(); damage_rect_ = gfx::RectF(); - if (draw_properties_.render_surface) - draw_properties_.render_surface->ResetPropertyChangedFlag(); + if (render_surface_) + render_surface_->ResetPropertyChangedFlag(); if (mask_layer_) mask_layer_->ResetAllChangeTrackingForSubtree(); @@ -1594,4 +1583,17 @@ void LayerImpl::NotifyAnimationFinished( layer_tree_impl_->InputScrollAnimationFinished(); } +void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { + if (!!render_surface() == should_have_render_surface) + return; + + SetNeedsPushProperties(); + layer_tree_impl()->set_needs_update_draw_properties(); + if (should_have_render_surface) { + render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); + return; + } + render_surface_.reset(); +} + } // namespace cc diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index 4fae166..1aaf5f2 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -222,9 +222,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, void SetHideLayerAndSubtree(bool hide); bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; } - bool force_render_surface() const { return force_render_surface_; } - void SetForceRenderSurface(bool force) { force_render_surface_ = force; } - void SetTransformOrigin(const gfx::Point3F& transform_origin); gfx::Point3F transform_origin() const { return transform_origin_; } @@ -303,9 +300,10 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, // These invalidate the host's render surface layer list. The caller // is responsible for calling set_needs_update_draw_properties on the tree // so that its list can be recreated. - void CreateRenderSurface(); - void ClearRenderSurface(); void ClearRenderSurfaceLayerList(); + void SetHasRenderSurface(bool has_render_surface); + + RenderSurfaceImpl* render_surface() const { return render_surface_.get(); } DrawProperties<LayerImpl>& draw_properties() { return draw_properties_; @@ -357,9 +355,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, draw_properties_.render_target->render_surface()); return draw_properties_.render_target; } - RenderSurfaceImpl* render_surface() const { - return draw_properties_.render_surface.get(); - } + int num_unclipped_descendants() const { return draw_properties_.num_unclipped_descendants; } @@ -567,14 +563,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, void Set3dSortingContextId(int id); int sorting_context_id() { return sorting_context_id_; } - // TODO(vollick): These is temporary and will be removed as soon as render - // surface determinations are moved out of CDP. They only exist because - // certain logic depends on whether or not a layer would render to a separate - // surface, but CDP destroys surfaces and targets it doesn't need, so without - // this boolean, this is impossible to determine after the fact without - // wastefully recomputing it. - void SetHasRenderSurface(bool value) {} - protected: LayerImpl(LayerTreeImpl* layer_impl, int id); @@ -655,7 +643,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, bool draw_checkerboard_for_missing_tiles_ : 1; bool draws_content_ : 1; bool hide_layer_and_subtree_ : 1; - bool force_render_surface_ : 1; // Cache transform_'s invertibility. bool transform_is_invertible_ : 1; @@ -729,7 +716,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, DrawProperties<LayerImpl> draw_properties_; scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_; - + scoped_ptr<RenderSurfaceImpl> render_surface_; DISALLOW_COPY_AND_ASSIGN(LayerImpl); }; diff --git a/cc/layers/layer_impl_unittest.cc b/cc/layers/layer_impl_unittest.cc index 7745d90..7b16710 100644 --- a/cc/layers/layer_impl_unittest.cc +++ b/cc/layers/layer_impl_unittest.cc @@ -101,6 +101,7 @@ TEST(LayerImplTest, VerifyLayerChangesAreTrackedProperly) { std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>(); scroll_children->insert(scroll_child); scroll_children->insert(root); + root->SetHasRenderSurface(true); scoped_ptr<LayerImpl> clip_parent = LayerImpl::Create(host_impl.active_tree(), 5); @@ -253,6 +254,7 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { host_impl.active_tree()->SetRootLayer( LayerImpl::Create(host_impl.active_tree(), 1)); LayerImpl* root = host_impl.active_tree()->root_layer(); + root->SetHasRenderSurface(true); scoped_ptr<LayerImpl> layer_ptr = LayerImpl::Create(host_impl.active_tree(), 2); LayerImpl* layer = layer_ptr.get(); @@ -276,6 +278,14 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; + // Render surface functions. + VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true)); + VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true)); + VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(false)); + // Create a render surface, because we must have a render surface if we have + // filters. + VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true)); + // Related filter functions. VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); diff --git a/cc/layers/layer_position_constraint_unittest.cc b/cc/layers/layer_position_constraint_unittest.cc index 5953f10..1c0619b 100644 --- a/cc/layers/layer_position_constraint_unittest.cc +++ b/cc/layers/layer_position_constraint_unittest.cc @@ -84,6 +84,7 @@ class LayerPositionConstraintTest : public testing::Test { scoped_ptr<LayerImpl> great_grand_child = LayerImpl::Create(host_impl_.active_tree(), 4); + root->SetHasRenderSurface(true); gfx::Transform IdentityMatrix; gfx::Point3F transform_origin; gfx::PointF position; @@ -599,7 +600,7 @@ TEST_F(LayerPositionConstraintTest, child->SetIsContainerForFixedPositionLayers(true); grand_child->SetPosition(gfx::PointF(8.f, 6.f)); - grand_child->SetForceRenderSurface(true); + grand_child->SetHasRenderSurface(true); great_grand_child->SetPositionConstraint(fixed_to_top_left_); great_grand_child->SetDrawsContent(true); @@ -739,9 +740,9 @@ TEST_F(LayerPositionConstraintTest, // Actually set up the scenario here. child->SetIsContainerForFixedPositionLayers(true); grand_child->SetPosition(gfx::PointF(8.f, 6.f)); - grand_child->SetForceRenderSurface(true); + grand_child->SetHasRenderSurface(true); great_grand_child->SetPosition(gfx::PointF(40.f, 60.f)); - great_grand_child->SetForceRenderSurface(true); + great_grand_child->SetHasRenderSurface(true); fixed_position_child->SetPositionConstraint(fixed_to_top_left_); fixed_position_child->SetDrawsContent(true); @@ -907,7 +908,7 @@ TEST_F(LayerPositionConstraintTest, LayerImpl* grand_child = child->children()[0]; child->SetIsContainerForFixedPositionLayers(true); - child->SetForceRenderSurface(true); + child->SetHasRenderSurface(true); grand_child->SetPositionConstraint(fixed_to_top_left_); grand_child->SetDrawsContent(true); diff --git a/cc/layers/nine_patch_layer_impl_unittest.cc b/cc/layers/nine_patch_layer_impl_unittest.cc index c901a97..de1bf40 100644 --- a/cc/layers/nine_patch_layer_impl_unittest.cc +++ b/cc/layers/nine_patch_layer_impl_unittest.cc @@ -50,7 +50,7 @@ void NinePatchLayerLayoutTest(const gfx::Size& bitmap_size, layer->draw_properties().visible_content_rect = visible_content_rect; layer->SetBounds(layer_size); layer->SetContentBounds(layer_size); - layer->CreateRenderSurface(); + layer->SetHasRenderSurface(true); layer->draw_properties().render_target = layer.get(); UIResourceId uid = 1; diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 65de537..ceac16d 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -209,6 +209,7 @@ class PictureLayerImplTest : public testing::Test { if (!tile_size.IsEmpty()) pending_layer->set_fixed_tile_size(tile_size); } + pending_root->SetHasRenderSurface(true); // The bounds() just mirror the pile size. pending_layer->SetBounds(raster_source->GetSize()); pending_layer->SetContentBounds(raster_source->GetSize()); @@ -1209,6 +1210,7 @@ TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { mask_ptr->SetContentBounds(layer_bounds); mask_ptr->SetDrawsContent(true); pending_layer_->SetMaskLayer(mask_ptr.Pass()); + pending_layer_->SetHasRenderSurface(true); time_ticks += base::TimeDelta::FromMilliseconds(1); host_impl_.SetCurrentBeginFrameArgs( @@ -1342,6 +1344,7 @@ TEST_F(PictureLayerImplTest, ScaledMaskLayer) { mask_ptr->SetContentBounds(layer_bounds); mask_ptr->SetDrawsContent(true); pending_layer_->SetMaskLayer(mask_ptr.Pass()); + pending_layer_->SetHasRenderSurface(true); time_ticks += base::TimeDelta::FromMilliseconds(1); host_impl_.SetCurrentBeginFrameArgs( diff --git a/cc/layers/render_surface_impl_unittest.cc b/cc/layers/render_surface_impl_unittest.cc index 6a96ba3..9934cd6 100644 --- a/cc/layers/render_surface_impl_unittest.cc +++ b/cc/layers/render_surface_impl_unittest.cc @@ -20,7 +20,7 @@ TEST(RenderSurfaceLayerImplTest, Occlusion) { owning_layer_impl->SetBounds(layer_size); owning_layer_impl->SetContentBounds(layer_size); owning_layer_impl->SetDrawsContent(true); - owning_layer_impl->SetForceRenderSurface(true); + owning_layer_impl->SetHasRenderSurface(true); impl.CalcDrawProps(viewport_size); diff --git a/cc/layers/render_surface_unittest.cc b/cc/layers/render_surface_unittest.cc index 6a3e168..6afbdcb 100644 --- a/cc/layers/render_surface_unittest.cc +++ b/cc/layers/render_surface_unittest.cc @@ -41,7 +41,7 @@ TEST(RenderSurfaceTest, VerifySurfaceChangesAreTrackedProperly) { FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); scoped_ptr<LayerImpl> owning_layer = LayerImpl::Create(host_impl.active_tree(), 1); - owning_layer->CreateRenderSurface(); + owning_layer->SetHasRenderSurface(true); ASSERT_TRUE(owning_layer->render_surface()); RenderSurfaceImpl* render_surface = owning_layer->render_surface(); gfx::Rect test_rect(3, 4, 5, 6); @@ -89,7 +89,7 @@ TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectSharedQuadState) { scoped_ptr<LayerImpl> owning_layer = LayerImpl::Create(host_impl.active_tree(), 2); - owning_layer->CreateRenderSurface(); + owning_layer->SetHasRenderSurface(true); ASSERT_TRUE(owning_layer->render_surface()); owning_layer->draw_properties().render_target = owning_layer.get(); @@ -159,7 +159,7 @@ TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectRenderPass) { scoped_ptr<LayerImpl> owning_layer = LayerImpl::Create(host_impl.active_tree(), 2); - owning_layer->CreateRenderSurface(); + owning_layer->SetHasRenderSurface(true); ASSERT_TRUE(owning_layer->render_surface()); owning_layer->draw_properties().render_target = owning_layer.get(); RenderSurfaceImpl* render_surface = owning_layer->render_surface(); diff --git a/cc/layers/solid_color_layer_impl_unittest.cc b/cc/layers/solid_color_layer_impl_unittest.cc index 320345f..7150f80 100644 --- a/cc/layers/solid_color_layer_impl_unittest.cc +++ b/cc/layers/solid_color_layer_impl_unittest.cc @@ -34,7 +34,7 @@ TEST(SolidColorLayerImplTest, VerifyTilingCompleteAndNoOverlap) { layer->draw_properties().visible_content_rect = visible_content_rect; layer->SetBounds(layer_size); layer->SetContentBounds(layer_size); - layer->CreateRenderSurface(); + layer->SetHasRenderSurface(true); layer->draw_properties().render_target = layer.get(); AppendQuadsData data; @@ -61,7 +61,7 @@ TEST(SolidColorLayerImplTest, VerifyCorrectBackgroundColorInQuad) { layer->SetBounds(layer_size); layer->SetContentBounds(layer_size); layer->SetBackgroundColor(test_color); - layer->CreateRenderSurface(); + layer->SetHasRenderSurface(true); layer->draw_properties().render_target = layer.get(); AppendQuadsData data; @@ -90,7 +90,7 @@ TEST(SolidColorLayerImplTest, VerifyCorrectOpacityInQuad) { layer->SetBounds(layer_size); layer->SetContentBounds(layer_size); layer->draw_properties().opacity = opacity; - layer->CreateRenderSurface(); + layer->SetHasRenderSurface(true); layer->draw_properties().render_target = layer.get(); AppendQuadsData data; diff --git a/cc/layers/tiled_layer_impl_unittest.cc b/cc/layers/tiled_layer_impl_unittest.cc index 689416a..148f36a 100644 --- a/cc/layers/tiled_layer_impl_unittest.cc +++ b/cc/layers/tiled_layer_impl_unittest.cc @@ -37,7 +37,7 @@ class TiledLayerImplTest : public testing::Test { layer->draw_properties().opacity = 1; layer->SetBounds(layer_size); layer->SetContentBounds(layer_size); - layer->CreateRenderSurface(); + layer->SetHasRenderSurface(true); layer->draw_properties().render_target = layer.get(); return layer.Pass(); } diff --git a/cc/layers/ui_resource_layer_impl_unittest.cc b/cc/layers/ui_resource_layer_impl_unittest.cc index dc24e1d..7149b07 100644 --- a/cc/layers/ui_resource_layer_impl_unittest.cc +++ b/cc/layers/ui_resource_layer_impl_unittest.cc @@ -32,7 +32,7 @@ scoped_ptr<UIResourceLayerImpl> GenerateUIResourceLayer( layer->draw_properties().visible_content_rect = visible_content_rect; layer->SetBounds(layer_size); layer->SetContentBounds(layer_size); - layer->CreateRenderSurface(); + layer->SetHasRenderSurface(true); layer->draw_properties().render_target = layer.get(); UIResourceBitmap bitmap(bitmap_size, opaque); diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc index c9a02af8..e9562c9 100644 --- a/cc/resources/tile_manager_unittest.cc +++ b/cc/resources/tile_manager_unittest.cc @@ -115,6 +115,7 @@ class TileManagerTilePriorityQueueTest : public testing::Test { pending_layer = FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, pile); pending_layer->SetDrawsContent(true); + pending_layer->SetHasRenderSurface(true); } // The bounds() just mirror the pile size. pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); diff --git a/cc/test/animation_test_common.cc b/cc/test/animation_test_common.cc index 602374f..ccd0828 100644 --- a/cc/test/animation_test_common.cc +++ b/cc/test/animation_test_common.cc @@ -174,6 +174,10 @@ bool FakeTransformTransition::AffectsScale() const { return false; } bool FakeTransformTransition::IsTranslation() const { return true; } +bool FakeTransformTransition::PreservesAxisAlignment() const { + return true; +} + bool FakeTransformTransition::MaximumTargetScale(bool forward_direction, float* max_scale) const { *max_scale = 1.f; diff --git a/cc/test/animation_test_common.h b/cc/test/animation_test_common.h index 2c41518..b2909b8 100644 --- a/cc/test/animation_test_common.h +++ b/cc/test/animation_test_common.h @@ -45,6 +45,7 @@ class FakeTransformTransition : public TransformAnimationCurve { gfx::BoxF* bounds) const override; bool AffectsScale() const override; bool IsTranslation() const override; + bool PreservesAxisAlignment() const override; bool MaximumTargetScale(bool forward_direction, float* max_scale) const override; diff --git a/cc/test/layer_test_common.cc b/cc/test/layer_test_common.cc index 762e82d..99d3c1c 100644 --- a/cc/test/layer_test_common.cc +++ b/cc/test/layer_test_common.cc @@ -103,6 +103,7 @@ LayerTestCommon::LayerImplTest::LayerImplTest() host_(FakeLayerTreeHost::Create(&client_)), root_layer_impl_(LayerImpl::Create(host_->host_impl()->active_tree(), 1)), render_pass_(RenderPass::Create()) { + root_layer_impl_->SetHasRenderSurface(true); scoped_ptr<FakeOutputSurface> output_surface = FakeOutputSurface::Create3d(); host_->host_impl()->InitializeRenderer(FakeOutputSurface::Create3d()); } diff --git a/cc/test/layer_tree_host_common_test.cc b/cc/test/layer_tree_host_common_test.cc index 8441657..d91652f 100644 --- a/cc/test/layer_tree_host_common_test.cc +++ b/cc/test/layer_tree_host_common_test.cc @@ -27,13 +27,9 @@ void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting( const gfx::Size& bounds, bool flatten_transform, bool is_3d_sorted) { - SetLayerPropertiesForTestingInternal<Layer>(layer, - transform, - transform_origin, - position, - bounds, - flatten_transform, - is_3d_sorted); + SetLayerPropertiesForTestingInternal(layer, transform, transform_origin, + position, bounds, flatten_transform, + is_3d_sorted); } void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting( @@ -43,14 +39,15 @@ void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting( const gfx::PointF& position, const gfx::Size& bounds, bool flatten_transform, - bool is_3d_sorted) { - SetLayerPropertiesForTestingInternal<LayerImpl>(layer, - transform, - transform_origin, - position, - bounds, - flatten_transform, - is_3d_sorted); + bool is_3d_sorted, + bool create_render_surface) { + SetLayerPropertiesForTestingInternal(layer, transform, transform_origin, + position, bounds, flatten_transform, + is_3d_sorted); + if (create_render_surface) { + layer->SetHasRenderSurface(true); + } + layer->SetContentBounds(bounds); } diff --git a/cc/test/layer_tree_host_common_test.h b/cc/test/layer_tree_host_common_test.h index 456183f..d899bab 100644 --- a/cc/test/layer_tree_host_common_test.h +++ b/cc/test/layer_tree_host_common_test.h @@ -62,7 +62,8 @@ class LayerTreeHostCommonTestBase { const gfx::PointF& position, const gfx::Size& bounds, bool flatten_transform, - bool is_3d_sorted); + bool is_3d_sorted, + bool create_render_surface); void ExecuteCalculateDrawProperties(Layer* root_layer, float device_scale_factor, diff --git a/cc/test/tiled_layer_test_common.cc b/cc/test/tiled_layer_test_common.cc index ca86499..7d810d1 100644 --- a/cc/test/tiled_layer_test_common.cc +++ b/cc/test/tiled_layer_test_common.cc @@ -99,8 +99,10 @@ void FakeTiledLayer::SetTexturePriorities( // itself. bool missing_target_render_surface = !render_target(); - if (missing_target_render_surface) + if (missing_target_render_surface) { CreateRenderSurface(); + draw_properties().render_target = this; + } TiledLayer::SetTexturePriorities(calculator); diff --git a/cc/trees/damage_tracker_unittest.cc b/cc/trees/damage_tracker_unittest.cc index 90b5b8a..95609d3 100644 --- a/cc/trees/damage_tracker_unittest.cc +++ b/cc/trees/damage_tracker_unittest.cc @@ -86,7 +86,7 @@ class DamageTrackerTest : public testing::Test { root->SetBounds(gfx::Size(500, 500)); root->SetContentBounds(gfx::Size(500, 500)); root->SetDrawsContent(true); - root->CreateRenderSurface(); + root->SetHasRenderSurface(true); root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500)); child->SetPosition(gfx::PointF(100.f, 100.f)); @@ -118,7 +118,7 @@ class DamageTrackerTest : public testing::Test { root->SetBounds(gfx::Size(500, 500)); root->SetContentBounds(gfx::Size(500, 500)); root->SetDrawsContent(true); - root->CreateRenderSurface(); + root->SetHasRenderSurface(true); root->render_surface()->SetContentRect(gfx::Rect(0, 0, 500, 500)); child1->SetPosition(gfx::PointF(100.f, 100.f)); @@ -126,11 +126,9 @@ class DamageTrackerTest : public testing::Test { child1->SetContentBounds(gfx::Size(30, 30)); // With a child that draws_content, opacity will cause the layer to create // its own RenderSurface. This layer does not draw, but is intended to - // create its own RenderSurface. TODO: setting opacity and - // ForceRenderSurface may be redundant here. - child1->SetOpacity(0.5f); + // create its own RenderSurface. child1->SetDrawsContent(false); - child1->SetForceRenderSurface(true); + child1->SetHasRenderSurface(true); child2->SetPosition(gfx::PointF(11.f, 11.f)); child2->SetBounds(gfx::Size(18, 18)); @@ -542,6 +540,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForImageFilter) { // Setting the filter will damage the whole surface. ClearDamageForAllSurfaces(root.get()); + child->SetHasRenderSurface(true); child->SetFilters(filters); EmulateDrawingOneFrame(root.get()); root_damage_rect = @@ -926,8 +925,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { // CASE 1: If a descendant surface disappears, its entire old area becomes // exposed. ClearDamageForAllSurfaces(root.get()); - child1->SetOpacity(1.f); - child1->SetForceRenderSurface(false); + child1->SetHasRenderSurface(false); EmulateDrawingOneFrame(root.get()); // Sanity check that there is only one surface now. @@ -952,8 +950,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForAddingAndRemovingRenderSurfaces) { // Then change the tree so that the render surface is added back. ClearDamageForAllSurfaces(root.get()); - child1->SetOpacity(0.5f); - child1->SetForceRenderSurface(true); + child1->SetHasRenderSurface(true); + EmulateDrawingOneFrame(root.get()); // Sanity check that there is a new surface now. @@ -1056,6 +1054,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplica) { reflection.Scale3d(-1.0, 1.0, 1.0); grand_child1_replica->SetTransform(reflection); grand_child1->SetReplicaLayer(grand_child1_replica.Pass()); + grand_child1->SetHasRenderSurface(true); } EmulateDrawingOneFrame(root.get()); @@ -1106,6 +1105,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplica) { // reflection to damage the target surface. ClearDamageForAllSurfaces(root.get()); grand_child1->SetReplicaLayer(nullptr); + grand_child1->SetHasRenderSurface(false); EmulateDrawingOneFrame(root.get()); ASSERT_EQ(old_content_rect.width(), child1->render_surface()->content_rect().width()); @@ -1140,12 +1140,12 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) { mask_layer->SetBounds(child->bounds()); mask_layer->SetContentBounds(child->bounds()); child->SetMaskLayer(mask_layer.Pass()); + child->SetHasRenderSurface(true); } LayerImpl* mask_layer = child->mask_layer(); // Add opacity and a grand_child so that the render surface persists even // after we remove the mask. - child->SetOpacity(0.5f); { scoped_ptr<LayerImpl> grand_child = LayerImpl::Create(host_impl_.active_tree(), 4); @@ -1157,9 +1157,6 @@ TEST_F(DamageTrackerTest, VerifyDamageForMask) { } EmulateDrawingOneFrame(root.get()); - // Sanity check that a new surface was created for the child. - ASSERT_TRUE(child->render_surface()); - // CASE 1: the update_rect on a mask layer should damage the entire target // surface. ClearDamageForAllSurfaces(root.get()); @@ -1233,6 +1230,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplicaMask) { reflection.Scale3d(-1.0, 1.0, 1.0); grand_child1_replica->SetTransform(reflection); grand_child1->SetReplicaLayer(grand_child1_replica.Pass()); + grand_child1->SetHasRenderSurface(true); } LayerImpl* grand_child1_replica = grand_child1->replica_layer(); @@ -1310,6 +1308,7 @@ TEST_F(DamageTrackerTest, VerifyDamageForReplicaMaskWithTransformOrigin) { reflection.Scale3d(-1.0, 1.0, 1.0); grand_child1_replica->SetTransform(reflection); grand_child1->SetReplicaLayer(grand_child1_replica.Pass()); + grand_child1->SetHasRenderSurface(true); } LayerImpl* grand_child1_replica = grand_child1->replica_layer(); @@ -1377,7 +1376,8 @@ TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) { // tracker does not crash when it receives an empty layer_list. scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.active_tree(), 1); - root->CreateRenderSurface(); + root->SetHasRenderSurface(true); + root->draw_properties().render_target = root.get(); ASSERT_TRUE(root == root->render_target()); RenderSurfaceImpl* target_surface = root->render_surface(); diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index 2022f46..b33d633 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -553,9 +553,8 @@ static inline void SavePaintPropertiesLayer(Layer* layer) { layer->replica_layer()->mask_layer()->SavePaintProperties(); } -template <typename LayerType> static bool SubtreeShouldRenderToSeparateSurface( - LayerType* layer, + Layer* layer, bool axis_aligned_with_respect_to_parent) { // // A layer and its descendants should render onto a new RenderSurfaceImpl if @@ -1111,18 +1110,6 @@ static inline void CalculateAnimationContentsScale( std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y()); } -template <typename LayerType> -static inline typename LayerType::RenderSurfaceType* CreateOrReuseRenderSurface( - LayerType* layer) { - if (!layer->render_surface()) { - layer->CreateRenderSurface(); - return layer->render_surface(); - } - - layer->render_surface()->ClearLayerLists(); - return layer->render_surface(); -} - template <typename LayerTypePtr> static inline void MarkLayerWithRenderSurfaceLayerListId( LayerTypePtr layer, @@ -1206,12 +1193,29 @@ struct PreCalculateMetaInformationRecursiveData { } }; +static bool ValidateRenderSurface(LayerImpl* layer) { + // There are a few cases in which it is incorrect to not have a + // render_surface. + if (layer->render_surface()) + return true; + + return layer->filters().IsEmpty() && layer->background_filters().IsEmpty() && + !layer->mask_layer() && !layer->replica_layer() && + !IsRootLayer(layer) && !layer->is_root_for_isolated_group() && + !layer->HasCopyRequest(); +} + +static bool ValidateRenderSurface(Layer* layer) { + return true; +} + // 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, PreCalculateMetaInformationRecursiveData* recursive_data) { + DCHECK(ValidateRenderSurface(layer)); layer->draw_properties().sorted_for_recursion = false; layer->draw_properties().has_child_with_a_scroll_parent = false; @@ -1609,6 +1613,7 @@ static void CalculateDrawPropertiesInternal( if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { if (layer->render_surface()) layer->ClearRenderSurfaceLayerList(); + layer->draw_properties().render_target = nullptr; return; } @@ -1834,28 +1839,26 @@ static void CalculateDrawPropertiesInternal( ? combined_transform_scales : gfx::Vector2dF(layer_scale_factors, layer_scale_factors); - bool render_to_separate_surface; - if (globals.can_render_to_separate_surface) { - render_to_separate_surface = SubtreeShouldRenderToSeparateSurface( - layer, combined_transform.Preserves2dAxisAlignment()); - } else { - render_to_separate_surface = IsRootLayer(layer); - } - - layer->SetHasRenderSurface(render_to_separate_surface); + bool render_to_separate_surface = + IsRootLayer(layer) || + (globals.can_render_to_separate_surface && layer->render_surface()); if (render_to_separate_surface) { + DCHECK(layer->render_surface()); // Check back-face visibility before continuing with this surface and its // subtree if (!layer->double_sided() && TransformToParentIsKnown(layer) && IsSurfaceBackFaceVisible(layer, combined_transform)) { layer->ClearRenderSurfaceLayerList(); + layer->draw_properties().render_target = nullptr; return; } typename LayerType::RenderSurfaceType* render_surface = - CreateOrReuseRenderSurface(layer); + layer->render_surface(); + layer->ClearRenderSurfaceLayerList(); + layer_draw_properties.render_target = layer; if (IsRootLayer(layer)) { // The root layer's render surface size is predetermined and so the root // layer can't directly support non-identity transforms. It should just @@ -2035,8 +2038,6 @@ static void CalculateDrawPropertiesInternal( animating_opacity_to_screen; data_for_children.parent_matrix = combined_transform; - layer->ClearRenderSurface(); - // Layers without render_surfaces directly inherit the ancestor's clip // status. layer_or_ancestor_clips_descendants = ancestor_clips_subtree; @@ -2077,7 +2078,7 @@ static void CalculateDrawPropertiesInternal( if (LayerClipsSubtree(layer)) { layer_or_ancestor_clips_descendants = true; - if (ancestor_clips_subtree && !layer->render_surface()) { + if (ancestor_clips_subtree && !render_to_separate_surface) { // A layer without render surface shares the same target as its ancestor. clip_rect_in_target_space = ancestor_clip_rect_in_target_space; @@ -2102,8 +2103,8 @@ static void CalculateDrawPropertiesInternal( } typename LayerType::LayerListType& descendants = - (layer->render_surface() ? layer->render_surface()->layer_list() - : *layer_list); + (render_to_separate_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. @@ -2185,7 +2186,8 @@ static void CalculateDrawPropertiesInternal( &descendants, accumulated_surface_state, current_render_surface_layer_list_id); - if (child->render_surface() && + // If the child is its own render target, then it has a render surface. + if (child->render_target() == child && !child->render_surface()->layer_list().empty() && !child->render_surface()->content_rect().IsEmpty()) { // This child will contribute its render surface, which means @@ -2224,12 +2226,12 @@ static void CalculateDrawPropertiesInternal( // target surface space). gfx::Rect local_drawable_content_rect_of_subtree = accumulated_surface_state->back().drawable_content_rect; - if (layer->render_surface()) { + if (render_to_separate_surface) { DCHECK(accumulated_surface_state->back().render_target == layer); accumulated_surface_state->pop_back(); } - if (layer->render_surface() && !IsRootLayer(layer) && + if (render_to_separate_surface && !IsRootLayer(layer) && layer->render_surface()->layer_list().empty()) { RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); return; @@ -2255,10 +2257,10 @@ static void CalculateDrawPropertiesInternal( // one. if (IsRootLayer(layer)) { // The root layer's surface's content_rect is always the entire viewport. - DCHECK(layer->render_surface()); + DCHECK(render_to_separate_surface); layer->render_surface()->SetContentRect( ancestor_clip_rect_in_target_space); - } else if (layer->render_surface()) { + } else if (render_to_separate_surface) { typename LayerType::RenderSurfaceType* render_surface = layer->render_surface(); gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree; @@ -2352,7 +2354,7 @@ static void CalculateDrawPropertiesInternal( // If neither this layer nor any of its children were added, early out. if (sorting_start_index == descendants.size()) { - DCHECK(!layer->render_surface() || IsRootLayer(layer)); + DCHECK(!render_to_separate_surface || IsRootLayer(layer)); return; } @@ -2435,6 +2437,49 @@ static void ProcessCalcDrawPropsInputs( data_for_recursion->subtree_is_visible_from_ancestor = true; } +void LayerTreeHostCommon::UpdateRenderSurface( + Layer* layer, + bool can_render_to_separate_surface, + gfx::Transform* transform, + bool* draw_transform_is_axis_aligned) { + bool preserves_2d_axis_alignment = + transform->Preserves2dAxisAlignment() && *draw_transform_is_axis_aligned; + if (IsRootLayer(layer) || (can_render_to_separate_surface && + SubtreeShouldRenderToSeparateSurface( + layer, preserves_2d_axis_alignment))) { + // We reset the transform here so that any axis-changing transforms + // will now be relative to this RenderSurface. + transform->MakeIdentity(); + *draw_transform_is_axis_aligned = true; + if (!layer->render_surface()) { + layer->CreateRenderSurface(); + } + layer->SetHasRenderSurface(true); + return; + } + layer->SetHasRenderSurface(false); + if (layer->render_surface()) + layer->ClearRenderSurface(); +} + +void LayerTreeHostCommon::UpdateRenderSurfaces( + Layer* layer, + bool can_render_to_separate_surface, + const gfx::Transform& parent_transform, + bool draw_transform_is_axis_aligned) { + gfx::Transform transform_for_children = layer->transform(); + transform_for_children *= parent_transform; + draw_transform_is_axis_aligned &= layer->AnimationsPreserveAxisAlignment(); + UpdateRenderSurface(layer, can_render_to_separate_surface, + &transform_for_children, &draw_transform_is_axis_aligned); + + for (size_t i = 0; i < layer->children().size(); ++i) { + UpdateRenderSurfaces(layer->children()[i].get(), + can_render_to_separate_surface, transform_for_children, + draw_transform_is_axis_aligned); + } +} + static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) { static const int tolerance = 1; return std::abs(r1.x() - r2.x()) <= tolerance && @@ -2445,6 +2490,9 @@ static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) { void LayerTreeHostCommon::CalculateDrawProperties( CalcDrawPropsMainInputs* inputs) { + UpdateRenderSurfaces(inputs->root_layer, + inputs->can_render_to_separate_surface, gfx::Transform(), + false); LayerList dummy_layer_list; SubtreeGlobals<Layer> globals; DataForRecursion<Layer> data_for_recursion; diff --git a/cc/trees/layer_tree_host_common.h b/cc/trees/layer_tree_host_common.h index 678ed75..0955b9a 100644 --- a/cc/trees/layer_tree_host_common.h +++ b/cc/trees/layer_tree_host_common.h @@ -106,6 +106,14 @@ class CC_EXPORT LayerTreeHostCommon { CalcDrawPropsMainInputs; typedef CalcDrawPropsInputsForTesting<Layer, RenderSurfaceLayerList> CalcDrawPropsMainInputsForTesting; + static void UpdateRenderSurfaces(Layer* root_layer, + bool can_render_to_separate_surface, + const gfx::Transform& transform, + bool preserves_2d_axis_alignment); + static void UpdateRenderSurface(Layer* layer, + bool can_render_to_separate_surface, + gfx::Transform* transform, + bool* animation_preserves_axis_alignment); static void CalculateDrawProperties(CalcDrawPropsMainInputs* inputs); typedef CalcDrawPropsInputs<LayerImpl, LayerImplList> CalcDrawPropsImplInputs; diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 6581a71..72eb287 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -323,23 +323,15 @@ TEST_F(LayerTreeHostCommonTest, TransformsAboutScrollOffset) { LayerImpl* sublayer = sublayer_scoped_ptr.get(); sublayer->SetContentsScale(kPageScale * kDeviceScale, kPageScale * kDeviceScale); - SetLayerPropertiesForTesting(sublayer, - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(500, 500), - true, + SetLayerPropertiesForTesting(sublayer, identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(500, 500), true, false, false); scoped_ptr<LayerImpl> scroll_layer_scoped_ptr( LayerImpl::Create(host_impl.active_tree(), 2)); LayerImpl* scroll_layer = scroll_layer_scoped_ptr.get(); - SetLayerPropertiesForTesting(scroll_layer, - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(10, 20), - true, + SetLayerPropertiesForTesting(scroll_layer, identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(10, 20), true, false, false); scoped_ptr<LayerImpl> clip_layer_scoped_ptr( LayerImpl::Create(host_impl.active_tree(), 4)); @@ -358,14 +350,11 @@ TEST_F(LayerTreeHostCommonTest, TransformsAboutScrollOffset) { scroll_layer_raw_ptr->SetScrollOffset(kScrollOffset); scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(3, 4), - true, + SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(3, 4), true, false, false); root->AddChild(clip_layer_scoped_ptr.Pass()); + root->SetHasRenderSurface(true); ExecuteCalculateDrawProperties( root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); @@ -383,13 +372,9 @@ TEST_F(LayerTreeHostCommonTest, TransformsAboutScrollOffset) { const float kTranslateX = 10.6f; const float kTranslateY = 20.6f; arbitrary_translate.Translate(kTranslateX, kTranslateY); - SetLayerPropertiesForTesting(scroll_layer, - arbitrary_translate, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(10, 20), - true, - false); + SetLayerPropertiesForTesting(scroll_layer, arbitrary_translate, + gfx::Point3F(), gfx::PointF(), gfx::Size(10, 20), + true, false, false); ExecuteCalculateDrawProperties( root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); expected_transform.MakeIdentity(); @@ -3794,11 +3779,13 @@ TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) { inputs.can_adjust_raster_scales = true; LayerTreeHostCommon::CalculateDrawProperties(&inputs); - // Verify which render surfaces were created. + // Verify which render surfaces were created and used. EXPECT_FALSE(front_facing_child->render_surface()); EXPECT_FALSE(back_facing_child->render_surface()); EXPECT_TRUE(front_facing_surface->render_surface()); - EXPECT_FALSE(back_facing_surface->render_surface()); + EXPECT_NE(back_facing_surface->render_target(), back_facing_surface); + // We expect that a render_surface was created but not used. + EXPECT_TRUE(back_facing_surface->render_surface()); EXPECT_FALSE(front_facing_child_of_front_facing_surface->render_surface()); EXPECT_FALSE(back_facing_child_of_front_facing_surface->render_surface()); EXPECT_FALSE(front_facing_child_of_back_facing_surface->render_surface()); @@ -4062,10 +4049,13 @@ TEST_F(LayerTreeHostCommonTest, inputs.can_adjust_raster_scales = true; LayerTreeHostCommon::CalculateDrawProperties(&inputs); - // Verify which render surfaces were created. + // Verify which render surfaces were created and used. EXPECT_TRUE(front_facing_surface->render_surface()); - EXPECT_FALSE( - back_facing_surface->render_surface()); // because it should be culled + + // We expect the render surface to have been created, but remain unused. + EXPECT_TRUE(back_facing_surface->render_surface()); + EXPECT_NE(back_facing_surface->render_target(), + back_facing_surface); // because it should be culled EXPECT_FALSE(child1->render_surface()); EXPECT_FALSE(child2->render_surface()); @@ -5646,22 +5636,14 @@ TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); const gfx::Transform identity_matrix; - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(100, 100), - true, + SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(100, 100), true, false, false); root->SetDrawsContent(true); scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); - SetLayerPropertiesForTesting(child.get(), - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(50, 50), - true, + SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(50, 50), true, false, false); child->SetDrawsContent(true); child->SetOpacity(0.0f); @@ -5671,6 +5653,7 @@ TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { child->layer_animation_controller(), 10.0, 0.0f, 1.0f, false); root->AddChild(child.Pass()); + root->SetHasRenderSurface(true); LayerImplList render_surface_layer_list; LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( @@ -5933,39 +5916,28 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { const gfx::Transform identity_matrix; scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(50, 50), - true, + SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(50, 50), true, false, false); root->SetDrawsContent(true); scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); - SetLayerPropertiesForTesting(child.get(), - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(40, 40), - true, + SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(40, 40), true, false, false); child->SetDrawsContent(true); scoped_ptr<LayerImpl> grand_child = LayerImpl::Create(host_impl.pending_tree(), 3); - SetLayerPropertiesForTesting(grand_child.get(), - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(30, 30), - true, - false); + SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, + gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), + true, false, false); grand_child->SetDrawsContent(true); grand_child->SetHideLayerAndSubtree(true); child->AddChild(grand_child.Pass()); root->AddChild(child.Pass()); + root->SetHasRenderSurface(true); LayerImplList render_surface_layer_list; LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( @@ -6046,35 +6018,23 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { const gfx::Transform identity_matrix; scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.pending_tree(), 1); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(50, 50), - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(50, 50), true, false, + true); root->SetDrawsContent(true); scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); - SetLayerPropertiesForTesting(child.get(), - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(40, 40), - true, + SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(40, 40), true, false, false); child->SetDrawsContent(true); child->SetHideLayerAndSubtree(true); scoped_ptr<LayerImpl> grand_child = LayerImpl::Create(host_impl.pending_tree(), 3); - SetLayerPropertiesForTesting(grand_child.get(), - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(30, 30), - true, - false); + SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, + gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), + true, false, false); grand_child->SetDrawsContent(true); child->AddChild(grand_child.Pass()); @@ -6945,40 +6905,20 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetDrawsContent(true); // This layer structure normally forces render surface due to preserves3d // behavior. - SetLayerPropertiesForTesting(child1.get(), - identity_matrix, - transform_origin, - position, - bounds, - false, - true); + SetLayerPropertiesForTesting(child1.get(), identity_matrix, transform_origin, + position, bounds, false, true, true); child1->SetDrawsContent(true); - SetLayerPropertiesForTesting(child2.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child2.get(), identity_matrix, transform_origin, + position, bounds, true, false, false); child2->SetDrawsContent(true); - SetLayerPropertiesForTesting(child3.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child3.get(), identity_matrix, transform_origin, + position, bounds, true, false, false); child3->SetDrawsContent(true); child2->Set3dSortingContextId(1); @@ -7620,55 +7560,27 @@ TEST_F(LayerTreeHostCommonTest, DoNotClobberSorting) { gfx::Transform bottom_transform; bottom_transform.Translate3d(0.0, 0.0, 3.0); - SetLayerPropertiesForTesting(root.get(), - identity_transform, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(50, 50), - true, - false); - SetLayerPropertiesForTesting(scroll_parent_border.get(), - identity_transform, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(40, 40), - true, - false); - SetLayerPropertiesForTesting(scroll_parent_clip.get(), - identity_transform, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(30, 30), - true, - false); - SetLayerPropertiesForTesting(scroll_parent.get(), - identity_transform, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(50, 50), - true, - false); - SetLayerPropertiesForTesting(scroll_child.get(), - identity_transform, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(50, 50), - true, - false); - SetLayerPropertiesForTesting(top_content.get(), - top_transform, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(50, 50), - false, + SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), + gfx::PointF(), gfx::Size(50, 50), true, false, true); - SetLayerPropertiesForTesting(bottom_content.get(), - bottom_transform, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(50, 50), - false, + SetLayerPropertiesForTesting(scroll_parent_border.get(), identity_transform, + gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), + true, false, false); + SetLayerPropertiesForTesting(scroll_parent_clip.get(), identity_transform, + gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), + true, false, false); + SetLayerPropertiesForTesting(scroll_parent.get(), identity_transform, + gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), + true, false, false); + SetLayerPropertiesForTesting(scroll_child.get(), identity_transform, + gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), + true, false, false); + SetLayerPropertiesForTesting(top_content.get(), top_transform, gfx::Point3F(), + gfx::PointF(), gfx::Size(50, 50), false, true, true); + SetLayerPropertiesForTesting(bottom_content.get(), bottom_transform, + gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), + false, true, true); scroll_child->SetShouldFlattenTransform(false); scroll_child->Set3dSortingContextId(1); @@ -7738,33 +7650,17 @@ TEST_F(LayerTreeHostCommonTest, ScrollCompensationWithRounding) { container_transform.Translate3d(10.0, 20.0, 0.0); gfx::Vector2dF container_offset = container_transform.To2dTranslation(); - SetLayerPropertiesForTesting(root.get(), - identity_transform, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(50, 50), - true, - false); - SetLayerPropertiesForTesting(container.get(), - container_transform, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(40, 40), - true, - false); - SetLayerPropertiesForTesting(scroller.get(), - identity_transform, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(30, 30), - true, - false); - SetLayerPropertiesForTesting(fixed.get(), - identity_transform, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(50, 50), - true, + SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), + gfx::PointF(), gfx::Size(50, 50), true, false, + true); + SetLayerPropertiesForTesting(container.get(), container_transform, + gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), + true, false, false); + SetLayerPropertiesForTesting(scroller.get(), identity_transform, + gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), + true, false, false); + SetLayerPropertiesForTesting(fixed.get(), identity_transform, gfx::Point3F(), + gfx::PointF(), gfx::Size(50, 50), true, false, false); scroller->AddChild(fixed.Pass()); @@ -7902,33 +7798,18 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { parent->AddChild(child.Pass()); grand_parent->AddChild(parent.Pass()); - SetLayerPropertiesForTesting(grand_parent.get(), - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(1, 2), - true, + SetLayerPropertiesForTesting(grand_parent.get(), identity_matrix, + gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), + true, false, true); + SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(1, 2), true, false, false); - SetLayerPropertiesForTesting(parent_raw, - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(1, 2), - true, - false); - SetLayerPropertiesForTesting(child_raw, - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(1, 2), - true, + SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(1, 2), true, false, false); - SetLayerPropertiesForTesting(grand_child_raw, - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(1, 2), - true, + + SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(1, 2), true, false, false); ExecuteCalculateDrawProperties(grand_parent.get()); @@ -8138,42 +8019,25 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { parent->AddChild(child.Pass()); grand_parent->AddChild(parent.Pass()); - SetLayerPropertiesForTesting(grand_parent_raw, - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(1, 2), - true, - false); - SetLayerPropertiesForTesting(parent_raw, - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(1, 2), - true, - false); - SetLayerPropertiesForTesting(child_raw, - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(1, 2), - true, - false); - SetLayerPropertiesForTesting(grand_child1_raw, - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(1, 2), - true, + SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix, + gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), + true, false, true); + SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(1, 2), true, false, false); - SetLayerPropertiesForTesting(grand_child2_raw, - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(1, 2), - true, + + SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(1, 2), true, false, false); + SetLayerPropertiesForTesting(grand_child1_raw, identity_matrix, + gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), + true, false, false); + + SetLayerPropertiesForTesting(grand_child2_raw, identity_matrix, + gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), + true, false, false); + // Start with nothing being drawn. ExecuteCalculateDrawProperties(grand_parent_raw); int member_id = render_surface_layer_list_count(); @@ -8191,7 +8055,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { // If we force render surface, but none of the layers are in the layer list, // then this layer should not appear in RSLL. - grand_child1_raw->SetForceRenderSurface(true); + grand_child1_raw->SetHasRenderSurface(true); ExecuteCalculateDrawProperties(grand_parent_raw); member_id = render_surface_layer_list_count(); @@ -8230,8 +8094,8 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { // Now child is forced to have a render surface, and one if its children draws // content. grand_child1_raw->SetDrawsContent(false); - grand_child1_raw->SetForceRenderSurface(false); - child_raw->SetForceRenderSurface(true); + grand_child1_raw->SetHasRenderSurface(false); + child_raw->SetHasRenderSurface(true); grand_child2_raw->SetDrawsContent(true); ExecuteCalculateDrawProperties(grand_parent_raw); @@ -8386,34 +8250,29 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) { root->AddChild(child1.Pass()); root->AddChild(child2.Pass()); + root->SetHasRenderSurface(true); gfx::Transform identity_matrix, scale_transform_child1, scale_transform_child2; scale_transform_child1.Scale(2, 3); scale_transform_child2.Scale(4, 5); - SetLayerPropertiesForTesting(root_layer, - identity_matrix, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(1, 1), - true, - false); - SetLayerPropertiesForTesting(child1_layer, - scale_transform_child1, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(), - true, - false); + SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), + gfx::PointF(), gfx::Size(1, 1), true, false, + true); + SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, + gfx::Point3F(), gfx::PointF(), gfx::Size(), true, + false, false); child1_layer->SetMaskLayer( LayerImpl::Create(host_impl.active_tree(), 4).Pass()); scoped_ptr<LayerImpl> replica_layer = LayerImpl::Create(host_impl.active_tree(), 5); + replica_layer->SetHasRenderSurface(true); replica_layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6)); child1_layer->SetReplicaLayer(replica_layer.Pass()); + child1_layer->SetHasRenderSurface(true); ExecuteCalculateDrawProperties(root_layer); @@ -8421,13 +8280,9 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) { scale.AppendScale(5.f, 8.f, 3.f); AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), scale); - SetLayerPropertiesForTesting(child2_layer, - scale_transform_child2, - gfx::Point3F(), - gfx::PointF(), - gfx::Size(), - true, - false); + SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, + gfx::Point3F(), gfx::PointF(), gfx::Size(), true, + false, false); ExecuteCalculateDrawProperties(root_layer); @@ -8688,7 +8543,8 @@ TEST_F(LayerTreeHostCommonTest, BoundsDeltaAffectVisibleContentRect) { gfx::PointF(), root_size, false, - false); + false, + true); root->SetContentBounds(root_size); root->SetMasksToBounds(true); @@ -8702,6 +8558,7 @@ TEST_F(LayerTreeHostCommonTest, BoundsDeltaAffectVisibleContentRect) { gfx::PointF(), sublayer_size, false, + false, false); sublayer->SetContentBounds(sublayer_size); diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index b536173..fb2fdb6 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -50,6 +50,7 @@ #include "cc/test/fake_video_frame_provider.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/layer_test_common.h" +#include "cc/test/layer_tree_test.h" #include "cc/test/render_pass_test_common.h" #include "cc/test/test_gpu_memory_buffer_manager.h" #include "cc/test/test_shared_bitmap_manager.h" @@ -180,6 +181,7 @@ class LayerTreeHostImplTest : public testing::Test, root->SetContentBounds(gfx::Size(10, 10)); root->SetDrawsContent(true); root->draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10); + root->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(root.Pass()); } @@ -226,6 +228,7 @@ class LayerTreeHostImplTest : public testing::Test, root->SetBounds(content_size); root->SetContentBounds(content_size); root->SetPosition(gfx::PointF()); + root->SetHasRenderSurface(true); scoped_ptr<LayerImpl> scroll = LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); @@ -567,20 +570,6 @@ TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); } -TEST_F(LayerTreeHostImplTest, ClearRootRenderSurfaceAndScroll) { - SetupScrollAndContentsLayers(gfx::Size(100, 100)); - host_impl_->SetViewportSize(gfx::Size(50, 50)); - DrawFrame(); - - // We should be able to scroll even if the root layer loses its render surface - // after the most recent render. - host_impl_->active_tree()->root_layer()->ClearRenderSurface(); - host_impl_->active_tree()->set_needs_update_draw_properties(); - - EXPECT_EQ(InputHandler::ScrollStarted, - host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); -} - TEST_F(LayerTreeHostImplTest, WheelEventHandlers) { SetupScrollAndContentsLayers(gfx::Size(100, 100)); host_impl_->SetViewportSize(gfx::Size(50, 50)); @@ -896,20 +885,6 @@ TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); } -TEST_F(LayerTreeHostImplTest, - ClearRootRenderSurfaceAndHitTestTouchHandlerRegion) { - SetupScrollAndContentsLayers(gfx::Size(100, 100)); - host_impl_->SetViewportSize(gfx::Size(50, 50)); - DrawFrame(); - - // We should be able to hit test for touch event handlers even if the root - // layer loses its render surface after the most recent render. - host_impl_->active_tree()->root_layer()->ClearRenderSurface(); - host_impl_->active_tree()->set_needs_update_draw_properties(); - - EXPECT_EQ(host_impl_->HaveTouchEventHandlersAt(gfx::Point()), false); -} - TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); host_impl_->SetViewportSize(gfx::Size(50, 50)); @@ -1438,6 +1413,7 @@ class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { \ scroll->AddChild(contents.Pass()); \ root->AddChild(scroll.Pass()); \ + root->SetHasRenderSurface(true); \ scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \ root->AddChild(scrollbar.Pass()); \ \ @@ -1582,6 +1558,7 @@ void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); root->SetBounds(viewport_size); + root->SetHasRenderSurface(true); scoped_ptr<LayerImpl> scroll = LayerImpl::Create(host_impl_->active_tree(), 2); @@ -1787,6 +1764,7 @@ TEST_F(LayerTreeHostImplTest, WillDrawReturningFalseDoesNotCall) { host_impl_->active_tree()->root_layer()); root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); + root->SetHasRenderSurface(true); DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[0]); @@ -1827,7 +1805,7 @@ TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( host_impl_->active_tree()->root_layer()); root->SetMasksToBounds(true); - + root->SetHasRenderSurface(true); root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); DidDrawCheckLayer* layer = static_cast<DidDrawCheckLayer*>(root->children()[0]); @@ -1880,6 +1858,7 @@ TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { static_cast<DidDrawCheckLayer*>(root->children()[0]); root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); + root->SetHasRenderSurface(true); DidDrawCheckLayer* top_layer = static_cast<DidDrawCheckLayer*>(root->children()[1]); // This layer covers the occluded_layer above. Make this layer large so it can @@ -1912,6 +1891,7 @@ TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); + root->SetHasRenderSurface(true); DidDrawCheckLayer* layer1 = static_cast<DidDrawCheckLayer*>(root->children()[0]); @@ -1919,7 +1899,7 @@ TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { DidDrawCheckLayer* layer2 = static_cast<DidDrawCheckLayer*>(layer1->children()[0]); - layer1->SetOpacity(0.3f); + layer1->SetHasRenderSurface(true); layer1->SetShouldFlattenTransform(true); EXPECT_FALSE(root->did_draw_called()); @@ -1991,7 +1971,7 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) { DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); - + root->SetHasRenderSurface(true); bool tile_missing = false; bool had_incomplete_tile = false; bool is_animating = false; @@ -2015,6 +1995,7 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithAnimatedLayer) { DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); + root->SetHasRenderSurface(true); bool tile_missing = false; bool had_incomplete_tile = false; bool is_animating = true; @@ -2038,6 +2019,7 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) { DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); + root->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -2066,6 +2048,7 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) { DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); + root->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -2095,6 +2078,7 @@ TEST_F(LayerTreeHostImplTest, DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); + root->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -2125,6 +2109,7 @@ TEST_F(LayerTreeHostImplTest, DidDrawCheckLayer::Create(host_impl_->active_tree(), 5)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); + root->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -2153,6 +2138,7 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) { DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); + root->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -2183,6 +2169,7 @@ TEST_F(LayerTreeHostImplTest, DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); + root->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -2214,6 +2201,7 @@ TEST_F(LayerTreeHostImplTest, DidDrawCheckLayer::Create(host_impl_->active_tree(), 7)); DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); + root->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); @@ -2242,6 +2230,7 @@ TEST_F(LayerTreeHostImplTest, TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); root->SetScrollClipLayer(Layer::INVALID_ID); + root->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(root.Pass()); DrawFrame(); @@ -2296,7 +2285,9 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { root->SetIsContainerForFixedPositionLayers(true); int inner_viewport_scroll_layer_id = root->id(); int page_scale_layer_id = root_clip->id(); + root_clip->SetHasRenderSurface(true); root_clip->AddChild(root.Pass()); + root_clip->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); host_impl_->active_tree()->SetViewportLayersFromIds( Layer::INVALID_ID, page_scale_layer_id, inner_viewport_scroll_layer_id, @@ -2361,7 +2352,7 @@ class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { root->SetPosition(gfx::PointF()); root->SetDrawsContent(false); root->SetIsContainerForFixedPositionLayers(true); - + root_clip->SetHasRenderSurface(true); outer_clip->SetBounds(outer_viewport_size); outer_scroll->SetScrollClipLayer(outer_clip->id()); outer_scroll->SetBounds(scroll_layer_size); @@ -2934,6 +2925,7 @@ TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { scroll_layer->AddChild(content_layer.Pass()); scroll_clip_layer->AddChild(scroll_layer.Pass()); + scroll_clip_layer->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); host_impl_->SetViewportSize(surface_size); DrawFrame(); @@ -2954,6 +2946,7 @@ TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { root->SetBounds(surface_size); root->SetContentBounds(contents_size); root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); + root->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(root.Pass()); host_impl_->SetViewportSize(surface_size); DrawFrame(); @@ -2971,6 +2964,7 @@ TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { gfx::Size surface_size(10, 10); scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); + root->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(root.Pass()); host_impl_->SetViewportSize(surface_size); DrawFrame(); @@ -2987,6 +2981,7 @@ TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { gfx::Size surface_size(10, 10); scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); + root->SetHasRenderSurface(true); scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, surface_size, root.get()); host_impl_->SetViewportSize(surface_size); @@ -3024,6 +3019,7 @@ TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) { CreateScrollableLayer(2, surface_size, clip_layer.get()); scroll_layer->AddChild(content_layer.Pass()); clip_layer->AddChild(scroll_layer.Pass()); + clip_layer->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); host_impl_->SetViewportSize(surface_size); @@ -3049,6 +3045,7 @@ TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { root_scrolling->SetIsContainerForFixedPositionLayers(true); root_clip->AddChild(root_scrolling.Pass()); root->AddChild(root_clip.Pass()); + root->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(root.Pass()); // The behaviour in this test assumes the page scale is applied at a layer // above the clip layer. @@ -3099,6 +3096,7 @@ TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) { root_scrolling->SetIsContainerForFixedPositionLayers(true); root_clip->AddChild(root_scrolling.Pass()); root->AddChild(root_clip.Pass()); + root->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(root.Pass()); // The behaviour in this test assumes the page scale is applied at a layer // above the clip layer. @@ -3204,6 +3202,7 @@ TEST_F(LayerTreeHostImplTest, ScrollChildAndChangePageScaleOnMainThread) { gfx::Size surface_size(30, 30); scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); root->SetBounds(gfx::Size(5, 5)); + root->SetHasRenderSurface(true); scoped_ptr<LayerImpl> root_scrolling = LayerImpl::Create(host_impl_->active_tree(), 2); root_scrolling->SetBounds(surface_size); @@ -3259,7 +3258,7 @@ TEST_F(LayerTreeHostImplTest, ScrollChildBeyondLimit) { gfx::Size content_size(20, 20); scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); root->SetBounds(surface_size); - + root->SetHasRenderSurface(true); scoped_ptr<LayerImpl> grand_child = CreateScrollableLayer(3, content_size, root.get()); @@ -3304,6 +3303,7 @@ TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { gfx::Size surface_size(20, 20); gfx::Size viewport_size(10, 10); scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); + root->SetHasRenderSurface(true); scoped_ptr<LayerImpl> root_scrolling = CreateScrollableLayer(2, surface_size, root.get()); root_scrolling->SetIsContainerForFixedPositionLayers(true); @@ -3413,6 +3413,7 @@ TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) { gfx::Size content_size(20, 20); scoped_ptr<LayerImpl> root_clip = LayerImpl::Create(host_impl_->active_tree(), 3); + root_clip->SetHasRenderSurface(true); scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size, root_clip.get()); // Make 'root' the clip layer for child: since they have the same sizes the @@ -3456,6 +3457,7 @@ TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { scoped_ptr<LayerImpl> root_scroll = CreateScrollableLayer(2, surface_size, root_clip.get()); root_scroll->SetIsContainerForFixedPositionLayers(true); + root_clip->SetHasRenderSurface(true); root_clip->AddChild(root_scroll.Pass()); host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, @@ -3473,6 +3475,7 @@ TEST_F(LayerTreeHostImplTest, ScrollBeforeRedraw) { CreateScrollableLayer(4, surface_size, root_clip2.get()); root_scroll2->SetIsContainerForFixedPositionLayers(true); root_clip2->AddChild(root_scroll2.Pass()); + root_clip2->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, Layer::INVALID_ID); @@ -3987,6 +3990,8 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildWithoutBubbling) { gfx::Size surface_size(10, 10); scoped_ptr<LayerImpl> root_clip = LayerImpl::Create(host_impl_->active_tree(), 4); + root_clip->SetHasRenderSurface(true); + scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, surface_size, root_clip.get()); @@ -4051,6 +4056,8 @@ TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { gfx::Size content_size(20, 20); scoped_ptr<LayerImpl> root_clip = LayerImpl::Create(host_impl_->active_tree(), 3); + root_clip->SetHasRenderSurface(true); + scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size, root_clip.get()); root->SetIsContainerForFixedPositionLayers(true); @@ -4107,6 +4114,8 @@ TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { float device_scale_factor = 1.5f; scoped_ptr<LayerImpl> root_clip = LayerImpl::Create(host_impl_->active_tree(), 3); + root_clip->SetHasRenderSurface(true); + scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size, root_clip.get()); root->SetIsContainerForFixedPositionLayers(true); @@ -4146,6 +4155,8 @@ TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { gfx::Size content_size(200, 200); scoped_ptr<LayerImpl> root_clip = LayerImpl::Create(host_impl_->active_tree(), 3); + root_clip->SetHasRenderSurface(true); + scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size, root_clip.get()); root->SetIsContainerForFixedPositionLayers(true); @@ -4292,6 +4303,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { root->SetBounds(gfx::Size(10, 10)); root->SetContentBounds(root->bounds()); root->SetDrawsContent(false); + root->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(root.Pass()); } LayerImpl* root = host_impl_->active_tree()->root_layer(); @@ -4401,6 +4413,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { // carries the inherited opacity). layer1->SetContentsOpaque(true); layer1->SetOpacity(0.5f); + layer1->SetHasRenderSurface(true); layer1->SetExpectation(false, true); layer1->SetUpdateRect(gfx::Rect(layer1->content_bounds())); layer2->SetExpectation(false, false); @@ -4412,6 +4425,7 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { EXPECT_TRUE(layer1->quads_appended()); EXPECT_TRUE(layer2->quads_appended()); host_impl_->DidDrawAllLayers(frame); + layer1->SetHasRenderSurface(false); // Draw again, but with child non-opaque, to make sure // layer1 not culled. @@ -4528,6 +4542,7 @@ class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { host_impl_->active_tree()->set_background_color(SK_ColorGRAY); host_impl_->active_tree()->SetRootLayer( LayerImpl::Create(host_impl_->active_tree(), 1)); + host_impl_->active_tree()->root_layer()->SetHasRenderSurface(true); host_impl_->active_tree()->root_layer()->AddChild( BlendStateCheckLayer::Create(host_impl_->active_tree(), 2, @@ -4818,6 +4833,7 @@ TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { root->SetBounds(gfx::Size(10, 10)); root->SetContentBounds(gfx::Size(10, 10)); root->SetDrawsContent(true); + root->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(root.Pass()); EXPECT_FALSE(provider->TestContext3d()->reshape_called()); provider->TestContext3d()->clear_reshape_called(); @@ -4886,6 +4902,7 @@ TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); + root->SetHasRenderSurface(true); scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); child->SetPosition(gfx::PointF(12.f, 13.f)); @@ -4952,7 +4969,7 @@ TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { root->SetBounds(gfx::Size(10, 10)); root->SetContentBounds(gfx::Size(10, 10)); root->SetDrawsContent(true); - root->SetForceRenderSurface(true); + root->SetHasRenderSurface(true); root->AddChild(child.Pass()); host_impl_->active_tree()->SetRootLayer(root.Pass()); @@ -5201,7 +5218,7 @@ static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( gfx::Rect child_rect(10, 10, 50, 50); gfx::Rect grand_child_rect(5, 5, 150, 150); - root->CreateRenderSurface(); + root->SetHasRenderSurface(true); root->SetPosition(root_rect.origin()); root->SetBounds(root_rect.size()); root->SetContentBounds(root->bounds()); @@ -5215,7 +5232,7 @@ static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( child->SetContentBounds(child->bounds()); child->draw_properties().visible_content_rect = child_rect; child->SetDrawsContent(false); - child->SetForceRenderSurface(true); + child->SetHasRenderSurface(true); grand_child->SetPosition(grand_child_rect.origin()); grand_child->SetBounds(grand_child_rect.size()); @@ -5295,6 +5312,7 @@ TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { scoped_ptr<LayerImpl> root_layer = LayerImpl::Create(host_impl_->active_tree(), 1); root_layer->SetBounds(gfx::Size(10, 10)); + root_layer->SetHasRenderSurface(true); scoped_refptr<VideoFrame> softwareFrame = media::VideoFrame::CreateColorFrame( @@ -5469,6 +5487,7 @@ TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) { root->SetBounds(gfx::Size(10, 10)); root->SetContentBounds(gfx::Size(10, 10)); root->SetDrawsContent(true); + root->SetHasRenderSurface(true); // Child layer is in the bottom right corner. scoped_ptr<SolidColorLayerImpl> child = @@ -5535,6 +5554,7 @@ TEST_F(LayerTreeHostImplTest, MaskLayerWithScaling) { scoped_ptr<LayerImpl> scoped_root = LayerImpl::Create(host_impl_->active_tree(), 1); LayerImpl* root = scoped_root.get(); + root->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); scoped_ptr<LayerImpl> scoped_scaling_layer = @@ -5550,6 +5570,7 @@ TEST_F(LayerTreeHostImplTest, MaskLayerWithScaling) { scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); + content_layer->SetHasRenderSurface(true); content_layer->SetMaskLayer(scoped_mask_layer.Pass()); gfx::Size root_size(100, 100); @@ -5675,6 +5696,8 @@ TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { scoped_ptr<LayerImpl> scoped_root = LayerImpl::Create(host_impl_->active_tree(), 1); LayerImpl* root = scoped_root.get(); + root->SetHasRenderSurface(true); + host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); scoped_ptr<LayerImpl> scoped_content_layer = @@ -5686,6 +5709,7 @@ TEST_F(LayerTreeHostImplTest, MaskLayerWithDifferentBounds) { FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); content_layer->SetMaskLayer(scoped_mask_layer.Pass()); + content_layer->SetHasRenderSurface(true); gfx::Size root_size(100, 100); root->SetBounds(root_size); @@ -5829,6 +5853,8 @@ TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { scoped_ptr<LayerImpl> scoped_root = LayerImpl::Create(host_impl_->active_tree(), 1); LayerImpl* root = scoped_root.get(); + root->SetHasRenderSurface(true); + host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); scoped_ptr<LayerImpl> scoped_content_layer = @@ -5840,11 +5866,13 @@ TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerWithDifferentBounds) { LayerImpl::Create(host_impl_->active_tree(), 2); LayerImpl* replica_layer = scoped_replica_layer.get(); content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); + content_layer->SetHasRenderSurface(true); scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = FakeMaskLayerImpl::Create(host_impl_->active_tree(), 4); FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); + replica_layer->SetHasRenderSurface(true); gfx::Size root_size(100, 100); root->SetBounds(root_size); @@ -5984,6 +6012,7 @@ TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { scoped_ptr<LayerImpl> scoped_root = LayerImpl::Create(host_impl_->active_tree(), 1); LayerImpl* root = scoped_root.get(); + root->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); scoped_ptr<LayerImpl> scoped_content_layer = @@ -6000,11 +6029,13 @@ TEST_F(LayerTreeHostImplTest, ReflectionMaskLayerForSurfaceWithUnclippedChild) { LayerImpl::Create(host_impl_->active_tree(), 4); LayerImpl* replica_layer = scoped_replica_layer.get(); content_layer->SetReplicaLayer(scoped_replica_layer.Pass()); + content_layer->SetHasRenderSurface(true); scoped_ptr<FakeMaskLayerImpl> scoped_mask_layer = FakeMaskLayerImpl::Create(host_impl_->active_tree(), 5); FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); replica_layer->SetMaskLayer(scoped_mask_layer.Pass()); + replica_layer->SetHasRenderSurface(true); gfx::Size root_size(100, 100); root->SetBounds(root_size); @@ -6108,6 +6139,8 @@ TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { scoped_ptr<LayerImpl> scoped_root = LayerImpl::Create(host_impl_->active_tree(), 1); LayerImpl* root = scoped_root.get(); + root->SetHasRenderSurface(true); + host_impl_->active_tree()->SetRootLayer(scoped_root.Pass()); scoped_ptr<LayerImpl> scoped_clipping_layer = @@ -6129,6 +6162,7 @@ TEST_F(LayerTreeHostImplTest, MaskLayerForSurfaceWithClippedLayer) { FakeMaskLayerImpl::Create(host_impl_->active_tree(), 6); FakeMaskLayerImpl* mask_layer = scoped_mask_layer.get(); content_layer->SetMaskLayer(scoped_mask_layer.Pass()); + content_layer->SetHasRenderSurface(true); gfx::Size root_size(100, 100); root->SetBounds(root_size); @@ -6214,6 +6248,7 @@ TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) { scoped_ptr<LayerImpl> scoped_root = LayerImpl::Create(host_impl_->pending_tree(), 1); LayerImpl* root = scoped_root.get(); + root->SetHasRenderSurface(true); host_impl_->pending_tree()->SetRootLayer(scoped_root.Pass()); @@ -6715,6 +6750,8 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) { gfx::Size content_size(20, 20); scoped_ptr<LayerImpl> root_clip = LayerImpl::Create(host_impl_->active_tree(), 3); + root_clip->SetHasRenderSurface(true); + scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size, root_clip.get()); root->SetIsContainerForFixedPositionLayers(true); @@ -6759,6 +6796,7 @@ TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { // the scroll doesn't bubble up to the parent layer. gfx::Size surface_size(10, 10); scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); + root->SetHasRenderSurface(true); scoped_ptr<LayerImpl> root_scrolling = CreateScrollableLayer(2, surface_size, root.get()); @@ -6829,6 +6867,7 @@ TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) { gfx::Size content_size(20, 20); scoped_ptr<LayerImpl> root_clip = LayerImpl::Create(host_impl_->active_tree(), 3); + root_clip->SetHasRenderSurface(true); scoped_ptr<LayerImpl> root_scroll = CreateScrollableLayer(1, content_size, root_clip.get()); int root_scroll_id = root_scroll->id(); @@ -7032,6 +7071,7 @@ TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { root->SetBounds(gfx::Size(10, 10)); root->SetContentBounds(gfx::Size(10, 10)); root->SetDrawsContent(true); + root->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(root.Pass()); @@ -7072,6 +7112,7 @@ TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) { root->SetBounds(gfx::Size(10, 10)); root->SetContentBounds(gfx::Size(10, 10)); root->SetDrawsContent(true); + root->SetHasRenderSurface(true); host_impl_->active_tree()->SetRootLayer(root.Pass()); @@ -7597,6 +7638,7 @@ class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { page_scale->AddChild(inner_scroll.Pass()); inner_clip->AddChild(page_scale.Pass()); + inner_clip->SetHasRenderSurface(true); layer_tree_impl->SetRootLayer(inner_clip.Pass()); layer_tree_impl->SetViewportLayersFromIds( Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 26eb513..f188260 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -290,6 +290,7 @@ class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest { protected: void SetupTree() override { scoped_refptr<Layer> root = Layer::Create(); + root->CreateRenderSurface(); root->SetBounds(gfx::Size(10, 10)); layer_tree_host()->SetRootLayer(root); LayerTreeHostTest::SetupTree(); @@ -483,6 +484,7 @@ class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { void SetupTree() override { root_layer_ = Layer::Create(); root_layer_->SetBounds(gfx::Size(10, 20)); + root_layer_->CreateRenderSurface(); if (layer_tree_host()->settings().impl_side_painting) scaled_layer_ = FakePictureLayer::Create(&client_); @@ -544,6 +546,7 @@ class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate void SetupTree() override { root_layer_ = Layer::Create(); root_layer_->SetBounds(gfx::Size(10, 20)); + root_layer_->CreateRenderSurface(); bool paint_scrollbar = true; bool has_thumb = false; @@ -795,6 +798,7 @@ class LayerTreeHostTestUndrawnLayersPushContentBoundsLater : root_layer_(Layer::Create()) {} void SetupTree() override { + root_layer_->CreateRenderSurface(); root_layer_->SetIsDrawable(true); root_layer_->SetBounds(gfx::Size(20, 20)); layer_tree_host()->SetRootLayer(root_layer_); @@ -3178,6 +3182,7 @@ class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest { void SetupTree() override { root_ = PushPropertiesCountingLayer::Create(); + root_->CreateRenderSurface(); child_ = PushPropertiesCountingLayer::Create(); child2_ = PushPropertiesCountingLayer::Create(); grandchild_ = PushPropertiesCountingLayer::Create(); @@ -3190,6 +3195,7 @@ class LayerTreeHostTestLayersPushProperties : public LayerTreeHostTest { child2_->AddChild(leaf_always_pushing_layer_); other_root_ = PushPropertiesCountingLayer::Create(); + other_root_->CreateRenderSurface(); // Don't set the root layer here. LayerTreeHostTest::SetupTree(); @@ -3562,6 +3568,7 @@ class LayerTreeHostTestPropertyChangesDuringUpdateArePushed void SetupTree() override { root_ = Layer::Create(); + root_->CreateRenderSurface(); root_->SetBounds(gfx::Size(1, 1)); bool paint_scrollbar = true; @@ -3618,6 +3625,7 @@ class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { void SetupTree() override { root_ = PushPropertiesCountingLayer::Create(); + root_->CreateRenderSurface(); child_ = PushPropertiesCountingLayer::Create(); root_->AddChild(child_); @@ -3679,6 +3687,7 @@ class LayerTreeHostTestCasePushPropertiesThreeGrandChildren void SetupTree() override { root_ = PushPropertiesCountingLayer::Create(); + root_->CreateRenderSurface(); child_ = PushPropertiesCountingLayer::Create(); grandchild1_ = PushPropertiesCountingLayer::Create(); grandchild2_ = PushPropertiesCountingLayer::Create(); @@ -4232,6 +4241,7 @@ class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { protected: void SetupTree() override { root_layer_ = Layer::Create(); + root_layer_->CreateRenderSurface(); root_layer_->SetPosition(gfx::Point()); root_layer_->SetBounds(gfx::Size(10, 10)); @@ -4340,6 +4350,7 @@ class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); root_layer->SetBounds(gfx::Size(200, 200)); root_layer->SetIsDrawable(true); + root_layer->CreateRenderSurface(); layer_tree_host()->SetRootLayer(root_layer); LayerTreeHostTest::SetupTree(); @@ -5199,6 +5210,7 @@ class LayerTreeHostTestContinuousPainting : public LayerTreeHostTest { void SetupTree() override { scoped_refptr<Layer> root_layer = Layer::Create(); root_layer->SetBounds(bounds_); + root_layer->CreateRenderSurface(); if (layer_tree_host()->settings().impl_side_painting) { picture_layer_ = FakePictureLayer::Create(&client_); diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc index 78d72de..2c5dd05 100644 --- a/cc/trees/layer_tree_impl_unittest.cc +++ b/cc/trees/layer_tree_impl_unittest.cc @@ -50,13 +50,8 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetDrawsContent(true); host_impl().SetViewportSize(root->bounds()); @@ -102,24 +97,14 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetDrawsContent(true); // Create hud and add it as a child of root. gfx::Size hud_bounds(200, 200); - SetLayerPropertiesForTesting(hud.get(), - identity_matrix, - transform_origin, - position, - hud_bounds, - true, - false); + SetLayerPropertiesForTesting(hud.get(), identity_matrix, transform_origin, + position, hud_bounds, true, false, false); hud->SetDrawsContent(true); host_impl().active_tree()->set_hud_layer(hud.get()); @@ -174,13 +159,9 @@ TEST_F(LayerTreeImplTest, HitTestingForUninvertibleTransform) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - uninvertible_transform, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), uninvertible_transform, + transform_origin, position, bounds, true, false, + true); root->SetDrawsContent(true); host_impl().SetViewportSize(root->bounds()); @@ -240,13 +221,8 @@ TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { // layer is located. gfx::PointF position(50.f, 50.f); gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetDrawsContent(true); host_impl().SetViewportSize(root->bounds()); @@ -296,13 +272,9 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - rotation45_degrees_about_center, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), rotation45_degrees_about_center, + transform_origin, position, bounds, true, false, + true); root->SetDrawsContent(true); host_impl().SetViewportSize(root->bounds()); @@ -365,13 +337,8 @@ TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { gfx::PointF position; gfx::Size bounds(100, 100); SetLayerPropertiesForTesting( - root.get(), - perspective_projection_about_center * translation_by_z, - transform_origin, - position, - bounds, - true, - false); + root.get(), perspective_projection_about_center * translation_by_z, + transform_origin, position, bounds, true, false, true); root->SetDrawsContent(true); host_impl().SetViewportSize(root->bounds()); @@ -426,25 +393,17 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleLayerWithScaledContents) { gfx::Transform identity_matrix; gfx::Point3F transform_origin; - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - gfx::PointF(), - gfx::Size(100, 100), - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + gfx::PointF(), gfx::Size(100, 100), true, false, + true); { gfx::PointF position(25.f, 25.f); gfx::Size bounds(50, 50); scoped_ptr<LayerImpl> test_layer = LayerImpl::Create(host_impl().active_tree(), 12345); - SetLayerPropertiesForTesting(test_layer.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); // override content bounds and contents scale test_layer->SetContentBounds(gfx::Size(100, 100)); @@ -506,13 +465,9 @@ TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { gfx::Point3F transform_origin; scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - gfx::PointF(), - gfx::Size(100, 100), - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + gfx::PointF(), gfx::Size(100, 100), true, false, + true); { scoped_ptr<LayerImpl> clipping_layer = LayerImpl::Create(host_impl().active_tree(), 123); @@ -520,26 +475,17 @@ TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { // layer is located. gfx::PointF position(25.f, 25.f); gfx::Size bounds(50, 50); - SetLayerPropertiesForTesting(clipping_layer.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); clipping_layer->SetMasksToBounds(true); scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl().active_tree(), 456); position = gfx::PointF(-50.f, -50.f); bounds = gfx::Size(300, 300); - SetLayerPropertiesForTesting(child.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, + position, bounds, true, false, false); child->SetDrawsContent(true); clipping_layer->AddChild(child.Pass()); root->AddChild(clipping_layer.Pass()); @@ -601,13 +547,8 @@ TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetMasksToBounds(true); { scoped_ptr<LayerImpl> child = @@ -619,13 +560,8 @@ TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) { position = gfx::PointF(10.f, 10.f); bounds = gfx::Size(80, 80); - SetLayerPropertiesForTesting(child.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, + position, bounds, true, false, false); child->SetMasksToBounds(true); gfx::Transform rotation45_degrees_about_corner; @@ -636,13 +572,9 @@ TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) { position = gfx::PointF(); bounds = gfx::Size(200, 200); // to ensure it covers at least sqrt(2) * 100. - SetLayerPropertiesForTesting(grand_child.get(), - rotation45_degrees_about_corner, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting( + grand_child.get(), rotation45_degrees_about_corner, transform_origin, + position, bounds, true, false, false); grand_child->SetMasksToBounds(true); // Rotates about the center of the layer @@ -656,13 +588,9 @@ TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) { rotated_leaf_transform.Translate(-50.0, -50.0); position = gfx::PointF(); bounds = gfx::Size(100, 100); - SetLayerPropertiesForTesting(rotated_leaf.get(), - rotated_leaf_transform, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(rotated_leaf.get(), rotated_leaf_transform, + transform_origin, position, bounds, true, + false, false); rotated_leaf->SetDrawsContent(true); grand_child->AddChild(rotated_leaf.Pass()); @@ -674,27 +602,6 @@ TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) { host_impl().active_tree()->SetRootLayer(root.Pass()); host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); - // Sanity check the scenario we just created. - // The grand_child is expected to create a render surface because it - // MasksToBounds and is not axis aligned. - ASSERT_EQ(2u, RenderSurfaceLayerList().size()); - ASSERT_EQ( - 1u, - RenderSurfaceLayerList().at(0)->render_surface()->layer_list().size()); - ASSERT_EQ(789, - RenderSurfaceLayerList() - .at(0) - ->render_surface() - ->layer_list() - .at(0) - ->id()); // grand_child's surface. - ASSERT_EQ( - 1u, - RenderSurfaceLayerList().at(1)->render_surface()->layer_list().size()); - ASSERT_EQ( - 2468, - RenderSurfaceLayerList()[1]->render_surface()->layer_list().at(0)->id()); - // (11, 89) is close to the the bottom left corner within the clip, but it is // not inside the layer. gfx::Point test_point(11, 89); @@ -749,13 +656,9 @@ TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { gfx::Point3F transform_origin; scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - gfx::PointF(), - gfx::Size(100, 100), - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + gfx::PointF(), gfx::Size(100, 100), true, false, + true); { scoped_ptr<LayerImpl> intermediate_layer = LayerImpl::Create(host_impl().active_tree(), 123); @@ -763,13 +666,9 @@ TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { // layer is located. gfx::PointF position(10.f, 10.f); gfx::Size bounds(50, 50); - SetLayerPropertiesForTesting(intermediate_layer.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(intermediate_layer.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); // Sanity check the intermediate layer should not clip. ASSERT_FALSE(intermediate_layer->masks_to_bounds()); ASSERT_FALSE(intermediate_layer->mask_layer()); @@ -781,13 +680,8 @@ TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { LayerImpl::Create(host_impl().active_tree(), 456); position = gfx::PointF(60.f, 60.f); // 70, 70 in screen space bounds = gfx::Size(20, 20); - SetLayerPropertiesForTesting(child.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, + position, bounds, true, false, false); child->SetDrawsContent(true); intermediate_layer->AddChild(child.Pass()); root->AddChild(intermediate_layer.Pass()); @@ -834,13 +728,8 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetDrawsContent(true); { // child 1 and child2 are initialized to overlap between x=50 and x=60. @@ -858,24 +747,16 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { position = gfx::PointF(10.f, 10.f); bounds = gfx::Size(50, 50); - SetLayerPropertiesForTesting(child1.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child1.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); child1->SetDrawsContent(true); position = gfx::PointF(50.f, 10.f); bounds = gfx::Size(50, 50); - SetLayerPropertiesForTesting(child2.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child2.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); child2->SetDrawsContent(true); // Remember that grand_child is positioned with respect to its parent (i.e. @@ -883,13 +764,9 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { // 100 x 50. position = gfx::PointF(0.f, 40.f); bounds = gfx::Size(100, 50); - SetLayerPropertiesForTesting(grand_child1.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); grand_child1->SetDrawsContent(true); child1->AddChild(grand_child1.Pass()); @@ -973,13 +850,8 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetDrawsContent(true); root->SetShouldFlattenTransform(false); root->Set3dSortingContextId(1); @@ -999,13 +871,9 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { position = gfx::PointF(10.f, 10.f); bounds = gfx::Size(50, 50); - SetLayerPropertiesForTesting(child1.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child1.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); child1->SetDrawsContent(true); child1->SetShouldFlattenTransform(false); child1->Set3dSortingContextId(1); @@ -1014,13 +882,8 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { bounds = gfx::Size(50, 50); gfx::Transform translate_z; translate_z.Translate3d(0, 0, -10.f); - SetLayerPropertiesForTesting(child2.get(), - translate_z, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child2.get(), translate_z, transform_origin, + position, bounds, true, false, false); child2->SetDrawsContent(true); child2->SetShouldFlattenTransform(false); child2->Set3dSortingContextId(1); @@ -1030,13 +893,9 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { // 100 x 50. position = gfx::PointF(0.f, 40.f); bounds = gfx::Size(100, 50); - SetLayerPropertiesForTesting(grand_child1.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); grand_child1->SetDrawsContent(true); grand_child1->SetShouldFlattenTransform(false); @@ -1122,13 +981,8 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetDrawsContent(true); { scoped_ptr<LayerImpl> child = @@ -1138,27 +992,18 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { position = gfx::PointF(10.f, 10.f); bounds = gfx::Size(1, 1); - SetLayerPropertiesForTesting(child.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, + position, bounds, true, false, false); child->SetDrawsContent(true); child->SetMasksToBounds(true); position = gfx::PointF(0.f, 40.f); bounds = gfx::Size(100, 50); - SetLayerPropertiesForTesting(grand_child.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); grand_child->SetDrawsContent(true); - grand_child->SetForceRenderSurface(true); + grand_child->SetHasRenderSurface(true); // This should let |grand_child| "escape" |child|'s clip. grand_child->SetClipParent(root.get()); @@ -1184,13 +1029,8 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetDrawsContent(true); { scoped_ptr<LayerImpl> child = @@ -1202,40 +1042,27 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { position = gfx::PointF(10.f, 10.f); bounds = gfx::Size(1, 1); - SetLayerPropertiesForTesting(child.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, + position, bounds, true, false, false); child->SetDrawsContent(true); child->SetMasksToBounds(true); position = gfx::PointF(); bounds = gfx::Size(200, 200); - SetLayerPropertiesForTesting(scroll_child.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(scroll_child.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); scroll_child->SetDrawsContent(true); // This should cause scroll child and its descendants to be affected by // |child|'s clip. scroll_child->SetScrollParent(child.get()); - SetLayerPropertiesForTesting(grand_child.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); grand_child->SetDrawsContent(true); - grand_child->SetForceRenderSurface(true); + grand_child->SetHasRenderSurface(true); scroll_child->AddChild(grand_child.Pass()); root->AddChild(scroll_child.Pass()); @@ -1265,13 +1092,8 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetDrawsContent(true); { // child 1 and child2 are initialized to overlap between x=50 and x=60. @@ -1289,42 +1111,30 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { position = gfx::PointF(10.f, 10.f); bounds = gfx::Size(50, 50); - SetLayerPropertiesForTesting(child1.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child1.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); child1->SetDrawsContent(true); - child1->SetForceRenderSurface(true); + child1->SetHasRenderSurface(true); position = gfx::PointF(50.f, 10.f); bounds = gfx::Size(50, 50); - SetLayerPropertiesForTesting(child2.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child2.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); child2->SetDrawsContent(true); - child2->SetForceRenderSurface(true); + child2->SetHasRenderSurface(true); // Remember that grand_child is positioned with respect to its parent (i.e. // child1). In screen space, the intended position is (10, 50), with size // 100 x 50. position = gfx::PointF(0.f, 40.f); bounds = gfx::Size(100, 50); - SetLayerPropertiesForTesting(grand_child1.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(grand_child1.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); grand_child1->SetDrawsContent(true); - grand_child1->SetForceRenderSurface(true); + grand_child1->SetHasRenderSurface(true); child1->AddChild(grand_child1.Pass()); root->AddChild(child1.Pass()); @@ -1416,13 +1226,8 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetDrawsContent(true); host_impl().SetViewportSize(root->bounds()); @@ -1504,13 +1309,9 @@ TEST_F(LayerTreeImplTest, gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - uninvertible_transform, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), uninvertible_transform, + transform_origin, position, bounds, true, false, + true); root->SetDrawsContent(true); root->SetTouchEventHandlerRegion(touch_handler_region); @@ -1582,13 +1383,8 @@ TEST_F(LayerTreeImplTest, // layer is located. gfx::PointF position(50.f, 50.f); gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetDrawsContent(true); root->SetTouchEventHandlerRegion(touch_handler_region); @@ -1658,26 +1454,18 @@ TEST_F(LayerTreeImplTest, gfx::Transform identity_matrix; gfx::Point3F transform_origin; - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - gfx::PointF(), - gfx::Size(100, 100), - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + gfx::PointF(), gfx::Size(100, 100), true, false, + true); { Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); gfx::PointF position(25.f, 25.f); gfx::Size bounds(50, 50); scoped_ptr<LayerImpl> test_layer = LayerImpl::Create(host_impl().active_tree(), 12345); - SetLayerPropertiesForTesting(test_layer.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); // override content bounds and contents scale test_layer->SetContentBounds(gfx::Size(100, 100)); @@ -1762,26 +1550,18 @@ TEST_F(LayerTreeImplTest, gfx::Transform identity_matrix; gfx::Point3F transform_origin; // Set the bounds of the root layer big enough to fit the child when scaled. - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - gfx::PointF(), - gfx::Size(100, 100), - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + gfx::PointF(), gfx::Size(100, 100), true, false, + true); { Region touch_handler_region(gfx::Rect(10, 10, 30, 30)); gfx::PointF position(25.f, 25.f); gfx::Size bounds(50, 50); scoped_ptr<LayerImpl> test_layer = LayerImpl::Create(host_impl().active_tree(), 12345); - SetLayerPropertiesForTesting(test_layer.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(test_layer.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); test_layer->SetDrawsContent(true); test_layer->SetTouchEventHandlerRegion(touch_handler_region); @@ -1888,13 +1668,9 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { gfx::Point3F transform_origin; scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - gfx::PointF(), - gfx::Size(100, 100), - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + gfx::PointF(), gfx::Size(100, 100), true, false, + true); { scoped_ptr<LayerImpl> clipping_layer = LayerImpl::Create(host_impl().active_tree(), 123); @@ -1902,13 +1678,9 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { // layer is located. gfx::PointF position(25.f, 25.f); gfx::Size bounds(50, 50); - SetLayerPropertiesForTesting(clipping_layer.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); clipping_layer->SetMasksToBounds(true); scoped_ptr<LayerImpl> child = @@ -1916,13 +1688,8 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); position = gfx::PointF(-50.f, -50.f); bounds = gfx::Size(300, 300); - SetLayerPropertiesForTesting(child.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(child.get(), identity_matrix, transform_origin, + position, bounds, true, false, false); child->SetDrawsContent(true); child->SetTouchEventHandlerRegion(touch_handler_region); clipping_layer->AddChild(child.Pass()); @@ -1983,13 +1750,9 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { gfx::Point3F transform_origin; scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - gfx::PointF(), - gfx::Size(100, 100), - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + gfx::PointF(), gfx::Size(100, 100), true, false, + true); { scoped_ptr<LayerImpl> touch_layer = LayerImpl::Create(host_impl().active_tree(), 123); @@ -1997,13 +1760,9 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { // layer is located. gfx::PointF position; gfx::Size bounds(50, 50); - SetLayerPropertiesForTesting(touch_layer.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(touch_layer.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); touch_layer->SetDrawsContent(true); touch_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 50, 50)); root->AddChild(touch_layer.Pass()); @@ -2016,13 +1775,9 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { // layer is located. gfx::PointF position(0, 25); gfx::Size bounds(50, 50); - SetLayerPropertiesForTesting(notouch_layer.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(notouch_layer.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); notouch_layer->SetDrawsContent(true); root->AddChild(notouch_layer.Pass()); } @@ -2080,13 +1835,8 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); root->SetDrawsContent(true); host_impl().SetViewportSize(root->bounds()); @@ -2156,13 +1906,8 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); gfx::Vector2dF clipping_offset(10, 10); { @@ -2171,26 +1916,18 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) { // The clipping layer should occlude the right selection bound. gfx::PointF position = gfx::PointF() + clipping_offset; gfx::Size bounds(50, 50); - SetLayerPropertiesForTesting(clipping_layer.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(clipping_layer.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); clipping_layer->SetMasksToBounds(true); scoped_ptr<LayerImpl> clipped_layer = LayerImpl::Create(host_impl().active_tree(), clipped_layer_id); position = gfx::PointF(); bounds = gfx::Size(100, 100); - SetLayerPropertiesForTesting(clipped_layer.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(clipped_layer.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); clipped_layer->SetDrawsContent(true); clipping_layer->AddChild(clipped_layer.Pass()); root->AddChild(clipping_layer.Pass()); @@ -2268,13 +2005,8 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) { gfx::Point3F transform_origin; gfx::PointF position; gfx::Size bounds(100, 100); - SetLayerPropertiesForTesting(root.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, + position, bounds, true, false, true); gfx::Vector2dF sub_layer_offset(10, 0); { @@ -2282,13 +2014,9 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) { LayerImpl::Create(host_impl().active_tree(), sub_layer_id); gfx::PointF position = gfx::PointF() + sub_layer_offset; gfx::Size bounds(50, 50); - SetLayerPropertiesForTesting(sub_layer.get(), - identity_matrix, - transform_origin, - position, - bounds, - true, - false); + SetLayerPropertiesForTesting(sub_layer.get(), identity_matrix, + transform_origin, position, bounds, true, + false, false); sub_layer->SetDrawsContent(true); root->AddChild(sub_layer.Pass()); } diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc index 35b3ffd..172b227 100644 --- a/cc/trees/occlusion_tracker_unittest.cc +++ b/cc/trees/occlusion_tracker_unittest.cc @@ -127,6 +127,9 @@ struct OcclusionTrackerTestMainThreadTypes { *layer = NULL; return ref; } + static void SetForceRenderSurface(LayerType* layer, bool force) { + layer->SetForceRenderSurface(force); + } static void DestroyLayer(LayerPtrType* layer) { *layer = NULL; } @@ -156,6 +159,9 @@ struct OcclusionTrackerTestImplThreadTypes { return layer->Pass(); } + static void SetForceRenderSurface(LayerType* layer, bool force) { + layer->SetHasRenderSurface(force); + } static void DestroyLayer(LayerPtrType* layer) { layer->reset(); } static void RecursiveUpdateNumChildren(LayerType* layer) { @@ -189,6 +195,7 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test { DCHECK(!root_.get()); root_ = Types::PassLayerPtr(&layer); + Types::SetForceRenderSurface(layer_ptr, true); SetRootLayerOnMainThread(layer_ptr); return layer_ptr; @@ -211,7 +218,7 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test { const gfx::Size& bounds) { typename Types::LayerType* layer = CreateLayer(parent, transform, position, bounds); - layer->SetForceRenderSurface(true); + Types::SetForceRenderSurface(layer, true); return layer; } @@ -272,7 +279,7 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test { bool opaque) { typename Types::ContentLayerType* layer = CreateDrawingLayer(parent, transform, position, bounds, opaque); - layer->SetForceRenderSurface(true); + Types::SetForceRenderSurface(layer, true); return layer; } @@ -300,12 +307,12 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test { CopyOutputRequest::CreateBitmapRequest(base::Bind( &OcclusionTrackerTest<Types>::CopyOutputCallback, base::Unretained(this)))); + layer->SetHasRenderSurface(true); layer->PassCopyRequests(&requests); } void CalcDrawEtc(TestContentLayerImpl* root) { DCHECK(root == root_.get()); - DCHECK(!root->render_surface()); Types::RecursiveUpdateNumChildren(root); LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( @@ -734,7 +741,7 @@ class OcclusionTrackerTestScaledRenderSurface layer1_matrix.Scale(2.0, 2.0); typename Types::ContentLayerType* layer1 = this->CreateDrawingLayer( parent, layer1_matrix, gfx::PointF(), gfx::Size(100, 100), true); - layer1->SetForceRenderSurface(true); + Types::SetForceRenderSurface(layer1, true); gfx::Transform layer2_matrix; layer2_matrix.Translate(25.0, 25.0); @@ -848,9 +855,8 @@ class OcclusionTrackerTestSurfaceRotatedOffAxis this->identity_matrix, gfx::PointF(), gfx::Size(1000, 1000)); typename Types::ContentLayerType* parent = this->CreateDrawingLayer( root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); - typename Types::LayerType* child = this->CreateLayer( + typename Types::LayerType* child = this->CreateSurface( parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500)); - child->SetMasksToBounds(true); typename Types::ContentLayerType* layer = this->CreateDrawingLayer( child, layer_transform, gfx::PointF(), gfx::Size(500, 500), true); this->CalcDrawEtc(root); @@ -1169,14 +1175,17 @@ class OcclusionTrackerTestFilters : public OcclusionTrackerTest<Types> { gfx::Size(500, 500), true); + Types::SetForceRenderSurface(blur_layer, true); FilterOperations filters; filters.Append(FilterOperation::CreateBlurFilter(10.f)); blur_layer->SetFilters(filters); + Types::SetForceRenderSurface(opaque_layer, true); filters.Clear(); filters.Append(FilterOperation::CreateGrayscaleFilter(0.5f)); opaque_layer->SetFilters(filters); + Types::SetForceRenderSurface(opacity_layer, true); filters.Clear(); filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); opacity_layer->SetFilters(filters); @@ -2229,8 +2238,8 @@ class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter gfx::PointF(50.f, 50.f), gfx::Size(100, 100), false); + Types::SetForceRenderSurface(filtered_surface, true); filtered_surface->SetBackgroundFilters(filters); - gfx::Rect occlusion_rect; switch (i) { case LEFT: @@ -2341,6 +2350,8 @@ class OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice true); // Filters make the layers own surfaces. + Types::SetForceRenderSurface(filtered_surface1, true); + Types::SetForceRenderSurface(filtered_surface2, true); FilterOperations filters; filters.Append(FilterOperation::CreateBlurFilter(1.f)); filtered_surface1->SetBackgroundFilters(filters); @@ -2427,6 +2438,7 @@ class OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter gfx::Size()); // Filters make the layer own a surface. + Types::SetForceRenderSurface(filtered_surface, true); FilterOperations filters; filters.Append(FilterOperation::CreateBlurFilter(3.f)); filtered_surface->SetBackgroundFilters(filters); @@ -2501,6 +2513,7 @@ class OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded true); // Filters make the layer own a surface. + Types::SetForceRenderSurface(filtered_surface, true); FilterOperations filters; filters.Append(FilterOperation::CreateBlurFilter(3.f)); filtered_surface->SetBackgroundFilters(filters); @@ -2597,6 +2610,7 @@ class OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded true); // Filters make the layer own a surface. + Types::SetForceRenderSurface(filtered_surface, true); FilterOperations filters; filters.Append(FilterOperation::CreateBlurFilter(3.f)); filtered_surface->SetBackgroundFilters(filters); diff --git a/ui/compositor/transform_animation_curve_adapter.cc b/ui/compositor/transform_animation_curve_adapter.cc index 1b67ca2..0f697e0 100644 --- a/ui/compositor/transform_animation_curve_adapter.cc +++ b/ui/compositor/transform_animation_curve_adapter.cc @@ -69,6 +69,12 @@ bool TransformAnimationCurveAdapter::IsTranslation() const { target_value_.IsIdentityOrTranslation(); } +bool TransformAnimationCurveAdapter::PreservesAxisAlignment() const { + return (initial_value_.IsIdentity() || + initial_value_.IsScaleOrTranslation()) && + (target_value_.IsIdentity() || target_value_.IsScaleOrTranslation()); +} + bool TransformAnimationCurveAdapter::MaximumTargetScale( bool forward_direction, float* max_scale) const { @@ -131,6 +137,12 @@ bool InverseTransformCurveAdapter::IsTranslation() const { base_curve_.IsTranslation(); } +bool InverseTransformCurveAdapter::PreservesAxisAlignment() const { + return (initial_value_.IsIdentity() || + initial_value_.IsScaleOrTranslation()) && + (base_curve_.PreservesAxisAlignment()); +} + bool InverseTransformCurveAdapter::MaximumTargetScale(bool forward_direction, float* max_scale) const { return false; diff --git a/ui/compositor/transform_animation_curve_adapter.h b/ui/compositor/transform_animation_curve_adapter.h index 5bbe6a3..ba88c59 100644 --- a/ui/compositor/transform_animation_curve_adapter.h +++ b/ui/compositor/transform_animation_curve_adapter.h @@ -32,6 +32,7 @@ class COMPOSITOR_EXPORT TransformAnimationCurveAdapter gfx::BoxF* bounds) const override; bool AffectsScale() const override; bool IsTranslation() const override; + bool PreservesAxisAlignment() const override; bool MaximumTargetScale(bool forward_direction, float* max_scale) const override; @@ -62,6 +63,7 @@ class COMPOSITOR_EXPORT InverseTransformCurveAdapter gfx::BoxF* bounds) const override; bool AffectsScale() const override; bool IsTranslation() const override; + bool PreservesAxisAlignment() const override; bool MaximumTargetScale(bool forward_direction, float* max_scale) const override; |