Marius Vlad | a72e371 | 2019-07-10 13:46:39 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2008-2011 Kristian Høgsberg |
| 3 | * Copyright © 2017, 2018 General Electric Company |
Pekka Paalanen | 1a4f87d | 2021-04-30 14:48:52 +0300 | [diff] [blame] | 4 | * Copyright © 2012, 2017-2019, 2021 Collabora, Ltd. |
Marius Vlad | a72e371 | 2019-07-10 13:46:39 +0300 | [diff] [blame] | 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining |
| 7 | * a copy of this software and associated documentation files (the |
| 8 | * "Software"), to deal in the Software without restriction, including |
| 9 | * without limitation the rights to use, copy, modify, merge, publish, |
| 10 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 11 | * permit persons to whom the Software is furnished to do so, subject to |
| 12 | * the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice (including the |
| 15 | * next paragraph) shall be included in all copies or substantial |
| 16 | * portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 22 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 23 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 25 | * SOFTWARE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef LIBWESTON_INTERNAL_H |
| 29 | #define LIBWESTON_INTERNAL_H |
| 30 | |
| 31 | /* |
| 32 | * This is the internal (private) part of libweston. All symbols found here |
| 33 | * are, and should be only (with a few exceptions) used within the internal |
| 34 | * parts of libweston. Notable exception(s) include a few files in tests/ that |
| 35 | * need access to these functions, screen-share file from compositor/ and those |
| 36 | * remoting/. Those will require some further fixing as to avoid including this |
| 37 | * private header. |
| 38 | * |
| 39 | * Eventually, these symbols should reside naturally into their own scope. New |
| 40 | * features should either provide their own (internal) header or use this one. |
| 41 | */ |
| 42 | |
Pekka Paalanen | 1a4f87d | 2021-04-30 14:48:52 +0300 | [diff] [blame] | 43 | #include <libweston/libweston.h> |
Pekka Paalanen | 90a5ffa | 2021-02-25 12:03:28 +0200 | [diff] [blame] | 44 | #include "color.h" |
Marius Vlad | a72e371 | 2019-07-10 13:46:39 +0300 | [diff] [blame] | 45 | |
| 46 | /* weston_buffer */ |
| 47 | |
| 48 | void |
| 49 | weston_buffer_send_server_error(struct weston_buffer *buffer, |
| 50 | const char *msg); |
| 51 | void |
| 52 | weston_buffer_reference(struct weston_buffer_reference *ref, |
| 53 | struct weston_buffer *buffer); |
| 54 | |
| 55 | void |
| 56 | weston_buffer_release_move(struct weston_buffer_release_reference *dest, |
| 57 | struct weston_buffer_release_reference *src); |
| 58 | |
| 59 | void |
| 60 | weston_buffer_release_reference(struct weston_buffer_release_reference *ref, |
| 61 | struct weston_buffer_release *buf_release); |
| 62 | |
Marius Vlad | 56f3a68 | 2019-07-10 14:48:39 +0300 | [diff] [blame] | 63 | /* weston_bindings */ |
| 64 | void |
Marius Vlad | 56f3a68 | 2019-07-10 14:48:39 +0300 | [diff] [blame] | 65 | weston_binding_list_destroy_all(struct wl_list *list); |
| 66 | |
| 67 | /* weston_compositor */ |
| 68 | |
| 69 | void |
| 70 | touch_calibrator_mode_changed(struct weston_compositor *compositor); |
| 71 | |
| 72 | int |
| 73 | noop_renderer_init(struct weston_compositor *ec); |
| 74 | |
| 75 | void |
| 76 | weston_compositor_add_head(struct weston_compositor *compositor, |
| 77 | struct weston_head *head); |
| 78 | void |
| 79 | weston_compositor_add_pending_output(struct weston_output *output, |
| 80 | struct weston_compositor *compositor); |
Marius Vlad | 56f3a68 | 2019-07-10 14:48:39 +0300 | [diff] [blame] | 81 | bool |
| 82 | weston_compositor_import_dmabuf(struct weston_compositor *compositor, |
| 83 | struct linux_dmabuf_buffer *buffer); |
Marius Vlad | 5a70154 | 2019-11-16 20:26:52 +0200 | [diff] [blame] | 84 | bool |
| 85 | weston_compositor_dmabuf_can_scanout(struct weston_compositor *compositor, |
| 86 | struct linux_dmabuf_buffer *buffer); |
Marius Vlad | 56f3a68 | 2019-07-10 14:48:39 +0300 | [diff] [blame] | 87 | void |
| 88 | weston_compositor_offscreen(struct weston_compositor *compositor); |
| 89 | |
| 90 | char * |
| 91 | weston_compositor_print_scene_graph(struct weston_compositor *ec); |
| 92 | |
| 93 | void |
| 94 | weston_compositor_read_presentation_clock( |
| 95 | const struct weston_compositor *compositor, |
| 96 | struct timespec *ts); |
| 97 | |
| 98 | int |
| 99 | weston_compositor_run_axis_binding(struct weston_compositor *compositor, |
| 100 | struct weston_pointer *pointer, |
| 101 | const struct timespec *time, |
| 102 | struct weston_pointer_axis_event *event); |
| 103 | void |
| 104 | weston_compositor_run_button_binding(struct weston_compositor *compositor, |
| 105 | struct weston_pointer *pointer, |
| 106 | const struct timespec *time, |
| 107 | uint32_t button, |
| 108 | enum wl_pointer_button_state value); |
| 109 | int |
| 110 | weston_compositor_run_debug_binding(struct weston_compositor *compositor, |
| 111 | struct weston_keyboard *keyboard, |
| 112 | const struct timespec *time, |
| 113 | uint32_t key, |
| 114 | enum wl_keyboard_key_state state); |
| 115 | void |
| 116 | weston_compositor_run_key_binding(struct weston_compositor *compositor, |
| 117 | struct weston_keyboard *keyboard, |
| 118 | const struct timespec *time, |
| 119 | uint32_t key, |
| 120 | enum wl_keyboard_key_state state); |
| 121 | void |
| 122 | weston_compositor_run_modifier_binding(struct weston_compositor *compositor, |
| 123 | struct weston_keyboard *keyboard, |
| 124 | enum weston_keyboard_modifier modifier, |
| 125 | enum wl_keyboard_key_state state); |
| 126 | void |
| 127 | weston_compositor_run_touch_binding(struct weston_compositor *compositor, |
| 128 | struct weston_touch *touch, |
| 129 | const struct timespec *time, |
| 130 | int touch_type); |
| 131 | void |
| 132 | weston_compositor_stack_plane(struct weston_compositor *ec, |
| 133 | struct weston_plane *plane, |
| 134 | struct weston_plane *above); |
| 135 | void |
| 136 | weston_compositor_set_touch_mode_normal(struct weston_compositor *compositor); |
| 137 | |
| 138 | void |
| 139 | weston_compositor_set_touch_mode_calib(struct weston_compositor *compositor); |
| 140 | |
| 141 | int |
| 142 | weston_compositor_set_presentation_clock(struct weston_compositor *compositor, |
| 143 | clockid_t clk_id); |
| 144 | int |
| 145 | weston_compositor_set_presentation_clock_software( |
| 146 | struct weston_compositor *compositor); |
| 147 | void |
| 148 | weston_compositor_shutdown(struct weston_compositor *ec); |
| 149 | |
| 150 | void |
| 151 | weston_compositor_xkb_destroy(struct weston_compositor *ec); |
| 152 | |
| 153 | int |
| 154 | weston_input_init(struct weston_compositor *compositor); |
| 155 | |
Ankit Nautiyal | 93dde24 | 2019-07-08 11:46:42 +0530 | [diff] [blame] | 156 | /* weston_output */ |
| 157 | |
leng.fang | 32af9fc | 2024-06-13 11:22:15 +0800 | [diff] [blame] | 158 | int |
| 159 | aml_config_setup(struct weston_compositor *ec); |
| 160 | |
limin.tian | ff78906 | 2024-08-14 02:24:40 +0000 | [diff] [blame] | 161 | int |
| 162 | aml_drm_config_setup(struct weston_compositor *ec); |
| 163 | |
Ankit Nautiyal | 93dde24 | 2019-07-08 11:46:42 +0530 | [diff] [blame] | 164 | void |
| 165 | weston_output_disable_planes_incr(struct weston_output *output); |
| 166 | |
| 167 | void |
| 168 | weston_output_disable_planes_decr(struct weston_output *output); |
| 169 | |
Marius Vlad | 58cac08 | 2019-07-10 16:29:05 +0300 | [diff] [blame] | 170 | /* weston_plane */ |
| 171 | |
| 172 | void |
| 173 | weston_plane_init(struct weston_plane *plane, |
| 174 | struct weston_compositor *ec, |
| 175 | int32_t x, int32_t y); |
| 176 | void |
| 177 | weston_plane_release(struct weston_plane *plane); |
Marius Vlad | 0bf3f5a | 2019-07-10 17:32:42 +0300 | [diff] [blame] | 178 | |
| 179 | /* weston_seat */ |
| 180 | |
| 181 | struct clipboard * |
| 182 | clipboard_create(struct weston_seat *seat); |
| 183 | |
| 184 | void |
| 185 | weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec, |
| 186 | const char *seat_name); |
| 187 | |
| 188 | void |
| 189 | weston_seat_repick(struct weston_seat *seat); |
| 190 | |
| 191 | void |
| 192 | weston_seat_release(struct weston_seat *seat); |
| 193 | |
| 194 | void |
| 195 | weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client); |
| 196 | |
Marius Vlad | eb34f82 | 2021-03-30 23:09:05 +0300 | [diff] [blame] | 197 | int |
Marius Vlad | 0bf3f5a | 2019-07-10 17:32:42 +0300 | [diff] [blame] | 198 | weston_seat_init_pointer(struct weston_seat *seat); |
| 199 | |
| 200 | int |
| 201 | weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap); |
| 202 | |
Marius Vlad | eb34f82 | 2021-03-30 23:09:05 +0300 | [diff] [blame] | 203 | int |
Marius Vlad | 0bf3f5a | 2019-07-10 17:32:42 +0300 | [diff] [blame] | 204 | weston_seat_init_touch(struct weston_seat *seat); |
| 205 | |
| 206 | void |
| 207 | weston_seat_release_keyboard(struct weston_seat *seat); |
| 208 | |
| 209 | void |
| 210 | weston_seat_release_pointer(struct weston_seat *seat); |
| 211 | |
| 212 | void |
| 213 | weston_seat_release_touch(struct weston_seat *seat); |
| 214 | |
| 215 | void |
| 216 | weston_seat_update_keymap(struct weston_seat *seat, struct xkb_keymap *keymap); |
| 217 | |
| 218 | void |
| 219 | wl_data_device_set_keyboard_focus(struct weston_seat *seat); |
| 220 | |
Marius Vlad | 9eb2064 | 2019-07-10 18:23:43 +0300 | [diff] [blame] | 221 | /* weston_pointer */ |
| 222 | |
| 223 | void |
| 224 | weston_pointer_clamp(struct weston_pointer *pointer, |
| 225 | wl_fixed_t *fx, wl_fixed_t *fy); |
| 226 | void |
| 227 | weston_pointer_set_default_grab(struct weston_pointer *pointer, |
| 228 | const struct weston_pointer_grab_interface *interface); |
| 229 | |
| 230 | void |
| 231 | weston_pointer_constraint_destroy(struct weston_pointer_constraint *constraint); |
| 232 | |
| 233 | /* weston_keyboard */ |
| 234 | bool |
| 235 | weston_keyboard_has_focus_resource(struct weston_keyboard *keyboard); |
| 236 | |
| 237 | /* weston_touch */ |
| 238 | |
| 239 | struct weston_touch_device * |
| 240 | weston_touch_create_touch_device(struct weston_touch *touch, |
| 241 | const char *syspath, |
| 242 | void *backend_data, |
| 243 | const struct weston_touch_device_ops *ops); |
| 244 | |
| 245 | void |
| 246 | weston_touch_device_destroy(struct weston_touch_device *device); |
| 247 | |
| 248 | bool |
| 249 | weston_touch_has_focus_resource(struct weston_touch *touch); |
| 250 | |
| 251 | int |
| 252 | weston_touch_start_drag(struct weston_touch *touch, |
| 253 | struct weston_data_source *source, |
| 254 | struct weston_surface *icon, |
| 255 | struct wl_client *client); |
| 256 | |
| 257 | |
| 258 | /* weston_touch_device */ |
| 259 | |
| 260 | bool |
| 261 | weston_touch_device_can_calibrate(struct weston_touch_device *device); |
| 262 | |
Marius Vlad | f1a6594 | 2019-07-10 20:42:45 +0300 | [diff] [blame] | 263 | /* weston_surface */ |
| 264 | void |
| 265 | weston_surface_to_buffer_float(struct weston_surface *surface, |
| 266 | float x, float y, float *bx, float *by); |
| 267 | pixman_box32_t |
| 268 | weston_surface_to_buffer_rect(struct weston_surface *surface, |
| 269 | pixman_box32_t rect); |
Marius Vlad | f1a6594 | 2019-07-10 20:42:45 +0300 | [diff] [blame] | 270 | void |
| 271 | weston_surface_to_buffer_region(struct weston_surface *surface, |
| 272 | pixman_region32_t *surface_region, |
| 273 | pixman_region32_t *buffer_region); |
| 274 | void |
| 275 | weston_surface_schedule_repaint(struct weston_surface *surface); |
Marius Vlad | 4e1d097 | 2019-07-10 20:56:04 +0300 | [diff] [blame] | 276 | |
| 277 | /* weston_spring */ |
| 278 | |
| 279 | void |
| 280 | weston_spring_init(struct weston_spring *spring, |
| 281 | double k, double current, double target); |
| 282 | int |
| 283 | weston_spring_done(struct weston_spring *spring); |
| 284 | |
| 285 | void |
| 286 | weston_spring_update(struct weston_spring *spring, const struct timespec *time); |
Marius Vlad | 7e4f58f | 2019-07-10 21:06:15 +0300 | [diff] [blame] | 287 | |
| 288 | /* weston_view */ |
| 289 | |
| 290 | void |
| 291 | weston_view_to_global_fixed(struct weston_view *view, |
| 292 | wl_fixed_t sx, wl_fixed_t sy, |
| 293 | wl_fixed_t *x, wl_fixed_t *y); |
| 294 | void |
| 295 | weston_view_from_global_float(struct weston_view *view, |
| 296 | float x, float y, float *vx, float *vy); |
| 297 | bool |
| 298 | weston_view_is_opaque(struct weston_view *ev, pixman_region32_t *region); |
| 299 | |
Marius Vlad | 5f6bee4 | 2019-09-11 16:41:04 +0300 | [diff] [blame] | 300 | bool |
| 301 | weston_view_has_valid_buffer(struct weston_view *ev); |
| 302 | |
Marius Vlad | 47e3d1e | 2019-09-11 16:53:08 +0300 | [diff] [blame] | 303 | bool |
| 304 | weston_view_matches_output_entirely(struct weston_view *ev, |
| 305 | struct weston_output *output); |
Marius Vlad | 7e4f58f | 2019-07-10 21:06:15 +0300 | [diff] [blame] | 306 | void |
| 307 | weston_view_move_to_plane(struct weston_view *view, |
| 308 | struct weston_plane *plane); |
| 309 | |
Marius Vlad | 3ff296e | 2019-07-10 21:27:49 +0300 | [diff] [blame] | 310 | void |
| 311 | weston_transformed_coord(int width, int height, |
| 312 | enum wl_output_transform transform, |
| 313 | int32_t scale, |
| 314 | float sx, float sy, float *bx, float *by); |
| 315 | pixman_box32_t |
| 316 | weston_transformed_rect(int width, int height, |
| 317 | enum wl_output_transform transform, |
| 318 | int32_t scale, |
| 319 | pixman_box32_t rect); |
| 320 | void |
| 321 | weston_transformed_region(int width, int height, |
| 322 | enum wl_output_transform transform, |
| 323 | int32_t scale, |
| 324 | pixman_region32_t *src, pixman_region32_t *dest); |
| 325 | void |
| 326 | weston_matrix_transform_region(pixman_region32_t *dest, |
| 327 | struct weston_matrix *matrix, |
| 328 | pixman_region32_t *src); |
| 329 | |
Marius Vlad | a9b69b4 | 2019-07-10 21:31:20 +0300 | [diff] [blame] | 330 | /* protected_surface */ |
| 331 | void |
| 332 | weston_protected_surface_send_event(struct protected_surface *psurface, |
| 333 | enum weston_hdcp_protection protection); |
| 334 | |
Leandro Ribeiro | 78f0192 | 2020-12-01 16:39:47 -0300 | [diff] [blame] | 335 | /* weston_drm_format */ |
| 336 | |
| 337 | struct weston_drm_format { |
| 338 | uint32_t format; |
| 339 | struct wl_array modifiers; |
| 340 | }; |
| 341 | |
| 342 | struct weston_drm_format_array { |
| 343 | struct wl_array arr; |
| 344 | }; |
| 345 | |
Leandro Ribeiro | 78f0192 | 2020-12-01 16:39:47 -0300 | [diff] [blame] | 346 | void |
| 347 | weston_drm_format_array_init(struct weston_drm_format_array *formats); |
| 348 | |
| 349 | void |
Leandro Ribeiro | 78f0192 | 2020-12-01 16:39:47 -0300 | [diff] [blame] | 350 | weston_drm_format_array_fini(struct weston_drm_format_array *formats); |
| 351 | |
| 352 | int |
| 353 | weston_drm_format_array_replace(struct weston_drm_format_array *formats, |
| 354 | const struct weston_drm_format_array *source_formats); |
| 355 | |
| 356 | struct weston_drm_format * |
| 357 | weston_drm_format_array_add_format(struct weston_drm_format_array *formats, |
| 358 | uint32_t format); |
| 359 | |
| 360 | void |
| 361 | weston_drm_format_array_remove_latest_format(struct weston_drm_format_array *formats); |
| 362 | |
| 363 | struct weston_drm_format * |
| 364 | weston_drm_format_array_find_format(const struct weston_drm_format_array *formats, |
| 365 | uint32_t format); |
| 366 | |
Leandro Ribeiro | 60c7fee | 2021-10-06 12:05:40 -0300 | [diff] [blame] | 367 | unsigned int |
| 368 | weston_drm_format_array_count_pairs(const struct weston_drm_format_array *formats); |
| 369 | |
Leandro Ribeiro | 78f0192 | 2020-12-01 16:39:47 -0300 | [diff] [blame] | 370 | bool |
| 371 | weston_drm_format_array_equal(const struct weston_drm_format_array *formats_A, |
| 372 | const struct weston_drm_format_array *formats_B); |
| 373 | |
| 374 | int |
| 375 | weston_drm_format_array_join(struct weston_drm_format_array *formats_A, |
| 376 | const struct weston_drm_format_array *formats_B); |
| 377 | |
Leandro Ribeiro | c51d4ad | 2021-08-30 12:52:26 -0300 | [diff] [blame] | 378 | int |
| 379 | weston_drm_format_array_intersect(struct weston_drm_format_array *formats_A, |
Leandro Ribeiro | 78f0192 | 2020-12-01 16:39:47 -0300 | [diff] [blame] | 380 | const struct weston_drm_format_array *formats_B); |
| 381 | |
| 382 | int |
| 383 | weston_drm_format_array_subtract(struct weston_drm_format_array *formats_A, |
| 384 | const struct weston_drm_format_array *formats_B); |
| 385 | |
| 386 | int |
| 387 | weston_drm_format_add_modifier(struct weston_drm_format *format, |
| 388 | uint64_t modifier); |
| 389 | |
| 390 | bool |
| 391 | weston_drm_format_has_modifier(const struct weston_drm_format *format, |
| 392 | uint64_t modifier); |
| 393 | |
| 394 | const uint64_t * |
| 395 | weston_drm_format_get_modifiers(const struct weston_drm_format *format, |
| 396 | unsigned int *count_out); |
| 397 | |
Pekka Paalanen | 1a4f87d | 2021-04-30 14:48:52 +0300 | [diff] [blame] | 398 | /** |
| 399 | * paint node |
| 400 | * |
| 401 | * A generic data structure unique for surface-view-output combination. |
| 402 | */ |
| 403 | struct weston_paint_node { |
Pekka Paalanen | 2fddc53 | 2021-04-30 17:41:29 +0300 | [diff] [blame] | 404 | /* Immutable members: */ |
| 405 | |
Pekka Paalanen | 1a4f87d | 2021-04-30 14:48:52 +0300 | [diff] [blame] | 406 | /* struct weston_surface::paint_node_list */ |
| 407 | struct wl_list surface_link; |
| 408 | struct weston_surface *surface; |
| 409 | |
| 410 | /* struct weston_view::paint_node_list */ |
| 411 | struct wl_list view_link; |
| 412 | struct weston_view *view; |
| 413 | |
| 414 | /* struct weston_output::paint_node_list */ |
| 415 | struct wl_list output_link; |
| 416 | struct weston_output *output; |
Pekka Paalanen | 2fddc53 | 2021-04-30 17:41:29 +0300 | [diff] [blame] | 417 | |
| 418 | /* Mutable members: */ |
| 419 | |
| 420 | /* struct weston_output::paint_node_z_order_list */ |
| 421 | struct wl_list z_order_link; |
Pekka Paalanen | 90a5ffa | 2021-02-25 12:03:28 +0200 | [diff] [blame] | 422 | |
| 423 | struct weston_surface_color_transform surf_xform; |
| 424 | bool surf_xform_valid; |
Leandro Ribeiro | 0a7034c | 2021-09-13 14:52:53 -0300 | [diff] [blame] | 425 | |
| 426 | uint32_t try_view_on_plane_failure_reasons; |
Pekka Paalanen | 1a4f87d | 2021-04-30 14:48:52 +0300 | [diff] [blame] | 427 | }; |
| 428 | |
| 429 | struct weston_paint_node * |
| 430 | weston_view_find_paint_node(struct weston_view *view, |
| 431 | struct weston_output *output); |
| 432 | |
Marius Vlad | 0260fed | 2019-07-11 14:54:46 +0300 | [diff] [blame] | 433 | /* others */ |
| 434 | int |
| 435 | wl_data_device_manager_init(struct wl_display *display); |
| 436 | |
Marius Vlad | a72e371 | 2019-07-10 13:46:39 +0300 | [diff] [blame] | 437 | #endif |