Debian Codegraph @

src/backend/backend.h

raw symbols SCIP
1 // SPDX-License-Identifier: MPL-2.0
2 // Copyright (c) 2018, Yuxuan Shui <[email protected]>
3
4 #pragma once
5
6 #include <stdbool.h>
7
8 #include <picom/backend.h>
9
10 #include "log.h"
11
12 enum backend_command_op {
13 BACKEND_COMMAND_INVALID = -1,
14 BACKEND_COMMAND_BLIT,
15 BACKEND_COMMAND_BLUR,
16 BACKEND_COMMAND_COPY_AREA,
17 };
18
19 /// Symbolic references used as render command source images. The actual `image_handle`
20 /// will later be filled in by the renderer using this symbolic reference.
21 enum backend_command_source {
22 BACKEND_COMMAND_SOURCE_IMAGE,
23 BACKEND_COMMAND_SOURCE_WINDOW,
24 BACKEND_COMMAND_SOURCE_WINDOW_SAVED,
25 BACKEND_COMMAND_SOURCE_SHADOW,
26 BACKEND_COMMAND_SOURCE_CLEAR,
27 };
28
29 // TODO(yshui) might need better names
30
31 struct backend_command {
32 enum backend_command_op op;
33 ivec2 origin;
34 enum backend_command_source source;
35 union {
36 struct {
37 struct backend_blit_args blit;
38 /// Region of the screen that will be covered by this blit
39 /// operations, in screen coordinates.
40 region_t opaque_region;
41 };
42 struct {
43 image_handle source_image;
44 const region_t *region;
45 } copy_area;
46 struct backend_blur_args blur;
47 };
48 /// Source mask for the operation.
49 /// This may be used for the `source_mask` field of `op` by the command builder.
50 /// `image` of `source_mask` is usually left empty by the command builder, and
51 /// the renderer will fill it in appropriately later.
52 struct backend_mask_image source_mask;
53 /// Target mask for the operation.
54 region_t target_mask;
55 /// Extra information attached to the shader used in this command.
56 const struct shader_info *shader_info;
57 };
58
59 bool backend_execute(struct backend_base *backend, image_handle target, unsigned ncmds,
60 const struct backend_command cmds[ncmds]);
61
62 struct backend_info *backend_find(const char *name);
63 struct backend_base *
64 backend_init(struct backend_info *info, session_t *ps, xcb_window_t target);
65 struct backend_info *backend_iter(void);
66 struct backend_info *backend_iter_next(struct backend_info *info);
67 const char *backend_name(struct backend_info *info);
68 bool backend_can_present(struct backend_info *info);
69 void log_backend_command_(enum log_level level, const char *func,
70 const struct backend_command *cmd);
71 #define log_backend_command(level, cmd) \
72 log_backend_command_(LOG_LEVEL_##level, __func__, &(cmd));
73
74 /// Define a backend entry point. (Note constructor priority 202 is used here because 1xx
75 /// is reversed by test.h, and 201 is used for logging initialization.)
76 #define BACKEND_ENTRYPOINT(func) static void __attribute__((constructor(202))) func(void)