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"
|
|
|
|
|
2024-03-25 18:33:01 +00:00
|
|
|
struct session;
|
|
|
|
struct win;
|
|
|
|
struct conv;
|
|
|
|
struct backend_base;
|
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
|
|
|
};
|
|
|
|
|
2023-06-29 04:39:36 +00:00
|
|
|
bool build_shadow(struct x_connection *, 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
|
|
|
|
2023-06-29 04:39:36 +00:00
|
|
|
xcb_render_picture_t
|
|
|
|
solid_picture(struct x_connection *, bool argb, double a, double r, double g, double b);
|
2018-12-31 14:27:18 +00:00
|
|
|
|
2023-06-29 04:39:36 +00:00
|
|
|
xcb_image_t *make_shadow(struct x_connection *c, const conv *kernel, double opacity,
|
|
|
|
int width, int height);
|
2019-02-03 18:41:02 +00:00
|
|
|
|
2024-02-10 08:20:10 +00:00
|
|
|
image_handle default_render_shadow(backend_t *backend_data, int width, int height,
|
|
|
|
struct backend_shadow_context *sctx, struct color color);
|
2022-08-25 16:53:31 +00:00
|
|
|
|
|
|
|
/// Implement `render_shadow` with `shadow_from_mask`.
|
2024-02-10 08:20:10 +00:00
|
|
|
image_handle
|
2022-08-25 16:53:31 +00:00
|
|
|
backend_render_shadow_from_mask(backend_t *backend_data, int width, int height,
|
|
|
|
struct backend_shadow_context *sctx, struct color color);
|
2022-08-25 04:21:19 +00:00
|
|
|
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
|
|
|
|
2024-02-10 08:20:10 +00:00
|
|
|
image_handle default_clone_image(backend_t *base, image_handle image, const region_t *reg);
|
|
|
|
bool default_is_image_transparent(backend_t *base attr_unused, image_handle image);
|
2021-06-14 02:22:13 +00:00
|
|
|
bool default_set_image_property(backend_t *base attr_unused, enum image_properties op,
|
2024-03-19 14:57:24 +00:00
|
|
|
image_handle image, const void *arg);
|
2021-06-14 02:22:13 +00:00
|
|
|
struct backend_image *default_new_backend_image(int w, int h);
|