chromium/cc/layers/picture_layer_impl_unittest.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "cc/layers/picture_layer_impl.h"

#include <stddef.h>

#include <algorithm>
#include <limits>
#include <memory>
#include <set>
#include <utility>

#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/test/scoped_feature_list.h"
#include "cc/animation/animation_host.h"
#include "cc/base/features.h"
#include "cc/base/math_util.h"
#include "cc/layers/append_quads_data.h"
#include "cc/layers/picture_layer.h"
#include "cc/test/fake_content_layer_client.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.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_picture_layer_impl.h"
#include "cc/test/fake_raster_source.h"
#include "cc/test/fake_recording_source.h"
#include "cc/test/layer_tree_impl_test_base.h"
#include "cc/test/skia_common.h"
#include "cc/test/test_layer_tree_host_base.h"
#include "cc/test/test_paint_worklet_input.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/tiles/tiling_set_raster_queue_all.h"
#include "cc/tiles/tiling_set_raster_queue_required.h"
#include "cc/trees/layer_tree_impl.h"
#include "components/viz/common/quads/draw_quad.h"
#include "components/viz/common/quads/tile_draw_quad.h"
#include "components/viz/test/begin_frame_args_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/test/geometry_util.h"

namespace cc {
namespace {

#define EXPECT_BOTH_EQ(expression, x)

#define EXPECT_BOTH_NE(expression, x)

#define EXPECT_BOTH_TRUE(expression)

#define EXPECT_BOTH_FALSE(expression)

class PictureLayerImplTest : public TestLayerTreeHostBase {};

// Legacy PictureLayerImplTest which forces SW rasterization. New tests should
// default to the more common GPU rasterization path.
class LegacySWPictureLayerImplTest : public PictureLayerImplTest {};

class CommitToActiveTreePictureLayerImplTest : public PictureLayerImplTest {};

class NoLowResPictureLayerImplTest : public LegacySWPictureLayerImplTest {};

TEST_F(LegacySWPictureLayerImplTest, CloneNoInvalidation) {}

TEST_F(LegacySWPictureLayerImplTest, ExternalViewportRectForPrioritizingTiles) {}

TEST_F(LegacySWPictureLayerImplTest, ViewportRectForTilePriorityIsCached) {}

TEST_F(LegacySWPictureLayerImplTest, ClonePartialInvalidation) {}

TEST_F(LegacySWPictureLayerImplTest, CloneFullInvalidation) {}

TEST_F(LegacySWPictureLayerImplTest, UpdateTilesCreatesTilings) {}

TEST_F(LegacySWPictureLayerImplTest, PendingLayerOnlyHasHighResTiling) {}

TEST_F(LegacySWPictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) {}

TEST_F(LegacySWPictureLayerImplTest, LowResTilingStaysOnActiveTree) {}

TEST_F(LegacySWPictureLayerImplTest, ZoomOutCrash) {}

TEST_F(LegacySWPictureLayerImplTest, ScaledBoundsOverflowInt) {}

TEST_F(LegacySWPictureLayerImplTest, PinchGestureTilings) {}

TEST_F(LegacySWPictureLayerImplTest, SnappedTilingDuringZoom) {}

TEST_F(LegacySWPictureLayerImplTest, CleanUpTilings) {}

TEST_F(LegacySWPictureLayerImplTest, DontAddLowResDuringAnimation) {}

TEST_F(LegacySWPictureLayerImplTest, DontAddLowResForSmallLayers) {}

TEST_F(LegacySWPictureLayerImplTest, HugeBackdropFilterMasksGetScaledDown) {}

TEST_F(LegacySWPictureLayerImplTest, ScaledBackdropFilterMaskLayer) {}

TEST_F(LegacySWPictureLayerImplTest, ScaledMaskLayer) {}

TEST_F(LegacySWPictureLayerImplTest, ReleaseTileResources) {}

// ReleaseResources should behave identically to ReleaseTileResources.
TEST_F(LegacySWPictureLayerImplTest, ReleaseResources) {}

TEST_F(LegacySWPictureLayerImplTest, ClampTilesToMaxTileSize) {}

TEST_F(LegacySWPictureLayerImplTest, ClampSingleTileToToMaxTileSize) {}

TEST_F(LegacySWPictureLayerImplTest, DisallowTileDrawQuads) {}

TEST_F(LegacySWPictureLayerImplTest, ResourcelessPartialRecording) {}

TEST_F(LegacySWPictureLayerImplTest, ResourcelessRecordingNotVisible) {}

TEST_F(LegacySWPictureLayerImplTest, FarScrolledQuadsShifted) {}

TEST_F(LegacySWPictureLayerImplTest, FarScrolledSolidColorQuadsShifted) {}

TEST_F(LegacySWPictureLayerImplTest, SolidColorLayerHasVisibleFullCoverage) {}

TEST_F(LegacySWPictureLayerImplTest, TileScalesWithSolidColorRasterSource) {}

TEST_F(NoLowResPictureLayerImplTest, MarkRequiredOffscreenTiles) {}

TEST_F(NoLowResPictureLayerImplTest,
       TileOutsideOfViewportForTilePriorityNotRequired) {}

TEST_F(LegacySWPictureLayerImplTest, HighResTileIsComplete) {}

TEST_F(LegacySWPictureLayerImplTest, HighResTileIsIncomplete) {}

TEST_F(LegacySWPictureLayerImplTest, HighResTileIsIncompleteLowResComplete) {}

TEST_F(LegacySWPictureLayerImplTest, LowResTileIsIncomplete) {}

TEST_F(LegacySWPictureLayerImplTest,
       HighResAndIdealResTileIsCompleteWhenRasterScaleIsNotIdeal) {}

TEST_F(LegacySWPictureLayerImplTest, AppendQuadsDataForCheckerboard) {}

TEST_F(LegacySWPictureLayerImplTest, HighResRequiredWhenActiveAllReady) {}

TEST_F(LegacySWPictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) {}

TEST_F(LegacySWPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) {}

TEST_F(LegacySWPictureLayerImplTest, DisallowRequiredForActivation) {}

TEST_F(LegacySWPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {}

TEST_F(LegacySWPictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) {}

TEST_F(LegacySWPictureLayerImplTest,
       HighResRequiredWhenActiveHasDifferentBounds) {}

TEST_F(LegacySWPictureLayerImplTest, ActivateUninitializedLayer) {}

TEST_F(LegacySWPictureLayerImplTest, ShareTilesOnNextFrame) {}

TEST_F(LegacySWPictureLayerImplTest, PendingHasNoTilesWithNoInvalidation) {}

TEST_F(LegacySWPictureLayerImplTest, ShareInvalidActiveTreeTiles) {}

TEST_F(LegacySWPictureLayerImplTest, RecreateInvalidPendingTreeTiles) {}

TEST_F(LegacySWPictureLayerImplTest, HighResCreatedWhenBoundsShrink) {}

// Tests when directly committing to the active tree, a small raster source
// makes the minimum scale bigger than the the previous high res tiling scale,
// causing the high res tiling (if not previously used for quads) to be removed.
// See crbug.com/1160003.
TEST_F(LegacySWPictureLayerImplTest,
       HighResCreatedWhenBoundsShrinkOnActiveLayerWithUsedNonIdealScaleTiling) {}

TEST_F(LegacySWPictureLayerImplTest, LowResTilingWithoutGpuRasterization) {}

TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) {}

TEST_F(PictureLayerImplTest, RequiredTilesWithGpuRasterization) {}

TEST_F(CommitToActiveTreePictureLayerImplTest,
       RequiredTilesWithGpuRasterizationAndFractionalDsf) {}

TEST_F(LegacySWPictureLayerImplTest, NoTilingIfDoesNotDrawContent) {}

TEST_F(LegacySWPictureLayerImplTest, FirstTilingDuringPinch) {}

TEST_F(LegacySWPictureLayerImplTest, PinchingTooSmall) {}

TEST_F(LegacySWPictureLayerImplTest, PinchingTooSmallWithContentsScale) {}

TEST_F(LegacySWPictureLayerImplTest, HighResTilingDuringAnimation) {}

TEST_F(LegacySWPictureLayerImplTest, HighResTilingDuringAnimationWideLayer) {}

TEST_F(LegacySWPictureLayerImplTest,
       HighResTilingDuringAnimationSmallerAnimationScale) {}

TEST_F(LegacySWPictureLayerImplTest,
       HighResTilingDuringAnimationSmallerAnimationScaleWithInvalidScale) {}

TEST_F(LegacySWPictureLayerImplTest, ViewportSizeChangeDuringAnimation) {}

TEST_F(LegacySWPictureLayerImplTest,
       AnimationTilingChangesWithWillChangeTransformHint) {}

TEST_F(LegacySWPictureLayerImplTest, HighResTilingDuringAnimationAspectRatio) {}

TEST_F(LegacySWPictureLayerImplTest,
       HighResTilingDuringAnimationAspectRatioTooLarge) {}

TEST_F(LegacySWPictureLayerImplTest, TilingSetRasterQueue) {}

TEST_F(LegacySWPictureLayerImplTest, TilingSetRasterQueueActiveTree) {}

TEST_F(LegacySWPictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) {}

TEST_F(LegacySWPictureLayerImplTest, TilingSetEvictionQueue) {}

TEST_F(LegacySWPictureLayerImplTest, Occlusion) {}

TEST_F(LegacySWPictureLayerImplTest, OcclusionOnSolidColorPictureLayer) {}

TEST_F(LegacySWPictureLayerImplTest, IgnoreOcclusionOnSolidColorMask) {}

TEST_F(LegacySWPictureLayerImplTest, RasterScaleChangeWithoutAnimation) {}

TEST_F(LegacySWPictureLayerImplTest, TinyRasterScale) {}

TEST_F(LegacySWPictureLayerImplTest,
       ForceAdjustRasterScaleWillChangeTransform) {}

TEST_F(LegacySWPictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) {}

TEST_F(LegacySWPictureLayerImplTest, HighResReadyToDrawEnoughToActivate) {}

TEST_F(LegacySWPictureLayerImplTest, ActiveHighResReadyNotEnoughToActivate) {}

TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) {}

TEST_F(NoLowResPictureLayerImplTest, PendingLayerOnlyHasHighResTiling) {}

TEST_F(NoLowResPictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) {}

TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {}

TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) {}

