#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h"
#include <memory>
#include "base/containers/adapters.h"
#include "base/memory/ptr_util.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/test_simple_task_runner.h"
#include "build/build_config.h"
#include "cc/input/main_thread_scrolling_reason.h"
#include "cc/layers/layer.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_frame_sink.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/trees/clip_node.h"
#include "cc/trees/effect_node.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_settings.h"
#include "cc/trees/property_tree.h"
#include "cc/trees/scroll_node.h"
#include "cc/trees/transform_node.h"
#include "cc/view_transition/view_transition_request.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/graphics/paint/effect_paint_property_node.h"
#include "third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_artifact.h"
#include "third_party/blink/renderer/platform/graphics/paint/scroll_paint_property_node.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/testing/fake_display_item_client.h"
#include "third_party/blink/renderer/platform/testing/layer_tree_host_embedder.h"
#include "third_party/blink/renderer/platform/testing/paint_property_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h"
#include "third_party/blink/renderer/platform/testing/picture_matchers.h"
#include "third_party/blink/renderer/platform/testing/test_paint_artifact.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "ui/gfx/geometry/test/geometry_util.h"
namespace blink {
namespace {
ElementsAre;
Pointee;
gfx::Transform Translation(SkScalar x, SkScalar y) { … }
class MockScrollCallbacks : public CompositorScrollCallbacks { … };
class PaintArtifactCompositorTest : public testing::Test,
public PaintTestConfigurations { … };
INSTANTIATE_PAINT_TEST_SUITE_P(…);
const auto kNotScrollingOnMain = …;
TEST_P(PaintArtifactCompositorTest, EmptyPaintArtifact) { … }
TEST_P(PaintArtifactCompositorTest, OneChunkWithAnOffset) { … }
TEST_P(PaintArtifactCompositorTest, OneTransform) { … }
TEST_P(PaintArtifactCompositorTest, OneTransformWithAlias) { … }
TEST_P(PaintArtifactCompositorTest, TransformCombining) { … }
TEST_P(PaintArtifactCompositorTest, BackfaceVisibility) { … }
TEST_P(PaintArtifactCompositorTest, FlattensInheritedTransform) { … }
TEST_P(PaintArtifactCompositorTest, FlattensInheritedTransformWithAlias) { … }
TEST_P(PaintArtifactCompositorTest, SortingContextID) { … }
TEST_P(PaintArtifactCompositorTest, OneClip) { … }
TEST_P(PaintArtifactCompositorTest, OneClipWithAlias) { … }
TEST_P(PaintArtifactCompositorTest, NestedClips) { … }
TEST_P(PaintArtifactCompositorTest, NestedClipsWithAlias) { … }
TEST_P(PaintArtifactCompositorTest, DeeplyNestedClips) { … }
TEST_P(PaintArtifactCompositorTest, SiblingClipsWithAlias) { … }
TEST_P(PaintArtifactCompositorTest, SiblingClipsWithCompositedTransform) { … }
TEST_P(PaintArtifactCompositorTest, SiblingTransformsWithAlias) { … }
TEST_P(PaintArtifactCompositorTest, SiblingTransformsWithComposited) { … }
TEST_P(PaintArtifactCompositorTest, ForeignLayerPassesThrough) { … }
TEST_P(PaintArtifactCompositorTest, EffectTreeConversionWithAlias) { … }
static PropertyTreeState ScrollState1(
const PropertyTreeState& parent_state = PropertyTreeState::Root(),
CompositingReasons compositing_reasons =
CompositingReason::kOverflowScrolling,
MainThreadScrollingReasons main_thread_reasons = kNotScrollingOnMain) { … }
static PropertyTreeState ScrollState2(
const PropertyTreeState& parent_state = PropertyTreeState::Root(),
CompositingReasons compositing_reasons =
CompositingReason::kOverflowScrolling,
MainThreadScrollingReasons main_thread_reasons = kNotScrollingOnMain) { … }
static void CheckCcScrollNode(const ScrollPaintPropertyNode& blink_scroll,
const cc::ScrollNode& cc_scroll) { … }
TEST_P(PaintArtifactCompositorTest, OneScrollNodeComposited) { … }
TEST_P(PaintArtifactCompositorTest, OneScrollNodeNonComposited) { … }
TEST_P(PaintArtifactCompositorTest, TransformUnderScrollNode) { … }
TEST_P(PaintArtifactCompositorTest, NestedScrollNodes) { … }
TEST_P(PaintArtifactCompositorTest, ScrollHitTestLayerOrder) { … }
TEST_P(PaintArtifactCompositorTest, NestedScrollableLayerOrder) { … }
TEST_P(PaintArtifactCompositorTest, AncestorScrollNodes) { … }
TEST_P(PaintArtifactCompositorTest, AncestorNonCompositedScrollNode) { … }
TEST_P(PaintArtifactCompositorTest, AncestorScrollNodesInversedOrder) { … }
TEST_P(PaintArtifactCompositorTest,
DifferentTransformTreeAndScrollTreeHierarchy) { … }
TEST_P(PaintArtifactCompositorTest,
DifferentTransformTreeAndScrollTreeHierarchyInversedOrder) { … }
TEST_P(PaintArtifactCompositorTest, FixedPositionScrollState) { … }
TEST_P(PaintArtifactCompositorTest, MergeSimpleChunks) { … }
TEST_P(PaintArtifactCompositorTest, MergeClip) { … }
TEST_P(PaintArtifactCompositorTest, Merge2DTransform) { … }
TEST_P(PaintArtifactCompositorTest, Merge2DTransformDirectAncestor) { … }
TEST_P(PaintArtifactCompositorTest, MergeTransformOrigin) { … }
TEST_P(PaintArtifactCompositorTest, MergeOpacity) { … }
TEST_P(PaintArtifactCompositorTest, MergeOpacityWithAlias) { … }
TEST_P(PaintArtifactCompositorTest, MergeNestedWithAlias) { … }
TEST_P(PaintArtifactCompositorTest, ClipPushedUp) { … }
TEST_P(PaintArtifactCompositorTest, EffectPushedUp) { … }
TEST_P(PaintArtifactCompositorTest, EffectAndClipPushedUp) { … }
TEST_P(PaintArtifactCompositorTest, ClipAndEffectNoTransform) { … }
TEST_P(PaintArtifactCompositorTest, TwoClips) { … }
TEST_P(PaintArtifactCompositorTest, TwoTransformsClipBetween) { … }
TEST_P(PaintArtifactCompositorTest, OverlapTransform) { … }
EffectPaintPropertyNode* CreateSampleEffectNodeWithElementId() { … }
TransformPaintPropertyNode* CreateSampleTransformNodeWithElementId() { … }
TEST_P(PaintArtifactCompositorTest, TransformWithElementId) { … }
TEST_P(PaintArtifactCompositorTest, EffectWithElementId) { … }
TEST_P(PaintArtifactCompositorTest, NonContiguousEffectWithElementId) { … }
TEST_P(PaintArtifactCompositorTest, EffectWithElementIdWithAlias) { … }
TEST_P(PaintArtifactCompositorTest, NonCompositedSimpleMask) { … }
TEST_P(PaintArtifactCompositorTest, CompositedMaskOneChild) { … }
TEST_P(PaintArtifactCompositorTest, NonCompositedMaskClearsOpaqueness) { … }
TEST_P(PaintArtifactCompositorTest, CompositedMaskTwoChildren) { … }
TEST_P(PaintArtifactCompositorTest, NonCompositedSimpleExoticBlendMode) { … }
TEST_P(PaintArtifactCompositorTest, ForcedCompositedExoticBlendMode) { … }
TEST_P(PaintArtifactCompositorTest,
CompositedExoticBlendModeOnTwoOpacityAnimationLayers) { … }
TEST_P(PaintArtifactCompositorTest,
CompositedExoticBlendModeOnTwo3DTransformLayers) { … }
TEST_P(PaintArtifactCompositorTest, DecompositeExoticBlendModeWithoutBackdrop) { … }
TEST_P(PaintArtifactCompositorTest,
DecompositeExoticBlendModeWithNonDrawingLayer) { … }
TEST_P(PaintArtifactCompositorTest, UpdateProducesNewSequenceNumber) { … }
TEST_P(PaintArtifactCompositorTest, DecompositeClip) { … }
TEST_P(PaintArtifactCompositorTest, DecompositeEffect) { … }
TEST_P(PaintArtifactCompositorTest, DirectlyCompositedEffect) { … }
TEST_P(PaintArtifactCompositorTest, DecompositeDeepEffect) { … }
TEST_P(PaintArtifactCompositorTest, IndirectlyCompositedEffect) { … }
TEST_P(PaintArtifactCompositorTest, DecompositedEffectNotMergingDueToOverlap) { … }
TEST_P(PaintArtifactCompositorTest, EffectivelyInvisibleChunk) { … }
TEST_P(PaintArtifactCompositorTest, EffectivelyInvisibleSolidColorChunk) { … }
TEST_P(PaintArtifactCompositorTest,
EffectivelyInvisibleChunkWithPrecedingChunk) { … }
TEST_P(PaintArtifactCompositorTest,
EffectivelyInvisibleChunkWithSubsequentChunk) { … }
TEST_P(PaintArtifactCompositorTest,
EffectivelyInvisibleChunkWithPrecedingAndSubsequentChunks) { … }
TEST_P(PaintArtifactCompositorTest, UpdateManagesLayerElementIds) { … }
TEST_P(PaintArtifactCompositorTest, SynthesizedClipSimple) { … }
TEST_P(PaintArtifactCompositorTest, SynthesizedClipRotatedNotSupported) { … }
TEST_P(PaintArtifactCompositorTest, SynthesizedClip90DegRotationSupported) { … }
TEST_P(PaintArtifactCompositorTest,
SynthesizedClipShaderBasedBorderRadiusNotSupported2) { … }
TEST_P(
PaintArtifactCompositorTest,
SynthesizedClipSimpleShaderBasedBorderRadiusNotSupportedMacNonEqualCorners) { … }
TEST_P(PaintArtifactCompositorTest, SynthesizedClipNested) { … }
TEST_P(PaintArtifactCompositorTest, SynthesizedClipIsNotDrawable) { … }
TEST_P(PaintArtifactCompositorTest, ReuseSyntheticClip) { … }
TEST_P(PaintArtifactCompositorTest,
SynthesizedClipIndirectlyCompositedClipPath) { … }
TEST_P(PaintArtifactCompositorTest, SynthesizedClipContiguous) { … }
TEST_P(PaintArtifactCompositorTest, SynthesizedClipDiscontiguous) { … }
TEST_P(PaintArtifactCompositorTest, SynthesizedClipAcrossChildEffect) { … }
TEST_P(PaintArtifactCompositorTest, SynthesizedClipRespectOutputClip) { … }
TEST_P(PaintArtifactCompositorTest, SynthesizedClipDelegateBlending) { … }
TEST_P(PaintArtifactCompositorTest, SynthesizedClipDelegateBackdropFilter) { … }
TEST_P(PaintArtifactCompositorTest, SynthesizedClipMultipleNonBackdropEffects) { … }
TEST_P(PaintArtifactCompositorTest, WillBeRemovedFromFrame) { … }
TEST_P(PaintArtifactCompositorTest, SolidColor) { … }
TEST_P(PaintArtifactCompositorTest, ContentsNonOpaque) { … }
TEST_P(PaintArtifactCompositorTest, ContentsOpaque) { … }
TEST_P(PaintArtifactCompositorTest, ContentsOpaqueUnitedNonOpaque) { … }
TEST_P(PaintArtifactCompositorTest, ContentsOpaqueUnitedClippedToOpaque) { … }
TEST_P(PaintArtifactCompositorTest, ContentsOpaqueUnitedOpaque1) { … }
TEST_P(PaintArtifactCompositorTest, ContentsOpaqueUnitedWithRoundedClip) { … }
TEST_P(PaintArtifactCompositorTest, ContentsOpaqueUnitedOpaque2) { … }
TEST_P(PaintArtifactCompositorTest, DecompositeEffectWithNoOutputClip) { … }
TEST_P(PaintArtifactCompositorTest, CompositedEffectWithNoOutputClip) { … }
TEST_P(PaintArtifactCompositorTest, LayerRasterInvalidationWithClip) { … }
TEST_P(PaintArtifactCompositorTest, CreatesViewportNodes) { … }
TEST_P(PaintArtifactCompositorTest, InSubtreeOfPageScale) { … }
TEST_P(PaintArtifactCompositorTest, ViewportPageScale) { … }
enum { … };
#define EXPECT_OPACITY(effect_id, expected_opacity, expected_flags) …
TEST_P(PaintArtifactCompositorTest, OpacityRenderSurfaces) { … }
TEST_P(PaintArtifactCompositorTest, OpacityRenderSurfacesWithFilterChildren) { … }
TEST_P(PaintArtifactCompositorTest, OpacityAnimationRenderSurfaces) { … }
TEST_P(PaintArtifactCompositorTest, OpacityRenderSurfacesWithBackdropChildren) { … }
TEST_P(PaintArtifactCompositorTest,
DirectTransformAnimationCausesRenderSurfaceFor2dAxisMisalignedClip) { … }
TEST_P(PaintArtifactCompositorTest,
IndirectTransformAnimationCausesRenderSurfaceFor2dAxisMisalignedClip) { … }
TEST_P(PaintArtifactCompositorTest, OpacityIndirectlyAffectingTwoLayers) { … }
TEST_P(PaintArtifactCompositorTest, WillChangeOpacityRenderSurfaceWithLayer) { … }
TEST_P(PaintArtifactCompositorTest,
WillChangeOpacityRenderSurfaceWithoutLayer) { … }
TEST_P(PaintArtifactCompositorTest,
OpacityIndirectlyAffectingTwoLayersWithOpacityAnimations) { … }
TEST_P(PaintArtifactCompositorTest, FilterCreatesRenderSurface) { … }
TEST_P(PaintArtifactCompositorTest, WillChangeFilterCreatesRenderSurface) { … }
TEST_P(PaintArtifactCompositorTest, FilterAnimationCreatesRenderSurface) { … }
TEST_P(PaintArtifactCompositorTest, BackdropFilterCreatesRenderSurface) { … }
TEST_P(PaintArtifactCompositorTest,
WillChangeBackdropFilterCreatesRenderSurface) { … }
TEST_P(PaintArtifactCompositorTest,
BackdropFilterAnimationCreatesRenderSurface) { … }
TEST_P(PaintArtifactCompositorTest, Non2dAxisAlignedClip) { … }
TEST_P(PaintArtifactCompositorTest, Non2dAxisAlignedRoundedRectClip) { … }
TEST_P(PaintArtifactCompositorTest,
Non2dAxisAlignedClipUnderLaterRenderSurface) { … }
static TransformPaintPropertyNode::State Transform3dState(
const gfx::Transform& transform) { … }
TEST_P(PaintArtifactCompositorTest, TransformChange) { … }
TEST_P(PaintArtifactCompositorTest, EffectChange) { … }
TEST_P(PaintArtifactCompositorTest, DirectlySetScrollOffset) { … }
TEST_P(PaintArtifactCompositorTest, NoCommitRequestForUnchangedScroll) { … }
TEST_P(PaintArtifactCompositorTest, AddIndirectlyCompositedScrollNodes) { … }
TEST_P(PaintArtifactCompositorTest, AddNonCompositedScrollNodes) { … }
TEST_P(PaintArtifactCompositorTest, AddNonCompositedMainThreadScrollNodes) { … }
TEST_P(PaintArtifactCompositorTest,
AddIndirectlyCompositedMainThreadScrollNodes) { … }
TEST_P(PaintArtifactCompositorTest, AddUnpaintedNonCompositedScrollNodes) { … }
TEST_P(PaintArtifactCompositorTest, RepaintIndirectScrollHitTest) { … }
TEST_P(PaintArtifactCompositorTest, ClearChangedStateWithIndirectTransform) { … }
TEST_P(PaintArtifactCompositorTest,
CompositedPixelMovingFilterWithClipExpander) { … }
TEST_P(PaintArtifactCompositorTest,
NonCompositedPixelMovingFilterWithCompositedClipExpander) { … }
TEST_P(PaintArtifactCompositorTest,
CreatePictureLayerForSolidColorBackdropFilterMask) { … }
}
}