chromium/gpu/command_buffer/service/shared_image/shared_image_representation.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "gpu/command_buffer/service/shared_image/shared_image_representation.h"

#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "components/viz/common/resources/shared_image_format_utils.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/texture_manager.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/GrYUVABackendTextures.h"
#include "third_party/skia/include/gpu/MutableTextureState.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "third_party/skia/include/gpu/graphite/Image.h"
#include "third_party/skia/include/gpu/graphite/YUVABackendTextures.h"
#include "third_party/skia/include/private/chromium/GrPromiseImageTexture.h"
#include "ui/gl/gl_fence.h"

#if BUILDFLAG(ENABLE_VULKAN)
#include "gpu/vulkan/vulkan_fence_helper.h"
#endif

namespace gpu {

///////////////////////////////////////////////////////////////////////////////
// SharedImageRepresentation

SharedImageRepresentation::SharedImageRepresentation(
    SharedImageManager* manager,
    SharedImageBacking* backing,
    MemoryTypeTracker* owning_tracker)
    :{}

SharedImageRepresentation::~SharedImageRepresentation() {}

size_t SharedImageRepresentation::NumPlanesExpected() const {}

///////////////////////////////////////////////////////////////////////////////
// GLTextureImageRepresentationBase

std::unique_ptr<GLTextureImageRepresentation::ScopedAccess>
GLTextureImageRepresentationBase::BeginScopedAccess(
    GLenum mode,
    AllowUnclearedAccess allow_uncleared) {}

gpu::TextureBase* GLTextureImageRepresentationBase::GetTextureBase() {}

bool GLTextureImageRepresentationBase::SupportsMultipleConcurrentReadAccess() {}

///////////////////////////////////////////////////////////////////////////////
// GLTextureImageRepresentation

gpu::TextureBase* GLTextureImageRepresentation::GetTextureBase(
    int plane_index) {}

gles2::Texture* GLTextureImageRepresentation::GetTexture() {}

void GLTextureImageRepresentation::UpdateClearedStateOnEndAccess() {}

void GLTextureImageRepresentation::UpdateClearedStateOnBeginAccess() {}

///////////////////////////////////////////////////////////////////////////////
// GLTexturePassthroughImageRepresentation

gpu::TextureBase* GLTexturePassthroughImageRepresentation::GetTextureBase(
    int plane_index) {}

const scoped_refptr<gles2::TexturePassthrough>&
GLTexturePassthroughImageRepresentation::GetTexturePassthrough() {}

bool GLTexturePassthroughImageRepresentation::
    NeedsSuspendAccessForDXGIKeyedMutex() const {}

///////////////////////////////////////////////////////////////////////////////
// SkiaImageRepresentation

SkiaImageRepresentation::SkiaImageRepresentation(SharedImageManager* manager,
                                                 SharedImageBacking* backing,
                                                 MemoryTypeTracker* tracker)
    :{}

SkiaImageRepresentation::~SkiaImageRepresentation() = default;

bool SkiaImageRepresentation::SupportsMultipleConcurrentReadAccess() {}

SkiaImageRepresentation::ScopedWriteAccess::ScopedWriteAccess(
    SkiaImageRepresentation* representation,
    std::vector<sk_sp<SkSurface>> surfaces)
    :{}

SkiaImageRepresentation::ScopedWriteAccess::ScopedWriteAccess(
    SkiaImageRepresentation* representation,
    std::vector<sk_sp<GrPromiseImageTexture>> promise_image_textures)
    :{}

SkiaImageRepresentation::ScopedWriteAccess::ScopedWriteAccess(
    SkiaImageRepresentation* representation,
    std::vector<skgpu::graphite::BackendTexture> graphite_textures)
    :{}

SkiaImageRepresentation::ScopedWriteAccess::~ScopedWriteAccess() {}

bool SkiaImageRepresentation::ScopedWriteAccess::NeedGraphiteContextSubmit() {}

SkiaImageRepresentation::ScopedReadAccess::ScopedReadAccess(
    SkiaImageRepresentation* representation,
    std::vector<sk_sp<GrPromiseImageTexture>> promise_image_textures)
    :{}

SkiaImageRepresentation::ScopedReadAccess::ScopedReadAccess(
    SkiaImageRepresentation* representation,
    std::vector<skgpu::graphite::BackendTexture> graphite_textures)
    :{}

SkiaImageRepresentation::ScopedReadAccess::~ScopedReadAccess() {}

bool SkiaImageRepresentation::ScopedReadAccess::NeedGraphiteContextSubmit() {}

///////////////////////////////////////////////////////////////////////////////
// SkiaGaneshImageRepresentation

SkiaGaneshImageRepresentation::SkiaGaneshImageRepresentation(
    GrDirectContext* gr_context,
    SharedImageManager* manager,
    SharedImageBacking* backing,
    MemoryTypeTracker* tracker)
    :{}

bool SkiaGaneshImageRepresentation::NeedGraphiteContextSubmitBeforeEndAccess() {}

SkiaGaneshImageRepresentation::ScopedGaneshWriteAccess::ScopedGaneshWriteAccess(
    base::PassKey<SkiaGaneshImageRepresentation> /* pass_key */,
    SkiaImageRepresentation* representation,
    std::vector<sk_sp<SkSurface>> surfaces,
    std::unique_ptr<skgpu::MutableTextureState> end_state)
    :{}

SkiaGaneshImageRepresentation::ScopedGaneshWriteAccess::ScopedGaneshWriteAccess(
    base::PassKey<SkiaGaneshImageRepresentation> /* pass_key */,
    SkiaImageRepresentation* representation,
    std::vector<sk_sp<GrPromiseImageTexture>> promise_image_textures,
    std::unique_ptr<skgpu::MutableTextureState> end_state)
    :{}

SkiaGaneshImageRepresentation::ScopedGaneshWriteAccess::
    ~ScopedGaneshWriteAccess() {}

bool SkiaGaneshImageRepresentation::ScopedGaneshWriteAccess::
    HasBackendSurfaceEndState() {}

void SkiaGaneshImageRepresentation::ScopedGaneshWriteAccess::
    ApplyBackendSurfaceEndState() {}

std::unique_ptr<SkiaImageRepresentation::ScopedWriteAccess>
SkiaGaneshImageRepresentation::BeginScopedWriteAccess(
    int final_msaa_count,
    const SkSurfaceProps& surface_props,
    const gfx::Rect& update_rect,
    std::vector<GrBackendSemaphore>* begin_semaphores,
    std::vector<GrBackendSemaphore>* end_semaphores,
    AllowUnclearedAccess allow_uncleared,
    bool use_sk_surface) {}

std::unique_ptr<SkiaImageRepresentation::ScopedWriteAccess>
SkiaGaneshImageRepresentation::BeginScopedWriteAccess(
    int final_msaa_count,
    const SkSurfaceProps& surface_props,
    std::vector<GrBackendSemaphore>* begin_semaphores,
    std::vector<GrBackendSemaphore>* end_semaphores,
    AllowUnclearedAccess allow_uncleared,
    bool use_sk_surface) {}

std::unique_ptr<SkiaImageRepresentation::ScopedWriteAccess>
SkiaGaneshImageRepresentation::BeginScopedWriteAccess(
    std::vector<GrBackendSemaphore>* begin_semaphores,
    std::vector<GrBackendSemaphore>* end_semaphores,
    AllowUnclearedAccess allow_uncleared,
    bool use_sk_surface) {}

SkiaGaneshImageRepresentation::ScopedGaneshReadAccess::ScopedGaneshReadAccess(
    base::PassKey<SkiaGaneshImageRepresentation> /* pass_key */,
    SkiaImageRepresentation* representation,
    std::vector<sk_sp<GrPromiseImageTexture>> promise_image_textures,
    std::unique_ptr<skgpu::MutableTextureState> end_state)
    :{}

SkiaGaneshImageRepresentation::ScopedGaneshReadAccess::
    ~ScopedGaneshReadAccess() {}

sk_sp<SkImage>
SkiaGaneshImageRepresentation::ScopedGaneshReadAccess::CreateSkImage(
    SharedContextState* context_state,
    SkImages::TextureReleaseProc texture_release_proc,
    SkImages::ReleaseContext release_context) {}

sk_sp<SkImage>
SkiaGaneshImageRepresentation::ScopedGaneshReadAccess::CreateSkImageForPlane(
    int plane_index,
    SharedContextState* context_state,
    SkImages::TextureReleaseProc texture_release_proc,
    SkImages::ReleaseContext release_context) {}

bool SkiaGaneshImageRepresentation::ScopedGaneshReadAccess::
    HasBackendSurfaceEndState() {}

void SkiaGaneshImageRepresentation::ScopedGaneshReadAccess::
    ApplyBackendSurfaceEndState() {}

std::unique_ptr<SkiaImageRepresentation::ScopedReadAccess>
SkiaGaneshImageRepresentation::BeginScopedReadAccess(
    std::vector<GrBackendSemaphore>* begin_semaphores,
    std::vector<GrBackendSemaphore>* end_semaphores) {}

///////////////////////////////////////////////////////////////////////////////
// SkiaGraphiteImageRepresentation

SkiaGraphiteImageRepresentation::SkiaGraphiteImageRepresentation(
    SharedImageManager* manager,
    SharedImageBacking* backing,
    MemoryTypeTracker* tracker)
    :{}

bool SkiaGraphiteImageRepresentation::
    NeedGraphiteContextSubmitBeforeEndAccess() {}

SkiaGraphiteImageRepresentation::ScopedGraphiteWriteAccess::
    ScopedGraphiteWriteAccess(
        base::PassKey<SkiaGraphiteImageRepresentation> /* pass_key */,
        SkiaImageRepresentation* representation,
        std::vector<sk_sp<SkSurface>> surfaces)
    :{}

SkiaGraphiteImageRepresentation::ScopedGraphiteWriteAccess::
    ScopedGraphiteWriteAccess(
        base::PassKey<SkiaGraphiteImageRepresentation> /* pass_key */,
        SkiaImageRepresentation* representation,
        std::vector<skgpu::graphite::BackendTexture> backend_textures)
    :{}

SkiaGraphiteImageRepresentation::ScopedGraphiteWriteAccess::
    ~ScopedGraphiteWriteAccess() = default;

bool SkiaGraphiteImageRepresentation::ScopedGraphiteWriteAccess::
    HasBackendSurfaceEndState() {}

// Graphite-Dawn backend handles Vulkan transitions by itself, so nothing to do
// here.
void SkiaGraphiteImageRepresentation::ScopedGraphiteWriteAccess::
    ApplyBackendSurfaceEndState() {}

std::unique_ptr<SkiaImageRepresentation::ScopedWriteAccess>
SkiaGraphiteImageRepresentation::BeginScopedWriteAccess(
    int final_msaa_count,
    const SkSurfaceProps& surface_props,
    const gfx::Rect& update_rect,
    std::vector<GrBackendSemaphore>* begin_semaphores,
    std::vector<GrBackendSemaphore>* end_semaphores,
    AllowUnclearedAccess allow_uncleared,
    bool use_sk_surface) {}

std::unique_ptr<SkiaImageRepresentation::ScopedWriteAccess>
SkiaGraphiteImageRepresentation::BeginScopedWriteAccess(
    int final_msaa_count,
    const SkSurfaceProps& surface_props,
    std::vector<GrBackendSemaphore>* begin_semaphores,
    std::vector<GrBackendSemaphore>* end_semaphores,
    AllowUnclearedAccess allow_uncleared,
    bool use_sk_surface) {}

std::unique_ptr<SkiaImageRepresentation::ScopedWriteAccess>
SkiaGraphiteImageRepresentation::BeginScopedWriteAccess(
    std::vector<GrBackendSemaphore>* begin_semaphores,
    std::vector<GrBackendSemaphore>* end_semaphores,
    AllowUnclearedAccess allow_uncleared,
    bool use_sk_surface) {}

SkiaGraphiteImageRepresentation::ScopedGraphiteReadAccess::
    ScopedGraphiteReadAccess(
        base::PassKey<SkiaGraphiteImageRepresentation> /* pass_key */,
        SkiaImageRepresentation* representation,
        std::vector<skgpu::graphite::BackendTexture> graphite_textures)
    :{}

SkiaGraphiteImageRepresentation::ScopedGraphiteReadAccess::
    ~ScopedGraphiteReadAccess() = default;

sk_sp<SkImage>
SkiaGraphiteImageRepresentation::ScopedGraphiteReadAccess::CreateSkImage(
    SharedContextState* context_state,
    SkImages::TextureReleaseProc texture_release_proc,
    SkImages::ReleaseContext release_context) {}

sk_sp<SkImage> SkiaGraphiteImageRepresentation::ScopedGraphiteReadAccess::
    CreateSkImageForPlane(int plane_index,
                          SharedContextState* context_state,
                          SkImages::TextureReleaseProc texture_release_proc,
                          SkImages::ReleaseContext release_context) {}

bool SkiaGraphiteImageRepresentation::ScopedGraphiteReadAccess::
    HasBackendSurfaceEndState() {}

// Graphite-Dawn backend handles Vulkan transitions by itself, so nothing to do
// here.
void SkiaGraphiteImageRepresentation::ScopedGraphiteReadAccess::
    ApplyBackendSurfaceEndState() {}

std::unique_ptr<SkiaImageRepresentation::ScopedReadAccess>
SkiaGraphiteImageRepresentation::BeginScopedReadAccess(
    std::vector<GrBackendSemaphore>* begin_semaphores,
    std::vector<GrBackendSemaphore>* end_semaphores) {}

std::string SkiaGraphiteImageRepresentation::WrappedTextureDebugLabel(
    int plane) const {}

///////////////////////////////////////////////////////////////////////////////
// OverlayImageRepresentation

#if BUILDFLAG(IS_ANDROID)
AHardwareBuffer* OverlayImageRepresentation::GetAHardwareBuffer() {
  NOTREACHED_IN_MIGRATION();
  return nullptr;
}
std::unique_ptr<base::android::ScopedHardwareBufferFenceSync>
OverlayImageRepresentation::GetAHardwareBufferFenceSync() {
  NOTREACHED_IN_MIGRATION();
  return nullptr;
}
#elif BUILDFLAG(IS_OZONE)
scoped_refptr<gfx::NativePixmap> OverlayImageRepresentation::GetNativePixmap() {}
#elif BUILDFLAG(IS_WIN)
std::optional<gl::DCLayerOverlayImage>
OverlayImageRepresentation::GetDCLayerOverlayImage() {
  NOTREACHED_IN_MIGRATION();
  return std::nullopt;
}
#elif BUILDFLAG(IS_APPLE)
gfx::ScopedIOSurface OverlayImageRepresentation::GetIOSurface() const {
  return gfx::ScopedIOSurface();
}
bool OverlayImageRepresentation::IsInUseByWindowServer() const {
  return false;
}
#endif

OverlayImageRepresentation::ScopedReadAccess::ScopedReadAccess(
    base::PassKey<OverlayImageRepresentation> pass_key,
    OverlayImageRepresentation* representation,
    gfx::GpuFenceHandle acquire_fence)
    :{}

OverlayImageRepresentation::ScopedReadAccess::~ScopedReadAccess() {}

std::unique_ptr<OverlayImageRepresentation::ScopedReadAccess>
OverlayImageRepresentation::BeginScopedReadAccess() {}

///////////////////////////////////////////////////////////////////////////////
// DawnImageRepresentation

DawnImageRepresentation::ScopedAccess::ScopedAccess(
    base::PassKey<DawnImageRepresentation> /* pass_key */,
    DawnImageRepresentation* representation,
    wgpu::Texture texture,
    AccessMode access_mode)
    :{}

DawnImageRepresentation::ScopedAccess::~ScopedAccess() {}

std::unique_ptr<DawnImageRepresentation::ScopedAccess>
DawnImageRepresentation::BeginScopedAccess(
    wgpu::TextureUsage usage,
    AllowUnclearedAccess allow_uncleared) {}

std::unique_ptr<DawnImageRepresentation::ScopedAccess>
DawnImageRepresentation::BeginScopedAccess(
    wgpu::TextureUsage usage,
    wgpu::TextureUsage internal_usage,
    AllowUnclearedAccess allow_uncleared) {}

std::unique_ptr<DawnImageRepresentation::ScopedAccess>
DawnImageRepresentation::BeginScopedAccess(wgpu::TextureUsage usage,
                                           AllowUnclearedAccess allow_uncleared,
                                           const gfx::Rect& update_rect) {}

std::unique_ptr<DawnImageRepresentation::ScopedAccess>
DawnImageRepresentation::BeginScopedAccess(wgpu::TextureUsage usage,
                                           wgpu::TextureUsage internal_usage,
                                           AllowUnclearedAccess allow_uncleared,
                                           const gfx::Rect& update_rect) {}

wgpu::Texture DawnImageRepresentation::BeginAccess(
    wgpu::TextureUsage usage,
    wgpu::TextureUsage internal_usage,
    const gfx::Rect& update_rect) {}

bool DawnImageRepresentation::SupportsMultipleConcurrentReadAccess() {}

///////////////////////////////////////////////////////////////////////////////
// SharedImageRepresentationFactoryRef

SharedImageRepresentationFactoryRef::SharedImageRepresentationFactoryRef(
    SharedImageManager* manager,
    SharedImageBacking* backing,
    MemoryTypeTracker* tracker,
    bool is_primary)
    :{}

SharedImageRepresentationFactoryRef::~SharedImageRepresentationFactoryRef() {}

///////////////////////////////////////////////////////////////////////////////
// MemoryImageRepresentation

MemoryImageRepresentation::ScopedReadAccess::ScopedReadAccess(
    base::PassKey<MemoryImageRepresentation> pass_key,
    MemoryImageRepresentation* representation,
    SkPixmap pixmap)
    :{}

MemoryImageRepresentation::ScopedReadAccess::~ScopedReadAccess() = default;

std::unique_ptr<MemoryImageRepresentation::ScopedReadAccess>
MemoryImageRepresentation::BeginScopedReadAccess() {}

///////////////////////////////////////////////////////////////////////////////
// RasterImageRepresentation

RasterImageRepresentation::ScopedReadAccess::ScopedReadAccess(
    base::PassKey<RasterImageRepresentation> pass_key,
    RasterImageRepresentation* representation,
    const cc::PaintOpBuffer* paint_op_buffer,
    const std::optional<SkColor4f>& clear_color)
    :{}

RasterImageRepresentation::ScopedReadAccess::~ScopedReadAccess() {}

RasterImageRepresentation::ScopedWriteAccess::ScopedWriteAccess(
    base::PassKey<RasterImageRepresentation> pass_key,
    RasterImageRepresentation* representation,
    cc::PaintOpBuffer* paint_op_buffer)
    :{}

RasterImageRepresentation::ScopedWriteAccess::~ScopedWriteAccess() {}

std::unique_ptr<RasterImageRepresentation::ScopedReadAccess>
RasterImageRepresentation::BeginScopedReadAccess() {}

std::unique_ptr<RasterImageRepresentation::ScopedWriteAccess>
RasterImageRepresentation::BeginScopedWriteAccess(
    scoped_refptr<SharedContextState> context_state,
    int final_msaa_count,
    const SkSurfaceProps& surface_props,
    const std::optional<SkColor4f>& clear_color,
    bool visible) {}

///////////////////////////////////////////////////////////////////////////////
// VideoImageRepresentation

VideoImageRepresentation::VideoImageRepresentation(SharedImageManager* manager,
                                                   SharedImageBacking* backing,
                                                   MemoryTypeTracker* tracker)
    :{}

VideoImageRepresentation::~VideoImageRepresentation() = default;

VideoImageRepresentation::ScopedWriteAccess::ScopedWriteAccess(
    base::PassKey<VideoImageRepresentation> /* pass_key */,
    VideoImageRepresentation* representation)
    :{}

VideoImageRepresentation::ScopedWriteAccess::~ScopedWriteAccess() {}

std::unique_ptr<VideoImageRepresentation::ScopedWriteAccess>
VideoImageRepresentation::BeginScopedWriteAccess() {}
VideoImageRepresentation::ScopedReadAccess::ScopedReadAccess(
    base::PassKey<VideoImageRepresentation> /* pass_key */,
    VideoImageRepresentation* representation)
    :{}

VideoImageRepresentation::ScopedReadAccess::~ScopedReadAccess() {}

std::unique_ptr<VideoImageRepresentation::ScopedReadAccess>
VideoImageRepresentation::BeginScopedReadAccess() {}

///////////////////////////////////////////////////////////////////////////////
// VulkanImageRepresentation

#if BUILDFLAG(ENABLE_VULKAN)
VulkanImageRepresentation::VulkanImageRepresentation(
    SharedImageManager* manager,
    SharedImageBacking* backing,
    MemoryTypeTracker* tracker,
    std::unique_ptr<gpu::VulkanImage> vulkan_image,
    gpu::VulkanDeviceQueue* vulkan_device_queue,
    gpu::VulkanImplementation& vulkan_impl)
    :{}

VulkanImageRepresentation::~VulkanImageRepresentation() {}

VulkanImageRepresentation::ScopedAccess::ScopedAccess(
    VulkanImageRepresentation* representation,
    AccessMode access_mode,
    std::vector<VkSemaphore> begin_semaphores,
    VkSemaphore end_semaphore)
    :{}

VulkanImageRepresentation::ScopedAccess::~ScopedAccess() {}

gpu::VulkanImage& VulkanImageRepresentation::ScopedAccess::GetVulkanImage() {}
#endif

}  // namespace gpu