TEST_F(NoLowResPictureLayerImplTest, ReleaseTileResources) {}

TEST_F(LegacySWPictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) {}

class PictureLayerImplTestWithDelegatingRenderer
    : public LegacySWPictureLayerImplTest {};

TEST_F(PictureLayerImplTestWithDelegatingRenderer,
       DelegatingRendererWithTileOOM) {}

class OcclusionTrackingPictureLayerImplTest
    : public LegacySWPictureLayerImplTest {};

TEST_F(OcclusionTrackingPictureLayerImplTest,
       OccludedTilesSkippedDuringRasterization) {}

TEST_F(OcclusionTrackingPictureLayerImplTest,
       OccludedTilesNotMarkedAsRequired) {}

void OcclusionTrackingPictureLayerImplTest::TestOcclusionForScale(
    float scale,
    int expected_occluded_count) {}

TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForScale0_3) {}

TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForScale0_7) {}

TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForScale1) {}

TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForScale2) {}

TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) {}

TEST_F(OcclusionTrackingPictureLayerImplTest,
       OccludedTilesConsideredDuringEviction) {}

TEST_F(LegacySWPictureLayerImplTest, PendingOrActiveTwinLayer) {}

void GetClientDataAndUpdateInvalidation(RecordingSource& recording_source,
                                        FakeContentLayerClient* client,
                                        gfx::Size layer_bounds) {}

