Vivoe Lite 0.5.0
Lightweight GVA like HMI for military displays.
Loading...
Searching...
No Matches
renderer.h
Go to the documentation of this file.
1//
2// Copyright (c) 2023, DefenceX PTY LTD
3//
4// This file is part of the VivoeX project developed by DefenceX.
5//
6// Licensed under the Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
7// License. See the LICENSE file in the project root for full license details.
8//
12
13#ifndef HMICORE_RENDERER_H_
14#define HMICORE_RENDERER_H_
15#include <stdint.h>
16
17#include <string>
18
19#include "hmicore/gva.h"
20
22const gva::ColourType kHmiAmber = {255, 153, 0};
24const gva::ColourType kHmiWhite = {255, 255, 255};
26const gva::ColourType kHmiRed = {255, 0, 0};
28const gva::ColourType kHmiGrey = {127, 127, 127};
30const gva::ColourType kHmiMediumGrey = {96, 96, 96};
32const gva::ColourType kHmiDarkGrey = {64, 64, 64};
34const gva::ColourType kHmiGreen = {0, 255, 0};
36const gva::ColourType kHmiDarkGreen = {0, 128, 0};
40const gva::ColourType kHmiBlue = {0, 0, 255};
42const gva::ColourType kHmiCyan = {0, 255, 255};
44const gva::ColourType kHmiDarkBlue = {51, 102, 153};
46const gva::ColourType kHmiLightBlue = {50, 50, 255};
48const gva::ColourType kHmiBlack = {0, 0, 0};
50const gva::ColourType kHmiYellow = {255, 255, 0};
52const gva::ColourType kHmiOrange = {255, 165, 0};
54const gva::ColourType kHmiNone = {0, 0, 0};
55
56namespace gva {
57
58class RendererCairo;
59
61class Renderer {
62 public:
69 Renderer(uint32_t width, uint32_t height);
70
75 virtual ~Renderer() = default;
76
83 virtual void SetPixel(uint32_t x, uint32_t y) = 0;
84
92 virtual void SetColour(uint8_t red, uint8_t green, uint8_t blue) = 0;
93
101 virtual void SetColourForeground(uint8_t red, uint8_t green, uint8_t blue) = 0;
102
110 virtual void SetColourBackground(uint8_t red, uint8_t green, uint8_t blue) = 0;
111
117 static uint32_t GetWidth() { return width_; }
118
124 static uint32_t GetHeight() { return height_; }
125
131 static void SetWidth(uint32_t width) { width_ = width; }
132
138 static void SetHeight(uint32_t height) { height_ = height; }
139
149 virtual uint32_t DrawLine(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2) = 0;
150
159 virtual void DrawCircle(uint32_t x, uint32_t y, uint32_t radius, bool fill) = 0;
160
170 virtual void DrawRectangle(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, bool fill) = 0;
171
180 virtual uint32_t DrawColor(uint8_t r, uint8_t g, uint8_t b) = 0;
181
191 virtual uint32_t TextureRGB(uint32_t x, uint32_t y, unsigned char* buffer, std::string_view file) = 0;
192
199 static uint32_t PackRgb(ColourType colour);
200
209 static uint32_t PackRgb(uint8_t r, uint8_t g, uint8_t b);
210
217 uint32_t UnpackRed(uint32_t rgb) const { return (rgb & 0xff0000) >> 16; }
218
225 uint32_t UnpackGreen(uint32_t rgb) const { return (rgb & 0xff00) >> 8; }
226
233 uint32_t UnpackBlue(uint32_t rgb) const { return rgb & 0xff; }
234
241 RgbUnpackedType UnpackRgb(uint64_t rgb) const;
242
243 protected:
245 static uint32_t height_;
247 static uint32_t width_;
248
249 private:
251 ColourType foreground_colour_;
253 ColourType background_colour_;
255 friend class RendererCairo;
256};
257
258} // namespace gva
259
260#endif // HMICORE_RENDERER_H_
Class definition of the Renderer Cairo.
Definition renderer_cairo.h:82
Class defining the renderer.
Definition renderer.h:61
static uint32_t height_
The height of the renderer.
Definition renderer.h:245
virtual void DrawCircle(uint32_t x, uint32_t y, uint32_t radius, bool fill)=0
Draw a circle, set filled to true to have solid circle.
virtual void SetColour(uint8_t red, uint8_t green, uint8_t blue)=0
Set the Colour attribute.
virtual void DrawRectangle(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, bool fill)=0
Draw a rectangle, set filled to true to have solid rectangle.
RgbUnpackedType UnpackRgb(uint64_t rgb) const
Unpack red, green and blue values.
Definition renderer.cc:27
virtual uint32_t DrawColor(uint8_t r, uint8_t g, uint8_t b)=0
Set the draw colour.
uint32_t UnpackRed(uint32_t rgb) const
Unpack a red value.
Definition renderer.h:217
virtual ~Renderer()=default
Destroy the Renderer object.
uint32_t UnpackBlue(uint32_t rgb) const
Unpack a blue value.
Definition renderer.h:233
virtual uint32_t TextureRGB(uint32_t x, uint32_t y, unsigned char *buffer, std::string_view file)=0
Set the background texture to and RGB buffer (No Alpha channel)
virtual void SetPixel(uint32_t x, uint32_t y)=0
Set the Pixel attribute.
static void SetWidth(uint32_t width)
Set the Width attribute.
Definition renderer.h:131
static uint32_t PackRgb(ColourType colour)
Pack the colour to RGB.
Definition renderer.cc:35
uint32_t UnpackGreen(uint32_t rgb) const
Unpack a green value.
Definition renderer.h:225
virtual void SetColourBackground(uint8_t red, uint8_t green, uint8_t blue)=0
Set the Colour Background attribute.
static uint32_t width_
The width of the renderer.
Definition renderer.h:247
static void SetHeight(uint32_t height)
Set the Height attribute.
Definition renderer.h:138
virtual uint32_t DrawLine(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2)=0
Draw a straight line.
virtual void SetColourForeground(uint8_t red, uint8_t green, uint8_t blue)=0
Set the Colour Foreground attribute.
static uint32_t GetWidth()
Get the Width attribute.
Definition renderer.h:117
static uint32_t GetHeight()
Get the Height attribute.
Definition renderer.h:124
const gva::ColourType kHmiGrey
The RGB values for dark red.
Definition renderer.h:28
const gva::ColourType kHmiLightBlue
The RGB values for dark red.
Definition renderer.h:46
const gva::ColourType kHmiDarkGreen
The RGB values for dark red.
Definition renderer.h:36
const gva::ColourType kHmiYellow
The RGB values for dark red.
Definition renderer.h:50
const gva::ColourType kHmiBlue
The RGB values for dark red.
Definition renderer.h:40
const gva::ColourType kHmiWhite
The RGB values for white.
Definition renderer.h:24
const gva::ColourType kHmiAmber
The RGB values for amber.
Definition renderer.h:22
const gva::ColourType kHmiBlack
The RGB values for dark red.
Definition renderer.h:48
const gva::ColourType kHmiDarkGreen2
The RGB values for dark red.
Definition renderer.h:38
const gva::ColourType kHmiRed
The RGB values for red.
Definition renderer.h:26
const gva::ColourType kHmiGreen
The RGB values for dark red.
Definition renderer.h:34
const gva::ColourType kHmiCyan
The RGB values for dark red.
Definition renderer.h:42
const gva::ColourType kHmiDarkGrey
The RGB values for dark red.
Definition renderer.h:32
const gva::ColourType kHmiNone
The RGB values for dark red.
Definition renderer.h:54
const gva::ColourType kHmiMediumGrey
The RGB values for dark red.
Definition renderer.h:30
const gva::ColourType kHmiOrange
The RGB values for dark red.
Definition renderer.h:52
const gva::ColourType kHmiDarkBlue
The RGB values for dark red.
Definition renderer.h:44
Struct for the colour.
Definition gva.h:553
Struct for RGB values.
Definition gva.h:581