region: constify

Simon Ser 2 years ago committed by Simon Zeni
parent fe4225d5de
commit c5d79bfb26

@ -25,6 +25,6 @@ struct wl_resource;
* *
* To allow clients to create wl_region objects, call wlr_compositor_create(). * To allow clients to create wl_region objects, call wlr_compositor_create().
*/ */
pixman_region32_t *wlr_region_from_resource(struct wl_resource *resource); const pixman_region32_t *wlr_region_from_resource(struct wl_resource *resource);
#endif #endif

@ -123,7 +123,7 @@ static void surface_handle_set_opaque_region(struct wl_client *client,
struct wlr_surface *surface = wlr_surface_from_resource(resource); struct wlr_surface *surface = wlr_surface_from_resource(resource);
surface->pending.committed |= WLR_SURFACE_STATE_OPAQUE_REGION; surface->pending.committed |= WLR_SURFACE_STATE_OPAQUE_REGION;
if (region_resource) { if (region_resource) {
pixman_region32_t *region = wlr_region_from_resource(region_resource); const pixman_region32_t *region = wlr_region_from_resource(region_resource);
pixman_region32_copy(&surface->pending.opaque, region); pixman_region32_copy(&surface->pending.opaque, region);
} else { } else {
pixman_region32_clear(&surface->pending.opaque); pixman_region32_clear(&surface->pending.opaque);
@ -136,7 +136,7 @@ static void surface_handle_set_input_region(struct wl_client *client,
struct wlr_surface *surface = wlr_surface_from_resource(resource); struct wlr_surface *surface = wlr_surface_from_resource(resource);
surface->pending.committed |= WLR_SURFACE_STATE_INPUT_REGION; surface->pending.committed |= WLR_SURFACE_STATE_INPUT_REGION;
if (region_resource) { if (region_resource) {
pixman_region32_t *region = wlr_region_from_resource(region_resource); const pixman_region32_t *region = wlr_region_from_resource(region_resource);
pixman_region32_copy(&surface->pending.input, region); pixman_region32_copy(&surface->pending.input, region);
} else { } else {
pixman_region32_fini(&surface->pending.input); pixman_region32_fini(&surface->pending.input);

@ -72,7 +72,7 @@ static void pointer_constraint_set_region(
pixman_region32_clear(&constraint->pending.region); pixman_region32_clear(&constraint->pending.region);
if (region_resource) { if (region_resource) {
pixman_region32_t *region = wlr_region_from_resource(region_resource); const pixman_region32_t *region = wlr_region_from_resource(region_resource);
pixman_region32_copy(&constraint->pending.region, region); pixman_region32_copy(&constraint->pending.region, region);
} }

@ -6,15 +6,27 @@
#include <wlr/types/wlr_region.h> #include <wlr/types/wlr_region.h>
#include "types/wlr_region.h" #include "types/wlr_region.h"
static const struct wl_region_interface region_impl;
static pixman_region32_t *region_from_resource(struct wl_resource *resource) {
assert(wl_resource_instance_of(resource, &wl_region_interface,
&region_impl));
return wl_resource_get_user_data(resource);
}
const pixman_region32_t *wlr_region_from_resource(struct wl_resource *resource) {
return region_from_resource(resource);
}
static void region_add(struct wl_client *client, struct wl_resource *resource, static void region_add(struct wl_client *client, struct wl_resource *resource,
int32_t x, int32_t y, int32_t width, int32_t height) { int32_t x, int32_t y, int32_t width, int32_t height) {
pixman_region32_t *region = wlr_region_from_resource(resource); pixman_region32_t *region = region_from_resource(resource);
pixman_region32_union_rect(region, region, x, y, width, height); pixman_region32_union_rect(region, region, x, y, width, height);
} }
static void region_subtract(struct wl_client *client, struct wl_resource *resource, static void region_subtract(struct wl_client *client, struct wl_resource *resource,
int32_t x, int32_t y, int32_t width, int32_t height) { int32_t x, int32_t y, int32_t width, int32_t height) {
pixman_region32_t *region = wlr_region_from_resource(resource); pixman_region32_t *region = region_from_resource(resource);
pixman_region32_union_rect(region, region, x, y, width, height); pixman_region32_union_rect(region, region, x, y, width, height);
pixman_region32_t rect; pixman_region32_t rect;
@ -34,7 +46,7 @@ static const struct wl_region_interface region_impl = {
}; };
static void region_handle_resource_destroy(struct wl_resource *resource) { static void region_handle_resource_destroy(struct wl_resource *resource) {
pixman_region32_t *reg = wlr_region_from_resource(resource); pixman_region32_t *reg = region_from_resource(resource);
pixman_region32_fini(reg); pixman_region32_fini(reg);
free(reg); free(reg);
} }
@ -61,9 +73,3 @@ struct wl_resource *region_create(struct wl_client *client,
return region_resource; return region_resource;
} }
pixman_region32_t *wlr_region_from_resource(struct wl_resource *resource) {
assert(wl_resource_instance_of(resource, &wl_region_interface,
&region_impl));
return wl_resource_get_user_data(resource);
}

Loading…
Cancel
Save