From b004e6d8d518638edbc098e6c1bd169578087bad Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Sat, 31 Oct 2020 08:06:41 +0100 Subject: [PATCH] code improved --- src/controls/QskSkinlet.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/controls/QskSkinlet.cpp b/src/controls/QskSkinlet.cpp index 22af51df..4b6160b9 100644 --- a/src/controls/QskSkinlet.cpp +++ b/src/controls/QskSkinlet.cpp @@ -77,32 +77,31 @@ static inline QSGNode* qskUpdateGraphicNode( if ( rect.isEmpty() ) return nullptr; + const auto control = skinnable->owningControl(); + if ( control == nullptr ) + return nullptr; + auto mode = QskTextureRenderer::OpenGL; auto graphicNode = static_cast< QskGraphicNode* >( node ); if ( graphicNode == nullptr ) graphicNode = new QskGraphicNode(); - QRectF r = rect; + if ( control->testControlFlag( QskControl::PreferRasterForTextures ) ) + mode = QskTextureRenderer::Raster; - if ( const auto control = skinnable->owningControl() ) - { - if ( control->testControlFlag( QskControl::PreferRasterForTextures ) ) - mode = QskTextureRenderer::Raster; + /* + Aligning the rect according to scene coordinates, so that + we don't run into rounding issues downstream, where values + will be floored/ceiled ending up with a slightly different + aspect ratio. + */ + QRectF r( + control->mapToScene( rect.topLeft() ), + rect.size() * QskTextureRenderer::devicePixelRatio() ); - /* - Aligning the rect according to scene coordinates, so that - we don't run into rounding issues downstream, where values - will be floored/ceiled ending up with a slightly different - aspect ratio. - */ - const QRectF sceneRect( - control->mapToScene( r.topLeft() ), - r.size() * QskTextureRenderer::devicePixelRatio() ); - - r = qskInnerRect( sceneRect ); - r.moveTopLeft( control->mapFromScene( r.topLeft() ) ); - } + r = qskInnerRect( r ); + r.moveTopLeft( control->mapFromScene( r.topLeft() ) ); graphicNode->setGraphic( graphic, colorFilter, mode, r );