unleashed-firmware/applications/services/gui/canvas_i.h

153 lines
3.3 KiB
C
Raw Normal View History

/**
* @file canvas_i.h
* GUI: internal Canvas API
*/
#pragma once
#include "canvas.h"
#include <u8g2.h>
#include <toolbox/compress.h>
#include <m-array.h>
#include <m-algo.h>
#include <furi.h>
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>
2024-05-20 17:23:47 +00:00
#define ICON_DECOMPRESSOR_BUFFER_SIZE (128u * 64 / 8)
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*CanvasCommitCallback)(
uint8_t* data,
size_t size,
CanvasOrientation orientation,
void* context);
typedef struct {
CanvasCommitCallback callback;
void* context;
} CanvasCallbackPair;
ARRAY_DEF(CanvasCallbackPairArray, CanvasCallbackPair, M_POD_OPLIST);
#define M_OPL_CanvasCallbackPairArray_t() ARRAY_OPLIST(CanvasCallbackPairArray, M_POD_OPLIST)
ALGO_DEF(CanvasCallbackPairArray, CanvasCallbackPairArray_t);
/** Canvas structure
*/
struct Canvas {
u8g2_t fb;
CanvasOrientation orientation;
size_t offset_x;
size_t offset_y;
size_t width;
size_t height;
CompressIcon* compress_icon;
CanvasCallbackPairArray_t canvas_callback_pair;
FuriMutex* mutex;
};
/** Allocate memory and initialize canvas
*
* @return Canvas instance
*/
Canvas* canvas_init(void);
/** Free canvas memory
*
* @param canvas Canvas instance
*/
void canvas_free(Canvas* canvas);
/** Get canvas buffer.
*
* @param canvas Canvas instance
*
* @return pointer to buffer
*/
uint8_t* canvas_get_buffer(Canvas* canvas);
/** Get canvas buffer size.
*
* @param canvas Canvas instance
*
* @return size of canvas in bytes
*/
size_t canvas_get_buffer_size(const Canvas* canvas);
/** Set drawing region relative to real screen buffer
*
* @param canvas Canvas instance
* @param offset_x x coordinate offset
* @param offset_y y coordinate offset
* @param width width
* @param height height
*/
void canvas_frame_set(
Canvas* canvas,
int32_t offset_x,
int32_t offset_y,
size_t width,
size_t height);
/** Set canvas orientation
*
* @param canvas Canvas instance
* @param orientation CanvasOrientation
*/
void canvas_set_orientation(Canvas* canvas, CanvasOrientation orientation);
/** Get canvas orientation
*
* @param canvas Canvas instance
*
* @return CanvasOrientation
*/
CanvasOrientation canvas_get_orientation(const Canvas* canvas);
/** Draw a u8g2 bitmap
*
[FL-870] Auto-generated firmware documentation take two (#2944) * Add doxygen and doxygen-awesome css, cleanup docs files * Ignore more libraries and remove leftover local variables * Create an actual intro page * .md files linting * Add doxygen action * Fix Doxygen path * Fix doxyfile path * Try to upload * Change docs branch * Add submudules checkout * Disable doxygen on PR * Mention the firmware docs in the readme * More dev docs mentions in the readme * Fix runner group, add tags * Test dev in PR * Disable running on PR * Fix a typo in the doxyfile * Try upload to S3 * Fix local path * Fix S3 ACL * Add delete flag, unifying dev and tags * Update ignored directories * More ignored directories * Even more ignored directories * Fix submodule * Change S3 uploader * Change S3 uploader version * Fix aws sync flags * Fix ACL * Disable ACL * Improve ignores, add WiFi devboard docs * TEMP: generate dev docs * TEMP: generate 0.89.0 docs * Disabling PR trigger * Enable submodules and test build * Enable test build * Disable test build * Change docs directory structure * Fix accidentally committed submodule * Fix submodules * Update links to the developer documentation * Markdown linting * Update workflow, enable test build * Fix doxygen dir path * Update Doxyfile-awesome.cfg * Change paths * Fix upload docs path * Disable pull_request debug trigger * Disable tags building * Remove autolinks and namespaces * Establish basic documentation structure * Add missing changes * Improve stylesheet, move some files * Improve examples * Improve the main page * Improve application dev docs * Improve system programming docs * Improve development tools docs * Improve other docs * Improve application examples * Fix formatting * Fix PVS-studio warnings * Improve visuals * Fix doxygen syntax warnings * Fix broken links * Update doxygen action Co-authored-by: DrunkBatya <drunkbatya.js@gmail.com> Co-authored-by: あく <alleteam@gmail.com> Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com> Co-authored-by: Georgii Surkov <37121527+gsurkov@users.noreply.github.com>
2024-03-06 06:25:21 +00:00
* @param u8g2 u8g2 instance
* @param x x coordinate
* @param y y coordinate
* @param width width
* @param height height
* @param bitmap bitmap
* @param rotation rotation
*/
void canvas_draw_u8g2_bitmap(
u8g2_t* u8g2,
int32_t x,
int32_t y,
size_t width,
size_t height,
const uint8_t* bitmap,
IconRotation rotation);
/** Add canvas commit callback.
*
* This callback will be called upon Canvas commit.
*
* @param canvas Canvas instance
* @param callback CanvasCommitCallback
* @param context CanvasCommitCallback context
*/
void canvas_add_framebuffer_callback(Canvas* canvas, CanvasCommitCallback callback, void* context);
/** Remove canvas commit callback.
*
* @param canvas Canvas instance
* @param callback CanvasCommitCallback
* @param context CanvasCommitCallback context
*/
void canvas_remove_framebuffer_callback(
Canvas* canvas,
CanvasCommitCallback callback,
void* context);
#ifdef __cplusplus
}
#endif