diff options
| author | Pablo MartÃnez <58857054+elpekenin@users.noreply.github.com> | 2023-03-25 18:56:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-25 18:56:04 +0100 |
| commit | cd542a0f6767231d73386c0913a9d2ee062ccf80 (patch) | |
| tree | 43e5328aeb8fee3e2e9e06daee4aad7f47ca73fa /quantum/painter | |
| parent | e640fd65fffd6332fbdddde06194dcfa6ce4fb52 (diff) | |
[Cleanup] Quantum Painter (#19825)
Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'quantum/painter')
| -rw-r--r-- | quantum/painter/lvgl/qp_lvgl.c | 2 | ||||
| -rw-r--r-- | quantum/painter/qff.h | 10 | ||||
| -rw-r--r-- | quantum/painter/qp.c | 22 | ||||
| -rw-r--r-- | quantum/painter/qp_comms.c | 16 | ||||
| -rw-r--r-- | quantum/painter/qp_draw.h | 14 | ||||
| -rw-r--r-- | quantum/painter/qp_draw_circle.c | 2 | ||||
| -rw-r--r-- | quantum/painter/qp_draw_codec.c | 22 | ||||
| -rw-r--r-- | quantum/painter/qp_draw_core.c | 20 | ||||
| -rw-r--r-- | quantum/painter/qp_draw_ellipse.c | 2 | ||||
| -rw-r--r-- | quantum/painter/qp_draw_image.c | 12 | ||||
| -rw-r--r-- | quantum/painter/qp_draw_text.c | 56 | ||||
| -rw-r--r-- | quantum/painter/qp_internal_driver.h | 22 | ||||
| -rw-r--r-- | quantum/painter/qp_stream.h | 4 |
13 files changed, 102 insertions, 102 deletions
diff --git a/quantum/painter/lvgl/qp_lvgl.c b/quantum/painter/lvgl/qp_lvgl.c index c6dd08ef97..660ffb6100 100644 --- a/quantum/painter/lvgl/qp_lvgl.c +++ b/quantum/painter/lvgl/qp_lvgl.c | |||
| @@ -60,7 +60,7 @@ bool qp_lvgl_attach(painter_device_t device) { | |||
| 60 | qp_dprintf("qp_lvgl_start: entry\n"); | 60 | qp_dprintf("qp_lvgl_start: entry\n"); |
| 61 | qp_lvgl_detach(); | 61 | qp_lvgl_detach(); |
| 62 | 62 | ||
| 63 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 63 | painter_driver_t *driver = (painter_driver_t *)device; |
| 64 | if (!driver->validate_ok) { | 64 | if (!driver->validate_ok) { |
| 65 | qp_dprintf("qp_lvgl_attach: fail (validation_ok == false)\n"); | 65 | qp_dprintf("qp_lvgl_attach: fail (validation_ok == false)\n"); |
| 66 | qp_lvgl_detach(); | 66 | qp_lvgl_detach(); |
diff --git a/quantum/painter/qff.h b/quantum/painter/qff.h index 6f1a1fd815..d1d629582f 100644 --- a/quantum/painter/qff.h +++ b/quantum/painter/qff.h | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | #define QFF_FONT_DESCRIPTOR_TYPEID 0x00 | 22 | #define QFF_FONT_DESCRIPTOR_TYPEID 0x00 |
| 23 | 23 | ||
| 24 | typedef struct __attribute__((packed)) qff_font_descriptor_v1_t { | 24 | typedef struct QP_PACKED qff_font_descriptor_v1_t { |
| 25 | qgf_block_header_v1_t header; // = { .type_id = 0x00, .neg_type_id = (~0x00), .length = 20 } | 25 | qgf_block_header_v1_t header; // = { .type_id = 0x00, .neg_type_id = (~0x00), .length = 20 } |
| 26 | uint32_t magic : 24; // constant, equal to 0x464651 ("QFF") | 26 | uint32_t magic : 24; // constant, equal to 0x464651 ("QFF") |
| 27 | uint8_t qff_version; // constant, equal to 0x01 | 27 | uint8_t qff_version; // constant, equal to 0x01 |
| @@ -50,13 +50,13 @@ _Static_assert(sizeof(qff_font_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t | |||
| 50 | #define QFF_GLYPH_OFFSET_BITS 18 | 50 | #define QFF_GLYPH_OFFSET_BITS 18 |
| 51 | #define QFF_GLYPH_OFFSET_MASK (((1 << QFF_GLYPH_OFFSET_BITS) - 1) << QFF_GLYPH_WIDTH_BITS) | 51 | #define QFF_GLYPH_OFFSET_MASK (((1 << QFF_GLYPH_OFFSET_BITS) - 1) << QFF_GLYPH_WIDTH_BITS) |
| 52 | 52 | ||
| 53 | typedef struct __attribute__((packed)) qff_ascii_glyph_v1_t { | 53 | typedef struct QP_PACKED qff_ascii_glyph_v1_t { |
| 54 | uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined | 54 | uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined |
| 55 | } qff_ascii_glyph_v1_t; | 55 | } qff_ascii_glyph_v1_t; |
| 56 | 56 | ||
| 57 | _Static_assert(sizeof(qff_ascii_glyph_v1_t) == 3, "qff_ascii_glyph_v1_t must be 3 bytes in v1 of QFF"); | 57 | _Static_assert(sizeof(qff_ascii_glyph_v1_t) == 3, "qff_ascii_glyph_v1_t must be 3 bytes in v1 of QFF"); |
| 58 | 58 | ||
| 59 | typedef struct __attribute__((packed)) qff_ascii_glyph_table_v1_t { | 59 | typedef struct QP_PACKED qff_ascii_glyph_table_v1_t { |
| 60 | qgf_block_header_v1_t header; // = { .type_id = 0x01, .neg_type_id = (~0x01), .length = 285 } | 60 | qgf_block_header_v1_t header; // = { .type_id = 0x01, .neg_type_id = (~0x01), .length = 285 } |
| 61 | qff_ascii_glyph_v1_t glyph[95]; // 95 glyphs, 0x20..0x7E | 61 | qff_ascii_glyph_v1_t glyph[95]; // 95 glyphs, 0x20..0x7E |
| 62 | } qff_ascii_glyph_table_v1_t; | 62 | } qff_ascii_glyph_table_v1_t; |
| @@ -68,14 +68,14 @@ _Static_assert(sizeof(qff_ascii_glyph_table_v1_t) == (sizeof(qgf_block_header_v1 | |||
| 68 | 68 | ||
| 69 | #define QFF_UNICODE_GLYPH_DESCRIPTOR_TYPEID 0x02 | 69 | #define QFF_UNICODE_GLYPH_DESCRIPTOR_TYPEID 0x02 |
| 70 | 70 | ||
| 71 | typedef struct __attribute__((packed)) qff_unicode_glyph_v1_t { | 71 | typedef struct QP_PACKED qff_unicode_glyph_v1_t { |
| 72 | uint32_t code_point : 24; | 72 | uint32_t code_point : 24; |
| 73 | uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined | 73 | uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined |
| 74 | } qff_unicode_glyph_v1_t; | 74 | } qff_unicode_glyph_v1_t; |
| 75 | 75 | ||
| 76 | _Static_assert(sizeof(qff_unicode_glyph_v1_t) == 6, "qff_unicode_glyph_v1_t must be 6 bytes in v1 of QFF"); | 76 | _Static_assert(sizeof(qff_unicode_glyph_v1_t) == 6, "qff_unicode_glyph_v1_t must be 6 bytes in v1 of QFF"); |
| 77 | 77 | ||
| 78 | typedef struct __attribute__((packed)) qff_unicode_glyph_table_v1_t { | 78 | typedef struct QP_PACKED qff_unicode_glyph_table_v1_t { |
| 79 | qgf_block_header_v1_t header; // = { .type_id = 0x02, .neg_type_id = (~0x02), .length = (N * 6) } | 79 | qgf_block_header_v1_t header; // = { .type_id = 0x02, .neg_type_id = (~0x02), .length = (N * 6) } |
| 80 | qff_unicode_glyph_v1_t glyph[0]; // Extent of '0' signifies that this struct is immediately followed by the glyph data | 80 | qff_unicode_glyph_v1_t glyph[0]; // Extent of '0' signifies that this struct is immediately followed by the glyph data |
| 81 | } qff_unicode_glyph_table_v1_t; | 81 | } qff_unicode_glyph_table_v1_t; |
diff --git a/quantum/painter/qp.c b/quantum/painter/qp.c index de36dee2c1..aea9381b60 100644 --- a/quantum/painter/qp.c +++ b/quantum/painter/qp.c | |||
| @@ -11,15 +11,15 @@ | |||
| 11 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 11 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 12 | // Internal driver validation | 12 | // Internal driver validation |
| 13 | 13 | ||
| 14 | static bool validate_driver_vtable(struct painter_driver_t *driver) { | 14 | static bool validate_driver_vtable(painter_driver_t *driver) { |
| 15 | return (driver->driver_vtable && driver->driver_vtable->init && driver->driver_vtable->power && driver->driver_vtable->clear && driver->driver_vtable->viewport && driver->driver_vtable->pixdata && driver->driver_vtable->palette_convert && driver->driver_vtable->append_pixels && driver->driver_vtable->append_pixdata) ? true : false; | 15 | return (driver->driver_vtable && driver->driver_vtable->init && driver->driver_vtable->power && driver->driver_vtable->clear && driver->driver_vtable->viewport && driver->driver_vtable->pixdata && driver->driver_vtable->palette_convert && driver->driver_vtable->append_pixels && driver->driver_vtable->append_pixdata) ? true : false; |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | static bool validate_comms_vtable(struct painter_driver_t *driver) { | 18 | static bool validate_comms_vtable(painter_driver_t *driver) { |
| 19 | return (driver->comms_vtable && driver->comms_vtable->comms_init && driver->comms_vtable->comms_start && driver->comms_vtable->comms_stop && driver->comms_vtable->comms_send) ? true : false; | 19 | return (driver->comms_vtable && driver->comms_vtable->comms_init && driver->comms_vtable->comms_start && driver->comms_vtable->comms_stop && driver->comms_vtable->comms_send) ? true : false; |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | static bool validate_driver_integrity(struct painter_driver_t *driver) { | 22 | static bool validate_driver_integrity(painter_driver_t *driver) { |
| 23 | return validate_driver_vtable(driver) && validate_comms_vtable(driver); | 23 | return validate_driver_vtable(driver) && validate_comms_vtable(driver); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| @@ -28,7 +28,7 @@ static bool validate_driver_integrity(struct painter_driver_t *driver) { | |||
| 28 | 28 | ||
| 29 | bool qp_init(painter_device_t device, painter_rotation_t rotation) { | 29 | bool qp_init(painter_device_t device, painter_rotation_t rotation) { |
| 30 | qp_dprintf("qp_init: entry\n"); | 30 | qp_dprintf("qp_init: entry\n"); |
| 31 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 31 | painter_driver_t *driver = (painter_driver_t *)device; |
| 32 | 32 | ||
| 33 | driver->validate_ok = false; | 33 | driver->validate_ok = false; |
| 34 | if (!validate_driver_integrity(driver)) { | 34 | if (!validate_driver_integrity(driver)) { |
| @@ -64,7 +64,7 @@ bool qp_init(painter_device_t device, painter_rotation_t rotation) { | |||
| 64 | 64 | ||
| 65 | bool qp_power(painter_device_t device, bool power_on) { | 65 | bool qp_power(painter_device_t device, bool power_on) { |
| 66 | qp_dprintf("qp_power: entry\n"); | 66 | qp_dprintf("qp_power: entry\n"); |
| 67 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 67 | painter_driver_t *driver = (painter_driver_t *)device; |
| 68 | if (!driver->validate_ok) { | 68 | if (!driver->validate_ok) { |
| 69 | qp_dprintf("qp_power: fail (validation_ok == false)\n"); | 69 | qp_dprintf("qp_power: fail (validation_ok == false)\n"); |
| 70 | return false; | 70 | return false; |
| @@ -86,7 +86,7 @@ bool qp_power(painter_device_t device, bool power_on) { | |||
| 86 | 86 | ||
| 87 | bool qp_clear(painter_device_t device) { | 87 | bool qp_clear(painter_device_t device) { |
| 88 | qp_dprintf("qp_clear: entry\n"); | 88 | qp_dprintf("qp_clear: entry\n"); |
| 89 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 89 | painter_driver_t *driver = (painter_driver_t *)device; |
| 90 | if (!driver->validate_ok) { | 90 | if (!driver->validate_ok) { |
| 91 | qp_dprintf("qp_clear: fail (validation_ok == false)\n"); | 91 | qp_dprintf("qp_clear: fail (validation_ok == false)\n"); |
| 92 | return false; | 92 | return false; |
| @@ -108,7 +108,7 @@ bool qp_clear(painter_device_t device) { | |||
| 108 | 108 | ||
| 109 | bool qp_flush(painter_device_t device) { | 109 | bool qp_flush(painter_device_t device) { |
| 110 | qp_dprintf("qp_flush: entry\n"); | 110 | qp_dprintf("qp_flush: entry\n"); |
| 111 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 111 | painter_driver_t *driver = (painter_driver_t *)device; |
| 112 | if (!driver->validate_ok) { | 112 | if (!driver->validate_ok) { |
| 113 | qp_dprintf("qp_flush: fail (validation_ok == false)\n"); | 113 | qp_dprintf("qp_flush: fail (validation_ok == false)\n"); |
| 114 | return false; | 114 | return false; |
| @@ -130,7 +130,7 @@ bool qp_flush(painter_device_t device) { | |||
| 130 | 130 | ||
| 131 | void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height, painter_rotation_t *rotation, uint16_t *offset_x, uint16_t *offset_y) { | 131 | void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height, painter_rotation_t *rotation, uint16_t *offset_x, uint16_t *offset_y) { |
| 132 | qp_dprintf("qp_geometry: entry\n"); | 132 | qp_dprintf("qp_geometry: entry\n"); |
| 133 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 133 | painter_driver_t *driver = (painter_driver_t *)device; |
| 134 | 134 | ||
| 135 | switch (driver->rotation) { | 135 | switch (driver->rotation) { |
| 136 | default: | 136 | default: |
| @@ -174,7 +174,7 @@ void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height, | |||
| 174 | 174 | ||
| 175 | void qp_set_viewport_offsets(painter_device_t device, uint16_t offset_x, uint16_t offset_y) { | 175 | void qp_set_viewport_offsets(painter_device_t device, uint16_t offset_x, uint16_t offset_y) { |
| 176 | qp_dprintf("qp_set_viewport_offsets: entry\n"); | 176 | qp_dprintf("qp_set_viewport_offsets: entry\n"); |
| 177 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 177 | painter_driver_t *driver = (painter_driver_t *)device; |
| 178 | 178 | ||
| 179 | driver->offset_x = offset_x; | 179 | driver->offset_x = offset_x; |
| 180 | driver->offset_y = offset_y; | 180 | driver->offset_y = offset_y; |
| @@ -187,7 +187,7 @@ void qp_set_viewport_offsets(painter_device_t device, uint16_t offset_x, uint16_ | |||
| 187 | 187 | ||
| 188 | bool qp_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) { | 188 | bool qp_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) { |
| 189 | qp_dprintf("qp_viewport: entry\n"); | 189 | qp_dprintf("qp_viewport: entry\n"); |
| 190 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 190 | painter_driver_t *driver = (painter_driver_t *)device; |
| 191 | if (!driver->validate_ok) { | 191 | if (!driver->validate_ok) { |
| 192 | qp_dprintf("qp_viewport: fail (validation_ok == false)\n"); | 192 | qp_dprintf("qp_viewport: fail (validation_ok == false)\n"); |
| 193 | return false; | 193 | return false; |
| @@ -210,7 +210,7 @@ bool qp_viewport(painter_device_t device, uint16_t left, uint16_t top, uint16_t | |||
| 210 | 210 | ||
| 211 | bool qp_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count) { | 211 | bool qp_pixdata(painter_device_t device, const void *pixel_data, uint32_t native_pixel_count) { |
| 212 | qp_dprintf("qp_pixdata: entry\n"); | 212 | qp_dprintf("qp_pixdata: entry\n"); |
| 213 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 213 | painter_driver_t *driver = (painter_driver_t *)device; |
| 214 | if (!driver->validate_ok) { | 214 | if (!driver->validate_ok) { |
| 215 | qp_dprintf("qp_pixdata: fail (validation_ok == false)\n"); | 215 | qp_dprintf("qp_pixdata: fail (validation_ok == false)\n"); |
| 216 | return false; | 216 | return false; |
diff --git a/quantum/painter/qp_comms.c b/quantum/painter/qp_comms.c index dc17b49460..bcc6de8f2e 100644 --- a/quantum/painter/qp_comms.c +++ b/quantum/painter/qp_comms.c | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | // Base comms APIs | 7 | // Base comms APIs |
| 8 | 8 | ||
| 9 | bool qp_comms_init(painter_device_t device) { | 9 | bool qp_comms_init(painter_device_t device) { |
| 10 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 10 | painter_driver_t *driver = (painter_driver_t *)device; |
| 11 | if (!driver->validate_ok) { | 11 | if (!driver->validate_ok) { |
| 12 | qp_dprintf("qp_comms_init: fail (validation_ok == false)\n"); | 12 | qp_dprintf("qp_comms_init: fail (validation_ok == false)\n"); |
| 13 | return false; | 13 | return false; |
| @@ -17,7 +17,7 @@ bool qp_comms_init(painter_device_t device) { | |||
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | bool qp_comms_start(painter_device_t device) { | 19 | bool qp_comms_start(painter_device_t device) { |
| 20 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 20 | painter_driver_t *driver = (painter_driver_t *)device; |
| 21 | if (!driver->validate_ok) { | 21 | if (!driver->validate_ok) { |
| 22 | qp_dprintf("qp_comms_start: fail (validation_ok == false)\n"); | 22 | qp_dprintf("qp_comms_start: fail (validation_ok == false)\n"); |
| 23 | return false; | 23 | return false; |
| @@ -27,7 +27,7 @@ bool qp_comms_start(painter_device_t device) { | |||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | void qp_comms_stop(painter_device_t device) { | 29 | void qp_comms_stop(painter_device_t device) { |
| 30 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 30 | painter_driver_t *driver = (painter_driver_t *)device; |
| 31 | if (!driver->validate_ok) { | 31 | if (!driver->validate_ok) { |
| 32 | qp_dprintf("qp_comms_stop: fail (validation_ok == false)\n"); | 32 | qp_dprintf("qp_comms_stop: fail (validation_ok == false)\n"); |
| 33 | return; | 33 | return; |
| @@ -37,7 +37,7 @@ void qp_comms_stop(painter_device_t device) { | |||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | uint32_t qp_comms_send(painter_device_t device, const void *data, uint32_t byte_count) { | 39 | uint32_t qp_comms_send(painter_device_t device, const void *data, uint32_t byte_count) { |
| 40 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 40 | painter_driver_t *driver = (painter_driver_t *)device; |
| 41 | if (!driver->validate_ok) { | 41 | if (!driver->validate_ok) { |
| 42 | qp_dprintf("qp_comms_send: fail (validation_ok == false)\n"); | 42 | qp_dprintf("qp_comms_send: fail (validation_ok == false)\n"); |
| 43 | return false; | 43 | return false; |
| @@ -50,8 +50,8 @@ uint32_t qp_comms_send(painter_device_t device, const void *data, uint32_t byte_ | |||
| 50 | // Comms APIs that use a D/C pin | 50 | // Comms APIs that use a D/C pin |
| 51 | 51 | ||
| 52 | void qp_comms_command(painter_device_t device, uint8_t cmd) { | 52 | void qp_comms_command(painter_device_t device, uint8_t cmd) { |
| 53 | struct painter_driver_t * driver = (struct painter_driver_t *)device; | 53 | painter_driver_t * driver = (painter_driver_t *)device; |
| 54 | struct painter_comms_with_command_vtable_t *comms_vtable = (struct painter_comms_with_command_vtable_t *)driver->comms_vtable; | 54 | painter_comms_with_command_vtable_t *comms_vtable = (painter_comms_with_command_vtable_t *)driver->comms_vtable; |
| 55 | comms_vtable->send_command(device, cmd); | 55 | comms_vtable->send_command(device, cmd); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| @@ -66,7 +66,7 @@ uint32_t qp_comms_command_databuf(painter_device_t device, uint8_t cmd, const vo | |||
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | void qp_comms_bulk_command_sequence(painter_device_t device, const uint8_t *sequence, size_t sequence_len) { | 68 | void qp_comms_bulk_command_sequence(painter_device_t device, const uint8_t *sequence, size_t sequence_len) { |
| 69 | struct painter_driver_t * driver = (struct painter_driver_t *)device; | 69 | painter_driver_t * driver = (painter_driver_t *)device; |
| 70 | struct painter_comms_with_command_vtable_t *comms_vtable = (struct painter_comms_with_command_vtable_t *)driver->comms_vtable; | 70 | painter_comms_with_command_vtable_t *comms_vtable = (painter_comms_with_command_vtable_t *)driver->comms_vtable; |
| 71 | comms_vtable->bulk_command_sequence(device, sequence, sequence_len); | 71 | comms_vtable->bulk_command_sequence(device, sequence, sequence_len); |
| 72 | } | 72 | } |
diff --git a/quantum/painter/qp_draw.h b/quantum/painter/qp_draw.h index 84b1946ca7..3d073efe8c 100644 --- a/quantum/painter/qp_draw.h +++ b/quantum/painter/qp_draw.h | |||
| @@ -63,7 +63,7 @@ enum qp_internal_rle_mode_t { | |||
| 63 | NON_REPEATING_RUN, | 63 | NON_REPEATING_RUN, |
| 64 | }; | 64 | }; |
| 65 | 65 | ||
| 66 | struct qp_internal_byte_input_state { | 66 | typedef struct qp_internal_byte_input_state_t { |
| 67 | painter_device_t device; | 67 | painter_device_t device; |
| 68 | qp_stream_t* src_stream; | 68 | qp_stream_t* src_stream; |
| 69 | int16_t curr; | 69 | int16_t curr; |
| @@ -74,22 +74,22 @@ struct qp_internal_byte_input_state { | |||
| 74 | uint8_t remain; // number of bytes remaining in the current mode | 74 | uint8_t remain; // number of bytes remaining in the current mode |
| 75 | } rle; | 75 | } rle; |
| 76 | }; | 76 | }; |
| 77 | }; | 77 | } qp_internal_byte_input_state_t; |
| 78 | 78 | ||
| 79 | struct qp_internal_pixel_output_state { | 79 | typedef struct qp_internal_pixel_output_state_t { |
| 80 | painter_device_t device; | 80 | painter_device_t device; |
| 81 | uint32_t pixel_write_pos; | 81 | uint32_t pixel_write_pos; |
| 82 | uint32_t max_pixels; | 82 | uint32_t max_pixels; |
| 83 | }; | 83 | } qp_internal_pixel_output_state_t; |
| 84 | 84 | ||
| 85 | bool qp_internal_pixel_appender(qp_pixel_t* palette, uint8_t index, void* cb_arg); | 85 | bool qp_internal_pixel_appender(qp_pixel_t* palette, uint8_t index, void* cb_arg); |
| 86 | 86 | ||
| 87 | struct qp_internal_byte_output_state { | 87 | typedef struct qp_internal_byte_output_state_t { |
| 88 | painter_device_t device; | 88 | painter_device_t device; |
| 89 | uint32_t byte_write_pos; | 89 | uint32_t byte_write_pos; |
| 90 | uint32_t max_bytes; | 90 | uint32_t max_bytes; |
| 91 | }; | 91 | } qp_internal_byte_output_state_t; |
| 92 | 92 | ||
| 93 | bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg); | 93 | bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg); |
| 94 | 94 | ||
| 95 | qp_internal_byte_input_callback qp_internal_prepare_input_state(struct qp_internal_byte_input_state* input_state, painter_compression_t compression); | 95 | qp_internal_byte_input_callback qp_internal_prepare_input_state(qp_internal_byte_input_state_t* input_state, painter_compression_t compression); |
diff --git a/quantum/painter/qp_draw_circle.c b/quantum/painter/qp_draw_circle.c index edaae35835..25517d91c5 100644 --- a/quantum/painter/qp_draw_circle.c +++ b/quantum/painter/qp_draw_circle.c | |||
| @@ -127,7 +127,7 @@ static bool qp_circle_helper_impl(painter_device_t device, uint16_t centerx, uin | |||
| 127 | 127 | ||
| 128 | bool qp_circle(painter_device_t device, uint16_t x, uint16_t y, uint16_t radius, uint8_t hue, uint8_t sat, uint8_t val, bool filled) { | 128 | bool qp_circle(painter_device_t device, uint16_t x, uint16_t y, uint16_t radius, uint8_t hue, uint8_t sat, uint8_t val, bool filled) { |
| 129 | qp_dprintf("qp_circle: entry\n"); | 129 | qp_dprintf("qp_circle: entry\n"); |
| 130 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 130 | painter_driver_t *driver = (painter_driver_t *)device; |
| 131 | if (!driver->validate_ok) { | 131 | if (!driver->validate_ok) { |
| 132 | qp_dprintf("qp_circle: fail (validation_ok == false)\n"); | 132 | qp_dprintf("qp_circle: fail (validation_ok == false)\n"); |
| 133 | return false; | 133 | return false; |
diff --git a/quantum/painter/qp_draw_codec.c b/quantum/painter/qp_draw_codec.c index 5d1cf7c52e..cee2e32e28 100644 --- a/quantum/painter/qp_draw_codec.c +++ b/quantum/painter/qp_draw_codec.c | |||
| @@ -54,8 +54,8 @@ bool qp_internal_decode_grayscale(painter_device_t device, uint32_t pixel_count, | |||
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | bool qp_internal_decode_recolor(painter_device_t device, uint32_t pixel_count, uint8_t bits_per_pixel, qp_internal_byte_input_callback input_callback, void* input_arg, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888, qp_internal_pixel_output_callback output_callback, void* output_arg) { | 56 | bool qp_internal_decode_recolor(painter_device_t device, uint32_t pixel_count, uint8_t bits_per_pixel, qp_internal_byte_input_callback input_callback, void* input_arg, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888, qp_internal_pixel_output_callback output_callback, void* output_arg) { |
| 57 | struct painter_driver_t* driver = (struct painter_driver_t*)device; | 57 | painter_driver_t* driver = (painter_driver_t*)device; |
| 58 | int16_t steps = 1 << bits_per_pixel; // number of items we need to interpolate | 58 | int16_t steps = 1 << bits_per_pixel; // number of items we need to interpolate |
| 59 | if (qp_internal_interpolate_palette(fg_hsv888, bg_hsv888, steps)) { | 59 | if (qp_internal_interpolate_palette(fg_hsv888, bg_hsv888, steps)) { |
| 60 | if (!driver->driver_vtable->palette_convert(device, steps, qp_internal_global_pixel_lookup_table)) { | 60 | if (!driver->driver_vtable->palette_convert(device, steps, qp_internal_global_pixel_lookup_table)) { |
| 61 | return false; | 61 | return false; |
| @@ -84,13 +84,13 @@ bool qp_internal_send_bytes(painter_device_t device, uint32_t byte_count, qp_int | |||
| 84 | // Progressive pull of bytes, push of pixels | 84 | // Progressive pull of bytes, push of pixels |
| 85 | 85 | ||
| 86 | static inline int16_t qp_drawimage_byte_uncompressed_decoder(void* cb_arg) { | 86 | static inline int16_t qp_drawimage_byte_uncompressed_decoder(void* cb_arg) { |
| 87 | struct qp_internal_byte_input_state* state = (struct qp_internal_byte_input_state*)cb_arg; | 87 | qp_internal_byte_input_state_t* state = (qp_internal_byte_input_state_t*)cb_arg; |
| 88 | state->curr = qp_stream_get(state->src_stream); | 88 | state->curr = qp_stream_get(state->src_stream); |
| 89 | return state->curr; | 89 | return state->curr; |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | static inline int16_t qp_drawimage_byte_rle_decoder(void* cb_arg) { | 92 | static inline int16_t qp_drawimage_byte_rle_decoder(void* cb_arg) { |
| 93 | struct qp_internal_byte_input_state* state = (struct qp_internal_byte_input_state*)cb_arg; | 93 | qp_internal_byte_input_state_t* state = (qp_internal_byte_input_state_t*)cb_arg; |
| 94 | 94 | ||
| 95 | // Work out if we're parsing the initial marker byte | 95 | // Work out if we're parsing the initial marker byte |
| 96 | if (state->rle.mode == MARKER_BYTE) { | 96 | if (state->rle.mode == MARKER_BYTE) { |
| @@ -126,8 +126,8 @@ static inline int16_t qp_drawimage_byte_rle_decoder(void* cb_arg) { | |||
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | bool qp_internal_pixel_appender(qp_pixel_t* palette, uint8_t index, void* cb_arg) { | 128 | bool qp_internal_pixel_appender(qp_pixel_t* palette, uint8_t index, void* cb_arg) { |
| 129 | struct qp_internal_pixel_output_state* state = (struct qp_internal_pixel_output_state*)cb_arg; | 129 | qp_internal_pixel_output_state_t* state = (qp_internal_pixel_output_state_t*)cb_arg; |
| 130 | struct painter_driver_t* driver = (struct painter_driver_t*)state->device; | 130 | painter_driver_t* driver = (painter_driver_t*)state->device; |
| 131 | 131 | ||
| 132 | if (!driver->driver_vtable->append_pixels(state->device, qp_internal_global_pixdata_buffer, palette, state->pixel_write_pos++, 1, &index)) { | 132 | if (!driver->driver_vtable->append_pixels(state->device, qp_internal_global_pixdata_buffer, palette, state->pixel_write_pos++, 1, &index)) { |
| 133 | return false; | 133 | return false; |
| @@ -145,8 +145,8 @@ bool qp_internal_pixel_appender(qp_pixel_t* palette, uint8_t index, void* cb_arg | |||
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg) { | 147 | bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg) { |
| 148 | struct qp_internal_byte_output_state* state = (struct qp_internal_byte_output_state*)cb_arg; | 148 | qp_internal_byte_output_state_t* state = (qp_internal_byte_output_state_t*)cb_arg; |
| 149 | struct painter_driver_t* driver = (struct painter_driver_t*)state->device; | 149 | painter_driver_t* driver = (painter_driver_t*)state->device; |
| 150 | 150 | ||
| 151 | if (!driver->driver_vtable->append_pixdata(state->device, qp_internal_global_pixdata_buffer, state->byte_write_pos++, byteval)) { | 151 | if (!driver->driver_vtable->append_pixdata(state->device, qp_internal_global_pixdata_buffer, state->byte_write_pos++, byteval)) { |
| 152 | return false; | 152 | return false; |
| @@ -154,7 +154,7 @@ bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg) { | |||
| 154 | 154 | ||
| 155 | // If we've hit the transmit limit, send out the entire buffer and reset the write position | 155 | // If we've hit the transmit limit, send out the entire buffer and reset the write position |
| 156 | if (state->byte_write_pos == state->max_bytes) { | 156 | if (state->byte_write_pos == state->max_bytes) { |
| 157 | struct painter_driver_t* driver = (struct painter_driver_t*)state->device; | 157 | painter_driver_t* driver = (painter_driver_t*)state->device; |
| 158 | if (!driver->driver_vtable->pixdata(state->device, qp_internal_global_pixdata_buffer, state->byte_write_pos * 8 / driver->native_bits_per_pixel)) { | 158 | if (!driver->driver_vtable->pixdata(state->device, qp_internal_global_pixdata_buffer, state->byte_write_pos * 8 / driver->native_bits_per_pixel)) { |
| 159 | return false; | 159 | return false; |
| 160 | } | 160 | } |
| @@ -164,7 +164,7 @@ bool qp_internal_byte_appender(uint8_t byteval, void* cb_arg) { | |||
| 164 | return true; | 164 | return true; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | qp_internal_byte_input_callback qp_internal_prepare_input_state(struct qp_internal_byte_input_state* input_state, painter_compression_t compression) { | 167 | qp_internal_byte_input_callback qp_internal_prepare_input_state(qp_internal_byte_input_state_t* input_state, painter_compression_t compression) { |
| 168 | switch (compression) { | 168 | switch (compression) { |
| 169 | case IMAGE_UNCOMPRESSED: | 169 | case IMAGE_UNCOMPRESSED: |
| 170 | return qp_drawimage_byte_uncompressed_decoder; | 170 | return qp_drawimage_byte_uncompressed_decoder; |
diff --git a/quantum/painter/qp_draw_core.c b/quantum/painter/qp_draw_core.c index 309ef93dd0..3988aaedf8 100644 --- a/quantum/painter/qp_draw_core.c +++ b/quantum/painter/qp_draw_core.c | |||
| @@ -37,21 +37,21 @@ __attribute__((__aligned__(4))) qp_pixel_t qp_internal_global_pixel_lookup_table | |||
| 37 | // Helpers | 37 | // Helpers |
| 38 | 38 | ||
| 39 | uint32_t qp_internal_num_pixels_in_buffer(painter_device_t device) { | 39 | uint32_t qp_internal_num_pixels_in_buffer(painter_device_t device) { |
| 40 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 40 | painter_driver_t *driver = (painter_driver_t *)device; |
| 41 | return ((QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE * 8) / driver->native_bits_per_pixel); | 41 | return ((QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE * 8) / driver->native_bits_per_pixel); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | // qp_setpixel internal implementation, but accepts a buffer with pre-converted native pixel. Only the first pixel is used. | 44 | // qp_setpixel internal implementation, but accepts a buffer with pre-converted native pixel. Only the first pixel is used. |
| 45 | bool qp_internal_setpixel_impl(painter_device_t device, uint16_t x, uint16_t y) { | 45 | bool qp_internal_setpixel_impl(painter_device_t device, uint16_t x, uint16_t y) { |
| 46 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 46 | painter_driver_t *driver = (painter_driver_t *)device; |
| 47 | return driver->driver_vtable->viewport(device, x, y, x, y) && driver->driver_vtable->pixdata(device, qp_internal_global_pixdata_buffer, 1); | 47 | return driver->driver_vtable->viewport(device, x, y, x, y) && driver->driver_vtable->pixdata(device, qp_internal_global_pixdata_buffer, 1); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | // Fills the global native pixel buffer with equivalent pixels matching the supplied HSV | 50 | // Fills the global native pixel buffer with equivalent pixels matching the supplied HSV |
| 51 | void qp_internal_fill_pixdata(painter_device_t device, uint32_t num_pixels, uint8_t hue, uint8_t sat, uint8_t val) { | 51 | void qp_internal_fill_pixdata(painter_device_t device, uint32_t num_pixels, uint8_t hue, uint8_t sat, uint8_t val) { |
| 52 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 52 | painter_driver_t *driver = (painter_driver_t *)device; |
| 53 | uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device); | 53 | uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device); |
| 54 | num_pixels = QP_MIN(pixels_in_pixdata, num_pixels); | 54 | num_pixels = QP_MIN(pixels_in_pixdata, num_pixels); |
| 55 | 55 | ||
| 56 | // Convert the color to native pixel format | 56 | // Convert the color to native pixel format |
| 57 | qp_pixel_t color = {.hsv888 = {.h = hue, .s = sat, .v = val}}; | 57 | qp_pixel_t color = {.hsv888 = {.h = hue, .s = sat, .v = val}}; |
| @@ -144,7 +144,7 @@ bool qp_internal_load_qgf_palette(qp_stream_t *stream, uint8_t bpp) { | |||
| 144 | // Quantum Painter External API: qp_setpixel | 144 | // Quantum Painter External API: qp_setpixel |
| 145 | 145 | ||
| 146 | bool qp_setpixel(painter_device_t device, uint16_t x, uint16_t y, uint8_t hue, uint8_t sat, uint8_t val) { | 146 | bool qp_setpixel(painter_device_t device, uint16_t x, uint16_t y, uint8_t hue, uint8_t sat, uint8_t val) { |
| 147 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 147 | painter_driver_t *driver = (painter_driver_t *)device; |
| 148 | if (!driver->validate_ok) { | 148 | if (!driver->validate_ok) { |
| 149 | qp_dprintf("qp_setpixel: fail (validation_ok == false)\n"); | 149 | qp_dprintf("qp_setpixel: fail (validation_ok == false)\n"); |
| 150 | return false; | 150 | return false; |
| @@ -174,7 +174,7 @@ bool qp_line(painter_device_t device, uint16_t x0, uint16_t y0, uint16_t x1, uin | |||
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | qp_dprintf("qp_line(%d, %d, %d, %d): entry\n", (int)x0, (int)y0, (int)x1, (int)y1); | 176 | qp_dprintf("qp_line(%d, %d, %d, %d): entry\n", (int)x0, (int)y0, (int)x1, (int)y1); |
| 177 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 177 | painter_driver_t *driver = (painter_driver_t *)device; |
| 178 | if (!driver->validate_ok) { | 178 | if (!driver->validate_ok) { |
| 179 | qp_dprintf("qp_line: fail (validation_ok == false)\n"); | 179 | qp_dprintf("qp_line: fail (validation_ok == false)\n"); |
| 180 | return false; | 180 | return false; |
| @@ -228,8 +228,8 @@ bool qp_line(painter_device_t device, uint16_t x0, uint16_t y0, uint16_t x1, uin | |||
| 228 | // Quantum Painter External API: qp_rect | 228 | // Quantum Painter External API: qp_rect |
| 229 | 229 | ||
| 230 | bool qp_internal_fillrect_helper_impl(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) { | 230 | bool qp_internal_fillrect_helper_impl(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) { |
| 231 | uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device); | 231 | uint32_t pixels_in_pixdata = qp_internal_num_pixels_in_buffer(device); |
| 232 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 232 | painter_driver_t *driver = (painter_driver_t *)device; |
| 233 | 233 | ||
| 234 | uint16_t l = QP_MIN(left, right); | 234 | uint16_t l = QP_MIN(left, right); |
| 235 | uint16_t r = QP_MAX(left, right); | 235 | uint16_t r = QP_MAX(left, right); |
| @@ -252,7 +252,7 @@ bool qp_internal_fillrect_helper_impl(painter_device_t device, uint16_t left, ui | |||
| 252 | 252 | ||
| 253 | bool qp_rect(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint8_t hue, uint8_t sat, uint8_t val, bool filled) { | 253 | bool qp_rect(painter_device_t device, uint16_t left, uint16_t top, uint16_t right, uint16_t bottom, uint8_t hue, uint8_t sat, uint8_t val, bool filled) { |
| 254 | qp_dprintf("qp_rect(%d, %d, %d, %d): entry\n", (int)left, (int)top, (int)right, (int)bottom); | 254 | qp_dprintf("qp_rect(%d, %d, %d, %d): entry\n", (int)left, (int)top, (int)right, (int)bottom); |
| 255 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 255 | painter_driver_t *driver = (painter_driver_t *)device; |
| 256 | if (!driver->validate_ok) { | 256 | if (!driver->validate_ok) { |
| 257 | qp_dprintf("qp_rect: fail (validation_ok == false)\n"); | 257 | qp_dprintf("qp_rect: fail (validation_ok == false)\n"); |
| 258 | return false; | 258 | return false; |
diff --git a/quantum/painter/qp_draw_ellipse.c b/quantum/painter/qp_draw_ellipse.c index 7f2f4abcfd..5c7abd7a7d 100644 --- a/quantum/painter/qp_draw_ellipse.c +++ b/quantum/painter/qp_draw_ellipse.c | |||
| @@ -61,7 +61,7 @@ static bool qp_ellipse_helper_impl(painter_device_t device, uint16_t centerx, ui | |||
| 61 | 61 | ||
| 62 | bool qp_ellipse(painter_device_t device, uint16_t x, uint16_t y, uint16_t sizex, uint16_t sizey, uint8_t hue, uint8_t sat, uint8_t val, bool filled) { | 62 | bool qp_ellipse(painter_device_t device, uint16_t x, uint16_t y, uint16_t sizex, uint16_t sizey, uint8_t hue, uint8_t sat, uint8_t val, bool filled) { |
| 63 | qp_dprintf("qp_ellipse: entry\n"); | 63 | qp_dprintf("qp_ellipse: entry\n"); |
| 64 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 64 | painter_driver_t *driver = (painter_driver_t *)device; |
| 65 | if (!driver->validate_ok) { | 65 | if (!driver->validate_ok) { |
| 66 | qp_dprintf("qp_ellipse: fail (validation_ok == false)\n"); | 66 | qp_dprintf("qp_ellipse: fail (validation_ok == false)\n"); |
| 67 | return false; | 67 | return false; |
diff --git a/quantum/painter/qp_draw_image.c b/quantum/painter/qp_draw_image.c index e722f3cf02..361c21b906 100644 --- a/quantum/painter/qp_draw_image.c +++ b/quantum/painter/qp_draw_image.c | |||
| @@ -124,7 +124,7 @@ typedef struct qgf_frame_info_t { | |||
| 124 | } qgf_frame_info_t; | 124 | } qgf_frame_info_t; |
| 125 | 125 | ||
| 126 | static bool qp_drawimage_prepare_frame_for_stream_read(painter_device_t device, qgf_image_handle_t *qgf_image, uint16_t frame_number, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888, qgf_frame_info_t *info) { | 126 | static bool qp_drawimage_prepare_frame_for_stream_read(painter_device_t device, qgf_image_handle_t *qgf_image, uint16_t frame_number, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888, qgf_frame_info_t *info) { |
| 127 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 127 | painter_driver_t *driver = (painter_driver_t *)device; |
| 128 | 128 | ||
| 129 | // Drop out if we can't actually place the data we read out anywhere | 129 | // Drop out if we can't actually place the data we read out anywhere |
| 130 | if (!info) { | 130 | if (!info) { |
| @@ -209,7 +209,7 @@ static bool qp_drawimage_prepare_frame_for_stream_read(painter_device_t device, | |||
| 209 | 209 | ||
| 210 | static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint16_t y, painter_image_handle_t image, int frame_number, qgf_frame_info_t *frame_info, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888) { | 210 | static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint16_t y, painter_image_handle_t image, int frame_number, qgf_frame_info_t *frame_info, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888) { |
| 211 | qp_dprintf("qp_drawimage_recolor: entry\n"); | 211 | qp_dprintf("qp_drawimage_recolor: entry\n"); |
| 212 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 212 | painter_driver_t *driver = (painter_driver_t *)device; |
| 213 | if (!driver->validate_ok) { | 213 | if (!driver->validate_ok) { |
| 214 | qp_dprintf("qp_drawimage_recolor: fail (validation_ok == false)\n"); | 214 | qp_dprintf("qp_drawimage_recolor: fail (validation_ok == false)\n"); |
| 215 | return false; | 215 | return false; |
| @@ -254,8 +254,8 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1 | |||
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | // Set up the input state | 256 | // Set up the input state |
| 257 | struct qp_internal_byte_input_state input_state = {.device = device, .src_stream = &qgf_image->stream}; | 257 | qp_internal_byte_input_state_t input_state = {.device = device, .src_stream = &qgf_image->stream}; |
| 258 | qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, frame_info->compression_scheme); | 258 | qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, frame_info->compression_scheme); |
| 259 | if (input_callback == NULL) { | 259 | if (input_callback == NULL) { |
| 260 | qp_dprintf("qp_drawimage_recolor: fail (invalid image compression scheme)\n"); | 260 | qp_dprintf("qp_drawimage_recolor: fail (invalid image compression scheme)\n"); |
| 261 | qp_comms_stop(device); | 261 | qp_comms_stop(device); |
| @@ -265,7 +265,7 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1 | |||
| 265 | bool ret = false; | 265 | bool ret = false; |
| 266 | if (frame_info->bpp <= 8) { | 266 | if (frame_info->bpp <= 8) { |
| 267 | // Set up the output state | 267 | // Set up the output state |
| 268 | struct qp_internal_pixel_output_state output_state = {.device = device, .pixel_write_pos = 0, .max_pixels = qp_internal_num_pixels_in_buffer(device)}; | 268 | qp_internal_pixel_output_state_t output_state = {.device = device, .pixel_write_pos = 0, .max_pixels = qp_internal_num_pixels_in_buffer(device)}; |
| 269 | 269 | ||
| 270 | // Decode the pixel data and stream to the display | 270 | // Decode the pixel data and stream to the display |
| 271 | ret = qp_internal_decode_palette(device, pixel_count, frame_info->bpp, input_callback, &input_state, qp_internal_global_pixel_lookup_table, qp_internal_pixel_appender, &output_state); | 271 | ret = qp_internal_decode_palette(device, pixel_count, frame_info->bpp, input_callback, &input_state, qp_internal_global_pixel_lookup_table, qp_internal_pixel_appender, &output_state); |
| @@ -275,7 +275,7 @@ static bool qp_drawimage_recolor_impl(painter_device_t device, uint16_t x, uint1 | |||
| 275 | } | 275 | } |
| 276 | } else { | 276 | } else { |
| 277 | // Set up the output state | 277 | // Set up the output state |
| 278 | struct qp_internal_byte_output_state output_state = {.device = device, .byte_write_pos = 0, .max_bytes = qp_internal_num_pixels_in_buffer(device) * driver->native_bits_per_pixel / 8}; | 278 | qp_internal_byte_output_state_t output_state = {.device = device, .byte_write_pos = 0, .max_bytes = qp_internal_num_pixels_in_buffer(device) * driver->native_bits_per_pixel / 8}; |
| 279 | 279 | ||
| 280 | // Stream the raw pixel data to the display | 280 | // Stream the raw pixel data to the display |
| 281 | uint32_t byte_count = pixel_count * frame_info->bpp / 8; | 281 | uint32_t byte_count = pixel_count * frame_info->bpp / 8; |
diff --git a/quantum/painter/qp_draw_text.c b/quantum/painter/qp_draw_text.c index f9fb2bf08f..ed3d373867 100644 --- a/quantum/painter/qp_draw_text.c +++ b/quantum/painter/qp_draw_text.c | |||
| @@ -164,7 +164,7 @@ typedef bool (*code_point_handler)(qff_font_handle_t *qff_font, uint32_t code_po | |||
| 164 | 164 | ||
| 165 | // Helper that sets up the palette (if required) and returns the offset in the stream that the data starts | 165 | // Helper that sets up the palette (if required) and returns the offset in the stream that the data starts |
| 166 | static inline bool qp_drawtext_prepare_font_for_render(painter_device_t device, qff_font_handle_t *qff_font, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888, uint32_t *data_offset) { | 166 | static inline bool qp_drawtext_prepare_font_for_render(painter_device_t device, qff_font_handle_t *qff_font, qp_pixel_t fg_hsv888, qp_pixel_t bg_hsv888, uint32_t *data_offset) { |
| 167 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 167 | painter_driver_t *driver = (painter_driver_t *)device; |
| 168 | 168 | ||
| 169 | // Drop out if we can't actually place the data we read out anywhere | 169 | // Drop out if we can't actually place the data we read out anywhere |
| 170 | if (!data_offset) { | 170 | if (!data_offset) { |
| @@ -319,13 +319,13 @@ static inline bool qp_iterate_code_points(qff_font_handle_t *qff_font, const cha | |||
| 319 | // String width calculation | 319 | // String width calculation |
| 320 | 320 | ||
| 321 | // Callback state | 321 | // Callback state |
| 322 | struct code_point_iter_calcwidth_state { | 322 | typedef struct code_point_iter_calcwidth_state_t { |
| 323 | int16_t width; | 323 | int16_t width; |
| 324 | }; | 324 | } code_point_iter_calcwidth_state_t; |
| 325 | 325 | ||
| 326 | // Codepoint handler callback: width calc | 326 | // Codepoint handler callback: width calc |
| 327 | static inline bool qp_font_code_point_handler_calcwidth(qff_font_handle_t *qff_font, uint32_t code_point, uint8_t width, uint8_t height, void *cb_arg) { | 327 | static inline bool qp_font_code_point_handler_calcwidth(qff_font_handle_t *qff_font, uint32_t code_point, uint8_t width, uint8_t height, void *cb_arg) { |
| 328 | struct code_point_iter_calcwidth_state *state = (struct code_point_iter_calcwidth_state *)cb_arg; | 328 | code_point_iter_calcwidth_state_t *state = (code_point_iter_calcwidth_state_t *)cb_arg; |
| 329 | 329 | ||
| 330 | // Increment the overall width by this glyph's width | 330 | // Increment the overall width by this glyph's width |
| 331 | state->width += width; | 331 | state->width += width; |
| @@ -337,19 +337,19 @@ static inline bool qp_font_code_point_handler_calcwidth(qff_font_handle_t *qff_f | |||
| 337 | // String drawing implementation | 337 | // String drawing implementation |
| 338 | 338 | ||
| 339 | // Callback state | 339 | // Callback state |
| 340 | struct code_point_iter_drawglyph_state { | 340 | typedef struct code_point_iter_drawglyph_state_t { |
| 341 | painter_device_t device; | 341 | painter_device_t device; |
| 342 | int16_t xpos; | 342 | int16_t xpos; |
| 343 | int16_t ypos; | 343 | int16_t ypos; |
| 344 | qp_internal_byte_input_callback input_callback; | 344 | qp_internal_byte_input_callback input_callback; |
| 345 | struct qp_internal_byte_input_state * input_state; | 345 | qp_internal_byte_input_state_t * input_state; |
| 346 | struct qp_internal_pixel_output_state *output_state; | 346 | qp_internal_pixel_output_state_t *output_state; |
| 347 | }; | 347 | } code_point_iter_drawglyph_state_t; |
| 348 | 348 | ||
| 349 | // Codepoint handler callback: drawing | 349 | // Codepoint handler callback: drawing |
| 350 | static inline bool qp_font_code_point_handler_drawglyph(qff_font_handle_t *qff_font, uint32_t code_point, uint8_t width, uint8_t height, void *cb_arg) { | 350 | static inline bool qp_font_code_point_handler_drawglyph(qff_font_handle_t *qff_font, uint32_t code_point, uint8_t width, uint8_t height, void *cb_arg) { |
| 351 | struct code_point_iter_drawglyph_state *state = (struct code_point_iter_drawglyph_state *)cb_arg; | 351 | code_point_iter_drawglyph_state_t *state = (code_point_iter_drawglyph_state_t *)cb_arg; |
| 352 | struct painter_driver_t * driver = (struct painter_driver_t *)state->device; | 352 | painter_driver_t * driver = (painter_driver_t *)state->device; |
| 353 | 353 | ||
| 354 | // Reset the input state's RLE mode -- the stream should already be correctly positioned by qp_iterate_code_points() | 354 | // Reset the input state's RLE mode -- the stream should already be correctly positioned by qp_iterate_code_points() |
| 355 | state->input_state->rle.mode = MARKER_BYTE; // ignored if not using RLE | 355 | state->input_state->rle.mode = MARKER_BYTE; // ignored if not using RLE |
| @@ -386,7 +386,7 @@ int16_t qp_textwidth(painter_font_handle_t font, const char *str) { | |||
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | // Create the codepoint iterator state | 388 | // Create the codepoint iterator state |
| 389 | struct code_point_iter_calcwidth_state state = {.width = 0}; | 389 | code_point_iter_calcwidth_state_t state = {.width = 0}; |
| 390 | // Iterate each codepoint, return the calculated width if successful. | 390 | // Iterate each codepoint, return the calculated width if successful. |
| 391 | return qp_iterate_code_points(qff_font, str, qp_font_code_point_handler_calcwidth, &state) ? state.width : 0; | 391 | return qp_iterate_code_points(qff_font, str, qp_font_code_point_handler_calcwidth, &state) ? state.width : 0; |
| 392 | } | 392 | } |
| @@ -405,7 +405,7 @@ int16_t qp_drawtext(painter_device_t device, uint16_t x, uint16_t y, painter_fon | |||
| 405 | 405 | ||
| 406 | int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, painter_font_handle_t font, const char *str, uint8_t hue_fg, uint8_t sat_fg, uint8_t val_fg, uint8_t hue_bg, uint8_t sat_bg, uint8_t val_bg) { | 406 | int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, painter_font_handle_t font, const char *str, uint8_t hue_fg, uint8_t sat_fg, uint8_t val_fg, uint8_t hue_bg, uint8_t sat_bg, uint8_t val_bg) { |
| 407 | qp_dprintf("qp_drawtext_recolor: entry\n"); | 407 | qp_dprintf("qp_drawtext_recolor: entry\n"); |
| 408 | struct painter_driver_t *driver = (struct painter_driver_t *)device; | 408 | painter_driver_t *driver = (painter_driver_t *)device; |
| 409 | if (!driver->validate_ok) { | 409 | if (!driver->validate_ok) { |
| 410 | qp_dprintf("qp_drawtext_recolor: fail (validation_ok == false)\n"); | 410 | qp_dprintf("qp_drawtext_recolor: fail (validation_ok == false)\n"); |
| 411 | return 0; | 411 | return 0; |
| @@ -423,8 +423,8 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai | |||
| 423 | } | 423 | } |
| 424 | 424 | ||
| 425 | // Set up the byte input state and input callback | 425 | // Set up the byte input state and input callback |
| 426 | struct qp_internal_byte_input_state input_state = {.device = device, .src_stream = &qff_font->stream}; | 426 | qp_internal_byte_input_state_t input_state = {.device = device, .src_stream = &qff_font->stream}; |
| 427 | qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, qff_font->compression_scheme); | 427 | qp_internal_byte_input_callback input_callback = qp_internal_prepare_input_state(&input_state, qff_font->compression_scheme); |
| 428 | if (input_callback == NULL) { | 428 | if (input_callback == NULL) { |
| 429 | qp_dprintf("qp_drawtext_recolor: fail (invalid font compression scheme)\n"); | 429 | qp_dprintf("qp_drawtext_recolor: fail (invalid font compression scheme)\n"); |
| 430 | qp_comms_stop(device); | 430 | qp_comms_stop(device); |
| @@ -432,18 +432,18 @@ int16_t qp_drawtext_recolor(painter_device_t device, uint16_t x, uint16_t y, pai | |||
| 432 | } | 432 | } |
| 433 | 433 | ||
| 434 | // Set up the pixel output state | 434 | // Set up the pixel output state |
| 435 | struct qp_internal_pixel_output_state output_state = {.device = device, .pixel_write_pos = 0, .max_pixels = qp_internal_num_pixels_in_buffer(device)}; | 435 | qp_internal_pixel_output_state_t output_state = {.device = device, .pixel_write_pos = 0, .max_pixels = qp_internal_num_pixels_in_buffer(device)}; |
| 436 | 436 | ||
| 437 | // Set up the codepoint iteration state | 437 | // Set up the codepoint iteration state |
| 438 | struct code_point_iter_drawglyph_state state = {// Common | 438 | code_point_iter_drawglyph_state_t state = {// Common |
| 439 | .device = device, | 439 | .device = device, |
| 440 | .xpos = x, | 440 | .xpos = x, |
| 441 | .ypos = y, | 441 | .ypos = y, |
| 442 | // Input | 442 | // Input |
| 443 | .input_callback = input_callback, | 443 | .input_callback = input_callback, |
| 444 | .input_state = &input_state, | 444 | .input_state = &input_state, |
| 445 | // Output | 445 | // Output |
| 446 | .output_state = &output_state}; | 446 | .output_state = &output_state}; |
| 447 | 447 | ||
| 448 | qp_pixel_t fg_hsv888 = {.hsv888 = {.h = hue_fg, .s = sat_fg, .v = val_fg}}; | 448 | qp_pixel_t fg_hsv888 = {.hsv888 = {.h = hue_fg, .s = sat_fg, .v = val_fg}}; |
| 449 | qp_pixel_t bg_hsv888 = {.hsv888 = {.h = hue_bg, .s = sat_bg, .v = val_bg}}; | 449 | qp_pixel_t bg_hsv888 = {.hsv888 = {.h = hue_bg, .s = sat_bg, .v = val_bg}}; |
diff --git a/quantum/painter/qp_internal_driver.h b/quantum/painter/qp_internal_driver.h index c976ff9db7..69da966f8c 100644 --- a/quantum/painter/qp_internal_driver.h +++ b/quantum/painter/qp_internal_driver.h | |||
| @@ -19,7 +19,7 @@ typedef bool (*painter_driver_append_pixels)(painter_device_t device, uint8_t *t | |||
| 19 | typedef bool (*painter_driver_append_pixdata)(painter_device_t device, uint8_t *target_buffer, uint32_t pixdata_offset, uint8_t pixdata_byte); | 19 | typedef bool (*painter_driver_append_pixdata)(painter_device_t device, uint8_t *target_buffer, uint32_t pixdata_offset, uint8_t pixdata_byte); |
| 20 | 20 | ||
| 21 | // Driver vtable definition | 21 | // Driver vtable definition |
| 22 | struct painter_driver_vtable_t { | 22 | typedef struct painter_driver_vtable_t { |
| 23 | painter_driver_init_func init; | 23 | painter_driver_init_func init; |
| 24 | painter_driver_power_func power; | 24 | painter_driver_power_func power; |
| 25 | painter_driver_clear_func clear; | 25 | painter_driver_clear_func clear; |
| @@ -29,7 +29,7 @@ struct painter_driver_vtable_t { | |||
| 29 | painter_driver_convert_palette_func palette_convert; | 29 | painter_driver_convert_palette_func palette_convert; |
| 30 | painter_driver_append_pixels append_pixels; | 30 | painter_driver_append_pixels append_pixels; |
| 31 | painter_driver_append_pixdata append_pixdata; | 31 | painter_driver_append_pixdata append_pixdata; |
| 32 | }; | 32 | } painter_driver_vtable_t; |
| 33 | 33 | ||
| 34 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 34 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 35 | // Comms callbacks | 35 | // Comms callbacks |
| @@ -39,28 +39,28 @@ typedef bool (*painter_driver_comms_start_func)(painter_device_t device); | |||
| 39 | typedef void (*painter_driver_comms_stop_func)(painter_device_t device); | 39 | typedef void (*painter_driver_comms_stop_func)(painter_device_t device); |
| 40 | typedef uint32_t (*painter_driver_comms_send_func)(painter_device_t device, const void *data, uint32_t byte_count); | 40 | typedef uint32_t (*painter_driver_comms_send_func)(painter_device_t device, const void *data, uint32_t byte_count); |
| 41 | 41 | ||
| 42 | struct painter_comms_vtable_t { | 42 | typedef struct painter_comms_vtable_t { |
| 43 | painter_driver_comms_init_func comms_init; | 43 | painter_driver_comms_init_func comms_init; |
| 44 | painter_driver_comms_start_func comms_start; | 44 | painter_driver_comms_start_func comms_start; |
| 45 | painter_driver_comms_stop_func comms_stop; | 45 | painter_driver_comms_stop_func comms_stop; |
| 46 | painter_driver_comms_send_func comms_send; | 46 | painter_driver_comms_send_func comms_send; |
| 47 | }; | 47 | } painter_comms_vtable_t; |
| 48 | 48 | ||
| 49 | typedef void (*painter_driver_comms_send_command_func)(painter_device_t device, uint8_t cmd); | 49 | typedef void (*painter_driver_comms_send_command_func)(painter_device_t device, uint8_t cmd); |
| 50 | typedef void (*painter_driver_comms_bulk_command_sequence)(painter_device_t device, const uint8_t *sequence, size_t sequence_len); | 50 | typedef void (*painter_driver_comms_bulk_command_sequence)(painter_device_t device, const uint8_t *sequence, size_t sequence_len); |
| 51 | 51 | ||
| 52 | struct painter_comms_with_command_vtable_t { | 52 | typedef struct painter_comms_with_command_vtable_t { |
| 53 | struct painter_comms_vtable_t base; // must be first, so this object can be cast from the painter_comms_vtable_t* type | 53 | painter_comms_vtable_t base; // must be first, so this object can be cast from the painter_comms_vtable_t* type |
| 54 | painter_driver_comms_send_command_func send_command; | 54 | painter_driver_comms_send_command_func send_command; |
| 55 | painter_driver_comms_bulk_command_sequence bulk_command_sequence; | 55 | painter_driver_comms_bulk_command_sequence bulk_command_sequence; |
| 56 | }; | 56 | } painter_comms_with_command_vtable_t; |
| 57 | 57 | ||
| 58 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 58 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 59 | // Driver base definition | 59 | // Driver base definition |
| 60 | 60 | ||
| 61 | struct painter_driver_t { | 61 | typedef struct painter_driver_t { |
| 62 | const struct painter_driver_vtable_t *driver_vtable; | 62 | const painter_driver_vtable_t *driver_vtable; |
| 63 | const struct painter_comms_vtable_t * comms_vtable; | 63 | const painter_comms_vtable_t * comms_vtable; |
| 64 | 64 | ||
| 65 | // Flag signifying if validation was successful | 65 | // Flag signifying if validation was successful |
| 66 | bool validate_ok; | 66 | bool validate_ok; |
| @@ -81,7 +81,7 @@ struct painter_driver_t { | |||
| 81 | 81 | ||
| 82 | // Comms config pointer -- needs to point to an appropriate comms config if the comms driver requires it. | 82 | // Comms config pointer -- needs to point to an appropriate comms config if the comms driver requires it. |
| 83 | void *comms_config; | 83 | void *comms_config; |
| 84 | }; | 84 | } painter_driver_t; |
| 85 | 85 | ||
| 86 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 86 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 87 | // Device internals | 87 | // Device internals |
diff --git a/quantum/painter/qp_stream.h b/quantum/painter/qp_stream.h index c0e745adc1..4f2b612e43 100644 --- a/quantum/painter/qp_stream.h +++ b/quantum/painter/qp_stream.h | |||
| @@ -48,14 +48,14 @@ uint32_t qp_stream_write_impl(const void *input_buf, uint32_t member_size, uint3 | |||
| 48 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 48 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 49 | // Stream definition | 49 | // Stream definition |
| 50 | 50 | ||
| 51 | struct qp_stream_t { | 51 | typedef struct qp_stream_t { |
| 52 | int16_t (*get)(qp_stream_t *stream); | 52 | int16_t (*get)(qp_stream_t *stream); |
| 53 | bool (*put)(qp_stream_t *stream, uint8_t c); | 53 | bool (*put)(qp_stream_t *stream, uint8_t c); |
| 54 | int (*seek)(qp_stream_t *stream, int32_t offset, int origin); | 54 | int (*seek)(qp_stream_t *stream, int32_t offset, int origin); |
| 55 | int32_t (*tell)(qp_stream_t *stream); | 55 | int32_t (*tell)(qp_stream_t *stream); |
| 56 | bool (*is_eof)(qp_stream_t *stream); | 56 | bool (*is_eof)(qp_stream_t *stream); |
| 57 | void (*close)(qp_stream_t *stream); | 57 | void (*close)(qp_stream_t *stream); |
| 58 | }; | 58 | } qp_stream_t; |
| 59 | 59 | ||
| 60 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 60 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 61 | // Memory streams | 61 | // Memory streams |
