KWin
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
KWin::RenderGeometry Class Reference

#include <itemgeometry.h>

Inheritance diagram for KWin::RenderGeometry:

Public Types

enum class  VertexSnappingMode { None , Round }
 

Public Member Functions

VertexSnappingMode vertexSnappingMode () const
 
void setVertexSnappingMode (VertexSnappingMode mode)
 
void copy (std::span< GLVertex2D > destination)
 
void appendWindowVertex (const WindowVertex &windowVertex, qreal deviceScale)
 
void appendWindowQuad (const WindowQuad &quad, qreal deviceScale)
 
void appendSubQuad (const WindowQuad &quad, const QRectF &subquad, qreal deviceScale)
 
void postProcessTextureCoordinates (const QMatrix4x4 &textureMatrix)
 

Detailed Description

A helper class for render geometry in device coordinates.

This mostly represents a vector of vertices, with some convenience methods for easily converting from WindowQuad and related classes to lists of GLVertex2D. This class assumes rendering happens as unindexed triangles.

Definition at line 96 of file itemgeometry.h.

Member Enumeration Documentation

◆ VertexSnappingMode

In what way should vertices snap to integer device coordinates?

Vertices are converted to device coordinates before being sent to the rendering system. Depending on scaling factors, this may lead to device coordinates with fractional parts. For some cases, this may not be ideal as fractional coordinates need to be interpolated and can lead to "blurry" rendering. To avoid that, we can snap the vertices to integer device coordinates when they are added.

Enumerator
None 
Round 

Definition at line 109 of file itemgeometry.h.

Member Function Documentation

◆ appendSubQuad()

void KWin::RenderGeometry::appendSubQuad ( const WindowQuad & quad,
const QRectF & subquad,
qreal deviceScale )

Append a sub-quad of a WindowQuad as two triangles.

This will append the sub-quad specified by intersection as two triangles. The quad is expected to be in logical coordinates, while the intersection is expected to be in device coordinates. The texture coordinates of the resulting vertices are based upon those of the quad, using bilinear interpolation for interpolating how much of the original texture coordinates to use.

Parameters
quadThe WindowQuad instance to use a sub-quad of.
subquadThe sub-quad to append.
deviceScaleThe scaling factor used to convert from logical to device coordinates.

Definition at line 252 of file itemgeometry.cpp.

◆ appendWindowQuad()

void KWin::RenderGeometry::appendWindowQuad ( const WindowQuad & quad,
qreal deviceScale )

Append a WindowQuad as two triangles.

This will append the corners of the specified WindowQuad in the right order so they make two triangles that can be rendered by OpenGL. The corners are converted to device coordinates and rounded, just like appendWindowVertex() does.

Parameters
quadThe WindowQuad instance to append.
deviceScaleThe scaling factor to use to go from logical to device coordinates.

Definition at line 238 of file itemgeometry.cpp.

◆ appendWindowVertex()

void KWin::RenderGeometry::appendWindowVertex ( const WindowVertex & windowVertex,
qreal deviceScale )

Append a WindowVertex as a geometry vertex.

WindowVertex is assumed to be in logical coordinates. It will be converted to device coordinates using the specified device scale and then rounded so it fits correctly on the device pixel grid.

Parameters
windowVertexThe WindowVertex instance to append.
deviceScaleThe scaling factor to use to go from logical to device coordinates.

Definition at line 223 of file itemgeometry.cpp.

◆ copy()

void KWin::RenderGeometry::copy ( std::span< GLVertex2D > destination)

Copy geometry data into another buffer.

This is primarily intended for copying into a vertex buffer for rendering.

Parameters
destinationThe destination buffer. This needs to be at least large enough to contain all elements.

Definition at line 217 of file itemgeometry.cpp.

◆ postProcessTextureCoordinates()

void KWin::RenderGeometry::postProcessTextureCoordinates ( const QMatrix4x4 & textureMatrix)

Modify this geometry's texture coordinates based on a matrix.

This is primarily intended to convert from non-normalised to normalised texture coordinates.

Parameters
textureMatrixThe texture matrix to use for modifying the texture coordinates. Note that only the 2D scale and translation are used.

Definition at line 289 of file itemgeometry.cpp.

◆ setVertexSnappingMode()

void KWin::RenderGeometry::setVertexSnappingMode ( VertexSnappingMode mode)
inline

Set the vertex snapping mode to use for this geometry.

Note that this doesn't change vertices retroactively, so you should set this before adding any vertices, or clear and rebuild the geometry after setting it.

Parameters
modeThe new rounding mode.

Definition at line 134 of file itemgeometry.h.

◆ vertexSnappingMode()

VertexSnappingMode KWin::RenderGeometry::vertexSnappingMode ( ) const
inline

The vertex snapping mode to use for this geometry.

By default, this is VertexSnappingMode::Round.

Definition at line 121 of file itemgeometry.h.


The documentation for this class was generated from the following files: