Louvre
v2.12.0-1
C++ library for Wayland compositors
|
OpenGL texture abstraction. More...
Public Types | |
enum | BufferSourceType |
Texture source enumeration indicating the origin of the texture data. More... | |
Public Member Functions | |
LTexture (bool premultipliedAlpha=false) noexcept | |
Creates an empty texture. More... | |
~LTexture () noexcept | |
The LTexture class destructor. More... | |
bool | setDataFromMainMemory (const LSize &size, UInt32 stride, UInt32 format, const void *buffer) noexcept |
Set the data of the texture from a buffer in main memory. More... | |
bool | setDataFromWaylandDRM (wl_resource *buffer) noexcept |
Set the data of the texture from a wl_drm buffer. More... | |
bool | setDataFromDMA (const LDMAPlanes &planes) noexcept |
Set the data of the texture from DMA planes. More... | |
bool | setDataFromGL (GLuint id, GLenum target, UInt32 format, const LSize &size, bool transferOwnership) noexcept |
Creates a wrapper around an existing OpenGL texture. More... | |
bool | updateRect (const LRect &rect, UInt32 stride, const void *buffer) noexcept |
Update a specific area of the texture with the provided buffer. More... | |
LTexture * | copy (const LSize &dst=LSize(), const LRect &src=LRect(), bool highQualityScaling=true) const noexcept |
Creates a copy of the texture. More... | |
bool | save (const std::filesystem::path &name) const noexcept |
Save the texture as a PNG file. More... | |
void | setFence () noexcept |
Sets a synchronization fence. More... | |
const LSize & | sizeB () const noexcept |
Gets the size of the texture in buffer coordinates. More... | |
bool | initialized () const noexcept |
Check if the texture has been initialized. More... | |
GLuint | id (LOutput *output) const noexcept |
Gets the OpenGL texture ID for a specific output. More... | |
GLenum | target () const noexcept |
Gets the OpenGL texture target. More... | |
BufferSourceType | sourceType () const noexcept |
Gets the texture source type. More... | |
UInt32 | format () const noexcept |
Gets the DRM format of the texture. More... | |
UInt32 | serial () const noexcept |
Gets the serial number of the texture. More... | |
bool | premultipliedAlpha () const noexcept |
Indicates whether the RGB components are pre-multiplied by the alpha component. More... | |
void | setPremultipliedAlpha (bool premultipledAlpha) const noexcept |
Sets a hint indicating whether the RGB components are pre-multiplied by the alpha component. More... | |
Public Member Functions inherited from LObject | |
LObject (const LObject &) noexcept | |
Copy constructor. More... | |
LObject & | operator= (const LObject &) noexcept |
Assignment operator (each object has its own individual LWeak reference count). More... | |
void | setUserData (UIntPtr data) const noexcept |
Store an unsigned integer value/pointer. More... | |
UIntPtr | userData () const noexcept |
Retrieves the stored unsigned integer value/pointer. More... | |
Static Public Member Functions | |
static UInt32 | waylandFormatToDRM (UInt32 waylandFormat) noexcept |
Gets the equivalent DRM buffer format from a Wayland SHM buffer format. More... | |
static UInt32 | formatBytesPerPixel (UInt32 format) noexcept |
Gets the number of bytes (not bits) per pixel of a DRM format. More... | |
static UInt32 | formatPlanes (UInt32 format) noexcept |
Gets the number of planes of a DRM format. More... | |
static const std::vector< LDMAFormat > & | supportedDMAFormats () noexcept |
Retrieves the DMA formats supported by the graphics backend. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from LObject | |
LObject () noexcept=default | |
Constructor of the LObject class. More... | |
virtual | ~LObject () noexcept |
Destructor of the LObject class. More... | |
void | notifyDestruction () noexcept |
Notifies the object destruction. 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.
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. |
GL | Sourced from a native OpenGL ES 2.0 texture. |
|
noexcept |
Creates an empty texture.
Gets the equivalent DRM buffer format from a Wayland SHM buffer format.
DRM formats are listed in drm_fourcc.h
.
waylandFormat | The Wayland buffer format to convert. |
Gets the number of bytes (not bits) per pixel of a DRM format.
format | The DRM format to get the bytes per pixel for. |
Gets the number of planes of a DRM format.
format | The DRM format. |
|
staticnoexcept |
Retrieves the DMA formats supported by the graphics backend.
|
noexcept |
Set the data of the texture from a buffer in main memory.
size | Width and height of the source buffer. |
stride | The stride of the source buffer. |
format | The DRM format of the buffer (defined in drm_fourcc.h ). |
buffer | The pointer to the source main memory buffer. |
true
if the data was successfully set, false
otherwise.
|
noexcept |
Set the data of the texture from a wl_drm
buffer.
buffer | The pointer to the wl_drm buffer. |
true
if the data was successfully set, false
otherwise.
|
noexcept |
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.
|
noexcept |
Creates a wrapper around an existing OpenGL texture.
id | The OpenGL texture ID. |
target | The OpenGL target for the texture (e.g., GL_TEXTURE_2D). |
format | The format of the texture data (specified as a DRM format). |
size | The dimensions of the texture in pixels. |
transferOwnership | If set to true , the texture will be automatically destroyed when the LTexture is destroyed or replaced. |
true
if the texture data was successfully set, false
otherwise. Update a specific area of the texture with the provided buffer.
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 source main memory buffer. |
buffer | A pointer to the origin of the source main memory buffer. |
true
if the update was successful; otherwise, false
.
|
noexcept |
Creates a copy of the texture.
dst | The destination size of the copied texture. Pass (0,0) to use the same size as the original texture. |
src | The rectangular area within the source texture to be copied. Pass (0,0,0,0) to copy the entire texture. |
highQualityScaling | Set this parameter to true to enable high-quality scaling, which produces better results when resizing to a significantly different size from the original. |
nullptr
on failure.
|
noexcept |
Save the texture as a PNG file.
This method allows you to save the texture as a PNG image file at the specified name
.
name | Full path and file name where the PNG image will be saved. |
true
if the save operation is successful, false
otherwise.
|
noexcept |
Sets a synchronization fence.
This method should be called after rendering is performed into the texture or the pixel data is updated via functions not defined within LTexture.
|
inlinenoexcept |
Gets the size of the texture in buffer coordinates.
|
inlinenoexcept |
Check if the texture has been initialized.
A texture is considered initialized when content has been assigned to it using any of the setDataXXX() variants.
true
if the texture has been initialized, false
otherwise.
|
noexcept |
Gets 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. |
|
inlinenoexcept |
Gets the OpenGL texture target.
|
inlinenoexcept |
Gets the texture source type.
|
inlinenoexcept |
Gets the DRM format of the texture.
drm_fourcc.h
for more information on DRM formats.
|
inlinenoexcept |
Gets the serial number of the texture.
The serial number is incremented each time the texture's backing storage, or its pixel data changes.
|
inlinenoexcept |
Indicates whether the RGB components are pre-multiplied by the alpha component.
This flag is crucial for proper blending of textures within LPainter and LScene.
By default, Wayland clients typically use pre-multiplied alpha, but user-defined textures may not adhere to this convention.
To modify this value, use setPremultipliedAlpha().
true
if the RGB components are pre-multiplied by the alpha component, false
otherwise.
|
inlinenoexcept |
Sets a hint indicating whether the RGB components are pre-multiplied by the alpha component.
This function allows you to modify the pre-multiplied alpha flag.
premultipledAlpha | true to indicate pre-multiplied alpha, false otherwise. |