1.12
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;
33
39class EGT_API KMSScreen : public Screen
40{
41public:
42
48 explicit KMSScreen(bool allocate_primary_plane = true,
49 PixelFormat format = PixelFormat::rgb565);
50
51 KMSScreen(const KMSScreen&) = delete;
52 KMSScreen& operator=(const KMSScreen&) = delete;
53 KMSScreen(KMSScreen&&) noexcept;
54 KMSScreen& operator=(KMSScreen&&) noexcept;
55
57 enum class plane_type
58 {
59 overlay,
60 primary,
61 cursor
62 };
63
67 uint32_t count_planes(plane_type type = plane_type::overlay);
68
71
72 void schedule_flip() override;
73
74 uint32_t index() override;
75
77 void close();
78
79 EGT_NODISCARD size_t max_brightness() const override;
80
81 EGT_NODISCARD size_t brightness() const override;
82
83 void brightness(size_t brightness) override;
84
85 ~KMSScreen() noexcept override;
86
88 static uint32_t max_buffers();
89
91 unique_plane_t allocate_overlay(const Size& size,
92 PixelFormat format = PixelFormat::argb8888,
93 WindowHint hint = WindowHint::automatic);
94
96 void deallocate_overlay(plane_data* plane);
97
98 EGT_NODISCARD bool have_planes() const override { return true; }
99
100 void flush() override;
101
102protected:
104 plane_data* overlay_plane_create(const Size& size,
105 PixelFormat format,
106 plane_type type);
107
109 int m_fd{-1};
111 struct kms_device* m_device {nullptr};
115 uint32_t m_index{0};
117 static std::vector<planeid> m_used;
118
119 friend class detail::KMSOverlay;
120};
121
122}
123}
124}
125
126#endif
Manages one of more buffers that make up a Screen.
Definition screen.h:39
Screen in a KMS dumb buffer inside of an overlay plane.
Definition kmsoverlay.h:35
Screen in an KMS dumb buffer.
Definition kmsscreen.h:40
~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:113
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.
void schedule_flip() override
Schedule a flip to occur later.
plane_type
Available plane types.
Definition kmsscreen.h:58
static std::vector< planeid > m_used
Global array used to keep track of allocated planes.
Definition kmsscreen.h:117
std::unique_ptr< plane_data, detail::plane_t_deleter > unique_plane_t
Unique pointer for a libplanes plane_data structure.
Definition kmstype.h:30
WindowHint
Hint used for configuring Window backends.
Definition widgetflags.h:710
@ overlay
Request an overlay plane.
PixelFormat
Supported pixel formats.
Definition types.h:30
EGT framework namespace.
Definition animation.h:24