#include <stddef.h>
#include <algorithm>
#include <memory>
#include <set>
#include <tuple>
#include <vector>
#include "base/containers/contains.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/test/scoped_feature_list.h"
#include "cc/animation/animation.h"
#include "cc/animation/animation_host.h"
#include "cc/animation/animation_id_provider.h"
#include "cc/layers/content_layer_client.h"
#include "cc/layers/effect_tree_layer_list_iterator.h"
#include "cc/layers/layer.h"
#include "cc/layers/layer_impl.h"
#include "cc/layers/render_surface_impl.h"
#include "cc/test/animation_test_common.h"
#include "cc/test/fake_content_layer_client.h"
#include "cc/test/fake_picture_layer.h"
#include "cc/test/fake_picture_layer_impl.h"
#include "cc/test/layer_tree_impl_test_base.h"
#include "cc/test/property_tree_test_utils.h"
#include "cc/trees/clip_node.h"
#include "cc/trees/draw_property_utils.h"
#include "cc/trees/effect_node.h"
#include "cc/trees/scroll_node.h"
#include "cc/trees/transform_node.h"
#include "components/viz/common/features.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/copy_output_result.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/animation/keyframe/keyframed_animation_curve.h"
#include "ui/gfx/geometry/linear_gradient.h"
#include "ui/gfx/geometry/quad_f.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/test/geometry_util.h"
#include "ui/gfx/geometry/transform.h"
#include "ui/gfx/geometry/transform_operations.h"
#include "ui/gfx/geometry/transform_util.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
namespace cc {
namespace {
bool LayerSubtreeHasCopyRequest(Layer* layer) { … }
class DrawPropertiesTestBase : public LayerTreeImplTestBase { … };
class DrawPropertiesTest : public DrawPropertiesTestBase,
public testing::Test { … };
class DrawPropertiesTestWithLayerTree : public DrawPropertiesTestBase,
public testing::Test { … };
class DrawPropertiesDrawRectsTest : public DrawPropertiesTest { … };
TEST_F(DrawPropertiesTest, TransformsForNoOpLayer) { … }
TEST_F(DrawPropertiesTest, TransformsForSingleLayer) { … }
TEST_F(DrawPropertiesTest, TransformsAboutScrollOffset) { … }
TEST_F(DrawPropertiesTest, TransformsForSimpleHierarchy) { … }
TEST_F(DrawPropertiesTest, TransformsForSingleRenderSurface) { … }
TEST_F(DrawPropertiesTest, TransformsForRenderSurfaceHierarchy) { … }
TEST_F(DrawPropertiesTest, LayerFullyContainedWithinClipInTargetSpace) { … }
TEST_F(DrawPropertiesTest, TransformsForDegenerateIntermediateLayer) { … }
TEST_F(DrawPropertiesTest, RenderSurfaceWithSublayerScale) { … }
TEST_F(DrawPropertiesTest, TransformAboveRootLayer) { … }
TEST_F(DrawPropertiesTest, DrawableContentRectForReferenceFilter) { … }
TEST_F(DrawPropertiesTest, DrawableContentRectForReferenceFilterHighDpi) { … }
TEST_F(DrawPropertiesTest, VisibleLayerRectForBlurFilterUnderClip) { … }
TEST_F(DrawPropertiesTest, VisibleLayerRectForReferenceFilterUnderClip) { … }
TEST_F(DrawPropertiesTest, RenderSurfaceForBlendMode) { … }
TEST_F(DrawPropertiesTest, RenderSurfaceDrawOpacity) { … }
TEST_F(DrawPropertiesTest, ClipRectCullsRenderSurfaces) { … }
TEST_F(DrawPropertiesTest, ClipRectCullsSurfaceWithoutVisibleContent) { … }
TEST_F(DrawPropertiesTest, IsClippedIsSetCorrectlyLayerImpl) { … }
TEST_F(DrawPropertiesTest, UpdateClipRectCorrectly) { … }
TEST_F(DrawPropertiesTest, DrawableContentRectForLayers) { … }
TEST_F(DrawPropertiesTest, ClipRectIsPropagatedCorrectlyToSurfaces) { … }
TEST_F(DrawPropertiesTest, AnimationsForRenderSurfaceHierarchy) { … }
TEST_F(DrawPropertiesTest, LargeTransforms) { … }
static bool TransformIsAnimating(LayerImpl* layer) { … }
static bool HasPotentiallyRunningTransformAnimation(LayerImpl* layer) { … }
TEST_F(DrawPropertiesTest,
ScreenSpaceTransformIsAnimatingWithDelayedAnimation) { … }
TEST_F(DrawPropertiesDrawRectsTest, DrawRectsForIdentityTransform) { … }
TEST_F(DrawPropertiesDrawRectsTest, DrawRectsFor2DRotations) { … }
TEST_F(DrawPropertiesDrawRectsTest, DrawRectsFor3dOrthographicTransform) { … }
TEST_F(DrawPropertiesDrawRectsTest, DrawRectsFor3dPerspectiveTransform) { … }
TEST_F(DrawPropertiesDrawRectsTest,
DrawRectsFor3dOrthographicIsNotClippedBehindSurface) { … }
TEST_F(DrawPropertiesDrawRectsTest, DrawRectsFor3dPerspectiveWhenClippedByW) { … }
static bool ProjectionClips(const gfx::Transform& map_transform,
const gfx::RectF& mapped_rect) { … }
TEST_F(DrawPropertiesDrawRectsTest, DrawRectsForPerspectiveUnprojection) { … }
TEST_F(DrawPropertiesTest, DrawableAndVisibleContentRectsForSimpleLayers) { … }
TEST_F(DrawPropertiesTest,
DrawableAndVisibleContentRectsForLayersClippedByLayer) { … }
TEST_F(DrawPropertiesTest, VisibleContentRectWithClippingAndScaling) { … }
TEST_F(DrawPropertiesTest, ClipRectWithClipParent) { … }
TEST_F(DrawPropertiesTest, ClipRectWithClippedDescendantOfFilter) { … }
TEST_F(DrawPropertiesTest,
DrawableAndVisibleContentRectsForLayersInUnclippedRenderSurface) { … }
TEST_F(DrawPropertiesTest, VisibleContentRectsForClippedSurfaceWithEmptyClip) { … }
TEST_F(DrawPropertiesTest,
DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) { … }
TEST_F(DrawPropertiesTest,
VisibleContentRectForLayerWithUninvertibleDrawTransform) { … }
TEST_F(DrawPropertiesTest, ClipExpanderWithUninvertibleTransform) { … }
TEST_F(DrawPropertiesTestWithLayerTree, OcclusionBySiblingOfTarget) { … }
TEST_F(DrawPropertiesTestWithLayerTree, OcclusionImmuneForSiblingOfTarget) { … }
TEST_F(DrawPropertiesTest, OcclusionForLayerWithUninvertibleDrawTransform) { … }
TEST_F(DrawPropertiesTest,
DrawableAndVisibleContentRectsForLayersInClippedRenderSurface) { … }
TEST_F(DrawPropertiesTest, DrawableAndVisibleContentRectsForSurfaceHierarchy) { … }
TEST_F(DrawPropertiesTest,
VisibleRectsForClippedDescendantsOfUnclippedSurfaces) { … }
TEST_F(DrawPropertiesTest,
VisibleRectsWhenClipChildIsBetweenTwoRenderSurfaces) { … }
TEST_F(DrawPropertiesTest, ClipRectOfSurfaceWhoseParentIsAClipChild) { … }
TEST_F(DrawPropertiesTest,
RenderSurfaceCommonAncestorClipOnChangeOfChildLayerClip) { … }
TEST_F(DrawPropertiesTest, RenderSurfaceContentRectWhenLayerNotDrawn) { … }
TEST_F(DrawPropertiesTest, VisibleRectsMultipleSurfaces) { … }
TEST_F(DrawPropertiesTest, RootClipPropagationToClippedSurface) { … }
TEST_F(DrawPropertiesTest,
DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) { … }
TEST_F(DrawPropertiesTest,
DrawableAndVisibleContentRectsWithTransformOnClippedSurface) { … }
TEST_F(DrawPropertiesTest, DrawableAndVisibleContentRectsInHighDPI) { … }
DrawPropertiesScalingTest;
TEST_F(DrawPropertiesScalingTest, LayerTransformsInHighDPI) { … }
TEST_F(DrawPropertiesScalingTest, SurfaceLayerTransformsInHighDPI) { … }
TEST_F(DrawPropertiesScalingTest, SmallIdealScale) { … }
TEST_F(DrawPropertiesScalingTest, IdealScaleForAnimatingLayer) { … }
TEST_F(DrawPropertiesTest, RenderSurfaceTransformsInHighDPI) { … }
TEST_F(DrawPropertiesTest,
RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) { … }
TEST_F(DrawPropertiesTestWithLayerTree, LayerSearch) { … }
TEST_F(DrawPropertiesTest, TransparentChildRenderSurfaceCreation) { … }
TEST_F(DrawPropertiesTest, OpacityAnimatingOnPendingTree) { … }
class BackfaceVisibilityInteropTest : public DrawPropertiesTestBase,
public testing::Test { … };
TEST_F(BackfaceVisibilityInteropTest, BackfaceInvisibleTransform) { … }
TEST_F(DrawPropertiesTestWithLayerTree, SubtreeHidden_SingleLayerImpl) { … }
TEST_F(DrawPropertiesTestWithLayerTree, SubtreeHidden_TwoLayersImpl) { … }
TEST_F(DrawPropertiesTestWithLayerTree, SubtreeHiddenWithCopyRequest) { … }
TEST_F(DrawPropertiesTestWithLayerTree, ClippedOutCopyRequest) { … }
TEST_F(DrawPropertiesTestWithLayerTree, SingularTransformAndCopyRequests) { … }
TEST_F(DrawPropertiesTestWithLayerTree, VisibleRectInNonRootCopyRequest) { … }
TEST_F(DrawPropertiesTest, TransformedClipParent) { … }
TEST_F(DrawPropertiesTest, ClipParentWithInterveningRenderSurface) { … }
TEST_F(DrawPropertiesTest, ClipParentScrolledInterveningLayer) { … }
TEST_F(DrawPropertiesTest, DescendantsOfClipChildren) { … }
TEST_F(DrawPropertiesTest,
SurfacesShouldBeUnaffectedByNonDescendantClipChildren) { … }
TEST_F(DrawPropertiesTest, TransformAnimationUpdatesBackfaceVisibility) { … }
TEST_F(DrawPropertiesTest, ScrollChildAndScrollParentDifferentTargets) { … }
TEST_F(DrawPropertiesTest, SingularTransformSubtreesDoNotDraw) { … }
TEST_F(DrawPropertiesTest, ScrollSnapping) { … }
TEST_F(DrawPropertiesTest, ScrollSnappingWithAnimatedScreenSpaceTransform) { … }
TEST_F(DrawPropertiesTest, ScrollSnappingWithScrollChild) { … }
class DrawPropertiesStickyPositionTest : public DrawPropertiesTest { … };
TEST_F(DrawPropertiesStickyPositionTest, StickyPositionTop) { … }
TEST_F(DrawPropertiesStickyPositionTest, StickyPositionTopRounded) { … }
TEST_F(DrawPropertiesStickyPositionTest, StickyPositionSubpixelScroll) { … }
TEST_F(DrawPropertiesStickyPositionTest, StickyPositionBottom) { … }
TEST_F(DrawPropertiesStickyPositionTest, StickyPositionBottomRounded) { … }
TEST_F(DrawPropertiesStickyPositionTest,
StickyPositionBottomOuterViewportDelta) { … }
TEST_F(DrawPropertiesStickyPositionTest, StickyPositionLeftRight) { … }
TEST_F(DrawPropertiesStickyPositionTest, StickyPositionMainThreadUpdates) { … }
TEST_F(DrawPropertiesStickyPositionTest, StickyPositionCompositedContainer) { … }
TEST_F(DrawPropertiesStickyPositionTest, StickyPositionScaledStickyBox) { … }
TEST_F(DrawPropertiesStickyPositionTest, StickyPositionScaledContainer) { … }
TEST_F(DrawPropertiesStickyPositionTest, StickyPositionNested) { … }
class DrawPropertiesAnchorPositionScrollTest : public DrawPropertiesTest { … };
TEST_F(DrawPropertiesAnchorPositionScrollTest, Basics) { … }
TEST_F(DrawPropertiesAnchorPositionScrollTest, NestedScrollers) { … }
class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { … };
TEST_F(DrawPropertiesTest, MaximumAnimationScaleFactor) { … }
static void GatherDrawnLayers(LayerTreeImpl* tree_impl,
std::set<LayerImpl*>* drawn_layers) { … }
TEST_F(DrawPropertiesTestWithLayerTree, RenderSurfaceLayerListMembership) { … }
TEST_F(DrawPropertiesTestWithLayerTree, DrawPropertyDeviceScale) { … }
TEST_F(DrawPropertiesTest, DrawPropertyScales) { … }
TEST_F(DrawPropertiesTest, AnimationScales) { … }
TEST_F(DrawPropertiesTest, AnimationScaleFromSmallToOne) { … }
TEST_F(DrawPropertiesTest, VisibleContentRectInChildRenderSurface) { … }
TEST_F(DrawPropertiesTest, ViewportBoundsDeltaAffectVisibleContentRect) { … }
TEST_F(DrawPropertiesTest, VisibleContentRectForAnimatedLayer) { … }
TEST_F(DrawPropertiesTest,
VisibleContentRectForAnimatedLayerWithSingularTransform) { … }
TEST_F(DrawPropertiesTest, ChangeTransformOrigin) { … }
TEST_F(DrawPropertiesTest, UpdateScrollChildPosition) { … }
TEST_F(DrawPropertiesTestWithLayerTree, HasCopyRequestsInTargetSubtree) { … }
TEST_F(DrawPropertiesTestWithLayerTree, SkippingSubtreeMain) { … }
TEST_F(DrawPropertiesTestWithLayerTree, SkippingLayerImpl) { … }
TEST_F(DrawPropertiesTest, LayerSkippingInSubtreeOfSingularTransform) { … }
TEST_F(DrawPropertiesTestWithLayerTree, SkippingPendingLayerImpl) { … }
TEST_F(DrawPropertiesTestWithLayerTree, SkippingLayer) { … }
TEST_F(DrawPropertiesTest, TransformOfParentClipNodeAncestorOfTarget) { … }
TEST_F(DrawPropertiesTest, RenderSurfaceWithUnclippedDescendantsClipsSubtree) { … }
TEST_F(DrawPropertiesTest,
RenderSurfaceWithUnclippedDescendantsButDoesntApplyOwnClip) { … }
TEST_F(DrawPropertiesTest,
RenderSurfaceClipsSubtreeAndHasUnclippedDescendants) { … }
TEST_F(DrawPropertiesTest, UnclippedClipParent) { … }
TEST_F(DrawPropertiesTest, RenderSurfaceContentRectWithMultipleSurfaces) { … }
TEST_F(DrawPropertiesTest, ClipBetweenClipChildTargetAndClipParentTarget) { … }
TEST_F(DrawPropertiesTest, VisibleRectForDescendantOfScaledSurface) { … }
TEST_F(DrawPropertiesTest, LayerWithInputHandlerAndZeroOpacity) { … }
TEST_F(DrawPropertiesTest, ClipParentDrawsIntoScaledRootSurface) { … }
TEST_F(DrawPropertiesTest, ClipChildVisibleRect) { … }
TEST_F(DrawPropertiesTest, LayerClipRectLargerThanClippingRenderSurfaceRect) { … }
TEST_F(DrawPropertiesTestWithLayerTree, SubtreeIsHiddenTest) { … }
TEST_F(DrawPropertiesTest, TwoUnclippedRenderSurfaces) { … }
TEST_F(DrawPropertiesTestWithLayerTree, MaskLayerDrawProperties) { … }
TEST_F(DrawPropertiesTest, SublayerScaleWithTransformNodeBetweenTwoTargets) { … }
TEST_F(DrawPropertiesTest, NoisyTransform) { … }
TEST_F(DrawPropertiesTest, LargeTransformTest) { … }
#if DCHECK_IS_ON()
class DrawPropertiesTestDoubleBlurCheck : public DrawPropertiesTestBase,
public testing::Test { … };
TEST_F(DrawPropertiesTestDoubleBlurCheck, CheckForNoDoubleBlurTest) { … }
#endif
TEST_F(DrawPropertiesTestWithLayerTree, OpacityAnimationsTrackingTest) { … }
TEST_F(DrawPropertiesTestWithLayerTree, TransformAnimationsTrackingTest) { … }
TEST_F(DrawPropertiesTestWithLayerTree, CopyRequestScalingTest) { … }
TEST_F(DrawPropertiesTestWithLayerTree, SubtreeHiddenWithCacheRenderSurface) { … }
TEST_F(DrawPropertiesTestWithLayerTree,
VisibleRectInNonRootCacheRenderSurface) { … }
TEST_F(DrawPropertiesTestWithLayerTree, CustomLayerClipBounds) { … }
TEST_F(DrawPropertiesTestWithLayerTree, CustomLayerClipBoundsWithMaskToBounds) { … }
struct MaskFilterTestCase { … };
class DrawPropertiesWithLayerTreeTest :
public DrawPropertiesTestWithLayerTree,
public testing::WithParamInterface<MaskFilterTestCase> { … };
TEST_P(DrawPropertiesWithLayerTreeTest, MaskFilterOnRenderSurface) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}