Commit eeb5a94c authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

mus: Use a cmd flag when mus is hosting viz.

Use --mus=viz if the mus window-server is the viz-host. If --mus is
not set to viz, then mus is used, but chrome still is the viz host.

For now, always set it to 'viz', so that mus still remains the viz
host. Once some more fixes land, we can turn it off by default.

BUG=786453

Change-Id: If8f6fca0178322311a0a14b718b08f9084bda35c
Reviewed-on: https://chromium-review.googlesource.com/792276
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519840}
parent 248a0ed1
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "ui/aura/test/aura_test_context_factory.h" #include "ui/aura/test/aura_test_context_factory.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
#include "ui/gfx/gfx_paths.h" #include "ui/gfx/gfx_paths.h"
#include "ui/gl/test/gl_surface_test_support.h" #include "ui/gl/test/gl_surface_test_support.h"
...@@ -73,6 +74,9 @@ void AshTestSuite::Initialize() { ...@@ -73,6 +74,9 @@ void AshTestSuite::Initialize() {
context_factory_ = std::make_unique<aura::test::AuraTestContextFactory>(); context_factory_ = std::make_unique<aura::test::AuraTestContextFactory>();
env_->set_context_factory(context_factory_.get()); env_->set_context_factory(context_factory_.get());
env_->set_context_factory_private(nullptr); env_->set_context_factory_private(nullptr);
// mus needs to host viz, because ash by itself cannot.
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kMus, switches::kMusHostVizValue);
} }
} }
......
...@@ -105,11 +105,6 @@ int ChromeMain(int argc, const char** argv) { ...@@ -105,11 +105,6 @@ int ChromeMain(int argc, const char** argv) {
#endif // defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN) #endif // defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN)
#if BUILDFLAG(ENABLE_MUS) #if BUILDFLAG(ENABLE_MUS)
if (service_manager::ServiceManagerIsRemote() ||
command_line->HasSwitch(switches::kMash)) {
params.create_discardable_memory = false;
params.env_mode = aura::Env::Mode::MUS;
}
// In config==mus the ui service runs in process and is shut down well before // In config==mus the ui service runs in process and is shut down well before
// the rest of Chrome. Have Chrome create the DiscardableSharedMemoryManager // the rest of Chrome. Have Chrome create the DiscardableSharedMemoryManager
// to ensure the DiscardableSharedMemoryManager is destroyed later on. Doing // to ensure the DiscardableSharedMemoryManager is destroyed later on. Doing
...@@ -119,6 +114,16 @@ int ChromeMain(int argc, const char** argv) { ...@@ -119,6 +114,16 @@ int ChromeMain(int argc, const char** argv) {
if (command_line->HasSwitch(switches::kMus)) { if (command_line->HasSwitch(switches::kMus)) {
params.create_discardable_memory = true; params.create_discardable_memory = true;
params.env_mode = aura::Env::Mode::MUS; params.env_mode = aura::Env::Mode::MUS;
// TODO(786453): Remove when mus no longer needs to host viz.
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kMus, switches::kMusHostVizValue);
}
if (service_manager::ServiceManagerIsRemote() ||
command_line->HasSwitch(switches::kMash)) {
params.create_discardable_memory = false;
params.env_mode = aura::Env::Mode::MUS;
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kMus, switches::kMusHostVizValue);
} }
#endif // BUILDFLAG(ENABLE_MUS) #endif // BUILDFLAG(ENABLE_MUS)
......
...@@ -85,10 +85,9 @@ class GoodiesDisplayerBrowserTest : public InProcessBrowserTest, ...@@ -85,10 +85,9 @@ class GoodiesDisplayerBrowserTest : public InProcessBrowserTest,
// InProcessBrowserTest overrides. // InProcessBrowserTest overrides.
void SetUpDefaultCommandLine(base::CommandLine* command_line) override { void SetUpDefaultCommandLine(base::CommandLine* command_line) override {
base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM); base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM);
if (command_line->HasSwitch(switches::kMash)) const char* kSwitchesToCopy[] = {switches::kMash, switches::kMus};
default_command_line.AppendSwitch(switches::kMash); default_command_line.CopySwitchesFrom(*command_line, kSwitchesToCopy,
else if (command_line->HasSwitch(switches::kMus)) arraysize(kSwitchesToCopy));
default_command_line.AppendSwitch(switches::kMus);
InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line); InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line);
if (NoFirstRunSpecified()) { // --no-first-run is present by default. if (NoFirstRunSpecified()) { // --no-first-run is present by default.
*command_line = default_command_line; *command_line = default_command_line;
......
...@@ -42,6 +42,8 @@ class MusTestLauncherDelegate : public ChromeTestLauncherDelegate { ...@@ -42,6 +42,8 @@ class MusTestLauncherDelegate : public ChromeTestLauncherDelegate {
content::GetContentMainParams()->env_mode = aura::Env::Mode::MUS; content::GetContentMainParams()->env_mode = aura::Env::Mode::MUS;
content::GetContentMainParams()->create_discardable_memory = content::GetContentMainParams()->create_discardable_memory =
(config_ == AshConfig::MUS); (config_ == AshConfig::MUS);
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kMus, switches::kMusHostVizValue);
return ChromeTestLauncherDelegate::RunTestSuite(argc, argv); return ChromeTestLauncherDelegate::RunTestSuite(argc, argv);
} }
......
...@@ -130,6 +130,7 @@ ...@@ -130,6 +130,7 @@
#include "third_party/boringssl/src/include/openssl/evp.h" #include "third_party/boringssl/src/include/openssl/evp.h"
#include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/display/display_switches.h" #include "ui/display/display_switches.h"
#include "ui/gfx/switches.h" #include "ui/gfx/switches.h"
...@@ -1454,9 +1455,6 @@ int BrowserMainLoop::BrowserThreadsStarted() { ...@@ -1454,9 +1455,6 @@ int BrowserMainLoop::BrowserThreadsStarted() {
#if BUILDFLAG(ENABLE_MUS) #if BUILDFLAG(ENABLE_MUS)
if (IsUsingMus()) { if (IsUsingMus()) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kMus,
IsMusHostingViz() ? switches::kMusHostVizValue : std::string());
base::CommandLine::ForCurrentProcess()->AppendSwitch( base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableSurfaceSynchronization); switches::kEnableSurfaceSynchronization);
} }
...@@ -1480,7 +1478,7 @@ int BrowserMainLoop::BrowserThreadsStarted() { ...@@ -1480,7 +1478,7 @@ int BrowserMainLoop::BrowserThreadsStarted() {
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
// If mus is not hosting viz, then the browser must. // If mus is not hosting viz, then the browser must.
bool browser_is_viz_host = !IsMusHostingViz(); bool browser_is_viz_host = !switches::IsMusHostingViz();
bool always_uses_gpu = true; bool always_uses_gpu = true;
bool established_gpu_channel = false; bool established_gpu_channel = false;
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include "services/service_manager/runner/common/client_util.h" #include "services/service_manager/runner/common/client_util.h"
#include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h"
#include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/compositor/compositor.h" #include "ui/compositor/compositor.h"
#include "ui/compositor/compositor_switches.h" #include "ui/compositor/compositor_switches.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
...@@ -242,7 +243,7 @@ GpuProcessTransportFactory::CreateSoftwareOutputDevice( ...@@ -242,7 +243,7 @@ GpuProcessTransportFactory::CreateSoftwareOutputDevice(
return base::WrapUnique(new viz::SoftwareOutputDevice); return base::WrapUnique(new viz::SoftwareOutputDevice);
#if defined(USE_AURA) #if defined(USE_AURA)
if (IsMusHostingViz()) { if (switches::IsMusHostingViz()) {
NOTREACHED(); NOTREACHED();
return nullptr; return nullptr;
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/command_buffer/service/gpu_switches.h"
#include "services/resource_coordinator/public/interfaces/memory_instrumentation/constants.mojom.h" #include "services/resource_coordinator/public/interfaces/memory_instrumentation/constants.mojom.h"
#include "services/service_manager/runner/common/client_util.h" #include "services/service_manager/runner/common/client_util.h"
#include "ui/base/ui_base_switches_util.h"
namespace content { namespace content {
...@@ -266,7 +267,7 @@ BrowserGpuChannelHostFactory::AllocateSharedMemory(size_t size) { ...@@ -266,7 +267,7 @@ BrowserGpuChannelHostFactory::AllocateSharedMemory(size_t size) {
void BrowserGpuChannelHostFactory::EstablishGpuChannel( void BrowserGpuChannelHostFactory::EstablishGpuChannel(
const gpu::GpuChannelEstablishedCallback& callback) { const gpu::GpuChannelEstablishedCallback& callback) {
#if defined(USE_AURA) #if defined(USE_AURA)
DCHECK(!IsMusHostingViz()); DCHECK(!switches::IsMusHostingViz());
#endif #endif
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (gpu_channel_.get() && gpu_channel_->IsLost()) { if (gpu_channel_.get() && gpu_channel_->IsLost()) {
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "content/browser/mus_util.h" #include "content/browser/mus_util.h"
#if defined(USE_AURA) #if defined(USE_AURA)
#include "content/public/browser/context_factory.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#endif #endif
...@@ -19,9 +18,4 @@ bool IsUsingMus() { ...@@ -19,9 +18,4 @@ bool IsUsingMus() {
#endif #endif
} }
bool IsMusHostingViz() {
// TODO(sad): Currently mus always is the viz host.
return IsUsingMus();
}
} // namespace content } // namespace content
...@@ -11,8 +11,6 @@ namespace content { ...@@ -11,8 +11,6 @@ namespace content {
CONTENT_EXPORT bool IsUsingMus(); CONTENT_EXPORT bool IsUsingMus();
bool IsMusHostingViz();
} // namespace content } // namespace content
#endif // CONTENT_BROWSER_MUS_UTIL_H_ #endif // CONTENT_BROWSER_MUS_UTIL_H_
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
#include "ui/base/hit_test.h" #include "ui/base/hit_test.h"
#include "ui/base/ime/input_method.h" #include "ui/base/ime/input_method.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/base/ui_base_types.h" #include "ui/base/ui_base_types.h"
#include "ui/compositor/compositor_vsync_manager.h" #include "ui/compositor/compositor_vsync_manager.h"
#include "ui/compositor/dip_util.h" #include "ui/compositor/dip_util.h"
...@@ -413,7 +414,7 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura( ...@@ -413,7 +414,7 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(
is_guest_view_hack_(is_guest_view_hack), is_guest_view_hack_(is_guest_view_hack),
device_scale_factor_(0.0f), device_scale_factor_(0.0f),
event_handler_(new RenderWidgetHostViewEventHandler(host_, this, this)), event_handler_(new RenderWidgetHostViewEventHandler(host_, this, this)),
frame_sink_id_(IsMusHostingViz() frame_sink_id_(switches::IsMusHostingViz()
? viz::FrameSinkId() ? viz::FrameSinkId()
: host_->AllocateFrameSinkId(is_guest_view_hack_)), : host_->AllocateFrameSinkId(is_guest_view_hack_)),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "content/browser/browser_main_loop.h" #include "content/browser/browser_main_loop.h"
#include "content/browser/child_process_launcher.h" #include "content/browser/child_process_launcher.h"
#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/mus_util.h"
#include "content/browser/service_manager/common_browser_interfaces.h" #include "content/browser/service_manager/common_browser_interfaces.h"
#include "content/browser/utility_process_host_impl.h" #include "content/browser/utility_process_host_impl.h"
#include "content/browser/wake_lock/wake_lock_context_host.h" #include "content/browser/wake_lock/wake_lock_context_host.h"
...@@ -65,6 +66,7 @@ ...@@ -65,6 +66,7 @@
#include "services/video_capture/public/cpp/constants.h" #include "services/video_capture/public/cpp/constants.h"
#include "services/video_capture/public/interfaces/constants.mojom.h" #include "services/video_capture/public/interfaces/constants.mojom.h"
#include "services/viz/public/interfaces/constants.mojom.h" #include "services/viz/public/interfaces/constants.mojom.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/base/ui_features.h" #include "ui/base/ui_features.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
...@@ -250,16 +252,21 @@ std::unique_ptr<service_manager::Service> CreateEmbeddedUIService( ...@@ -250,16 +252,21 @@ std::unique_ptr<service_manager::Service> CreateEmbeddedUIService(
config.resource_runner = task_runner; config.resource_runner = task_runner;
config.image_cursors_set_weak_ptr = image_cursors_set_weak_ptr; config.image_cursors_set_weak_ptr = image_cursors_set_weak_ptr;
config.memory_manager = memory_manager; config.memory_manager = memory_manager;
config.should_host_viz = switches::IsMusHostingViz();
return base::MakeUnique<ui::Service>(&config); return base::MakeUnique<ui::Service>(&config);
} }
void RegisterUIServiceInProcessIfNecessary( void RegisterUIServiceInProcessIfNecessary(
ServiceManagerConnection* connection) { ServiceManagerConnection* connection) {
// Some tests don't create BrowserMainLoop. // Some tests don't create BrowserMainLoop.
if (!base::CommandLine::ForCurrentProcess()->HasSwitch("mus") || if (!BrowserMainLoop::GetInstance())
!BrowserMainLoop::GetInstance()) { return;
// Do not embed the UI service when running in mash.
if (base::CommandLine::ForCurrentProcess()->HasSwitch("mash"))
return;
// Do not embed the UI service if not running with --mus.
if (!IsUsingMus())
return; return;
}
service_manager::EmbeddedServiceInfo info; service_manager::EmbeddedServiceInfo info;
info.factory = base::Bind( info.factory = base::Bind(
......
...@@ -296,6 +296,9 @@ bool UtilityProcessHostImpl::StartProcess() { ...@@ -296,6 +296,9 @@ bool UtilityProcessHostImpl::StartProcess() {
switches::kProxyServer, switches::kProxyServer,
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
switches::kEnableSandboxLogging, switches::kEnableSandboxLogging,
#endif
#if defined(USE_AURA)
switches::kMus,
#endif #endif
switches::kUseFakeDeviceForMediaStream, switches::kUseFakeDeviceForMediaStream,
switches::kUseFileForFakeVideoCapture, switches::kUseFileForFakeVideoCapture,
......
...@@ -186,6 +186,7 @@ ...@@ -186,6 +186,7 @@
#include "third_party/skia/include/core/SkGraphics.h" #include "third_party/skia/include/core/SkGraphics.h"
#include "ui/base/layout.h" #include "ui/base/layout.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/display/display_switches.h" #include "ui/display/display_switches.h"
#include "ui/gl/gl_switches.h" #include "ui/gl/gl_switches.h"
...@@ -330,16 +331,6 @@ void AddHistogramSample(void* hist, int sample) { ...@@ -330,16 +331,6 @@ void AddHistogramSample(void* hist, int sample) {
histogram->Add(sample); histogram->Add(sample);
} }
bool IsMusHostingViz() {
#if BUILDFLAG(ENABLE_MUS)
const auto* cmdline = base::CommandLine::ForCurrentProcess();
return cmdline->GetSwitchValueASCII(switches::kMus) ==
switches::kMusHostVizValue;
#else
return false;
#endif
}
class FrameFactoryImpl : public mojom::FrameFactory { class FrameFactoryImpl : public mojom::FrameFactory {
public: public:
explicit FrameFactoryImpl(const service_manager::BindSourceInfo& source_info) explicit FrameFactoryImpl(const service_manager::BindSourceInfo& source_info)
...@@ -695,10 +686,11 @@ void RenderThreadImpl::Init( ...@@ -695,10 +686,11 @@ void RenderThreadImpl::Init(
base::BindRepeating(&CreateSingleSampleMetricsProvider, base::BindRepeating(&CreateSingleSampleMetricsProvider,
message_loop()->task_runner(), GetConnector())); message_loop()->task_runner(), GetConnector()));
gpu_ = ui::Gpu::Create( gpu_ =
GetConnector(), ui::Gpu::Create(GetConnector(),
IsMusHostingViz() ? ui::mojom::kServiceName : mojom::kBrowserServiceName, switches::IsMusHostingViz() ? ui::mojom::kServiceName
GetIOTaskRunner()); : mojom::kBrowserServiceName,
GetIOTaskRunner());
viz::mojom::SharedBitmapAllocationNotifierPtr viz::mojom::SharedBitmapAllocationNotifierPtr
shared_bitmap_allocation_notifier_ptr; shared_bitmap_allocation_notifier_ptr;
...@@ -2031,7 +2023,7 @@ void RenderThreadImpl::RequestNewLayerTreeFrameSink( ...@@ -2031,7 +2023,7 @@ void RenderThreadImpl::RequestNewLayerTreeFrameSink(
} }
#if defined(USE_AURA) #if defined(USE_AURA)
if (IsMusHostingViz()) { if (switches::IsMusHostingViz()) {
if (!RendererWindowTreeClient::Get(routing_id)) { if (!RendererWindowTreeClient::Get(routing_id)) {
callback.Run(nullptr); callback.Run(nullptr);
return; return;
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "content/shell/common/shell_switches.h" #include "content/shell/common/shell_switches.h"
#include "media/base/media_switches.h" #include "media/base/media_switches.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_switches.h"
#include "ui/base/ui_features.h"
#ifdef V8_USE_EXTERNAL_STARTUP_DATA #ifdef V8_USE_EXTERNAL_STARTUP_DATA
#include "gin/v8_initializer.h" #include "gin/v8_initializer.h"
...@@ -50,6 +52,12 @@ class ContentBrowserTestSuite : public ContentTestSuiteBase { ...@@ -50,6 +52,12 @@ class ContentBrowserTestSuite : public ContentTestSuiteBase {
public: public:
ContentBrowserTestSuite(int argc, char** argv) ContentBrowserTestSuite(int argc, char** argv)
: ContentTestSuiteBase(argc, argv) { : ContentTestSuiteBase(argc, argv) {
#if BUILDFLAG(ENABLE_MUS)
// TODO(786453): This should be removed once mus can run without viz.
auto* cmd = base::CommandLine::ForCurrentProcess();
if (cmd->HasSwitch(switches::kMus))
cmd->AppendSwitchASCII(switches::kMus, switches::kMusHostVizValue);
#endif
} }
~ContentBrowserTestSuite() override {} ~ContentBrowserTestSuite() override {}
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
#include "ui/compositor/compositor.h" #include "ui/compositor/compositor.h"
#include "ui/compositor/reflector.h" #include "ui/compositor/reflector.h"
#include "ui/compositor/test/fake_context_factory.h" #include "ui/compositor/test/fake_context_factory.h"
...@@ -36,6 +37,8 @@ void MashTestSuite::Initialize() { ...@@ -36,6 +37,8 @@ void MashTestSuite::Initialize() {
base::CommandLine::ForCurrentProcess()->AppendSwitch( base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kOverrideUseSoftwareGLForTests); switches::kOverrideUseSoftwareGLForTests);
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kMus, switches::kMusHostVizValue);
// Load ash mus strings and resources; not 'common' (Chrome) resources. // Load ash mus strings and resources; not 'common' (Chrome) resources.
base::FilePath resources; base::FilePath resources;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "services/ui/public/interfaces/constants.mojom.h" #include "services/ui/public/interfaces/constants.mojom.h"
#include "services/ui/public/interfaces/window_server_test.mojom.h" #include "services/ui/public/interfaces/window_server_test.mojom.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_switches.h"
namespace ui { namespace ui {
namespace demo { namespace demo {
...@@ -30,6 +31,8 @@ class MusDemoTest : public service_manager::test::ServiceTest { ...@@ -30,6 +31,8 @@ class MusDemoTest : public service_manager::test::ServiceTest {
void SetUp() override { void SetUp() override {
base::CommandLine::ForCurrentProcess()->AppendSwitch("use-test-config"); base::CommandLine::ForCurrentProcess()->AppendSwitch("use-test-config");
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kMus, switches::kMusHostVizValue);
ServiceTest::SetUp(); ServiceTest::SetUp();
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "services/ui/ws/window_server_test_base.h" #include "services/ui/ws/window_server_test_base.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h"
#include "base/location.h" #include "base/location.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/run_loop.h" #include "base/run_loop.h"
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/mus/window_tree_client.h" #include "ui/aura/mus/window_tree_client.h"
#include "ui/aura/mus/window_tree_host_mus.h" #include "ui/aura/mus/window_tree_host_mus.h"
#include "ui/base/ui_base_switches.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/display_list.h" #include "ui/display/display_list.h"
#include "ui/wm/core/capture_controller.h" #include "ui/wm/core/capture_controller.h"
...@@ -91,6 +93,8 @@ WindowServerTestBase::ReleaseMostRecentClient() { ...@@ -91,6 +93,8 @@ WindowServerTestBase::ReleaseMostRecentClient() {
} }
void WindowServerTestBase::SetUp() { void WindowServerTestBase::SetUp() {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kMus, switches::kMusHostVizValue);
WindowServerServiceTestBase::SetUp(); WindowServerServiceTestBase::SetUp();
env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "ui/aura/window_delegate.h" #include "ui/aura/window_delegate.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/base/class_property.h" #include "ui/base/class_property.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/gfx/geometry/dip_util.h" #include "ui/gfx/geometry/dip_util.h"
...@@ -591,6 +592,8 @@ void WindowPortMus::UpdatePrimarySurfaceId() { ...@@ -591,6 +592,8 @@ void WindowPortMus::UpdatePrimarySurfaceId() {
} }
void WindowPortMus::UpdateClientSurfaceEmbedder() { void WindowPortMus::UpdateClientSurfaceEmbedder() {
if (!switches::IsMusHostingViz())
return;
if (window_mus_type() != WindowMusType::TOP_LEVEL_IN_WM && if (window_mus_type() != WindowMusType::TOP_LEVEL_IN_WM &&
window_mus_type() != WindowMusType::EMBED_IN_OWNER && window_mus_type() != WindowMusType::EMBED_IN_OWNER &&
window_mus_type() != WindowMusType::DISPLAY_MANUALLY_CREATED && window_mus_type() != WindowMusType::DISPLAY_MANUALLY_CREATED &&
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
#include "ui/aura/window_port_for_shutdown.h" #include "ui/aura/window_port_for_shutdown.h"
#include "ui/aura/window_tracker.h" #include "ui/aura/window_tracker.h"
#include "ui/base/layout.h" #include "ui/base/layout.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/base/ui_base_types.h" #include "ui/base/ui_base_types.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/display/types/display_constants.h" #include "ui/display/types/display_constants.h"
...@@ -224,11 +225,15 @@ WindowTreeClient::WindowTreeClient( ...@@ -224,11 +225,15 @@ WindowTreeClient::WindowTreeClient(
io_task_runner = io_thread_->task_runner(); io_task_runner = io_thread_->task_runner();
} }
gpu_ = ui::Gpu::Create(connector, ui::mojom::kServiceName, io_task_runner); if (switches::IsMusHostingViz()) {
compositor_context_factory_ = gpu_ =
std::make_unique<MusContextFactory>(gpu_.get()); ui::Gpu::Create(connector, ui::mojom::kServiceName, io_task_runner);
initial_context_factory_ = Env::GetInstance()->context_factory(); compositor_context_factory_ =
Env::GetInstance()->set_context_factory(compositor_context_factory_.get()); std::make_unique<MusContextFactory>(gpu_.get());
initial_context_factory_ = Env::GetInstance()->context_factory();
Env::GetInstance()->set_context_factory(
compositor_context_factory_.get());
}
// WindowServerTest will create more than one WindowTreeClient. We will not // WindowServerTest will create more than one WindowTreeClient. We will not
// create the discardable memory manager for those tests. // create the discardable memory manager for those tests.
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "ui/aura/window_tracker.h" #include "ui/aura/window_tracker.h"
#include "ui/aura/window_tree_host_observer.h" #include "ui/aura/window_tree_host_observer.h"
#include "ui/base/class_property.h" #include "ui/base/class_property.h"
#include "ui/base/ui_base_switches.h"
#include "ui/compositor/compositor.h" #include "ui/compositor/compositor.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/display_switches.h" #include "ui/display/display_switches.h"
...@@ -192,6 +193,8 @@ class WindowTreeClientWmTestSurfaceSync ...@@ -192,6 +193,8 @@ class WindowTreeClientWmTestSurfaceSync
// WindowTreeClientWmTest: // WindowTreeClientWmTest:
void SetUp() override { void SetUp() override {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kMus, switches::kMusHostVizValue);
if (GetParam()) { if (GetParam()) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kForceDeviceScaleFactor, "2"); switches::kForceDeviceScaleFactor, "2");
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "ui/base/ime/input_method_factory.h" #include "ui/base/ime/input_method_factory.h"
#include "ui/base/ime/input_method_initializer.h" #include "ui/base/ime/input_method_initializer.h"
#include "ui/base/platform_window_defaults.h" #include "ui/base/platform_window_defaults.h"
#include "ui/base/ui_base_switches.h"
#include "ui/compositor/compositor.h" #include "ui/compositor/compositor.h"
#include "ui/compositor/layer_animator.h" #include "ui/compositor/layer_animator.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h"
...@@ -105,6 +106,11 @@ void AuraTestHelper::SetUp(ui::ContextFactory* context_factory, ...@@ -105,6 +106,11 @@ void AuraTestHelper::SetUp(ui::ContextFactory* context_factory,
capture_client_ = std::make_unique<client::DefaultCaptureClient>(); capture_client_ = std::make_unique<client::DefaultCaptureClient>();
const Env::Mode env_mode = const Env::Mode env_mode =
(mode_ == Mode::LOCAL) ? Env::Mode::LOCAL : Env::Mode::MUS; (mode_ == Mode::LOCAL) ? Env::Mode::LOCAL : Env::Mode::MUS;
if (env_mode == Env::Mode::MUS) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kMus, switches::kMusHostVizValue);
}
if (mode_ == Mode::MUS_CREATE_WINDOW_TREE_CLIENT) if (mode_ == Mode::MUS_CREATE_WINDOW_TREE_CLIENT)
InitWindowTreeClient(); InitWindowTreeClient();
if (!Env::GetInstanceDontCreate()) if (!Env::GetInstanceDontCreate())
......
...@@ -127,7 +127,7 @@ const char kMangleLocalizedStrings[] = "mangle-localized-strings"; ...@@ -127,7 +127,7 @@ const char kMangleLocalizedStrings[] = "mangle-localized-strings";
const char kSlowDownCompositingScaleFactor[] = const char kSlowDownCompositingScaleFactor[] =
"slow-down-compositing-scale-factor"; "slow-down-compositing-scale-factor";
#if BUILDFLAG(ENABLE_MUS) #if defined(USE_AURA)
// Used to enable the mus service (aka the UI service). This makes mus run in // Used to enable the mus service (aka the UI service). This makes mus run in
// process. It is also used to notify the clients that the UI service is being // process. It is also used to notify the clients that the UI service is being
// used. If the value of this flag is set to kMusHostVizValue, then that means // used. If the value of this flag is set to kMusHostVizValue, then that means
......
...@@ -57,7 +57,7 @@ UI_BASE_EXPORT extern const char kUseSkiaRenderer[]; ...@@ -57,7 +57,7 @@ UI_BASE_EXPORT extern const char kUseSkiaRenderer[];
UI_BASE_EXPORT extern const char kDisallowNonExactResourceReuse[]; UI_BASE_EXPORT extern const char kDisallowNonExactResourceReuse[];
UI_BASE_EXPORT extern const char kMangleLocalizedStrings[]; UI_BASE_EXPORT extern const char kMangleLocalizedStrings[];
#if BUILDFLAG(ENABLE_MUS) #if defined(USE_AURA)
UI_BASE_EXPORT extern const char kMus[]; UI_BASE_EXPORT extern const char kMus[];
UI_BASE_EXPORT extern const char kMusHostVizValue[]; UI_BASE_EXPORT extern const char kMusHostVizValue[];
#endif #endif
......
...@@ -20,4 +20,13 @@ bool IsTouchDragDropEnabled() { ...@@ -20,4 +20,13 @@ bool IsTouchDragDropEnabled() {
#endif #endif
} }
bool IsMusHostingViz() {
#if defined(USE_AURA)
auto* cmd = base::CommandLine::ForCurrentProcess();
return cmd->GetSwitchValueASCII(switches::kMus) == switches::kMusHostVizValue;
#else
return false;
#endif
}
} // namespace switches } // namespace switches
...@@ -12,6 +12,10 @@ namespace switches { ...@@ -12,6 +12,10 @@ namespace switches {
UI_BASE_EXPORT bool IsLinkDisambiguationPopupEnabled(); UI_BASE_EXPORT bool IsLinkDisambiguationPopupEnabled();
UI_BASE_EXPORT bool IsTouchDragDropEnabled(); UI_BASE_EXPORT bool IsTouchDragDropEnabled();
// Returns whether mus is hosting viz. Mus is hosting viz only if --mus flag
// is set to 'viz'.
UI_BASE_EXPORT bool IsMusHostingViz();
} // namespace switches } // namespace switches
#endif // UI_BASE_UI_BASE_SWITCHES_UTIL_H_ #endif // UI_BASE_UI_BASE_SWITCHES_UTIL_H_
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "ui/aura/mus/window_tree_host_mus.h" #include "ui/aura/mus/window_tree_host_mus.h"
#include "ui/aura/test/mus/input_method_mus_test_api.h" #include "ui/aura/test/mus/input_method_mus_test_api.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/ui_base_switches.h"
#include "ui/compositor/test/fake_context_factory.h" #include "ui/compositor/test/fake_context_factory.h"
#include "ui/gl/gl_switches.h" #include "ui/gl/gl_switches.h"
#include "ui/views/mus/desktop_window_tree_host_mus.h" #include "ui/views/mus/desktop_window_tree_host_mus.h"
...@@ -248,6 +249,8 @@ void ViewsMusTestSuite::Initialize() { ...@@ -248,6 +249,8 @@ void ViewsMusTestSuite::Initialize() {
EnsureCommandLineSwitch(ui::switches::kUseTestConfig); EnsureCommandLineSwitch(ui::switches::kUseTestConfig);
EnsureCommandLineSwitch(switches::kOverrideUseSoftwareGLForTests); EnsureCommandLineSwitch(switches::kOverrideUseSoftwareGLForTests);
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kMus, switches::kMusHostVizValue);
ViewsTestSuite::Initialize(); ViewsTestSuite::Initialize();
service_manager_connections_ = std::make_unique<ServiceManagerConnection>(); service_manager_connections_ = std::make_unique<ServiceManagerConnection>();
......
...@@ -27,7 +27,8 @@ WMTestHelper::WMTestHelper(const gfx::Size& default_window_size, ...@@ -27,7 +27,8 @@ WMTestHelper::WMTestHelper(const gfx::Size& default_window_size,
service_manager::Connector* connector, service_manager::Connector* connector,
ui::ContextFactory* context_factory) { ui::ContextFactory* context_factory) {
wm_state_ = std::make_unique<WMState>(); wm_state_ = std::make_unique<WMState>();
aura::Env::GetInstance()->set_context_factory(context_factory); if (context_factory)
aura::Env::GetInstance()->set_context_factory(context_factory);
if (aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL) if (aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL)
InitLocalHost(default_window_size); InitLocalHost(default_window_size);
else else
......
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