blob: 13f84d5ff2b32929fe3402cff85b3277774da2b6 [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
dljamesa01655042025-03-24 21:43:299> Note: There are 2 buildflags which target platforms who use OZONE.
10> They are slightly different from each other:
11> * IS_OZONE: Targets Linux, ChromeOS, and Fuchsia.
12> * IS_OZONE_WAYLAND: Targets only Linux systems using the Wayland window
13> manager. Does not include ChromeOS or Fuchsia.
14
fwang8491a612016-10-31 20:59:4515## Guiding Principles
16
17Our goal is to enable chromium to be used in a wide variety of projects by
18making porting to new platforms easy. To support this goal, ozone follows the
19following principles:
20
211. **Interfaces, not ifdefs**. Differences between platforms are handled by
22 calling a platform-supplied object through an interface instead of using
23 conditional compilation. Platform internals remain encapsulated, and the
24 public interface acts as a firewall between the platform-neutral upper
25 layers (aura, blink, content, etc) and the platform-specific lower layers.
26 The platform layer is relatively centralized to minimize the number of
27 places ports need to add code.
282. **Flexible interfaces**. The platform interfaces should encapsulate just what
29 chrome needs from the platform, with minimal constraints on the platform's
30 implementation as well as minimal constraints on usage from upper layers. An
31 overly prescriptive interface is less useful for porting because fewer ports
32 will be able to use it unmodified. Another way of stating is that the
33 platform layer should provide mechanism, not policy.
343. **Runtime binding of platforms**. Avoiding conditional compilation in the
35 upper layers allows us to build multiple platforms into one binary and bind
36 them at runtime. We allow this and provide a command-line flag to select a
37 platform (`--ozone-platform`) if multiple are enabled. Each platform has a
38 unique build define (e.g. `ozone_platform_foo`) that can be turned on or off
39 independently.
404. **Easy out-of-tree platforms**. Most ports begin as forks. Some of them
41 later merge their code upstream, others will have an extended life out of
42 tree. This is OK, and we should make this process easy to encourage ports,
43 and to encourage frequent gardening of chromium changes into the downstream
44 project. If gardening an out-of-tree port is hard, then those projects will
45 simply ship outdated and potentially insecure chromium-derived code to users.
46 One way we support these projects is by providing a way to inject additional
47 platforms into the build by only patching one `ozone_extra.gni` file.
48
49## Ozone Platform Interface
50
51Ozone moves platform-specific code behind the following interfaces:
52
53* `PlatformWindow` represents a window in the windowing system underlying
54 chrome. Interaction with the windowing system (resize, maximize, close, etc)
55 as well as dispatch of input events happens via this interface. Under aura, a
56 `PlatformWindow` corresponds to a `WindowTreeHost`. Under mojo, it corresponds
57 to a `NativeViewport`. On bare hardware, the underlying windowing system is
58 very simple and a platform window corresponds to a physical display.
59* `SurfaceFactoryOzone` is used to create surfaces for the Chrome compositor to
60 paint on using EGL/GLES2 or Skia.
61* `GpuPlatformSupportHost` provides the platform code
62 access to IPC between the browser & GPU processes. Some platforms need this
63 to provide additional services in the GPU process such as display
64 configuration.
fwang8491a612016-10-31 20:59:4565* `OverlayManagerOzone` is used to manage overlays.
66* `InputController` allows to control input devices such as keyboard, mouse or
67 touchpad.
68* `SystemInputInjector` converts input into events and injects them to the
69 Ozone platform.
70* `NativeDisplayDelegate` is used to support display configuration & hotplug.
Maksim Sisov0a0b7482018-10-18 07:59:4271* `PlatformScreen` is used to fetch screen configuration.
72* `ClipboardDelegate` provides an interface to exchange data with other
73applications on the host system using a system clipboard mechanism.
fwang8491a612016-10-31 20:59:4574
75## Ozone in Chromium
76
77Our implementation of Ozone required changes concentrated in these areas:
78
79* Cleaning up extensive assumptions about use of X11 throughout the tree,
kylecharcbd11482023-01-04 19:58:1980 protecting this code behind the `USE_X11` ifdef, and adding a new `IS_OZONE`
fwang8491a612016-10-31 20:59:4581 path that works in a relatively platform-neutral way by delegating to the
82 interfaces described above.
83* a `WindowTreeHostOzone` to send events into Aura and participate in display
84 management on the host system, and
85* an Ozone-specific flavor of `GLSurfaceEGL` which delegates allocation of
86 accelerated surfaces and refresh syncing to the provided implementation of
87 `SurfaceFactoryOzone`.
88
89## Porting with Ozone
90
91Users of the Ozone abstraction need to do the following, at minimum:
92
93* Write a subclass of `PlatformWindow`. This class (I'll call it
94 `PlatformWindowImpl`) is responsible for window system integration. It can
95 use `MessagePumpLibevent` to poll for events from file descriptors and then
96 invoke `PlatformWindowDelegate::DispatchEvent` to dispatch each event.
97* Write a subclass of `SurfaceFactoryOzone` that handles allocating accelerated
98 surfaces. I'll call this `SurfaceFactoryOzoneImpl`.
Henrique Ferreiroaaa2a6262020-05-22 00:36:1599* Write a subclass of `CursorFactory` to manage cursors, or use the
Henrique Ferreiroc3d6e3722021-11-18 20:54:39100 `BitmapCursorFactory` implementation if only bitmap cursors need to be supported.
fwang8491a612016-10-31 20:59:45101* Write a subclass of `OverlayManagerOzone` or just use `StubOverlayManager` if
102 your platform does not support overlays.
103* Write a subclass of `NativeDisplayDelegate` if necessary or just use
Maksim Sisov0a0b7482018-10-18 07:59:42104 `FakeDisplayDelegate`, and write a subclass of `PlatformScreen`, which is
105 used by aura::ScreenOzone then.
fwang8491a612016-10-31 20:59:45106* Write a subclass of `GpuPlatformSupportHost` or just use
107 `StubGpuPlatformSupportHost`.
108* Write a subclass of `InputController` or just use `StubInputController`.
109* Write a subclass of `SystemInputInjector` if necessary.
110* Write a subclass of `OzonePlatform` that owns instances of
111 the above subclasses and provide a static constructor function for these
112 objects. This constructor will be called when
113 your platform is selected and the returned objects will be used to provide
114 implementations of all the ozone platform interfaces.
115 If your platform does not need some of the interfaces then you can just
116 return a `Stub*` instance or a `nullptr`.
117
118## Adding an Ozone Platform to the build (instructions for out-of-tree ports)
119
120The recommended way to add your platform to the build is as follows. This walks
121through creating a new ozone platform called `foo`.
122
1231. Fork `chromium/src.git`.
1242. Add your implementation in `ui/ozone/platform/` alongside internal platforms.
1253. Patch `ui/ozone/ozone_extra.gni` to add your `foo` platform.
126
127## Building with Ozone
128
derat81710502017-02-22 17:57:55129### 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:45130
131To build `chrome`, do this from the `src` directory:
132
133``` shell
134gn args out/OzoneChromeOS --args="use_ozone=true target_os=\"chromeos\""
135ninja -C out/OzoneChromeOS chrome
136```
137
138Then to run for example the X11 platform:
139
140``` shell
fwang399b51c2016-11-10 09:48:27141./out/OzoneChromeOS/chrome --ozone-platform=x11
fwang8491a612016-10-31 20:59:45142```
143
144### Embedded
145
fwang7af9db62017-01-09 14:52:22146**Warning: Only some targets such as `content_shell` or unit tests are
147currently working for embedded builds.**
fwang8491a612016-10-31 20:59:45148
149To build `content_shell`, do this from the `src` directory:
150
151``` shell
152gn args out/OzoneEmbedded --args="use_ozone=true toolkit_views=false"
153ninja -C out/OzoneEmbedded content_shell
154```
155
156Then to run for example the headless platform:
157
158``` shell
fwang399b51c2016-11-10 09:48:27159./out/OzoneEmbedded/content_shell --ozone-platform=headless \
fwang8491a612016-10-31 20:59:45160 --ozone-dump-file=/tmp/
161```
162
Maksim Sisovfb1ab3d2021-11-08 06:34:40163### Linux Desktop - ([X11 waterfall](https://ci.chromium.org/p/chromium/builders/try/linux-rel) &&
164[Wayland waterfall](https://ci.chromium.org/p/chromium/builders/try/linux-wayland-rel))
fwang8491a612016-10-31 20:59:45165
Maksim Sisovfb1ab3d2021-11-08 06:34:40166By default, Linux enables the following Ozone backends - X11, Wayland and Headless.
fwang15744c72016-11-08 13:58:33167
Maksim Sisovfb1ab3d2021-11-08 06:34:40168If you want to disable Ozone/X11 in the build, do this from the `src` directory:
fwang15744c72016-11-08 13:58:33169
170``` shell
Maksim Sisovfb1ab3d2021-11-08 06:34:40171gn args out/OzoneLinuxDesktop --args="ozone_platform_x11=false"
fwang15744c72016-11-08 13:58:33172ninja -C out/OzoneLinuxDesktop chrome
173```
Maksim Sisov0a0b7482018-10-18 07:59:42174
Maksim Sisovfb1ab3d2021-11-08 06:34:40175If you want to disable all, but Wayland Ozone backend, do this from the `src` directory:
fwang15744c72016-11-08 13:58:33176
177``` shell
Maksim Sisovfb1ab3d2021-11-08 06:34:40178gn args out/OzoneLinuxDesktop --args="ozone_auto_platforms=false ozone_platform_wayland=true"
179ninja -C out/OzoneLinuxDesktop chrome
180```
181
182Chrome/Linux uses X11 Ozone backend by default. Thus, simply start the browser without any parameters:
183
184``` shell
185./out/OzoneLinuxDesktop/chrome
fwang15744c72016-11-08 13:58:33186```
187
Maksim Sisov0a0b7482018-10-18 07:59:42188Or run for example the Wayland platform:
189
190``` shell
Maksim Sisovc3642a62019-03-13 08:06:40191./out/OzoneLinuxDesktop/chrome --ozone-platform=wayland
Maksim Sisov0a0b7482018-10-18 07:59:42192```
193
Maksim Sisovfb1ab3d2021-11-08 06:34:40194It is also possible to choose an Ozone backend via the chrome://flags/#ozone-platform-hint.
Kramer Ge5667ccd2024-07-18 20:47:25195The following options are available - Default, X11, Wayland, and Auto. "Auto"
196selects Wayland if possible, X11 otherwise.
Maksim Sisov69bc52c2020-09-30 06:30:38197
Maksim Sisov69bc52c2020-09-30 06:30:38198
fwang8491a612016-10-31 20:59:45199### GN Configuration notes
200
201You can turn properly implemented ozone platforms on and off by setting the
202corresponding flags in your GN configuration. For example
Peter McNeeley4ea922e2020-09-16 00:14:30203`ozone_platform_headless=false ozone_platform_drm=false` will turn off the
204headless and DRM (GBM) platforms.
fwang8491a612016-10-31 20:59:45205This will result in a smaller binary and faster builds. To turn ALL platforms
206off by default, set `ozone_auto_platforms=false`.
207
208You can also specify a default platform to run by setting the `ozone_platform`
209build parameter. For example `ozone_platform="x11"` will make X11 the
210default platform when `--ozone-platform` is not passed to the program.
211If `ozone_auto_platforms` is true then `ozone_platform` is set to `headless`
212by default.
213
214## Running with Ozone
215
216Specify the platform you want to use at runtime using the `--ozone-platform`
Peter McNeeley4ea922e2020-09-16 00:14:30217flag. For example, to run `content_shell` with the DRM (GBM) platform:
fwang8491a612016-10-31 20:59:45218
219``` shell
Peter McNeeley4ea922e2020-09-16 00:14:30220content_shell --ozone-platform=drm
fwang8491a612016-10-31 20:59:45221```
222
223Caveats:
224
225* `content_shell` always runs at 800x600 resolution.
Peter McNeeley4ea922e2020-09-16 00:14:30226* For the DRM (GBM) platform, you may need to terminate your X server (or any other
fwang8491a612016-10-31 20:59:45227 display server) prior to testing.
fwang399b51c2016-11-10 09:48:27228* During development, you may need to configure
Tom Anderson93e49e492019-12-23 19:55:37229 [sandboxing](linux/sandboxing.md) or to disable it.
fwang8491a612016-10-31 20:59:45230
231## Ozone Platforms
232
233### Headless
234
235This platform
236draws graphical output to a PNG image (no GPU support; software rendering only)
237and will not output to the screen. You can set
238the path of the directory where to output the images
239by specifying `--ozone-dump-file=/path/to/output-directory` on the
240command line:
241
242``` shell
fwang399b51c2016-11-10 09:48:27243content_shell --ozone-platform=headless \
fwang8491a612016-10-31 20:59:45244 --ozone-dump-file=/tmp/
245```
246
247### DRM/GBM
248
249This is Linux direct rending with acceleration via mesa GBM & linux DRM/KMS
250(EGL/GLES2 accelerated rendering & modesetting in GPU process) and is in
derat81710502017-02-22 17:57:55251production use on [Chrome OS](https://www.chromium.org/chromium-os).
fwang8491a612016-10-31 20:59:45252
derat81710502017-02-22 17:57:55253Note that all Chrome OS builds of Chrome will compile and attempt to use this.
fwang8491a612016-10-31 20:59:45254See [Building Chromium for Chromium OS](https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/building-chromium-browser) for build instructions.
255
256### Cast
257
258This platform is used for
259[Chromecast](https://www.google.com/intl/en_us/chromecast/).
260
261### X11
262
263This platform provides support for the [X window system](https://www.x.org/).
264
Maksim Sisovfb1ab3d2021-11-08 06:34:40265X11 is the default Ozone backend. You can try to compile and run it with the following
266configuration:
Maksim Sisov0c9db242019-11-22 06:20:35267
268``` shell
Maksim Sisovfb1ab3d2021-11-08 06:34:40269gn args out/OzoneX11
Maksim Sisov0c9db242019-11-22 06:20:35270ninja -C out/OzoneX11 chrome
Maksim Sisovfb1ab3d2021-11-08 06:34:40271./out/OzoneX11/chrome
Maksim Sisov0c9db242019-11-22 06:20:35272```
273
fwang8491a612016-10-31 20:59:45274### Wayland
275
276This platform provides support for the
277[Wayland](http://wayland.freedesktop.org/) display protocol. It was
278initially developed by Intel as
279[a fork of chromium](https://github.com/01org/ozone-wayland)
280and then partially upstreamed.
Maksim Sisov0c9db242019-11-22 06:20:35281
282Currently, the Ozone/Wayland is actively being developed by Igalia in
283the Chromium mainline repository with some features missing at the moment. The
284progress can be tracked in the [issue #578890](https://crbug.com/578890).
fwang8491a612016-10-31 20:59:45285
fwang15744c72016-11-08 13:58:33286Below are some quick build & run instructions. It is assumed that you are
fwang7af9db62017-01-09 14:52:22287launching `chrome` from a Wayland environment such as `weston`. Execute the
Maksim Sisov0c9db242019-11-22 06:20:35288following commands (make sure a system version of gbm and drm is used, which
289are required by Ozone/Wayland by design, when running on Linux platforms.):
fwang8491a612016-10-31 20:59:45290
Maksim Sisovfb1ab3d2021-11-08 06:34:40291Please note that the Wayland Ozone backend is built by default unless
292`ozone_auto_platforms=false` is set (the same as the X11 Ozone backend).
293
fwang8491a612016-10-31 20:59:45294``` shell
Maksim Sisovfb1ab3d2021-11-08 06:34:40295gn args out/OzoneWayland
fwang8491a612016-10-31 20:59:45296ninja -C out/OzoneWayland chrome
Maksim Sisov0a0b7482018-10-18 07:59:42297./out/OzoneWayland/chrome --ozone-platform=wayland
fwang8491a612016-10-31 20:59:45298```
299
Maksim Sisov0c9db242019-11-22 06:20:35300Native file dialogs are currently supported through the GTK toolkit. That
301implies that the browser is compiled with glib and gtk enabled. Please
302append the following gn args to your configuration:
303
304``` shell
305use_ozone=true
306use_system_minigbm=true
307use_system_libdrm=true
308use_xkbcommon=true
309use_glib=true
310use_gtk=true
311```
312
Orko Garaif682a9b2025-03-06 22:50:03313Running some test suites requires a Wayland server. If you're not running one
314you can use a locally compiled version of Weston or Mutter. This is what the
315build bots do. Please note that this is required for interactive_ui_tests, as
316those tests use a patched version of the compositor.
317
Orko Garai98c06a582025-03-11 19:52:46318Mutter and its dependencies are not checked out by default to keep the disk
319usage optimal for most developers. In order to checkout mutter, add the
320`checkout_mutter` custom var in your .gclient file and set it to `True` and run `gclient sync`.
321
322```
323solutions = [
324 {
325 "url": "https://chromium.googlesource.com/chromium/src.git",
326 "managed": False,
327 "name": "src",
328 "custom_deps": {},
329 "custom_vars": {
330 "checkout_mutter": True,
331 },
332 },
333]
334```
335
336For weston, simply add this to your gn args:
James Cooka6e9a7c2021-01-29 23:59:13337
338``` shell
339use_bundled_weston = true
340```
341
Orko Garaif682a9b2025-03-06 22:50:03342
Orko Garai98c06a582025-03-11 19:52:46343Then after building the test executable, run the xvfb.py wrapper script and tell
344it to start the compositor with the tests:
James Cooka6e9a7c2021-01-29 23:59:13345
346``` shell
347cd out/debug # or your out directory
Orko Garaif682a9b2025-03-06 22:50:03348```
349``` shell
350# For weston
Maksim Sisovfb1ab3d2021-11-08 06:34:40351../../testing/xvfb.py --use-weston --no-xvfb ./views_unittests --ozone-platform=wayland
James Cooka6e9a7c2021-01-29 23:59:13352```
Orko Garaif682a9b2025-03-06 22:50:03353``` shell
354# For mutter
355../../testing/xvfb.py --use-mutter --no-xvfb ./views_unittests --ozone-platform=wayland
356```
James Cooka6e9a7c2021-01-29 23:59:13357
Maksim Sisov0c9db242019-11-22 06:20:35358Feel free to discuss with us on freenode.net, `#ozone-wayland` channel or on
359`ozone-dev`, or on `#ozone-wayland-x11` channel in [chromium slack](https://www.chromium.org/developers/slack).
360
fwang8491a612016-10-31 20:59:45361### Caca
362
363This platform
364draws graphical output to text using
365[libcaca](http://caca.zoy.org/wiki/libcaca)
366(no GPU support; software
367rendering only). In case you ever wanted to test embedded content shell on
368tty.
369It has been
370[removed from the tree](https://codereview.chromium.org/2445323002/) and is no
fwang7fa6daf72016-11-03 16:07:04371longer maintained but you can
372[build it as an out-of-tree port](https://github.com/fred-wang/ozone-caca).
373
374Alternatively, you can try the latest revision known to work. First, install
375libcaca shared library and development files. Next, move to the git revision
376`0e64be9cf335ee3bea7c989702c5a9a0934af037`
377(you will probably need to synchronize the build dependencies with
378`gclient sync --with_branch_heads`). Finally, build and run the caca platform
379with the following commands:
fwang8491a612016-10-31 20:59:45380
381``` shell
fwang8491a612016-10-31 20:59:45382gn args out/OzoneCaca \
383 --args="use_ozone=true ozone_platform_caca=true use_sysroot=false ozone_auto_platforms=false toolkit_views=false"
384ninja -C out/OzoneCaca content_shell
fwang399b51c2016-11-10 09:48:27385./out/OzoneCaca/content_shell
fwang8491a612016-10-31 20:59:45386```
387
388 Note: traditional TTYs are not the ideal browsing experience.<br/>
fwang639002722016-11-08 12:33:04389 ![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:45390
Erik Chen96f83142022-06-15 20:43:25391### drm
392Ash-chrome client implementation.
393
Caroline Liuca634cb02023-08-29 16:19:07394### flatland
Erik Chen96f83142022-06-15 20:43:25395For fuchsia.
396
fwang8491a612016-10-31 20:59:45397## Communication
398
399There is a public mailing list:
400[[email protected]](https://groups.google.com/a/chromium.org/forum/#!forum/ozone-dev)