using QSGGeometry::updateTexturedRectGeometry

This commit is contained in:
Uwe Rathmann 2023-12-13 15:09:20 +01:00
parent 245491724d
commit dda2525970
1 changed files with 7 additions and 29 deletions

View File

@ -159,38 +159,16 @@ void BlurringNode::setRect( const QRectF& rect )
{ {
Q_D( BlurringNode ); Q_D( BlurringNode );
if ( rect == d->rect ) if ( rect != d->rect )
return; {
d->rect = rect; d->rect = rect;
struct Point : QSGGeometry::Point2D QSGGeometry::updateTexturedRectGeometry(
{ &d->geometry, rect, QRectF( 0, 0, 1, 1 ) );
inline void operator=( const QPointF& pos )
{
x = static_cast< float >( pos.x() );
y = static_cast< float >( pos.y() );
}
};
const QRectF r0( 0, 0, 1, 1 );
auto points = static_cast< Point* >( d->geometry.vertexData() );
points[0] = rect.topLeft();
points[1] = r0.topLeft();
points[2] = rect.topRight();
points[3] = r0.topRight();
points[4] = rect.bottomLeft();
points[5] = r0.bottomLeft();
points[6] = rect.bottomRight();
points[7] = r0.bottomRight();
d->geometry.markVertexDataDirty(); d->geometry.markVertexDataDirty();
markDirty( QSGNode::DirtyGeometry ); markDirty( QSGNode::DirtyGeometry );
}
} }
QRectF BlurringNode::rect() const QRectF BlurringNode::rect() const