void PictureLayerImplTest::TestQuadsForSolidColor(bool test_for_solid,
                                                  bool partial_opaque) {}

TEST_F(LegacySWPictureLayerImplTest, DrawSolidQuads) {}

TEST_F(LegacySWPictureLayerImplTest, DrawNonSolidQuads) {}

TEST_F(LegacySWPictureLayerImplTest, DrawTransparentQuads) {}

TEST_F(LegacySWPictureLayerImplTest, NonSolidToSolidNoTilings) {}

TEST_F(LegacySWPictureLayerImplTest, ChangeInViewportAllowsTilingUpdates) {}

TEST_F(LegacySWPictureLayerImplTest, CloneMissingRecordings) {}

TEST_F(LegacySWPictureLayerImplTest,
       DirectlyCompositedImageRasterSourceCoverage) {}

TEST_F(LegacySWPictureLayerImplTest, ScrollPastLiveTilesRectAndBack) {}

TEST_F(LegacySWPictureLayerImplTest, ScrollPropagatesToPending) {}

TEST_F(LegacySWPictureLayerImplTest, UpdateLCDTextInvalidatesPendingTree) {}

TEST_F(LegacySWPictureLayerImplTest, UpdateLCDTextPushToActiveTree) {}

TEST_F(LegacySWPictureLayerImplTest, UpdateLCDTextPushToActiveTreeWith2dScale) {}

