Commit ea7742fa authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

window-service: makes window-service clients create RasterContextProvider

Refactors code for creating RasterContextProvider out of content into
services/ws so that can be used by window-service clients as well as
content.

BUG=905569
TEST=covered by tests

Change-Id: Iec41d949ebd9819e597e14e194bd15ba54318527
Reviewed-on: https://chromium-review.googlesource.com/c/1347209
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611588}
parent 69ad26ad
......@@ -92,9 +92,9 @@ void StagingBuffer::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
if (!gpu_memory_buffer)
return;
gfx::GpuMemoryBufferId buffer_id = gpu_memory_buffer->GetId();
// Use |this| as the id, which works with multiple StagingBuffers.
std::string buffer_dump_name =
base::StringPrintf("cc/one_copy/staging_memory/buffer_%d", buffer_id.id);
base::StringPrintf("cc/one_copy/staging_memory/buffer_%p", this);
MemoryAllocatorDump* buffer_dump = pmd->CreateAllocatorDump(buffer_dump_name);
uint64_t buffer_size_in_bytes =
......
......@@ -67,6 +67,7 @@
#include "services/ws/public/mojom/user_activity_monitor.mojom.h"
#include "ui/aura/mus/property_converter.h"
#include "ui/aura/mus/user_activity_forwarder.h"
#include "ui/aura/mus/window_tree_client.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/user_activity/user_activity_detector.h"
......@@ -327,6 +328,10 @@ void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() {
app_list_client_.reset();
ash_shell_init_.reset();
// WindowTreeClient needs to do some shutdown while the IO thread is alive.
if (mus_client_)
mus_client_->window_tree_client()->OnEarlyShutdown();
chromeos::NetworkConnect::Shutdown();
network_connect_delegate_.reset();
}
......
......@@ -126,6 +126,17 @@ namespace {
// from RenderWidgetHostImpl.
constexpr uint32_t kDefaultClientId = 0u;
// Id used in creating ContextProviderCommandBuffer.
constexpr int32_t kStreamId = content::kGpuStreamIdDefault;
// Url identity supplied to ContextProviderCommandBuffer.
constexpr char kIdentityUrl[] =
"chrome://gpu/GpuProcessTransportFactory::CreateContextCommon";
// All browser contexts get the same stream id and priority.
constexpr gpu::SchedulingPriority kStreamPriority =
content::kGpuStreamPriorityUI;
#if defined(OS_MACOSX)
bool IsCALayersDisabledFromCommandLine() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
......@@ -133,14 +144,6 @@ bool IsCALayersDisabledFromCommandLine() {
}
#endif
bool CheckWorkerContextLost(viz::RasterContextProvider* context_provider) {
if (!context_provider)
return false;
viz::RasterContextProvider::ScopedRasterContextLock lock(context_provider);
return lock.RasterInterface()->GetGraphicsResetStatusKHR() != GL_NO_ERROR;
}
} // namespace
namespace content {
......@@ -170,6 +173,11 @@ GpuProcessTransportFactory::GpuProcessTransportFactory(
renderer_settings_(viz::CreateRendererSettings()),
resize_task_runner_(std::move(resize_task_runner)),
task_graph_runner_(new cc::SingleThreadTaskGraphRunner),
shared_worker_context_provider_factory_(
kStreamId,
kStreamPriority,
GURL(kIdentityUrl),
ws::command_buffer_metrics::ContextType::BROWSER_WORKER),
gpu_channel_factory_(gpu_channel_factory),
compositing_mode_reporter_(compositing_mode_reporter),
server_shared_bitmap_manager_(server_shared_bitmap_manager),
......@@ -374,41 +382,26 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
if (!use_gpu_compositing || use_vulkan) {
// If not using GL compositing, don't keep the old shared worker context.
shared_worker_context_provider_ = nullptr;
shared_worker_context_provider_factory_.Reset();
} else if (!gpu_channel_host) {
// Failed to establish a channel, which is a fatal error, so stop trying to
// use gpu compositing.
use_gpu_compositing = false;
shared_worker_context_provider_ = nullptr;
shared_worker_context_provider_factory_.Reset();
} else {
// Drop the old shared worker context if it was lost.
if (CheckWorkerContextLost(shared_worker_context_provider_.get()))
shared_worker_context_provider_ = nullptr;
if (!shared_worker_context_provider_) {
const bool need_alpha_channel = false;
const bool support_locking = true;
const bool support_gles2_interface =
features::IsUiGpuRasterizationEnabled();
const bool support_raster_interface = true;
const bool support_grcontext = features::IsUiGpuRasterizationEnabled();
shared_worker_context_provider_ = CreateContextCommon(
gpu_channel_host, gpu::kNullSurfaceHandle, need_alpha_channel,
false /* support_stencil */, support_locking, support_gles2_interface,
support_raster_interface, support_grcontext,
ws::command_buffer_metrics::ContextType::BROWSER_WORKER);
auto result = shared_worker_context_provider_->BindToCurrentThread();
if (result != gpu::ContextResult::kSuccess) {
shared_worker_context_provider_ = nullptr;
if (gpu::IsFatalOrSurfaceFailure(result))
use_gpu_compositing = false;
}
auto shared_worker_validate_result =
shared_worker_context_provider_factory_.Validate(
gpu_channel_host, GetGpuMemoryBufferManager());
if (shared_worker_validate_result != gpu::ContextResult::kSuccess) {
shared_worker_context_provider_factory_.Reset();
if (gpu::IsFatalOrSurfaceFailure(shared_worker_validate_result))
use_gpu_compositing = false;
}
// The |context_provider| is used for both the browser compositor and the
// display compositor. If we failed to make a worker context, just start
// over and try again.
if (shared_worker_context_provider_) {
if (shared_worker_context_provider()) {
// For mus, we create an offscreen context for a mus window, and we will
// use CommandBufferProxyImpl::TakeFrontBuffer() to take the context's
// front buffer into a mailbox, insert a sync token, and send the
......@@ -437,7 +430,7 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
}
bool gpu_compositing_ready =
use_vulkan || (context_provider && shared_worker_context_provider_);
use_vulkan || (context_provider && shared_worker_context_provider());
UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor",
gpu_compositing_ready);
if (!gpu_compositing_ready) {
......@@ -452,7 +445,7 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
// Try again if we didn't give up on gpu. Otherwise, drop the shared context
// if it exists and won't be used.
if (!use_gpu_compositing) {
shared_worker_context_provider_ = nullptr;
shared_worker_context_provider_factory_.Reset();
} else {
gpu_channel_factory_->EstablishGpuChannel(base::BindOnce(
&GpuProcessTransportFactory::EstablishedGpuChannel,
......@@ -625,7 +618,7 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
auto layer_tree_frame_sink = std::make_unique<viz::DirectLayerTreeFrameSink>(
compositor->frame_sink_id(), GetHostFrameSinkManager(),
GetFrameSinkManager(), data->display.get(), data->display_client.get(),
context_provider, shared_worker_context_provider_,
context_provider, shared_worker_context_provider(),
compositor->task_runner(), GetGpuMemoryBufferManager(),
features::IsVizHitTestingEnabled());
data->display->Resize(compositor->size());
......@@ -935,6 +928,11 @@ GpuProcessTransportFactory::SharedMainThreadContextProvider() {
return shared_main_thread_contexts_;
}
scoped_refptr<viz::RasterContextProvider>
GpuProcessTransportFactory::shared_worker_context_provider() {
return shared_worker_context_provider_factory_.provider();
}
GpuProcessTransportFactory::PerCompositorData*
GpuProcessTransportFactory::CreatePerCompositorData(
ui::Compositor* compositor) {
......@@ -1025,10 +1023,6 @@ GpuProcessTransportFactory::CreateContextCommon(
DCHECK(gpu_channel_host);
DCHECK(!is_gpu_compositing_disabled_);
// All browser contexts get the same stream id and priority.
int32_t stream_id = content::kGpuStreamIdDefault;
gpu::SchedulingPriority stream_priority = content::kGpuStreamPriorityUI;
// This is called from a few places to create different contexts:
// - The shared main thread context (offscreen).
// - The compositor context, which is used by the browser compositor
......@@ -1060,11 +1054,10 @@ GpuProcessTransportFactory::CreateContextCommon(
constexpr bool automatic_flushes = false;
GURL url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon");
return base::MakeRefCounted<ws::ContextProviderCommandBuffer>(
std::move(gpu_channel_host), GetGpuMemoryBufferManager(), stream_id,
stream_priority, surface_handle, url, automatic_flushes, support_locking,
support_grcontext, memory_limits, attributes, type);
std::move(gpu_channel_host), GetGpuMemoryBufferManager(), kStreamId,
kStreamPriority, surface_handle, GURL(kIdentityUrl), automatic_flushes,
support_locking, support_grcontext, memory_limits, attributes, type);
}
} // namespace content
......@@ -24,6 +24,7 @@
#include "gpu/ipc/client/gpu_channel_host.h"
#include "gpu/vulkan/buildflags.h"
#include "services/ws/public/cpp/gpu/command_buffer_metrics.h"
#include "services/ws/public/cpp/gpu/shared_worker_context_provider_factory.h"
#include "ui/compositor/compositor.h"
namespace base {
......@@ -43,10 +44,10 @@ class VulkanImplementation;
namespace viz {
class CompositingModeReporterImpl;
class OutputDeviceBacking;
class RasterContextProvider;
class ServerSharedBitmapManager;
class SoftwareOutputDevice;
class VulkanInProcessContextProvider;
class RasterContextProvider;
}
namespace ws {
......@@ -112,6 +113,8 @@ class GpuProcessTransportFactory : public ui::ContextFactory,
private:
struct PerCompositorData;
scoped_refptr<viz::RasterContextProvider> shared_worker_context_provider();
PerCompositorData* CreatePerCompositorData(ui::Compositor* compositor);
std::unique_ptr<viz::SoftwareOutputDevice> CreateSoftwareOutputDevice(
gfx::AcceleratedWidget widget,
......@@ -165,7 +168,8 @@ class GpuProcessTransportFactory : public ui::ContextFactory,
base::ObserverList<ui::ContextFactoryObserver>::Unchecked observer_list_;
scoped_refptr<base::SingleThreadTaskRunner> resize_task_runner_;
std::unique_ptr<cc::SingleThreadTaskGraphRunner> task_graph_runner_;
scoped_refptr<viz::RasterContextProvider> shared_worker_context_provider_;
ws::SharedWorkerContextProviderFactory
shared_worker_context_provider_factory_;
bool is_gpu_compositing_disabled_ = false;
bool disable_frame_rate_limit_ = false;
......
......@@ -35,6 +35,7 @@ source_set("gpu") {
"//gpu/command_buffer/client:gles2_cmd_helper",
"//gpu/command_buffer/client:gles2_implementation",
"//gpu/command_buffer/client:raster",
"//gpu/command_buffer/client:raster_interface",
"//gpu/command_buffer/client:webgpu",
"//gpu/command_buffer/common:raster",
"//gpu/skia_bindings",
......@@ -43,4 +44,10 @@ source_set("gpu") {
"//services/ws/public/mojom",
"//ui/gl",
]
if (use_aura || is_mac) {
public += [ "shared_worker_context_provider_factory.h" ]
sources += [ "shared_worker_context_provider_factory.cc" ]
}
}
// Copyright 2018 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 "services/ws/public/cpp/gpu/shared_worker_context_provider_factory.h"
#include "components/viz/common/gpu/raster_context_provider.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "gpu/command_buffer/common/context_result.h"
#include "gpu/ipc/client/gpu_channel_host.h"
#include "services/ws/public/cpp/gpu/context_provider_command_buffer.h"
#include "ui/base/ui_base_features.h"
namespace ws {
namespace {
bool CheckWorkerContextLost(viz::RasterContextProvider* context_provider) {
if (!context_provider)
return false;
viz::RasterContextProvider::ScopedRasterContextLock lock(context_provider);
return lock.RasterInterface()->GetGraphicsResetStatusKHR() != GL_NO_ERROR;
}
} // namespace
SharedWorkerContextProviderFactory::SharedWorkerContextProviderFactory(
int32_t stream_id,
gpu::SchedulingPriority priority,
const GURL& identifying_url,
ws::command_buffer_metrics::ContextType context_type)
: stream_id_(stream_id),
priority_(priority),
identifying_url_(identifying_url),
context_type_(context_type) {}
SharedWorkerContextProviderFactory::~SharedWorkerContextProviderFactory() =
default;
void SharedWorkerContextProviderFactory::Reset() {
provider_ = nullptr;
}
gpu::ContextResult SharedWorkerContextProviderFactory::Validate(
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) {
if (CheckWorkerContextLost(provider_.get()))
provider_ = nullptr;
if (provider_)
return gpu::ContextResult::kSuccess;
// TODO(crbug.com/909568): refactor
// RenderThreadImpl::SharedCompositorWorkerContextProvider to use this.
const bool need_alpha_channel = false;
const bool support_locking = true;
const bool support_gles2_interface = features::IsUiGpuRasterizationEnabled();
const bool support_raster_interface = true;
const bool support_grcontext = features::IsUiGpuRasterizationEnabled();
provider_ = CreateContextProvider(
std::move(gpu_channel_host), gpu_memory_buffer_manager,
gpu::kNullSurfaceHandle, need_alpha_channel, false /* support_stencil */,
support_locking, support_gles2_interface, support_raster_interface,
support_grcontext, context_type_);
auto result = provider_->BindToCurrentThread();
if (result != gpu::ContextResult::kSuccess)
provider_ = nullptr;
return result;
}
scoped_refptr<viz::RasterContextProvider>
SharedWorkerContextProviderFactory::CreateContextProvider(
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
gpu::SurfaceHandle surface_handle,
bool need_alpha_channel,
bool need_stencil_bits,
bool support_locking,
bool support_gles2_interface,
bool support_raster_interface,
bool support_grcontext,
ws::command_buffer_metrics::ContextType type) {
DCHECK(gpu_channel_host);
gpu::ContextCreationAttribs attributes;
attributes.alpha_size = need_alpha_channel ? 8 : -1;
attributes.depth_size = 0;
attributes.stencil_size = need_stencil_bits ? 8 : 0;
attributes.samples = 0;
attributes.sample_buffers = 0;
attributes.bind_generates_resource = false;
attributes.lose_context_when_out_of_memory = true;
attributes.buffer_preserved = false;
attributes.enable_gles2_interface = support_gles2_interface;
attributes.enable_raster_interface = support_raster_interface;
gpu::SharedMemoryLimits memory_limits =
gpu::SharedMemoryLimits::ForDisplayCompositor();
constexpr bool automatic_flushes = false;
return base::MakeRefCounted<ws::ContextProviderCommandBuffer>(
std::move(gpu_channel_host), gpu_memory_buffer_manager, stream_id_,
priority_, surface_handle, identifying_url_, automatic_flushes,
support_locking, support_grcontext, memory_limits, attributes, type);
}
} // namespace ws
// Copyright 2018 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.
#ifndef SERVICES_WS_PUBLIC_CPP_GPU_SHARED_WORKER_CONTEXT_PROVIDER_FACTORY_H_
#define SERVICES_WS_PUBLIC_CPP_GPU_SHARED_WORKER_CONTEXT_PROVIDER_FACTORY_H_
#include <stdint.h>
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "gpu/ipc/common/surface_handle.h"
#include "url/gurl.h"
namespace gpu {
class GpuChannelHost;
class GpuMemoryBufferManager;
enum class ContextResult;
enum class SchedulingPriority;
} // namespace gpu
namespace viz {
class RasterContextProvider;
}
namespace ws {
namespace command_buffer_metrics {
enum class ContextType;
}
// SharedWorkerContextProviderFactory is responsible for creation, and owning
// viz::RasterContextProvider.
class SharedWorkerContextProviderFactory {
public:
SharedWorkerContextProviderFactory(
int32_t stream_id,
gpu::SchedulingPriority priority,
const GURL& identifying_url,
ws::command_buffer_metrics::ContextType context_type);
~SharedWorkerContextProviderFactory();
// Drops the reference to |provider_|. This ensures the next time Validate()
// is called a new RasterContextProvider is created.
void Reset();
// Validates |provider_|, and if necessary attempts to recreate. Returns
// creation status. Use provider() to access the created
// RasterContextProvider.
gpu::ContextResult Validate(
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager);
scoped_refptr<viz::RasterContextProvider> provider() { return provider_; }
private:
scoped_refptr<viz::RasterContextProvider> CreateContextProvider(
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
gpu::SurfaceHandle surface_handle,
bool need_alpha_channel,
bool need_stencil_bits,
bool support_locking,
bool support_gles2_interface,
bool support_raster_interface,
bool support_grcontext,
ws::command_buffer_metrics::ContextType type);
const int32_t stream_id_;
const gpu::SchedulingPriority priority_;
const GURL identifying_url_;
const ws::command_buffer_metrics::ContextType context_type_;
scoped_refptr<viz::RasterContextProvider> provider_;
DISALLOW_COPY_AND_ASSIGN(SharedWorkerContextProviderFactory);
};
} // namespace ws
#endif // SERVICES_WS_PUBLIC_CPP_GPU_SHARED_WORKER_CONTEXT_PROVIDER_FACTORY_H_
......@@ -9,6 +9,7 @@ include_rules = [
"+components/viz/common",
"+components/viz/service/frame_sinks/frame_sink_manager_impl.h",
"+gpu/command_buffer/client/gpu_memory_buffer_manager.h",
"+gpu/command_buffer/common",
"+gpu/ipc/client/gpu_channel_host.h",
"+mojo/public/cpp/system/buffer.h",
"+mojo/public/cpp/system/platform_handle.h",
......
......@@ -9,7 +9,10 @@
#include "cc/mojo_embedder/async_layer_tree_frame_sink.h"
#include "components/viz/common/gpu/context_provider.h"
#include "components/viz/host/renderer_settings_creation.h"
#include "gpu/command_buffer/common/scheduling_priority.h"
#include "services/ws/public/cpp/gpu/command_buffer_metrics.h"
#include "services/ws/public/cpp/gpu/gpu.h"
#include "services/ws/public/cpp/gpu/shared_worker_context_provider_factory.h"
#include "ui/aura/mus/window_port_mus.h"
#include "ui/aura/window_tree_host.h"
#include "ui/compositor/compositor_switches.h"
......@@ -24,6 +27,10 @@ MusContextFactory::MusContextFactory(ws::Gpu* gpu)
MusContextFactory::~MusContextFactory() {}
void MusContextFactory::ResetSharedWorkerContextProvider() {
shared_worker_context_provider_factory_.reset();
}
void MusContextFactory::OnEstablishedGpuChannel(
base::WeakPtr<ui::Compositor> compositor,
scoped_refptr<gpu::GpuChannelHost> gpu_channel) {
......@@ -35,16 +42,42 @@ void MusContextFactory::OnEstablishedGpuChannel(
DCHECK(window_port);
scoped_refptr<viz::ContextProvider> context_provider =
gpu_->CreateContextProvider(std::move(gpu_channel));
gpu_->CreateContextProvider(gpu_channel);
// If the binding fails, then we need to return early since the compositor
// expects a successfully initialized/bound provider.
if (context_provider->BindToCurrentThread() != gpu::ContextResult::kSuccess) {
// TODO(danakj): We should retry if the result was not kFatalFailure.
return;
}
if (!shared_worker_context_provider_factory_) {
// TODO(sky): unify these with values from ws::Gpu.
const int32_t stream_id = 0;
const gpu::SchedulingPriority stream_priority =
gpu::SchedulingPriority::kNormal;
const GURL identity_url("chrome://gpu/MusContextFactory");
shared_worker_context_provider_factory_ =
std::make_unique<ws::SharedWorkerContextProviderFactory>(
stream_id, stream_priority, identity_url,
ws::command_buffer_metrics::ContextType::MUS_CLIENT);
}
scoped_refptr<viz::RasterContextProvider> shared_worker_context_provider;
auto shared_worker_validate_result =
shared_worker_context_provider_factory_->Validate(
gpu_channel, GetGpuMemoryBufferManager());
if (shared_worker_validate_result == gpu::ContextResult::kSuccess) {
shared_worker_context_provider =
shared_worker_context_provider_factory_->provider();
} else {
shared_worker_context_provider_factory_.reset();
}
std::unique_ptr<cc::LayerTreeFrameSink> layer_tree_frame_sink =
window_port->RequestLayerTreeFrameSink(std::move(context_provider),
gpu_->gpu_memory_buffer_manager());
window_port->RequestLayerTreeFrameSink(
std::move(context_provider),
std::move(shared_worker_context_provider),
gpu_->gpu_memory_buffer_manager());
compositor->SetLayerTreeFrameSink(std::move(layer_tree_frame_sink));
}
......
......@@ -23,6 +23,7 @@ class GpuChannelHost;
namespace ws {
class Gpu;
class SharedWorkerContextProviderFactory;
}
namespace aura {
......@@ -33,6 +34,10 @@ class AURA_EXPORT MusContextFactory : public ui::ContextFactory {
explicit MusContextFactory(ws::Gpu* gpu);
~MusContextFactory() override;
// Drops the references to the RasterContextProvider. This may be called to
// ensure a particular shutdown ordering.
void ResetSharedWorkerContextProvider();
private:
// Callback function for Gpu::EstablishGpuChannel().
void OnEstablishedGpuChannel(base::WeakPtr<ui::Compositor> compositor,
......@@ -53,6 +58,8 @@ class AURA_EXPORT MusContextFactory : public ui::ContextFactory {
ws::RasterThreadHelper raster_thread_helper_;
ws::Gpu* gpu_;
scoped_refptr<viz::ContextProvider> shared_main_thread_context_provider_;
std::unique_ptr<ws::SharedWorkerContextProviderFactory>
shared_worker_context_provider_factory_;
base::WeakPtrFactory<MusContextFactory> weak_ptr_factory_;
......
......@@ -175,6 +175,7 @@ void WindowPortMus::EmbedUsingToken(
std::unique_ptr<cc::mojo_embedder::AsyncLayerTreeFrameSink>
WindowPortMus::RequestLayerTreeFrameSink(
scoped_refptr<viz::ContextProvider> context_provider,
scoped_refptr<viz::RasterContextProvider> raster_context_provider,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) {
viz::mojom::CompositorFrameSinkPtrInfo sink_info;
viz::mojom::CompositorFrameSinkRequest sink_request =
......@@ -184,6 +185,9 @@ WindowPortMus::RequestLayerTreeFrameSink(
mojo::MakeRequest(&client);
cc::mojo_embedder::AsyncLayerTreeFrameSink::InitParams params;
ui::Compositor* compositor = window_->layer()->GetCompositor();
DCHECK(compositor);
params.compositor_task_runner = compositor->task_runner();
params.gpu_memory_buffer_manager = gpu_memory_buffer_manager;
params.pipes.compositor_frame_sink_info = std::move(sink_info);
params.pipes.client_request = std::move(client_request);
......@@ -202,7 +206,7 @@ WindowPortMus::RequestLayerTreeFrameSink(
auto layer_tree_frame_sink =
std::make_unique<cc::mojo_embedder::AsyncLayerTreeFrameSink>(
std::move(context_provider), nullptr /* worker_context_provider */,
std::move(context_provider), std::move(raster_context_provider),
&params);
window_tree_client_->AttachCompositorFrameSink(
server_id(), std::move(sink_request), std::move(client));
......@@ -687,8 +691,10 @@ WindowPortMus::CreateLayerTreeFrameSink() {
DCHECK_EQ(window_mus_type(), WindowMusType::LOCAL);
DCHECK(!local_layer_tree_frame_sink_);
// TODO(sky): this needs to supply a RasterContextProvider.
auto client_layer_tree_frame_sink = RequestLayerTreeFrameSink(
nullptr, window_->env()->context_factory()->GetGpuMemoryBufferManager());
nullptr, nullptr,
window_->env()->context_factory()->GetGpuMemoryBufferManager());
local_layer_tree_frame_sink_ = client_layer_tree_frame_sink->GetWeakPtr();
embed_frame_sink_id_ = GenerateFrameSinkIdFromServerId();
window_->SetEmbedFrameSinkId(embed_frame_sink_id_);
......
......@@ -40,6 +40,7 @@ class GpuMemoryBufferManager;
namespace viz {
class ContextProvider;
class RasterContextProvider;
}
namespace aura {
......@@ -101,6 +102,7 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
std::unique_ptr<cc::mojo_embedder::AsyncLayerTreeFrameSink>
RequestLayerTreeFrameSink(
scoped_refptr<viz::ContextProvider> context_provider,
scoped_refptr<viz::RasterContextProvider> raster_context_provider,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager);
viz::FrameSinkId GenerateFrameSinkIdFromServerId() const;
......
......@@ -906,6 +906,11 @@ gfx::Point WindowTreeClient::GetCursorScreenPoint() {
static_cast<int16_t>(location & 0xFFFF));
}
void WindowTreeClient::OnEarlyShutdown() {
if (compositor_context_factory_)
compositor_context_factory_->ResetSharedWorkerContextProvider();
}
void WindowTreeClient::OnEventObserverAdded(
ui::EventObserver* observer,
const std::set<ui::EventType>& types) {
......
......@@ -198,6 +198,9 @@ class AURA_EXPORT WindowTreeClient
// race the asynchronous initialization; but in that case we return (0, 0).
gfx::Point GetCursorScreenPoint();
// May be called to do early shutdown.
void OnEarlyShutdown();
// Called when the local aura::Env adds or removes EventObservers.
void OnEventObserverAdded(ui::EventObserver* observer,
const std::set<ui::EventType>& types);
......
......@@ -3259,6 +3259,8 @@ TEST_P(WindowTest, LocalSurfaceIdChanges) {
window.Init(ui::LAYER_NOT_DRAWN);
window.SetBounds(gfx::Rect(300, 300));
root_window()->AddChild(&window);
std::unique_ptr<cc::LayerTreeFrameSink> frame_sink(
window.CreateLayerTreeFrameSink());
viz::LocalSurfaceId local_surface_id1 =
......
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