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

// Copyright 2024 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/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

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

#include <memory>
#include <optional>
#include <utility>

#include "cc/base/math_util.h"
#include "components/viz/common/display/renderer_settings.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/quads/aggregated_render_pass_draw_quad.h"
#include "components/viz/common/quads/solid_color_draw_quad.h"
#include "components/viz/service/display/overlay_processor_interface.h"
#include "components/viz/service/display/overlay_processor_stub.h"
#include "components/viz/test/compositor_frame_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/rect.h"

namespace viz {
namespace {

constexpr float kDefaultDeviceScaleFactor =;

size_t NumVisibleRects(const QuadList& quads) {}

class OcclusionCullerTest : public testing::Test {};

// Quads that require blending should not be treated as occluders
// regardless of full opacity.
TEST_F(OcclusionCullerTest, OcclusionCullingWithBlending) {}

// Quads that intersect backdrop filter render pass quads should not be
// split because splitting may affect how the filter applies to an
// underlying quad.
TEST_F(OcclusionCullerTest, OcclusionCullingWithIntersectingBackdropFilter) {}

// Check if occlusion culling does not remove any DrawQuads when no quad is
// being covered completely.
TEST_F(OcclusionCullerTest, OcclusionCullingWithNonCoveringDrawQuad) {}

// Check if the occlusion culling removes a DrawQuad that is hidden behind
// a smaller disjointed DrawQuad.
// NOTE: this test will fail if RendererSettings.kMaximumOccluderComplexity is
// reduced to 1, since |rects[1]| will become the only occluder, and the quad
// defined by |rects[2]| will not be occluded (removed).
TEST_F(OcclusionCullerTest,
       OcclusionCullingWithSingleOverlapBehindDisjointedDrawQuads) {}

// Check if the occlusion culling removes DrawQuads that are hidden behind
// two different sized disjointed DrawQuads.
// NOTE: this test will fail if RendererSettings.kMaximumOccluderComplexity is
// reduced to 1, since |rects[1]| will become the only occluder, and the quad
// defined by |rects[2]| will not be occluded (removed).
TEST_F(OcclusionCullerTest,
       OcclusionCullingWithMultipleOverlapBehindDisjointedDrawQuads) {}

// Check if occlusion culling removes DrawQuads that are not shown on screen.
TEST_F(OcclusionCullerTest, CompositorFrameWithOverlapDrawQuad) {}

// Check if occlusion occlusion works well with scale change transformer.
TEST_F(OcclusionCullerTest, CompositorFrameWithTransformer) {}

// Check if occlusion culling works with transform at epsilon scale.
TEST_F(OcclusionCullerTest, CompositorFrameWithEpsilonScaleTransform) {}

// Check if occlusion culling works with transform at negative scale.
TEST_F(OcclusionCullerTest, CompositorFrameWithNegativeScaleTransform) {}

// Check if occlusion culling works well with rotation transform.
//
//  +-----+                                  +----+
//  |     |   rotation (by 45 on y-axis) ->  |    |     same height
//  +-----+                                  +----+     reduced weight
TEST_F(OcclusionCullerTest, CompositorFrameWithRotation) {}

// Check if occlusion culling is handled correctly if the transform does not
// preserves 2d axis alignment.
TEST_F(OcclusionCullerTest, CompositorFrameWithPerspective) {}

// Check if occlusion culling works with transparent DrawQuads.
TEST_F(OcclusionCullerTest, CompositorFrameWithOpacityChange) {}

TEST_F(OcclusionCullerTest, CompositorFrameWithOpaquenessChange) {}

// Test if occlusion culling skips 3d objects. https://crbug.com/833748
TEST_F(OcclusionCullerTest, CompositorFrameZTranslate) {}

TEST_F(OcclusionCullerTest, CompositorFrameWithTranslateTransformer) {}

TEST_F(OcclusionCullerTest, CompositorFrameWithCombinedSharedQuadState) {}

// Remove overlapping quads in non-root render passes.
TEST_F(OcclusionCullerTest, OcclusionCullingWithMultipleRenderPass) {}

// Occlusion tracking should not persist across render passes.
TEST_F(OcclusionCullerTest, CompositorFrameWithMultipleRenderPass) {}

TEST_F(OcclusionCullerTest, CompositorFrameWithCoveredRenderPass) {}

TEST_F(OcclusionCullerTest, CompositorFrameWithClip) {}

// Check if occlusion culling works with copy requests in root RenderPass only.
TEST_F(OcclusionCullerTest, CompositorFrameWithCopyRequest) {}

TEST_F(OcclusionCullerTest, CompositorFrameWithRenderPass) {}

TEST_F(OcclusionCullerTest,
       CompositorFrameWithMultipleDrawQuadInSharedQuadState) {}

TEST_F(OcclusionCullerTest, CompositorFrameWithNonInvertibleTransform) {}

// Check if occlusion culling works with very large DrawQuad. crbug.com/824528.
TEST_F(OcclusionCullerTest, OcclusionCullingWithLargeDrawQuad) {}

TEST_F(OcclusionCullerTest, OcclusionCullingWithRoundedCornerDoesNotOcclude) {}

TEST_F(OcclusionCullerTest, OcclusionCullingWithRoundedCornerDoesNotOccludeY) {}

TEST_F(OcclusionCullerTest, OcclusionCullingWithRoundedCornerDoesNotOccludeX) {}

TEST_F(OcclusionCullerTest, OcclusionCullingWithRoundedCornerDoesOcclude) {}

TEST_F(OcclusionCullerTest, OcclusionCullingWithRoundedCornerDoesOccludeXY) {}

TEST_F(OcclusionCullerTest, OcclusionCullingSplit) {}

// Tests cases in which occlusion culling splits are performed due to first pass
// complexity reduction in visible regions. For more details, see:
// https://tinyurl.com/RegionComplexityReduction#heading=h.fg95k5w5t791
TEST_F(OcclusionCullerTest, FirstPassVisibleComplexityReduction) {}

TEST_F(OcclusionCullerTest, OcclusionCullingWithRoundedCornerPartialOcclude) {}

// Test that the threshold we use to determine if it's worth splitting a quad or
// not takes into account the device scale factor. In particular, this test
// would not pass if we had a display scale factor equal to 1.f instead of 1.5f
// since the number of saved fragments would only be 100x100 which is lower than
// our threshold 128x128.
TEST_F(OcclusionCullerTest, OcclusionCullingSplitDeviceScaleFactorFractional) {}

}  // namespace
}  // namespace viz