#include "ui/gfx/gpu_fence_handle.h"
#include <atomic>
#include <cstddef>
#include "base/debug/alias.h"
#include "base/feature_list.h"
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/notreached.h"
#include "build/build_config.h"
#include "ui/gfx/switches.h"
#if BUILDFLAG(IS_POSIX)
#include <unistd.h>
#include "base/posix/eintr_wrapper.h"
#endif
#if BUILDFLAG(IS_FUCHSIA)
#include "base/fuchsia/fuchsia_logging.h"
#endif
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include "base/process/process_handle.h"
#endif
namespace {
std::atomic<uint32_t> g_num_clones_counter{ … };
bool IsEnabledUseSmartRefForGPUFenceHandle() { … }
gfx::GpuFenceHandle::ScopedPlatformFence PlatformDuplicate(
const gfx::GpuFenceHandle::ScopedPlatformFence& scoped_fence) { … }
}
namespace gfx {
GpuFenceHandle::GpuFenceHandle() = default;
GpuFenceHandle::GpuFenceHandle(GpuFenceHandle&& other)
: … { … }
GpuFenceHandle& GpuFenceHandle::operator=(GpuFenceHandle&& other) { … }
void GpuFenceHandle::Reset() { … }
GpuFenceHandle::~GpuFenceHandle() = default;
bool GpuFenceHandle::is_null() const { … }
GpuFenceHandle::RefCountedScopedFence::RefCountedScopedFence(
ScopedPlatformFence scoped_fence)
: … { … }
GpuFenceHandle::RefCountedScopedFence::~RefCountedScopedFence() = default;
#if BUILDFLAG(IS_POSIX)
int GpuFenceHandle::Peek() const { … }
#elif BUILDFLAG(IS_WIN)
HANDLE GpuFenceHandle::Peek() const {
return is_null() ? INVALID_HANDLE_VALUE
: smart_fence_.get()->scoped_fence_.Get();
}
#endif
void GpuFenceHandle::Adopt(ScopedPlatformFence scoped_fence) { … }
GpuFenceHandle::ScopedPlatformFence GpuFenceHandle::Release() { … }
uint32_t GpuFenceHandle::GetAndClearNumberOfClones() { … }
GpuFenceHandle GpuFenceHandle::Clone() const { … }
}