Commit 25ebb7a4 authored by Weiliang Chen's avatar Weiliang Chen Committed by Commit Bot

viz: Add SharedImageInterface for SkiaRenderer on Shared Data Structure

Add a SharedImageInterfaceInProcess to use for SkiaRenderer on Viz.
This is put on the shared data structure of
DisplayCompositorMemoryAndTaskController.

R=rjkroege, Khushal
TBR=boliu@chromium.org

Bug: 1042538
Change-Id: I37e2778e4c5576e4f9fbd33e0997d9e93030ca19
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485281
Commit-Queue: weiliangc <weiliangc@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821516}
parent f562ca0a
...@@ -155,8 +155,8 @@ OutputSurfaceProviderWebview::CreateOutputSurface( ...@@ -155,8 +155,8 @@ OutputSurfaceProviderWebview::CreateOutputSurface(
} else { } else {
auto context_provider = AwRenderThreadContextProvider::Create( auto context_provider = AwRenderThreadContextProvider::Create(
gl_surface_, DeferredGpuCommandService::GetInstance(), gl_surface_, DeferredGpuCommandService::GetInstance(),
display_compositor_controller->get_gpu_task_scheduler(), display_compositor_controller->gpu_task_scheduler(),
display_compositor_controller->get_controller_on_gpu()); display_compositor_controller->controller_on_gpu());
return std::make_unique<ParentOutputSurface>(gl_surface_, return std::make_unique<ParentOutputSurface>(gl_surface_,
std::move(context_provider)); std::move(context_provider));
} }
......
...@@ -42,6 +42,7 @@ include_rules = [ ...@@ -42,6 +42,7 @@ include_rules = [
"+gpu/ipc/gpu_task_scheduler_helper.h", "+gpu/ipc/gpu_task_scheduler_helper.h",
"+gpu/ipc/display_compositor_memory_and_task_controller_on_gpu.h", "+gpu/ipc/display_compositor_memory_and_task_controller_on_gpu.h",
"+gpu/ipc/scheduler_sequence.h", "+gpu/ipc/scheduler_sequence.h",
"+gpu/ipc/shared_image_interface_in_process.h",
"+gpu/command_buffer/service/shared_image_factory.h", "+gpu/command_buffer/service/shared_image_factory.h",
"+gpu/command_buffer/service/shared_image_manager.h", "+gpu/command_buffer/service/shared_image_manager.h",
"+gpu/config/gpu_driver_bug_workaround_type.h", "+gpu/config/gpu_driver_bug_workaround_type.h",
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "components/viz/service/display_embedder/skia_output_surface_dependency.h" #include "components/viz/service/display_embedder/skia_output_surface_dependency.h"
#include "gpu/ipc/scheduler_sequence.h" #include "gpu/ipc/scheduler_sequence.h"
#include "gpu/ipc/shared_image_interface_in_process.h"
namespace viz { namespace viz {
...@@ -27,6 +28,11 @@ DisplayCompositorMemoryAndTaskController:: ...@@ -27,6 +28,11 @@ DisplayCompositorMemoryAndTaskController::
base::Unretained(this), skia_dependency_.get(), &event); base::Unretained(this), skia_dependency_.get(), &event);
gpu_task_scheduler_->ScheduleGpuTask(std::move(callback), {}); gpu_task_scheduler_->ScheduleGpuTask(std::move(callback), {});
event.Wait(); event.Wait();
shared_image_interface_ =
std::make_unique<gpu::SharedImageInterfaceInProcess>(
gpu_task_scheduler_->GetTaskSequence(), controller_on_gpu_.get(),
nullptr /* command_buffer_helper*/);
} }
DisplayCompositorMemoryAndTaskController:: DisplayCompositorMemoryAndTaskController::
...@@ -40,11 +46,12 @@ DisplayCompositorMemoryAndTaskController:: ...@@ -40,11 +46,12 @@ DisplayCompositorMemoryAndTaskController::
base::WaitableEvent::InitialState::NOT_SIGNALED); base::WaitableEvent::InitialState::NOT_SIGNALED);
auto callback = base::BindOnce( auto callback = base::BindOnce(
&DisplayCompositorMemoryAndTaskController::InitializeOnGpuGL, &DisplayCompositorMemoryAndTaskController::InitializeOnGpuGL,
base::Unretained(this), task_executor, &event); base::Unretained(this), task_executor, image_factory, &event);
gpu_task_scheduler_->GetTaskSequence()->ScheduleTask(std::move(callback), {}); gpu_task_scheduler_->GetTaskSequence()->ScheduleTask(std::move(callback), {});
event.Wait(); event.Wait();
// TODO(weiliangc): Create SharedImageInterface from input params. // TODO(weiliangc): Move VizProcessContextProvider initialization here to take
// ownership of the shared image interface.
} }
DisplayCompositorMemoryAndTaskController:: DisplayCompositorMemoryAndTaskController::
...@@ -59,6 +66,7 @@ DisplayCompositorMemoryAndTaskController:: ...@@ -59,6 +66,7 @@ DisplayCompositorMemoryAndTaskController::
base::Unretained(this), &event); base::Unretained(this), &event);
gpu_task_scheduler_->GetTaskSequence()->ScheduleTask(std::move(callback), {}); gpu_task_scheduler_->GetTaskSequence()->ScheduleTask(std::move(callback), {});
event.Wait(); event.Wait();
shared_image_interface_.reset();
} }
void DisplayCompositorMemoryAndTaskController::InitializeOnGpuSkia( void DisplayCompositorMemoryAndTaskController::InitializeOnGpuSkia(
...@@ -67,17 +75,25 @@ void DisplayCompositorMemoryAndTaskController::InitializeOnGpuSkia( ...@@ -67,17 +75,25 @@ void DisplayCompositorMemoryAndTaskController::InitializeOnGpuSkia(
DCHECK(event); DCHECK(event);
controller_on_gpu_ = controller_on_gpu_ =
std::make_unique<gpu::DisplayCompositorMemoryAndTaskControllerOnGpu>( std::make_unique<gpu::DisplayCompositorMemoryAndTaskControllerOnGpu>(
skia_dependency->GetSharedContextState()); skia_dependency->GetSharedContextState(),
skia_dependency->GetMailboxManager(),
skia_dependency->GetGpuImageFactory(),
skia_dependency->GetSharedImageManager(),
skia_dependency->GetSyncPointManager(),
skia_dependency->GetGpuPreferences(),
skia_dependency->GetGpuDriverBugWorkarounds(),
skia_dependency->GetGpuFeatureInfo());
event->Signal(); event->Signal();
} }
void DisplayCompositorMemoryAndTaskController::InitializeOnGpuGL( void DisplayCompositorMemoryAndTaskController::InitializeOnGpuGL(
gpu::CommandBufferTaskExecutor* task_executor, gpu::CommandBufferTaskExecutor* task_executor,
gpu::ImageFactory* image_factory,
base::WaitableEvent* event) { base::WaitableEvent* event) {
DCHECK(event); DCHECK(event);
controller_on_gpu_ = controller_on_gpu_ =
std::make_unique<gpu::DisplayCompositorMemoryAndTaskControllerOnGpu>( std::make_unique<gpu::DisplayCompositorMemoryAndTaskControllerOnGpu>(
task_executor); task_executor, image_factory);
event->Signal(); event->Signal();
} }
...@@ -87,4 +103,9 @@ void DisplayCompositorMemoryAndTaskController::DestroyOnGpu( ...@@ -87,4 +103,9 @@ void DisplayCompositorMemoryAndTaskController::DestroyOnGpu(
controller_on_gpu_.reset(); controller_on_gpu_.reset();
event->Signal(); event->Signal();
} }
gpu::SharedImageInterface*
DisplayCompositorMemoryAndTaskController::shared_image_interface() {
return shared_image_interface_.get();
}
} // namespace viz } // namespace viz
...@@ -17,6 +17,8 @@ class WaitableEvent; ...@@ -17,6 +17,8 @@ class WaitableEvent;
namespace gpu { namespace gpu {
class ImageFactory; class ImageFactory;
class SharedImageInterface;
class SharedImageInterfaceInProcess;
} }
namespace viz { namespace viz {
...@@ -42,22 +44,24 @@ class VIZ_SERVICE_EXPORT DisplayCompositorMemoryAndTaskController { ...@@ -42,22 +44,24 @@ class VIZ_SERVICE_EXPORT DisplayCompositorMemoryAndTaskController {
const DisplayCompositorMemoryAndTaskController&) = delete; const DisplayCompositorMemoryAndTaskController&) = delete;
~DisplayCompositorMemoryAndTaskController(); ~DisplayCompositorMemoryAndTaskController();
SkiaOutputSurfaceDependency* get_skia_dependency() { SkiaOutputSurfaceDependency* skia_dependency() {
return skia_dependency_.get(); return skia_dependency_.get();
} }
gpu::GpuTaskSchedulerHelper* get_gpu_task_scheduler() { gpu::GpuTaskSchedulerHelper* gpu_task_scheduler() {
return gpu_task_scheduler_.get(); return gpu_task_scheduler_.get();
} }
gpu::DisplayCompositorMemoryAndTaskControllerOnGpu* get_controller_on_gpu() { gpu::DisplayCompositorMemoryAndTaskControllerOnGpu* controller_on_gpu() {
return controller_on_gpu_.get(); return controller_on_gpu_.get();
} }
gpu::SharedImageInterface* shared_image_interface();
private: private:
void InitializeOnGpuSkia(SkiaOutputSurfaceDependency* skia_dependency, void InitializeOnGpuSkia(SkiaOutputSurfaceDependency* skia_dependency,
base::WaitableEvent* event); base::WaitableEvent* event);
void InitializeOnGpuSkiaWebView(base::WaitableEvent* event);
void InitializeOnGpuGL(gpu::CommandBufferTaskExecutor* task_executor, void InitializeOnGpuGL(gpu::CommandBufferTaskExecutor* task_executor,
gpu::ImageFactory* image_factory,
base::WaitableEvent* event); base::WaitableEvent* event);
void DestroyOnGpu(base::WaitableEvent* event); void DestroyOnGpu(base::WaitableEvent* event);
...@@ -69,6 +73,11 @@ class VIZ_SERVICE_EXPORT DisplayCompositorMemoryAndTaskController { ...@@ -69,6 +73,11 @@ class VIZ_SERVICE_EXPORT DisplayCompositorMemoryAndTaskController {
// Accessed on the gpu thread. // Accessed on the gpu thread.
std::unique_ptr<gpu::DisplayCompositorMemoryAndTaskControllerOnGpu> std::unique_ptr<gpu::DisplayCompositorMemoryAndTaskControllerOnGpu>
controller_on_gpu_; controller_on_gpu_;
// Accessed on the compositor thread.
// TODO(weiliangc): Move the GLRenderer's SharedImageInterface ownership here
// as well.
std::unique_ptr<gpu::SharedImageInterfaceInProcess> shared_image_interface_;
}; };
} // namespace viz } // namespace viz
......
...@@ -144,8 +144,8 @@ OverlayProcessorInterface::CreateOverlayProcessor( ...@@ -144,8 +144,8 @@ OverlayProcessorInterface::CreateOverlayProcessor(
return std::make_unique<OverlayProcessorAndroid>( return std::make_unique<OverlayProcessorAndroid>(
shared_image_manager, shared_image_manager,
display_controller->get_controller_on_gpu()->memory_tracker(), display_controller->controller_on_gpu()->memory_tracker(),
display_controller->get_gpu_task_scheduler()); display_controller->gpu_task_scheduler());
} }
#else // Default #else // Default
return std::make_unique<OverlayProcessorStub>(); return std::make_unique<OverlayProcessorStub>();
......
...@@ -97,8 +97,8 @@ std::unique_ptr<SkiaOutputSurface> SkiaOutputSurfaceImpl::Create( ...@@ -97,8 +97,8 @@ std::unique_ptr<SkiaOutputSurface> SkiaOutputSurfaceImpl::Create(
const RendererSettings& renderer_settings, const RendererSettings& renderer_settings,
const DebugRendererSettings* debug_settings) { const DebugRendererSettings* debug_settings) {
DCHECK(display_controller); DCHECK(display_controller);
DCHECK(display_controller->get_skia_dependency()); DCHECK(display_controller->skia_dependency());
DCHECK(display_controller->get_gpu_task_scheduler()); DCHECK(display_controller->gpu_task_scheduler());
auto output_surface = std::make_unique<SkiaOutputSurfaceImpl>( auto output_surface = std::make_unique<SkiaOutputSurfaceImpl>(
util::PassKey<SkiaOutputSurfaceImpl>(), display_controller, util::PassKey<SkiaOutputSurfaceImpl>(), display_controller,
renderer_settings, debug_settings); renderer_settings, debug_settings);
...@@ -113,13 +113,13 @@ SkiaOutputSurfaceImpl::SkiaOutputSurfaceImpl( ...@@ -113,13 +113,13 @@ SkiaOutputSurfaceImpl::SkiaOutputSurfaceImpl(
const RendererSettings& renderer_settings, const RendererSettings& renderer_settings,
const DebugRendererSettings* debug_settings) const DebugRendererSettings* debug_settings)
: SkiaOutputSurface( : SkiaOutputSurface(
GetOutputSurfaceType(display_controller->get_skia_dependency())), GetOutputSurfaceType(display_controller->skia_dependency())),
dependency_(display_controller->get_skia_dependency()), dependency_(display_controller->skia_dependency()),
renderer_settings_(renderer_settings), renderer_settings_(renderer_settings),
debug_settings_(debug_settings), debug_settings_(debug_settings),
display_compositor_controller_(display_controller), display_compositor_controller_(display_controller),
gpu_task_scheduler_( gpu_task_scheduler_(
display_compositor_controller_->get_gpu_task_scheduler()) { display_compositor_controller_->gpu_task_scheduler()) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
} }
...@@ -787,7 +787,7 @@ void SkiaOutputSurfaceImpl::InitializeOnGpuThread( ...@@ -787,7 +787,7 @@ void SkiaOutputSurfaceImpl::InitializeOnGpuThread(
impl_on_gpu_ = SkiaOutputSurfaceImplOnGpu::Create( impl_on_gpu_ = SkiaOutputSurfaceImplOnGpu::Create(
dependency_, renderer_settings_, gpu_task_scheduler_->GetSequenceId(), dependency_, renderer_settings_, gpu_task_scheduler_->GetSequenceId(),
display_compositor_controller_->get_controller_on_gpu(), display_compositor_controller_->controller_on_gpu(),
std::move(did_swap_buffer_complete_callback), std::move(did_swap_buffer_complete_callback),
std::move(buffer_presented_callback), std::move(context_lost_callback), std::move(buffer_presented_callback), std::move(context_lost_callback),
std::move(vsync_callback_runner)); std::move(vsync_callback_runner));
......
...@@ -248,7 +248,7 @@ void VizProcessContextProvider::InitializeContext( ...@@ -248,7 +248,7 @@ void VizProcessContextProvider::InitializeContext(
const gpu::SharedMemoryLimits& mem_limits) { const gpu::SharedMemoryLimits& mem_limits) {
const bool is_offscreen = surface_handle == gpu::kNullSurfaceHandle; const bool is_offscreen = surface_handle == gpu::kNullSurfaceHandle;
DCHECK(display_controller); DCHECK(display_controller);
gpu_task_scheduler_helper_ = display_controller->get_gpu_task_scheduler(); gpu_task_scheduler_helper_ = display_controller->gpu_task_scheduler();
command_buffer_ = std::make_unique<gpu::InProcessCommandBuffer>( command_buffer_ = std::make_unique<gpu::InProcessCommandBuffer>(
task_executor, task_executor,
...@@ -258,7 +258,7 @@ void VizProcessContextProvider::InitializeContext( ...@@ -258,7 +258,7 @@ void VizProcessContextProvider::InitializeContext(
gpu_memory_buffer_manager, image_factory, gpu_channel_manager_delegate, gpu_memory_buffer_manager, image_factory, gpu_channel_manager_delegate,
base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
gpu_task_scheduler_helper_->GetTaskSequence(), gpu_task_scheduler_helper_->GetTaskSequence(),
display_controller->get_controller_on_gpu(), nullptr, nullptr); display_controller->controller_on_gpu(), nullptr, nullptr);
if (context_result_ != gpu::ContextResult::kSuccess) { if (context_result_ != gpu::ContextResult::kSuccess) {
DLOG(ERROR) << "Failed to initialize InProcessCommmandBuffer"; DLOG(ERROR) << "Failed to initialize InProcessCommmandBuffer";
return; return;
......
...@@ -132,6 +132,8 @@ RootCompositorFrameSinkImpl::Create( ...@@ -132,6 +132,8 @@ RootCompositorFrameSinkImpl::Create(
gpu::SharedImageInterface* sii = nullptr; gpu::SharedImageInterface* sii = nullptr;
if (output_surface->context_provider()) if (output_surface->context_provider())
sii = output_surface->context_provider()->SharedImageInterface(); sii = output_surface->context_provider()->SharedImageInterface();
else if (display_controller)
sii = display_controller->shared_image_interface();
auto overlay_processor = OverlayProcessorInterface::CreateOverlayProcessor( auto overlay_processor = OverlayProcessorInterface::CreateOverlayProcessor(
output_surface.get(), output_surface->GetSurfaceHandle(), output_surface.get(), output_surface->GetSurfaceHandle(),
......
...@@ -59,8 +59,8 @@ std::unique_ptr<gpu::GLInProcessContext> CreateGLInProcessContext( ...@@ -59,8 +59,8 @@ std::unique_ptr<gpu::GLInProcessContext> CreateGLInProcessContext(
TestGpuServiceHolder::GetInstance()->task_executor(), nullptr, TestGpuServiceHolder::GetInstance()->task_executor(), nullptr,
is_offscreen, gpu::kNullSurfaceHandle, attribs, is_offscreen, gpu::kNullSurfaceHandle, attribs,
gpu::SharedMemoryLimits(), gpu_memory_buffer_manager, image_factory, gpu::SharedMemoryLimits(), gpu_memory_buffer_manager, image_factory,
display_controller->get_gpu_task_scheduler(), display_controller->gpu_task_scheduler(),
display_controller->get_controller_on_gpu(), std::move(task_runner)); display_controller->controller_on_gpu(), std::move(task_runner));
DCHECK_EQ(result, gpu::ContextResult::kSuccess); DCHECK_EQ(result, gpu::ContextResult::kSuccess);
} else { } else {
......
...@@ -27,9 +27,23 @@ CommandBufferId GenNextCommandBufferId() { ...@@ -27,9 +27,23 @@ CommandBufferId GenNextCommandBufferId() {
// Used for SkiaRenderer. // Used for SkiaRenderer.
DisplayCompositorMemoryAndTaskControllerOnGpu:: DisplayCompositorMemoryAndTaskControllerOnGpu::
DisplayCompositorMemoryAndTaskControllerOnGpu( DisplayCompositorMemoryAndTaskControllerOnGpu(
scoped_refptr<SharedContextState> shared_context_state) scoped_refptr<SharedContextState> shared_context_state,
MailboxManager* mailbox_manager,
ImageFactory* image_factory,
SharedImageManager* shared_image_manager,
SyncPointManager* sync_point_manager,
const GpuPreferences& gpu_preferences,
const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds,
const GpuFeatureInfo& gpu_feature_info)
: shared_context_state_(std::move(shared_context_state)), : shared_context_state_(std::move(shared_context_state)),
command_buffer_id_(g_next_shared_route_id.GetNext() + 1), command_buffer_id_(g_next_shared_route_id.GetNext() + 1),
mailbox_manager_(mailbox_manager),
image_factory_(image_factory),
shared_image_manager_(shared_image_manager),
sync_point_manager_(sync_point_manager),
gpu_preferences_(gpu_preferences),
gpu_driver_bug_workarounds_(gpu_driver_bug_workarounds),
gpu_feature_info_(gpu_feature_info),
should_have_memory_tracker_(true) { should_have_memory_tracker_(true) {
DCHECK_CALLED_ON_VALID_SEQUENCE(gpu_sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(gpu_sequence_checker_);
} }
...@@ -37,9 +51,19 @@ DisplayCompositorMemoryAndTaskControllerOnGpu:: ...@@ -37,9 +51,19 @@ DisplayCompositorMemoryAndTaskControllerOnGpu::
// Used for InProcessCommandBuffer. // Used for InProcessCommandBuffer.
DisplayCompositorMemoryAndTaskControllerOnGpu:: DisplayCompositorMemoryAndTaskControllerOnGpu::
DisplayCompositorMemoryAndTaskControllerOnGpu( DisplayCompositorMemoryAndTaskControllerOnGpu(
CommandBufferTaskExecutor* task_executor) CommandBufferTaskExecutor* task_executor,
ImageFactory* image_factory)
: shared_context_state_(task_executor->GetSharedContextState()), : shared_context_state_(task_executor->GetSharedContextState()),
command_buffer_id_(GenNextCommandBufferId()) { command_buffer_id_(GenNextCommandBufferId()),
mailbox_manager_(task_executor->mailbox_manager()),
image_factory_(image_factory),
shared_image_manager_(task_executor->shared_image_manager()),
sync_point_manager_(task_executor->sync_point_manager()),
gpu_preferences_(task_executor->gpu_preferences()),
gpu_driver_bug_workarounds_(
GpuDriverBugWorkarounds(task_executor->gpu_feature_info()
.enabled_gpu_driver_bug_workarounds)),
gpu_feature_info_(task_executor->gpu_feature_info()) {
DCHECK_CALLED_ON_VALID_SEQUENCE(gpu_sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(gpu_sequence_checker_);
// Android WebView won't have a memory tracker. // Android WebView won't have a memory tracker.
......
...@@ -11,11 +11,18 @@ ...@@ -11,11 +11,18 @@
#include "gpu/command_buffer/service/memory_tracking.h" #include "gpu/command_buffer/service/memory_tracking.h"
#include "gpu/command_buffer/service/sequence_id.h" #include "gpu/command_buffer/service/sequence_id.h"
#include "gpu/command_buffer/service/shared_context_state.h" #include "gpu/command_buffer/service/shared_context_state.h"
#include "gpu/config/gpu_driver_bug_workarounds.h"
#include "gpu/ipc/common/command_buffer_id.h" #include "gpu/ipc/common/command_buffer_id.h"
#include "gpu/ipc/gl_in_process_context_export.h" #include "gpu/ipc/gl_in_process_context_export.h"
namespace gpu { namespace gpu {
class CommandBufferTaskExecutor; class CommandBufferTaskExecutor;
class ImageFactory;
class MailboxManager;
class SyncPointManager;
class SharedImageManager;
struct GpuFeatureInfo;
struct GpuPreferences;
// This class holds ownership of data structure that is only used on the gpu // This class holds ownership of data structure that is only used on the gpu
// thread. This class is expected to be 1:1 relationship with the display // thread. This class is expected to be 1:1 relationship with the display
...@@ -24,11 +31,19 @@ class GL_IN_PROCESS_CONTEXT_EXPORT ...@@ -24,11 +31,19 @@ class GL_IN_PROCESS_CONTEXT_EXPORT
DisplayCompositorMemoryAndTaskControllerOnGpu { DisplayCompositorMemoryAndTaskControllerOnGpu {
public: public:
// Used for SkiaRenderer. // Used for SkiaRenderer.
explicit DisplayCompositorMemoryAndTaskControllerOnGpu( DisplayCompositorMemoryAndTaskControllerOnGpu(
scoped_refptr<SharedContextState> shared_context_state); scoped_refptr<SharedContextState> shared_context_state,
MailboxManager* mailbox_manager,
ImageFactory* image_factory,
SharedImageManager* shared_image_manager,
SyncPointManager* sync_point_manager,
const GpuPreferences& gpu_preferences,
const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds,
const GpuFeatureInfo& gpu_feature_info);
// Used for InProcessCommandBuffer. // Used for InProcessCommandBuffer.
explicit DisplayCompositorMemoryAndTaskControllerOnGpu( DisplayCompositorMemoryAndTaskControllerOnGpu(
CommandBufferTaskExecutor* task_executor); CommandBufferTaskExecutor* task_executor,
ImageFactory* image_factory);
DisplayCompositorMemoryAndTaskControllerOnGpu( DisplayCompositorMemoryAndTaskControllerOnGpu(
const DisplayCompositorMemoryAndTaskControllerOnGpu&) = delete; const DisplayCompositorMemoryAndTaskControllerOnGpu&) = delete;
DisplayCompositorMemoryAndTaskControllerOnGpu& operator=( DisplayCompositorMemoryAndTaskControllerOnGpu& operator=(
...@@ -45,11 +60,32 @@ class GL_IN_PROCESS_CONTEXT_EXPORT ...@@ -45,11 +60,32 @@ class GL_IN_PROCESS_CONTEXT_EXPORT
// GPU process. Not Used for cross process shared image stub. // GPU process. Not Used for cross process shared image stub.
static gpu::CommandBufferId NextCommandBufferId(); static gpu::CommandBufferId NextCommandBufferId();
MailboxManager* mailbox_manager() const { return mailbox_manager_; }
ImageFactory* image_factory() const { return image_factory_; }
SharedImageManager* shared_image_manager() const {
return shared_image_manager_;
}
SyncPointManager* sync_point_manager() const { return sync_point_manager_; }
const GpuPreferences& gpu_preferences() const { return gpu_preferences_; }
const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds() const {
return gpu_driver_bug_workarounds_;
}
const GpuFeatureInfo& gpu_feature_info() const { return gpu_feature_info_; }
private: private:
scoped_refptr<SharedContextState> shared_context_state_; scoped_refptr<SharedContextState> shared_context_state_;
const CommandBufferId command_buffer_id_; const CommandBufferId command_buffer_id_;
// Used for creating SharedImageFactory.
MailboxManager* mailbox_manager_;
ImageFactory* image_factory_;
SharedImageManager* shared_image_manager_;
SyncPointManager* sync_point_manager_;
const GpuPreferences& gpu_preferences_;
GpuDriverBugWorkarounds gpu_driver_bug_workarounds_;
const GpuFeatureInfo& gpu_feature_info_;
// Only needed for InProcessCommandBuffer. // Only needed for InProcessCommandBuffer.
bool should_have_memory_tracker_ = false; bool should_have_memory_tracker_ = false;
std::unique_ptr<MemoryTracker> memory_tracker_; std::unique_ptr<MemoryTracker> memory_tracker_;
......
...@@ -319,9 +319,7 @@ gpu::ContextResult InProcessCommandBuffer::Initialize( ...@@ -319,9 +319,7 @@ gpu::ContextResult InProcessCommandBuffer::Initialize(
if (result == gpu::ContextResult::kSuccess) { if (result == gpu::ContextResult::kSuccess) {
capabilities_ = capabilities; capabilities_ = capabilities;
shared_image_interface_ = std::make_unique<SharedImageInterfaceInProcess>( shared_image_interface_ = std::make_unique<SharedImageInterfaceInProcess>(
task_executor_, task_sequence_, gpu_dependency_->NextCommandBufferId(), task_sequence_, gpu_dependency_,
context_group_->mailbox_manager(), image_factory_,
gpu_dependency_->memory_tracker(),
std::make_unique<SharedImageInterfaceHelper>(this)); std::make_unique<SharedImageInterfaceHelper>(this));
} }
...@@ -339,7 +337,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread( ...@@ -339,7 +337,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
} else { } else {
gpu_dependency_holder_ = gpu_dependency_holder_ =
std::make_unique<DisplayCompositorMemoryAndTaskControllerOnGpu>( std::make_unique<DisplayCompositorMemoryAndTaskControllerOnGpu>(
task_executor_); task_executor_, params.image_factory);
gpu_dependency_ = gpu_dependency_holder_.get(); gpu_dependency_ = gpu_dependency_holder_.get();
} }
......
...@@ -16,25 +16,21 @@ ...@@ -16,25 +16,21 @@
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
namespace gpu { namespace gpu {
SharedImageInterfaceInProcess::SharedImageInterfaceInProcess( SharedImageInterfaceInProcess::SharedImageInterfaceInProcess(
CommandBufferTaskExecutor* task_executor, SingleTaskSequence* task_sequence,
SingleTaskSequence* single_task_sequence, DisplayCompositorMemoryAndTaskControllerOnGpu* display_controller,
CommandBufferId command_buffer_id,
MailboxManager* mailbox_manager,
ImageFactory* image_factory,
MemoryTracker* memory_tracker,
std::unique_ptr<CommandBufferHelper> command_buffer_helper) std::unique_ptr<CommandBufferHelper> command_buffer_helper)
: task_sequence_(single_task_sequence), : task_sequence_(task_sequence),
command_buffer_id_(command_buffer_id), command_buffer_id_(display_controller->NextCommandBufferId()),
command_buffer_helper_(std::move(command_buffer_helper)), command_buffer_helper_(std::move(command_buffer_helper)),
shared_image_manager_(task_executor->shared_image_manager()), shared_image_manager_(display_controller->shared_image_manager()),
mailbox_manager_(mailbox_manager), mailbox_manager_(display_controller->mailbox_manager()),
sync_point_manager_(task_executor->sync_point_manager()) { sync_point_manager_(display_controller->sync_point_manager()) {
DETACH_FROM_SEQUENCE(gpu_sequence_checker_); DETACH_FROM_SEQUENCE(gpu_sequence_checker_);
task_sequence_->ScheduleTask( task_sequence_->ScheduleTask(
base::BindOnce(&SharedImageInterfaceInProcess::SetUpOnGpu, base::BindOnce(&SharedImageInterfaceInProcess::SetUpOnGpu,
base::Unretained(this), task_executor, image_factory, base::Unretained(this), display_controller),
memory_tracker),
{}); {});
} }
...@@ -49,29 +45,26 @@ SharedImageInterfaceInProcess::~SharedImageInterfaceInProcess() { ...@@ -49,29 +45,26 @@ SharedImageInterfaceInProcess::~SharedImageInterfaceInProcess() {
{}); {});
completion.Wait(); completion.Wait();
} }
void SharedImageInterfaceInProcess::SetUpOnGpu( void SharedImageInterfaceInProcess::SetUpOnGpu(
CommandBufferTaskExecutor* task_executor, DisplayCompositorMemoryAndTaskControllerOnGpu* display_controller) {
ImageFactory* image_factory,
MemoryTracker* memory_tracker) {
DCHECK_CALLED_ON_VALID_SEQUENCE(gpu_sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(gpu_sequence_checker_);
context_state_ = display_controller->shared_context_state();
context_state_ = task_executor->GetSharedContextState().get();
create_factory_ = base::BindOnce( create_factory_ = base::BindOnce(
[](CommandBufferTaskExecutor* task_executor, ImageFactory* image_factory, [](DisplayCompositorMemoryAndTaskControllerOnGpu* display_controller,
MemoryTracker* memory_tracker, MailboxManager* mailbox_manager,
bool enable_wrapped_sk_image) { bool enable_wrapped_sk_image) {
auto shared_image_factory = std::make_unique<SharedImageFactory>( auto shared_image_factory = std::make_unique<SharedImageFactory>(
task_executor->gpu_preferences(), display_controller->gpu_preferences(),
GpuDriverBugWorkarounds(task_executor->gpu_feature_info() display_controller->gpu_driver_bug_workarounds(),
.enabled_gpu_driver_bug_workarounds), display_controller->gpu_feature_info(),
task_executor->gpu_feature_info(), display_controller->shared_context_state(),
task_executor->GetSharedContextState().get(), mailbox_manager, display_controller->mailbox_manager(),
task_executor->shared_image_manager(), image_factory, display_controller->shared_image_manager(),
memory_tracker, enable_wrapped_sk_image); display_controller->image_factory(),
display_controller->memory_tracker(), enable_wrapped_sk_image);
return shared_image_factory; return shared_image_factory;
}, },
task_executor, image_factory, memory_tracker, mailbox_manager_); display_controller);
// Make the SharedImageInterface use the same sequence as the command buffer, // Make the SharedImageInterface use the same sequence as the command buffer,
// it's necessary for WebView because of the blocking behavior. // it's necessary for WebView because of the blocking behavior.
...@@ -122,9 +115,11 @@ void SharedImageInterfaceInProcess::LazyCreateSharedImageFactory() { ...@@ -122,9 +115,11 @@ void SharedImageInterfaceInProcess::LazyCreateSharedImageFactory() {
return; return;
// We need WrappedSkImage to support creating a SharedImage with pixel data // We need WrappedSkImage to support creating a SharedImage with pixel data
// when GL is unavailable. This is used in various unit tests. // when GL is unavailable. This is used in various unit tests. If we don't
// have a command buffer helper, that means this class is created for
// SkiaRenderer, and we definitely need to turn on enable_wrapped_sk_image.
const bool enable_wrapped_sk_image = const bool enable_wrapped_sk_image =
command_buffer_helper_ && command_buffer_helper_->EnableWrappedSkImage(); !command_buffer_helper_ || command_buffer_helper_->EnableWrappedSkImage();
shared_image_factory_ = shared_image_factory_ =
std::move(create_factory_).Run(enable_wrapped_sk_image); std::move(create_factory_).Run(enable_wrapped_sk_image);
} }
......
...@@ -11,10 +11,7 @@ ...@@ -11,10 +11,7 @@
#include "gpu/ipc/in_process_command_buffer.h" #include "gpu/ipc/in_process_command_buffer.h"
namespace gpu { namespace gpu {
class CommandBufferTaskExecutor;
class ImageFactory;
class MailboxManager; class MailboxManager;
class MemoryTracker;
class SyncPointClientState; class SyncPointClientState;
struct SyncToken; struct SyncToken;
class SharedContextState; class SharedContextState;
...@@ -22,7 +19,7 @@ class SharedImageFactory; ...@@ -22,7 +19,7 @@ class SharedImageFactory;
class SharedImageManager; class SharedImageManager;
class SingleTaskSequence; class SingleTaskSequence;
// This is an implementation of the SharedImageInterface to be used on viz // This is an implementation of the SharedImageInterface to be used on the viz
// compositor thread. This class also implements the corresponding parts // compositor thread. This class also implements the corresponding parts
// happening on gpu thread. // happening on gpu thread.
// TODO(weiliangc): Currently this is implemented as backed by // TODO(weiliangc): Currently this is implemented as backed by
...@@ -33,12 +30,8 @@ class GL_IN_PROCESS_CONTEXT_EXPORT SharedImageInterfaceInProcess ...@@ -33,12 +30,8 @@ class GL_IN_PROCESS_CONTEXT_EXPORT SharedImageInterfaceInProcess
using CommandBufferHelper = using CommandBufferHelper =
InProcessCommandBuffer::SharedImageInterfaceHelper; InProcessCommandBuffer::SharedImageInterfaceHelper;
SharedImageInterfaceInProcess( SharedImageInterfaceInProcess(
CommandBufferTaskExecutor* task_executor,
SingleTaskSequence* task_sequence, SingleTaskSequence* task_sequence,
CommandBufferId command_buffer_id, DisplayCompositorMemoryAndTaskControllerOnGpu* display_controller,
MailboxManager* mailbox_manager,
ImageFactory* image_factory,
MemoryTracker* memory_tracker,
std::unique_ptr<CommandBufferHelper> command_buffer_helper); std::unique_ptr<CommandBufferHelper> command_buffer_helper);
~SharedImageInterfaceInProcess() override; ~SharedImageInterfaceInProcess() override;
...@@ -154,9 +147,8 @@ class GL_IN_PROCESS_CONTEXT_EXPORT SharedImageInterfaceInProcess ...@@ -154,9 +147,8 @@ class GL_IN_PROCESS_CONTEXT_EXPORT SharedImageInterfaceInProcess
private: private:
struct SharedImageFactoryInput; struct SharedImageFactoryInput;
void SetUpOnGpu(CommandBufferTaskExecutor* task_executor, void SetUpOnGpu(
ImageFactory* image_factory, DisplayCompositorMemoryAndTaskControllerOnGpu* display_controller);
MemoryTracker* memory_tracker);
void DestroyOnGpu(base::WaitableEvent* completion); void DestroyOnGpu(base::WaitableEvent* completion);
SyncToken MakeSyncToken(uint64_t release_id) { SyncToken MakeSyncToken(uint64_t release_id) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment