diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2023-06-26 13:51:04 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2023-06-29 13:38:23 +0000 |
| commit | 0a5073f5703e89cfa4219d5b532cb134f9def6d5 (patch) | |
| tree | 4f083a5222aa346943dfd9ec8315a6e26c5e3184 /render.c | |
| parent | render: maybe_resize(): convert local variable ‘scale’ to float (diff) | |
wayland: add wayl_surface_scale(), and wayl_win_scale()
These functions scale a surface+buffer.
For now, only using the legacy scaling
method (wl_surface_set_buffer_scale()).
Diffstat (limited to 'render.c')
| -rw-r--r-- | render.c | 47 |
1 files changed, 13 insertions, 34 deletions
@@ -1691,8 +1691,8 @@ render_overlay(struct terminal *term) &(pixman_rectangle16_t){0, 0, term->width, term->height}); quirk_weston_subsurface_desync_on(overlay->sub); + wayl_surface_scale(term->wl, overlay->surf, term->scale); wl_subsurface_set_position(overlay->sub, 0, 0); - wl_surface_set_buffer_scale(overlay->surf, term->scale); wl_surface_attach(overlay->surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer( @@ -1830,12 +1830,9 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx) static void csd_commit(struct terminal *term, struct wl_surface *surf, struct buffer *buf) { - xassert(buf->width % (int)term->scale == 0); - xassert(buf->height % (int)term->scale == 0); - + wayl_surface_scale(term->wl, surf, term->scale); wl_surface_attach(surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer(surf, 0, 0, buf->width, buf->height); - wl_surface_set_buffer_scale(surf, term->scale); wl_surface_commit(surf); } @@ -1926,13 +1923,10 @@ render_osd(struct terminal *term, pixman_image_unref(src); pixman_image_set_clip_region32(buf->pix[0], NULL); - xassert(buf->width % (int)term->scale == 0); - xassert(buf->height % (int)term->scale == 0); - quirk_weston_subsurface_desync_on(sub_surf); + wayl_surface_scale(term->wl, surf, term->scale); wl_surface_attach(surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer(surf, 0, 0, buf->width, buf->height); - wl_surface_set_buffer_scale(surf, term->scale); struct wl_region *region = wl_compositor_create_region(term->wl->compositor); if (region != NULL) { @@ -1955,9 +1949,6 @@ render_csd_title(struct terminal *term, const struct csd_data *info, if (info->width == 0 || info->height == 0) return; - xassert(info->width % (int)term->scale == 0); - xassert(info->height % (int)term->scale == 0); - uint32_t bg = term->conf->csd.color.title_set ? term->conf->csd.color.title : 0xffu << 24 | term->conf->colors.fg; @@ -2000,9 +1991,6 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx, if (info->width == 0 || info->height == 0) return; - xassert(info->width % (int)term->scale == 0); - xassert(info->height % (int)term->scale == 0); - { pixman_color_t color = color_hex_to_pixman_with_alpha(0, 0); render_csd_part(term, surf, buf, info->width, info->height, &color); @@ -2288,9 +2276,6 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx, if (info->width == 0 || info->height == 0) return; - xassert(info->width % (int)term->scale == 0); - xassert(info->height % (int)term->scale == 0); - uint32_t _color; uint16_t alpha = 0xffff; bool is_active = false; @@ -3032,7 +3017,7 @@ grid_render(struct terminal *term) term->window->frame_callback = wl_surface_frame(term->window->surface); wl_callback_add_listener(term->window->frame_callback, &frame_listener, term); - wl_surface_set_buffer_scale(term->window->surface, term->scale); + wayl_win_scale(term->window); if (term->wl->presentation != NULL && term->conf->presentation_timings) { struct timespec commit_time; @@ -3066,9 +3051,6 @@ grid_render(struct terminal *term) term->window->surface, 0, 0, INT32_MAX, INT32_MAX); } - xassert(buf->width % (int)term->scale == 0); - xassert(buf->height % (int)term->scale == 0); - wl_surface_attach(term->window->surface, buf->wl_buf, 0, 0); wl_surface_commit(term->window->surface); } @@ -3132,17 +3114,17 @@ render_search_box(struct terminal *term) const size_t wanted_visible_cells = max(20, total_cells); xassert(term->scale >= 1); - const int scale = round(term->scale); + const int rounded_scale = round(term->scale); - const size_t margin = 3 * scale; + const size_t margin = 3 * rounded_scale; const size_t width = term->width - 2 * margin; const size_t visible_width = min( term->width - 2 * margin, - (2 * margin + wanted_visible_cells * term->cell_width + scale - 1) / scale * scale); + (2 * margin + wanted_visible_cells * term->cell_width + rounded_scale - 1) / rounded_scale * rounded_scale); const size_t height = min( term->height - 2 * margin, - (2 * margin + 1 * term->cell_height + scale - 1) / scale * scale); + (2 * margin + 1 * term->cell_height + rounded_scale - 1) / rounded_scale * rounded_scale); const size_t visible_cells = (visible_width - 2 * margin) / term->cell_width; size_t glyph_offset = term->render.search_glyph_offset; @@ -3389,15 +3371,12 @@ render_search_box(struct terminal *term) /* TODO: this is only necessary on a window resize */ wl_subsurface_set_position( term->window->search.sub, - margin / scale, - max(0, (int32_t)term->height - height - margin) / scale); - - xassert(buf->width % scale == 0); - xassert(buf->height % scale == 0); + margin / term->scale, + max(0, (int32_t)term->height - height - margin) / term->scale); + wayl_surface_scale(term->wl, term->window->search.surf, term->scale); wl_surface_attach(term->window->search.surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer(term->window->search.surf, 0, 0, width, height); - wl_surface_set_buffer_scale(term->window->search.surf, scale); struct wl_region *region = wl_compositor_create_region(term->wl->compositor); if (region != NULL) { @@ -4284,6 +4263,8 @@ render_xcursor_update(struct seat *seat) const float scale = seat->pointer.scale; struct wl_cursor_image *image = seat->pointer.cursor->images[0]; + wayl_surface_scale(seat->wayl, seat->pointer.surface, scale); + wl_surface_attach( seat->pointer.surface, wl_cursor_image_get_buffer(image), 0, 0); @@ -4295,8 +4276,6 @@ render_xcursor_update(struct seat *seat) wl_surface_damage_buffer( seat->pointer.surface, 0, 0, INT32_MAX, INT32_MAX); - wl_surface_set_buffer_scale(seat->pointer.surface, scale); - xassert(seat->pointer.xcursor_callback == NULL); seat->pointer.xcursor_callback = wl_surface_frame(seat->pointer.surface); wl_callback_add_listener(seat->pointer.xcursor_callback, &xcursor_listener, seat); |
