Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

wlr_render_rect improvement proposal #2258

Closed
icedman opened this issue Jun 5, 2020 · 7 comments
Closed

wlr_render_rect improvement proposal #2258

icedman opened this issue Jun 5, 2020 · 7 comments

Comments

@icedman
Copy link

icedman commented Jun 5, 2020

This is more of a request or a proposal for wlr_render_rect:

  1. it could accept 4 colors - one for each of the vertices
  2. it would respect the alpha component of the color provided

Rationale:

With the above changes, we could render a lot more "styled" decorations without resorting to cairo and caching textures.
#1 allows for simple gradients
#2 allows for bevels (with some overdraw).
#2 also allows for recoloring textures with gradient overlays.

Why I personally want these changes : I'm trying to recreate the blackbox/fluxbox on wlroots from the tinywl code. Currently, I have to resort to cairo for most of the rendering.

But I think even sway could achieve more styling with the two simple changes.

@emersion
Copy link
Member

emersion commented Jun 5, 2020

We kept the renderer to the bare minimum because there'll always be that "one last feature" compositors need. We prefer compositors to directly use OpenGL when they need something more complicated.

@icedman
Copy link
Author

icedman commented Jun 5, 2020

This one at least "it would respect the alpha component of the color provided"
..given that the function accepts float[static 4]

@emersion
Copy link
Member

emersion commented Jun 5, 2020

This one would be a bug. IIRC it works correctly when we use it in Sway?

@icedman
Copy link
Author

icedman commented Jun 6, 2020

I did a quick test with the tinywl code.
Alpha component doesn't affect wl_render_rect. I'm not sure with sway.

for(int i=0;i<10;i++) {
  float box_color[4] = {1.0, 0.0, 1.0, 0.1*i};
    struct wlr_box box = {
      .x = 105*i,
      .y = 0,
      .width = 100,
      .height = 100
    };
  wlr_render_rect(renderer, &box, box_color, output->wlr_output->transform_matrix);
}

https://raw.githubusercontent.com/icedman/tinybox/master/screenshots/tinywl-varying-alpha.png

@ammen99
Copy link
Member

ammen99 commented Jun 6, 2020

I think the source color needs to have premultiplied alpha, right @emersion ?

@emersion
Copy link
Member

emersion commented Jun 6, 2020

Oh, good point, forgot about pre-multiplied alpha. @ascent12 Should we handle this in the renderer?

@emersion
Copy link
Member

Closing because the original question is answered. Feel free to open a separate bug report for the alpha issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants