1.2
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
KMSScreen Class Reference

Screen in an KMS dumb buffer. More...

Inheritance diagram for KMSScreen:
Inheritance graph
[legend]

Public Types

enum class  plane_type { overlay , primary , cursor }
 Available plane types. More...
 
- Public Types inherited from Screen
using DamageArray = std::vector< Rect >
 Type used for damage arrays. More...
 

Public Member Functions

 KMSScreen (bool allocate_primary_plane=true, PixelFormat format=PixelFormat::rgb565)
 
 KMSScreen (const KMSScreen &)=delete
 
 KMSScreen (KMSScreen &&) noexcept
 
 ~KMSScreen () noexcept override
 
unique_plane_t allocate_overlay (const Size &size, PixelFormat format=PixelFormat::argb8888, WindowHint hint=WindowHint::automatic)
 Allocate an overlay plane. More...
 
EGT_NODISCARD size_t brightness () const override
 Get the current brightness of the screen. More...
 
void brightness (size_t brightness) override
 Set the brightness of the screen. More...
 
void close ()
 Close and release the screen. More...
 
uint32_t count_planes (plane_type type=plane_type::overlay)
 Count the number of available hardware planes with a specific type. More...
 
void deallocate_overlay (plane_data *plane)
 Deallocate an overlay plane. More...
 
EGT_NODISCARD bool have_planes () const override
 Returns true if the screen supports planes. More...
 
uint32_t index () override
 If the screen implementation manages multiple buffers, this will return the index of the current buffer. More...
 
EGT_NODISCARD size_t max_brightness () const override
 Get the max brightness of the screen. More...
 
KMSScreenoperator= (const KMSScreen &)=delete
 
KMSScreenoperator= (KMSScreen &&) noexcept
 
void schedule_flip () override
 Schedule a flip to occur later. More...
 
- Public Member Functions inherited from Screen
 Screen () noexcept
 
 Screen (const Screen &)=default
 
 Screen (Screen &&) noexcept=default
 
virtual ~Screen () noexcept=default
 
void async_flip (bool async)
 Set if asynchronous buffer flips are used. More...
 
EGT_NODISCARD Rect box () const
 Bounding box for the screen. More...
 
EGT_NODISCARD shared_cairo_t context () const
 Get the context for the screen. More...
 
virtual void flip (const DamageArray &damage)
 Perform a flip of the buffers. More...
 
EGT_NODISCARD PixelFormat format () const
 Get the format of the screen. More...
 
virtual void high_fidelity ()
 Configure high fidelity options. More...
 
virtual void low_fidelity ()
 Configure low fidelity options. More...
 
Screenoperator= (const Screen &)=default
 
Screenoperator= (Screen &&) noexcept=default
 
EGT_NODISCARD Size size () const
 Size of the screen. More...
 

Static Public Member Functions

static KMSScreeninstance ()
 Get a pointer to the KMSScreen instance. More...
 
static uint32_t max_buffers ()
 Get the number of buffers to use for KMS planes. More...
 
- Static Public Member Functions inherited from Screen
static void damage_algorithm (Screen::DamageArray &damage, Rect rect)
 This function implements the algorithm for adding damage rectangles to a list. More...
 

Protected Member Functions

plane_data * overlay_plane_create (const Size &size, PixelFormat format, plane_type type)
 Allocate an overlay plane. More...
 
- Protected Member Functions inherited from Screen
virtual void copy_to_buffer (ScreenBuffer &buffer)
 Copy the framebuffer to the current composition buffer. More...
 
void copy_to_buffer_software (ScreenBuffer &buffer)
 Copy the framebuffer to the current composition buffer. More...
 
void init (const Size &size, PixelFormat format=PixelFormat::argb8888)
 
void init (void **ptr, uint32_t count, const Size &size, PixelFormat format=PixelFormat::argb8888)
 

Protected Attributes

struct kms_device * m_device {nullptr}
 Instance of the KMS device. More...
 
int m_fd {-1}
 Internal DRM/KMS file descriptor. More...
 
bool m_gfx2d {false}
 Enable GFX2D. More...
 
uint32_t m_index {0}
 Current flip index. More...
 
unique_plane_t m_plane
 Plane instance pointer. More...
 
std::unique_ptr< FlipThread > m_pool
 Internal thread pool for flipping. More...
 
- Protected Attributes inherited from Screen
bool m_async {false}
 Perform flips asynchronously if supported. More...
 
BufferArray m_buffers
 Screen buffer array. More...
 
