blob: 8b93d42ff1c00678ba1baaa084353ac10e764b76 [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "android_webview/browser/gfx/skia_output_surface_dependency_webview.h"
#include "android_webview/browser/gfx/aw_vulkan_context_provider.h"
#include "android_webview/browser/gfx/gpu_service_web_view.h"
#include "android_webview/browser/gfx/parent_output_surface.h"
#include "android_webview/browser/gfx/task_forwarding_sequence.h"
#include "android_webview/browser/gfx/task_queue_web_view.h"
namespace android_webview {
SkiaOutputSurfaceDependencyWebView::SkiaOutputSurfaceDependencyWebView(
TaskQueueWebView* task_queue,
GpuServiceWebView* gpu_service,
gpu::SharedContextState* shared_context_state,
gl::GLSurface* gl_surface)
: gl_surface_(gl_surface),
task_queue_(task_queue),
gpu_service_(gpu_service),
workarounds_(
gpu_service_->gpu_feature_info().enabled_gpu_driver_bug_workarounds),
shared_context_state_(shared_context_state) {}
SkiaOutputSurfaceDependencyWebView::~SkiaOutputSurfaceDependencyWebView() =
default;
std::unique_ptr<gpu::SingleTaskSequence>
SkiaOutputSurfaceDependencyWebView::CreateSequence() {
return std::make_unique<TaskForwardingSequence>(
this->task_queue_, this->gpu_service_->sync_point_manager());
}
bool SkiaOutputSurfaceDependencyWebView::IsUsingVulkan() {
return shared_context_state_ && shared_context_state_->GrContextIsVulkan();
}
gpu::SharedImageManager*
SkiaOutputSurfaceDependencyWebView::GetSharedImageManager() {
return gpu_service_->shared_image_manager();
}
gpu::SyncPointManager*
SkiaOutputSurfaceDependencyWebView::GetSyncPointManager() {
return gpu_service_->sync_point_manager();
}
const gpu::GpuDriverBugWorkarounds&
SkiaOutputSurfaceDependencyWebView::GetGpuDriverBugWorkarounds() {
return workarounds_;
}
scoped_refptr<gpu::SharedContextState>
SkiaOutputSurfaceDependencyWebView::GetSharedContextState() {
return shared_context_state_;
}
gpu::raster::GrShaderCache*
SkiaOutputSurfaceDependencyWebView::GetGrShaderCache() {
return nullptr;
}
viz::VulkanContextProvider*
SkiaOutputSurfaceDependencyWebView::GetVulkanContextProvider() {
return shared_context_state_->vk_context_provider();
}
const gpu::GpuPreferences&
SkiaOutputSurfaceDependencyWebView::GetGpuPreferences() {
return gpu_service_->gpu_preferences();
}
const gpu::GpuFeatureInfo&
SkiaOutputSurfaceDependencyWebView::GetGpuFeatureInfo() {
return gpu_service_->gpu_feature_info();
}
gpu::MailboxManager* SkiaOutputSurfaceDependencyWebView::GetMailboxManager() {
return gpu_service_->mailbox_manager();
}
void SkiaOutputSurfaceDependencyWebView::ScheduleGrContextCleanup() {
// There is no way to access the gpu thread here, so leave it no-op for now.
}
void SkiaOutputSurfaceDependencyWebView::PostTaskToClientThread(
base::OnceClosure closure) {
task_queue_->ScheduleClientTask(std::move(closure));
}
bool SkiaOutputSurfaceDependencyWebView::IsOffscreen() {
return false;
}
gpu::SurfaceHandle SkiaOutputSurfaceDependencyWebView::GetSurfaceHandle() {
return gpu::kNullSurfaceHandle;
}
scoped_refptr<gl::GLSurface>
SkiaOutputSurfaceDependencyWebView::CreateGLSurface(
base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub) {
return gl_surface_;
}
} // namespace android_webview