chromium/gpu/command_buffer/service/shared_image/ozone_image_backing_factory_unittest.cc

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

#include "gpu/command_buffer/service/shared_image/ozone_image_backing_factory.h"

#include "components/viz/common/resources/shared_image_format.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/command_buffer/service/shared_image/gl_ozone_image_representation.h"
#include "gpu/command_buffer/service/shared_image/ozone_image_backing.h"
#include "gpu/command_buffer/service/shared_image/ozone_image_gl_textures_holder.h"
#include "gpu/command_buffer/service/shared_image/shared_image_manager.h"
#include "gpu/command_buffer/service/shared_image/shared_image_test_base.h"
#include "gpu/config/gpu_finch_features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/gl_utils.h"
#include "ui/gl/init/gl_factory.h"

namespace gpu {

namespace {

class FakeOnScreenSurface : public gl::SurfacelessEGL {};

}  // namespace

class OzoneImageBackingFactoryTest : public SharedImageTestBase {};

TEST_F(OzoneImageBackingFactoryTest, UsesCacheForTextureHolders) {}

// Verifies that the cache is not used for onscreen surfaces.
TEST_F(OzoneImageBackingFactoryTest, UsesCacheForTextureHolders2) {}

TEST_F(OzoneImageBackingFactoryTest, MarksContextLostOnContextLost) {}

// Same as above, but with an onscreen surface.
TEST_F(OzoneImageBackingFactoryTest, MarksContextLostOnContextLost2) {}

TEST_F(OzoneImageBackingFactoryTest, RemovesTextureHoldersOnContextDestroy) {}

// If textures are created for different contexts, the SI must restore a
// previous current context upon destruction a texture from a different context.
TEST_F(OzoneImageBackingFactoryTest, RestoresContextOnAnotherContextDestroy) {}

// Verifies that if there is a compatible context, the texture is reused. Eg,
// there was a request to create a texture for one context, then the context was
// changed and another request came. If the contexts are compatible, the texture
// holder is reused. Otherwise, a new texture is created.
TEST_F(OzoneImageBackingFactoryTest, FindsCompatibleContextAndReusesTexture) {}

// If the cached textures holder is shared between two contexts, which are
// compatible for such usage, destruction of one context or making it loose
// context shouldn't make a texture holder destroy textures or mark texture as
// context lost. Once all contexts have context lost or are destroy, only then
// the holder must destroy textures and/or mark them as context lost.
TEST_F(OzoneImageBackingFactoryTest, CorrectlyDestroysAndMarksContextLost) {}

}  // namespace gpu