From aeee4d98792ece92703c3ed4a7705056294136b3 Mon Sep 17 00:00:00 2001 From: Nicolas Roggeman Date: Thu, 18 Jan 2024 11:39:34 +0100 Subject: [PATCH] Remove horizontal and both mirroring to simplify code --- Makefile.defines | 2 +- ...er_circle_bottom_left_32px_1bpp_nocomp.bmp | Bin 0 -> 3126 bytes ...er_circle_bottom_left_40px_1bpp_nocomp.bmp | Bin 0 -> 4854 bytes ...rter_circle_top_left_32px_1bpp_nocomp.bmp} | Bin ...rter_circle_top_left_40px_1bpp_nocomp.bmp} | Bin ...rter_disc_bottom_left_32px_1bpp_nocomp.bmp | Bin 0 -> 3126 bytes ...rter_disc_bottom_left_40px_1bpp_nocomp.bmp | Bin 0 -> 4854 bytes ...uarter_disc_top_left_32px_1bpp_nocomp.bmp} | Bin ...uarter_disc_top_left_40px_1bpp_nocomp.bmp} | Bin lib_nbgl/include/nbgl_types.h | 16 +- lib_nbgl/src/nbgl_draw.c | 137 ++++++++++-------- 11 files changed, 80 insertions(+), 75 deletions(-) create mode 100755 lib_nbgl/glyphs/quarter_circle_bottom_left_32px_1bpp_nocomp.bmp create mode 100755 lib_nbgl/glyphs/quarter_circle_bottom_left_40px_1bpp_nocomp.bmp rename lib_nbgl/glyphs/{quarter_circle_32px_1bpp_nocomp.bmp => quarter_circle_top_left_32px_1bpp_nocomp.bmp} (100%) rename lib_nbgl/glyphs/{quarter_circle_40px_1bpp_nocomp.bmp => quarter_circle_top_left_40px_1bpp_nocomp.bmp} (100%) create mode 100755 lib_nbgl/glyphs/quarter_disc_bottom_left_32px_1bpp_nocomp.bmp create mode 100755 lib_nbgl/glyphs/quarter_disc_bottom_left_40px_1bpp_nocomp.bmp rename lib_nbgl/glyphs/{quarter_round_32px_1bpp_nocomp.bmp => quarter_disc_top_left_32px_1bpp_nocomp.bmp} (100%) rename lib_nbgl/glyphs/{quarter_round_40px_1bpp_nocomp.bmp => quarter_disc_top_left_40px_1bpp_nocomp.bmp} (100%) diff --git a/Makefile.defines b/Makefile.defines index defb13d06..ae6afc2cb 100644 --- a/Makefile.defines +++ b/Makefile.defines @@ -38,7 +38,7 @@ endif API_LEVEL := 0 TARGET_PATH := $(BOLOS_SDK)/target/$(TARGET) TARGET_ID := $(shell cat $(TARGET_PATH)/include/bolos_target.h | grep TARGET_ID | cut -f3 -d' ') -TARGET_NAME := $(shell cat $(TARGET_PATH)/include/bolos_target.h | grep TARGET_ | grep -v TARGET_ID | cut -f2 -d' ') +TARGET_NAME := $(sort $(shell cat $(TARGET_PATH)/include/bolos_target.h | grep TARGET_ | grep -v TARGET_ID | cut -f2 -d' ')) SDK_NAME := "ledger-secure-sdk" SDK_VERSION := $(shell git -C $(BOLOS_SDK) describe --tags --exact-match --match "v[0-9]*" --dirty) SDK_HASH := $(shell git -C $(BOLOS_SDK) describe --always --dirty --exclude '*' --abbrev=40) diff --git a/lib_nbgl/glyphs/quarter_circle_bottom_left_32px_1bpp_nocomp.bmp b/lib_nbgl/glyphs/quarter_circle_bottom_left_32px_1bpp_nocomp.bmp new file mode 100755 index 0000000000000000000000000000000000000000..a5aa51f39f8976a982e41086508455b9f5b9a814 GIT binary patch literal 3126 zcmZ?rHRE9b12Z700mKSW%*Y@CWI=!sHvM8*+z{HC4737nINUmFF=%HpO`SbzIGzLmiBmiZD3KbvhQregCEmxQ smkuEVv;vO9r literal 0 HcmV?d00001 diff --git a/lib_nbgl/glyphs/quarter_circle_32px_1bpp_nocomp.bmp b/lib_nbgl/glyphs/quarter_circle_top_left_32px_1bpp_nocomp.bmp similarity index 100% rename from lib_nbgl/glyphs/quarter_circle_32px_1bpp_nocomp.bmp rename to lib_nbgl/glyphs/quarter_circle_top_left_32px_1bpp_nocomp.bmp diff --git a/lib_nbgl/glyphs/quarter_circle_40px_1bpp_nocomp.bmp b/lib_nbgl/glyphs/quarter_circle_top_left_40px_1bpp_nocomp.bmp similarity index 100% rename from lib_nbgl/glyphs/quarter_circle_40px_1bpp_nocomp.bmp rename to lib_nbgl/glyphs/quarter_circle_top_left_40px_1bpp_nocomp.bmp diff --git a/lib_nbgl/glyphs/quarter_disc_bottom_left_32px_1bpp_nocomp.bmp b/lib_nbgl/glyphs/quarter_disc_bottom_left_32px_1bpp_nocomp.bmp new file mode 100755 index 0000000000000000000000000000000000000000..dfd831fd2341cd974df18397d4521ff5e7e654cb GIT binary patch literal 3126 zcmeH@F%Ez*2u16xlar&PC-4C7-v2mSt=goa@IlkTlmuJh{};-#&Ye4B_TS0pcxB@T ze+$vK&K-Hj_G#SIc)rI+7Ik~Wr+8`2z)unEzn0I!h$hY_%s>g`10-4^@@X4f<@qos zD`fatkEW61YZ#oC|5JX8$N0lSw1RQ`q_rD1(v10L2VC|V%0!SDM64^8F+1tJQrusf@_`VkJ zqk6`T@NMe&jtj#f&uE)}|D>G-#=m{NhGb)TFYg9Ax#agI@#dz-YeIny%?p4t5y6`w zV%wA#LqaLs3*q1p=!JP`5b>fcCYSXxFe01w5+E{~@RB4hZh1KhpT3lrKR(@9-a`zi>jv-C;;v2?muJhxh#?yCaCUi6A(N9~4Q$F%fnn6qAXG>g|UyizR_ HxakBwXEg@R literal 0 HcmV?d00001 diff --git a/lib_nbgl/glyphs/quarter_round_32px_1bpp_nocomp.bmp b/lib_nbgl/glyphs/quarter_disc_top_left_32px_1bpp_nocomp.bmp similarity index 100% rename from lib_nbgl/glyphs/quarter_round_32px_1bpp_nocomp.bmp rename to lib_nbgl/glyphs/quarter_disc_top_left_32px_1bpp_nocomp.bmp diff --git a/lib_nbgl/glyphs/quarter_round_40px_1bpp_nocomp.bmp b/lib_nbgl/glyphs/quarter_disc_top_left_40px_1bpp_nocomp.bmp similarity index 100% rename from lib_nbgl/glyphs/quarter_round_40px_1bpp_nocomp.bmp rename to lib_nbgl/glyphs/quarter_disc_top_left_40px_1bpp_nocomp.bmp diff --git a/lib_nbgl/include/nbgl_types.h b/lib_nbgl/include/nbgl_types.h index 37ca6fb9d..aea8ed272 100644 --- a/lib_nbgl/include/nbgl_types.h +++ b/lib_nbgl/include/nbgl_types.h @@ -53,22 +53,12 @@ extern "C" { * */ #define NO_TRANSFORMATION 0 -/** - * Horizontal mirroring when rendering bitmap - * - */ -#define HORIZONTAL_MIRROR 0x1 -/** - * Vertical mirroring when rendering bitmap - * - */ -#define VERTICAL_MIRROR 0x2 /** - * Both directions mirroring when rendering bitmap + * Vertical mirroring when rendering bitmap * */ -#define BOTH_MIRRORS (HORIZONTAL_MIRROR | VERTICAL_MIRROR) +#define VERTICAL_MIRROR 0x2 /** * Rotation 90 degrees clockwise when rendering bitmap @@ -206,7 +196,7 @@ typedef enum { /** * @brief Represents the transformation to be applied on the bitmap before rendering - * This is a bitfield using masks as @ref HORIZONTAL_MIRROR + * This is a bitfield using masks as @ref VERTICAL_MIRROR */ typedef uint8_t nbgl_transformation_t; diff --git a/lib_nbgl/src/nbgl_draw.c b/lib_nbgl/src/nbgl_draw.c index ea3490d81..8cb35e652 100644 --- a/lib_nbgl/src/nbgl_draw.c +++ b/lib_nbgl/src/nbgl_draw.c @@ -24,10 +24,12 @@ /********************* * DEFINES *********************/ -#define BAGL_FILL_CIRCLE_3PI2_2PI 1 -#define BAGL_FILL_CIRCLE_PI_3PI2 2 -#define BAGL_FILL_CIRCLE_0_PI2 4 -#define BAGL_FILL_CIRCLE_PI2_PI 8 +typedef enum { + BAGL_FILL_CIRCLE_0_PI2, + BAGL_FILL_CIRCLE_PI2_PI, + BAGL_FILL_CIRCLE_PI_3PI2, + BAGL_FILL_CIRCLE_3PI2_2PI +} quarter_t; #define QR_PIXEL_WIDTH_HEIGHT 4 @@ -78,12 +80,18 @@ static const uint8_t radiusValues[] = { #ifdef SCREEN_SIZE_WALLET // indexed by nbgl_radius_t (except RADIUS_0_PIXELS) -static const nbgl_icon_details_t *quarterDiscs[] = {&C_quarter_round_32px_1bpp, - &C_quarter_round_40px_1bpp}; +static const uint8_t *topQuarterDiscs[] + = {C_quarter_disc_top_left_32px_1bpp_bitmap, C_quarter_disc_top_left_40px_1bpp_bitmap}; + +static const uint8_t *bottomQuarterDiscs[] + = {C_quarter_disc_bottom_left_32px_1bpp_bitmap, C_quarter_disc_bottom_left_40px_1bpp_bitmap}; // indexed by nbgl_radius_t (except RADIUS_0_PIXELS) -static const nbgl_icon_details_t *quarterCircles[] = {&C_quarter_circle_32px_1bpp, - &C_quarter_circle_40px_1bpp}; +static const uint8_t *topQuarterCircles[] + = {C_quarter_circle_top_left_32px_1bpp_bitmap, C_quarter_circle_top_left_40px_1bpp_bitmap}; + +static const uint8_t *bottomQuarterCircles[] = {C_quarter_circle_bottom_left_32px_1bpp_bitmap, + C_quarter_circle_bottom_left_40px_1bpp_bitmap}; #endif // SCREEN_SIZE_WALLET #ifdef NBGL_QRCODE @@ -102,7 +110,7 @@ CCASSERT(qr_code_buffer, sizeof(QrCodeBuffer_t) <= GZLIB_UNCOMPRESSED_CHUNK); static void draw_circle_helper(int x_center, int y_center, nbgl_radius_t radiusIndex, - uint8_t quarter, + quarter_t quarter, color_t borderColor, color_t innerColor, color_t backgroundColor) @@ -114,65 +122,72 @@ static void draw_circle_helper(int x_center, if (radiusIndex > RADIUS_MAX) { return; } + area.width = area.height = radiusValues[radiusIndex]; #ifdef SCREEN_SIZE_WALLET if (borderColor == innerColor) { - quarter_buffer - = (const uint8_t *) ((const nbgl_icon_details_t *) PIC(quarterDiscs[radiusIndex])) - ->bitmap; + if (quarter < BAGL_FILL_CIRCLE_PI_3PI2) { + quarter_buffer = (const uint8_t *) PIC(topQuarterDiscs[radiusIndex]); + } + else { + quarter_buffer = (const uint8_t *) PIC(bottomQuarterDiscs[radiusIndex]); + } } else { - quarter_buffer - = (const uint8_t *) ((const nbgl_icon_details_t *) PIC(quarterCircles[radiusIndex])) - ->bitmap; + if (quarter < BAGL_FILL_CIRCLE_PI_3PI2) { + quarter_buffer = (const uint8_t *) PIC(topQuarterCircles[radiusIndex]); + } + else { + quarter_buffer = (const uint8_t *) PIC(bottomQuarterCircles[radiusIndex]); + } } - area.width = area.height = radiusValues[radiusIndex]; - area.backgroundColor = backgroundColor; - if (quarter & BAGL_FILL_CIRCLE_3PI2_2PI) { // - area.x0 = x_center; - area.y0 = y_center; - nbgl_frontDrawImage(&area, quarter_buffer, BOTH_MIRRORS, borderColor); - } - if (quarter & BAGL_FILL_CIRCLE_PI_3PI2) { // - area.x0 = x_center - area.width; - area.y0 = y_center; - nbgl_frontDrawImage(&area, quarter_buffer, HORIZONTAL_MIRROR, borderColor); - } - if (quarter & BAGL_FILL_CIRCLE_0_PI2) { // - area.x0 = x_center; - area.y0 = y_center - area.width; - nbgl_frontDrawImage(&area, quarter_buffer, VERTICAL_MIRROR, borderColor); - } - if (quarter & BAGL_FILL_CIRCLE_PI2_PI) { // - area.x0 = x_center - area.width; - area.y0 = y_center - area.width; - nbgl_frontDrawImage(&area, quarter_buffer, NO_TRANSFORMATION, borderColor); + switch (quarter) { + case BAGL_FILL_CIRCLE_3PI2_2PI: // bottom right + area.x0 = x_center; + area.y0 = y_center; + nbgl_frontDrawImage(&area, quarter_buffer, VERTICAL_MIRROR, borderColor); + break; + case BAGL_FILL_CIRCLE_PI_3PI2: // bottom left + area.x0 = x_center - area.width; + area.y0 = y_center; + nbgl_frontDrawImage(&area, quarter_buffer, NO_TRANSFORMATION, borderColor); + break; + case BAGL_FILL_CIRCLE_0_PI2: // top right + area.x0 = x_center; + area.y0 = y_center - area.width; + nbgl_frontDrawImage(&area, quarter_buffer, VERTICAL_MIRROR, borderColor); + break; + case BAGL_FILL_CIRCLE_PI2_PI: // top left + area.x0 = x_center - area.width; + area.y0 = y_center - area.width; + nbgl_frontDrawImage(&area, quarter_buffer, NO_TRANSFORMATION, borderColor); + break; } #else // SCREEN_SIZE_WALLET - area.width = area.height = radiusValues[radiusIndex]; - area.backgroundColor = backgroundColor; - if (quarter & BAGL_FILL_CIRCLE_3PI2_2PI) { // - area.x0 = x_center; - area.y0 = y_center; - quarter_buffer - = (borderColor == innerColor) ? quarter_disc_3px_180_1bpp : quarter_circle_3px_180_1bpp; - } - if (quarter & BAGL_FILL_CIRCLE_PI_3PI2) { // - area.x0 = x_center - area.width; - area.y0 = y_center; - quarter_buffer - = (borderColor == innerColor) ? quarter_disc_3px_270_1bpp : quarter_circle_3px_270_1bpp; - } - if (quarter & BAGL_FILL_CIRCLE_0_PI2) { // - area.x0 = x_center; - area.y0 = y_center - area.width; - quarter_buffer - = (borderColor == innerColor) ? quarter_disc_3px_90_1bpp : quarter_circle_3px_90_1bpp; - } - if (quarter & BAGL_FILL_CIRCLE_PI2_PI) { // - area.x0 = x_center - area.width; - area.y0 = y_center - area.width; - quarter_buffer - = (borderColor == innerColor) ? quarter_disc_3px_1bpp : quarter_circle_3px_1bpp; + switch (quarter) { + case BAGL_FILL_CIRCLE_3PI2_2PI: // bottom right + area.x0 = x_center; + area.y0 = y_center; + quarter_buffer = (borderColor == innerColor) ? quarter_disc_3px_180_1bpp + : quarter_circle_3px_180_1bpp; + break; + case BAGL_FILL_CIRCLE_PI_3PI2: // bottom left + area.x0 = x_center - area.width; + area.y0 = y_center; + quarter_buffer = (borderColor == innerColor) ? quarter_disc_3px_270_1bpp + : quarter_circle_3px_270_1bpp; + break; + case BAGL_FILL_CIRCLE_0_PI2: // top right + area.x0 = x_center; + area.y0 = y_center - area.width; + quarter_buffer = (borderColor == innerColor) ? quarter_disc_3px_90_1bpp + : quarter_circle_3px_90_1bpp; + break; + case BAGL_FILL_CIRCLE_PI2_PI: // top left + area.x0 = x_center - area.width; + area.y0 = y_center - area.width; + quarter_buffer + = (borderColor == innerColor) ? quarter_disc_3px_1bpp : quarter_circle_3px_1bpp; + break; } nbgl_frontDrawImage(&area, quarter_buffer, NO_TRANSFORMATION, borderColor); #endif // SCREEN_SIZE_WALLET