Merge remote-tracking branch 'upstream/master' into abo_RTH_sanity_fix
[inav.git] / src / main / drivers / display_canvas.c
bloba3738e5edb97b6edd329e9b89af1b03d20843941
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 #include "drivers/display_canvas.h"
29 void displayCanvasSetStrokeColor(displayCanvas_t *displayCanvas, displayCanvasColor_e color)
31 if (displayCanvas->vTable->setStrokeColor) {
32 displayCanvas->vTable->setStrokeColor(displayCanvas, color);
36 void displayCanvasSetFillColor(displayCanvas_t *displayCanvas, displayCanvasColor_e color)
38 if (displayCanvas->vTable->setFillColor) {
39 displayCanvas->vTable->setFillColor(displayCanvas, color);
43 void displayCanvasSetStrokeAndFillColor(displayCanvas_t *displayCanvas, displayCanvasColor_e color)
45 if (displayCanvas->vTable->setStrokeAndFillColor) {
46 displayCanvas->vTable->setStrokeAndFillColor(displayCanvas, color);
47 } else {
48 displayCanvasSetStrokeColor(displayCanvas, color);
49 displayCanvasSetFillColor(displayCanvas, color);
53 void displayCanvasSetColorInversion(displayCanvas_t *displayCanvas, bool inverted)
55 if (displayCanvas->vTable->setColorInversion) {
56 displayCanvas->vTable->setColorInversion(displayCanvas, inverted);
60 void displayCanvasSetPixel(displayCanvas_t *displayCanvas, int x, int y, displayCanvasColor_e color)
62 if (displayCanvas->vTable->setPixel) {
63 displayCanvas->vTable->setPixel(displayCanvas, x, y, color);
67 void displayCanvasSetPixelToStrokeColor(displayCanvas_t *displayCanvas, int x, int y)
69 if (displayCanvas->vTable->setPixelToStrokeColor) {
70 displayCanvas->vTable->setPixelToStrokeColor(displayCanvas, x, y);
74 void displayCanvasSetPixelToFillColor(displayCanvas_t *displayCanvas, int x, int y)
76 if (displayCanvas->vTable->setPixelToFillColor) {
77 displayCanvas->vTable->setPixelToFillColor(displayCanvas, x, y);
81 void displayCanvasSetStrokeWidth(displayCanvas_t *displayCanvas, unsigned w)
83 if (displayCanvas->vTable->setStrokeWidth) {
84 displayCanvas->vTable->setStrokeWidth(displayCanvas, w);
88 void displayCanvasSetLineOutlineType(displayCanvas_t *displayCanvas, displayCanvasOutlineType_e outlineType)
90 if (displayCanvas->vTable->setLineOutlineType) {
91 displayCanvas->vTable->setLineOutlineType(displayCanvas, outlineType);
95 void displayCanvasSetLineOutlineColor(displayCanvas_t *displayCanvas, displayCanvasColor_e outlineColor)
97 if (displayCanvas->vTable->setLineOutlineColor) {
98 displayCanvas->vTable->setLineOutlineColor(displayCanvas, outlineColor);
102 void displayCanvasClipToRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h)
104 if (displayCanvas->vTable->clipToRect) {
105 displayCanvas->vTable->clipToRect(displayCanvas, x, y, w, h);
109 void displayCanvasClearRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h)
111 if (displayCanvas->vTable->clearRect) {
112 displayCanvas->vTable->clearRect(displayCanvas, x, y, w, h);
116 void displayCanvasResetDrawingState(displayCanvas_t *displayCanvas)
118 if (displayCanvas->vTable->resetDrawingState) {
119 displayCanvas->vTable->resetDrawingState(displayCanvas);
123 void displayCanvasDrawCharacter(displayCanvas_t *displayCanvas, int x, int y, uint16_t chr, displayCanvasBitmapOption_t opts)
125 if (displayCanvas->vTable->drawCharacter) {
126 displayCanvas->vTable->drawCharacter(displayCanvas, x, y, chr, opts);
130 void displayCanvasDrawCharacterMask(displayCanvas_t *displayCanvas, int x, int y, uint16_t chr, displayCanvasColor_e color, displayCanvasBitmapOption_t opts)
132 if (displayCanvas->vTable->drawCharacterMask) {
133 displayCanvas->vTable->drawCharacterMask(displayCanvas, x, y, chr, color, opts);
137 void displayCanvasDrawString(displayCanvas_t *displayCanvas, int x, int y, const char *s, displayCanvasBitmapOption_t opts)
139 if (displayCanvas->vTable->drawString) {
140 displayCanvas->vTable->drawString(displayCanvas, x, y, s, opts);
144 void displayCanvasDrawStringMask(displayCanvas_t *displayCanvas, int x, int y, const char *s, displayCanvasColor_e color, displayCanvasBitmapOption_t opts)
146 if (displayCanvas->vTable->drawStringMask) {
147 displayCanvas->vTable->drawStringMask(displayCanvas, x, y, s, color, opts);
151 void displayCanvasMoveToPoint(displayCanvas_t *displayCanvas, int x, int y)
153 if (displayCanvas->vTable->moveToPoint) {
154 displayCanvas->vTable->moveToPoint(displayCanvas, x, y);
158 void displayCanvasStrokeLineToPoint(displayCanvas_t *displayCanvas, int x, int y)
160 if (displayCanvas->vTable->strokeLineToPoint) {
161 displayCanvas->vTable->strokeLineToPoint(displayCanvas, x, y);
165 void displayCanvasStrokeTriangle(displayCanvas_t *displayCanvas, int x1, int y1, int x2, int y2, int x3, int y3)
167 if (displayCanvas->vTable->strokeTriangle) {
168 displayCanvas->vTable->strokeTriangle(displayCanvas, x1, y1, x2, y2, x3, y3);
172 void displayCanvasFillTriangle(displayCanvas_t *displayCanvas, int x1, int y1, int x2, int y2, int x3, int y3)
174 if (displayCanvas->vTable->fillTriangle) {
175 displayCanvas->vTable->fillTriangle(displayCanvas, x1, y1, x2, y2, x3, y3);
179 void displayCanvasFillStrokeTriangle(displayCanvas_t *displayCanvas, int x1, int y1, int x2, int y2, int x3, int y3)
181 if (displayCanvas->vTable->fillStrokeTriangle) {
182 displayCanvas->vTable->fillStrokeTriangle(displayCanvas, x1, y1, x2, y2, x3, y3);
186 void displayCanvasStrokeRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h)
188 if (displayCanvas->vTable->strokeRect) {
189 displayCanvas->vTable->strokeRect(displayCanvas, x, y, w, h);
193 void displayCanvasFillRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h)
195 if (displayCanvas->vTable->fillRect) {
196 displayCanvas->vTable->fillRect(displayCanvas, x, y, w, h);
200 void displayCanvasFillStrokeRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h)
202 if (displayCanvas->vTable->fillStrokeRect) {
203 displayCanvas->vTable->fillStrokeRect(displayCanvas, x, y, w, h);
207 void displayCanvasStrokeEllipseInRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h)
209 if (displayCanvas->vTable->strokeEllipseInRect) {
210 displayCanvas->vTable->strokeEllipseInRect(displayCanvas, x, y, w, h);
214 void displayCanvasFillEllipseInRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h)
216 if (displayCanvas->vTable->fillEllipseInRect) {
217 displayCanvas->vTable->fillEllipseInRect(displayCanvas, x, y, w, h);
221 void displayCanvasFillStrokeEllipseInRect(displayCanvas_t *displayCanvas, int x, int y, int w, int h)
223 if (displayCanvas->vTable->fillStrokeEllipseInRect) {
224 displayCanvas->vTable->fillStrokeEllipseInRect(displayCanvas, x, y, w, h);
228 void displayCanvasCtmReset(displayCanvas_t *displayCanvas)
230 if (displayCanvas->vTable->ctmReset) {
231 displayCanvas->vTable->ctmReset(displayCanvas);
235 void displayCanvasCtmSet(displayCanvas_t *displayCanvas, float m11, float m12, float m21, float m22, float m31, float m32)
237 if (displayCanvas->vTable->ctmSet) {
238 displayCanvas->vTable->ctmSet(displayCanvas, m11, m12, m21, m22, m31, m32);
242 void displayCanvasCtmTranslate(displayCanvas_t *displayCanvas, float tx, float ty)
244 if (displayCanvas->vTable->ctmTranslate) {
245 displayCanvas->vTable->ctmTranslate(displayCanvas, tx, ty);
249 void displayCanvasCtmScale(displayCanvas_t *displayCanvas, float sx, float sy)
251 if (displayCanvas->vTable->ctmScale) {
252 displayCanvas->vTable->ctmScale(displayCanvas, sx, sy);
256 void displayCanvasCtmRotate(displayCanvas_t *displayCanvas, float r)
258 if (displayCanvas->vTable->ctmRotate) {
259 displayCanvas->vTable->ctmRotate(displayCanvas, r);
263 void displayCanvasContextPush(displayCanvas_t *displayCanvas)
265 if (displayCanvas->vTable->contextPush) {
266 displayCanvas->vTable->contextPush(displayCanvas);
270 void displayCanvasContextPop(displayCanvas_t *displayCanvas)
272 if (displayCanvas->vTable->contextPop) {
273 displayCanvas->vTable->contextPop(displayCanvas);
277 bool displayCanvasGetWidgets(displayWidgets_t *widgets, const displayCanvas_t *displayCanvas)
279 return displayCanvas && displayCanvas->vTable->getWidgets ? displayCanvas->vTable->getWidgets(widgets, displayCanvas) : false;