From 21dfe207940837809cccd119462469e07d604676 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Mon, 14 Jun 2021 01:51:09 +0100 Subject: [PATCH] backend: rename copy -> clone_image This feels more appropriate as this operation doesn't necessarily copy data. Signed-off-by: Yuxuan Shui --- .clang-tidy | 2 +- src/backend/backend.c | 4 ++-- src/backend/backend.h | 8 +++++--- src/backend/dummy/dummy.c | 6 +++--- src/backend/gl/gl_common.c | 4 ++-- src/backend/gl/gl_common.h | 2 +- src/backend/gl/glx.c | 2 +- src/backend/xrender/xrender.c | 4 ++-- 8 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 59e7273..7b59c22 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -18,4 +18,4 @@ CheckOptions: - key: readability-magic-numbers.IgnoredIntegerValues value: 4;8;16;24;32;1;2;3;4096;65536; - key: readability-magic-numbers.IgnoredFloatingPointValues - value: 255.0; + value: 255.0;1.0; diff --git a/src/backend/backend.c b/src/backend/backend.c index 4ff3f60..0e1fe09 100644 --- a/src/backend/backend.c +++ b/src/backend/backend.c @@ -306,7 +306,7 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) { ps->backend_data, w->shadow_image, w->g.x + w->shadow_dx, w->g.y + w->shadow_dy, ®_shadow, ®_visible); } else { - auto new_img = ps->backend_data->ops->copy( + auto new_img = ps->backend_data->ops->clone_image( ps->backend_data, w->shadow_image, ®_visible); ps->backend_data->ops->image_op( ps->backend_data, IMAGE_OP_APPLY_ALPHA_ALL, new_img, @@ -360,7 +360,7 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) { pixman_region32_intersect(®_visible_local, ®_visible_local, ®_bound_local); - auto new_img = ps->backend_data->ops->copy( + auto new_img = ps->backend_data->ops->clone_image( ps->backend_data, w->win_image, ®_visible_local); if (w->invert_color) { ps->backend_data->ops->image_op( diff --git a/src/backend/backend.h b/src/backend/backend.h index 48c9334..5f04113 100644 --- a/src/backend/backend.h +++ b/src/backend/backend.h @@ -232,9 +232,11 @@ struct backend_operations { bool (*read_pixel)(backend_t *backend_data, void *image_data, int x, int y, struct color *output); - /// Create another instance of the `image_data`. All `image_op` calls on the - /// returned image should not affect the original image - void *(*copy)(backend_t *base, const void *image_data, const region_t *reg_visible); + /// Create another instance of the `image_data`. All `image_op` and + /// `image_set_property` calls on the returned image should not affect the + /// original image + void *(*clone_image)(backend_t *base, const void *image_data, + const region_t *reg_visible); /// Create a blur context that can be used to call `blur` void *(*create_blur_context)(backend_t *base, enum blur_method, void *args); diff --git a/src/backend/dummy/dummy.c b/src/backend/dummy/dummy.c index 4b24f9f..e00d359 100644 --- a/src/backend/dummy/dummy.c +++ b/src/backend/dummy/dummy.c @@ -121,8 +121,8 @@ bool dummy_image_op(struct backend_base *base, enum image_operations op attr_unu return true; } -void *dummy_image_copy(struct backend_base *base, const void *image, - const region_t *reg_visible attr_unused) { +void *dummy_clone_image(struct backend_base *base, const void *image, + const region_t *reg_visible attr_unused) { auto img = (const struct dummy_image *)image; dummy_check_image(base, img); (*img->refcount)++; @@ -159,7 +159,7 @@ struct backend_operations dummy_ops = { .max_buffer_age = 5, .image_op = dummy_image_op, - .copy = dummy_image_copy, + .clone_image = dummy_clone_image, .create_blur_context = dummy_create_blur_context, .destroy_blur_context = dummy_destroy_blur_context, .get_blur_size = dummy_get_blur_size, diff --git a/src/backend/gl/gl_common.c b/src/backend/gl/gl_common.c index 28f31a2..9ecfb5d 100644 --- a/src/backend/gl/gl_common.c +++ b/src/backend/gl/gl_common.c @@ -1087,8 +1087,8 @@ void gl_release_image(backend_t *base, void *image_data) { gl_check_err(); } -void *gl_copy(backend_t *base attr_unused, const void *image_data, - const region_t *reg_visible attr_unused) { +void *gl_clone(backend_t *base attr_unused, const void *image_data, + const region_t *reg_visible attr_unused) { const struct gl_image *img = image_data; auto new_img = ccalloc(1, struct gl_image); *new_img = *img; diff --git a/src/backend/gl/gl_common.h b/src/backend/gl/gl_common.h index ca51c0b..709dc29 100644 --- a/src/backend/gl/gl_common.h +++ b/src/backend/gl/gl_common.h @@ -115,7 +115,7 @@ bool gl_image_op(backend_t *base, enum image_operations op, void *image_data, void gl_release_image(backend_t *base, void *image_data); -void *gl_copy(backend_t *base, const void *image_data, const region_t *reg_visible); +void *gl_clone(backend_t *base, const void *image_data, const region_t *reg_visible); bool gl_blur(backend_t *base, double opacity, void *, const region_t *reg_blur, const region_t *reg_visible); diff --git a/src/backend/gl/glx.c b/src/backend/gl/glx.c index 214bfbc..be6183c 100644 --- a/src/backend/gl/glx.c +++ b/src/backend/gl/glx.c @@ -527,7 +527,7 @@ struct backend_operations glx_ops = { .compose = gl_compose, .image_op = gl_image_op, .read_pixel = gl_read_pixel, - .copy = gl_copy, + .clone_image = gl_clone, .blur = gl_blur, .is_image_transparent = gl_is_image_transparent, .present = glx_present, diff --git a/src/backend/xrender/xrender.c b/src/backend/xrender/xrender.c index 56d31de..e60c8de 100644 --- a/src/backend/xrender/xrender.c +++ b/src/backend/xrender/xrender.c @@ -466,7 +466,7 @@ static bool image_op(backend_t *base, enum image_operations op, void *image, } // TODO(yshui): use copy-on-write -static void *copy(backend_t *base, const void *image, const region_t *reg) { +static void *clone_image(backend_t *base, const void *image, const region_t *reg) { const struct _xrender_image_data *img = image; struct _xrender_data *xd = (void *)base; auto new_img = ccalloc(1, struct _xrender_image_data); @@ -679,7 +679,7 @@ struct backend_operations xrender_ops = { .image_op = image_op, .read_pixel = read_pixel, - .copy = copy, + .clone_image = clone_image, .create_blur_context = create_blur_context, .destroy_blur_context = destroy_blur_context, .get_blur_size = get_blur_size,