Skip to content

Commit

Permalink
chore: update to 0.17.4
Browse files Browse the repository at this point in the history
sync upstream

Log:
  • Loading branch information
justforlxz committed Oct 17, 2024
1 parent 00e7d15 commit bb04c74
Show file tree
Hide file tree
Showing 32 changed files with 332 additions and 140 deletions.
5 changes: 5 additions & 0 deletions backend/drm/libliftoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "backend/drm/drm.h"
#include "backend/drm/iface.h"
#include "config.h"

static bool init(struct wlr_drm_backend *drm) {
// TODO: lower log level
Expand Down Expand Up @@ -436,7 +437,11 @@ static bool crtc_commit(struct wlr_drm_connector *conn,
goto out;
}

#if HAVE_LIBLIFTOFF_0_5
int ret = liftoff_output_apply(crtc->liftoff, req, flags, NULL);
#else
int ret = liftoff_output_apply(crtc->liftoff, req, flags);
#endif
if (ret != 0) {
wlr_drm_conn_log(conn, test_only ? WLR_DEBUG : WLR_ERROR,
"liftoff_output_apply failed: %s", strerror(-ret));
Expand Down
1 change: 1 addition & 0 deletions backend/drm/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ wlr_files += files(

if libliftoff.found()
wlr_files += files('libliftoff.c')
internal_config.set10('HAVE_LIBLIFTOFF_0_5', libliftoff.version().version_compare('>=0.5.0'))
endif

features += { 'drm-backend': true }
Expand Down
10 changes: 4 additions & 6 deletions backend/libinput/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,11 @@ static bool backend_start(struct wlr_backend *wlr_backend) {

int libinput_fd = libinput_get_fd(backend->libinput_context);

handle_libinput_readable(libinput_fd, WL_EVENT_READABLE, backend);
if (!env_parse_bool("WLR_LIBINPUT_NO_DEVICES") && wl_list_empty(&backend->devices)) {
handle_libinput_readable(libinput_fd, WL_EVENT_READABLE, backend);
if (wl_list_empty(&backend->devices)) {
wlr_log(WLR_ERROR, "libinput initialization failed, no input devices");
wlr_log(WLR_ERROR, "Set WLR_LIBINPUT_NO_DEVICES=1 to suppress this check");
return false;
}
wlr_log(WLR_ERROR, "libinput initialization failed, no input devices");
wlr_log(WLR_ERROR, "Set WLR_LIBINPUT_NO_DEVICES=1 to suppress this check");
return false;
}

struct wl_event_loop *event_loop =
Expand Down
3 changes: 3 additions & 0 deletions backend/wayland/tablet_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ static void handle_pad_added(void *data,
struct wlr_wl_seat *seat = data;
if (seat->zwp_tablet_pad_v2 != NULL) {
wlr_log(WLR_ERROR, "zwp_tablet_pad_v2 is already present");
zwp_tablet_pad_v2_destroy(zwp_tablet_pad_v2);
return;
}

Expand Down Expand Up @@ -780,6 +781,7 @@ static void handle_tool_added(void *data,
struct wlr_wl_seat *seat = data;
if (seat->zwp_tablet_tool_v2 != NULL) {
wlr_log(WLR_ERROR, "zwp_tablet_tool_v2 already present");
zwp_tablet_tool_v2_destroy(zwp_tablet_tool_v2);
return;
}

Expand Down Expand Up @@ -861,6 +863,7 @@ static void handle_tab_added(void *data,
struct wlr_wl_seat *seat = data;
if (seat->zwp_tablet_v2 != NULL) {
wlr_log(WLR_ERROR, "zwp_tablet_v2 already present");
zwp_tablet_v2_destroy(zwp_tablet_v2);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions backend/x11/input_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void handle_x11_xinput_event(struct wlr_x11_backend *x11,
}

wlr_keyboard_notify_modifiers(&x11->keyboard, ev->mods.base,
ev->mods.latched, ev->mods.locked, ev->mods.effective);
ev->mods.latched, ev->mods.locked, ev->group.effective);
send_key_event(x11, ev->detail - 8, WL_KEYBOARD_KEY_STATE_PRESSED, ev->time);
x11->time = ev->time;
break;
Expand All @@ -139,7 +139,7 @@ void handle_x11_xinput_event(struct wlr_x11_backend *x11,
(xcb_input_key_release_event_t *)event;

wlr_keyboard_notify_modifiers(&x11->keyboard, ev->mods.base,
ev->mods.latched, ev->mods.locked, ev->mods.effective);
ev->mods.latched, ev->mods.locked, ev->group.effective);
send_key_event(x11, ev->detail - 8, WL_KEYBOARD_KEY_STATE_RELEASED, ev->time);
x11->time = ev->time;
break;
Expand Down
5 changes: 5 additions & 0 deletions include/types/wlr_xdg_shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure(
void handle_xdg_toplevel_ack_configure(struct wlr_xdg_toplevel *toplevel,
struct wlr_xdg_toplevel_configure *configure);

/**
* Returns true if a positioner is complete.
*/
bool wlr_xdg_positioner_is_complete(struct wlr_xdg_positioner *positioner);

#endif
5 changes: 3 additions & 2 deletions include/wlr/types/wlr_compositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,9 @@ bool wlr_surface_has_buffer(struct wlr_surface *surface);
struct wlr_texture *wlr_surface_get_texture(struct wlr_surface *surface);

/**
* Get the root of the subsurface tree for this surface. Can return NULL if
* a surface in the tree has been destroyed.
* Get the root of the subsurface tree for this surface.
* May return the same surface passed if that surface is the root.
* Never returns NULL.
*/
struct wlr_surface *wlr_surface_get_root_surface(struct wlr_surface *surface);

Expand Down
4 changes: 4 additions & 0 deletions include/xwayland/xwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,8 @@ char *xwm_get_atom_name(struct wlr_xwm *xwm, xcb_atom_t atom);
bool xwm_atoms_contains(struct wlr_xwm *xwm, xcb_atom_t *atoms,
size_t num_atoms, enum atom_name needle);

xcb_void_cookie_t xwm_send_event_with_size(xcb_connection_t *c,
uint8_t propagate, xcb_window_t destination,
uint32_t event_mask, const void *event, uint32_t length);

#endif
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
'wlroots',
'c',
version: '0.17.2',
version: '0.17.4',
license: 'MIT',
meson_version: '>=0.59.0',
default_options: [
Expand Down
6 changes: 5 additions & 1 deletion render/gles2/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,11 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl) {
load_gl_proc(&renderer->procs.glQueryCounterEXT, "glQueryCounterEXT");
load_gl_proc(&renderer->procs.glGetQueryObjectivEXT, "glGetQueryObjectivEXT");
load_gl_proc(&renderer->procs.glGetQueryObjectui64vEXT, "glGetQueryObjectui64vEXT");
load_gl_proc(&renderer->procs.glGetInteger64vEXT, "glGetInteger64vEXT");
if (eglGetProcAddress("glGetInteger64vEXT")) {
load_gl_proc(&renderer->procs.glGetInteger64vEXT, "glGetInteger64vEXT");
} else {
load_gl_proc(&renderer->procs.glGetInteger64vEXT, "glGetInteger64v");
}
}

if (renderer->exts.KHR_debug) {
Expand Down
118 changes: 79 additions & 39 deletions render/pixman/pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
return;
}

pixman_op_t op = get_pixman_blending(options->blend_mode);
pixman_image_set_clip_region32(buffer->image, (pixman_region32_t *)options->clip);

struct wlr_fbox src_fbox;
wlr_render_texture_options_get_src_box(options, &src_fbox);
struct wlr_box src_box = {
Expand All @@ -67,14 +70,14 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
});
}

struct wlr_box orig_box;
wlr_box_transform(&orig_box, &dst_box, options->transform,
// Rotate the source size into destination coordinates
struct wlr_box src_box_transformed;
wlr_box_transform(&src_box_transformed, &src_box, options->transform,
buffer->buffer->width, buffer->buffer->height);

int32_t dest_x, dest_y, width, height;
if (options->transform != WL_OUTPUT_TRANSFORM_NORMAL ||
orig_box.width != src_box.width ||
orig_box.height != src_box.height) {
src_box_transformed.width != dst_box.width ||
src_box_transformed.height != dst_box.height) {
// Cosinus/sinus values are extact integers for enum wl_output_transform entries
int tr_cos = 1, tr_sin = 0, tr_x = 0, tr_y = 0;
switch (options->transform) {
Expand All @@ -85,70 +88,107 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
tr_cos = 0;
tr_sin = 1;
tr_x = buffer->buffer->height;
tr_y = src_box.width;
break;
case WL_OUTPUT_TRANSFORM_180:
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
tr_cos = -1;
tr_sin = 0;
tr_x = buffer->buffer->width;
tr_y = buffer->buffer->height;
tr_x = src_box.width;
tr_y = src_box.height;
break;
case WL_OUTPUT_TRANSFORM_270:
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
tr_cos = 0;
tr_sin = -1;
tr_y = buffer->buffer->width;
tr_x = src_box.height;
break;
}

// Pixman transforms are generally the opposite of what you expect because they
// apply to the coordinate system rather than the image. The comments here
// refer to what happens to the image, so all the code between
// pixman_transform_init_identity() and pixman_image_set_transform() is probably
// best read backwards. Also this means translations are in the opposite
// direction, imagine them as moving the origin around rather than moving the
// image.
//
// Beware that this doesn't work quite the same as wp_viewporter: We apply crop
// before transform and scale, whereas it defines crop in post-transform-scale
// coordinates. But this only applies to internal wlroots code - the viewporter
// extension code makes sure that to clients everything works as it should.

struct pixman_transform transform;
pixman_transform_init_identity(&transform);

// Apply scaling to get to the dst_box size. Because the scaling is applied last
// it depends on the whether the rotation swapped width and height, which is why
// we use src_box_transformed instead of src_box.
pixman_transform_scale(&transform, NULL,
pixman_double_to_fixed(src_box_transformed.width / (double)dst_box.width),
pixman_double_to_fixed(src_box_transformed.height / (double)dst_box.height));

// pixman rotates about the origin which again leaves everything outside of the
// viewport. Translate the result so that its new top-left corner is back at the
// origin.
pixman_transform_translate(&transform, NULL,
-pixman_int_to_fixed(tr_x), -pixman_int_to_fixed(tr_y));

// Apply the rotation
pixman_transform_rotate(&transform, NULL,
pixman_int_to_fixed(tr_cos), pixman_int_to_fixed(tr_sin));

// Apply flip before rotation
if (options->transform >= WL_OUTPUT_TRANSFORM_FLIPPED) {
// The flip leaves everything left of the Y axis which is outside the
// viewport. So translate everything back into the viewport.
pixman_transform_translate(&transform, NULL,
-pixman_int_to_fixed(src_box.width), pixman_int_to_fixed(0));
// Flip by applying a scale of -1 to the X axis
pixman_transform_scale(&transform, NULL,
pixman_int_to_fixed(-1), pixman_int_to_fixed(1));
}

// Apply the translation for source crop so the origin is now at the top-left of
// the region we're actually using. Do this last so all the other transforms
// apply on top of this.
pixman_transform_translate(&transform, NULL,
pixman_int_to_fixed(tr_x), pixman_int_to_fixed(tr_y));
pixman_transform_translate(&transform, NULL,
-pixman_int_to_fixed(orig_box.x), -pixman_int_to_fixed(orig_box.y));
pixman_transform_scale(&transform, NULL,
pixman_double_to_fixed(src_box.width / (double)orig_box.width),
pixman_double_to_fixed(src_box.height / (double)orig_box.height));
pixman_int_to_fixed(src_box.x), pixman_int_to_fixed(src_box.y));

pixman_image_set_transform(texture->image, &transform);

dest_x = dest_y = 0;
width = buffer->buffer->width;
height = buffer->buffer->height;
switch (options->filter_mode) {
case WLR_SCALE_FILTER_BILINEAR:
pixman_image_set_filter(texture->image, PIXMAN_FILTER_BILINEAR, NULL, 0);
break;
case WLR_SCALE_FILTER_NEAREST:
pixman_image_set_filter(texture->image, PIXMAN_FILTER_NEAREST, NULL, 0);
break;
}

// Now composite the result onto the pass buffer. We specify a source origin of 0,0
// because the x,y part of source crop is already done using the transform. The
// width,height part of source crop is done here by the width and height we pass:
// because of the scaling, cropping at the end by dst_box.{width,height} is
// equivalent to if we cropped at the start by src_box.{width,height}.
pixman_image_composite32(op, texture->image, mask, buffer->image,
0, 0, // source x,y
0, 0, // mask x,y
dst_box.x, dst_box.y, // dest x,y
dst_box.width, dst_box.height // composite width,height
);

pixman_image_set_transform(texture->image, NULL);
} else {
// No transforms or crop needed, just a straight blit from the source
pixman_image_set_transform(texture->image, NULL);
dest_x = dst_box.x;
dest_y = dst_box.y;
width = src_box.width;
height = src_box.height;
pixman_image_composite32(op, texture->image, mask, buffer->image,
src_box.x, src_box.y, 0, 0, dst_box.x, dst_box.y,
src_box.width, src_box.height);
}

switch (options->filter_mode) {
case WLR_SCALE_FILTER_BILINEAR:
pixman_image_set_filter(texture->image, PIXMAN_FILTER_BILINEAR, NULL, 0);
break;
case WLR_SCALE_FILTER_NEAREST:
pixman_image_set_filter(texture->image, PIXMAN_FILTER_NEAREST, NULL, 0);
break;
}

pixman_op_t op = get_pixman_blending(options->blend_mode);

pixman_image_set_clip_region32(buffer->image, (pixman_region32_t *)options->clip);
pixman_image_composite32(op, texture->image, mask,
buffer->image, src_box.x, src_box.y, 0, 0, dest_x, dest_y,
width, height);
pixman_image_set_clip_region32(buffer->image, NULL);

pixman_image_set_transform(texture->image, NULL);

if (texture->buffer != NULL) {
wlr_buffer_end_data_ptr_access(texture->buffer);
}
Expand Down
22 changes: 13 additions & 9 deletions render/vulkan/pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ static float color_to_linear(float non_linear) {
non_linear / 12.92;
}

static float color_to_linear_premult(float non_linear, float alpha) {
return (alpha == 0) ? 0 : color_to_linear(non_linear / alpha) * alpha;
}

static void mat3_to_mat4(const float mat3[9], float mat4[4][4]) {
memset(mat4, 0, sizeof(float) * 16);
mat4[0][0] = mat3[0];
Expand Down Expand Up @@ -139,9 +143,7 @@ static bool render_pass_submit(struct wlr_render_pass *wlr_pass) {
size_t idx = 0;
uint32_t render_wait_len = 0;
wl_list_for_each_safe(texture, tmp_tex, &renderer->foreign_textures, foreign_link) {
VkImageLayout src_layout = VK_IMAGE_LAYOUT_GENERAL;
if (!texture->transitioned) {
src_layout = VK_IMAGE_LAYOUT_UNDEFINED;
texture->transitioned = true;
}

Expand All @@ -151,7 +153,7 @@ static bool render_pass_submit(struct wlr_render_pass *wlr_pass) {
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT,
.dstQueueFamilyIndex = renderer->dev->queue_family,
.image = texture->image,
.oldLayout = src_layout,
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
.srcAccessMask = 0, // ignored anyways
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
Expand Down Expand Up @@ -439,9 +441,9 @@ static void render_pass_add_rect(struct wlr_render_pass *wlr_pass,
// colors in linear space as well (and vulkan then automatically
// does the conversion for out sRGB render targets).
float linear_color[] = {
color_to_linear(options->color.r),
color_to_linear(options->color.g),
color_to_linear(options->color.b),
color_to_linear_premult(options->color.r, options->color.a),
color_to_linear_premult(options->color.g, options->color.a),
color_to_linear_premult(options->color.b, options->color.a),
options->color.a, // no conversion for alpha
};

Expand Down Expand Up @@ -565,9 +567,6 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
wlr_render_texture_options_get_dst_box(options, &dst_box);
float alpha = wlr_render_texture_options_get_alpha(options);

pixman_region32_t clip;
get_clip_region(pass, options->clip, &clip);

float proj[9], matrix[9];
wlr_matrix_identity(proj);
wlr_matrix_project_box(matrix, &dst_box, options->transform, 0, proj);
Expand Down Expand Up @@ -620,6 +619,9 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(vert_pcr_data), sizeof(float),
&alpha);

pixman_region32_t clip;
get_clip_region(pass, options->clip, &clip);

int clip_rects_len;
const pixman_box32_t *clip_rects = pixman_region32_rectangles(&clip, &clip_rects_len);
for (int i = 0; i < clip_rects_len; i++) {
Expand All @@ -642,6 +644,8 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
}

texture->last_used_cb = pass->command_buffer;

pixman_region32_fini(&clip);
}

static const struct wlr_render_pass_impl render_pass_impl = {
Expand Down
2 changes: 2 additions & 0 deletions render/vulkan/pixel_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
free(modp.pDrmFormatModifierProperties);
free(props->dmabuf.render_mods);
free(props->dmabuf.texture_mods);
props->dmabuf.render_mods = NULL;
props->dmabuf.texture_mods = NULL;
return false;
}

Expand Down
Loading

0 comments on commit bb04c74

Please sign in to comment.