From d91e260f2738c765f72e9e990bfecf1baa76a70f Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Fri, 10 May 2024 02:57:44 +0100 Subject: [PATCH] backend: merge v2 backend ops back into backend_operations Signed-off-by: Yuxuan Shui --- src/backend/backend.c | 10 +-- src/backend/backend.h | 126 ++++++++++++++++------------------ src/backend/dummy/dummy.c | 30 ++++---- src/backend/gl/egl.c | 32 ++++----- src/backend/gl/glx.c | 32 ++++----- src/backend/xrender/xrender.c | 32 ++++----- src/picom.c | 11 ++- src/renderer/renderer.c | 111 +++++++++++++++--------------- src/win.c | 9 ++- 9 files changed, 189 insertions(+), 204 deletions(-) diff --git a/src/backend/backend.c b/src/backend/backend.c index e59e280d41..4e0068c1b7 100644 --- a/src/backend/backend.c +++ b/src/backend/backend.c @@ -66,22 +66,22 @@ bool backend_execute(struct backend_base *backend, image_handle target, unsigned continue; } succeeded = - backend->ops->v2.blit(backend, cmd->origin, target, &cmd->blit); + backend->ops->blit(backend, cmd->origin, target, &cmd->blit); break; case BACKEND_COMMAND_COPY_AREA: if (!pixman_region32_not_empty(cmd->copy_area.region)) { continue; } - succeeded = backend->ops->v2.copy_area(backend, cmd->origin, target, - cmd->copy_area.source_image, - cmd->copy_area.region); + succeeded = backend->ops->copy_area(backend, cmd->origin, target, + cmd->copy_area.source_image, + cmd->copy_area.region); break; case BACKEND_COMMAND_BLUR: if (!pixman_region32_not_empty(&cmd->blur.mask->region)) { continue; } succeeded = - backend->ops->v2.blur(backend, cmd->origin, target, &cmd->blur); + backend->ops->blur(backend, cmd->origin, target, &cmd->blur); break; case BACKEND_COMMAND_INVALID: default: assert(false); diff --git a/src/backend/backend.h b/src/backend/backend.h index a44e4920c6..05cc258a1c 100644 --- a/src/backend/backend.h +++ b/src/backend/backend.h @@ -202,18 +202,37 @@ enum backend_quirk { BACKEND_QUIRK_SLOW_BLUR = 1 << 0, }; -struct backend_ops_v2 { - /// Get backend quirks - /// @return a bitmask of `enum backend_quirk`. - uint32_t (*quirks)(struct backend_base *backend_data) attr_nonnull(1); +struct backend_operations { + // =========== Initialization =========== - /// Check if an optional image format is supported by the backend. - bool (*is_format_supported)(struct backend_base *backend_data, - enum backend_image_format format) attr_nonnull(1); + /// Initialize the backend, prepare for rendering to the target window. + backend_t *(*init)(session_t *, xcb_window_t)attr_nonnull(1); + void (*deinit)(backend_t *backend_data) attr_nonnull(1); - /// Return the capabilities of an image. - uint32_t (*image_capabilities)(struct backend_base *backend_data, image_handle image) - attr_nonnull(1, 2); + /// Called when rendering will be stopped for an unknown amount of + /// time (e.g. when screen is unredirected). Free some resources. + /// + /// Optional, not yet used + void (*pause)(backend_t *backend_data, session_t *ps); + + /// Called before rendering is resumed + /// + /// Optional, not yet used + void (*resume)(backend_t *backend_data, session_t *ps); + + /// Called when root window size changed. All existing image data ever + /// returned by this backend should remain valid after this call + /// returns. + /// + /// Optional + void (*root_change)(backend_t *backend_data, session_t *ps); + + // =========== Rendering ============ + + /// Called before when a new frame starts. + /// + /// Optional + void (*prepare)(backend_t *backend_data, const region_t *reg_damage); /// Multiply the alpha channel of the target image by a given value. /// @@ -315,6 +334,23 @@ struct backend_ops_v2 { bool (*clear)(struct backend_base *backend_data, image_handle target, struct color color) attr_nonnull(1, 2); + /// Present the back buffer to the target window. Ideally the backend should keep + /// track of the region of the back buffer that has been updated, and use relevant + /// mechanism (when possible) to present only the updated region. + bool (*present)(struct backend_base *backend_data) attr_nonnull(1); + + // ============ Resource management =========== + + /// Create a shader object from a shader source. + /// + /// Optional + void *(*create_shader)(backend_t *backend_data, const char *source)attr_nonnull(1, 2); + + /// Free a shader object. + /// + /// Required if create_shader is present. + void (*destroy_shader)(backend_t *backend_data, void *shader) attr_nonnull(1, 2); + /// Create a new, uninitialized image with the given format and size. /// /// @param backend_data backend data @@ -324,11 +360,6 @@ struct backend_ops_v2 { enum backend_image_format format, geometry_t size) attr_nonnull(1); - /// Acquire the image handle of the back buffer. - /// - /// @param backend_data backend data - image_handle (*back_buffer)(struct backend_base *backend_data); - /// Bind a X pixmap to the backend's internal image data structure. /// /// @param backend_data backend data @@ -339,6 +370,11 @@ struct backend_ops_v2 { image_handle (*bind_pixmap)(struct backend_base *backend_data, xcb_pixmap_t pixmap, struct xvisual_info fmt) attr_nonnull(1); + /// Acquire the image handle of the back buffer. + /// + /// @param backend_data backend data + image_handle (*back_buffer)(struct backend_base *backend_data); + /// Free resources associated with an image data structure. Releasing the image /// returned by `back_buffer` should be a no-op. /// @@ -348,59 +384,19 @@ struct backend_ops_v2 { xcb_pixmap_t (*release_image)(struct backend_base *backend_data, image_handle image) attr_nonnull(1, 2); - /// Present the back buffer to the target window. Ideally the backend should keep - /// track of the region of the back buffer that has been updated, and use relevant - /// mechanism (when possible) to present only the updated region. - bool (*present)(struct backend_base *backend_data) attr_nonnull(1); -}; - -struct backend_operations { - // =========== V2 =========== - struct backend_ops_v2 v2; - // =========== Initialization =========== - - /// Initialize the backend, prepare for rendering to the target window. - backend_t *(*init)(session_t *, xcb_window_t)attr_nonnull(1); - void (*deinit)(backend_t *backend_data) attr_nonnull(1); - - /// Called when rendering will be stopped for an unknown amount of - /// time (e.g. when screen is unredirected). Free some resources. - /// - /// Optional, not yet used - void (*pause)(backend_t *backend_data, session_t *ps); - - /// Called before rendering is resumed - /// - /// Optional, not yet used - void (*resume)(backend_t *backend_data, session_t *ps); - - /// Called when root window size changed. All existing image data ever - /// returned by this backend should remain valid after this call - /// returns. - /// - /// Optional - void (*root_change)(backend_t *backend_data, session_t *ps); - - // =========== Rendering ============ - - /// Called before when a new frame starts. - /// - /// Optional - void (*prepare)(backend_t *backend_data, const region_t *reg_damage); - - // ============ Resource management =========== + // =========== Query =========== - /// Create a shader object from a shader source. - /// - /// Optional - void *(*create_shader)(backend_t *backend_data, const char *source)attr_nonnull(1, 2); + /// Get backend quirks + /// @return a bitmask of `enum backend_quirk`. + uint32_t (*quirks)(struct backend_base *backend_data) attr_nonnull(1); - /// Free a shader object. - /// - /// Required if create_shader is present. - void (*destroy_shader)(backend_t *backend_data, void *shader) attr_nonnull(1, 2); + /// Check if an optional image format is supported by the backend. + bool (*is_format_supported)(struct backend_base *backend_data, + enum backend_image_format format) attr_nonnull(1); - // =========== Query =========== + /// Return the capabilities of an image. + uint32_t (*image_capabilities)(struct backend_base *backend_data, image_handle image) + attr_nonnull(1, 2); /// Get the attributes of a shader. /// diff --git a/src/backend/dummy/dummy.c b/src/backend/dummy/dummy.c index 33433666d7..06bb33be47 100644 --- a/src/backend/dummy/dummy.c +++ b/src/backend/dummy/dummy.c @@ -205,22 +205,20 @@ bool dummy_is_format_supported(struct backend_base *base attr_unused, } struct backend_operations dummy_ops = { - .v2 = - { - .apply_alpha = dummy_apply_alpha, - .back_buffer = dummy_back_buffer, - .blit = dummy_blit, - .blur = dummy_blur, - .clear = dummy_clear, - .copy_area = dummy_copy_area, - .copy_area_quantize = dummy_copy_area, - .image_capabilities = dummy_image_capabilities, - .is_format_supported = dummy_is_format_supported, - .new_image = dummy_new_image, - .bind_pixmap = dummy_bind_pixmap, - .quirks = backend_no_quirks, - .release_image = dummy_release_image, - }, + .apply_alpha = dummy_apply_alpha, + .back_buffer = dummy_back_buffer, + .blit = dummy_blit, + .blur = dummy_blur, + .clear = dummy_clear, + .copy_area = dummy_copy_area, + .copy_area_quantize = dummy_copy_area, + .image_capabilities = dummy_image_capabilities, + .is_format_supported = dummy_is_format_supported, + .new_image = dummy_new_image, + .bind_pixmap = dummy_bind_pixmap, + .quirks = backend_no_quirks, + .release_image = dummy_release_image, + .init = dummy_init, .deinit = dummy_deinit, .buffer_age = dummy_buffer_age, diff --git a/src/backend/gl/egl.c b/src/backend/gl/egl.c index 4de618dcb2..8ff0754648 100644 --- a/src/backend/gl/egl.c +++ b/src/backend/gl/egl.c @@ -339,23 +339,21 @@ static void egl_diagnostics(backend_t *base) { } struct backend_operations egl_ops = { - .v2 = - { - .apply_alpha = gl_apply_alpha, - .back_buffer = gl_back_buffer, - .blit = gl_blit, - .blur = gl_blur, - .bind_pixmap = egl_bind_pixmap, - .clear = gl_clear, - .copy_area = gl_copy_area, - .copy_area_quantize = gl_copy_area_quantize, - .is_format_supported = gl_is_format_supported, - .image_capabilities = gl_image_capabilities, - .new_image = gl_new_image, - .present = egl_present, - .quirks = backend_no_quirks, - .release_image = gl_release_image, - }, + .apply_alpha = gl_apply_alpha, + .back_buffer = gl_back_buffer, + .blit = gl_blit, + .blur = gl_blur, + .bind_pixmap = egl_bind_pixmap, + .clear = gl_clear, + .copy_area = gl_copy_area, + .copy_area_quantize = gl_copy_area_quantize, + .is_format_supported = gl_is_format_supported, + .image_capabilities = gl_image_capabilities, + .new_image = gl_new_image, + .present = egl_present, + .quirks = backend_no_quirks, + .release_image = gl_release_image, + .init = egl_init, .deinit = egl_deinit, .root_change = gl_root_change, diff --git a/src/backend/gl/glx.c b/src/backend/gl/glx.c index e919fe2f4a..feaccfcf6d 100644 --- a/src/backend/gl/glx.c +++ b/src/backend/gl/glx.c @@ -518,23 +518,21 @@ static void glx_diagnostics(backend_t *base) { } struct backend_operations glx_ops = { - .v2 = - { - .apply_alpha = gl_apply_alpha, - .back_buffer = gl_back_buffer, - .bind_pixmap = glx_bind_pixmap, - .blit = gl_blit, - .blur = gl_blur, - .clear = gl_clear, - .copy_area = gl_copy_area, - .copy_area_quantize = gl_copy_area_quantize, - .image_capabilities = gl_image_capabilities, - .is_format_supported = gl_is_format_supported, - .new_image = gl_new_image, - .present = glx_present, - .quirks = backend_no_quirks, - .release_image = gl_release_image, - }, + .apply_alpha = gl_apply_alpha, + .back_buffer = gl_back_buffer, + .bind_pixmap = glx_bind_pixmap, + .blit = gl_blit, + .blur = gl_blur, + .clear = gl_clear, + .copy_area = gl_copy_area, + .copy_area_quantize = gl_copy_area_quantize, + .image_capabilities = gl_image_capabilities, + .is_format_supported = gl_is_format_supported, + .new_image = gl_new_image, + .present = glx_present, + .quirks = backend_no_quirks, + .release_image = gl_release_image, + .init = glx_init, .deinit = glx_deinit, .root_change = gl_root_change, diff --git a/src/backend/xrender/xrender.c b/src/backend/xrender/xrender.c index d7ddd59e45..1e685de4bc 100644 --- a/src/backend/xrender/xrender.c +++ b/src/backend/xrender/xrender.c @@ -1001,23 +1001,21 @@ uint32_t xrender_quirks(struct backend_base *base) { } struct backend_operations xrender_ops = { - .v2 = - { - .apply_alpha = xrender_apply_alpha, - .back_buffer = xrender_back_buffer, - .bind_pixmap = xrender_bind_pixmap, - .blit = xrender_blit, - .blur = xrender_blur, - .clear = xrender_clear, - .copy_area = xrender_copy_area, - .copy_area_quantize = xrender_copy_area, - .image_capabilities = xrender_image_capabilities, - .is_format_supported = xrender_is_format_supported, - .new_image = xrender_new_image, - .present = xrender_present, - .quirks = xrender_quirks, - .release_image = xrender_release_image, - }, + .apply_alpha = xrender_apply_alpha, + .back_buffer = xrender_back_buffer, + .bind_pixmap = xrender_bind_pixmap, + .blit = xrender_blit, + .blur = xrender_blur, + .clear = xrender_clear, + .copy_area = xrender_copy_area, + .copy_area_quantize = xrender_copy_area, + .image_capabilities = xrender_image_capabilities, + .is_format_supported = xrender_is_format_supported, + .new_image = xrender_new_image, + .present = xrender_present, + .quirks = xrender_quirks, + .release_image = xrender_release_image, + .init = xrender_init, .deinit = xrender_deinit, // TODO(yshui) make blur faster so we can use `backend_render_shadow_from_mask` for diff --git a/src/picom.c b/src/picom.c index a79b0a1e5c..d3e0a2be4a 100644 --- a/src/picom.c +++ b/src/picom.c @@ -639,7 +639,7 @@ static void destroy_backend(session_t *ps) { } if (ps->backend_data && ps->root_image) { - ps->backend_data->ops->v2.release_image(ps->backend_data, ps->root_image); + ps->backend_data->ops->release_image(ps->backend_data, ps->root_image); ps->root_image = NULL; } @@ -1152,8 +1152,7 @@ void root_damaged(session_t *ps) { if (ps->backend_data) { if (ps->root_image) { - ps->backend_data->ops->v2.release_image(ps->backend_data, - ps->root_image); + ps->backend_data->ops->release_image(ps->backend_data, ps->root_image); ps->root_image = NULL; } auto pixmap = x_get_root_back_pixmap(&ps->c, ps->atoms); @@ -1187,7 +1186,7 @@ void root_damaged(session_t *ps) { : x_get_visual_for_depth(ps->c.screen_info, r->depth); free(r); - ps->root_image = ps->backend_data->ops->v2.bind_pixmap( + ps->root_image = ps->backend_data->ops->bind_pixmap( ps->backend_data, pixmap, x_get_visual_info(&ps->c, visual)); ps->root_image_generation += 1; if (!ps->root_image) { @@ -1452,7 +1451,7 @@ uint8_t session_redirection_mode(session_t *ps) { assert(!ps->o.legacy_backends); return XCB_COMPOSITE_REDIRECT_AUTOMATIC; } - if (!ps->o.legacy_backends && !backend_list[ps->o.backend]->v2.present) { + if (!ps->o.legacy_backends && !backend_list[ps->o.backend]->present) { // if the backend doesn't render anything, we don't need to take over the // screen. return XCB_COMPOSITE_REDIRECT_AUTOMATIC; @@ -2409,7 +2408,7 @@ static session_t *session_init(int argc, char **argv, Display *dpy, log_info("The compositor is started in automatic redirection mode."); assert(!ps->o.legacy_backends); - if (backend_list[ps->o.backend]->v2.present) { + if (backend_list[ps->o.backend]->present) { // If the backend has `present`, we couldn't be in automatic // redirection mode unless we are in debug mode. assert(ps->o.debug_mode); diff --git a/src/renderer/renderer.c b/src/renderer/renderer.c index d461d0404a..877cb9c6d5 100644 --- a/src/renderer/renderer.c +++ b/src/renderer/renderer.c @@ -42,16 +42,16 @@ struct renderer { void renderer_free(struct backend_base *backend, struct renderer *r) { if (r->white_image) { - backend->ops->v2.release_image(backend, r->white_image); + backend->ops->release_image(backend, r->white_image); } if (r->black_image) { - backend->ops->v2.release_image(backend, r->black_image); + backend->ops->release_image(backend, r->black_image); } if (r->back_image) { - backend->ops->v2.release_image(backend, r->back_image); + backend->ops->release_image(backend, r->back_image); } if (r->monitor_repaint_pixel) { - backend->ops->v2.release_image(backend, r->monitor_repaint_pixel); + backend->ops->release_image(backend, r->monitor_repaint_pixel); } if (r->shadow_blur_context) { backend->ops->destroy_blur_context(backend, r->shadow_blur_context); @@ -70,7 +70,7 @@ void renderer_free(struct backend_base *backend, struct renderer *r) { } if (r->monitor_repaint_copy) { for (int i = 0; i < r->max_buffer_age; i++) { - backend->ops->v2.release_image(backend, r->monitor_repaint_copy[i]); + backend->ops->release_image(backend, r->monitor_repaint_copy[i]); } free(r->monitor_repaint_copy); } @@ -81,21 +81,21 @@ static bool renderer_init(struct renderer *renderer, struct backend_base *backend, double shadow_radius, struct color shadow_color, bool dithered_present) { auto has_high_precision = - backend->ops->v2.is_format_supported(backend, BACKEND_IMAGE_FORMAT_PIXMAP_HIGH); + backend->ops->is_format_supported(backend, BACKEND_IMAGE_FORMAT_PIXMAP_HIGH); renderer->format = has_high_precision && dithered_present ? BACKEND_IMAGE_FORMAT_PIXMAP_HIGH : BACKEND_IMAGE_FORMAT_PIXMAP; renderer->back_image = NULL; renderer->white_image = - backend->ops->v2.new_image(backend, renderer->format, (struct geometry){1, 1}); - if (!renderer->white_image || !backend->ops->v2.clear(backend, renderer->white_image, - (struct color){1, 1, 1, 1})) { + backend->ops->new_image(backend, renderer->format, (struct geometry){1, 1}); + if (!renderer->white_image || !backend->ops->clear(backend, renderer->white_image, + (struct color){1, 1, 1, 1})) { return false; } renderer->black_image = - backend->ops->v2.new_image(backend, renderer->format, (struct geometry){1, 1}); - if (!renderer->black_image || !backend->ops->v2.clear(backend, renderer->black_image, - (struct color){0, 0, 0, 1})) { + backend->ops->new_image(backend, renderer->format, (struct geometry){1, 1}); + if (!renderer->black_image || !backend->ops->clear(backend, renderer->black_image, + (struct color){0, 0, 0, 1})) { return false; } renderer->canvas_size = (struct geometry){0, 0}; @@ -148,9 +148,9 @@ static inline bool renderer_set_root_size(struct renderer *r, struct backend_bas return true; } if (r->back_image) { - backend->ops->v2.release_image(backend, r->back_image); + backend->ops->release_image(backend, r->back_image); } - r->back_image = backend->ops->v2.new_image(backend, r->format, root_size); + r->back_image = backend->ops->new_image(backend, r->format, root_size); if (r->back_image != NULL) { r->canvas_size = root_size; return true; @@ -158,7 +158,7 @@ static inline bool renderer_set_root_size(struct renderer *r, struct backend_bas r->canvas_size = (struct geometry){0, 0}; if (r->monitor_repaint_copy) { for (int i = 0; i < r->max_buffer_age; i++) { - backend->ops->v2.release_image(backend, r->monitor_repaint_copy[i]); + backend->ops->release_image(backend, r->monitor_repaint_copy[i]); } free(r->monitor_repaint_copy); r->monitor_repaint_copy = NULL; @@ -170,17 +170,16 @@ static bool renderer_bind_mask(struct renderer *r, struct backend_base *backend, struct managed_win *w) { struct geometry size = {.width = w->widthb, .height = w->heightb}; bool succeeded = false; - auto image = backend->ops->v2.new_image(backend, BACKEND_IMAGE_FORMAT_MASK, size); - if (!image || !backend->ops->v2.clear(backend, image, (struct color){0, 0, 0, 0})) { + auto image = backend->ops->new_image(backend, BACKEND_IMAGE_FORMAT_MASK, size); + if (!image || !backend->ops->clear(backend, image, (struct color){0, 0, 0, 0})) { log_error("Failed to create mask image"); goto err; } auto bound_region_local = win_get_bounding_shape_global_by_val(w); pixman_region32_translate(&bound_region_local, -w->g.x, -w->g.y); - succeeded = - backend->ops->v2.copy_area(backend, (struct coord){0, 0}, (image_handle)image, - r->white_image, &bound_region_local); + succeeded = backend->ops->copy_area(backend, (struct coord){0, 0}, (image_handle)image, + r->white_image, &bound_region_local); pixman_region32_fini(&bound_region_local); if (!succeeded) { log_error("Failed to fill the mask"); @@ -191,7 +190,7 @@ renderer_bind_mask(struct renderer *r, struct backend_base *backend, struct mana err: if (image != NULL) { - backend->ops->v2.release_image(backend, image); + backend->ops->release_image(backend, image); } return succeeded; } @@ -210,11 +209,11 @@ renderer_shadow_from_mask(struct renderer *r, struct backend_base *backend, // Apply the properties on the mask image and blit the result into a larger // image, each side larger by `2 * radius` so there is space for blurring. - normalized_mask_image = backend->ops->v2.new_image( + normalized_mask_image = backend->ops->new_image( backend, BACKEND_IMAGE_FORMAT_MASK, (struct geometry){mask_size.width + 2 * radius, mask_size.height + 2 * radius}); - if (!normalized_mask_image || !backend->ops->v2.clear(backend, normalized_mask_image, - (struct color){0, 0, 0, 0})) { + if (!normalized_mask_image || !backend->ops->clear(backend, normalized_mask_image, + (struct color){0, 0, 0, 0})) { log_error("Failed to create mask image"); goto out; } @@ -240,8 +239,8 @@ renderer_shadow_from_mask(struct renderer *r, struct backend_base *backend, .border_width = 0, .max_brightness = 1, }; - succeeded = backend->ops->v2.blit(backend, (struct coord){radius, radius}, - normalized_mask_image, &args); + succeeded = backend->ops->blit(backend, (struct coord){radius, radius}, + normalized_mask_image, &args); pixman_region32_fini(&mask_args.region); if (!succeeded) { log_error("Failed to blit for shadow generation"); @@ -265,8 +264,8 @@ renderer_shadow_from_mask(struct renderer *r, struct backend_base *backend, .mask = &mask_args, .blur_context = r->shadow_blur_context, }; - succeeded = backend->ops->v2.blur(backend, (struct coord){0, 0}, - normalized_mask_image, &args); + succeeded = backend->ops->blur(backend, (struct coord){0, 0}, + normalized_mask_image, &args); pixman_region32_fini(&mask_args.region); if (!succeeded) { log_error("Failed to blur for shadow generation"); @@ -275,19 +274,19 @@ renderer_shadow_from_mask(struct renderer *r, struct backend_base *backend, } // Finally, we blit with this mask to colorize the shadow succeeded = false; - shadow_image = backend->ops->v2.new_image( + shadow_image = backend->ops->new_image( backend, BACKEND_IMAGE_FORMAT_PIXMAP, (struct geometry){mask_size.width + 2 * radius, mask_size.height + 2 * radius}); if (!shadow_image || - !backend->ops->v2.clear(backend, shadow_image, (struct color){0, 0, 0, 0})) { + !backend->ops->clear(backend, shadow_image, (struct color){0, 0, 0, 0})) { log_error("Failed to allocate shadow image"); goto out; } - shadow_color_pixel = backend->ops->v2.new_image( - backend, BACKEND_IMAGE_FORMAT_PIXMAP, (struct geometry){1, 1}); + shadow_color_pixel = backend->ops->new_image(backend, BACKEND_IMAGE_FORMAT_PIXMAP, + (struct geometry){1, 1}); if (!shadow_color_pixel || - !backend->ops->v2.clear(backend, shadow_color_pixel, r->shadow_color)) { + !backend->ops->clear(backend, shadow_color_pixel, r->shadow_color)) { log_error("Failed to create shadow color image"); goto out; } @@ -314,19 +313,19 @@ renderer_shadow_from_mask(struct renderer *r, struct backend_base *backend, .border_width = 0, .max_brightness = 1, }; - succeeded = backend->ops->v2.blit(backend, (struct coord){0, 0}, shadow_image, &args); + succeeded = backend->ops->blit(backend, (struct coord){0, 0}, shadow_image, &args); pixman_region32_fini(&mask_args.region); out: if (normalized_mask_image) { - backend->ops->v2.release_image(backend, normalized_mask_image); + backend->ops->release_image(backend, normalized_mask_image); } if (shadow_color_pixel) { - backend->ops->v2.release_image(backend, shadow_color_pixel); + backend->ops->release_image(backend, shadow_color_pixel); } if (!succeeded && shadow_image) { log_error("Failed to draw shadow image"); - backend->ops->v2.release_image(backend, shadow_image); + backend->ops->release_image(backend, shadow_image); shadow_image = NULL; } return shadow_image; @@ -334,7 +333,7 @@ renderer_shadow_from_mask(struct renderer *r, struct backend_base *backend, static bool renderer_bind_shadow(struct renderer *r, struct backend_base *backend, struct managed_win *w) { - if (backend->ops->v2.quirks(backend) & BACKEND_QUIRK_SLOW_BLUR) { + if (backend->ops->quirks(backend) & BACKEND_QUIRK_SLOW_BLUR) { xcb_pixmap_t shadow = XCB_NONE; xcb_render_picture_t pict = XCB_NONE; @@ -345,7 +344,7 @@ static bool renderer_bind_shadow(struct renderer *r, struct backend_base *backen auto visual = x_get_visual_for_standard(backend->c, XCB_PICT_STANDARD_ARGB_32); - w->shadow_image = backend->ops->v2.bind_pixmap( + w->shadow_image = backend->ops->bind_pixmap( backend, shadow, x_get_visual_info(backend->c, visual)); } else { if (!w->mask_image && !renderer_bind_mask(r, backend, w)) { @@ -423,16 +422,16 @@ static bool renderer_prepare_commands(struct renderer *r, struct backend_base *b void renderer_ensure_monitor_repaint_ready(struct renderer *r, struct backend_base *backend) { if (!r->monitor_repaint_pixel) { - r->monitor_repaint_pixel = backend->ops->v2.new_image( + r->monitor_repaint_pixel = backend->ops->new_image( backend, BACKEND_IMAGE_FORMAT_PIXMAP, (struct geometry){1, 1}); BUG_ON(!r->monitor_repaint_pixel); - backend->ops->v2.clear(backend, r->monitor_repaint_pixel, - (struct color){.alpha = 0.5, .red = 0.5}); + backend->ops->clear(backend, r->monitor_repaint_pixel, + (struct color){.alpha = 0.5, .red = 0.5}); } if (!r->monitor_repaint_copy) { r->monitor_repaint_copy = ccalloc(r->max_buffer_age, image_handle); for (int i = 0; i < r->max_buffer_age; i++) { - r->monitor_repaint_copy[i] = backend->ops->v2.new_image( + r->monitor_repaint_copy[i] = backend->ops->new_image( backend, BACKEND_IMAGE_FORMAT_PIXMAP, (struct geometry){.width = r->canvas_size.width, .height = r->canvas_size.height}); @@ -541,10 +540,10 @@ bool renderer_render(struct renderer *r, struct backend_base *backend, // Restore the area of back buffer that was tainted by monitor repaint int past_frame = (r->frame_index + r->max_buffer_age - buffer_age) % r->max_buffer_age; - backend->ops->v2.copy_area(backend, (struct coord){}, - backend->ops->v2.back_buffer(backend), - r->monitor_repaint_copy[past_frame], - &r->monitor_repaint_region[past_frame]); + backend->ops->copy_area(backend, (struct coord){}, + backend->ops->back_buffer(backend), + r->monitor_repaint_copy[past_frame], + &r->monitor_repaint_region[past_frame]); } if (!backend_execute(backend, r->back_image, layout->number_of_commands, @@ -555,9 +554,9 @@ bool renderer_render(struct renderer *r, struct backend_base *backend, if (monitor_repaint) { // Keep a copy of un-tainted back image - backend->ops->v2.copy_area(backend, (struct coord){}, - r->monitor_repaint_copy[r->frame_index], - r->back_image, &damage_region); + backend->ops->copy_area(backend, (struct coord){}, + r->monitor_repaint_copy[r->frame_index], + r->back_image, &damage_region); pixman_region32_copy(&r->monitor_repaint_region[r->frame_index], &damage_region); struct backend_mask mask = {.region = damage_region}; @@ -570,14 +569,14 @@ bool renderer_render(struct renderer *r, struct backend_base *backend, .mask = &mask, }; log_trace("Blit for monitor repaint"); - backend->ops->v2.blit(backend, (struct coord){}, r->back_image, &blit); + backend->ops->blit(backend, (struct coord){}, r->back_image, &blit); } - if (backend->ops->v2.present) { - backend->ops->v2.copy_area_quantize(backend, (struct coord){}, - backend->ops->v2.back_buffer(backend), - r->back_image, &damage_region); - backend->ops->v2.present(backend); + if (backend->ops->present) { + backend->ops->copy_area_quantize(backend, (struct coord){}, + backend->ops->back_buffer(backend), + r->back_image, &damage_region); + backend->ops->present(backend); } // "Un-cull" the render commands, so later damage calculation using those commands diff --git a/src/win.c b/src/win.c index a6ffc3b535..575188401d 100644 --- a/src/win.c +++ b/src/win.c @@ -335,7 +335,7 @@ static inline void win_release_pixmap(backend_t *base, struct managed_win *w) { assert(w->win_image); if (w->win_image) { xcb_pixmap_t pixmap = XCB_NONE; - pixmap = base->ops->v2.release_image(base, w->win_image); + pixmap = base->ops->release_image(base, w->win_image); w->win_image = NULL; // Bypassing win_set_flags, because `w` might have been destroyed w->flags |= WIN_FLAGS_PIXMAP_NONE; @@ -349,7 +349,7 @@ static inline void win_release_shadow(backend_t *base, struct managed_win *w) { if (w->shadow_image) { assert(w->shadow); xcb_pixmap_t pixmap = XCB_NONE; - pixmap = base->ops->v2.release_image(base, w->shadow_image); + pixmap = base->ops->release_image(base, w->shadow_image); w->shadow_image = NULL; if (pixmap != XCB_NONE) { xcb_free_pixmap(base->c->c, pixmap); @@ -360,7 +360,7 @@ static inline void win_release_shadow(backend_t *base, struct managed_win *w) { static inline void win_release_mask(backend_t *base, struct managed_win *w) { if (w->mask_image) { xcb_pixmap_t pixmap = XCB_NONE; - pixmap = base->ops->v2.release_image(base, w->mask_image); + pixmap = base->ops->release_image(base, w->mask_image); w->mask_image = NULL; if (pixmap != XCB_NONE) { xcb_free_pixmap(base->c->c, pixmap); @@ -380,8 +380,7 @@ static inline bool win_bind_pixmap(struct backend_base *b, struct managed_win *w return false; } log_debug("New named pixmap for %#010x (%s) : %#010x", w->base.id, w->name, pixmap); - w->win_image = - b->ops->v2.bind_pixmap(b, pixmap, x_get_visual_info(b->c, w->a.visual)); + w->win_image = b->ops->bind_pixmap(b, pixmap, x_get_visual_info(b->c, w->a.visual)); if (!w->win_image) { log_error("Failed to bind pixmap"); xcb_free_pixmap(b->c->c, pixmap);