mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
Use pre-multiplied colors by default
wlr_scene_rects expect their color to be pre-multiplied while cairo_set_source_rgba() expects them to not be pre-multiplied. With this patch we now use premultiplied colors internally by default and then reverse it when setting cairo colors. This ensures the titlebar uses a consistent color in case it was defined with some transparency by the user. Fixes: #1684
This commit is contained in:
parent
33859138cf
commit
c35ba02ffa
3 changed files with 20 additions and 4 deletions
|
|
@ -85,7 +85,19 @@ draw_cairo_border(cairo_t *cairo, struct wlr_fbox fbox, double line_width)
|
|||
void
|
||||
set_cairo_color(cairo_t *cairo, const float *c)
|
||||
{
|
||||
cairo_set_source_rgba(cairo, c[0], c[1], c[2], c[3]);
|
||||
/*
|
||||
* We are dealing with pre-multiplied colors
|
||||
* but cairo expects unmultiplied colors here
|
||||
*/
|
||||
float alpha = c[3];
|
||||
|
||||
if (alpha == 0.0f) {
|
||||
cairo_set_source_rgba(cairo, 0, 0, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
cairo_set_source_rgba(cairo, c[0] / alpha, c[1] / alpha,
|
||||
c[2] / alpha, alpha);
|
||||
}
|
||||
|
||||
struct surface_context
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue