code moved to QskTextureRenderer
This commit is contained in:
parent
d64f861e33
commit
271b595609
|
@ -7,11 +7,6 @@
|
||||||
#include "QskTextureRenderer.h"
|
#include "QskTextureRenderer.h"
|
||||||
|
|
||||||
#include <qquickwindow.h>
|
#include <qquickwindow.h>
|
||||||
#include <qsgtexture.h>
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
|
||||||
#include <qsgtexture_platform.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QskGraphicTextureFactory::QskGraphicTextureFactory()
|
QskGraphicTextureFactory::QskGraphicTextureFactory()
|
||||||
{
|
{
|
||||||
|
@ -28,33 +23,47 @@ QskGraphicTextureFactory::~QskGraphicTextureFactory()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskGraphicTextureFactory::setGraphic( const QskGraphic& graphic )
|
||||||
|
{
|
||||||
|
m_graphic = graphic;
|
||||||
|
}
|
||||||
|
|
||||||
|
QskGraphic QskGraphicTextureFactory::graphic() const
|
||||||
|
{
|
||||||
|
return m_graphic;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskGraphicTextureFactory::setColorFilter(
|
||||||
|
const QskColorFilter& colorFilter )
|
||||||
|
{
|
||||||
|
m_colorFilter = colorFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QskColorFilter& QskGraphicTextureFactory::colorFilter() const
|
||||||
|
{
|
||||||
|
return m_colorFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskGraphicTextureFactory::setSize( const QSize& size )
|
||||||
|
{
|
||||||
|
m_size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize QskGraphicTextureFactory::size() const
|
||||||
|
{
|
||||||
|
return m_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QSGTexture* QskGraphicTextureFactory::createTexture( QQuickWindow* window ) const
|
QSGTexture* QskGraphicTextureFactory::createTexture( QQuickWindow* window ) const
|
||||||
{
|
{
|
||||||
const uint textureId = QskTextureRenderer::createTextureFromGraphic(
|
using namespace QskTextureRenderer;
|
||||||
|
|
||||||
|
const uint textureId = createTextureFromGraphic(
|
||||||
QskTextureRenderer::OpenGL, m_size, m_graphic, m_colorFilter,
|
QskTextureRenderer::OpenGL, m_size, m_graphic, m_colorFilter,
|
||||||
Qt::IgnoreAspectRatio );
|
Qt::IgnoreAspectRatio );
|
||||||
|
|
||||||
const auto flags = static_cast< QQuickWindow::CreateTextureOptions >(
|
return textureFromId( window, textureId, m_size );
|
||||||
QQuickWindow::TextureHasAlphaChannel | QQuickWindow::TextureOwnsGLTexture );
|
|
||||||
|
|
||||||
QSGTexture* texture;
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
|
||||||
|
|
||||||
texture = QNativeInterface::QSGOpenGLTexture::fromNative(
|
|
||||||
textureId, window, m_size, flags );
|
|
||||||
|
|
||||||
#elif QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
|
|
||||||
const int nativeLayout = 0; // VkImageLayout in case of Vulkan
|
|
||||||
|
|
||||||
texture = window->createTextureFromNativeObject(
|
|
||||||
QQuickWindow::NativeObjectTexture, &textureId, nativeLayout,
|
|
||||||
m_size, flags );
|
|
||||||
#else
|
|
||||||
texture = window->createTextureFromId( textureId, m_size, flags );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize QskGraphicTextureFactory::textureSize() const
|
QSize QskGraphicTextureFactory::textureSize() const
|
||||||
|
|
|
@ -40,35 +40,4 @@ class QSK_EXPORT QskGraphicTextureFactory : public QQuickTextureFactory
|
||||||
QSize m_size;
|
QSize m_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void QskGraphicTextureFactory::setGraphic( const QskGraphic& graphic )
|
|
||||||
{
|
|
||||||
m_graphic = graphic;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline QskGraphic QskGraphicTextureFactory::graphic() const
|
|
||||||
{
|
|
||||||
return m_graphic;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void QskGraphicTextureFactory::setColorFilter(
|
|
||||||
const QskColorFilter& colorFilter )
|
|
||||||
{
|
|
||||||
m_colorFilter = colorFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const QskColorFilter& QskGraphicTextureFactory::colorFilter() const
|
|
||||||
{
|
|
||||||
return m_colorFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void QskGraphicTextureFactory::setSize( const QSize& size )
|
|
||||||
{
|
|
||||||
m_size = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline QSize QskGraphicTextureFactory::size() const
|
|
||||||
{
|
|
||||||
return m_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,6 +23,12 @@
|
||||||
#include <qscreen.h>
|
#include <qscreen.h>
|
||||||
#include <qsurface.h>
|
#include <qsurface.h>
|
||||||
|
|
||||||
|
#include <qsgtexture.h>
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
||||||
|
#include <qsgtexture_platform.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static uint qskCreateTextureOpenGL(
|
static uint qskCreateTextureOpenGL(
|
||||||
const QSize& size, QskTextureRenderer::PaintHelper* helper )
|
const QSize& size, QskTextureRenderer::PaintHelper* helper )
|
||||||
{
|
{
|
||||||
|
@ -129,6 +135,35 @@ static uint qskCreateTextureRaster(
|
||||||
return textureId;
|
return textureId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSGTexture* QskTextureRenderer::textureFromId(
|
||||||
|
QQuickWindow* window, uint textureId, const QSize& size )
|
||||||
|
{
|
||||||
|
const auto flags = static_cast< QQuickWindow::CreateTextureOptions >(
|
||||||
|
QQuickWindow::TextureHasAlphaChannel | QQuickWindow::TextureOwnsGLTexture );
|
||||||
|
|
||||||
|
QSGTexture* texture;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
||||||
|
|
||||||
|
texture = QNativeInterface::QSGOpenGLTexture::fromNative(
|
||||||
|
textureId, window, size, flags );
|
||||||
|
|
||||||
|
#elif QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
|
||||||
|
|
||||||
|
const int nativeLayout = 0; // VkImageLayout in case of Vulkan
|
||||||
|
|
||||||
|
texture = window->createTextureFromNativeObject(
|
||||||
|
QQuickWindow::NativeObjectTexture, &textureId, nativeLayout, size, flags );
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
texture = window->createTextureFromId( textureId, size, flags );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
QskTextureRenderer::PaintHelper::~PaintHelper()
|
QskTextureRenderer::PaintHelper::~PaintHelper()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -136,6 +171,10 @@ QskTextureRenderer::PaintHelper::~PaintHelper()
|
||||||
uint QskTextureRenderer::createTexture(
|
uint QskTextureRenderer::createTexture(
|
||||||
RenderMode renderMode, const QSize& size, PaintHelper* helper )
|
RenderMode renderMode, const QSize& size, PaintHelper* helper )
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
||||||
|
// Qt6.0.0 is buggy when using FBOs. So let's disable it for the moment TODO ...
|
||||||
|
renderMode = Raster;
|
||||||
|
#endif
|
||||||
if ( renderMode == AutoDetect )
|
if ( renderMode == AutoDetect )
|
||||||
{
|
{
|
||||||
if ( qskSetup->controlFlags() & QskSetup::PreferRasterForTextures )
|
if ( qskSetup->controlFlags() & QskSetup::PreferRasterForTextures )
|
||||||
|
|
|
@ -15,6 +15,8 @@ class QskColorFilter;
|
||||||
class QPainter;
|
class QPainter;
|
||||||
class QSize;
|
class QSize;
|
||||||
class QOpenGLContext;
|
class QOpenGLContext;
|
||||||
|
class QSGTexture;
|
||||||
|
class QQuickWindow;
|
||||||
|
|
||||||
namespace QskTextureRenderer
|
namespace QskTextureRenderer
|
||||||
{
|
{
|
||||||
|
@ -48,6 +50,9 @@ namespace QskTextureRenderer
|
||||||
RenderMode, const QSize&, const QskGraphic&,
|
RenderMode, const QSize&, const QskGraphic&,
|
||||||
const QskColorFilter&, Qt::AspectRatioMode );
|
const QskColorFilter&, Qt::AspectRatioMode );
|
||||||
|
|
||||||
|
QSK_EXPORT QSGTexture* textureFromId(
|
||||||
|
QQuickWindow*, uint textureId, const QSize& );
|
||||||
|
|
||||||
QSK_EXPORT qreal devicePixelRatio( const QOpenGLContext* = nullptr );
|
QSK_EXPORT qreal devicePixelRatio( const QOpenGLContext* = nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue