[go: nahoru, domu]

blob: cb36fdb9dbcd8778792691fc1c2e8a261c7f4ea3 [file] [log] [blame]
spang@chromium.org85905ed2014-07-24 18:48:411// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Kristian H. Kristensen30a4f932018-03-05 18:58:595#include <iostream>
Michael Spang2829d0d2019-03-21 21:10:256#include <memory>
martina.kollarovac0f8a962015-12-21 09:09:007
spang@chromium.org85905ed2014-07-24 18:48:418#include "base/at_exit.h"
9#include "base/command_line.h"
Peng Huangb97e1882018-02-23 18:43:2110#include "base/debug/stack_trace.h"
Alexander Timin4f9c35c2018-11-01 20:15:2011#include "base/message_loop/message_loop.h"
spang@chromium.org85905ed2014-07-24 18:48:4112#include "base/run_loop.h"
Gabriel Charette52fa3ae2019-04-15 21:44:3713#include "base/task/thread_pool/thread_pool.h"
Robert Kroegerb0c2e452017-06-19 21:36:1914#include "base/trace_event/trace_event.h"
Mustafa Çamurcu92fe48f2018-04-24 21:51:0115#include "build/build_config.h"
Robert Kroegerb0c2e452017-06-19 21:36:1916#include "components/tracing/common/trace_to_console.h"
17#include "components/tracing/common/tracing_switches.h"
Michael Spang1523cdb2019-03-18 22:01:5518#include "mojo/core/embedder/embedder.h"
dnicoara6e408ee82015-01-14 03:55:2719#include "ui/events/ozone/layout/keyboard_layout_engine.h"
20#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
Michael Spangc44ad7df2018-04-25 20:23:2721#include "ui/ozone/demo/simple_renderer_factory.h"
Daniel Nicoarae0723f132018-03-22 22:00:0822#include "ui/ozone/demo/window_manager.h"
Michael Spang1523cdb2019-03-18 22:01:5523#include "ui/ozone/public/ozone_gpu_test_helper.h"
spang@chromium.org85905ed2014-07-24 18:48:4124#include "ui/ozone/public/ozone_platform.h"
spang@chromium.org85905ed2014-07-24 18:48:4125
Kristian H. Kristensen30a4f932018-03-05 18:58:5926const char kHelp[] = "help";
spangcb6a15f2015-09-16 22:48:5527
spang@chromium.org85905ed2014-07-24 18:48:4128int main(int argc, char** argv) {
avi6b10fd02014-12-23 05:51:2329 base::CommandLine::Init(argc, argv);
spang@chromium.org85905ed2014-07-24 18:48:4130 base::AtExitManager exit_manager;
31
Peng Huangb97e1882018-02-23 18:43:2132 base::debug::EnableInProcessStackDumping();
33
dnicoara655c4e62015-02-11 18:25:5634 // Initialize logging so we can enable VLOG messages.
35 logging::LoggingSettings settings;
Mustafa Çamurcu92fe48f2018-04-24 21:51:0136
37// Logs to system debug by default on POSIX.
38#if defined(OS_WIN)
39 settings.log_file = FILE_PATH_LITERAL("ozone_demo.log");
40#endif
41
dnicoara655c4e62015-02-11 18:25:5642 logging::InitLogging(settings);
43
Kristian H. Kristensen30a4f932018-03-05 18:58:5944 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kHelp)) {
Alexandros Frantzisddd5a912018-05-17 03:24:2245 std::cout << "Usage:\n\n"
46 " --disable-gpu Force software rendering\n"
47 " --disable-surfaceless Don't use surfaceless EGL\n"
48 " --window-size=WIDTHxHEIGHT Specify window size\n"
49 " --partial-primary-plane "
50 "Use smaller than fullscreen primary plane\n"
51 " --enable-overlay Use an overlay plane\n"
52 " --disable-primary-plane Don't use the primary plane\n"
53 " --use-gpu-fences "
54 "Use GpuFences for buffer display synchronization\n";
Kristian H. Kristensen30a4f932018-03-05 18:58:5955
56 // TODO(hoegsberg): We should add a little more help text about how these
57 // options interact and depend on each other.
58
59 exit(EXIT_SUCCESS);
60 }
61
Robert Kroegerb0c2e452017-06-19 21:36:1962 // Initialize tracing.
63 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
64 switches::kTraceToConsole)) {
65 base::trace_event::TraceConfig trace_config =
66 tracing::GetConfigForTraceToConsole();
67 base::trace_event::TraceLog::GetInstance()->SetEnabled(
68 trace_config, base::trace_event::TraceLog::RECORDING_MODE);
69 }
70
Michael Spang1523cdb2019-03-18 22:01:5571 mojo::core::Init();
72
spang@chromium.org85905ed2014-07-24 18:48:4173 base::MessageLoopForUI message_loop;
Gabriel Charette52fa3ae2019-04-15 21:44:3774 base::ThreadPool::CreateAndStartWithDefaultParams("OzoneDemo");
spang@chromium.org85905ed2014-07-24 18:48:4175
kylechard0cd2b32017-09-19 00:30:1676 ui::OzonePlatform::InitParams params;
77 params.single_process = true;
Michael Spang1523cdb2019-03-18 22:01:5578 params.using_mojo = ui::OzonePlatform::EnsureInstance()
79 ->GetPlatformProperties()
80 .requires_mojo;
kylechard0cd2b32017-09-19 00:30:1681 ui::OzonePlatform::InitializeForUI(params);
dnicoara6e408ee82015-01-14 03:55:2782 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine()
83 ->SetCurrentLayoutByName("us");
spang@chromium.org85905ed2014-07-24 18:48:4184
Michael Spang1523cdb2019-03-18 22:01:5585 ui::OzonePlatform::InitializeForGPU(params);
86 ui::OzonePlatform::GetInstance()->AfterSandboxEntry();
87
88 std::unique_ptr<ui::OzoneGpuTestHelper> gpu_helper;
89 if (!params.using_mojo) {
90 // OzoneGpuTestHelper transports Chrome IPC messages between host & gpu code
91 // in single process mode. We don't use both Chrome IPC and mojo, so only
92 // initialize it for non-mojo platforms.
93 gpu_helper = std::make_unique<ui::OzoneGpuTestHelper>();
94 gpu_helper->Initialize(base::ThreadTaskRunnerHandle::Get());
95 }
96
spang@chromium.org85905ed2014-07-24 18:48:4197 base::RunLoop run_loop;
spangbb91b33b2015-01-09 23:06:1798
Michael Spangc44ad7df2018-04-25 20:23:2799 ui::WindowManager window_manager(
100 std::make_unique<ui::SimpleRendererFactory>(), run_loop.QuitClosure());
spangbb91b33b2015-01-09 23:06:17101
102 run_loop.Run();
spang@chromium.org85905ed2014-07-24 18:48:41103
104 return 0;
105}