KWin
|
#include <itemgeometry.h>
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) |
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.
|
strong |
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.
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.
quad | The WindowQuad instance to use a sub-quad of. |
subquad | The sub-quad to append. |
deviceScale | The scaling factor used to convert from logical to device coordinates. |
Definition at line 252 of file itemgeometry.cpp.
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.
quad | The WindowQuad instance to append. |
deviceScale | The scaling factor to use to go from logical to device coordinates. |
Definition at line 238 of file itemgeometry.cpp.
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.
windowVertex | The WindowVertex instance to append. |
deviceScale | The scaling factor to use to go from logical to device coordinates. |
Definition at line 223 of file itemgeometry.cpp.
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.
destination | The destination buffer. This needs to be at least large enough to contain all elements. |
Definition at line 217 of file itemgeometry.cpp.
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.
textureMatrix | The 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.
|
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.
mode | The new rounding mode. |
Definition at line 134 of file itemgeometry.h.
|
inline |
The vertex snapping mode to use for this geometry.
By default, this is VertexSnappingMode::Round.
Definition at line 121 of file itemgeometry.h.