blob: 8406b41d69aa599ffd0abf8031ac41e388c1e1fe [file] [log] [blame] [view]
fwang8491a612016-10-31 20:59:451# Ozone Overview
2
3Ozone is a platform abstraction layer beneath the Aura window system that is
4used for low level input and graphics. Once complete, the abstraction will
5support underlying systems ranging from embedded SoC targets to new
6X11-alternative window systems on Linux such as Wayland or Mir to bring up Aura
7Chromium by providing an implementation of the platform interface.
8
9## Guiding Principles
10
11Our goal is to enable chromium to be used in a wide variety of projects by
12making porting to new platforms easy. To support this goal, ozone follows the
13following principles:
14
151. **Interfaces, not ifdefs**. Differences between platforms are handled by
16 calling a platform-supplied object through an interface instead of using
17 conditional compilation. Platform internals remain encapsulated, and the
18 public interface acts as a firewall between the platform-neutral upper
19 layers (aura, blink, content, etc) and the platform-specific lower layers.
20 The platform layer is relatively centralized to minimize the number of
21 places ports need to add code.
222. **Flexible interfaces**. The platform interfaces should encapsulate just what
23 chrome needs from the platform, with minimal constraints on the platform's
24 implementation as well as minimal constraints on usage from upper layers. An
25 overly prescriptive interface is less useful for porting because fewer ports
26 will be able to use it unmodified. Another way of stating is that the
27 platform layer should provide mechanism, not policy.
283. **Runtime binding of platforms**. Avoiding conditional compilation in the
29 upper layers allows us to build multiple platforms into one binary and bind
30 them at runtime. We allow this and provide a command-line flag to select a
31 platform (`--ozone-platform`) if multiple are enabled. Each platform has a
32 unique build define (e.g. `ozone_platform_foo`) that can be turned on or off
33 independently.
344. **Easy out-of-tree platforms**. Most ports begin as forks. Some of them
35 later merge their code upstream, others will have an extended life out of
36 tree. This is OK, and we should make this process easy to encourage ports,
37 and to encourage frequent gardening of chromium changes into the downstream
38 project. If gardening an out-of-tree port is hard, then those projects will
39 simply ship outdated and potentially insecure chromium-derived code to users.
40 One way we support these projects is by providing a way to inject additional
41 platforms into the build by only patching one `ozone_extra.gni` file.
42
43## Ozone Platform Interface
44
45Ozone moves platform-specific code behind the following interfaces:
46
47* `PlatformWindow` represents a window in the windowing system underlying
48 chrome. Interaction with the windowing system (resize, maximize, close, etc)
49 as well as dispatch of input events happens via this interface. Under aura, a
50 `PlatformWindow` corresponds to a `WindowTreeHost`. Under mojo, it corresponds
51 to a `NativeViewport`. On bare hardware, the underlying windowing system is
52 very simple and a platform window corresponds to a physical display.
53* `SurfaceFactoryOzone` is used to create surfaces for the Chrome compositor to
54 paint on using EGL/GLES2 or Skia.
55* `GpuPlatformSupportHost` provides the platform code
56 access to IPC between the browser & GPU processes. Some platforms need this
57 to provide additional services in the GPU process such as display
58 configuration.
fwang8491a612016-10-31 20:59:4559* `OverlayManagerOzone` is used to manage overlays.
60* `InputController` allows to control input devices such as keyboard, mouse or
61 touchpad.
62* `SystemInputInjector` converts input into events and injects them to the
63 Ozone platform.
64* `NativeDisplayDelegate` is used to support display configuration & hotplug.
Maksim Sisov0a0b7482018-10-18 07:59:4265* `PlatformScreen` is used to fetch screen configuration.
66* `ClipboardDelegate` provides an interface to exchange data with other
67applications on the host system using a system clipboard mechanism.
fwang8491a612016-10-31 20:59:4568
69## Ozone in Chromium
70
71Our implementation of Ozone required changes concentrated in these areas:
72
73* Cleaning up extensive assumptions about use of X11 throughout the tree,
kylecharcbd11482023-01-04 19:58:1974 protecting this code behind the `USE_X11` ifdef, and adding a new `IS_OZONE`
fwang8491a612016-10-31 20:59:4575 path that works in a relatively platform-neutral way by delegating to the
76 interfaces described above.
77* a `WindowTreeHostOzone` to send events into Aura and participate in display
78 management on the host system, and
79* an Ozone-specific flavor of `GLSurfaceEGL` which delegates allocation of
80 accelerated surfaces and refresh syncing to the provided implementation of
81 `SurfaceFactoryOzone`.
82
83## Porting with Ozone
84
85Users of the Ozone abstraction need to do the following, at minimum:
86
87* Write a subclass of `PlatformWindow`. This class (I'll call it
88 `PlatformWindowImpl`) is responsible for window system integration. It can
89 use `MessagePumpLibevent` to poll for events from file descriptors and then
90 invoke `PlatformWindowDelegate::DispatchEvent` to dispatch each event.
91* Write a subclass of `SurfaceFactoryOzone` that handles allocating accelerated
92 surfaces. I'll call this `SurfaceFactoryOzoneImpl`.
Henrique Ferreiroaaa2a6262020-05-22 00:36:1593* Write a subclass of `CursorFactory` to manage cursors, or use the
Henrique Ferreiroc3d6e3722021-11-18 20:54:3994 `BitmapCursorFactory` implementation if only bitmap cursors need to be supported.
fwang8491a612016-10-31 20:59:4595* Write a subclass of `OverlayManagerOzone` or just use `StubOverlayManager` if
96 your platform does not support overlays.
97* Write a subclass of `NativeDisplayDelegate` if necessary or just use
Maksim Sisov0a0b7482018-10-18 07:59:4298 `FakeDisplayDelegate`, and write a subclass of `PlatformScreen`, which is
99 used by aura::ScreenOzone then.
fwang8491a612016-10-31 20:59:45100* Write a subclass of `GpuPlatformSupportHost` or just use
101 `StubGpuPlatformSupportHost`.
102* Write a subclass of `InputController` or just use `StubInputController`.
103* Write a subclass of `SystemInputInjector` if necessary.
104* Write a subclass of `OzonePlatform` that owns instances of
105 the above subclasses and provide a static constructor function for these
106 objects. This constructor will be called when
107 your platform is selected and the returned objects will be used to provide
108 implementations of all the ozone platform interfaces.
109 If your platform does not need some of the interfaces then you can just
110 return a `Stub*` instance or a `nullptr`.
111
112## Adding an Ozone Platform to the build (instructions for out-of-tree ports)
113
114The recommended way to add your platform to the build is as follows. This walks
115through creating a new ozone platform called `foo`.
116
1171. Fork `chromium/src.git`.
1182. Add your implementation in `ui/ozone/platform/` alongside internal platforms.
1193. Patch `ui/ozone/ozone_extra.gni` to add your `foo` platform.
120
121## Building with Ozone
122
derat817105082017-02-22 17:57:55123### Chrome OS - ([waterfall](https://build.chromium.org/p/chromium.chromiumos/waterfall?builder=Linux+ChromiumOS+Ozone+Builder&builder=Linux+ChromiumOS+Ozone+Tests+%281%29&builder=Linux+ChromiumOS+Ozone+Tests+%282%29&reload=none))
fwang8491a612016-10-31 20:59:45124
125To build `chrome`, do this from the `src` directory:
126
127``` shell
128gn args out/OzoneChromeOS --args="use_ozone=true target_os=\"chromeos\""
129ninja -C out/OzoneChromeOS chrome
130```
131
132Then to run for example the X11 platform:
133
134``` shell
fwang399b51c2016-11-10 09:48:27135./out/OzoneChromeOS/chrome --ozone-platform=x11
fwang8491a612016-10-31 20:59:45136```
137
138### Embedded
139
fwang7af9db62017-01-09 14:52:22140**Warning: Only some targets such as `content_shell` or unit tests are
141currently working for embedded builds.**
fwang8491a612016-10-31 20:59:45142
143To build `content_shell`, do this from the `src` directory:
144
145``` shell
146gn args out/OzoneEmbedded --args="use_ozone=true toolkit_views=false"
147ninja -C out/OzoneEmbedded content_shell
148```
149
150Then to run for example the headless platform:
151
152``` shell
fwang399b51c2016-11-10 09:48:27153./out/OzoneEmbedded/content_shell --ozone-platform=headless \
fwang8491a612016-10-31 20:59:45154 --ozone-dump-file=/tmp/
155```
156
Maksim Sisovfb1ab3d2021-11-08 06:34:40157### Linux Desktop - ([X11 waterfall](https://ci.chromium.org/p/chromium/builders/try/linux-rel) &&
158[Wayland waterfall](https://ci.chromium.org/p/chromium/builders/try/linux-wayland-rel))
fwang8491a612016-10-31 20:59:45159
Maksim Sisovfb1ab3d2021-11-08 06:34:40160By default, Linux enables the following Ozone backends - X11, Wayland and Headless.
fwang15744c72016-11-08 13:58:33161
Maksim Sisovfb1ab3d2021-11-08 06:34:40162If you want to disable Ozone/X11 in the build, do this from the `src` directory:
fwang15744c72016-11-08 13:58:33163
164``` shell
Maksim Sisovfb1ab3d2021-11-08 06:34:40165gn args out/OzoneLinuxDesktop --args="ozone_platform_x11=false"
fwang15744c72016-11-08 13:58:33166ninja -C out/OzoneLinuxDesktop chrome
167```
Maksim Sisov0a0b7482018-10-18 07:59:42168
Maksim Sisovfb1ab3d2021-11-08 06:34:40169If you want to disable all, but Wayland Ozone backend, do this from the `src` directory:
fwang15744c72016-11-08 13:58:33170
171``` shell
Maksim Sisovfb1ab3d2021-11-08 06:34:40172gn args out/OzoneLinuxDesktop --args="ozone_auto_platforms=false ozone_platform_wayland=true"
173ninja -C out/OzoneLinuxDesktop chrome
174```
175
176Chrome/Linux uses X11 Ozone backend by default. Thus, simply start the browser without any parameters:
177
178``` shell
179./out/OzoneLinuxDesktop/chrome
fwang15744c72016-11-08 13:58:33180```
181
Maksim Sisov0a0b7482018-10-18 07:59:42182Or run for example the Wayland platform:
183
184``` shell
Maksim Sisovc3642a62019-03-13 08:06:40185./out/OzoneLinuxDesktop/chrome --ozone-platform=wayland
Maksim Sisov0a0b7482018-10-18 07:59:42186```
187
Maksim Sisovfb1ab3d2021-11-08 06:34:40188It is also possible to choose an Ozone backend via the chrome://flags/#ozone-platform-hint.
189The following options are available - Default, X11, Wayland, and Auto. The default one is
190"X11". "Auto" selects Wayland if possible, X11 otherwise.
Maksim Sisov69bc52c2020-09-30 06:30:38191
Maksim Sisov69bc52c2020-09-30 06:30:38192
fwang8491a612016-10-31 20:59:45193### GN Configuration notes
194
195You can turn properly implemented ozone platforms on and off by setting the
196corresponding flags in your GN configuration. For example
Peter McNeeley4ea922e2020-09-16 00:14:30197`ozone_platform_headless=false ozone_platform_drm=false` will turn off the
198headless and DRM (GBM) platforms.
fwang8491a612016-10-31 20:59:45199This will result in a smaller binary and faster builds. To turn ALL platforms
200off by default, set `ozone_auto_platforms=false`.
201
202You can also specify a default platform to run by setting the `ozone_platform`
203build parameter. For example `ozone_platform="x11"` will make X11 the
204default platform when `--ozone-platform` is not passed to the program.
205If `ozone_auto_platforms` is true then `ozone_platform` is set to `headless`
206by default.
207
208## Running with Ozone
209
210Specify the platform you want to use at runtime using the `--ozone-platform`
Peter McNeeley4ea922e2020-09-16 00:14:30211flag. For example, to run `content_shell` with the DRM (GBM) platform:
fwang8491a612016-10-31 20:59:45212
213``` shell
Peter McNeeley4ea922e2020-09-16 00:14:30214content_shell --ozone-platform=drm
fwang8491a612016-10-31 20:59:45215```
216
217Caveats:
218
219* `content_shell` always runs at 800x600 resolution.
Peter McNeeley4ea922e2020-09-16 00:14:30220* For the DRM (GBM) platform, you may need to terminate your X server (or any other
fwang8491a612016-10-31 20:59:45221 display server) prior to testing.
fwang399b51c2016-11-10 09:48:27222* During development, you may need to configure
Tom Anderson93e49e492019-12-23 19:55:37223 [sandboxing](linux/sandboxing.md) or to disable it.
fwang8491a612016-10-31 20:59:45224
225## Ozone Platforms
226
227### Headless
228
229This platform
230draws graphical output to a PNG image (no GPU support; software rendering only)
231and will not output to the screen. You can set
232the path of the directory where to output the images
233by specifying `--ozone-dump-file=/path/to/output-directory` on the
234command line:
235
236``` shell
fwang399b51c2016-11-10 09:48:27237content_shell --ozone-platform=headless \
fwang8491a612016-10-31 20:59:45238 --ozone-dump-file=/tmp/
239```
240
241### DRM/GBM
242
243This is Linux direct rending with acceleration via mesa GBM & linux DRM/KMS
244(EGL/GLES2 accelerated rendering & modesetting in GPU process) and is in
derat817105082017-02-22 17:57:55245production use on [Chrome OS](https://www.chromium.org/chromium-os).
fwang8491a612016-10-31 20:59:45246
derat817105082017-02-22 17:57:55247Note that all Chrome OS builds of Chrome will compile and attempt to use this.
fwang8491a612016-10-31 20:59:45248See [Building Chromium for Chromium OS](https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/building-chromium-browser) for build instructions.
249
250### Cast
251
252This platform is used for
253[Chromecast](https://www.google.com/intl/en_us/chromecast/).
254
255### X11
256
257This platform provides support for the [X window system](https://www.x.org/).
258
Maksim Sisovfb1ab3d2021-11-08 06:34:40259X11 is the default Ozone backend. You can try to compile and run it with the following
260configuration:
Maksim Sisov0c9db242019-11-22 06:20:35261
262``` shell
Maksim Sisovfb1ab3d2021-11-08 06:34:40263gn args out/OzoneX11
Maksim Sisov0c9db242019-11-22 06:20:35264ninja -C out/OzoneX11 chrome
Maksim Sisovfb1ab3d2021-11-08 06:34:40265./out/OzoneX11/chrome
Maksim Sisov0c9db242019-11-22 06:20:35266```
267
fwang8491a612016-10-31 20:59:45268### Wayland
269
270This platform provides support for the
271[Wayland](http://wayland.freedesktop.org/) display protocol. It was
272initially developed by Intel as
273[a fork of chromium](https://github.com/01org/ozone-wayland)
274and then partially upstreamed.
Maksim Sisov0c9db242019-11-22 06:20:35275
276Currently, the Ozone/Wayland is actively being developed by Igalia in
277the Chromium mainline repository with some features missing at the moment. The
278progress can be tracked in the [issue #578890](https://crbug.com/578890).
fwang8491a612016-10-31 20:59:45279
fwang15744c72016-11-08 13:58:33280Below are some quick build & run instructions. It is assumed that you are
fwang7af9db62017-01-09 14:52:22281launching `chrome` from a Wayland environment such as `weston`. Execute the
Maksim Sisov0c9db242019-11-22 06:20:35282following commands (make sure a system version of gbm and drm is used, which
283are required by Ozone/Wayland by design, when running on Linux platforms.):
fwang8491a612016-10-31 20:59:45284
Maksim Sisovfb1ab3d2021-11-08 06:34:40285Please note that the Wayland Ozone backend is built by default unless
286`ozone_auto_platforms=false` is set (the same as the X11 Ozone backend).
287
fwang8491a612016-10-31 20:59:45288``` shell
Maksim Sisovfb1ab3d2021-11-08 06:34:40289gn args out/OzoneWayland
fwang8491a612016-10-31 20:59:45290ninja -C out/OzoneWayland chrome
Maksim Sisov0a0b7482018-10-18 07:59:42291./out/OzoneWayland/chrome --ozone-platform=wayland
fwang8491a612016-10-31 20:59:45292```
293
Maksim Sisov0c9db242019-11-22 06:20:35294Native file dialogs are currently supported through the GTK toolkit. That
295implies that the browser is compiled with glib and gtk enabled. Please
296append the following gn args to your configuration:
297
298``` shell
299use_ozone=true
300use_system_minigbm=true
301use_system_libdrm=true
302use_xkbcommon=true
303use_glib=true
304use_gtk=true
305```
306
James Cooka6e9a7c2021-01-29 23:59:13307Running some test suites requires a Wayland server. If you're not
308running one you can use a locally compiled version of Weston. This is
Max Ihlenfeldtf995c612021-11-09 14:08:41309what the build bots do. Please note that this is required for
310interactive_ui_tests, as those tests use a patched version of Weston's
311test plugin. Add this to your gn args:
James Cooka6e9a7c2021-01-29 23:59:13312
313``` shell
314use_bundled_weston = true
315```
316
317Then run the xvfb.py wrapper script and tell it to start Weston:
318
319``` shell
320cd out/debug # or your out directory
Maksim Sisovfb1ab3d2021-11-08 06:34:40321../../testing/xvfb.py --use-weston --no-xvfb ./views_unittests --ozone-platform=wayland
James Cooka6e9a7c2021-01-29 23:59:13322```
323
Maksim Sisov0c9db242019-11-22 06:20:35324Feel free to discuss with us on freenode.net, `#ozone-wayland` channel or on
325`ozone-dev`, or on `#ozone-wayland-x11` channel in [chromium slack](https://www.chromium.org/developers/slack).
326
fwang8491a612016-10-31 20:59:45327### Caca
328
329This platform
330draws graphical output to text using
331[libcaca](http://caca.zoy.org/wiki/libcaca)
332(no GPU support; software
333rendering only). In case you ever wanted to test embedded content shell on
334tty.
335It has been
336[removed from the tree](https://codereview.chromium.org/2445323002/) and is no
fwang7fa6daf72016-11-03 16:07:04337longer maintained but you can
338[build it as an out-of-tree port](https://github.com/fred-wang/ozone-caca).
339
340Alternatively, you can try the latest revision known to work. First, install
341libcaca shared library and development files. Next, move to the git revision
342`0e64be9cf335ee3bea7c989702c5a9a0934af037`
343(you will probably need to synchronize the build dependencies with
344`gclient sync --with_branch_heads`). Finally, build and run the caca platform
345with the following commands:
fwang8491a612016-10-31 20:59:45346
347``` shell
fwang8491a612016-10-31 20:59:45348gn args out/OzoneCaca \
349 --args="use_ozone=true ozone_platform_caca=true use_sysroot=false ozone_auto_platforms=false toolkit_views=false"
350ninja -C out/OzoneCaca content_shell
fwang399b51c2016-11-10 09:48:27351./out/OzoneCaca/content_shell
fwang8491a612016-10-31 20:59:45352```
353
354 Note: traditional TTYs are not the ideal browsing experience.<br/>
fwang639002722016-11-08 12:33:04355 ![Picture of a workstation using Ozone/caca to display the Google home page in a text terminal](./images/ozone_caca.jpg)
fwang8491a612016-10-31 20:59:45356
Erik Chen96f83142022-06-15 20:43:25357### drm
358Ash-chrome client implementation.
359
360### flatland / scenic
361For fuchsia.
362
fwang8491a612016-10-31 20:59:45363## Communication
364
365There is a public mailing list:
366[[email protected]](https://groups.google.com/a/chromium.org/forum/#!forum/ozone-dev)