mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 04:41:26 +04:00
Icons: compression fixes & larger dimension support (#3564)
* toolbox, gui: fixes for compressed icon handling * ufbt: fixes for generated vscode project * scripts: increased max dimensions for image converter * icon type changes * linter fixes; api sync * gui: docs fix * toolbox: fixed potential decoder buffer overflow * minor cleanup * fbt: sdk: suppressed deprecation warnings in API table * toolbox: compress: added unit tests vscode: now installs resources for unit_tests unit_tests: now loads subghz region data * toolbox: compress: review fixes, pt 1 * compress: now passes decoder buffer size as constructor argument; auto-resize decoder buffer; crash on failed icon decompression * PVS fixes * pvs fixes, pt2 * doxygen fixes * investigating unit test failures * investigating unit test failures * investigating unit test failures * investigating unit test failures * investigating unit test failures * UnitTests: move all tests into plugins, brakes testing * UnitTests: add plugin API and update plugin entrypoints * UniTests: Test runner that works with plugins * fbt: extra filtering for extapps to include in build * UnitTests: filter tests by name * loader: restored API table for unit_test build config * Add various missing symbols to API table * UnitTest: fail on plugin load error * UnitTests: cleanup plugin api and reporting * unit_tests: composite resolver * UnitTests: remove unused declaration * unit_tests, nfc: moved mock nfc implementation to libnfc * unit_tests: api: removed redundant #define * toolbox: compress: removed size_hint for icons; triggering furi_check on oversized icons * gui: icon, icon_animation: removed size hit APIs * Format Sources. Cleanup code. * loader: refuse to start .fal as app * toolbox: compress: fixed memory corruption in operations with small destination buffer; added unit tests for that case * unit_tests: proper test skipping; better selective test interface * unit_tests: moved 'loading' logging to proper location Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -14,7 +14,7 @@ App(
|
||||
],
|
||||
stack_size=1 * 1024,
|
||||
order=20,
|
||||
sdk_headers=["bt_service/bt.h"],
|
||||
sdk_headers=["bt_service/bt.h", "bt_service/bt_keys_storage.h"],
|
||||
)
|
||||
|
||||
App(
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct BtKeysStorage BtKeysStorage;
|
||||
|
||||
BtKeysStorage* bt_keys_storage_alloc(const char* keys_storage_path);
|
||||
@@ -18,3 +22,7 @@ bool bt_keys_storage_load(BtKeysStorage* instance);
|
||||
bool bt_keys_storage_update(BtKeysStorage* instance, uint8_t* start_addr, uint32_t size);
|
||||
|
||||
bool bt_keys_storage_delete(BtKeysStorage* instance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "slideshow.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <storage/storage.h>
|
||||
#include <gui/icon.h>
|
||||
#include <gui/icon_i.h>
|
||||
|
||||
@@ -15,7 +15,7 @@ const CanvasFontParameters canvas_font_params[FontTotalNumber] = {
|
||||
|
||||
Canvas* canvas_init(void) {
|
||||
Canvas* canvas = malloc(sizeof(Canvas));
|
||||
canvas->compress_icon = compress_icon_alloc();
|
||||
canvas->compress_icon = compress_icon_alloc(ICON_DECOMPRESSOR_BUFFER_SIZE);
|
||||
|
||||
// Initialize mutex
|
||||
canvas->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
@@ -390,7 +390,7 @@ void canvas_draw_icon_ex(
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
uint8_t* icon_data = NULL;
|
||||
compress_icon_decode(canvas->compress_icon, icon_get_data(icon), &icon_data);
|
||||
compress_icon_decode(canvas->compress_icon, icon_get_frame_data(icon, 0), &icon_data);
|
||||
canvas_draw_u8g2_bitmap(
|
||||
&canvas->fb, x, y, icon_get_width(icon), icon_get_height(icon), icon_data, rotation);
|
||||
}
|
||||
@@ -402,7 +402,7 @@ void canvas_draw_icon(Canvas* canvas, int32_t x, int32_t y, const Icon* icon) {
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
uint8_t* icon_data = NULL;
|
||||
compress_icon_decode(canvas->compress_icon, icon_get_data(icon), &icon_data);
|
||||
compress_icon_decode(canvas->compress_icon, icon_get_frame_data(icon, 0), &icon_data);
|
||||
canvas_draw_u8g2_bitmap(
|
||||
&canvas->fb, x, y, icon_get_width(icon), icon_get_height(icon), icon_data, IconRotation0);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <m-algo.h>
|
||||
#include <furi.h>
|
||||
|
||||
#define ICON_DECOMPRESSOR_BUFFER_SIZE (128u * 64 / 8)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
#include "icon.h"
|
||||
#include "icon_i.h"
|
||||
#include <furi.h>
|
||||
|
||||
uint8_t icon_get_width(const Icon* instance) {
|
||||
#include <furi.h>
|
||||
|
||||
uint16_t icon_get_width(const Icon* instance) {
|
||||
furi_check(instance);
|
||||
|
||||
return instance->width;
|
||||
}
|
||||
|
||||
uint8_t icon_get_height(const Icon* instance) {
|
||||
uint16_t icon_get_height(const Icon* instance) {
|
||||
furi_check(instance);
|
||||
|
||||
return instance->height;
|
||||
@@ -16,5 +19,14 @@ uint8_t icon_get_height(const Icon* instance) {
|
||||
const uint8_t* icon_get_data(const Icon* instance) {
|
||||
furi_check(instance);
|
||||
|
||||
return instance->frames[0];
|
||||
return icon_get_frame_data(instance, 0);
|
||||
}
|
||||
|
||||
uint32_t icon_get_frame_count(const Icon* instance) {
|
||||
return instance->frame_count;
|
||||
}
|
||||
|
||||
const uint8_t* icon_get_frame_data(const Icon* instance, uint32_t frame) {
|
||||
furi_check(frame < instance->frame_count);
|
||||
return instance->frames[frame];
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <core/common_defines.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -19,7 +20,7 @@ typedef struct Icon Icon;
|
||||
*
|
||||
* @return width in pixels
|
||||
*/
|
||||
uint8_t icon_get_width(const Icon* instance);
|
||||
uint16_t icon_get_width(const Icon* instance);
|
||||
|
||||
/** Get icon height
|
||||
*
|
||||
@@ -27,15 +28,32 @@ uint8_t icon_get_width(const Icon* instance);
|
||||
*
|
||||
* @return height in pixels
|
||||
*/
|
||||
uint8_t icon_get_height(const Icon* instance);
|
||||
uint16_t icon_get_height(const Icon* instance);
|
||||
|
||||
/** Get Icon XBM bitmap data
|
||||
/** Get Icon XBM bitmap data for the first frame
|
||||
*
|
||||
* @param[in] instance pointer to Icon data
|
||||
*
|
||||
* @return pointer to XBM bitmap data
|
||||
* @return pointer to compressed XBM bitmap data
|
||||
*/
|
||||
const uint8_t* icon_get_data(const Icon* instance);
|
||||
FURI_DEPRECATED const uint8_t* icon_get_data(const Icon* instance);
|
||||
|
||||
/** Get Icon frame count
|
||||
*
|
||||
* @param[in] instance pointer to Icon data
|
||||
*
|
||||
* @return frame count
|
||||
*/
|
||||
uint32_t icon_get_frame_count(const Icon* instance);
|
||||
|
||||
/** Get Icon XBM bitmap data for a particular frame
|
||||
*
|
||||
* @param[in] instance pointer to Icon data
|
||||
* @param[in] frame frame index
|
||||
*
|
||||
* @return pointer to compressed XBM bitmap data
|
||||
*/
|
||||
const uint8_t* icon_get_frame_data(const Icon* instance, uint32_t frame);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "icon.h"
|
||||
#include <stdint.h>
|
||||
|
||||
struct Icon {
|
||||
const uint8_t width;
|
||||
const uint8_t height;
|
||||
const uint16_t width;
|
||||
const uint16_t height;
|
||||
const uint8_t frame_count;
|
||||
const uint8_t frame_rate;
|
||||
const uint8_t* const* frames;
|
||||
|
||||
@@ -10,19 +10,6 @@
|
||||
|
||||
static_assert(!has_hash_collisions(elf_api_table), "Detected API method hash collision!");
|
||||
|
||||
#ifdef APP_UNIT_TESTS
|
||||
constexpr HashtableApiInterface mock_elf_api_interface{
|
||||
{
|
||||
.api_version_major = 0,
|
||||
.api_version_minor = 0,
|
||||
.resolver_callback = &elf_resolve_from_hashtable,
|
||||
},
|
||||
nullptr,
|
||||
nullptr,
|
||||
};
|
||||
|
||||
const ElfApiInterface* const firmware_api_interface = &mock_elf_api_interface;
|
||||
#else
|
||||
constexpr HashtableApiInterface elf_api_interface{
|
||||
{
|
||||
.api_version_major = (elf_api_version >> 16),
|
||||
@@ -33,7 +20,6 @@ constexpr HashtableApiInterface elf_api_interface{
|
||||
elf_api_table.cend(),
|
||||
};
|
||||
const ElfApiInterface* const firmware_api_interface = &elf_api_interface;
|
||||
#endif
|
||||
|
||||
extern "C" void furi_hal_info_get_api_version(uint16_t* major, uint16_t* minor) {
|
||||
*major = firmware_api_interface->api_version_major;
|
||||
|
||||
@@ -353,6 +353,12 @@ static LoaderStatus loader_start_external_app(
|
||||
|
||||
FURI_LOG_I(TAG, "Loaded in %zums", (size_t)(furi_get_tick() - start));
|
||||
|
||||
if(flipper_application_is_plugin(loader->app.fap)) {
|
||||
status = loader_make_status_error(
|
||||
LoaderStatusErrorInternal, error_message, "Plugin %s is not runnable", path);
|
||||
break;
|
||||
}
|
||||
|
||||
loader->app.thread = flipper_application_alloc_thread(loader->app.fap, args);
|
||||
FuriString* app_name = furi_string_alloc();
|
||||
path_extract_filename_no_ext(path, app_name);
|
||||
|
||||
@@ -92,7 +92,7 @@ static bool loader_applications_item_callback(
|
||||
path, loader_applications_app->storage, icon_ptr, item_name);
|
||||
} else {
|
||||
path_extract_filename(path, item_name, false);
|
||||
memcpy(*icon_ptr, icon_get_data(&I_js_script_10px), FAP_MANIFEST_MAX_ICON_SIZE);
|
||||
memcpy(*icon_ptr, icon_get_frame_data(&I_js_script_10px, 0), FAP_MANIFEST_MAX_ICON_SIZE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
#include <flipper.pb.h>
|
||||
#include <cli/cli.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void* (*RpcSystemAlloc)(RpcSession* session);
|
||||
typedef void (*RpcSystemFree)(void* context);
|
||||
typedef void (*PBMessageHandler)(const PB_Main* msg_request, void* context);
|
||||
@@ -45,3 +49,7 @@ void rpc_debug_print_data(const char* prefix, uint8_t* buffer, size_t size);
|
||||
void rpc_cli_command_start_session(Cli* cli, FuriString* args, void* context);
|
||||
|
||||
PB_CommandStatus rpc_system_storage_get_error(FS_Error fs_error);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user