aspectRatio as parameter added, using IgnoreAspectRatio for graphics
what fixes resizing the background of the automotive example
This commit is contained in:
parent
5a9a4dfa89
commit
280ce5149d
|
@ -125,7 +125,8 @@ bool Benchmark::run( const QString& dirName )
|
||||||
using namespace QskTextureRenderer;
|
using namespace QskTextureRenderer;
|
||||||
|
|
||||||
const auto textureId = createTextureFromGraphic(
|
const auto textureId = createTextureFromGraphic(
|
||||||
OpenGL, targetSize, graphics[ i ], colorFilter );
|
OpenGL, targetSize, graphics[ i ], colorFilter,
|
||||||
|
Qt::IgnoreAspectRatio );
|
||||||
|
|
||||||
if ( textureId == 0 )
|
if ( textureId == 0 )
|
||||||
{
|
{
|
||||||
|
@ -150,7 +151,8 @@ bool Benchmark::run( const QString& dirName )
|
||||||
using namespace QskTextureRenderer;
|
using namespace QskTextureRenderer;
|
||||||
|
|
||||||
const auto textureId = createTextureFromGraphic(
|
const auto textureId = createTextureFromGraphic(
|
||||||
Raster, targetSize, graphics[ i ], colorFilter );
|
Raster, targetSize, graphics[ i ], colorFilter,
|
||||||
|
Qt::IgnoreAspectRatio );
|
||||||
|
|
||||||
if ( textureId == 0 )
|
if ( textureId == 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,8 @@ QskGraphicTextureFactory::~QskGraphicTextureFactory()
|
||||||
QSGTexture* QskGraphicTextureFactory::createTexture( QQuickWindow* window ) const
|
QSGTexture* QskGraphicTextureFactory::createTexture( QQuickWindow* window ) const
|
||||||
{
|
{
|
||||||
const uint textureId = QskTextureRenderer::createTextureFromGraphic(
|
const uint textureId = QskTextureRenderer::createTextureFromGraphic(
|
||||||
QskTextureRenderer::OpenGL, m_size, m_graphic, m_colorFilter );
|
QskTextureRenderer::OpenGL, m_size, m_graphic, m_colorFilter,
|
||||||
|
Qt::IgnoreAspectRatio );
|
||||||
|
|
||||||
const auto flags = static_cast< QQuickWindow::CreateTextureOptions >(
|
const auto flags = static_cast< QQuickWindow::CreateTextureOptions >(
|
||||||
QQuickWindow::TextureHasAlphaChannel | QQuickWindow::TextureOwnsGLTexture );
|
QQuickWindow::TextureHasAlphaChannel | QQuickWindow::TextureOwnsGLTexture );
|
||||||
|
|
|
@ -70,7 +70,7 @@ void QskGraphicNode::setGraphic(
|
||||||
if ( isTextureDirty )
|
if ( isTextureDirty )
|
||||||
{
|
{
|
||||||
const uint textureId = QskTextureRenderer::createTextureFromGraphic(
|
const uint textureId = QskTextureRenderer::createTextureFromGraphic(
|
||||||
renderMode, rect.size(), graphic, colorFilter );
|
renderMode, rect.size(), graphic, colorFilter, Qt::IgnoreAspectRatio );
|
||||||
|
|
||||||
QskTextureNode::setTextureId( textureId );
|
QskTextureNode::setTextureId( textureId );
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,28 +144,32 @@ uint QskTextureRenderer::createTexture(
|
||||||
|
|
||||||
uint QskTextureRenderer::createTextureFromGraphic(
|
uint QskTextureRenderer::createTextureFromGraphic(
|
||||||
RenderMode renderMode, const QSize& size,
|
RenderMode renderMode, const QSize& size,
|
||||||
const QskGraphic& graphic, const QskColorFilter& colorFilter )
|
const QskGraphic& graphic, const QskColorFilter& colorFilter,
|
||||||
|
Qt::AspectRatioMode aspectRatioMode )
|
||||||
{
|
{
|
||||||
class PaintHelper : public QskTextureRenderer::PaintHelper
|
class PaintHelper : public QskTextureRenderer::PaintHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PaintHelper( const QskGraphic& graphic, const QskColorFilter& filter )
|
PaintHelper( const QskGraphic& graphic,
|
||||||
|
const QskColorFilter& filter, Qt::AspectRatioMode aspectRatioMode )
|
||||||
: m_graphic( graphic )
|
: m_graphic( graphic )
|
||||||
, m_filter( filter )
|
, m_filter( filter )
|
||||||
|
, m_aspectRatioMode( aspectRatioMode )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint( QPainter* painter, const QSize& size ) override
|
void paint( QPainter* painter, const QSize& size ) override
|
||||||
{
|
{
|
||||||
const QRect rect( 0, 0, size.width(), size.height() );
|
const QRect rect( 0, 0, size.width(), size.height() );
|
||||||
m_graphic.render( painter, rect, m_filter, Qt::KeepAspectRatio );
|
m_graphic.render( painter, rect, m_filter, m_aspectRatioMode );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QskGraphic& m_graphic;
|
const QskGraphic& m_graphic;
|
||||||
const QskColorFilter& m_filter;
|
const QskColorFilter& m_filter;
|
||||||
|
const Qt::AspectRatioMode m_aspectRatioMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
PaintHelper helper( graphic, colorFilter );
|
PaintHelper helper( graphic, colorFilter, aspectRatioMode );
|
||||||
return createTexture( renderMode, size, &helper );
|
return createTexture( renderMode, size, &helper );
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#define QSK_TEXTURE_RENDERER_H
|
#define QSK_TEXTURE_RENDERER_H
|
||||||
|
|
||||||
#include "QskGlobal.h"
|
#include "QskGlobal.h"
|
||||||
|
#include <qnamespace.h>
|
||||||
|
|
||||||
class QskGraphic;
|
class QskGraphic;
|
||||||
class QskColorFilter;
|
class QskColorFilter;
|
||||||
|
@ -43,7 +44,8 @@ namespace QskTextureRenderer
|
||||||
RenderMode, const QSize&, PaintHelper* helper );
|
RenderMode, const QSize&, PaintHelper* helper );
|
||||||
|
|
||||||
QSK_EXPORT uint createTextureFromGraphic(
|
QSK_EXPORT uint createTextureFromGraphic(
|
||||||
RenderMode, const QSize&, const QskGraphic&, const QskColorFilter& );
|
RenderMode, const QSize&, const QskGraphic&,
|
||||||
|
const QskColorFilter&, Qt::AspectRatioMode );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue