chromium/components/viz/service/display/overlay_candidate_factory_unittest.cc

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

#include "components/viz/service/display/overlay_candidate_factory.h"

#include <unordered_map>
#include <vector>

#include "base/dcheck_is_on.h"
#include "components/viz/client/client_resource_provider.h"
#include "components/viz/common/gpu/context_provider.h"
#include "components/viz/common/quads/aggregated_render_pass.h"
#include "components/viz/common/quads/aggregated_render_pass_draw_quad.h"
#include "components/viz/common/quads/draw_quad.h"
#include "components/viz/common/quads/solid_color_draw_quad.h"
#include "components/viz/common/quads/texture_draw_quad.h"
#include "components/viz/common/resources/resource_id.h"
#include "components/viz/common/resources/shared_image_format.h"
#include "components/viz/service/display/aggregated_frame.h"
#include "components/viz/service/display/display_resource_provider.h"
#include "components/viz/service/display/display_resource_provider_null.h"
#include "components/viz/service/display/overlay_candidate.h"
#include "components/viz/test/test_context_provider.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/test/geometry_util.h"
#include "ui/gfx/overlay_transform_utils.h"
#include "ui/gfx/video_types.h"

_;
Mock;

namespace viz {
namespace {

RoundedDisplayMasksInfo;

OverlayCandidateFactory::OverlayContext GetOverlayContextForTesting() {}

// TODO(zoraiznaeem): Move resource creation code into OverlayTestBase class.
class OverlayCandidateFactoryTestBase : public testing::Test {};

SolidColorDrawQuad* AddQuad(const gfx::Rect quad_rect,
                            const gfx::Transform& quad_to_target_transform,
                            AggregatedRenderPass* render_pass,
                            const std::optional<gfx::Rect> clip_rect,
                            const gfx::Rect visible_rect) {}

SolidColorDrawQuad* AddQuad(const gfx::Rect quad_rect,
                            const gfx::Transform& quad_to_target_transform,
                            AggregatedRenderPass* render_pass) {}

AggregatedRenderPassDrawQuad* AddRenderPassQuad(
    gfx::Rect quad_rect,
    gfx::Transform transform,
    std::optional<gfx::Rect> clip_rect,
    AggregatedRenderPassId rpid,
    AggregatedRenderPass* render_pass) {}

OverlayCandidate CreateCandidate(float left,
                                 float top,
                                 float right,
                                 float bottom) {}

OverlayCandidateFactoryTest;

TEST_F(OverlayCandidateFactoryTest, IsOccluded) {}

TEST_F(OverlayCandidateFactoryTest, IsOccludedScaled) {}

TEST_F(OverlayCandidateFactoryTest, RoundedCorner) {}

TEST_F(OverlayCandidateFactoryTest, RoundedCornerOptimizedwireSize) {}

class OverlayCandidateFactoryArbitraryTransformTest
    : public OverlayCandidateFactoryTestBase {};

// Check that axis-aligned transforms are stored as OverlayTransforms when
// possible.
TEST_F(OverlayCandidateFactoryArbitraryTransformTest,
       AxisAlignedNotBakedIntoDisplayRect) {}

// Check that even arbitrary transforms are preserved on the overlay
// candidate.
TEST_F(OverlayCandidateFactoryArbitraryTransformTest, SupportsNonAxisAligned) {}

// Check that we include the Y-flip state with our arbitrary transform since
// we don't include it on the gfx::OverlayTransform in this case.
TEST_F(OverlayCandidateFactoryArbitraryTransformTest, TransformIncludesYFlip) {}

TEST_F(OverlayCandidateFactoryArbitraryTransformTest,
       UseArbitraryTransformWhenSupported) {}

TEST_F(OverlayCandidateFactoryArbitraryTransformTest,
       UseOverlayTransformWhenPossibleForWireSize) {}

TEST_F(OverlayCandidateFactoryArbitraryTransformTest,
       Allow3DTransformNoPerspective) {}

// Checks that a transform that preserve the flatness of quads on the XY-plane,
// but not necessarily without perspective are still allowed to be promoted.
TEST_F(OverlayCandidateFactoryArbitraryTransformTest,
       TechnicallyFlatTransform) {}

#if DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST)
class OverlayCandidateFactoryInvalidContextTest
    : public OverlayCandidateFactoryTestBase {};

// Check that OverlayCandidateFactory isn't changed to allow for arbitrary
// transform support when clip support is not available. Such a configuration
// would likely be incorrect since clip rects are generally provided in target
// space and cannot be baked into the display rect when there is an arbitrary
// transform in between.
TEST_F(OverlayCandidateFactoryInvalidContextTest, NoClipSupport) {}

// All quads have a transform on their |sqs|, we need to support some way to
// store it on our OverlayCandidates. This test checks that an
// OverlayCandidateFactory without transform support is invalid.
TEST_F(OverlayCandidateFactoryInvalidContextTest, NoTransformSupport) {}
#endif

// Check that a factory fails to promote a quad with a non-axis-aligned
// transform when it doesn't support arbitrary transforms.
TEST_F(OverlayCandidateFactoryArbitraryTransformTest,
       NoArbitraryTransformSupportFails) {}

TEST_F(OverlayCandidateFactoryArbitraryTransformTest,
       OccludedByFilteredQuadWorksInTargetSpace) {}

TEST_F(OverlayCandidateFactoryArbitraryTransformTest,
       UnassignedDamageWithArbitraryTransforms) {}

constexpr float kEpsilon =;

// Check that uv clips are applied correctly when the candidate is transformed.
class TransformedOverlayClipRectTest : public OverlayCandidateFactoryTestBase {};

TEST_F(TransformedOverlayClipRectTest, NoTransform) {}

TEST_F(TransformedOverlayClipRectTest, Rotate90) {}

TEST_F(TransformedOverlayClipRectTest, Rotate180) {}

TEST_F(TransformedOverlayClipRectTest, Rotate270) {}

TEST_F(TransformedOverlayClipRectTest, ClippedUvs) {}

// Test to make sure we handle overlays that need detiling and have a rotation
// correctly. The UV rect of these overlays assumes no rotation, so we have to
// rotate them before applying the clip.
TEST_F(TransformedOverlayClipRectTest, NoTransformNeedsDetiling) {}

TEST_F(TransformedOverlayClipRectTest, Rotate90NeedsDetiling) {}

TEST_F(TransformedOverlayClipRectTest, Rotate180NeedsDetiling) {}

TEST_F(TransformedOverlayClipRectTest, Rotate270NeedsDetiling) {}

TEST_F(OverlayCandidateFactoryTest, RenderPassClipped) {}

TEST_F(OverlayCandidateFactoryTest, RenderPassOffscreen) {}

TEST_F(OverlayCandidateFactoryTest, RenderPassOffscreenBeforeFilter) {}

TEST_F(OverlayCandidateFactoryTest, ClipDelegation_Success) {}

TEST_F(OverlayCandidateFactoryTest, ClipDelegation_OutOfWindow) {}

TEST_F(OverlayCandidateFactoryTest, ClipDelegation_VisibleRect) {}

}  // namespace
}  // namespace viz