shared_cairo_t m_cr
 Composition surface context. More...
 
PixelFormat m_format {}
 Format of the screen. More...
 
Size m_size
 Size of the screen. More...
 
shared_cairo_surface_t m_surface
 Composition surface. More...
 

Static Protected Attributes

static std::vector< planeid > m_used
 Global array used to keep track of allocated planes. More...
 

Friends

class detail::KMSOverlay
 

Additional Inherited Members

- Protected Types inherited from Screen
using BufferArray = std::vector< ScreenBuffer >
 Type used for an array of ScreenBuffer objects. More...
 

Detailed Description

Screen in an KMS dumb buffer.

This uses libplanes to modeset and configure planes.

Member Enumeration Documentation

◆ plane_type

enum plane_type
strong

Available plane types.

Enumerator
overlay 
primary 
cursor 

Constructor & Destructor Documentation

◆ KMSScreen() [1/3]

KMSScreen ( bool  allocate_primary_plane = true,
PixelFormat  format = PixelFormat::rgb565 
)
explicit
Parameters
allocate_primary_planeAllocate a primary plane, or create a trash buffer instead.
formatRequested format for the screen.

◆ KMSScreen() [2/3]

KMSScreen ( const KMSScreen )
delete

◆ KMSScreen() [3/3]

KMSScreen ( KMSScreen &&  )
noexcept

◆ ~KMSScreen()

~KMSScreen ( )
overridenoexcept

Member Function Documentation

◆ allocate_overlay()

unique_plane_t allocate_overlay ( const Size size,
PixelFormat  format = PixelFormat::argb8888,
WindowHint  hint = WindowHint::automatic 
)

Allocate an overlay plane.

◆ brightness() [1/2]

EGT_NODISCARD size_t brightness ( ) const
overridevirtual

Get the current brightness of the screen.

Note
Not all screens support this capability.

Reimplemented from Screen.

◆ brightness() [2/2]

void brightness ( size_t  brightness)
overridevirtual

Set the brightness of the screen.

Parameters
brightnessValue from 0 to max_brightness().
Note
Not all screens support this capability.

Reimplemented from Screen.

◆ close()

void close ( )

Close and release the screen.

◆ count_planes()

uint32_t count_planes ( plane_type  type = plane_type::overlay)

Count the number of available hardware planes with a specific type.

◆ deallocate_overlay()

void deallocate_overlay ( plane_data *  plane)

Deallocate an overlay plane.

◆ have_planes()

EGT_NODISCARD bool have_planes ( ) const
inlineoverridevirtual

Returns true if the screen supports planes.

Reimplemented from Screen.

◆ index()

uint32_t index ( )
overridevirtual

If the screen implementation manages multiple buffers, this will return the index of the current buffer.

Reimplemented from Screen.

◆ instance()

static KMSScreen* instance ( )
static

Get a pointer to the KMSScreen instance.

◆ max_brightness()

EGT_NODISCARD size_t max_brightness ( ) const
overridevirtual

Get the max brightness of the screen.

Note
Not all screens support this capability.

Reimplemented from Screen.

◆ max_buffers()

static uint32_t max_buffers ( )
static

Get the number of buffers to use for KMS planes.

◆ operator=() [1/2]

KMSScreen& operator= ( const KMSScreen )
delete

◆ operator=() [2/2]

KMSScreen& operator= ( KMSScreen &&  )
noexcept

◆ overlay_plane_create()

plane_data* overlay_plane_create ( const Size size,
PixelFormat  format,
plane_type  type 
)
protected

Allocate an overlay plane.

◆ schedule_flip()

void schedule_flip ( )
overridevirtual

Schedule a flip to occur later.

This is needed if a flip should occur sometime in the future to the hardware.

Implements Screen.

Friends And Related Function Documentation

◆ detail::KMSOverlay

friend class detail::KMSOverlay
friend

Member Data Documentation

◆ m_device

struct kms_device* m_device {nullptr}
protected

Instance of the KMS device.

◆ m_fd

int m_fd {-1}
protected

Internal DRM/KMS file descriptor.

◆ m_gfx2d

bool m_gfx2d {false}
protected

Enable GFX2D.

◆ m_index

uint32_t m_index {0}
protected

Current flip index.

◆ m_plane

unique_plane_t m_plane
protected

Plane instance pointer.

◆ m_pool

std::unique_ptr<FlipThread> m_pool
protected

Internal thread pool for flipping.

◆ m_used

std::vector<planeid> m_used
staticprotected

Global array used to keep track of allocated planes.