Changeset d723a80 in mainline


Ignore:
Timestamp:
2018-10-18T18:55:40Z (6 years ago)
Author:
Maurizio Lombardi <mlombard@…>
Children:
14ad75c
Parents:
8a1afd2
Message:

compositor: fix the over operator

If a vterm is on top of a vcalc and you decrease the opacity of the
first (or rotate/resize it), the result composite image is obviously wrong
(the vcalc's buttons become black…).

This is because of some mistakes in the over operator's implementation.
This patch fixes the problem by reimplementing it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/softrend/compose.c

    r8a1afd2 rd723a80  
    5353pixel_t compose_over(pixel_t fg, pixel_t bg)
    5454{
    55         uint16_t mf;
    56         uint16_t mb;
    57 
    5855        uint8_t res_a;
    5956        uint8_t res_r;
    6057        uint8_t res_g;
    6158        uint8_t res_b;
     59        uint32_t res_a_inv;
    6260
    63         res_a = (ALPHA(fg) * 255 + (255 - ALPHA(fg)) * ALPHA(bg)) / 255;
    64         mf = ALPHA(fg);
    65         mb = (255 * 255 - ALPHA(fg) * ALPHA(bg)) / 255;
     61        res_a_inv = ALPHA(bg) * (255 - ALPHA(fg));
     62        res_a = ALPHA(fg) + (res_a_inv / 255);
    6663
    67         res_r = (mf * RED(fg) + mb * RED(bg)) / 255;
    68         res_g = (mf * GREEN(fg) + mb * GREEN(bg)) / 255;
    69         res_b = (mf * BLUE(fg) + mb * BLUE(bg)) / 255;
     64        res_r = (RED(fg) * ALPHA(fg) / 255) + (RED(bg) * res_a_inv) / (255 * 255);
     65        res_g = (GREEN(fg) * ALPHA(fg) / 255) + (GREEN(bg) * res_a_inv) / (255 * 255);
     66        res_b = (BLUE(fg) * ALPHA(fg) / 255) + (BLUE(bg) * res_a_inv) / (255 * 255);
    7067
    7168        return PIXEL(res_a, res_r, res_g, res_b);
Note: See TracChangeset for help on using the changeset viewer.