以下例子均基于desktop-shell
weston_head::
Represents a head, usually a display connector
https://fossies.org/dox/weston-9.0.0/structweston__head__coll__graph_org.svg
struct weston_head {
struct weston_compositor *compositor; /**< owning compositor */
struct wl_list compositor_link; /**< in weston_compositor::head_list */
struct wl_signal destroy_signal; /**< destroy callbacks */
struct weston_output *output; /**< the output driving this head */
struct wl_list output_link; /**< in weston_output::head_list */
struct wl_list resource_list; /**< wl_output protocol objects */
struct wl_global *global; /**< wl_output global */
struct wl_list xdg_output_resource_list; /**< xdg_output protocol objects */
int32_t mm_width; /**< physical image width in mm */
int32_t mm_height; /**< physical image height in mm */
/** WL_OUTPUT_TRANSFORM enum to apply to match native orientation */
uint32_t transform;
char *make; /**< monitor manufacturer (PNP ID) */
char *model; /**< monitor model */
char *serial_number; /**< monitor serial */
uint32_t subpixel; /**< enum wl_output_subpixel */
bool connection_internal; /**< embedded monitor (e.g. laptop) */
bool device_changed; /**< monitor information has changed */
char *name; /**< head name, e.g. connector name */
bool connected; /**< is physically connected */
bool non_desktop; /**< non-desktop display, e.g. HMD */
/** Current content protection status */
enum weston_hdcp_protection current_protection;
};
weston_head的初始化时的创建过程:
weston_backend_init
drm_backend_create //drm-backend初始化的时候
drm_backend_discover_connectors
drm_backend_add_connector
drm_head_create
weston_head_init //初始化weston_head结构体
...
weston_head_set_internal(&head->base); //依据判断设置internal属性
weston_compositor_add_head //关联weston_compositor和weston_head
weston_compositor_schedule_heads_changed //主要时处理head change的消息机制::wet->heads_changed_listener.notify = drm_heads_changed;主要是drm_heads_changed函数的调用,注意也就是后面output的创建信号
weston_compositor_schedule_heads_changed //主要时处理head change的消息机制::wet->heads_changed_listener.notify = drm_heads_changed;主要是drm_heads_changed函数的调用,注意也就是后面output的创建信号
weston_output::
Content producer for heads
https://fossies.org/dox/weston-9.0.0/structweston__output__coll__graph_org.svg
struct weston_output {
uint32_t id;
char *name;
/** Matches the lifetime from the user perspective */
struct wl_signal user_destroy_signal;
void *renderer_state;
struct wl_list link;
struct weston_compositor *compositor;
/** From global to output buffer coordinates. */
struct weston_matrix matrix;
/** From output buffer to global coordinates. */
struct weston_matrix inverse_matrix;
struct wl_list animation_list;
int32_t x, y, width, height;
/** Output area in global coordinates, simple rect */
pixman_region32_t region;
/** True if damage has occurred since the last repaint for this output;
* if set, a repaint will eventually occur. */
bool repaint_needed;
/** Used only between repaint_begin and repaint_cancel. */
bool repainted;
/** State of the repaint loop */
enum {
REPAINT_NOT_SCHEDULED = 0, /**< idle; no repaint will occur */
REPAINT_BEGIN_FROM_IDLE, /**< start_repaint_loop scheduled */
REPAINT_SCHEDULED, /**< repaint is scheduled to occur */
REPAINT_AWAITING_COMPLETION, /**< last repaint not yet finished */
} repaint_status;
/** If repaint_status is REPAINT_SCHEDULED, contains the time the
* next repaint should be run */
struct timespec next_repaint;
/** For cancelling the idle_repaint callback on output destruction. */
struct wl_event_source *idle_repaint_source;
struct weston_output_zoom zoom;
int dirty;
struct wl_signal frame_signal;
struct wl_signal destroy_signal; /**< sent when disabled */
int move_x, move_y;
struct timespec frame_time; /* presentation timestamp */
uint64_t msc; /* media stream counter */
int disable_planes;
int destroying;
struct wl_list feedback_list;
uint32_t transform;
int32_t native_scale;
int32_t current_sc