Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1c051b6 authored by Jason Sams's avatar Jason Sams
Browse files

Fix bug in grain.

Compare with 0 was done against unsigned which did not
correctly clamp.

Change-Id: I6dbff36190c279961017e57db3aaba51c60a0ad3
parent 19e1086d
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -43,10 +43,10 @@ int32_t gHeight;


rs_allocation gBlendSource;
rs_allocation gBlendSource;
void blend9(uchar *out, uint32_t x, uint32_t y) {
void blend9(uchar *out, uint32_t x, uint32_t y) {
    uint32_t x1 = min(x+1, (uint32_t)gWidth);
    uint32_t x1 = min((int32_t)x+1, (int32_t)gWidth);
    uint32_t x2 = max(x-1, (uint32_t)0);
    uint32_t x2 = max((int32_t)x-1, (int32_t)0);
    uint32_t y1 = min(y+1, (uint32_t)gHeight);
    uint32_t y1 = min((int32_t)y+1, (int32_t)gHeight);
    uint32_t y2 = max(y-1, (uint32_t)0);
    uint32_t y2 = max((int32_t)y-1, (int32_t)0);


    uint p00 = 56 *  ((uchar *)rsGetElementAt(gBlendSource, x1, y1))[0];
    uint p00 = 56 *  ((uchar *)rsGetElementAt(gBlendSource, x1, y1))[0];
    uint p01 = 114 * ((uchar *)rsGetElementAt(gBlendSource, x, y1))[0];
    uint p01 = 114 * ((uchar *)rsGetElementAt(gBlendSource, x, y1))[0];