~aleteoryx/muditaos

ref: e6213e94077379e7d1ae6908dc2a6769fa406ccb muditaos/module-gui/gui/core/Renderer.hpp -rw-r--r-- 1.6 KiB
e6213e94 — Lucjan Bryndza [EGD-5737] Merge master into experimental 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <list>

#include <module-utils/math/Math.hpp>

#include "DrawCommand.hpp"
#include "Context.hpp"
#include "DrawCommandForward.hpp"

namespace gui
{
    class RawFont;
    class FontGlyph;

    class Renderer
    {
        /**
         * convention: all the coordinates are is a pixel. the origin is (0,0) and it's ABOVE (UP) & TO THE LEFT of the
         * topmost left pixel. Therefore to draw 1px wide line spanning the whole topmost row, it will be drawHorizontal
         * (0,0, 1px, length, ::DOWN). It's equvalent to drawHorizontal (0,1, 1px, length, ::UP); default is DOWN &
         * RIGHT a is the first pixel. a is (0,0) DOWN (& RIGHT) == a is (0,1) UP (& RIGHT) b is (2,2) UP (& RIGHT)   ==
         * b is (2,1) DOWN (& RIGHT)
         *
         * _| 0 1 2 3
         * 0  a
         * 1      b
         * 2
         * 3
         *
         */
      protected:
        void drawLine(Context *ctx, CommandLine *cmd);

        void drawRectangle(Context *ctx, CommandRectangle *cmd);

        void drawArc(Context *ctx, CommandArc *cmd);

        void drawCircle(Context *ctx, CommandCircle *cmd);

        void drawText(Context *ctx, CommandText *cmd);

        void drawChar(Context *context, const int16_t x, const int16_t y, FontGlyph *glyph, const Color color);

        void drawImage(Context *ctx, CommandImage *cmd);

      public:
        virtual ~Renderer() = default;

        void render(Context *ctx, std::list<std::unique_ptr<DrawCommand>> &commands);
    };

} /* namespace gui */