From ffb875ed17ab9f7a616a7360301888611ecf8a91 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 1 Apr 2021 12:10:46 +0200 Subject: [PATCH] fix (draw_mask) fix << on negative value Fixes https://github.com/lvgl/lvgl/issues/2144#issuecomment-811764356 --- src/draw/lv_draw_mask.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/draw/lv_draw_mask.c b/src/draw/lv_draw_mask.c index cebec442d..a9e708993 100644 --- a/src/draw/lv_draw_mask.c +++ b/src/draw/lv_draw_mask.c @@ -490,6 +490,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_b lv_coord_t len, lv_draw_mask_line_param_t * p) { + int32_t y_at_x; y_at_x = (int32_t)((int32_t)p->yx_steep * abs_x) >> 10; @@ -538,9 +539,12 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_b } } + if(abs_y < 0) { + printf("asd\n"); + } int32_t xe; - if(p->yx_steep > 0) xe = ((abs_y << 8) * p->xy_steep) >> 10; - else xe = (((abs_y + 1) << 8) * p->xy_steep) >> 10; + if(p->yx_steep > 0) xe = ((abs_y * 256) * p->xy_steep) >> 10; + else xe = (((abs_y + 1) * 256) * p->xy_steep) >> 10; int32_t xei = xe >> 8; int32_t xef = xe & 0xFF; @@ -633,12 +637,12 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_ } /*X start*/ - int32_t xs = ((abs_y << 8) * p->xy_steep) >> 10; + int32_t xs = ((abs_y * 256) * p->xy_steep) >> 10; int32_t xsi = xs >> 8; int32_t xsf = xs & 0xFF; /*X end*/ - int32_t xe = (((abs_y + 1) << 8) * p->xy_steep) >> 10; + int32_t xe = (((abs_y + 1) * 256) * p->xy_steep) >> 10; int32_t xei = xe >> 8; int32_t xef = xe & 0xFF;