#include "gpu/command_buffer/client/client_shared_image.h"
#include <GLES2/gl2.h>
#include <GLES2/gl2extchromium.h>
#include "base/check_is_test.h"
#include "base/containers/contains.h"
#include "base/trace_event/process_memory_dump.h"
#include "components/viz/common/resources/shared_image_format_utils.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/common/shared_image_capabilities.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/ipc/common/gpu_memory_buffer_support.h"
#include "ui/gfx/buffer_types.h"
namespace gpu {
namespace {
static bool allow_external_sampling_without_native_buffers_for_testing = …;
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_OZONE)
bool GMBIsNative(gfx::GpuMemoryBufferType gmb_type) { … }
#endif
uint32_t ComputeTextureTargetForSharedImage(
SharedImageMetadata metadata,
gfx::GpuMemoryBufferType client_gmb_type,
scoped_refptr<SharedImageInterface> sii) { … }
}
ClientSharedImage::ScopedMapping::ScopedMapping() = default;
ClientSharedImage::ScopedMapping::~ScopedMapping() { … }
std::unique_ptr<ClientSharedImage::ScopedMapping>
ClientSharedImage::ScopedMapping::Create(
gfx::GpuMemoryBuffer* gpu_memory_buffer) { … }
bool ClientSharedImage::ScopedMapping::Init(
gfx::GpuMemoryBuffer* gpu_memory_buffer) { … }
void* ClientSharedImage::ScopedMapping::Memory(const uint32_t plane_index) { … }
size_t ClientSharedImage::ScopedMapping::Stride(const uint32_t plane_index) { … }
gfx::Size ClientSharedImage::ScopedMapping::Size() { … }
gfx::BufferFormat ClientSharedImage::ScopedMapping::Format() { … }
bool ClientSharedImage::ScopedMapping::IsSharedMemory() { … }
void ClientSharedImage::ScopedMapping::OnMemoryDump(
base::trace_event::ProcessMemoryDump* pmd,
const base::trace_event::MemoryAllocatorDumpGuid& buffer_dump_guid,
uint64_t tracing_process_id,
int importance) { … }
void ClientSharedImage::AllowExternalSamplingWithoutNativeBuffersForTesting(
bool allow) { … }
ClientSharedImage::ClientSharedImage(
const Mailbox& mailbox,
const SharedImageMetadata& metadata,
const SyncToken& sync_token,
scoped_refptr<SharedImageInterfaceHolder> sii_holder,
gfx::GpuMemoryBufferType gmb_type)
: … { … }
ClientSharedImage::ClientSharedImage(
const Mailbox& mailbox,
const SharedImageMetadata& metadata,
const SyncToken& sync_token,
scoped_refptr<SharedImageInterfaceHolder> sii_holder,
uint32_t texture_target)
: … { … }
ClientSharedImage::ClientSharedImage(const Mailbox& mailbox,
const SharedImageMetadata& metadata,
const SyncToken& sync_token,
uint32_t texture_target)
: … { … }
ClientSharedImage::ClientSharedImage(
const Mailbox& mailbox,
const SharedImageMetadata& metadata,
const SyncToken& sync_token,
GpuMemoryBufferHandleInfo handle_info,
scoped_refptr<SharedImageInterfaceHolder> sii_holder)
: … { … }
ClientSharedImage::~ClientSharedImage() { … }
std::unique_ptr<ClientSharedImage::ScopedMapping> ClientSharedImage::Map() { … }
#if BUILDFLAG(IS_APPLE)
void ClientSharedImage::SetColorSpaceOnNativeBuffer(
const gfx::ColorSpace& color_space) {
CHECK(gpu_memory_buffer_);
gpu_memory_buffer_->SetColorSpace(color_space);
}
#endif
uint32_t ClientSharedImage::GetTextureTarget() { … }
scoped_refptr<ClientSharedImage> ClientSharedImage::MakeUnowned() { … }
ExportedSharedImage ClientSharedImage::Export() { … }
scoped_refptr<ClientSharedImage> ClientSharedImage::ImportUnowned(
const ExportedSharedImage& exported_shared_image) { … }
void ClientSharedImage::OnMemoryDump(
base::trace_event::ProcessMemoryDump* pmd,
const base::trace_event::MemoryAllocatorDumpGuid& buffer_dump_guid,
int importance) { … }
void ClientSharedImage::BeginAccess(bool readonly) { … }
void ClientSharedImage::EndAccess(bool readonly) { … }
std::unique_ptr<SharedImageTexture> ClientSharedImage::CreateGLTexture(
gles2::GLES2Interface* gl) { … }
scoped_refptr<ClientSharedImage> ClientSharedImage::CreateForTesting() { … }
scoped_refptr<ClientSharedImage> ClientSharedImage::CreateForTesting(
uint32_t texture_target) { … }
ExportedSharedImage::ExportedSharedImage() = default;
ExportedSharedImage::ExportedSharedImage(const Mailbox& mailbox,
const SharedImageMetadata& metadata,
const SyncToken& sync_token,
uint32_t texture_target)
: … { … }
SharedImageTexture::ScopedAccess::ScopedAccess(SharedImageTexture* texture,
const SyncToken& sync_token,
bool readonly)
: … { … }
SharedImageTexture::ScopedAccess::~ScopedAccess() { … }
void SharedImageTexture::ScopedAccess::DidEndAccess() { … }
SyncToken SharedImageTexture::ScopedAccess::EndAccess(
std::unique_ptr<SharedImageTexture::ScopedAccess> scoped_shared_image) { … }
SharedImageTexture::SharedImageTexture(gles2::GLES2Interface* gl,
ClientSharedImage* shared_image)
: … { … }
SharedImageTexture::~SharedImageTexture() { … }
std::unique_ptr<SharedImageTexture::ScopedAccess>
SharedImageTexture::BeginAccess(const SyncToken& sync_token, bool readonly) { … }
void SharedImageTexture::DidEndAccess(bool readonly) { … }
}