2022-08-20 00:01:06 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2023-05-13 16:10:33 +03:00
|
|
|
#ifndef LABWC_GRAPHIC_HELPERS_H
|
|
|
|
|
#define LABWC_GRAPHIC_HELPERS_H
|
2022-08-20 00:01:06 +02:00
|
|
|
|
2025-07-28 01:03:22 -04:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdint.h>
|
2022-07-06 17:37:22 +02:00
|
|
|
#include <cairo.h>
|
2022-10-05 08:43:56 +02:00
|
|
|
|
2023-06-29 17:45:33 +01:00
|
|
|
struct wlr_fbox;
|
2022-08-20 00:01:06 +02:00
|
|
|
|
2022-08-20 20:11:58 +02:00
|
|
|
/**
|
|
|
|
|
* Sets the cairo color.
|
|
|
|
|
* Splits a float[4] single color array into its own arguments
|
|
|
|
|
*/
|
2024-03-16 22:20:40 -04:00
|
|
|
void set_cairo_color(cairo_t *cairo, const float *color);
|
2022-08-20 20:11:58 +02:00
|
|
|
|
2025-05-29 12:31:41 -04:00
|
|
|
/* Creates a solid color cairo pattern from premultipled RGBA */
|
|
|
|
|
cairo_pattern_t *color_to_pattern(const float *color);
|
|
|
|
|
|
|
|
|
|
bool is_pattern_opaque(cairo_pattern_t *pattern);
|
|
|
|
|
|
|
|
|
|
/* Like zfree() but for a cairo_pattern_t */
|
|
|
|
|
#define zfree_pattern(ptr) do { \
|
|
|
|
|
if (ptr) { \
|
|
|
|
|
cairo_pattern_destroy(ptr); \
|
|
|
|
|
(ptr) = NULL; \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2022-08-20 20:11:58 +02:00
|
|
|
/* Draws a border with a specified line width */
|
2023-06-29 17:45:33 +01:00
|
|
|
void draw_cairo_border(cairo_t *cairo, struct wlr_fbox fbox, double line_width);
|
2023-05-13 16:10:33 +03:00
|
|
|
|
2025-04-22 11:47:38 -04:00
|
|
|
/* Converts X11 color name to ARGB32 (with alpha = 255) */
|
|
|
|
|
bool lookup_named_color(const char *name, uint32_t *argb);
|
2023-12-17 02:16:49 +01:00
|
|
|
|
2023-05-13 16:10:33 +03:00
|
|
|
#endif /* LABWC_GRAPHIC_HELPERS_H */
|