mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-02-26 01:40:35 -05:00
render/pass: implement antialiasing for fractional coordinates
Signed-off-by: Loukas Agorgianitis <loukas@agorgianitis.com>
This commit is contained in:
parent
5a49f2ae14
commit
e92d8a7a53
11 changed files with 170 additions and 20 deletions
|
|
@ -1,6 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <pixman.h>
|
||||
#include <stdbool.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <wlr/render/drm_syncobj.h>
|
||||
|
|
@ -77,7 +79,12 @@ out:
|
|||
|
||||
static void render(const struct wlr_fbox *box, const pixman_region32_t *clip, GLint attrib) {
|
||||
pixman_region32_t region;
|
||||
pixman_region32_init_rect(®ion, round(box->x), round(box->y), round(box->width), round(box->height));
|
||||
// Expand region to include edge fragments for AA
|
||||
pixman_region32_init_rect(®ion,
|
||||
floor(box->x),
|
||||
floor(box->y),
|
||||
ceil(box->x + box->width) - floor(box->x),
|
||||
ceil(box->y + box->height) - floor(box->y));
|
||||
|
||||
if (clip) {
|
||||
pixman_region32_intersect(®ion, ®ion, clip);
|
||||
|
|
@ -247,6 +254,12 @@ static void render_pass_add_texture(struct wlr_render_pass *wlr_pass,
|
|||
set_proj_matrix(shader->proj, pass->projection_matrix, &dst_box);
|
||||
set_tex_matrix(shader->tex_proj, options->transform, &src_box);
|
||||
|
||||
glUniform4f(shader->dst_bounds,
|
||||
(float)dst_box.x,
|
||||
(float)dst_box.y,
|
||||
(float)(dst_box.x + dst_box.width),
|
||||
(float)(dst_box.y + dst_box.height));
|
||||
|
||||
render(&dst_box, options->clip, shader->pos_attrib);
|
||||
|
||||
glBindTexture(texture->target, 0);
|
||||
|
|
@ -270,6 +283,12 @@ static void render_pass_add_rect(struct wlr_render_pass *wlr_pass,
|
|||
set_proj_matrix(renderer->shaders.quad.proj, pass->projection_matrix, &box);
|
||||
glUniform4f(renderer->shaders.quad.color, color->r, color->g, color->b, color->a);
|
||||
|
||||
glUniform4f(renderer->shaders.quad.dst_bounds,
|
||||
(float)box.x,
|
||||
(float)box.y,
|
||||
(float)(box.x + box.width),
|
||||
(float)(box.y + box.height));
|
||||
|
||||
render(&box, options->clip, renderer->shaders.quad.pos_attrib);
|
||||
|
||||
pop_gles2_debug(renderer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue