FlowArithmeticCalculator 1.0.0
Flow Arithmetic Calculator
Loading...
Searching...
No Matches
SkiaRendererImpl.h
Go to the documentation of this file.
1#ifndef SKIA_RENDERER_H
2#define SKIA_RENDERER_H
3
4#include <GLFW/glfw3.h>
5#include <skia/include/core/SkCanvas.h>
6#include <skia/include/core/SkColorSpace.h>
7#include <skia/include/core/SkPaint.h>
8#include <skia/include/core/SkSurface.h>
9#include <skia/include/gpu/ganesh/GrBackendSurface.h>
10#include <skia/include/gpu/ganesh/GrDirectContext.h>
11#include <skia/include/gpu/ganesh/SkSurfaceGanesh.h>
12#include <skia/include/gpu/ganesh/gl/GrGLBackendSurface.h>
13#include <skia/include/gpu/ganesh/gl/GrGLDirectContext.h>
14#include <skia/include/gpu/ganesh/gl/GrGLInterface.h>
15
16#include <algorithm>
17#include <numeric>
18#include <optional>
19#include <stdexcept>
20#include <vector>
21
22#include "FontManager.h"
28#include "constants.h"
30#include "logging/Loggable.h"
31#include "renderer/colors.h"
32#include "window/WindowBase.h"
33
34// below: 20% margin between texts, 10% margin between rows
35// for SkiaRendererImpl::renderCenteredTextsRows
38
39namespace gui::renderer {
40 // using an empty namespace to avoid polluting the outer scope of gui::renderer
41 namespace {
42 namespace colors = gui::renderer::colors;
44 } // namespace
45
50 protected business_logic::Loggable<SkiaRendererImpl> {
51 public:
62 std::shared_ptr<business_logic::BlocksManager> blocksManager);
63
67 ~SkiaRendererImpl() override;
68
69 // disable copy semantics
72
73 // disable move semantics
76
80 void render();
81
89 float xScale,
90 float yScale);
91
95 void renderCenteredTextsRows(SkCanvas* canvas,
97 const std::vector<components::UITextsRow>& rows) override;
98
99 private:
100 // since Loggable is a template base class, the compiler does not see Logger::logger in the
101 // current scope; so as not to use this->logger explicitly each time, the below brings it to
102 // the current scope explicitly
104
108 std::shared_ptr<business_logic::BlocksManager> blocksManager;
109
114
118 sk_sp<GrDirectContext> grContext;
119
123 sk_sp<SkSurface> skSurface;
124
128 void reinitializeSurface();
129
134 };
135
136} // namespace gui::renderer
137
138#endif // SKIA_RENDERER_H
constexpr float CENTERED_TEXT_ROWS_MARGIN_HORIZONTAL_NORM_PERCENT
constexpr float CENTERED_TEXT_ROWS_MARGIN_VERTICAL_NORM_PERCENT
Class that provides a logger for the given class; automatically deduces the logger.
Definition Loggable.h:37
std::shared_ptr< spdlog::logger > logger
Definition Loggable.h:75
Class responsible for rendering the GUI using Skia and GLFW.
void render()
Renders the current frame.
SkiaRendererImpl(SkiaRendererImpl &&)=delete
void handleWindowResized(gui::window::WindowBase< SkCanvas > *window, float xScale, float yScale)
Handles window resize events.
SkiaRendererImpl(const SkiaRendererImpl &)=delete
std::shared_ptr< business_logic::BlocksManager > blocksManager
The blocks manager.
void reinitializeSurface()
Reinitializes the Skia surface using the current width and height.
SkiaRendererImpl & operator=(const SkiaRendererImpl &)=delete
void renderCenteredTextsRows(SkCanvas *canvas, const business_logic::geometry::Size2D &size, const std::vector< components::UITextsRow > &rows) override
Renders the texts on the canvas around the center horizontally, centered vertically.
sk_sp< GrDirectContext > grContext
The Skia context.
gui::window::WindowBase< SkCanvas > * window
The window.
~SkiaRendererImpl() override
Destructor.
SkiaRendererImpl & operator=(SkiaRendererImpl &&)=delete
sk_sp< SkSurface > skSurface
The Skia surface.
gui::renderer::delegate::UIRendererDelegate< SkCanvas > * uiRendererDelegatePtr
The UI renderer delegate.
The delegate for the UI renderer.
The abstract base class for implementing a window.
Definition WindowBase.h:27
UI primitives and components to be rendered as part of the UI.
Definition UIText.cpp:3
Color constants used for rendering entities.
Definition colors.cpp:3
The GUI renderer and renderer-supporting implementation module.
Definition colors.cpp:3
A basic struct representing a 2D size.
Definition Size2D.h:8