[Wayland] (二) 代码结构 [FW]

 2023-09-05 阅读 81 评论 0

摘要:先贴一张Wayland SW Architecture Diagram, refer to:https://wayland.freedesktop.org/architecture.html The kernel gets an event and sends it to the compositor. This is similar to the X case, which is great, since we get to reuse all the input drivers in the

先贴一张Wayland SW Architecture Diagram, refer to: https://wayland.freedesktop.org/architecture.html

  1. The kernel gets an event and sends it to the compositor. This is similar to the X case, which is great, since we get to reuse all the input drivers in the kernel.
  2. The compositor looks through its scenegraph to determine which window should receive the event. The scenegraph corresponds to what's on screen and the compositor understands the transformations that it may have applied to the elements in the scenegraph. Thus, the compositor can pick the right window and transform the screen coordinates to window-local coordinates, by applying the inverse transformations. The types of transformation that can be applied to a window is only restricted to what the compositor can do, as long as it can compute the inverse transformation for the input events.
  3. As in the X case, when the client receives the event, it updates the UI in response. But in the wayland case, the rendering happens in the client, and the client just sends a request to the compositor to indicate the region that was updated.
  4. The compositor collects damage requests from its clients and then recomposites the screen. The compositor can then directly issue an ioctl to schedule a pageflip with KMS.

FW: http://www.cnblogs.com/cnland/archive/2013/01/15/2861319.html

获取、编译 Wayland 及其依赖库可参考 Wayland 官方网站的 Build 指南:http://wayland.freedesktop.org/building.html

Wayland 实现的代码组成可以分成以下四部分:

1.  Wayland 库

Wayland 中最核心的部分,Wayland 协议的大部分实现位于这里。

1)   工具程序(wayland-scanner)

分析 Wayland 协议文件,并生成相应的头文件及代码文件。

源码文件列表:

wayland/src/scanner.c

 

2)   工具库

供其他库、程序使用的工具函数、接口、结构等。

源码文件列表:

wayland/src/connection.c                           

wayland/src/wayland-util.c                         

wayland/src/wayland-util.h                         

wayland/src/wayland-os.c                           

wayland/src/wayland-os.h                           

wayland/src/wayland-private.h

 

3)   Client 库

供 Client 使用的桩接口(stub interfaces)及 event listener 结构定义。

源码文件列表:

wayland/src/wayland-protocol.c                     

wayland/src/wayland-client.c

 

4)   Server 库

Wayland 核心协议的实现。

源码文件列表:

wayland/src/wayland-protocol.c                     

wayland/src/wayland-server.c                       

wayland/src/wayland-shm.c                          

wayland/src/data-device.c                          

wayland/src/event-loop.c

 

5)   Cursor 库

Cursor 相关功能的实现。不作为重点分析部分。

源码文件列表:

wayland/cursor/wayland-cursor.h

wayland/cursor/wayland-cursor.c                       

wayland/cursor/os-compatibility.c                     

wayland/cursor/os-compatibility.h                     

wayland/cursor/xcursor.c                              

wayland/cursor/xcursor.h

 

6)   公用头文件

wayland/src/wayland-util.h

wayland/src/wayland-server-protocol.h

wayland/src/wayland-server.h  

wayland/src/wayland-client-protocol.h             

wayland/src/wayland-client.h         

wayland/src/wayland-version.h

wayland/src/wayland-egl.h

 

2.      EGL 相关实现

EGL surface 与 Waylandsurface 之间的互相转换,代码位于 mesa 中。

1)   libEGL 中的代码

mesa/src/egl/drivers/dri2/platform_wayland.c

mesa/src/egl/wayland/wayland-drm/wayland-drm.c

mesa/src/egl/wayland/wayland-drm/wayland-drm-protocol.c

mesa/src/egl/wayland/wayland-drm/wayland-drm-client-protocol.h

mesa/src/egl/wayland/wayland-drm/wayland-drm-server-protocol.h

 

2)   libwayland-egl

mesa/src/egl/wayland/wayland-egl/wayland-egl-priv.h

mesa/src/egl/wayland/wayland-egl/wayland-egl.c

 

3.      Weston (WaylandCompositor 的参考实现)

1)  Compositor

合成器的一个参考实现,代码较多,选取几个关键部分进行分析,如事件处理、图形输出等。

重点分析的源码列表:

weston/src/compositor.c

weston/src/compositor-drm.c

weston/src/evdev.c

 

2)  Shell (作为Compositor的插件实现)

可以认为是一个窗口管理器或桌面管理插件。

重点分析的源码列表:

weston/src/shell.c

 

3)  Clients

客户端程序,如 Terminal 等。不作为重点分析,仅在分析交互流程时,选取关键代码段进行分析。

 

4.      协议

一系列的 XML 文件,定义 Wayland的核心协议及扩展协议。

核心协议:

wayland/protocol/wayland.xml

mesa/src/egl/wayland/wayland-drm/wayland-drm.xml(很重要,可以认为是核心协议)

 

扩展协议(不作为重点分析对象):

weston/protocol/desktop-shell.xml

weston/protocol/tablet-shell.xml

 

另外还有一些单元测试代码,位于 wayland 和weston 的tests 目录,主要用来测试通用的 utility 函数,查看这些代码对理解 utility 函数的用途是很有帮助的。

转载于:https://www.cnblogs.com/bouygues/p/5687302.html

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/5/1049.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息