TEST_F(LegacySWPictureLayerImplTest, TilingAllTilesDone) {}

class TileSizeTest : public PictureLayerImplTest {};

class LegacySWTileSizeTest : public TileSizeTest {};

TEST_F(LegacySWTileSizeTest, SWTileSizes) {}

TEST_F(TileSizeTest, GPUTileSizes) {}

TEST_F(TileSizeTest, RawDrawTileSizes) {}

class HalfWidthTileTest : public PictureLayerImplTest {};

TEST_F(HalfWidthTileTest, TileSizes) {}

TEST_F(NoLowResPictureLayerImplTest, LowResWasHighResCollision) {}

TEST_F(LegacySWPictureLayerImplTest, HighResWasLowResCollision) {}

TEST_F(LegacySWPictureLayerImplTest, CompositedImageCalculateContentsScale) {}

TEST_F(LegacySWPictureLayerImplTest, CompositedImageIgnoreIdealContentsScale) {}

TEST_F(LegacySWPictureLayerImplTest, CompositedImageRasterScaleChanges) {}

TEST_F(LegacySWPictureLayerImplTest, CompositedImageRasterOnChange) {}

TEST_F(LegacySWPictureLayerImplTest, CompositedImageTinyRasterScale) {}

TEST_F(LegacySWPictureLayerImplTest, CompositedImageHugeRasterScale) {}

TEST_F(LegacySWPictureLayerImplTest, CompositedImageRasterHighResScreen) {}

TEST_F(LegacySWPictureLayerImplTest, CompositedImageRasterOptOutTransitions) {}

TEST_F(LegacySWPictureLayerImplTest,
       ChangeRasterTranslationNukePendingLayerTiles) {}

TEST_F(LegacySWPictureLayerImplTest,
       ChangeRasterTranslationNukeActiveLayerTiles) {}

TEST_F(LegacySWPictureLayerImplTest, AnimatedImages) {}

TEST_F(LegacySWPictureLayerImplTest, PaintWorkletInputPaintRecordInvalidation) {}

TEST_F(LegacySWPictureLayerImplTest, PaintWorkletInputs) {}

TEST_F(LegacySWPictureLayerImplTest, PaintWorkletInputsIdenticalEntries) {}

TEST_F(LegacySWPictureLayerImplTest, NoTilingsUsesScaleOne) {}

TEST_F(LegacySWPictureLayerImplTest,
       TransformedRasterizationAndContentsOpaqueAndLCDText) {}

TEST_F(LegacySWPictureLayerImplTest,
       TransformedRasterizationAndLCDTextWithoutText) {}

TEST_F(LegacySWPictureLayerImplTest, InvalidateRasterInducingScrolls) {}

enum {};

class LCDTextTest : public PictureLayerImplTest,
                    public testing::WithParamInterface<unsigned> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(LCDTextTest, IdentityTransform) {}

TEST_P(LCDTextTest, IntegralTransform) {}

TEST_P(LCDTextTest, NonIntegralTranslation) {}

TEST_P(LCDTextTest, NonIntegralTranslationAboveRenderTarget) {}

TEST_P(LCDTextTest, NonTranslation) {}

TEST_P(LCDTextTest, NonTranslationAboveRenderTarget) {}

TEST_P(LCDTextTest, Opacity) {}

TEST_P(LCDTextTest, ContentsNotOpaque) {}

TEST_P(LCDTextTest, WillChangeTransform) {}

TEST_P(LCDTextTest, Filter) {}

TEST_P(LCDTextTest, FilterAnimation) {}

TEST_P(LCDTextTest, BackdropFilter) {}

TEST_P(LCDTextTest, BackdropFilterAnimation) {}

TEST_P(LCDTextTest, ContentsOpaqueForText) {}

TEST_P(LCDTextTest, TransformAnimation) {}

}  // namespace
}  // namespace cc