mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-16 06:59:44 -05:00
Implement wlr_region using pixman
This commit is contained in:
parent
a77fac0760
commit
1bea754521
5 changed files with 58 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ wlr_files += files(
|
|||
'wlr_keyboard.c',
|
||||
'wlr_output.c',
|
||||
'wlr_pointer.c',
|
||||
'wlr_region.c',
|
||||
'wlr_tablet_pad.c',
|
||||
'wlr_tablet_tool.c',
|
||||
'wlr_touch.c',
|
||||
|
|
|
|||
44
types/wlr_region.c
Normal file
44
types/wlr_region.c
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <wayland-server.h>
|
||||
#include <pixman.h>
|
||||
|
||||
static void region_add(struct wl_client *client, struct wl_resource *resource,
|
||||
int32_t x, int32_t y, int32_t width, int32_t height) {
|
||||
pixman_region32_t *region = wl_resource_get_user_data(resource);
|
||||
pixman_region32_union_rect(region, region, x, y, width, height);
|
||||
}
|
||||
|
||||
static void region_subtract(struct wl_client *client, struct wl_resource *resource,
|
||||
int32_t x, int32_t y, int32_t width, int32_t height) {
|
||||
pixman_region32_t *region = wl_resource_get_user_data(resource);
|
||||
pixman_region32_union_rect(region, region, x, y, width, height);
|
||||
|
||||
pixman_region32_t rect;
|
||||
pixman_region32_init_rect(&rect, x, y, width, height);
|
||||
pixman_region32_subtract(region, region, &rect);
|
||||
pixman_region32_fini(&rect);
|
||||
}
|
||||
|
||||
static void region_destroy(struct wl_client *client, struct wl_resource *resource) {
|
||||
wl_resource_destroy(resource);
|
||||
}
|
||||
|
||||
static const struct wl_region_interface region_interface = {
|
||||
region_destroy,
|
||||
region_add,
|
||||
region_subtract,
|
||||
};
|
||||
|
||||
static void destroy_region(struct wl_resource *resource) {
|
||||
pixman_region32_t *reg = wl_resource_get_user_data(resource);
|
||||
pixman_region32_fini(reg);
|
||||
free(reg);
|
||||
}
|
||||
|
||||
void wlr_region_create(struct wl_resource *res) {
|
||||
pixman_region32_t *region = calloc(1, sizeof(pixman_region32_t));
|
||||
pixman_region32_init(region);
|
||||
wl_resource_set_implementation(res, ®ion_interface, region, destroy_region);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue