#include "components/viz/service/display_embedder/skia_output_surface_dependency_impl.h"
#include <memory>
#include <utility>
#include "base/functional/callback_helpers.h"
#include "base/task/bind_post_task.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "components/viz/service/gl/gpu_service_impl.h"
#include "gpu/command_buffer/service/command_buffer_task_executor.h"
#include "gpu/command_buffer/service/dawn_context_provider.h"
#include "gpu/command_buffer/service/gpu_task_scheduler_helper.h"
#include "gpu/command_buffer/service/scheduler.h"
#include "gpu/command_buffer/service/scheduler_sequence.h"
#include "gpu/config/gpu_finch_features.h"
#include "gpu/ipc/service/image_transport_surface.h"
#include "ui/gl/init/gl_factory.h"
namespace viz {
SkiaOutputSurfaceDependencyImpl::SkiaOutputSurfaceDependencyImpl(
GpuServiceImpl* gpu_service_impl,
gpu::SurfaceHandle surface_handle)
: … { … }
SkiaOutputSurfaceDependencyImpl::~SkiaOutputSurfaceDependencyImpl() = default;
std::unique_ptr<gpu::SingleTaskSequence>
SkiaOutputSurfaceDependencyImpl::CreateSequence() { … }
gpu::SharedImageManager*
SkiaOutputSurfaceDependencyImpl::GetSharedImageManager() { … }
gpu::SyncPointManager* SkiaOutputSurfaceDependencyImpl::GetSyncPointManager() { … }
const gpu::GpuDriverBugWorkarounds&
SkiaOutputSurfaceDependencyImpl::GetGpuDriverBugWorkarounds() { … }
scoped_refptr<gpu::SharedContextState>
SkiaOutputSurfaceDependencyImpl::GetSharedContextState() { … }
gpu::raster::GrShaderCache*
SkiaOutputSurfaceDependencyImpl::GetGrShaderCache() { … }
VulkanContextProvider*
SkiaOutputSurfaceDependencyImpl::GetVulkanContextProvider() { … }
gpu::DawnContextProvider*
SkiaOutputSurfaceDependencyImpl::GetDawnContextProvider() { … }
const gpu::GpuPreferences& SkiaOutputSurfaceDependencyImpl::GetGpuPreferences()
const { … }
const gpu::GpuFeatureInfo&
SkiaOutputSurfaceDependencyImpl::GetGpuFeatureInfo() { … }
bool SkiaOutputSurfaceDependencyImpl::IsOffscreen() { … }
gpu::SurfaceHandle SkiaOutputSurfaceDependencyImpl::GetSurfaceHandle() { … }
scoped_refptr<gl::Presenter>
SkiaOutputSurfaceDependencyImpl::CreatePresenter() { … }
scoped_refptr<gl::GLSurface> SkiaOutputSurfaceDependencyImpl::CreateGLSurface(
gl::GLSurfaceFormat format) { … }
#if BUILDFLAG(IS_ANDROID)
base::ScopedClosureRunner SkiaOutputSurfaceDependencyImpl::CachePresenter(
gl::Presenter* presenter) {
gpu_service_impl_->compositor_gpu_task_runner()->PostTask(
FROM_HERE,
base::BindOnce(&gl::Presenter::AddRef, base::Unretained(presenter)));
auto release_callback = base::BindPostTask(
gpu_service_impl_->compositor_gpu_task_runner(),
base::BindOnce(&gl::Presenter::Release, base::Unretained(presenter)));
return base::ScopedClosureRunner(std::move(release_callback));
}
base::ScopedClosureRunner SkiaOutputSurfaceDependencyImpl::CacheGLSurface(
gl::GLSurface* surface) {
gpu_service_impl_->compositor_gpu_task_runner()->PostTask(
FROM_HERE,
base::BindOnce(&gl::GLSurface::AddRef, base::Unretained(surface)));
auto release_callback = base::BindPostTask(
gpu_service_impl_->compositor_gpu_task_runner(),
base::BindOnce(&gl::GLSurface::Release, base::Unretained(surface)));
return base::ScopedClosureRunner(std::move(release_callback));
}
#endif
scoped_refptr<base::SingleThreadTaskRunner>
SkiaOutputSurfaceDependencyImpl::GetClientTaskRunner() { … }
void SkiaOutputSurfaceDependencyImpl::ScheduleGrContextCleanup() { … }
void SkiaOutputSurfaceDependencyImpl::ScheduleDelayedGPUTaskFromGPUThread(
base::OnceClosure task) { … }
void SkiaOutputSurfaceDependencyImpl::DidLoseContext(
gpu::error::ContextLostReason reason,
const GURL& active_url) { … }
bool SkiaOutputSurfaceDependencyImpl::NeedsSupportForExternalStencil() { … }
bool SkiaOutputSurfaceDependencyImpl::IsUsingCompositorGpuThread() { … }
}