#include "gpu/command_buffer/service/shared_image/egl_image_backing.h"
#include <optional>
#include "base/memory/raw_ptr.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/shared_context_state.h"
#include "gpu/command_buffer/service/shared_image/shared_image_gl_utils.h"
#include "gpu/command_buffer/service/shared_image/shared_image_representation.h"
#include "gpu/command_buffer/service/shared_image/skia_gl_image_representation.h"
#include "gpu/command_buffer/service/texture_manager.h"
#include "ui/gl/buildflags.h"
#include "ui/gl/gl_fence_egl.h"
#include "ui/gl/gl_utils.h"
#include "ui/gl/scoped_binders.h"
#include "ui/gl/shared_gl_fence_egl.h"
#if BUILDFLAG(USE_DAWN) && BUILDFLAG(DAWN_ENABLE_BACKEND_OPENGLES)
#include "gpu/command_buffer/service/shared_image/dawn_egl_image_representation.h"
#endif
namespace gpu {
class EGLImageBacking::TextureHolder : public base::RefCounted<TextureHolder> { … };
class EGLImageBacking::GLRepresentationShared { … };
class EGLImageBacking::GLTextureEGLImageRepresentation
: public GLTextureImageRepresentation { … };
class EGLImageBacking::GLTexturePassthroughEGLImageRepresentation
: public GLTexturePassthroughImageRepresentation { … };
EGLImageBacking::EGLImageBacking(
const Mailbox& mailbox,
viz::SharedImageFormat format,
const gfx::Size& size,
const gfx::ColorSpace& color_space,
GrSurfaceOrigin surface_origin,
SkAlphaType alpha_type,
SharedImageUsageSet usage,
std::string debug_label,
size_t estimated_size,
const std::vector<GLCommonImageBackingFactory::FormatInfo>& format_info,
const GpuDriverBugWorkarounds& workarounds,
bool use_passthrough,
base::span<const uint8_t> pixel_data)
: … { … }
EGLImageBacking::~EGLImageBacking() { … }
SharedImageBackingType EGLImageBacking::GetType() const { … }
void EGLImageBacking::Update(std::unique_ptr<gfx::GpuFence> in_fence) { … }
template <class T>
std::unique_ptr<T> EGLImageBacking::ProduceGLTextureInternal(
SharedImageManager* manager,
MemoryTypeTracker* tracker) { … }
std::unique_ptr<GLTextureImageRepresentation> EGLImageBacking::ProduceGLTexture(
SharedImageManager* manager,
MemoryTypeTracker* tracker) { … }
std::unique_ptr<GLTexturePassthroughImageRepresentation>
EGLImageBacking::ProduceGLTexturePassthrough(SharedImageManager* manager,
MemoryTypeTracker* tracker) { … }
std::unique_ptr<SkiaGaneshImageRepresentation>
EGLImageBacking::ProduceSkiaGanesh(
SharedImageManager* manager,
MemoryTypeTracker* tracker,
scoped_refptr<SharedContextState> context_state) { … }
std::unique_ptr<DawnImageRepresentation> EGLImageBacking::ProduceDawn(
SharedImageManager* manager,
MemoryTypeTracker* tracker,
const wgpu::Device& device,
wgpu::BackendType backend_type,
std::vector<wgpu::TextureFormat> view_formats,
scoped_refptr<SharedContextState> context_state) { … }
bool EGLImageBacking::BeginWrite() { … }
void EGLImageBacking::EndWrite() { … }
bool EGLImageBacking::BeginRead(const GLRepresentationShared* reader) { … }
void EGLImageBacking::EndRead(const GLRepresentationShared* reader) { … }
gl::ScopedEGLImage EGLImageBacking::GenEGLImageSibling(
base::span<const uint8_t> pixel_data,
std::vector<GLuint>& service_ids,
int plane) { … }
std::vector<scoped_refptr<EGLImageBacking::TextureHolder>>
EGLImageBacking::GenEGLImageSiblings(base::span<const uint8_t> pixel_data) { … }
void EGLImageBacking::MarkForDestruction() { … }
}