13#ifndef HMICORE_RENDERER_CAIRO_H_
14#define HMICORE_RENDERER_CAIRO_H_
76enum class LineCapEnd { kLineCapButt, kLineCapRound, kLineCapSquare };
79typedef void (*CallbackType)(
void *io, gpointer data);
109 HandleType *
Init(uint32_t width, uint32_t height,
bool fullscreen =
false);
117 void SetPixel(uint32_t x, uint32_t y)
override;
126 void SetColour(uint8_t red, uint8_t green, uint8_t blue)
override;
212 uint32_t
MovePen(int32_t x, int32_t y);
222 uint32_t
DrawPen(uint32_t x, uint32_t y,
bool close);
260 void DrawArcRaw(uint32_t x, uint32_t y, uint32_t radius, uint32_t angle1, uint32_t angle2);
271 uint32_t
DrawLine(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2)
override;
291 void Scale(
double x,
double y);
306 void Rotate(
double radians);
324 void DrawCircle(uint32_t x, uint32_t y, uint32_t radius,
bool fill)
override;
335 void DrawRectangle(uint32_t x, uint32_t y, uint32_t width, uint32_t height,
bool fill)
override;
347 void DrawRoundedRectangle(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t corner,
bool fill);
360 void DrawTriangle(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, uint32_t x3, uint32_t y3,
bool fill);
378 uint32_t
DrawColor(uint8_t r, uint8_t g, uint8_t b)
override;
393 uint32_t
CurveTo(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, uint32_t x3, uint32_t y3);
432 uint32_t
GetTextWidth(std::string_view str, uint32_t fontSize)
const;
441 uint32_t
GetTextHeight(std::string_view str, uint32_t fontSize)
const;
450 void DrawString(uint32_t x, uint32_t y, std::string_view text);
459 void DrawLabel(uint32_t x, uint32_t y, std::string_view text);
468 void DrawTextCentre(uint32_t x, std::string_view text, uint32_t size);
479 uint32_t
TextureRGB(uint32_t x, uint32_t y,
unsigned char *buffer, std::string_view file)
override;
489 uint32_t
TextureRGB(uint32_t x, uint32_t y,
unsigned char *buffer);
499 uint32_t
TextureRGB(uint32_t x, uint32_t y, cairo_surface_t *surface);
514 draw_commands_.clear();
566 void Configure(uint32_t height, uint32_t width);
575 int32_t current_handle_;
584 double IntToFloat(
int c)
const {
return static_cast<double>(1) / 255 * c; }
589 std::vector<Command> draw_commands_;
594 std::vector<image_type> image_list_;
599 std::vector<image_type> cache_image_list_;
Class definition of the HandleType.
Definition renderer_cairo_types.h:23
Class definition of the Renderer Cairo.
Definition renderer_cairo.h:82
void Configure(uint32_t height, uint32_t width)
Configure the surface to use new dimensions.
Definition renderer_cairo.cc:712
void Draw()
Redraw the screen.
Definition renderer_cairo.cc:39
void DrawArcRaw(uint32_t x, uint32_t y, uint32_t radius, uint32_t angle1, uint32_t angle2)
Definition renderer_cairo.cc:463
uint32_t MovePen(int32_t x, int32_t y)
Definition renderer_cairo.cc:359
void DrawTextCentre(uint32_t x, std::string_view text, uint32_t size)
Draw some text on the screen and centre it.
Definition renderer_cairo.cc:609
void Save()
Save the current state of the renderer.
Definition renderer_cairo.cc:399
uint32_t GetTextHeight(std::string_view str, uint32_t fontSize) const
Get the Text Height object.
Definition renderer_cairo.cc:580
void SetSurface(cairo_surface_t *surface)
Set the Surface attribute, used by application.
Definition renderer_cairo.cc:710
void Scale(double x, double y)
Scale the renderer.
Definition renderer_cairo.cc:411
void Restore()
Restore the last saved state of the renderer.
Definition renderer_cairo.cc:405
~RendererCairo() override
Destroy the Renderer Cairo object.
Definition renderer_cairo.cc:37
void Rotate(double radians)
Rotate the renderer.
Definition renderer_cairo.cc:427
uint32_t DrawLine(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2) override
Definition renderer_cairo.cc:442
void DrawRectangle(uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool fill) override
Draw a rectangle.
Definition renderer_cairo.cc:474
void SetPixel(uint32_t x, uint32_t y) override
Definition renderer_cairo.cc:291
uint32_t TextureRGB(uint32_t x, uint32_t y, unsigned char *buffer, std::string_view file) override
Set a texture (file) to use as a bitmap.
Definition renderer_cairo.cc:613
void DrawTriangle(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, uint32_t x3, uint32_t y3, bool fill)
Draw a triangle.
Definition renderer_cairo.cc:501
void DrawCircle(uint32_t x, uint32_t y, uint32_t radius, bool fill) override
Draw a circle.
Definition renderer_cairo.cc:451
uint32_t GetHeight() const
Get the Height object.
Definition renderer_cairo.h:537
uint32_t MovePenRaw(int32_t x, int32_t y)
Definition renderer_cairo.cc:369
static HandleType render_
Class definition of the HandleType.
Definition renderer_cairo.h:85
uint32_t DrawPenRaw(int32_t x, int32_t y)
Definition renderer_cairo.cc:389
void SetLineType(uint32_t type)
Set the Line Type object.
Definition renderer_cairo.cc:339
uint32_t DrawPen(uint32_t x, uint32_t y, bool close)
Definition renderer_cairo.cc:379
void SetHeight(uint32_t height) const
Set the Height object.
Definition renderer_cairo.h:523
uint32_t GetWidth() const
Get the Width object.
Definition renderer_cairo.h:544
uint32_t CurveTo(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, uint32_t x3, uint32_t y3)
Adds a cubic Bézier spline to the path from the current point to position (x3 , y3 ) in user-space co...
Definition renderer_cairo.cc:525
void SetWidth(uint32_t width) const
Set the Width object.
Definition renderer_cairo.h:530
void DrawSurface(cairo_t *cr)
Draw the new cairo surface to the screen.
Definition renderer_cairo.cc:705
uint32_t ClosePath(bool fill)
Close drawing path.
Definition renderer_cairo.cc:434
void Reset()
Redraw the screen.
Definition renderer_cairo.h:513
uint32_t DrawColor(ColourType colour)
Set the Colour object to draw with.
Definition renderer_cairo.cc:538
void SetLineThickness(uint32_t thickness, LineType fill)
Set the Line Thickness object.
Definition renderer_cairo.cc:355
void SetTextFont(uint32_t slope, widget::WeightType weight, std::string_view font_name, double size)
Set the Text Font object.
Definition renderer_cairo.cc:548
void SetColourForeground(ColourType colour)
Set the Colour Foreground object.
Definition renderer_cairo.cc:309
void SetColourBackground(ColourType colour)
Set the Colour Background attribute.
Definition renderer_cairo.cc:317
void DrawString(uint32_t x, uint32_t y, std::string_view text)
Draw some text on the screen.
Definition renderer_cairo.cc:589
void Translate(uint32_t x, uint32_t y)
Translate the renderer.
Definition renderer_cairo.cc:419
static void DestroySurface()
Destroy the current cairo surface, usually called during shutdown.
Definition renderer_cairo.cc:719
void Pop()
Pop the last saved state of the renderer.
Definition renderer_cairo.cc:564
void DrawRoundedRectangle(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t corner, bool fill)
Draw a rounded rectangle.
Definition renderer_cairo.cc:488
uint32_t GetTextWidth(std::string_view str, uint32_t fontSize) const
Get the Text Width object.
Definition renderer_cairo.cc:570
uint32_t DrawPen(uint32_t x, uint32_t y)
Definition renderer_cairo.h:231
void Push()
Push the current state of the renderer.
Definition renderer_cairo.cc:558
HandleType * Init(uint32_t width, uint32_t height, bool fullscreen=false)
Initalise the renderer with display parameters.
Definition renderer_cairo.cc:281
void DrawLabel(uint32_t x, uint32_t y, std::string_view text)
Draw an on screen label.
Definition renderer_cairo.cc:598
void SetColour(uint8_t red, uint8_t green, uint8_t blue) override
Set the Colour object.
Definition renderer_cairo.cc:293
Class defining the renderer.
Definition renderer.h:61
static uint32_t height_
The height of the renderer.
Definition renderer.h:245
friend class RendererCairo
The Cairo renderer.
Definition renderer.h:255
static uint32_t width_
The width of the renderer.
Definition renderer.h:247
LineType
Enum for the label states.
Definition gva.h:54
const gva::ColourType kHmiWhite
The RGB values for white.
Definition renderer.h:24
LineCapEnd
Struct definition of the LineType.
Definition renderer_cairo.h:76
DrawType
Class definition of the DrawType.
Definition renderer_cairo_types.h:40
Struct for the colour.
Definition gva.h:553
The Command structure.
Definition renderer_cairo.h:34
int32_t arg2
An argument value 2.
Definition renderer_cairo.h:54
int32_t arg4
An argument value 4.
Definition renderer_cairo.h:58
double width
The width value.
Definition renderer_cairo.h:40
double height
The height value.
Definition renderer_cairo.h:38
double angle2
The angle2 value.
Definition renderer_cairo.h:48
bool fill
Fill if true.
Definition renderer_cairo.h:62
DrawType command
The command type.
Definition renderer_cairo.h:36
int32_t arg1
An argument value 1.
Definition renderer_cairo.h:52
ColourType colour
The colour value.
Definition renderer_cairo.h:50
std::array< PointType, 3 > points
Points value.
Definition renderer_cairo.h:42
double angle1
The angle1 value.
Definition renderer_cairo.h:46
int32_t arg3
An argument value 3.
Definition renderer_cairo.h:56
double radius
The radius value.
Definition renderer_cairo.h:44
std::string text
String text.
Definition renderer_cairo.h:60
Struct definition of the image_type.
Definition renderer_cairo.h:66
cairo_surface_t * image
The images cairo surface.
Definition renderer_cairo.h:70
std::string name
The images string filename.
Definition renderer_cairo.h:68
bool from_cache
True if read from cache.
Definition renderer_cairo.h:72