blob: 3c0546ea086fa04862896efa7c19ab42e5d31ac2 [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,
74 protecting this code behind the `USE_X11` ifdef, and adding a new `USE_OZONE`
75 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
fwang8491a612016-10-31 20:59:4594 `BitmapCursorFactoryOzone` implementation if only bitmap cursors need to be
95 supported.
96* Write a subclass of `OverlayManagerOzone` or just use `StubOverlayManager` if
97 your platform does not support overlays.
98* Write a subclass of `NativeDisplayDelegate` if necessary or just use
Maksim Sisov0a0b7482018-10-18 07:59:4299 `FakeDisplayDelegate`, and write a subclass of `PlatformScreen`, which is
100 used by aura::ScreenOzone then.
fwang8491a612016-10-31 20:59:45101* Write a subclass of `GpuPlatformSupportHost` or just use
102 `StubGpuPlatformSupportHost`.
103* Write a subclass of `InputController` or just use `StubInputController`.
104* Write a subclass of `SystemInputInjector` if necessary.
105* Write a subclass of `OzonePlatform` that owns instances of
106 the above subclasses and provide a static constructor function for these
107 objects. This constructor will be called when
108 your platform is selected and the returned objects will be used to provide
109 implementations of all the ozone platform interfaces.
110 If your platform does not need some of the interfaces then you can just
111 return a `Stub*` instance or a `nullptr`.
112
113## Adding an Ozone Platform to the build (instructions for out-of-tree ports)
114
115The recommended way to add your platform to the build is as follows. This walks
116through creating a new ozone platform called `foo`.
117
1181. Fork `chromium/src.git`.
1192. Add your implementation in `ui/ozone/platform/` alongside internal platforms.
1203. Patch `ui/ozone/ozone_extra.gni` to add your `foo` platform.
121
122## Building with Ozone
123
derat817105082017-02-22 17:57:55124### 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:45125
126To build `chrome`, do this from the `src` directory:
127
128``` shell
129gn args out/OzoneChromeOS --args="use_ozone=true target_os=\"chromeos\""
130ninja -C out/OzoneChromeOS chrome
131```
132
133Then to run for example the X11 platform:
134
135``` shell
fwang399b51c2016-11-10 09:48:27136./out/OzoneChromeOS/chrome --ozone-platform=x11
fwang8491a612016-10-31 20:59:45137```
138
139### Embedded
140
fwang7af9db62017-01-09 14:52:22141**Warning: Only some targets such as `content_shell` or unit tests are
142currently working for embedded builds.**
fwang8491a612016-10-31 20:59:45143
144To build `content_shell`, do this from the `src` directory:
145
146``` shell
147gn args out/OzoneEmbedded --args="use_ozone=true toolkit_views=false"
148ninja -C out/OzoneEmbedded content_shell
149```
150
151Then to run for example the headless platform:
152
153``` shell
fwang399b51c2016-11-10 09:48:27154./out/OzoneEmbedded/content_shell --ozone-platform=headless \
fwang8491a612016-10-31 20:59:45155 --ozone-dump-file=/tmp/
156```
157
Maksim Sisov69bc52c2020-09-30 06:30:38158### Linux Desktop - ([waterfall](https://ci.chromium.org/p/chromium/builders/try/linux-ozone-rel))
fwang8491a612016-10-31 20:59:45159
Maksim Sisov69bc52c2020-09-30 06:30:38160**Warning: Experimental Ozone feature is available in the official Chrome distributions since m87.
161 It is not required to build Ozone for Linux anymore for the purpose of testing. It is enough
162 to start Chrome with the following flags - ./chrome --enable-features=UseOzonePlatform
163 --ozone-platform={x11/wayland}.**
fwang15744c72016-11-08 13:58:33164
Maksim Sisov69bc52c2020-09-30 06:30:38165To build `chrome` with Ozone support, it is no longer required to pass any additional
166gn arguments. One can just follow the manual about how to build Chromium for Linux as both
167(Aura/X11) 'use\_x11=true' and (Linux/Ozone) 'use\_ozone=true' are set by default.
168
169If you want to disable Aura/X11 in the build, do this from the `src` directory:
fwang15744c72016-11-08 13:58:33170
171``` shell
Maksim Sisov69bc52c2020-09-30 06:30:38172gn args out/OzoneLinuxDesktop --args="use_x11=false"
fwang15744c72016-11-08 13:58:33173ninja -C out/OzoneLinuxDesktop chrome
174```
Maksim Sisov0a0b7482018-10-18 07:59:42175
Maksim Sisov69bc52c2020-09-30 06:30:38176Then to run for example the X11 platform (note that passing --enable-features=UseOzonePlatform
177is not required if Aura/X11 is disabled):
fwang15744c72016-11-08 13:58:33178
179``` shell
Scott Violet52134e2e2018-05-01 00:33:16180./out/OzoneLinuxDesktop/chrome --ozone-platform=x11
fwang15744c72016-11-08 13:58:33181```
182
Maksim Sisov0a0b7482018-10-18 07:59:42183Or run for example the Wayland platform:
184
185``` shell
Maksim Sisovc3642a62019-03-13 08:06:40186./out/OzoneLinuxDesktop/chrome --ozone-platform=wayland
Maksim Sisov0a0b7482018-10-18 07:59:42187```
188
Maksim Sisov69bc52c2020-09-30 06:30:38189If you want to disable Linux/Ozone in the build, do this from the `src` directory:
190
191``` shell
192gn args out/LinuxDesktop --args="use_ozone=false"
193ninja -C out/LinuxDesktop chrome
194```
195
fwang8491a612016-10-31 20:59:45196### GN Configuration notes
197
198You can turn properly implemented ozone platforms on and off by setting the
199corresponding flags in your GN configuration. For example
Peter McNeeley4ea922e2020-09-16 00:14:30200`ozone_platform_headless=false ozone_platform_drm=false` will turn off the
201headless and DRM (GBM) platforms.
fwang8491a612016-10-31 20:59:45202This will result in a smaller binary and faster builds. To turn ALL platforms
203off by default, set `ozone_auto_platforms=false`.
204
205You can also specify a default platform to run by setting the `ozone_platform`
206build parameter. For example `ozone_platform="x11"` will make X11 the
207default platform when `--ozone-platform` is not passed to the program.
208If `ozone_auto_platforms` is true then `ozone_platform` is set to `headless`
209by default.
210
211## Running with Ozone
212
213Specify the platform you want to use at runtime using the `--ozone-platform`
Peter McNeeley4ea922e2020-09-16 00:14:30214flag. For example, to run `content_shell` with the DRM (GBM) platform:
fwang8491a612016-10-31 20:59:45215
216``` shell
Peter McNeeley4ea922e2020-09-16 00:14:30217content_shell --ozone-platform=drm
fwang8491a612016-10-31 20:59:45218```
219
220Caveats:
221
222* `content_shell` always runs at 800x600 resolution.
Peter McNeeley4ea922e2020-09-16 00:14:30223* For the DRM (GBM) platform, you may need to terminate your X server (or any other
fwang8491a612016-10-31 20:59:45224 display server) prior to testing.
fwang399b51c2016-11-10 09:48:27225* During development, you may need to configure
Tom Anderson93e49e492019-12-23 19:55:37226 [sandboxing](linux/sandboxing.md) or to disable it.
fwang8491a612016-10-31 20:59:45227
228## Ozone Platforms
229
230### Headless
231
232This platform
233draws graphical output to a PNG image (no GPU support; software rendering only)
234and will not output to the screen. You can set
235the path of the directory where to output the images
236by specifying `--ozone-dump-file=/path/to/output-directory` on the
237command line:
238
239``` shell
fwang399b51c2016-11-10 09:48:27240content_shell --ozone-platform=headless \
fwang8491a612016-10-31 20:59:45241 --ozone-dump-file=/tmp/
242```
243
244### DRM/GBM
245
246This is Linux direct rending with acceleration via mesa GBM & linux DRM/KMS
247(EGL/GLES2 accelerated rendering & modesetting in GPU process) and is in
derat817105082017-02-22 17:57:55248production use on [Chrome OS](https://www.chromium.org/chromium-os).
fwang8491a612016-10-31 20:59:45249
derat817105082017-02-22 17:57:55250Note that all Chrome OS builds of Chrome will compile and attempt to use this.
fwang8491a612016-10-31 20:59:45251See [Building Chromium for Chromium OS](https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/building-chromium-browser) for build instructions.
252
253### Cast
254
255This platform is used for
256[Chromecast](https://www.google.com/intl/en_us/chromecast/).
257
258### X11
259
260This platform provides support for the [X window system](https://www.x.org/).
261
Maksim Sisov0c9db242019-11-22 06:20:35262The support for X11 is being actively developed by Igalia and the chromium
263community and is intended to replace the current legacy X11 path.
264
265You can try to compile and run it with the following configuration:
266
267``` shell
268gn args out/OzoneX11 --args="use_ozone=true"
269ninja -C out/OzoneX11 chrome
270./out/OzoneX11/chrome --ozone-platform=x11
271```
272
fwang8491a612016-10-31 20:59:45273### Wayland
274
275This platform provides support for the
276[Wayland](http://wayland.freedesktop.org/) display protocol. It was
277initially developed by Intel as
278[a fork of chromium](https://github.com/01org/ozone-wayland)
279and then partially upstreamed.
Maksim Sisov0c9db242019-11-22 06:20:35280
281Currently, the Ozone/Wayland is actively being developed by Igalia in
282the Chromium mainline repository with some features missing at the moment. The
283progress can be tracked in the [issue #578890](https://crbug.com/578890).
fwang8491a612016-10-31 20:59:45284
fwang15744c72016-11-08 13:58:33285Below are some quick build & run instructions. It is assumed that you are
fwang7af9db62017-01-09 14:52:22286launching `chrome` from a Wayland environment such as `weston`. Execute the
Maksim Sisov0c9db242019-11-22 06:20:35287following commands (make sure a system version of gbm and drm is used, which
288are required by Ozone/Wayland by design, when running on Linux platforms.):
fwang8491a612016-10-31 20:59:45289
290``` shell
Maksim Sisov0c9db242019-11-22 06:20:35291gn args out/OzoneWayland --args="use_ozone=true use_system_minigbm=true use_system_libdrm=true use_xkbcommon=true"
fwang8491a612016-10-31 20:59:45292ninja -C out/OzoneWayland chrome
Maksim Sisov0a0b7482018-10-18 07:59:42293./out/OzoneWayland/chrome --ozone-platform=wayland
fwang8491a612016-10-31 20:59:45294```
295
Maksim Sisov0c9db242019-11-22 06:20:35296Native file dialogs are currently supported through the GTK toolkit. That
297implies that the browser is compiled with glib and gtk enabled. Please
298append the following gn args to your configuration:
299
300``` shell
301use_ozone=true
302use_system_minigbm=true
303use_system_libdrm=true
304use_xkbcommon=true
305use_glib=true
306use_gtk=true
307```
308
309Feel free to discuss with us on freenode.net, `#ozone-wayland` channel or on
310`ozone-dev`, or on `#ozone-wayland-x11` channel in [chromium slack](https://www.chromium.org/developers/slack).
311
fwang8491a612016-10-31 20:59:45312### Caca
313
314This platform
315draws graphical output to text using
316[libcaca](http://caca.zoy.org/wiki/libcaca)
317(no GPU support; software
318rendering only). In case you ever wanted to test embedded content shell on
319tty.
320It has been
321[removed from the tree](https://codereview.chromium.org/2445323002/) and is no
fwang7fa6daf72016-11-03 16:07:04322longer maintained but you can
323[build it as an out-of-tree port](https://github.com/fred-wang/ozone-caca).
324
325Alternatively, you can try the latest revision known to work. First, install
326libcaca shared library and development files. Next, move to the git revision
327`0e64be9cf335ee3bea7c989702c5a9a0934af037`
328(you will probably need to synchronize the build dependencies with
329`gclient sync --with_branch_heads`). Finally, build and run the caca platform
330with the following commands:
fwang8491a612016-10-31 20:59:45331
332``` shell
fwang8491a612016-10-31 20:59:45333gn args out/OzoneCaca \
334 --args="use_ozone=true ozone_platform_caca=true use_sysroot=false ozone_auto_platforms=false toolkit_views=false"
335ninja -C out/OzoneCaca content_shell
fwang399b51c2016-11-10 09:48:27336./out/OzoneCaca/content_shell
fwang8491a612016-10-31 20:59:45337```
338
339 Note: traditional TTYs are not the ideal browsing experience.<br/>
fwang639002722016-11-08 12:33:04340 ![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:45341
342## Communication
343
344There is a public mailing list:
345[ozone-dev@chromium.org](https://groups.google.com/a/chromium.org/forum/#!forum/ozone-dev)
close