diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-05-09 16:25:58 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2014-05-10 11:53:47 +0200 |
commit | 66646dd8c37adb488a79ab274b2396a649674e6d (patch) | |
tree | b0f5ac752a52cec3de1d47692e09295197622dcd /src/quick/scenegraph/util | |
parent | da15ea0f3b5805db657f13060c21efa78f10cde2 (diff) | |
parent | d82a17b929dd88fe76258b0f801beaa1b2ee343e (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
.qmake.conf
src/plugins/accessible/quick/quick.pro
src/quick/items/qquickpincharea.cpp
src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
src/quick/scenegraph/qsgthreadedrenderloop.cpp
Manually adjusted for TestHTTPServer constructor change:
tests/auto/quick/qquickimage/tst_qquickimage.cpp
Change-Id: I5e58a7c08ea92d6fc5e3bce98571c54f7b2ce08f
Diffstat (limited to 'src/quick/scenegraph/util')
-rw-r--r-- | src/quick/scenegraph/util/qsgatlastexture.cpp | 21 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp | 13 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgsimplematerial.cpp | 6 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgsimpletexturenode.cpp | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgtexture.cpp | 18 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgtexturematerial.cpp | 29 |
6 files changed, 53 insertions, 36 deletions
diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp index 99d1d60258..1ff7d11162 100644 --- a/src/quick/scenegraph/util/qsgatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgatlastexture.cpp @@ -143,7 +143,13 @@ Atlas::Atlas(const QSize &size) , m_allocated(false) { -#ifdef QT_OPENGL_ES + m_internalFormat = GL_RGBA; + m_externalFormat = GL_BGRA; + +#ifndef QT_OPENGL_ES + if (QOpenGLContext::currentContext()->isOpenGLES()) { +#endif + #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) QString *deviceName = static_cast<QString *>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("AndroidDeviceName")); @@ -153,7 +159,7 @@ Atlas::Atlas(const QSize &size) || deviceName->compare(QStringLiteral("samsung SM-T215"), Qt::CaseInsensitive) == 0); #else static bool wrongfullyReportsBgra8888Support = false; -#endif +#endif // ANDROID const char *ext = (const char *) glGetString(GL_EXTENSIONS); if (!wrongfullyReportsBgra8888Support @@ -165,13 +171,13 @@ Atlas::Atlas(const QSize &size) } else if (strstr(ext, "GL_APPLE_texture_format_BGRA8888")) { m_internalFormat = GL_RGBA; m_externalFormat = GL_BGRA; -#endif +#endif // IOS } else { m_internalFormat = m_externalFormat = GL_RGBA; } -#else - m_internalFormat = GL_RGBA; - m_externalFormat = GL_BGRA; + +#ifndef QT_OPENGL_ES + } #endif m_use_bgra_fallback = qEnvironmentVariableIsSet("QSG_ATLAS_USE_BGRA_FALLBACK"); @@ -326,7 +332,8 @@ void Atlas::bind(QSGTexture::Filtering filtering) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); #if !defined(QT_OPENGL_ES_2) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); + if (!QOpenGLContext::currentContext()->isOpenGLES()) + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); #endif glTexImage2D(GL_TEXTURE_2D, 0, m_internalFormat, m_size.width(), m_size.height(), 0, m_externalFormat, GL_UNSIGNED_BYTE, 0); diff --git a/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp b/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp index 59bde0d602..f5a75fd627 100644 --- a/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp +++ b/src/quick/scenegraph/util/qsgdepthstencilbuffer.cpp @@ -75,8 +75,6 @@ void QSGDepthStencilBuffer::detach() GL_RENDERBUFFER, 0); } -// ###TODO Remove once using Khronos OpenGL headers -#if defined(QT_OPENGL_ES_2) #ifndef GL_DEPTH24_STENCIL8_OES #define GL_DEPTH24_STENCIL8_OES 0x88F0 #endif @@ -84,7 +82,6 @@ void QSGDepthStencilBuffer::detach() #ifndef GL_DEPTH_COMPONENT24_OES #define GL_DEPTH_COMPONENT24_OES 0x81A6 #endif -#endif QSGDefaultDepthStencilBuffer::QSGDefaultDepthStencilBuffer(QOpenGLContext *context, const Format &format) : QSGDepthStencilBuffer(context, format) @@ -117,12 +114,10 @@ QSGDefaultDepthStencilBuffer::QSGDefaultDepthStencilBuffer(QOpenGLContext *conte if (!m_depthBuffer && (format.attachments & DepthAttachment)) { m_functions.glGenRenderbuffers(1, &m_depthBuffer); m_functions.glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer); -#ifdef QT_OPENGL_ES - const GLenum internalFormat = m_functions.hasOpenGLExtension(QOpenGLExtensions::Depth24) + GLenum internalFormat = GL_DEPTH_COMPONENT; + if (context->isOpenGLES()) + internalFormat = m_functions.hasOpenGLExtension(QOpenGLExtensions::Depth24) ? GL_DEPTH_COMPONENT24_OES : GL_DEPTH_COMPONENT16; -#else - const GLenum internalFormat = GL_DEPTH_COMPONENT; -#endif if (format.samples && m_functions.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) { m_functions.glRenderbufferStorageMultisample(GL_RENDERBUFFER, format.samples, internalFormat, width, height); @@ -136,7 +131,7 @@ QSGDefaultDepthStencilBuffer::QSGDefaultDepthStencilBuffer(QOpenGLContext *conte #ifdef QT_OPENGL_ES const GLenum internalFormat = GL_STENCIL_INDEX8; #else - const GLenum internalFormat = GL_STENCIL_INDEX; + const GLenum internalFormat = context->isOpenGLES() ? GL_STENCIL_INDEX8 : GL_STENCIL_INDEX; #endif if (format.samples && m_functions.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) { m_functions.glRenderbufferStorageMultisample(GL_RENDERBUFFER, format.samples, diff --git a/src/quick/scenegraph/util/qsgsimplematerial.cpp b/src/quick/scenegraph/util/qsgsimplematerial.cpp index a247b37d77..ada4dd6c4f 100644 --- a/src/quick/scenegraph/util/qsgsimplematerial.cpp +++ b/src/quick/scenegraph/util/qsgsimplematerial.cpp @@ -142,6 +142,9 @@ the unique QSGSimpleMaterialShader implementation must be instantiated with a unique C++ type. + \note All classes with QSG prefix should be used solely on the scene graph's + rendering thread. See \l {Scene Graph and Rendering} for more information. + \sa {Scene Graph - Simple Material} */ @@ -244,6 +247,9 @@ \inmodule QtQuick + \note All classes with QSG prefix should be used solely on the scene graph's + rendering thread. See \l {Scene Graph and Rendering} for more information. + \sa QSGSimpleMaterialShader */ diff --git a/src/quick/scenegraph/util/qsgsimpletexturenode.cpp b/src/quick/scenegraph/util/qsgsimpletexturenode.cpp index 47cb82d01b..bbf115fa2a 100644 --- a/src/quick/scenegraph/util/qsgsimpletexturenode.cpp +++ b/src/quick/scenegraph/util/qsgsimpletexturenode.cpp @@ -107,6 +107,8 @@ QSGSimpleTextureNode::QSGSimpleTextureNode() setGeometry(&m_geometry); setMaterial(&m_material); setOpaqueMaterial(&m_opaque_material); + m_material.setMipmapFiltering(QSGTexture::None); + m_opaque_material.setMipmapFiltering(QSGTexture::None); #ifdef QSG_RUNTIME_DESCRIPTION qsgnode_set_description(this, QLatin1String("simpletexture")); #endif diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index 3bbcb0c112..cd0b64fe49 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -39,8 +39,6 @@ ** ****************************************************************************/ -#define GL_GLEXT_PROTOTYPES - #include "qsgtexture_p.h" #include <qopenglfunctions.h> #include <QtQuick/private/qsgcontext_p.h> @@ -83,7 +81,7 @@ static QElapsedTimer qsg_renderer_timer; QT_BEGIN_NAMESPACE -#if !defined(QT_NO_DEBUG) && defined(QT_OPENGL_ES_2) +#ifndef QT_NO_DEBUG inline static bool isPowerOfTwo(int x) { // Assumption: x >= 1 @@ -237,6 +235,9 @@ static void qt_debug_remove_texture(QSGTexture* texture) the function removedFromAtlas() can be used to extract a non-atlassed copy. + \note All classes with QSG prefix should be used solely on the scene graph's + rendering thread. See \l {Scene Graph and Rendering} for more information. + \sa {Scene Graph - Rendering FBOs}, {Scene Graph - Rendering FBOs in a thread} */ @@ -514,7 +515,7 @@ void QSGTexture::updateBindOptions(bool force) } if (force || d->wrapChanged) { -#if !defined(QT_NO_DEBUG) && defined(QT_OPENGL_ES_2) +#ifndef QT_NO_DEBUG if (d->horizontalWrap == Repeat || d->verticalWrap == Repeat) { bool npotSupported = QOpenGLFunctions(QOpenGLContext::currentContext()).hasOpenGLFeature(QOpenGLFunctions::NPOTTextures); QSize size = textureSize(); @@ -566,6 +567,7 @@ void QSGPlainTexture::setImage(const QImage &image) m_has_alpha = image.hasAlphaChannel(); m_dirty_texture = true; m_dirty_bind_options = true; + m_mipmaps_generated = false; } int QSGPlainTexture::textureId() const @@ -686,7 +688,10 @@ void QSGPlainTexture::bind() externalFormat = GL_BGRA; #ifdef QT_OPENGL_ES internalFormat = GL_BGRA; -#endif +#else + if (context->isOpenGLES()) + internalFormat = GL_BGRA; +#endif // QT_OPENGL_ES } else if (!wrongfullyReportsBgra8888Support && (context->hasExtension(QByteArrayLiteral("GL_EXT_texture_format_BGRA8888")) || context->hasExtension(QByteArrayLiteral("GL_IMG_texture_format_BGRA8888")))) { @@ -765,6 +770,9 @@ void QSGPlainTexture::bind() To update the content of the texture, call updateTexture() explicitly. Simply calling bind() will not update the texture. + + \note All classes with QSG prefix should be used solely on the scene graph's + rendering thread. See \l {Scene Graph and Rendering} for more information. */ diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp index df55404504..afa535d322 100644 --- a/src/quick/scenegraph/util/qsgtexturematerial.cpp +++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp @@ -46,13 +46,11 @@ QT_BEGIN_NAMESPACE -#ifdef QT_OPENGL_ES_2 inline static bool isPowerOfTwo(int x) { // Assumption: x >= 1 return x == (x & -x); } -#endif QSGMaterialType QSGOpaqueTextureMaterialShader::type; @@ -83,19 +81,20 @@ void QSGOpaqueTextureMaterialShader::updateState(const RenderState &state, QSGMa QSGTexture *t = tx->texture(); t->setFiltering(tx->filtering()); -#ifdef QT_OPENGL_ES_2 - bool npotSupported = QOpenGLFunctions(const_cast<QOpenGLContext *>(state.context())).hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat); - QSize size = t->textureSize(); - bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height()); - if (!npotSupported && isNpot) { - t->setHorizontalWrapMode(QSGTexture::ClampToEdge); - t->setVerticalWrapMode(QSGTexture::ClampToEdge); - } else -#endif - { - t->setHorizontalWrapMode(tx->horizontalWrapMode()); - t->setVerticalWrapMode(tx->verticalWrapMode()); + + t->setHorizontalWrapMode(tx->horizontalWrapMode()); + t->setVerticalWrapMode(tx->verticalWrapMode()); + bool npotSupported = const_cast<QOpenGLContext *>(state.context()) + ->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat); + if (!npotSupported) { + QSize size = t->textureSize(); + const bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height()); + if (isNpot) { + t->setHorizontalWrapMode(QSGTexture::ClampToEdge); + t->setVerticalWrapMode(QSGTexture::ClampToEdge); + } } + t->setMipmapFiltering(tx->mipmapFiltering()); if (oldTx == 0 || oldTx->texture()->textureId() != t->textureId()) @@ -153,7 +152,7 @@ void QSGOpaqueTextureMaterialShader::updateState(const RenderState &state, QSGMa QSGOpaqueTextureMaterial::QSGOpaqueTextureMaterial() : m_texture(0) , m_filtering(QSGTexture::Nearest) - , m_mipmap_filtering(QSGTexture::Nearest) + , m_mipmap_filtering(QSGTexture::None) , m_horizontal_wrap(QSGTexture::ClampToEdge) , m_vertical_wrap(QSGTexture::ClampToEdge) { |