2019-02-03 18:47:36 +00:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
// Copyright (c) Yuxuan Shui <yshuiv7@gmail.com>
|
2018-10-03 21:46:18 +00:00
|
|
|
#pragma once
|
2019-02-03 18:47:36 +00:00
|
|
|
|
2018-12-31 14:27:18 +00:00
|
|
|
#include <xcb/render.h>
|
2019-01-01 11:01:47 +00:00
|
|
|
#include <xcb/xcb_image.h>
|
2018-12-31 14:27:18 +00:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2021-06-14 02:22:13 +00:00
|
|
|
#include "backend.h"
|
2019-06-08 23:44:46 +00:00
|
|
|
#include "config.h"
|
2018-12-31 14:27:18 +00:00
|
|
|
#include "region.h"
|
|
|
|
|
|
|
|
typedef struct session session_t;
|
|
|
|
typedef struct win win;
|
2019-01-01 11:01:47 +00:00
|
|
|
typedef struct conv conv;
|
2019-03-30 09:07:21 +00:00
|
|
|
typedef struct backend_base backend_t;
|
2019-04-27 14:07:23 +00:00
|
|
|
struct backend_operations;
|
2018-10-03 21:46:18 +00:00
|
|
|
|
2019-12-20 20:38:21 +00:00
|
|
|
struct dual_kawase_params {
|
|
|
|
/// Number of downsample passes
|
|
|
|
int iterations;
|
|
|
|
/// Pixel offset for down- and upsample
|
|
|
|
float offset;
|
|
|
|
/// Save area around blur target (@ref resize_width, @ref resize_height)
|
|
|
|
int expand;
|
|
|
|
};
|
|
|
|
|
2021-06-14 02:22:13 +00:00
|
|
|
struct backend_image_inner_base {
|
|
|
|
int refcount;
|
|
|
|
bool has_alpha;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct backend_image {
|
|
|
|
// Backend dependent inner image data
|
|
|
|
struct backend_image_inner_base *inner;
|
|
|
|
double opacity;
|
|
|
|
double dim;
|
|
|
|
double max_brightness;
|
2021-07-16 18:11:23 +00:00
|
|
|
double corner_radius;
|
2021-06-14 02:22:13 +00:00
|
|
|
// Effective size of the image
|
|
|
|
int ewidth, eheight;
|
|
|
|
bool color_inverted;
|
2022-01-13 11:31:31 +00:00
|
|
|
int border_width;
|
2021-06-14 02:22:13 +00:00
|
|
|
};
|
|
|
|
|
2019-03-30 09:07:21 +00:00
|
|
|
bool build_shadow(xcb_connection_t *, xcb_drawable_t, double opacity, int width,
|
|
|
|
int height, const conv *kernel, xcb_render_picture_t shadow_pixel,
|
2019-02-20 18:17:16 +00:00
|
|
|
xcb_pixmap_t *pixmap, xcb_render_picture_t *pict);
|
2018-10-03 21:46:18 +00:00
|
|
|
|
2019-02-26 23:21:11 +00:00
|
|
|
xcb_render_picture_t solid_picture(xcb_connection_t *, xcb_drawable_t, bool argb,
|
|
|
|
double a, double r, double g, double b);
|
2018-12-31 14:27:18 +00:00
|
|
|
|
2019-06-08 23:44:46 +00:00
|
|
|
xcb_image_t *
|
|
|
|
make_shadow(xcb_connection_t *c, const conv *kernel, double opacity, int width, int height);
|
2019-02-03 18:41:02 +00:00
|
|
|
|
|
|
|
/// The default implementation of `is_win_transparent`, it simply looks at win::mode. So
|
|
|
|
/// this is not suitable for backends that alter the content of windows
|
|
|
|
bool default_is_win_transparent(void *, win *, void *);
|
|
|
|
|
|
|
|
/// The default implementation of `is_frame_transparent`, it uses win::frame_opacity. Same
|
|
|
|
/// caveat as `default_is_win_transparent` applies.
|
|
|
|
bool default_is_frame_transparent(void *, win *, void *);
|
2019-02-26 23:52:37 +00:00
|
|
|
|
2022-08-25 04:21:19 +00:00
|
|
|
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 *
|
|
|
|
default_create_shadow_context(backend_t *backend_data, double radius);
|
|
|
|
|
|
|
|
void default_destroy_shadow_context(backend_t *backend_data,
|
|
|
|
struct backend_shadow_context *sctx);
|
2019-04-27 14:07:23 +00:00
|
|
|
|
|
|
|
void init_backend_base(struct backend_base *base, session_t *ps);
|
2019-06-08 23:44:46 +00:00
|
|
|
|
2019-06-09 11:44:32 +00:00
|
|
|
struct conv **generate_blur_kernel(enum blur_method method, void *args, int *kernel_count);
|
2019-12-20 20:38:21 +00:00
|
|
|
struct dual_kawase_params *generate_dual_kawase_params(void *args);
|
2021-06-14 02:22:13 +00:00
|
|
|
|
|
|
|
void *default_clone_image(backend_t *base, const void *image_data, const region_t *reg);
|
|
|
|
bool default_is_image_transparent(backend_t *base attr_unused, void *image_data);
|
|
|
|
bool default_set_image_property(backend_t *base attr_unused, enum image_properties op,
|
|
|
|
void *image_data, void *arg);
|
|
|
|
struct backend_image *default_new_backend_image(int w, int h);
|