Skip to content

Commit 141a673

Browse files
Merge pull request #718 from LedgerHQ/abo_nbgl_mask
Flex: Add nbgl masking syscall
2 parents fddeb90 + d497dc1 commit 141a673

File tree

6 files changed

+46
-1
lines changed

6 files changed

+46
-1
lines changed

include/syscalls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@
304304
#define SYSCALL_nbgl_get_font_ID 0x01fa000c
305305
#define SYSCALL_nbgl_screen_reinit_ID 0x00fa000d
306306
#define SYSCALL_nbgl_front_draw_img_rle_ID 0x05fa0010
307+
#define SYSCALL_nbgl_front_control_area_masking_ID 0x03fa0012
307308

308309
#ifdef HAVE_SE_EINK_DISPLAY
309310
#define SYSCALL_nbgl_wait_pipeline_ID 0x00fa0011

lib_nbgl/include/nbgl_front.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ void nbgl_frontDrawImageRle(const nbgl_area_t *area,
4545
void nbgl_frontRefreshArea(const nbgl_area_t *area,
4646
nbgl_refresh_mode_t mode,
4747
nbgl_post_refresh_t post_refresh);
48+
void nbgl_frontControlAreaMasking(uint8_t mask_index, nbgl_area_t *masked_area_or_null);
4849

4950
/**********************
5051
* MACROS

lib_nbgl/include/nbgl_obj.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,12 @@ typedef struct PACKED__ nbgl_text_entry_s {
448448
const char *text; ///< text to display (up to nbChars chars).
449449
} nbgl_text_entry_t;
450450

451+
typedef struct PACKED__ nbgl_mask_control_s {
452+
nbgl_obj_t obj; ///< common part
453+
bool enableMasking; ///< true: Enable masking of area / false: Disable masking of area
454+
uint8_t maskIndex; ///< index of mask
455+
} nbgl_mask_control_t;
456+
451457
/**
452458
* @brief struct to represent a "spinner", represented by the Ledger corners, in gray, with one of
453459
* the corners in black (@ref SPINNER type)

lib_nbgl/include/nbgl_types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ typedef enum {
128128
KEYPAD, ///< Keypad
129129
SPINNER, ///< Spinner
130130
IMAGE_FILE, ///< Image file (with Ledger compression)
131-
TEXT_ENTRY ///< area for entered text, only for Nanos
131+
TEXT_ENTRY, ///< area for entered text, only for Nanos
132+
MASK_CONTROL, ///< OS-specific object to enable/disable masked area
132133
} nbgl_obj_type_t;
133134

134135
/**

lib_nbgl/src/nbgl_obj.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,26 @@ static void draw_image_file(nbgl_image_file_t *obj, nbgl_obj_t *prevObj, bool co
13651365
nbgl_frontDrawImageFile((nbgl_area_t *) obj, obj->buffer, BLACK, ramBuffer);
13661366
}
13671367

1368+
#ifdef NBGL_MASKING
1369+
static void draw_mask_control(nbgl_mask_control_t *obj, nbgl_obj_t *prevObj, bool computePosition)
1370+
{
1371+
if (computePosition) {
1372+
compute_position((nbgl_obj_t *) obj, prevObj);
1373+
}
1374+
1375+
if (objDrawingDisabled) {
1376+
return;
1377+
}
1378+
1379+
if (obj->enableMasking) {
1380+
nbgl_frontControlAreaMasking(obj->maskIndex, &obj->obj.area);
1381+
}
1382+
else {
1383+
nbgl_frontControlAreaMasking(obj->maskIndex, NULL);
1384+
}
1385+
}
1386+
#endif // NBGL_MASKING
1387+
13681388
/**
13691389
* @brief internal function used to draw an object of any type
13701390
*
@@ -1447,6 +1467,11 @@ draw_object(nbgl_obj_t *obj, nbgl_obj_t *prevObj, bool computePosition)
14471467
draw_textEntry((nbgl_text_entry_t *) obj, prevObj, computePosition);
14481468
break;
14491469
#endif // HAVE_SE_TOUCH
1470+
#ifdef NBGL_MASKING
1471+
case MASK_CONTROL:
1472+
draw_mask_control((nbgl_mask_control_t *) obj, prevObj, computePosition);
1473+
break;
1474+
#endif // NBGL_MASKING
14501475
default:
14511476
LOG_DEBUG(OBJ_LOGGER, "Not existing object type\n");
14521477
break;

src/syscalls.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ void nbgl_frontDrawImageRle(nbgl_area_t *area,
103103
return;
104104
}
105105

106+
#ifdef NBGL_MASKING
107+
void nbgl_frontControlAreaMasking(uint8_t mask_index, nbgl_area_t *masked_area_or_null)
108+
{
109+
unsigned int parameters[2];
110+
parameters[0] = (unsigned int) mask_index;
111+
parameters[1] = (unsigned int) masked_area_or_null;
112+
SVC_Call(SYSCALL_nbgl_front_control_area_masking_ID, parameters);
113+
return;
114+
}
115+
#endif // NBGL_MASKING
116+
106117
void nbgl_frontDrawImageFile(nbgl_area_t *area,
107118
uint8_t *buffer,
108119
nbgl_color_map_t colorMap,

0 commit comments

Comments
 (0)