Changeset 4fff3c7 in mainline for uspace/lib/softrend/compose.c


Ignore:
Timestamp:
2018-10-19T07:51:31Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2cea4c58
Parents:
bae43dc
git-author:
Maurizio Lombardi <mlombard@…> (2018-10-18 18:55:40)
git-committer:
Jakub Jermar <jakub@…> (2018-10-19 07:51:31)
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

    rbae43dc r4fff3c7  
    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.