#include "gpu/command_buffer/service/shared_image/shared_memory_image_backing.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/notreached.h"
#include "base/trace_event/process_memory_dump.h"
#include "components/viz/common/resources/resource_sizes.h"
#include "components/viz/common/resources/shared_image_format_utils.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/shared_image_trace_utils.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/command_buffer/service/memory_tracking.h"
#include "gpu/command_buffer/service/shared_context_state.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_memory_region_wrapper.h"
#include "third_party/skia/include/core/SkAlphaType.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkColorType.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkPixmap.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/skia_conversions.h"
namespace gpu {
namespace {
class MemoryImageRepresentationImpl : public MemoryImageRepresentation { … };
class OverlayImageRepresentationImpl : public OverlayImageRepresentation { … };
}
SharedMemoryImageBacking::~SharedMemoryImageBacking() = default;
void SharedMemoryImageBacking::Update(std::unique_ptr<gfx::GpuFence> in_fence) { … }
SharedImageBackingType SharedMemoryImageBacking::GetType() const { … }
gfx::Rect SharedMemoryImageBacking::ClearedRect() const { … }
void SharedMemoryImageBacking::SetClearedRect(const gfx::Rect& cleared_rect) { … }
gfx::GpuMemoryBufferHandle
SharedMemoryImageBacking::GetGpuMemoryBufferHandle() { … }
const SharedMemoryRegionWrapper&
SharedMemoryImageBacking::shared_memory_wrapper() { … }
const std::vector<SkPixmap>& SharedMemoryImageBacking::pixmaps() { … }
std::unique_ptr<DawnImageRepresentation> SharedMemoryImageBacking::ProduceDawn(
SharedImageManager* manager,
MemoryTypeTracker* tracker,
const wgpu::Device& device,
wgpu::BackendType backend_type,
std::vector<wgpu::TextureFormat> view_formats,
scoped_refptr<SharedContextState> context_state) { … }
std::unique_ptr<GLTextureImageRepresentation>
SharedMemoryImageBacking::ProduceGLTexture(SharedImageManager* manager,
MemoryTypeTracker* tracker) { … }
std::unique_ptr<GLTexturePassthroughImageRepresentation>
SharedMemoryImageBacking::ProduceGLTexturePassthrough(
SharedImageManager* manager,
MemoryTypeTracker* tracker) { … }
std::unique_ptr<SkiaGaneshImageRepresentation>
SharedMemoryImageBacking::ProduceSkiaGanesh(
SharedImageManager* manager,
MemoryTypeTracker* tracker,
scoped_refptr<SharedContextState> context_state) { … }
std::unique_ptr<OverlayImageRepresentation>
SharedMemoryImageBacking::ProduceOverlay(SharedImageManager* manager,
MemoryTypeTracker* tracker) { … }
std::unique_ptr<MemoryImageRepresentation>
SharedMemoryImageBacking::ProduceMemory(SharedImageManager* manager,
MemoryTypeTracker* tracker) { … }
base::trace_event::MemoryAllocatorDump* SharedMemoryImageBacking::OnMemoryDump(
const std::string& dump_name,
base::trace_event::MemoryAllocatorDumpGuid client_guid,
base::trace_event::ProcessMemoryDump* pmd,
uint64_t client_tracing_id) { … }
SharedMemoryImageBacking::SharedMemoryImageBacking(
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,
SharedMemoryRegionWrapper wrapper,
gfx::GpuMemoryBufferHandle handle,
std::optional<gfx::BufferUsage> buffer_usage)
: … { … }
}