Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / drivers / display_canvas.h
blob7abff66d32902c15b69155ad009023bf14e6c9ce
1 /*
2 * This file is part of INAV.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
6 * You can obtain one at http://mozilla.org/MPL/2.0/.
8 * Alternatively, the contents of this file may be used under the terms
9 * of the GNU General Public License Version 3, as described below:
11 * This file is free software: you may copy, redistribute and/or modify
12 * it under the terms of the GNU General Public License as published by the
13 * Free Software Foundation, either version 3 of the License, or (at your
14 * option) any later version.
16 * This file is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
19 * Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see http://www.gnu.org/licenses/.
24 * @author Alberto Garcia Hierro <alberto@garciahierro.com>
27 #pragma once
29 #include <stdbool.h>
30 #include <stdint.h>
32 typedef struct displayWidgets_s displayWidgets_t;
34 typedef enum {
35 DISPLAY_CANVAS_BITMAP_OPT_INVERT_COLORS = 1 << 0,
36 DISPLAY_CANVAS_BITMAP_OPT_SOLID_BACKGROUND = 1 << 1,
37 DISPLAY_CANVAS_BITMAP_OPT_ERASE_TRANSPARENT = 1 << 2,
38 } displayCanvasBitmapOption_t;
40 typedef enum {
41 DISPLAY_CANVAS_COLOR_BLACK = 0,
42 DISPLAY_CANVAS_COLOR_TRANSPARENT = 1,
43 DISPLAY_CANVAS_COLOR_WHITE = 2,
44 DISPLAY_CANVAS_COLOR_GRAY = 3,
45 } displayCanvasColor_e;
47 typedef enum {
48 DISPLAY_CANVAS_OUTLINE_TYPE_NONE = 0,
49 DISPLAY_CANVAS_OUTLINE_TYPE_TOP = 1 << 0,
50 DISPLAY_CANVAS_OUTLINE_TYPE_RIGHT = 1 << 1,
51 DISPLAY_CANVAS_OUTLINE_TYPE_BOTTOM = 1 << 2,
52 DISPLAY_CANVAS_OUTLINE_TYPE_LEFT = 1 << 3,
53 } displayCanvasOutlineType_e;
55 typedef struct displayCanvasVTable_s displayCanvasVTable_t;
57 typedef struct displayCanvas_s {
58 const displayCanvasVTable_t *vTable;
59 void *device;
60 uint16_t width;
61 uint16_t height;
62 uint8_t gridElementWidth;
63 uint8_t gridElementHeight;
64 } displayCanvas_t;
66 typedef struct displayCanvasVTable_s {
67 void (*setStrokeColor)(displayCanvas_t *displayCanvas, displayCanvasColor_e color);
68 void (*setFillColor)(displayCanvas_t *displayCanvas, displayCanvasColor_e color);
69 void (*setStrokeAndFillColor)(displayCanvas_t *displayCanvas, displayCanvasColor_e color);
70 void (*setColorInversion)(displayCanvas_t *displayCanvas, bool inverted);
71 void (*setPixel)(displayCanvas_t *displayCanvas, int x, int y, displayCanvasColor_e color);
72 void (*setPixelToStrokeColor)(displayCanvas_t *displayCanvas, int x, int y);
73 void (*setPixelToFillColor)(displayCanvas_t *displayCanvas, int x, int y);
74 void (*setStrokeWidth)(displayCanvas_t *displayCanvas, unsigned w);
75 void (*setLineOutlineType)(displayCanvas_t *displayCanvas, displayCanvasOutlineType_e outlineType);
76 void (*setLineOutlineColor)(displayCanvas_t *displayCanvas, displayCanvasColor_e outlineColor);
78 void (*clipToRect)(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
79 void (*clearRect)(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
80 void (*resetDrawingState)(displayCanvas_t *displayCanvas);
81 void (*drawCharacter)(displayCanvas_t *displayCanvas, int x, int y, uint16_t chr, displayCanvasBitmapOption_t opts);
82 void (*drawCharacterMask)(displayCanvas_t *displayCanvas, int x, int y, uint16_t chr, displayCanvasColor_e color, displayCanvasBitmapOption_t opts);
83 void (*drawString)(displayCanvas_t *displayCanvas, int x, int y, const char *s, displayCanvasBitmapOption_t opts);
84 void (*drawStringMask)(displayCanvas_t *displayCanvas, int x, int y, const char *s, displayCanvasColor_e color, displayCanvasBitmapOption_t opts);
85 void (*moveToPoint)(displayCanvas_t *displayCanvas, int x, int y);
86 void (*strokeLineToPoint)(displayCanvas_t *displayCanvas, int x, int y);
87 void (*strokeTriangle)(displayCanvas_t *displayCanvas, int x1, int y1, int x2, int y2, int x3, int y3);
88 void (*fillTriangle)(displayCanvas_t *displayCanvas, int x1, int y1, int x2, int y2, int x3, int y3);
89 void (*fillStrokeTriangle)(displayCanvas_t *displayCanvas, int x1, int y1, int x2, int y2, int x3, int y3);
90 void (*strokeRect)(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
91 void (*fillRect)(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
92 void (*fillStrokeRect)(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
93 void (*strokeEllipseInRect)(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
94 void (*fillEllipseInRect)(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
95 void (*fillStrokeEllipseInRect)(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
97 void (*ctmReset)(displayCanvas_t *displayCanvas);
98 void (*ctmSet)(displayCanvas_t *displayCanvas, float m11, float m12, float m21, float m22, float m31, float m32);
99 void (*ctmTranslate)(displayCanvas_t *displayCanvas, float tx, float ty);
100 void (*ctmScale)(displayCanvas_t *displayCanvas, float sx, float sy);
101 void (*ctmRotate)(displayCanvas_t *displayCanvas, float r);
103 void (*contextPush)(displayCanvas_t *displayCanvas);
104 void (*contextPop)(displayCanvas_t *displayCanvas);
106 bool (*getWidgets)(displayWidgets_t *widgets, const displayCanvas_t *displayCanvas);
107 } displayCanvasVTable_t;
109 void displayCanvasSetStrokeColor(displayCanvas_t *displayCanvas, displayCanvasColor_e color);
110 void displayCanvasSetFillColor(displayCanvas_t *displayCanvas, displayCanvasColor_e color);
111 void displayCanvasSetStrokeAndFillColor(displayCanvas_t *displayCanvas, displayCanvasColor_e color);
112 void displayCanvasSetColorInversion(displayCanvas_t *displayCanvas, bool inverted);
113 void displayCanvasSetPixel(displayCanvas_t *displayCanvas, int x, int y, displayCanvasColor_e);
114 void displayCanvasSetPixelToStrokeColor(displayCanvas_t *displayCanvas, int x, int y);
115 void displayCanvasSetPixelToFillColor(displayCanvas_t *displayCanvas, int x, int y);
116 void displayCanvasSetStrokeWidth(displayCanvas_t *displayCanvas, unsigned w);
117 void displayCanvasSetLineOutlineType(displayCanvas_t *displayCanvas, displayCanvasOutlineType_e outlineType);
118 void displayCanvasSetLineOutlineColor(displayCanvas_t *displayCanvas, displayCanvasColor_e outlineColor);
120 void displayCanvasClipToRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
121 void displayCanvasClearRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
122 void displayCanvasResetDrawingState(displayCanvas_t *displayCanvas);
123 void displayCanvasDrawCharacter(displayCanvas_t *displayCanvas, int x, int y, uint16_t chr, displayCanvasBitmapOption_t opts);
124 void displayCanvasDrawCharacterMask(displayCanvas_t *displayCanvas, int x, int y, uint16_t chr, displayCanvasColor_e color, displayCanvasBitmapOption_t opts);
125 void displayCanvasDrawString(displayCanvas_t *displayCanvas, int x, int y, const char *s, displayCanvasBitmapOption_t opts);
126 void displayCanvasDrawStringMask(displayCanvas_t *displayCanvas, int x, int y, const char *s, displayCanvasColor_e color, displayCanvasBitmapOption_t opts);
127 void displayCanvasMoveToPoint(displayCanvas_t *displayCanvas, int x, int y);
128 void displayCanvasStrokeLineToPoint(displayCanvas_t *displayCanvas, int x, int y);
129 void displayCanvasStrokeTriangle(displayCanvas_t *displayCanvas, int x1, int y1, int x2, int y2, int x3, int y3);
130 void displayCanvasFillTriangle(displayCanvas_t *displayCanvas, int x1, int y1, int x2, int y2, int x3, int y3);
131 void displayCanvasFillStrokeTriangle(displayCanvas_t *displayCanvas, int x1, int y1, int x2, int y2, int x3, int y3);
132 void displayCanvasStrokeRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
133 void displayCanvasFillRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
134 void displayCanvasFillStrokeRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
135 void displayCanvasStrokeEllipseInRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
136 void displayCanvasFillEllipseInRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
137 void displayCanvasFillStrokeEllipseInRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h);
139 void displayCanvasCtmReset(displayCanvas_t *displayCanvas);
140 void displayCanvasCtmSet(displayCanvas_t *displayCanvas, float m11, float m12, float m21, float m22, float m31, float m32);
141 void displayCanvasCtmTranslate(displayCanvas_t *displayCanvas, float tx, float ty);
142 void displayCanvasCtmScale(displayCanvas_t *displayCanvas, float sx, float sy);
143 void displayCanvasCtmRotate(displayCanvas_t *displayCanvas, float r);
145 void displayCanvasContextPush(displayCanvas_t *displayCanvas);
146 void displayCanvasContextPop(displayCanvas_t *displayCanvas);
148 bool displayCanvasGetWidgets(displayWidgets_t *widgets, const displayCanvas_t *displayCanvas);