chromium/cc/trees/occlusion_tracker_unittest.cc

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

#include "cc/trees/occlusion_tracker.h"

#include <stddef.h>

#include <memory>
#include <utility>

#include "base/test/scoped_feature_list.h"
#include "cc/animation/animation_host.h"
#include "cc/base/math_util.h"
#include "cc/layers/layer.h"
#include "cc/layers/layer_impl.h"
#include "cc/paint/filter_operation.h"
#include "cc/paint/filter_operations.h"
#include "cc/test/animation_test_common.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_impl.h"
#include "cc/test/layer_test_common.h"
#include "cc/test/property_tree_test_utils.h"
#include "cc/test/test_occlusion_tracker.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/draw_property_utils.h"
#include "cc/trees/single_thread_proxy.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/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/transform.h"

namespace cc {
namespace {

class TestContentLayerImpl : public LayerImpl {};

class TestOcclusionTrackerWithClip : public TestOcclusionTracker {};

class OcclusionTrackerTest : public testing::Test {};

#define RUN_TEST_IMPL_THREAD_OPAQUE_LAYERS(ClassName)
#define RUN_TEST_IMPL_THREAD_OPAQUE_PAINTS(ClassName)

#define ALL_OCCLUSIONTRACKER_TEST(ClassName)

class OcclusionTrackerTestIdentityTransforms : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestIdentityTransforms)

class OcclusionTrackerTestRotatedChild : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestRotatedChild)

class OcclusionTrackerTestTranslatedChild : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestTranslatedChild)

class OcclusionTrackerTestChildInRotatedChild : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestChildInRotatedChild)

class OcclusionTrackerTestScaledRenderSurface : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledRenderSurface)

class OcclusionTrackerTestVisitTargetTwoTimes : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestVisitTargetTwoTimes)

class OcclusionTrackerTestSurfaceRotatedOffAxis : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceRotatedOffAxis)

class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithTwoOpaqueChildren)

class OcclusionTrackerTestOverlappingSurfaceSiblings
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOverlappingSurfaceSiblings)

class OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(
    OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms)

class OcclusionTrackerTestFilters : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestFilters)

class OcclusionTrackerTestFiltersRenderSurfaceOcclusion
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestFiltersRenderSurfaceOcclusion)

class OcclusionTrackerTestOpaqueContentsRegionEmpty
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty)

class OcclusionTrackerTestOpaqueContentsRegionNonEmpty
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOpaqueContentsRegionNonEmpty)

class OcclusionTrackerTestLayerBehindCameraDoesNotOcclude
    : public OcclusionTrackerTest {};

class OcclusionTrackerTestSurfaceOcclusionTranslatesToParent
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(
    OcclusionTrackerTestSurfaceOcclusionTranslatesToParent)

class OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(
    OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping)

class OcclusionTrackerTestSurfaceChildOfSurface : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface)

class OcclusionTrackerTestDontOccludePixelsNeededForBackdropFilter
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(
    OcclusionTrackerTestDontOccludePixelsNeededForBackdropFilter)

class OcclusionTrackerTestPixelsNeededForDropShadowBackdropFilter
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(
    OcclusionTrackerTestPixelsNeededForDropShadowBackdropFilter)

class OcclusionTrackerTestTwoBackdropFiltersReduceOcclusionTwice
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(
    OcclusionTrackerTestTwoBackdropFiltersReduceOcclusionTwice)

class OcclusionTrackerTestDontReduceOcclusionBelowBackdropFilter
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(
    OcclusionTrackerTestDontReduceOcclusionBelowBackdropFilter)

class OcclusionTrackerTestDontReduceOcclusionIfBackdropFilterIsOccluded
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(
    OcclusionTrackerTestDontReduceOcclusionIfBackdropFilterIsOccluded)

class OcclusionTrackerTestReduceOcclusionWhenBkgdFilterIsPartiallyOccluded
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(
    OcclusionTrackerTestReduceOcclusionWhenBkgdFilterIsPartiallyOccluded)

class OcclusionTrackerTestRenderSurfaceOccludingBlendMode
    : public OcclusionTrackerTest {};

class OcclusionTrackerTestRenderSurfaceBlendModeSrcOver
    : public OcclusionTrackerTestRenderSurfaceOccludingBlendMode {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestRenderSurfaceBlendModeSrcOver)

class OcclusionTrackerTestRenderSurfaceBlendModeSrc
    : public OcclusionTrackerTestRenderSurfaceOccludingBlendMode {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestRenderSurfaceBlendModeSrc)

class OcclusionTrackerTestRenderSurfaceNonOccludingBlendMode
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(
    OcclusionTrackerTestRenderSurfaceNonOccludingBlendMode)

// No OcclusionTrackerTestNonRenderSurfaceOccludingBlendMode because kSrcOver is
// default and is tested in many other tests, and kSrc always creates a render
// surface.

class OcclusionTrackerTestNonRenderSurfaceNonOccludingBlendMode
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(
    OcclusionTrackerTestNonRenderSurfaceNonOccludingBlendMode)

class OcclusionTrackerTestMinimumTrackingSize : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestMinimumTrackingSize)

class OcclusionTrackerTestScaledLayerIsClipped : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledLayerIsClipped)

class OcclusionTrackerTestScaledLayerInSurfaceIsClipped
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledLayerInSurfaceIsClipped)

class OcclusionTrackerTestCopyRequestDoesOcclude : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestCopyRequestDoesOcclude)

class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude
    : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude)

class OcclusionTrackerTestOccludedLayer : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOccludedLayer)

class OcclusionTrackerTestUnoccludedLayerQuery : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedLayerQuery)

class OcclusionTrackerTestUnoccludedSurfaceQuery : public OcclusionTrackerTest {};

ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery)

}  // namespace
}  // namespace cc