weston的源代码里面有关于client的绘画例子
建议追踪https://github.com/wayland-project/weston/blob/master/clients/
增加一种功能的操作例子shm.c[增加subsurface支持]
需要注意的是:
weston 本身来说并不支持surface去指定自己在屏幕上的位置。那如果我们希望固定surface的位置,我们需要绘画一个full-screen的主surface+subsurface,这样我们就一个固定subsurface的位置;
切记要用full-screen,而不是自己去确认屏幕的分辨率,不然多个不一样分辨率的情况,你无法确认主surface的大小。
另外一般来说你可以绘画一个透明的主surface,一般是在设置
ret = create_shm_buffer(window->display, buffer,
window->width, window->height,
- WL_SHM_FORMAT_XRGB8888);
+ WL_SHM_FORMAT_ARGB8888);
当然也可以调用gl-api去实现。
struct display {
struct wl_display *display;
struct wl_registry *registry;
struct wl_compositor *compositor;
#if 1
struct wl_subcompositor *subcompositor;
#endif
struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct wl_shm *shm;
bool has_xrgb;
struct ivi_application *ivi_application;
};
struct window {
struct display *display;
int width, height;
struct wl_surface *surface;
#if 1
struct wl_surface *main_surface;
struct wl_subsurface *subsurface;
struct wl_surface *main1_surface;
struct wl_subsurface *subsurface1;
#endif
struct zxdg_surface_v6 *xdg_surface;
struct zxdg_toplevel_v6 *xdg_toplevel;
struct ivi_surface *ivi_surface;
struct buffer buffers[4];
struct buffer *prev_buffer;
struct wl_callback *callback;
bool wait_for_configure;
};
static struct window *
create_window(struct display *display, int width, int height)
{
struct window *window;
#if 1
struct wl_subcompositor *subcompo = display->subcompositor;
#endif
window = zalloc(sizeof *window);
if (!window)
return NULL;
window->callback = NULL;
window->display = display;
window->width = width;
window->height = height;
window->surface = wl_compositor_create_surface(display->compositor);
#if 1
window->main_surface = wl_compositor_create_surface(display->compositor);
window->subsurface = wl_subcompositor_get_subsurface(subcompo, window->main_surface, window->surface)