Commit 5c24e192 authored by Alexander Dunaev's avatar Alexander Dunaev Committed by Commit Bot

[ozone] Enabled Ozone in viz_demo.

viz-demo was trying to check features in order to do Ozone-specific
things, but it didn't set up features so --enable-features flag wouldn't
work, and the Ozone platform was not initialised either.

This CL fixes that.

Change-Id: I0d3ad45bcb1025fe1c3ab60edd615b03aea7bd1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2470523
Commit-Queue: Alexander Dunaev <adunaev@igalia.com>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817341}
parent e2f1328a
......@@ -55,6 +55,7 @@ executable("viz_demo") {
deps = [
"//base",
"//base:base_static",
"//base:i18n",
"//build/win:default_exe_manifest",
"//components/viz/demo:host",
......
......@@ -5,6 +5,7 @@
#include <utility>
#include "base/at_exit.h"
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/i18n/icu_util.h"
#include "base/macros.h"
......@@ -27,7 +28,9 @@
#include "ui/platform_window/platform_window_init_properties.h"
#if defined(USE_OZONE)
#include "ui/ozone/public/ozone_gpu_test_helper.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
#endif
#if defined(OS_WIN)
......@@ -84,10 +87,6 @@ class InitMojo {
class InitUI {
public:
InitUI() {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform())
XInitThreads();
#endif
event_source_ = ui::PlatformEventSource::CreateDefault();
}
......@@ -207,12 +206,57 @@ int DemoMain() {
return 0;
}
#if defined(USE_OZONE)
std::unique_ptr<ui::OzoneGpuTestHelper> gpu_helper;
static void SetupOzone(base::WaitableEvent* done) {
base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
cmd_line->AppendSwitchASCII(switches::kUseGL, gl::kGLImplementationEGLName);
ui::OzonePlatform::InitParams params;
params.single_process = true;
ui::OzonePlatform::InitializeForGPU(params);
done->Signal();
}
#endif
} // namespace
int main(int argc, char** argv) {
#if defined(USE_OZONE)
base::CommandLine command_line(argc, argv);
auto feature_list = std::make_unique<base::FeatureList>();
feature_list->InitializeFromCommandLine(
command_line.GetSwitchValueASCII(switches::kEnableFeatures),
command_line.GetSwitchValueASCII(switches::kDisableFeatures));
base::FeatureList::SetInstance(std::move(feature_list));
base::Thread rendering_thread("GLRenderingVEAClientThread");
#endif
InitBase base(argc, argv);
InitMojo mojo;
InitUI ui;
#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform()) {
ui::OzonePlatform::InitParams params;
params.single_process = true;
ui::OzonePlatform::InitializeForUI(params);
base::Thread::Options options;
options.message_pump_type = base::MessagePumpType::UI;
CHECK(rendering_thread.StartWithOptions(options));
base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
rendering_thread.task_runner()->PostTask(
FROM_HERE, base::BindOnce(&SetupOzone, &done));
done.Wait();
// To create dmabuf through gbm, Ozone needs to be set up.
gpu_helper = std::make_unique<ui::OzoneGpuTestHelper>();
gpu_helper->Initialize(base::ThreadTaskRunnerHandle::Get());
}
#endif
return DemoMain();
}
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