backend: rename copy -> clone_image

This feels more appropriate as this operation doesn't necessarily copy
data.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2021-06-14 01:51:09 +01:00
parent d9c9742132
commit 21dfe20794
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
8 changed files with 17 additions and 15 deletions

View File

@ -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;

View File

@ -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, &reg_shadow, &reg_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, &reg_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(&reg_visible_local, &reg_visible_local,
&reg_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, &reg_visible_local);
if (w->invert_color) {
ps->backend_data->ops->image_op(

View File

@ -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);

View File

@ -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,

View File

@ -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;

View File

@ -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);

View File

@ -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,

View File

@ -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,