mirror of
https://github.com/yshui/picom.git
synced 2025-04-07 17:44:04 -04:00
backend: refine the backend interface
Add some const qualifiers to backend arguments that shouldn't be modified. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
a4f183efca
commit
86ea2bbcf2
8 changed files with 22 additions and 21 deletions
|
@ -57,7 +57,7 @@ void handle_device_reset(session_t *ps) {
|
|||
/// @param target the image to render into
|
||||
/// @param root_image the image containing the desktop background
|
||||
bool backend_execute(struct backend_base *backend, image_handle target, unsigned ncmds,
|
||||
struct backend_command cmds[ncmds]) {
|
||||
const struct backend_command cmds[ncmds]) {
|
||||
bool succeeded = true;
|
||||
for (auto cmd = &cmds[0]; succeeded && cmd != &cmds[ncmds]; cmd++) {
|
||||
switch (cmd->op) {
|
||||
|
|
|
@ -95,7 +95,7 @@ struct backend_blur_args {
|
|||
void *blur_context;
|
||||
/// The source mask for the blur operation, may be NULL. Only parts of the source
|
||||
/// image covered by the mask should participate in the blur operation.
|
||||
struct backend_mask_image *source_mask;
|
||||
const struct backend_mask_image *source_mask;
|
||||
/// Region of the target image that will be covered by the blur operation, in the
|
||||
/// source image's coordinate.
|
||||
const region_t *target_mask;
|
||||
|
@ -111,7 +111,7 @@ struct backend_blit_args {
|
|||
/// Mask for the source image. may be NULL. Only contents covered by the mask
|
||||
/// should participate in the blit operation. This applies to the source image
|
||||
/// before it's scaled.
|
||||
struct backend_mask_image *source_mask;
|
||||
const struct backend_mask_image *source_mask;
|
||||
/// Mask for the target image. Only regions of the target image covered by this
|
||||
/// mask should be modified. This is the target's coordinate system.
|
||||
const region_t *target_mask;
|
||||
|
@ -267,7 +267,7 @@ struct backend_operations {
|
|||
/// @param args arguments for blit
|
||||
/// @return whether the operation is successful
|
||||
bool (*blit)(struct backend_base *backend_data, ivec2 origin, image_handle target,
|
||||
struct backend_blit_args *args) attr_nonnull(1, 3, 4);
|
||||
const struct backend_blit_args *args) attr_nonnull(1, 3, 4);
|
||||
|
||||
/// Blur a given region of a source image and store the result in the
|
||||
/// target image.
|
||||
|
@ -286,7 +286,7 @@ struct backend_operations {
|
|||
/// @param args argument for blur
|
||||
/// @return whether the operation is successful
|
||||
bool (*blur)(struct backend_base *backend_data, ivec2 origin, image_handle target,
|
||||
struct backend_blur_args *args) attr_nonnull(1, 3, 4);
|
||||
const struct backend_blur_args *args) attr_nonnull(1, 3, 4);
|
||||
|
||||
/// Direct copy of pixels from a source image on to the target image.
|
||||
/// This is a simpler version of `blit`, without any effects. Note unlike `blit`,
|
||||
|
@ -451,7 +451,7 @@ struct backend_operations {
|
|||
extern struct backend_operations *backend_list[];
|
||||
|
||||
bool backend_execute(struct backend_base *backend, image_handle target, unsigned ncmds,
|
||||
struct backend_command cmds[ncmds]);
|
||||
const struct backend_command cmds[ncmds]);
|
||||
void log_backend_command_(enum log_level level, const char *func,
|
||||
const struct backend_command *cmd);
|
||||
#define log_backend_command(level, cmd) \
|
||||
|
|
|
@ -72,7 +72,7 @@ static void dummy_check_image(struct backend_base *base, image_handle image) {
|
|||
}
|
||||
|
||||
bool dummy_blit(struct backend_base *base, ivec2 origin attr_unused, image_handle target,
|
||||
struct backend_blit_args *args) {
|
||||
const struct backend_blit_args *args) {
|
||||
dummy_check_image(base, target);
|
||||
dummy_check_image(base, args->source_image);
|
||||
if (args->source_mask) {
|
||||
|
@ -88,7 +88,7 @@ bool dummy_blit(struct backend_base *base, ivec2 origin attr_unused, image_handl
|
|||
}
|
||||
|
||||
bool dummy_blur(struct backend_base *base, ivec2 origin attr_unused, image_handle target,
|
||||
struct backend_blur_args *args) {
|
||||
const struct backend_blur_args *args) {
|
||||
dummy_check_image(base, target);
|
||||
dummy_check_image(base, args->source_image);
|
||||
if (args->source_mask) {
|
||||
|
|
|
@ -45,7 +45,7 @@ struct gl_blur_context {
|
|||
* Blur contents in a particular region.
|
||||
*/
|
||||
static bool gl_kernel_blur(double opacity, struct gl_blur_context *bctx,
|
||||
struct backend_mask_image *mask, const GLuint vao[2],
|
||||
const struct backend_mask_image *mask, const GLuint vao[2],
|
||||
const int vao_nelems[2], struct gl_texture *source,
|
||||
GLuint blur_sampler, GLuint target_fbo, GLuint default_mask) {
|
||||
int curr = 0;
|
||||
|
@ -147,7 +147,7 @@ static bool gl_kernel_blur(double opacity, struct gl_blur_context *bctx,
|
|||
/// [0]: for sampling from blurred result into the target fbo.
|
||||
/// [1]: for sampling from the source texture into blurred textures.
|
||||
bool gl_dual_kawase_blur(double opacity, struct gl_blur_context *bctx,
|
||||
struct backend_mask_image *mask, const GLuint vao[2],
|
||||
const struct backend_mask_image *mask, const GLuint vao[2],
|
||||
const int vao_nelems[2], struct gl_texture *source,
|
||||
GLuint blur_sampler, GLuint target_fbo, GLuint default_mask) {
|
||||
int iterations = bctx->blur_texture_count;
|
||||
|
@ -313,7 +313,7 @@ gl_blur_context_preallocate_textures(struct gl_blur_context *bctx, ivec2 source_
|
|||
}
|
||||
|
||||
bool gl_blur(struct backend_base *base, ivec2 origin, image_handle target_,
|
||||
struct backend_blur_args *args) {
|
||||
const struct backend_blur_args *args) {
|
||||
auto gd = (struct gl_data *)base;
|
||||
auto target = (struct gl_texture *)target_;
|
||||
auto source = (struct gl_texture *)args->source_image;
|
||||
|
|
|
@ -522,9 +522,10 @@ static inline void gl_y_flip_texture(int nrects, GLint *coord, GLint texture_hei
|
|||
|
||||
/// Lower `struct backend_blit_args` into a list of GL coordinates, vertex indices, a
|
||||
/// shader, and uniforms.
|
||||
static int gl_lower_blit_args(struct gl_data *gd, ivec2 origin, struct backend_blit_args *args,
|
||||
GLint **coord, GLuint **indices, struct gl_shader **shader,
|
||||
struct gl_uniform_value *uniforms) {
|
||||
static int
|
||||
gl_lower_blit_args(struct gl_data *gd, ivec2 origin, const struct backend_blit_args *args,
|
||||
GLint **coord, GLuint **indices, struct gl_shader **shader,
|
||||
struct gl_uniform_value *uniforms) {
|
||||
auto img = (struct gl_texture *)args->source_image;
|
||||
int nrects;
|
||||
const rect_t *rects;
|
||||
|
@ -602,7 +603,7 @@ static int gl_lower_blit_args(struct gl_data *gd, ivec2 origin, struct backend_b
|
|||
}
|
||||
|
||||
bool gl_blit(backend_t *base, ivec2 origin, image_handle target_,
|
||||
struct backend_blit_args *args) {
|
||||
const struct backend_blit_args *args) {
|
||||
auto gd = (struct gl_data *)base;
|
||||
auto source = (struct gl_texture *)args->source_image;
|
||||
auto target = (struct gl_texture *)target_;
|
||||
|
|
|
@ -145,7 +145,7 @@ uint64_t gl_get_shader_attributes(backend_t *backend_data, void *shader);
|
|||
bool gl_last_render_time(backend_t *backend_data, struct timespec *time);
|
||||
|
||||
bool gl_blit(backend_t *base, ivec2 origin, image_handle target,
|
||||
struct backend_blit_args *args);
|
||||
const struct backend_blit_args *args);
|
||||
image_handle gl_new_image(backend_t *backend_data attr_unused,
|
||||
enum backend_image_format format, ivec2 size);
|
||||
bool gl_clear(backend_t *backend_data, image_handle target, struct color color);
|
||||
|
@ -164,7 +164,7 @@ xcb_pixmap_t gl_release_image(backend_t *base, image_handle image);
|
|||
image_handle gl_clone(backend_t *base, image_handle image, const region_t *reg_visible);
|
||||
|
||||
bool gl_blur(struct backend_base *gd, ivec2 origin, image_handle target,
|
||||
struct backend_blur_args *args);
|
||||
const struct backend_blur_args *args);
|
||||
bool gl_copy_area(backend_t *backend_data, ivec2 origin, image_handle target,
|
||||
image_handle source, const region_t *region);
|
||||
bool gl_copy_area_quantize(backend_t *backend_data, ivec2 origin, image_handle target_handle,
|
||||
|
|
|
@ -267,7 +267,7 @@ xrender_process_mask(struct xrender_data *xd, const struct backend_mask_image *m
|
|||
}
|
||||
|
||||
static bool xrender_blit(struct backend_base *base, ivec2 origin,
|
||||
image_handle target_handle, struct backend_blit_args *args) {
|
||||
image_handle target_handle, const struct backend_blit_args *args) {
|
||||
auto xd = (struct xrender_data *)base;
|
||||
auto inner = (struct xrender_image_data_inner *)args->source_image;
|
||||
auto target = (struct xrender_image_data_inner *)target_handle;
|
||||
|
@ -475,7 +475,7 @@ xrender_copy_area(struct backend_base *base, ivec2 origin, image_handle target_h
|
|||
}
|
||||
|
||||
static bool xrender_blur(struct backend_base *base, ivec2 origin,
|
||||
image_handle target_handle, struct backend_blur_args *args) {
|
||||
image_handle target_handle, const struct backend_blur_args *args) {
|
||||
auto bctx = (struct xrender_blur_context *)args->blur_context;
|
||||
auto source_mask = args->source_image
|
||||
? (struct xrender_image_data_inner *)args->source_mask->image
|
||||
|
|
|
@ -430,7 +430,7 @@ static bool renderer_prepare_commands(struct renderer *r, struct backend_base *b
|
|||
!renderer_bind_mask(r, backend, w)) {
|
||||
return false;
|
||||
}
|
||||
cmd->blit.source_mask->image = w->mask_image;
|
||||
cmd->source_mask.image = w->mask_image;
|
||||
}
|
||||
break;
|
||||
case BACKEND_COMMAND_BLUR:
|
||||
|
@ -441,7 +441,7 @@ static bool renderer_prepare_commands(struct renderer *r, struct backend_base *b
|
|||
!renderer_bind_mask(r, backend, w)) {
|
||||
return false;
|
||||
}
|
||||
cmd->blur.source_mask->image = w->mask_image;
|
||||
cmd->source_mask.image = w->mask_image;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Add table
Reference in a new issue