diff options
Diffstat (limited to 'src/quick/scenegraph/util/qsgtexture.cpp')
-rw-r--r-- | src/quick/scenegraph/util/qsgtexture.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index 9b9c77dce4..4cf339aeb8 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "qsgtexture_p.h" -#include <qopenglfunctions.h> #include <QtQuick/private/qsgcontext_p.h> #include <qthread.h> #include <qmath.h> @@ -46,9 +45,12 @@ #include <private/qqmlglobal_p.h> #include <QtGui/qguiapplication.h> #include <QtGui/qpa/qplatformnativeinterface.h> -#include <QtGui/qopenglcontext.h> -#include <QtGui/qopenglfunctions.h> - +#ifndef QT_NO_OPENGL +# include <qopenglfunctions.h> +# include <QtGui/qopenglcontext.h> +# include <QtGui/qopenglfunctions.h> +# include <private/qsgdefaultrendercontext_p.h> +#endif #include <private/qsgmaterialshader_p.h> #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) && !defined(__UCLIBC__) @@ -68,7 +70,9 @@ #include <QHash> #endif +#ifndef QT_NO_OPENGL static QElapsedTimer qsg_renderer_timer; +#endif #ifndef QT_NO_DEBUG static const bool qsg_leak_check = !qEnvironmentVariableIsEmpty("QML_LEAK_CHECK"); @@ -82,11 +86,13 @@ static const bool qsg_leak_check = !qEnvironmentVariableIsEmpty("QML_LEAK_CHECK" QT_BEGIN_NAMESPACE +#ifndef QT_NO_OPENGL inline static bool isPowerOfTwo(int x) { // Assumption: x >= 1 return x == (x & -x); } +#endif QSGTexturePrivate::QSGTexturePrivate() : wrapChanged(false) @@ -278,6 +284,7 @@ Q_GLOBAL_STATIC(QMutex, qsg_valid_texture_mutex) bool qsg_safeguard_texture(QSGTexture *texture) { +#ifndef QT_NO_OPENGL QMutexLocker locker(qsg_valid_texture_mutex()); if (!qsg_valid_texture_set()->contains(texture)) { qWarning() << "Invalid texture accessed:" << (void *) texture; @@ -285,6 +292,9 @@ bool qsg_safeguard_texture(QSGTexture *texture) QOpenGLContext::currentContext()->functions()->glBindTexture(GL_TEXTURE_2D, 0); return false; } +#else + Q_UNUSED(texture) +#endif return true; } #endif @@ -517,6 +527,7 @@ QSGTexture::WrapMode QSGTexture::verticalWrapMode() const */ void QSGTexture::updateBindOptions(bool force) { +#ifndef QT_NO_OPENGL Q_D(QSGTexture); QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); force |= isAtlasTexture(); @@ -551,6 +562,9 @@ void QSGTexture::updateBindOptions(bool force) funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, d->verticalWrap == Repeat ? GL_REPEAT : GL_CLAMP_TO_EDGE); d->wrapChanged = false; } +#else + Q_UNUSED(force) +#endif } QSGPlainTexture::QSGPlainTexture() @@ -568,8 +582,10 @@ QSGPlainTexture::QSGPlainTexture() QSGPlainTexture::~QSGPlainTexture() { +#ifndef QT_NO_OPENGL if (m_texture_id && m_owns_texture && QOpenGLContext::currentContext()) QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_texture_id); +#endif } void qsg_swizzleBGRAToRGBA(QImage *image) @@ -601,8 +617,10 @@ int QSGPlainTexture::textureId() const // or ~QSGPlainTexture so just keep it minimal here. return 0; } else if (m_texture_id == 0){ +#ifndef QT_NO_OPENGL // Generate a texture id for use later and return it. QOpenGLContext::currentContext()->functions()->glGenTextures(1, &const_cast<QSGPlainTexture *>(this)->m_texture_id); +#endif return m_texture_id; } } @@ -611,8 +629,10 @@ int QSGPlainTexture::textureId() const void QSGPlainTexture::setTextureId(int id) { +#ifndef QT_NO_OPENGL if (m_texture_id && m_owns_texture) QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_texture_id); +#endif m_texture_id = id; m_dirty_texture = false; @@ -623,6 +643,7 @@ void QSGPlainTexture::setTextureId(int id) void QSGPlainTexture::bind() { +#ifndef QT_NO_OPENGL QOpenGLContext *context = QOpenGLContext::currentContext(); QOpenGLFunctions *funcs = context->functions(); if (!m_dirty_texture) { @@ -684,7 +705,7 @@ void QSGPlainTexture::bind() // based on QSGTexture::textureSize which is updated after this, so that // should be ok. int max; - if (QSGRenderContext *rc = QSGRenderContext::from(context)) + if (auto rc = QSGDefaultRenderContext::from(context)) max = rc->maxTextureSize(); else funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max); @@ -789,6 +810,7 @@ void QSGPlainTexture::bind() m_dirty_bind_options = false; if (!m_retain_image) m_image = QImage(); +#endif } |