#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "gpu/command_buffer/service/shared_image/egl_image_backing_factory.h"
#include <optional>
#include <thread>
#include "base/bits.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/test/run_until.h"
#include "base/test/test_timeouts.h"
#include "build/build_config.h"
#include "components/viz/common/resources/resource_sizes.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/command_buffer/service/service_utils.h"
#include "gpu/command_buffer/service/shared_context_state.h"
#include "gpu/command_buffer/service/shared_image/dawn_image_representation_unittest_common.h"
#include "gpu/command_buffer/service/shared_image/shared_image_backing.h"
#include "gpu/command_buffer/service/shared_image/shared_image_factory.h"
#include "gpu/command_buffer/service/shared_image/shared_image_format_service_utils.h"
#include "gpu/command_buffer/service/shared_image/shared_image_manager.h"
#include "gpu/command_buffer/service/shared_image/shared_image_representation.h"
#include "gpu/command_buffer/service/shared_image/test_utils.h"
#include "gpu/config/gpu_driver_bug_workarounds.h"
#include "gpu/config/gpu_feature_info.h"
#include "gpu/config/gpu_preferences.h"
#include "gpu/config/gpu_test_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/gpu/GrBackendSemaphore.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "third_party/skia/include/private/chromium/GrPromiseImageTexture.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/color_space.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/gl_utils.h"
#include "ui/gl/init/gl_factory.h"
#if BUILDFLAG(USE_DAWN) && BUILDFLAG(DAWN_ENABLE_BACKEND_OPENGLES)
#include <dawn/dawn_proc.h>
#include <dawn/native/DawnNative.h>
#include <dawn/webgpu_cpp.h>
#endif
AtLeast;
namespace gpu {
namespace {
bool IsEglImageSupported() { … }
void CreateSharedContext(const GpuDriverBugWorkarounds& workarounds,
scoped_refptr<gl::GLSurface>& surface,
scoped_refptr<gl::GLContext>& context,
scoped_refptr<SharedContextState>& context_state,
scoped_refptr<gles2::FeatureInfo>& feature_info) { … }
class EGLImageBackingFactoryThreadSafeTest
: public testing::TestWithParam<std::tuple<bool, viz::SharedImageFormat>> { … };
class CreateAndValidateSharedImageRepresentations { … };
TEST_P(EGLImageBackingFactoryThreadSafeTest, BasicThreadSafe) { … }
TEST_P(EGLImageBackingFactoryThreadSafeTest, BasicInitialData) { … }
TEST_P(EGLImageBackingFactoryThreadSafeTest, OneWriterOneReader) { … }
#if BUILDFLAG(USE_DAWN) && BUILDFLAG(DAWN_ENABLE_BACKEND_OPENGLES) && \
!BUILDFLAG(IS_ANDROID)
TEST_P(EGLImageBackingFactoryThreadSafeTest, Dawn_SkiaGL) { … }
TEST_P(EGLImageBackingFactoryThreadSafeTest, Dawn_SampledTexture) { … }
#endif
CreateAndValidateSharedImageRepresentations::
CreateAndValidateSharedImageRepresentations(
EGLImageBackingFactory* backing_factory,
viz::SharedImageFormat format,
bool is_thread_safe,
SharedImageManager* shared_image_manager,
MemoryTypeTracker* memory_type_tracker,
SharedImageRepresentationFactory* shared_image_representation_factory,
SharedContextState* context_state,
bool upload_initial_data)
: … { … }
CreateAndValidateSharedImageRepresentations::
~CreateAndValidateSharedImageRepresentations() { … }
const auto kSharedImageFormats = …;
std::string TestParamToString(
const testing::TestParamInfo<std::tuple<bool, viz::SharedImageFormat>>&
param_info) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}