Louvre
v1.2.1-2
C++ library for Wayland compositors
|
#include <LTexture.h>
OpenGL texture abstraction. More...
OpenGL texture abstraction.
The LTexture class is an abstraction of an OpenGL texture. It provides a unified interface for generating and updating textures from buffers in main memory, wl_drm
buffers, and DMA buffers. The current texture buffer content is destroyed and replaced every time any of the setData() variants is used.
Public Types | |
enum | BufferSourceType |
Texture source enumeration indicating the origin of the texture data. More... | |
Public Member Functions | |
LTexture () | |
Create an empty texture. More... | |
~LTexture () | |
The LTexture class destructor. More... | |
bool | setDataB (const LSize &size, UInt32 stride, UInt32 format, const void *buffer) |
Set the data of the texture from a buffer in main memory. More... | |
bool | setData (void *wlDRMBuffer) |
Set the data of the texture from a wl_drm buffer. More... | |
bool | setDataB (const LDMAPlanes *planes) |
Set the data of the texture from DMA planes. More... | |
bool | updateRect (const LRect &rect, UInt32 stride, const void *buffer) |
Update a specific area of the texture with the provided buffer. More... | |
LTexture * | copyB (const LSize &dst=LSize(), const LRect &src=LRect(), bool highQualityScaling=true) const |
Create a copy of the texture. More... | |
bool | save (const std::filesystem::path &name) const |
Save the texture as a PNG file. More... | |
const LSize & | sizeB () const |
Get the size of the texture in buffer coordinates. More... | |
bool | initialized () const |
Check if the texture has been initialized. More... | |
GLuint | id (LOutput *output) const |
Get the OpenGL texture ID for a specific output. More... | |
GLenum | target () const |
Get the OpenGL texture target. More... | |
BufferSourceType | sourceType () const |
Get the texture source type. More... | |
UInt32 | format () const |
Get the DRM format of the texture. More... | |
Public Member Functions inherited from LObject | |
LObject ()=default | |
Constructor of the LObject class. More... | |
~LObject () | |
Destructor of the LObject class. More... | |
std::shared_ptr< const bool > | isAlive () const |
Object's liveness status. More... | |
Static Public Member Functions | |
static UInt32 | waylandFormatToDRM (UInt32 waylandFormat) |
Get the equivalent DRM buffer format from a Wayland buffer format. More... | |
static UInt32 | formatBytesPerPixel (UInt32 format) |
Get the number of bytes (not bits) per pixel of a DRM format. More... | |
static UInt32 | formatPlanes (UInt32 format) |
Get the number of planes of a DRM format. More... | |
Static Public Member Functions inherited from LObject | |
static LCompositor * | compositor () |
Quick access to the global compositor instance. More... | |
static LSeat * | seat () |
Quick access to the global seat instance. More... | |
static LCursor * | cursor () |
Quick access to the global cursor instance. More... | |
enum BufferSourceType |
Texture source enumeration indicating the origin of the texture data.
Enumerator | |
---|---|
CPU | Buffer sourced from main memory. |
WL_DRM | Buffer sourced from |
DMA | Buffer sourced from DMA planes. |
Framebuffer | Indicates the texture is from an LFramebuffer. |
Native | Sourced from a native OpenGL ES 2.0 texture. |
LTexture | ( | ) |
Create an empty texture.
Get the equivalent DRM buffer format from a Wayland buffer format.
DRM formats are listed in drm_fourcc.h
.
waylandFormat | The Wayland buffer format to convert. |
Get the number of bytes (not bits) per pixel of a DRM format.
format | The DRM format to get the bytes per pixel for. |
Get the number of planes of a DRM format.
format | The DRM format. |
Set the data of the texture from a buffer in main memory.
size | The size of the texture in buffer coordinates. |
stride | The stride of the buffer. |
format | The DRM format of the buffer (defined in drm_fourcc.h ). |
buffer | The pointer to the main memory buffer. |
true
if the data was successfully set, false
otherwise. bool setData | ( | void * | wlDRMBuffer | ) |
Set the data of the texture from a wl_drm
buffer.
wlDRMBuffer | The pointer to the wl_drm buffer. |
true
if the data was successfully set, false
otherwise. bool setDataB | ( | const LDMAPlanes * | planes | ) |
Set the data of the texture from DMA planes.
planes | The pointer to the DMA planes struct. |
true
if the data was successfully set, false
otherwise. Update a specific area of the texture with the provided buffer.
To successfully update the texture, the provided buffer must have the same format as the texture. If invalid parameters are passed or if the texture cannot be modified, this method returns false
.
rect | The rect within the texture to update, specified in buffer coordinates with the top-left corner as the origin. |
stride | The stride of the main memory buffer. |
buffer | A pointer to the main memory buffer. |
true
if the update was successful; otherwise, false
. LTexture * copyB | ( | const LSize & | dst = LSize() , |
const LRect & | src = LRect() , |
||
bool | highQualityScaling = true |
||
) | const |
Create a copy of the texture.
The destination size (dst) is the size of the copied texture, and the source (src) is the rectangular area within the texture to be copied. Using both parameters, a clipped and scaled copy version can be created from the texture.
Using negative values for the source rect size (srcW and srcH) causes the texture to be mirrored along the given axis.
dst | The destination size of the copied texture. Passing an empty Louvre::LSize means the same texture size is used. |
src | The rectangular area within the texture to be copied. Passing an empty Louvre::LRect means the entire texture is used. |
highQualityScaling | Set this value to true to enable high-quality scaling, which produces better results when resizing to a significantly different size from the original. |
bool save | ( | const std::filesystem::path & | name | ) | const |
Save the texture as a PNG file.
This method allows you to save the texture as a PNG image file at the specified path
.
name | The file path where the PNG image will be saved. |
true
if the save operation is successful, false
otherwise. const LSize & sizeB | ( | ) | const |
Get the size of the texture in buffer coordinates.
bool initialized | ( | ) | const |
Check if the texture has been initialized.
A texture is considered initialized when content has been assigned to it using any setData() variant.
true
if the texture has been initialized, false
otherwise. Get the OpenGL texture ID for a specific output.
If nullptr is passed as output, a texture for the main thread is returned.
output | The specific output for which to get the texture ID. |
GLenum target | ( | ) | const |
Get the OpenGL texture target.
LTexture::BufferSourceType sourceType | ( | ) | const |
Get the texture source type.
UInt32 format | ( | ) | const |
Get the DRM format of the texture.
drm_fourcc.h
for more information on DRM formats.