mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-29 16:05:59 +01:00
Merge pull request #862 from emersion/renderer-scissor-upside-down
Make wlr_renderer_scissor take normal coords instead of upside-down ones
This commit is contained in:
commit
63763d3279
4 changed files with 17 additions and 9 deletions
|
@ -38,6 +38,8 @@ struct wlr_gles2_renderer {
|
||||||
GLuint tex_rgbx;
|
GLuint tex_rgbx;
|
||||||
GLuint tex_ext;
|
GLuint tex_ext;
|
||||||
} shaders;
|
} shaders;
|
||||||
|
|
||||||
|
uint32_t viewport_width, viewport_height;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum wlr_gles2_texture_type {
|
enum wlr_gles2_texture_type {
|
||||||
|
|
|
@ -31,11 +31,14 @@ static struct wlr_gles2_renderer *gles2_get_renderer_in_context(
|
||||||
|
|
||||||
static void gles2_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
|
static void gles2_begin(struct wlr_renderer *wlr_renderer, uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
|
struct wlr_gles2_renderer *renderer =
|
||||||
gles2_get_renderer_in_context(wlr_renderer);
|
gles2_get_renderer_in_context(wlr_renderer);
|
||||||
|
|
||||||
GLES2_DEBUG_PUSH;
|
GLES2_DEBUG_PUSH;
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
renderer->viewport_width = width;
|
||||||
|
renderer->viewport_height = height;
|
||||||
|
|
||||||
// enable transparency
|
// enable transparency
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
@ -64,11 +67,16 @@ static void gles2_clear(struct wlr_renderer *wlr_renderer,
|
||||||
|
|
||||||
static void gles2_scissor(struct wlr_renderer *wlr_renderer,
|
static void gles2_scissor(struct wlr_renderer *wlr_renderer,
|
||||||
struct wlr_box *box) {
|
struct wlr_box *box) {
|
||||||
|
struct wlr_gles2_renderer *renderer =
|
||||||
gles2_get_renderer_in_context(wlr_renderer);
|
gles2_get_renderer_in_context(wlr_renderer);
|
||||||
|
|
||||||
GLES2_DEBUG_PUSH;
|
GLES2_DEBUG_PUSH;
|
||||||
if (box != NULL) {
|
if (box != NULL) {
|
||||||
glScissor(box->x, box->y, box->width, box->height);
|
struct wlr_box gl_box;
|
||||||
|
wlr_box_transform(box, WL_OUTPUT_TRANSFORM_FLIPPED_180,
|
||||||
|
renderer->viewport_width, renderer->viewport_height, &gl_box);
|
||||||
|
|
||||||
|
glScissor(gl_box.x, gl_box.y, gl_box.width, gl_box.height);
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
|
|
@ -177,9 +177,8 @@ static void scissor_output(struct roots_output *output, pixman_box32_t *rect) {
|
||||||
wlr_output_transformed_resolution(output->wlr_output, &ow, &oh);
|
wlr_output_transformed_resolution(output->wlr_output, &ow, &oh);
|
||||||
|
|
||||||
// Scissor is in renderer coordinates, ie. upside down
|
// Scissor is in renderer coordinates, ie. upside down
|
||||||
enum wl_output_transform transform = wlr_output_transform_compose(
|
enum wl_output_transform transform =
|
||||||
wlr_output_transform_invert(wlr_output->transform),
|
wlr_output_transform_invert(wlr_output->transform);
|
||||||
WL_OUTPUT_TRANSFORM_FLIPPED_180);
|
|
||||||
wlr_box_transform(&box, transform, ow, oh, &box);
|
wlr_box_transform(&box, transform, ow, oh, &box);
|
||||||
|
|
||||||
wlr_renderer_scissor(renderer, &box);
|
wlr_renderer_scissor(renderer, &box);
|
||||||
|
|
|
@ -339,9 +339,8 @@ static void output_scissor(struct wlr_output *output, pixman_box32_t *rect) {
|
||||||
wlr_output_transformed_resolution(output, &ow, &oh);
|
wlr_output_transformed_resolution(output, &ow, &oh);
|
||||||
|
|
||||||
// Scissor is in renderer coordinates, ie. upside down
|
// Scissor is in renderer coordinates, ie. upside down
|
||||||
enum wl_output_transform transform = wlr_output_transform_compose(
|
enum wl_output_transform transform =
|
||||||
wlr_output_transform_invert(output->transform),
|
wlr_output_transform_invert(output->transform);
|
||||||
WL_OUTPUT_TRANSFORM_FLIPPED_180);
|
|
||||||
wlr_box_transform(&box, transform, ow, oh, &box);
|
wlr_box_transform(&box, transform, ow, oh, &box);
|
||||||
|
|
||||||
wlr_renderer_scissor(renderer, &box);
|
wlr_renderer_scissor(renderer, &box);
|
||||||
|
|
Loading…
Reference in a new issue