mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
backend: add shadow_from_mask based implementation of render_shadow
If the backend implements shadow_from_mask then it doesn't need to implement render_shadow. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
de209fd52c
commit
a9ec614286
3 changed files with 29 additions and 2 deletions
|
@ -215,12 +215,18 @@ struct backend_operations {
|
||||||
void *(*bind_pixmap)(backend_t *backend_data, xcb_pixmap_t pixmap,
|
void *(*bind_pixmap)(backend_t *backend_data, xcb_pixmap_t pixmap,
|
||||||
struct xvisual_info fmt, bool owned);
|
struct xvisual_info fmt, bool owned);
|
||||||
|
|
||||||
|
/// Create a shadow context for rendering shadows with radius `radius`.
|
||||||
|
/// Default implementation: default_backend_create_shadow_context
|
||||||
struct backend_shadow_context *(*create_shadow_context)(backend_t *backend_data,
|
struct backend_shadow_context *(*create_shadow_context)(backend_t *backend_data,
|
||||||
double radius);
|
double radius);
|
||||||
|
/// Destroy a shadow context
|
||||||
|
/// Default implementation: default_backend_destroy_shadow_context
|
||||||
void (*destroy_shadow_context)(backend_t *backend_data,
|
void (*destroy_shadow_context)(backend_t *backend_data,
|
||||||
struct backend_shadow_context *ctx);
|
struct backend_shadow_context *ctx);
|
||||||
|
|
||||||
/// Create a shadow image based on the parameters
|
/// Create a shadow image based on the parameters. Resulting image should have a
|
||||||
|
/// size of `width + radisu * 2` x `height + radius * 2`. Radius is set when the
|
||||||
|
/// shadow context is created.
|
||||||
/// Default implementation: default_backend_render_shadow
|
/// Default implementation: default_backend_render_shadow
|
||||||
///
|
///
|
||||||
/// Required.
|
/// Required.
|
||||||
|
@ -228,7 +234,8 @@ struct backend_operations {
|
||||||
struct backend_shadow_context *ctx, struct color color);
|
struct backend_shadow_context *ctx, struct color color);
|
||||||
|
|
||||||
/// Create a shadow by blurring a mask. `size` is the size of the blur. The
|
/// Create a shadow by blurring a mask. `size` is the size of the blur. The
|
||||||
/// backend can use whichever blur method is the fastest.
|
/// backend can use whichever blur method is the fastest. The shadow produced
|
||||||
|
/// shoule be consistent with `render_shadow`.
|
||||||
///
|
///
|
||||||
/// Optional.
|
/// Optional.
|
||||||
void *(*shadow_from_mask)(backend_t *backend_data, void *mask,
|
void *(*shadow_from_mask)(backend_t *backend_data, void *mask,
|
||||||
|
|
|
@ -311,6 +311,21 @@ void *default_backend_render_shadow(backend_t *backend_data, int width, int heig
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Implement render_shadow with shadow_from_mask
|
||||||
|
void *
|
||||||
|
backend_render_shadow_from_mask(backend_t *backend_data, int width, int height,
|
||||||
|
struct backend_shadow_context *sctx, struct color color) {
|
||||||
|
region_t reg;
|
||||||
|
pixman_region32_init_rect(®, 0, 0, (unsigned int)width, (unsigned int)height);
|
||||||
|
void *mask = backend_data->ops->make_mask(
|
||||||
|
backend_data, (geometry_t){.width = width, .height = height}, ®);
|
||||||
|
pixman_region32_fini(®);
|
||||||
|
|
||||||
|
void *shadow = backend_data->ops->shadow_from_mask(backend_data, mask, sctx, color);
|
||||||
|
backend_data->ops->release_image(backend_data, mask);
|
||||||
|
return shadow;
|
||||||
|
}
|
||||||
|
|
||||||
struct backend_shadow_context *
|
struct backend_shadow_context *
|
||||||
default_create_shadow_context(backend_t *backend_data attr_unused, double radius) {
|
default_create_shadow_context(backend_t *backend_data attr_unused, double radius) {
|
||||||
auto ret =
|
auto ret =
|
||||||
|
|
|
@ -64,6 +64,11 @@ bool default_is_frame_transparent(void *, win *, void *);
|
||||||
|
|
||||||
void *default_backend_render_shadow(backend_t *backend_data, int width, int height,
|
void *default_backend_render_shadow(backend_t *backend_data, int width, int height,
|
||||||
struct backend_shadow_context *sctx, struct color color);
|
struct backend_shadow_context *sctx, struct color color);
|
||||||
|
|
||||||
|
/// Implement `render_shadow` with `shadow_from_mask`.
|
||||||
|
void *
|
||||||
|
backend_render_shadow_from_mask(backend_t *backend_data, int width, int height,
|
||||||
|
struct backend_shadow_context *sctx, struct color color);
|
||||||
struct backend_shadow_context *
|
struct backend_shadow_context *
|
||||||
default_create_shadow_context(backend_t *backend_data, double radius);
|
default_create_shadow_context(backend_t *backend_data, double radius);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue