|
|
@ -100,15 +100,15 @@ static void surface_set_input_region(struct wl_client *client,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void wlr_surface_update_size(struct wlr_surface *surface, struct wlr_surface_state *current) {
|
|
|
|
static void wlr_surface_update_size(struct wlr_surface *surface, struct wlr_surface_state *state) {
|
|
|
|
int scale = current->scale;
|
|
|
|
int scale = state->scale;
|
|
|
|
enum wl_output_transform transform = current->transform;
|
|
|
|
enum wl_output_transform transform = state->transform;
|
|
|
|
|
|
|
|
|
|
|
|
wlr_texture_get_buffer_size(surface->texture, current->buffer,
|
|
|
|
wlr_texture_get_buffer_size(surface->texture, state->buffer,
|
|
|
|
¤t->buffer_width, ¤t->buffer_height);
|
|
|
|
&state->buffer_width, &state->buffer_height);
|
|
|
|
|
|
|
|
|
|
|
|
int _width = current->buffer_width / scale;
|
|
|
|
int _width = state->buffer_width / scale;
|
|
|
|
int _height = current->buffer_height / scale;
|
|
|
|
int _height = state->buffer_height / scale;
|
|
|
|
|
|
|
|
|
|
|
|
if (transform == WL_OUTPUT_TRANSFORM_90 ||
|
|
|
|
if (transform == WL_OUTPUT_TRANSFORM_90 ||
|
|
|
|
transform == WL_OUTPUT_TRANSFORM_270 ||
|
|
|
|
transform == WL_OUTPUT_TRANSFORM_270 ||
|
|
|
@ -119,10 +119,10 @@ static void wlr_surface_update_size(struct wlr_surface *surface, struct wlr_surf
|
|
|
|
_height = tmp;
|
|
|
|
_height = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wl_list_init(¤t->frame_callback_list);
|
|
|
|
wl_list_init(&state->frame_callback_list);
|
|
|
|
|
|
|
|
|
|
|
|
current->width = _width;
|
|
|
|
state->width = _width;
|
|
|
|
current->height = _height;
|
|
|
|
state->height = _height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void wlr_surface_to_buffer_region(int scale,
|
|
|
|
static void wlr_surface_to_buffer_region(int scale,
|
|
|
@ -209,85 +209,85 @@ static void wlr_surface_to_buffer_region(int scale,
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Append pending state to current state and clear pending state.
|
|
|
|
* Append pending state to current state and clear pending state.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
static void wlr_surface_move_state(struct wlr_surface *surface, struct wlr_surface_state *pending,
|
|
|
|
static void wlr_surface_move_state(struct wlr_surface *surface, struct wlr_surface_state *next,
|
|
|
|
struct wlr_surface_state *current) {
|
|
|
|
struct wlr_surface_state *state) {
|
|
|
|
bool update_damage = false;
|
|
|
|
bool update_damage = false;
|
|
|
|
bool update_size = false;
|
|
|
|
bool update_size = false;
|
|
|
|
|
|
|
|
|
|
|
|
if ((pending->invalid & WLR_SURFACE_INVALID_SCALE)) {
|
|
|
|
if ((next->invalid & WLR_SURFACE_INVALID_SCALE)) {
|
|
|
|
current->scale = pending->scale;
|
|
|
|
state->scale = next->scale;
|
|
|
|
update_size = true;
|
|
|
|
update_size = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((pending->invalid & WLR_SURFACE_INVALID_TRANSFORM)) {
|
|
|
|
if ((next->invalid & WLR_SURFACE_INVALID_TRANSFORM)) {
|
|
|
|
current->transform = pending->transform;
|
|
|
|
state->transform = next->transform;
|
|
|
|
update_size = true;
|
|
|
|
update_size = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((pending->invalid & WLR_SURFACE_INVALID_BUFFER)) {
|
|
|
|
if ((next->invalid & WLR_SURFACE_INVALID_BUFFER)) {
|
|
|
|
if (current->buffer) {
|
|
|
|
if (state->buffer) {
|
|
|
|
wl_resource_post_event(current->buffer, WL_BUFFER_RELEASE);
|
|
|
|
wl_resource_post_event(state->buffer, WL_BUFFER_RELEASE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
current->buffer = pending->buffer;
|
|
|
|
state->buffer = next->buffer;
|
|
|
|
pending->buffer = NULL;
|
|
|
|
next->buffer = NULL;
|
|
|
|
update_size = true;
|
|
|
|
update_size = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (update_size) {
|
|
|
|
if (update_size) {
|
|
|
|
wlr_surface_update_size(surface, current);
|
|
|
|
wlr_surface_update_size(surface, state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((pending->invalid & WLR_SURFACE_INVALID_SURFACE_DAMAGE)) {
|
|
|
|
if ((next->invalid & WLR_SURFACE_INVALID_SURFACE_DAMAGE)) {
|
|
|
|
pixman_region32_union(¤t->surface_damage,
|
|
|
|
pixman_region32_union(&state->surface_damage,
|
|
|
|
¤t->surface_damage,
|
|
|
|
&state->surface_damage,
|
|
|
|
&pending->surface_damage);
|
|
|
|
&next->surface_damage);
|
|
|
|
pixman_region32_intersect_rect(¤t->surface_damage,
|
|
|
|
pixman_region32_intersect_rect(&state->surface_damage,
|
|
|
|
¤t->surface_damage, 0, 0, current->width,
|
|
|
|
&state->surface_damage, 0, 0, state->width,
|
|
|
|
current->height);
|
|
|
|
state->height);
|
|
|
|
|
|
|
|
|
|
|
|
pixman_region32_clear(&pending->surface_damage);
|
|
|
|
pixman_region32_clear(&next->surface_damage);
|
|
|
|
update_damage = true;
|
|
|
|
update_damage = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((pending->invalid & WLR_SURFACE_INVALID_BUFFER_DAMAGE)) {
|
|
|
|
if ((next->invalid & WLR_SURFACE_INVALID_BUFFER_DAMAGE)) {
|
|
|
|
pixman_region32_union(¤t->buffer_damage,
|
|
|
|
pixman_region32_union(&state->buffer_damage,
|
|
|
|
¤t->buffer_damage,
|
|
|
|
&state->buffer_damage,
|
|
|
|
&pending->buffer_damage);
|
|
|
|
&next->buffer_damage);
|
|
|
|
|
|
|
|
|
|
|
|
pixman_region32_clear(&pending->buffer_damage);
|
|
|
|
pixman_region32_clear(&next->buffer_damage);
|
|
|
|
update_damage = true;
|
|
|
|
update_damage = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (update_damage) {
|
|
|
|
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(current->scale, current->transform,
|
|
|
|
wlr_surface_to_buffer_region(state->scale, state->transform,
|
|
|
|
¤t->surface_damage, &buffer_damage, current->width,
|
|
|
|
&state->surface_damage, &buffer_damage, state->width,
|
|
|
|
current->height);
|
|
|
|
state->height);
|
|
|
|
pixman_region32_union(¤t->buffer_damage,
|
|
|
|
pixman_region32_union(&state->buffer_damage,
|
|
|
|
¤t->buffer_damage, &buffer_damage);
|
|
|
|
&state->buffer_damage, &buffer_damage);
|
|
|
|
pixman_region32_fini(&buffer_damage);
|
|
|
|
pixman_region32_fini(&buffer_damage);
|
|
|
|
|
|
|
|
|
|
|
|
pixman_region32_intersect_rect(¤t->buffer_damage,
|
|
|
|
pixman_region32_intersect_rect(&state->buffer_damage,
|
|
|
|
¤t->buffer_damage, 0, 0,
|
|
|
|
&state->buffer_damage, 0, 0,
|
|
|
|
current->buffer_width, current->buffer_height);
|
|
|
|
state->buffer_width, state->buffer_height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((pending->invalid & WLR_SURFACE_INVALID_OPAQUE_REGION)) {
|
|
|
|
if ((next->invalid & WLR_SURFACE_INVALID_OPAQUE_REGION)) {
|
|
|
|
// TODO: process buffer
|
|
|
|
// TODO: process buffer
|
|
|
|
pixman_region32_clear(&pending->opaque);
|
|
|
|
pixman_region32_clear(&next->opaque);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((pending->invalid & WLR_SURFACE_INVALID_INPUT_REGION)) {
|
|
|
|
if ((next->invalid & WLR_SURFACE_INVALID_INPUT_REGION)) {
|
|
|
|
// TODO: process buffer
|
|
|
|
// TODO: process buffer
|
|
|
|
pixman_region32_clear(&pending->input);
|
|
|
|
pixman_region32_clear(&next->input);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((pending->invalid & WLR_SURFACE_INVALID_SUBSURFACE_POSITION)) {
|
|
|
|
if ((next->invalid & WLR_SURFACE_INVALID_SUBSURFACE_POSITION)) {
|
|
|
|
current->subsurface_position.x = pending->subsurface_position.x;
|
|
|
|
state->subsurface_position.x = next->subsurface_position.x;
|
|
|
|
current->subsurface_position.y = pending->subsurface_position.y;
|
|
|
|
state->subsurface_position.y = next->subsurface_position.y;
|
|
|
|
pending->subsurface_position.x = 0;
|
|
|
|
next->subsurface_position.x = 0;
|
|
|
|
pending->subsurface_position.y = 0;
|
|
|
|
next->subsurface_position.y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((pending->invalid & WLR_SURFACE_INVALID_FRAME_CALLBACK_LIST)) {
|
|
|
|
if ((next->invalid & WLR_SURFACE_INVALID_FRAME_CALLBACK_LIST)) {
|
|
|
|
wl_list_insert_list(¤t->frame_callback_list, &pending->frame_callback_list);
|
|
|
|
wl_list_insert_list(&state->frame_callback_list, &next->frame_callback_list);
|
|
|
|
wl_list_init(&pending->frame_callback_list);
|
|
|
|
wl_list_init(&next->frame_callback_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
current->invalid |= pending->invalid;
|
|
|
|
state->invalid |= next->invalid;
|
|
|
|
pending->invalid = 0;
|
|
|
|
next->invalid = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void wlr_surface_commit_pending(struct wlr_surface *surface) {
|
|
|
|
static void wlr_surface_commit_pending(struct wlr_surface *surface) {
|
|
|
@ -489,18 +489,18 @@ static struct wlr_surface_state *wlr_surface_state_create() {
|
|
|
|
return state;
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void wlr_surface_state_destroy(struct wlr_surface_state *current) {
|
|
|
|
static void wlr_surface_state_destroy(struct wlr_surface_state *state) {
|
|
|
|
struct wlr_frame_callback *cb, *tmp;
|
|
|
|
struct wlr_frame_callback *cb, *tmp;
|
|
|
|
wl_list_for_each_safe(cb, tmp, ¤t->frame_callback_list, link) {
|
|
|
|
wl_list_for_each_safe(cb, tmp, &state->frame_callback_list, link) {
|
|
|
|
wl_resource_destroy(cb->resource);
|
|
|
|
wl_resource_destroy(cb->resource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pixman_region32_fini(¤t->surface_damage);
|
|
|
|
pixman_region32_fini(&state->surface_damage);
|
|
|
|
pixman_region32_fini(¤t->buffer_damage);
|
|
|
|
pixman_region32_fini(&state->buffer_damage);
|
|
|
|
pixman_region32_fini(¤t->opaque);
|
|
|
|
pixman_region32_fini(&state->opaque);
|
|
|
|
pixman_region32_fini(¤t->input);
|
|
|
|
pixman_region32_fini(&state->input);
|
|
|
|
|
|
|
|
|
|
|
|
free(current);
|
|
|
|
free(state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wlr_subsurface_destroy(struct wlr_subsurface *subsurface) {
|
|
|
|
void wlr_subsurface_destroy(struct wlr_subsurface *subsurface) {
|
|
|
|