aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp6
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.cpp36
-rw-r--r--src/quick/scenegraph/qsgdefaultimagenode.cpp8
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp78
-rw-r--r--src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp2
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp8
-rw-r--r--src/quick/scenegraph/util/qsgsimpletexturenode.cpp3
7 files changed, 73 insertions, 68 deletions
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index caa0d032a4..bb8e3c4b36 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -408,7 +408,11 @@ QSGDistanceFieldGlyphCache *QSGContext::distanceFieldGlyphCache(const QRawFont &
QSGGlyphNode *QSGContext::createNativeGlyphNode()
{
#if defined(QT_OPENGL_ES) && !defined(QT_OPENGL_ES_2_ANGLE)
- return createGlyphNode();
+ Q_D(QSGContext);
+ if (d->distanceFieldDisabled)
+ return new QSGDefaultGlyphNode;
+ else
+ return createGlyphNode();
#else
return new QSGDefaultGlyphNode;
#endif
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
index 50009d7709..39d9832f58 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp
@@ -101,10 +101,10 @@ const char *QSGTextMaskShader::vertexShader() const {
const char *QSGTextMaskShader::fragmentShader() const {
return
"varying highp vec2 sampleCoord; \n"
- "uniform sampler2D texture; \n"
+ "uniform sampler2D _qt_texture; \n"
"uniform lowp vec4 color; \n"
"void main() { \n"
- " lowp vec4 glyph = texture2D(texture, sampleCoord); \n"
+ " lowp vec4 glyph = texture2D(_qt_texture, sampleCoord); \n"
" gl_FragColor = vec4(glyph.rgb * color.a, glyph.a); \n"
"}";
}
@@ -389,14 +389,14 @@ const char *QSGStyledTextShader::fragmentShader() const
return
"varying highp vec2 sampleCoord; \n"
"varying highp vec2 shiftedSampleCoord; \n"
- "uniform sampler2D texture; \n"
+ "uniform sampler2D _qt_texture; \n"
"uniform lowp vec4 color; \n"
"uniform lowp vec4 styleColor; \n"
- "void main() { \n"
- " lowp float glyph = texture2D(texture, sampleCoord).a; \n"
- " lowp float style = clamp(texture2D(texture, shiftedSampleCoord).a - glyph, \n"
- " 0.0, 1.0); \n"
- " gl_FragColor = style * styleColor + glyph * color; \n"
+ "void main() { \n"
+ " lowp float glyph = texture2D(_qt_texture, sampleCoord).a; \n"
+ " lowp float style = clamp(texture2D(_qt_texture, shiftedSampleCoord).a - glyph, \n"
+ " 0.0, 1.0); \n"
+ " gl_FragColor = style * styleColor + glyph * color; \n"
"}";
}
@@ -444,18 +444,18 @@ const char *QSGOutlinedTextShader::fragmentShader() const
"varying highp vec2 sCoordDown; \n"
"varying highp vec2 sCoordLeft; \n"
"varying highp vec2 sCoordRight; \n"
- "uniform sampler2D texture; \n"
+ "uniform sampler2D _qt_texture; \n"
"uniform lowp vec4 color; \n"
"uniform lowp vec4 styleColor; \n"
- "void main() { \n"
- "lowp float glyph = texture2D(texture, sampleCoord).a; \n"
- " lowp float outline = clamp(clamp(texture2D(texture, sCoordUp).a + \n"
- " texture2D(texture, sCoordDown).a + \n"
- " texture2D(texture, sCoordLeft).a + \n"
- " texture2D(texture, sCoordRight).a, \n"
- " 0.0, 1.0) - glyph, \n"
- " 0.0, 1.0); \n"
- " gl_FragColor = outline * styleColor + glyph * color; \n"
+ "void main() { \n"
+ "lowp float glyph = texture2D(_qt_texture, sampleCoord).a; \n"
+ " lowp float outline = clamp(clamp(texture2D(_qt_texture, sCoordUp).a + \n"
+ " texture2D(_qt_texture, sCoordDown).a + \n"
+ " texture2D(_qt_texture, sCoordLeft).a + \n"
+ " texture2D(_qt_texture, sCoordRight).a, \n"
+ " 0.0, 1.0) - glyph, \n"
+ " 0.0, 1.0); \n"
+ " gl_FragColor = outline * styleColor + glyph * color; \n"
"}";
}
diff --git a/src/quick/scenegraph/qsgdefaultimagenode.cpp b/src/quick/scenegraph/qsgdefaultimagenode.cpp
index 349a92ac7f..11d0e5dbeb 100644
--- a/src/quick/scenegraph/qsgdefaultimagenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultimagenode.cpp
@@ -298,15 +298,13 @@ void QSGDefaultImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode)
void QSGDefaultImageNode::setTexture(QSGTexture *texture)
{
- if (texture == m_material.texture())
- return;
+ Q_ASSERT(texture);
m_material.setTexture(texture);
m_materialO.setTexture(texture);
m_smoothMaterial.setTexture(texture);
- // Texture cleanup
- if (texture)
- m_material.setFlag(QSGMaterial::Blending, texture->hasAlphaChannel());
+ m_material.setFlag(QSGMaterial::Blending, texture->hasAlphaChannel());
+
markDirty(DirtyMaterial);
// Because the texture can be a different part of the atlas, we need to update it...
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index 0cf7abed2e..125243847a 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -96,15 +96,15 @@ const char *QSGDistanceFieldTextMaterialShader::vertexShader() const {
const char *QSGDistanceFieldTextMaterialShader::fragmentShader() const {
return
- "varying highp vec2 sampleCoord; \n"
- "uniform mediump sampler2D texture; \n"
- "uniform lowp vec4 color; \n"
- "uniform mediump float alphaMin; \n"
- "uniform mediump float alphaMax; \n"
- "void main() { \n"
- " gl_FragColor = color * smoothstep(alphaMin, \n"
- " alphaMax, \n"
- " texture2D(texture, sampleCoord).a); \n"
+ "varying highp vec2 sampleCoord; \n"
+ "uniform mediump sampler2D _qt_texture; \n"
+ "uniform lowp vec4 color; \n"
+ "uniform mediump float alphaMin; \n"
+ "uniform mediump float alphaMax; \n"
+ "void main() { \n"
+ " gl_FragColor = color * smoothstep(alphaMin, \n"
+ " alphaMax, \n"
+ " texture2D(_qt_texture, sampleCoord).a); \n"
"}";
}
@@ -366,7 +366,7 @@ protected:
const char *DistanceFieldOutlineTextMaterialShader::fragmentShader() const {
return
"varying highp vec2 sampleCoord; \n"
- "uniform sampler2D texture; \n"
+ "uniform sampler2D _qt_texture; \n"
"uniform lowp vec4 color; \n"
"uniform lowp vec4 styleColor; \n"
"uniform mediump float alphaMin; \n"
@@ -374,7 +374,7 @@ const char *DistanceFieldOutlineTextMaterialShader::fragmentShader() const {
"uniform mediump float outlineAlphaMax0; \n"
"uniform mediump float outlineAlphaMax1; \n"
"void main() { \n"
- " mediump float d = texture2D(texture, sampleCoord).a; \n"
+ " mediump float d = texture2D(_qt_texture, sampleCoord).a; \n"
" gl_FragColor = mix(styleColor, color, smoothstep(alphaMin, alphaMax, d)) \n"
" * smoothstep(outlineAlphaMax0, outlineAlphaMax1, d); \n"
"}";
@@ -514,19 +514,19 @@ const char *DistanceFieldShiftedStyleTextMaterialShader::vertexShader() const
const char *DistanceFieldShiftedStyleTextMaterialShader::fragmentShader() const {
return
- "varying highp vec2 sampleCoord; \n"
- "varying highp vec2 shiftedSampleCoord; \n"
- "uniform sampler2D texture; \n"
- "uniform lowp vec4 color; \n"
- "uniform lowp vec4 styleColor; \n"
- "uniform mediump float alphaMin; \n"
- "uniform mediump float alphaMax; \n"
- "void main() { \n"
- " highp float a = smoothstep(alphaMin, alphaMax, texture2D(texture, sampleCoord).a);\n"
- " highp vec4 shifted = styleColor * smoothstep(alphaMin, \n"
- " alphaMax, \n"
- " texture2D(texture, shiftedSampleCoord).a); \n"
- " gl_FragColor = mix(shifted, color, a); \n"
+ "varying highp vec2 sampleCoord; \n"
+ "varying highp vec2 shiftedSampleCoord; \n"
+ "uniform sampler2D _qt_texture; \n"
+ "uniform lowp vec4 color; \n"
+ "uniform lowp vec4 styleColor; \n"
+ "uniform mediump float alphaMin; \n"
+ "uniform mediump float alphaMax; \n"
+ "void main() { \n"
+ " highp float a = smoothstep(alphaMin, alphaMax, texture2D(_qt_texture, sampleCoord).a); \n"
+ " highp vec4 shifted = styleColor * smoothstep(alphaMin, \n"
+ " alphaMax, \n"
+ " texture2D(_qt_texture, shiftedSampleCoord).a); \n"
+ " gl_FragColor = mix(shifted, color, a); \n"
"}";
}
@@ -607,17 +607,17 @@ const char *QSGHiQSubPixelDistanceFieldTextMaterialShader::fragmentShader() cons
"varying highp vec3 sampleNearLeft; \n"
"varying highp vec3 sampleNearRight; \n"
"varying highp vec3 sampleFarRight; \n"
- "uniform sampler2D texture; \n"
+ "uniform sampler2D _qt_texture; \n"
"uniform lowp vec4 color; \n"
"uniform mediump float alphaMin; \n"
"uniform mediump float alphaMax; \n"
"void main() { \n"
" highp vec4 n; \n"
- " n.x = texture2DProj(texture, sampleFarLeft).a; \n"
- " n.y = texture2DProj(texture, sampleNearLeft).a; \n"
- " highp float c = texture2D(texture, sampleCoord).a; \n"
- " n.z = texture2DProj(texture, sampleNearRight).a; \n"
- " n.w = texture2DProj(texture, sampleFarRight).a; \n"
+ " n.x = texture2DProj(_qt_texture, sampleFarLeft).a; \n"
+ " n.y = texture2DProj(_qt_texture, sampleNearLeft).a; \n"
+ " highp float c = texture2D(_qt_texture, sampleCoord).a; \n"
+ " n.z = texture2DProj(_qt_texture, sampleNearRight).a; \n"
+ " n.w = texture2DProj(_qt_texture, sampleFarRight).a; \n"
#if 0
// Blurrier, faster.
" n = smoothstep(alphaMin, alphaMax, n); \n"
@@ -638,18 +638,18 @@ const char *QSGHiQSubPixelDistanceFieldTextMaterialShader::fragmentShader() cons
// return
// "#extension GL_OES_standard_derivatives: enable \n"
// "varying highp vec2 sampleCoord; \n"
-// "uniform sampler2D texture; \n"
+// "uniform sampler2D _qt_texture; \n"
// "uniform lowp vec4 color; \n"
// "uniform highp float alphaMin; \n"
// "uniform highp float alphaMax; \n"
// "void main() { \n"
// " highp vec2 delta = dFdx(sampleCoord); \n"
// " highp vec4 n; \n"
-// " n.x = texture2D(texture, sampleCoord - 0.667 * delta).a; \n"
-// " n.y = texture2D(texture, sampleCoord - 0.333 * delta).a; \n"
-// " highp float c = texture2D(texture, sampleCoord).a; \n"
-// " n.z = texture2D(texture, sampleCoord + 0.333 * delta).a; \n"
-// " n.w = texture2D(texture, sampleCoord + 0.667 * delta).a; \n"
+// " n.x = texture2D(_qt_texture, sampleCoord - 0.667 * delta).a; \n"
+// " n.y = texture2D(_qt_texture, sampleCoord - 0.333 * delta).a; \n"
+// " highp float c = texture2D(_qt_texture, sampleCoord).a; \n"
+// " n.z = texture2D(_qt_texture, sampleCoord + 0.333 * delta).a; \n"
+// " n.w = texture2D(_qt_texture, sampleCoord + 0.667 * delta).a; \n"
// " n = smoothstep(alphaMin, alphaMax, n); \n"
// " c = smoothstep(alphaMin, alphaMax, c); \n"
// " gl_FragColor = vec4(0.333 * (n.xyz + n.yzw + c), c) * color.w; \n"
@@ -746,14 +746,14 @@ const char *QSGLoQSubPixelDistanceFieldTextMaterialShader::fragmentShader() cons
return
"varying highp vec3 sampleNearLeft; \n"
"varying highp vec3 sampleNearRight; \n"
- "uniform sampler2D texture; \n"
+ "uniform sampler2D _qt_texture; \n"
"uniform lowp vec4 color; \n"
"uniform mediump float alphaMin; \n"
"uniform mediump float alphaMax; \n"
"void main() { \n"
" highp vec2 n; \n"
- " n.x = texture2DProj(texture, sampleNearLeft).a; \n"
- " n.y = texture2DProj(texture, sampleNearRight).a; \n"
+ " n.x = texture2DProj(_qt_texture, sampleNearLeft).a; \n"
+ " n.y = texture2DProj(_qt_texture, sampleNearRight).a; \n"
" n = smoothstep(alphaMin, alphaMax, n); \n"
" highp float c = 0.5 * (n.x + n.y); \n"
" gl_FragColor = vec4(n.x, c, n.y, c) * color.w; \n"
diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
index fb9eebf403..34a884348d 100644
--- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp
@@ -531,7 +531,7 @@ void QSGSharedDistanceFieldGlyphCache::saveTexture(GLuint textureId, int width,
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
- int textureUniformLocation = glGetUniformLocation(shaderProgram, "texture");
+ int textureUniformLocation = glGetUniformLocation(shaderProgram, "_qt_texture");
glUniform1i(textureUniformLocation, 0);
}
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index d19c047e5a..7421db1db1 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -406,22 +406,26 @@ bool QSGRenderThread::event(QEvent *e)
pendingUpdate |= SyncRequest;
return true;
- case WM_TryRelease:
+ case WM_TryRelease: {
RLDEBUG1(" Render: WM_TryRelease");
mutex.lock();
+ WMTryReleaseEvent *wme = static_cast<WMTryReleaseEvent *>(e);
if (m_windows.size() == 0) {
- WMTryReleaseEvent *wme = static_cast<WMTryReleaseEvent *>(e);
RLDEBUG1(" Render: - setting exit flag and invalidating GL");
invalidateOpenGL(wme->window, wme->inDestructor);
shouldExit = !gl;
if (sleeping)
stopEventProcessing = true;
+ } else if (wme->window == gl->surface()) {
+ RLDEBUG1(" Render: - destroying the current window. Calling doneCurrent()...");
+ gl->doneCurrent();
} else {
RLDEBUG1(" Render: - not releasing anything because we have active windows...");
}
waitCondition.wakeOne();
mutex.unlock();
return true;
+ }
case WM_Grab: {
RLDEBUG1(" Render: WM_Grab");
diff --git a/src/quick/scenegraph/util/qsgsimpletexturenode.cpp b/src/quick/scenegraph/util/qsgsimpletexturenode.cpp
index 5d9946a37b..fc1d6cecbc 100644
--- a/src/quick/scenegraph/util/qsgsimpletexturenode.cpp
+++ b/src/quick/scenegraph/util/qsgsimpletexturenode.cpp
@@ -173,8 +173,7 @@ QRectF QSGSimpleTextureNode::rect() const
*/
void QSGSimpleTextureNode::setTexture(QSGTexture *texture)
{
- if (m_material.texture() == texture)
- return;
+ Q_ASSERT(texture);
m_material.setTexture(texture);
m_opaque_material.setTexture(texture);
Q_D(QSGSimpleTextureNode);