#include "gpu/command_buffer/service/skia_utils.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/process_memory_dump.h"
#include "build/build_config.h"
#include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/graphite_image_provider.h"
#include "gpu/command_buffer/service/shared_context_state.h"
#include "gpu/config/gpu_finch_features.h"
#include "gpu/config/gpu_switches.h"
#include "gpu/config/skia_limits.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkTextureCompressionType.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrContextThreadSafeProxy.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h"
#include "third_party/skia/include/gpu/ganesh/vk/GrVkBackendSurface.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "third_party/skia/include/gpu/graphite/Context.h"
#include "third_party/skia/include/gpu/graphite/GraphiteTypes.h"
#include "third_party/skia/include/gpu/graphite/Recorder.h"
#include "third_party/skia/include/gpu/vk/VulkanTypes.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_version_info.h"
#if BUILDFLAG(ENABLE_VULKAN)
#include "components/viz/common/gpu/vulkan_context_provider.h"
#include "components/viz/common/resources/shared_image_format.h"
#include "gpu/vulkan/vulkan_device_queue.h"
#include "gpu/vulkan/vulkan_fence_helper.h"
#include "gpu/vulkan/vulkan_function_pointers.h"
#include "gpu/vulkan/vulkan_image.h"
#endif
namespace gpu {
namespace {
struct FlushCleanupContext { … };
void CleanupAfterSkiaFlush(void* context) { … }
void CleanupAfterGraphiteRecording(void* context, skgpu::CallbackResult) { … }
template <class T>
void DeleteSkObject(SharedContextState* context_state, sk_sp<T> sk_object) { … }
#if BUILDFLAG(ENABLE_VULKAN)
constexpr bool VkFormatNeedsYcbcrSampler(VkFormat format) { … }
#endif
}
GrContextOptions GetDefaultGrContextOptions() { … }
skgpu::graphite::ContextOptions GetDefaultGraphiteContextOptions(
const GpuDriverBugWorkarounds& workarounds) { … }
void DumpBackgroundGraphiteMemoryStatistics(
const skgpu::graphite::Context* context,
const skgpu::graphite::Recorder* recorder,
base::trace_event::ProcessMemoryDump* pmd) { … }
GLuint GetGrGLBackendTextureFormat(
const gles2::FeatureInfo* feature_info,
GLenum gl_storage_format,
sk_sp<GrContextThreadSafeProxy> gr_context_thread_safe) { … }
bool GetGrBackendTexture(const gles2::FeatureInfo* feature_info,
GLenum target,
const gfx::Size& size,
GLuint service_id,
GLenum gl_storage_format,
sk_sp<GrContextThreadSafeProxy> gr_context_thread_safe,
GrBackendTexture* gr_texture) { … }
void AddCleanupTaskForSkiaFlush(base::OnceClosure task,
GrFlushInfo* flush_info) { … }
void AddCleanupTaskForGraphiteRecording(
base::OnceClosure task,
skgpu::graphite::InsertRecordingInfo* info) { … }
void AddVulkanCleanupTaskForSkiaFlush(
viz::VulkanContextProvider* context_provider,
GrFlushInfo* flush_info) { … }
void DeleteGrBackendTexture(SharedContextState* context_state,
GrBackendTexture* backend_texture) { … }
void DeleteSkImage(SharedContextState* context_state, sk_sp<SkImage> sk_image) { … }
void DeleteSkSurface(SharedContextState* context_state,
sk_sp<SkSurface> sk_surface) { … }
#if BUILDFLAG(ENABLE_VULKAN)
GrVkImageInfo CreateGrVkImageInfo(VulkanImage* image,
const viz::SharedImageFormat& si_format,
const gfx::ColorSpace& color_space) { … }
GPU_GLES2_EXPORT skgpu::VulkanYcbcrConversionInfo
CreateVulkanYcbcrConversionInfo(
VkPhysicalDevice physical_device,
VkImageTiling tiling,
VkFormat format,
const viz::SharedImageFormat& si_format,
const gfx::ColorSpace& color_space,
const std::optional<VulkanYCbCrInfo>& ycbcr_info) { … }
#endif
bool ShouldVulkanSyncCpuForSkiaSubmit(
viz::VulkanContextProvider* context_provider) { … }
uint64_t GrBackendTextureTracingID(const GrBackendTexture& backend_texture) { … }
}