LoginSignup
29
23

More than 5 years have passed since last update.

Wayland の Client と Compositor の概念を理解する

Last updated at Posted at 2016-07-04

Wayland とは

一言で言えば「X11 に変わる次の Window System」でしょうか。

Wikipedia より引用します。

背景
Waylandのプロジェクトは、レッドハットの開発者Kristian Høgsbergが「全てのフレームがパーフェクトであること — 言いたいのは、画面の乱れや遅れや再描画やちらつきを二度と見ずに済むくらいにアプリケーションが描画を十分にコントロールできるようになること」を目標として開始した。
Waylandの開発にはX.orgの開発者が多数参加している。

Wayland アプリを

https://wayland.freedesktop.org/architecture.html
に習い、まずは Wayland より先に存在した X11 の Achitecture 図から見てみます。

X11 Achitecture

https://wayland.freedesktop.org/x-architecture.png

簡単にイベント開始から描画までの流れを書くと、
①:kernel からイベントが来たら、
②:X server がどの X Client (アプリ)にイベントを渡すか決め、イベントを渡し、
③:X Client はイベントに応じた処理を行い、その結果の描画更新要求を X server に行い、
④:X server は描画更新要求を受け取ると、 Compositor に渡し、
⑤:Compositor が(各アプリの描画内容や、各ウインドウの重なりを踏まえ)画面全体の描画更新を行い、
⑥:X server は Compositor から描画バッファをコピーし、 kernel に渡す

というわけで、つまりは X server が中央にいて、複雑かつ処理が冗長なのが
X11 の問題点でした。

Wayland Achitecture

wayland-architecture.png
https://wayland.freedesktop.org/x-architecture.png

対して Wayland では、
①:kernel がイベントを Wayland Compositor に渡し、(ここは X11 と似ている)
②:Wayland Compositor がイベント送付先 Wayland Client を賢く判断し
③:Wayland Client は描画更新要求を Compositor に行い、(ここも X11 と似ている)
④:Wayland Compositor は Wayland Client から描画要求を受け取ったら画面を Composite (合成)し、ダイレクトに Kernel に描画要求

します。シンプルですね。

サンプルソース

実際に動かしてみます。

https://github.com/eyelash/tutorials/blob/master/wayland-egl.c
こちらの方のソースを引用します。
Wayland と EGL を使用している、かつソースが短くて良いですね。

ビルドと実行

環境は ubuntu です。

$ gcc -o wayland-egl wayland-egl.c -lwayland-client -lwayland-egl -lEGL -lGL
$ weston  // Weston Compositor がインストール済であること
$ wayland-egl

Screenshotfrom2016-04-22090443.png

参考

Wayland https://wayland.freedesktop.org/
Waylandプログラミング入門 http://d.hatena.ne.jp/devm33/20140422/1398182440

29
23
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
29
23