1.10
kmsscreen.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_DETAIL_SCREEN_KMSSCREEN_H
7#define EGT_DETAIL_SCREEN_KMSSCREEN_H
8
14#include <egt/detail/meta.h>
15#include <egt/detail/screen/kmstype.h>
16#include <egt/geometry.h>
17#include <egt/screen.h>
18#include <egt/window.h>
19#include <memory>
20#include <vector>
21
22struct plane_data;
23struct kms_device;
24
25namespace egt
26{
27inline namespace v1
28{
29namespace detail
30{
31struct planeid;
32class KMSOverlay;
33struct FlipThread;
34
40class EGT_API KMSScreen : public Screen
41{
42public:
43
49 explicit KMSScreen(bool allocate_primary_plane = true,
50 PixelFormat format = PixelFormat::rgb565);
51
52 KMSScreen(const KMSScreen&) = delete;
53 KMSScreen& operator=(const KMSScreen&) = delete;
54 KMSScreen(KMSScreen&&) noexcept;
55 KMSScreen& operator=(KMSScreen&&) noexcept;
56
58 enum class plane_type
59 {
60 overlay,
61 primary,
62 cursor
63 };
64
68 uint32_t count_planes(plane_type type = plane_type::overlay);
69
72
73 void schedule_flip() override;
74
75 uint32_t index() override;
76
78 void close();
79
80 EGT_NODISCARD size_t max_brightness() const override;
81
82 EGT_NODISCARD size_t brightness() const override;
83
84 void brightness(size_t brightness) override;
85
86 ~KMSScreen() noexcept override;
87
89 static uint32_t max_buffers();
90
92 unique_plane_t allocate_overlay(const Size& size,
93 PixelFormat format = PixelFormat::argb8888,
94 WindowHint hint = WindowHint::automatic);
95
97 void deallocate_overlay(plane_data* plane);
98
99 EGT_NODISCARD bool have_planes() const override { return true; }
100
101protected:
103 plane_data* overlay_plane_create(const Size& size,
104 PixelFormat format,
105 plane_type type);
106
108 int m_fd{-1};
110 struct kms_device* m_device {nullptr};
114 uint32_t m_index{0};
116 static std::vector<planeid> m_used;
118 std::unique_ptr<FlipThread> m_pool;
120 bool m_gfx2d {false};
121
122 friend class detail::KMSOverlay;
123};
124
125}
126}
127}
128
129#endif
Manages one of more buffers that make up a Screen.
Definition screen.h:34
Screen in a KMS dumb buffer inside of an overlay plane.
Definition kmsoverlay.h:37
Screen in an KMS dumb buffer.
Definition kmsscreen.h:41
~KMSScreen() noexcept override
KMSScreen(bool allocate_primary_plane=true, PixelFormat format=PixelFormat::rgb565)
KMSScreen(KMSScreen &&) noexcept
EGT_NODISCARD size_t brightness() const override
Get the current brightness of the screen.
KMSScreen & operator=(const KMSScreen &)=delete
KMSScreen(const KMSScreen &)=delete
static KMSScreen * instance()
Get a pointer to the KMSScreen instance.
void close()
Close and release the screen.
void brightness(size_t brightness) override
Set the brightness of the screen.
uint32_t index() override
If the screen implementation manages multiple buffers, this will return the index of the current buff...
EGT_NODISCARD size_t max_brightness() const override
Get the max brightness of the screen.
unique_plane_t m_plane
Plane instance pointer.
Definition kmsscreen.h:112
uint32_t count_planes(plane_type type=plane_type::overlay)
Count the number of available hardware planes with a specific type.
plane_data * overlay_plane_create(const Size &size, PixelFormat format, plane_type type)
Allocate an overlay plane.
std::unique_ptr< FlipThread > m_pool
Internal thread pool for flipping.
Definition kmsscreen.h:118
void schedule_flip() override
Schedule a flip to occur later.
plane_type
Available plane types.
Definition kmsscreen.h:59
static std::vector< planeid > m_used
Global array used to keep track of allocated planes.
Definition kmsscreen.h:116
std::unique_ptr< plane_data, detail::plane_t_deleter > unique_plane_t
Unique pointer for a cairo context.
Definition kmstype.h:30
WindowHint
Hint used for configuring Window backends.
Definition widgetflags.h:683
@ overlay
Request an overlay plane.
PixelFormat
Supported pixel formats.
Definition types.h:94
EGT framework namespace.
Definition animation.h:24