|
|
@ -67,6 +67,9 @@ static void surface_set_opaque_region(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *region_resource) {
|
|
|
|
struct wl_resource *region_resource) {
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_OPAQUE_REGION)) {
|
|
|
|
|
|
|
|
pixman_region32_clear(&surface->pending.opaque);
|
|
|
|
|
|
|
|
}
|
|
|
|
surface->pending.invalid |= WLR_SURFACE_INVALID_OPAQUE_REGION;
|
|
|
|
surface->pending.invalid |= WLR_SURFACE_INVALID_OPAQUE_REGION;
|
|
|
|
if (region_resource) {
|
|
|
|
if (region_resource) {
|
|
|
|
pixman_region32_t *region = wl_resource_get_user_data(region_resource);
|
|
|
|
pixman_region32_t *region = wl_resource_get_user_data(region_resource);
|
|
|
@ -80,12 +83,14 @@ static void surface_set_input_region(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *region_resource) {
|
|
|
|
struct wl_resource *region_resource) {
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_INPUT_REGION)) {
|
|
|
|
|
|
|
|
pixman_region32_clear(&surface->pending.input);
|
|
|
|
|
|
|
|
}
|
|
|
|
surface->pending.invalid |= WLR_SURFACE_INVALID_INPUT_REGION;
|
|
|
|
surface->pending.invalid |= WLR_SURFACE_INVALID_INPUT_REGION;
|
|
|
|
if (region_resource) {
|
|
|
|
if (region_resource) {
|
|
|
|
pixman_region32_t *region = wl_resource_get_user_data(region_resource);
|
|
|
|
pixman_region32_t *region = wl_resource_get_user_data(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_init_rect(&surface->pending.input,
|
|
|
|
pixman_region32_init_rect(&surface->pending.input,
|
|
|
|
INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX);
|
|
|
|
INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -199,20 +204,30 @@ static void wlr_surface_to_buffer_region(struct wlr_surface *surface,
|
|
|
|
static void surface_commit(struct wl_client *client,
|
|
|
|
static void surface_commit(struct wl_client *client,
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
bool update_size = false;
|
|
|
|
|
|
|
|
bool update_damage = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_SCALE)) {
|
|
|
|
surface->current.scale = surface->pending.scale;
|
|
|
|
surface->current.scale = surface->pending.scale;
|
|
|
|
|
|
|
|
update_size = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_TRANSFORM)) {
|
|
|
|
surface->current.transform = surface->pending.transform;
|
|
|
|
surface->current.transform = surface->pending.transform;
|
|
|
|
|
|
|
|
update_size = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_BUFFER)) {
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_BUFFER)) {
|
|
|
|
surface->current.buffer = surface->pending.buffer;
|
|
|
|
surface->current.buffer = surface->pending.buffer;
|
|
|
|
|
|
|
|
update_size = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_SURFACE_DAMAGE)) {
|
|
|
|
if (update_size) {
|
|
|
|
int32_t oldw = surface->current.buffer_width;
|
|
|
|
int32_t oldw = surface->current.buffer_width;
|
|
|
|
int32_t oldh = surface->current.buffer_height;
|
|
|
|
int32_t oldh = surface->current.buffer_height;
|
|
|
|
wlr_surface_update_size(surface);
|
|
|
|
wlr_surface_update_size(surface);
|
|
|
|
|
|
|
|
|
|
|
|
surface->reupload_buffer = oldw != surface->current.buffer_width ||
|
|
|
|
surface->reupload_buffer = oldw != surface->current.buffer_width ||
|
|
|
|
oldh != surface->current.buffer_height;
|
|
|
|
oldh != surface->current.buffer_height;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_SURFACE_DAMAGE)) {
|
|
|
|
pixman_region32_union(&surface->current.surface_damage,
|
|
|
|
pixman_region32_union(&surface->current.surface_damage,
|
|
|
|
&surface->current.surface_damage,
|
|
|
|
&surface->current.surface_damage,
|
|
|
|
&surface->pending.surface_damage);
|
|
|
|
&surface->pending.surface_damage);
|
|
|
@ -220,25 +235,38 @@ static void surface_commit(struct wl_client *client,
|
|
|
|
&surface->current.surface_damage, 0, 0, surface->current.width,
|
|
|
|
&surface->current.surface_damage, 0, 0, surface->current.width,
|
|
|
|
surface->current.height);
|
|
|
|
surface->current.height);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pixman_region32_clear(&surface->pending.surface_damage);
|
|
|
|
|
|
|
|
update_damage = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_BUFFER_DAMAGE)) {
|
|
|
|
pixman_region32_union(&surface->current.buffer_damage,
|
|
|
|
pixman_region32_union(&surface->current.buffer_damage,
|
|
|
|
&surface->current.buffer_damage,
|
|
|
|
&surface->current.buffer_damage,
|
|
|
|
&surface->pending.buffer_damage);
|
|
|
|
&surface->pending.buffer_damage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pixman_region32_clear(&surface->pending.buffer_damage);
|
|
|
|
|
|
|
|
update_damage = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update_damage) {
|
|
|
|
pixman_region32_t buffer_damage;
|
|
|
|
pixman_region32_t buffer_damage;
|
|
|
|
pixman_region32_init(&buffer_damage);
|
|
|
|
pixman_region32_init(&buffer_damage);
|
|
|
|
wlr_surface_to_buffer_region(surface, &surface->current.surface_damage,
|
|
|
|
wlr_surface_to_buffer_region(surface, &surface->current.surface_damage,
|
|
|
|
&buffer_damage, surface->current.width, surface->current.height);
|
|
|
|
&buffer_damage, surface->current.width, surface->current.height);
|
|
|
|
pixman_region32_union(&surface->current.buffer_damage,
|
|
|
|
pixman_region32_union(&surface->current.buffer_damage,
|
|
|
|
&surface->current.buffer_damage, &buffer_damage);
|
|
|
|
&surface->current.buffer_damage, &buffer_damage);
|
|
|
|
|
|
|
|
pixman_region32_fini(&buffer_damage);
|
|
|
|
|
|
|
|
|
|
|
|
pixman_region32_intersect_rect(&surface->current.buffer_damage,
|
|
|
|
pixman_region32_intersect_rect(&surface->current.buffer_damage,
|
|
|
|
&surface->current.buffer_damage, 0, 0,
|
|
|
|
&surface->current.buffer_damage, 0, 0,
|
|
|
|
surface->current.buffer_width, surface->current.buffer_height);
|
|
|
|
surface->current.buffer_width, surface->current.buffer_height);
|
|
|
|
|
|
|
|
|
|
|
|
pixman_region32_clear(&surface->pending.surface_damage);
|
|
|
|
|
|
|
|
pixman_region32_clear(&surface->pending.buffer_damage);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO: Commit other changes
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_OPAQUE_REGION)) {
|
|
|
|
|
|
|
|
// TODO: process buffer
|
|
|
|
|
|
|
|
pixman_region32_clear(&surface->pending.opaque);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((surface->pending.invalid & WLR_SURFACE_INVALID_INPUT_REGION)) {
|
|
|
|
|
|
|
|
// TODO: process buffer
|
|
|
|
|
|
|
|
pixman_region32_clear(&surface->pending.input);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
surface->pending.invalid = 0;
|
|
|
|
surface->pending.invalid = 0;
|
|
|
|
// TODO: add the invalid bitfield to this callback
|
|
|
|
// TODO: add the invalid bitfield to this callback
|
|
|
@ -286,11 +314,8 @@ void wlr_surface_flush_damage(struct wlr_surface *surface) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
release:
|
|
|
|
release:
|
|
|
|
pixman_region32_fini(&surface->current.surface_damage);
|
|
|
|
pixman_region32_clear(&surface->current.surface_damage);
|
|
|
|
pixman_region32_init(&surface->current.surface_damage);
|
|
|
|
pixman_region32_clear(&surface->current.buffer_damage);
|
|
|
|
|
|
|
|
|
|
|
|
pixman_region32_fini(&surface->current.buffer_damage);
|
|
|
|
|
|
|
|
pixman_region32_init(&surface->current.buffer_damage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_resource_post_event(surface->current.buffer, WL_BUFFER_RELEASE);
|
|
|
|
wl_resource_post_event(surface->current.buffer, WL_BUFFER_RELEASE);
|
|
|
|
surface->current.buffer = NULL;
|
|
|
|
surface->current.buffer = NULL;
|
|
|
@ -299,6 +324,7 @@ release:
|
|
|
|
static void surface_set_buffer_transform(struct wl_client *client,
|
|
|
|
static void surface_set_buffer_transform(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, int transform) {
|
|
|
|
struct wl_resource *resource, int transform) {
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
surface->pending.invalid |= WLR_SURFACE_INVALID_TRANSFORM;
|
|
|
|
surface->pending.transform = transform;
|
|
|
|
surface->pending.transform = transform;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -306,6 +332,7 @@ static void surface_set_buffer_scale(struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
int32_t scale) {
|
|
|
|
int32_t scale) {
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
struct wlr_surface *surface = wl_resource_get_user_data(resource);
|
|
|
|
|
|
|
|
surface->pending.invalid |= WLR_SURFACE_INVALID_SCALE;
|
|
|
|
surface->pending.scale = scale;
|
|
|
|
surface->pending.scale = scale;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -317,23 +344,23 @@ static void surface_damage_buffer(struct wl_client *client,
|
|
|
|
if (width < 0 || height < 0) {
|
|
|
|
if (width < 0 || height < 0) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
surface->pending.invalid |= WLR_SURFACE_INVALID_SURFACE_DAMAGE;
|
|
|
|
surface->pending.invalid |= WLR_SURFACE_INVALID_BUFFER_DAMAGE;
|
|
|
|
pixman_region32_union_rect(&surface->pending.buffer_damage,
|
|
|
|
pixman_region32_union_rect(&surface->pending.buffer_damage,
|
|
|
|
&surface->pending.buffer_damage,
|
|
|
|
&surface->pending.buffer_damage,
|
|
|
|
x, y, width, height);
|
|
|
|
x, y, width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const struct wl_surface_interface surface_interface = {
|
|
|
|
const struct wl_surface_interface surface_interface = {
|
|
|
|
surface_destroy,
|
|
|
|
.destroy = surface_destroy,
|
|
|
|
surface_attach,
|
|
|
|
.attach = surface_attach,
|
|
|
|
surface_damage,
|
|
|
|
.damage = surface_damage,
|
|
|
|
surface_frame,
|
|
|
|
.frame = surface_frame,
|
|
|
|
surface_set_opaque_region,
|
|
|
|
.set_opaque_region = surface_set_opaque_region,
|
|
|
|
surface_set_input_region,
|
|
|
|
.set_input_region = surface_set_input_region,
|
|
|
|
surface_commit,
|
|
|
|
.commit = surface_commit,
|
|
|
|
surface_set_buffer_transform,
|
|
|
|
.set_buffer_transform = surface_set_buffer_transform,
|
|
|
|
surface_set_buffer_scale,
|
|
|
|
.set_buffer_scale = surface_set_buffer_scale,
|
|
|
|
surface_damage_buffer
|
|
|
|
.damage_buffer = surface_damage_buffer
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void destroy_surface(struct wl_resource *resource) {
|
|
|
|
static void destroy_surface(struct wl_resource *resource) {
|
|
|
@ -344,6 +371,10 @@ static void destroy_surface(struct wl_resource *resource) {
|
|
|
|
wl_list_for_each_safe(cb, next, &surface->frame_callback_list, link) {
|
|
|
|
wl_list_for_each_safe(cb, next, &surface->frame_callback_list, link) {
|
|
|
|
wl_resource_destroy(cb->resource);
|
|
|
|
wl_resource_destroy(cb->resource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pixman_region32_fini(&surface->pending.surface_damage);
|
|
|
|
|
|
|
|
pixman_region32_fini(&surface->pending.buffer_damage);
|
|
|
|
|
|
|
|
pixman_region32_fini(&surface->pending.opaque);
|
|
|
|
|
|
|
|
pixman_region32_fini(&surface->pending.input);
|
|
|
|
|
|
|
|
|
|
|
|
free(surface);
|
|
|
|
free(surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -356,12 +387,16 @@ struct wlr_surface *wlr_surface_create(struct wl_resource *res,
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
surface->renderer = renderer;
|
|
|
|
surface->renderer = renderer;
|
|
|
|
surface->texture = wlr_render_texture_init(renderer);
|
|
|
|
surface->texture = wlr_render_texture_create(renderer);
|
|
|
|
surface->resource = res;
|
|
|
|
surface->resource = res;
|
|
|
|
surface->current.scale = 1;
|
|
|
|
surface->current.scale = 1;
|
|
|
|
surface->pending.scale = 1;
|
|
|
|
surface->pending.scale = 1;
|
|
|
|
surface->current.transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
|
|
|
surface->current.transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
|
|
|
surface->pending.transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
|
|
|
surface->pending.transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
|
|
|
|
|
|
|
pixman_region32_init(&surface->pending.surface_damage);
|
|
|
|
|
|
|
|
pixman_region32_init(&surface->pending.buffer_damage);
|
|
|
|
|
|
|
|
pixman_region32_init(&surface->pending.opaque);
|
|
|
|
|
|
|
|
pixman_region32_init(&surface->pending.input);
|
|
|
|
wl_signal_init(&surface->signals.commit);
|
|
|
|
wl_signal_init(&surface->signals.commit);
|
|
|
|
wl_list_init(&surface->frame_callback_list);
|
|
|
|
wl_list_init(&surface->frame_callback_list);
|
|
|
|
wl_resource_set_implementation(res, &surface_interface,
|
|
|
|
wl_resource_set_implementation(res, &surface_interface,
|
|
|
|