Make GL2PaintEngine::drawCachedGlyphs use updateTexture
Ensures that we have a consistent view of what the last used texture was, which is critical when deciding whether or not we need to re-bind the texture or update texture properties. Change-Id: Ib47eb00abde98d148fc6e569ce3e359b340328fb Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
This commit is contained in:
parent
37fa842f41
commit
1cc83b575d
@ -697,10 +697,6 @@ void QOpenGL2PaintEngineExPrivate::transferMode(EngineMode newMode)
|
||||
if (newMode == mode)
|
||||
return;
|
||||
|
||||
if (mode != BrushDrawingMode) {
|
||||
lastTextureUsed = GLuint(-1);
|
||||
}
|
||||
|
||||
if (newMode == TextDrawingMode) {
|
||||
shaderManager->setHasComplexGeometry(true);
|
||||
} else {
|
||||
@ -1934,35 +1930,23 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat gly
|
||||
prepareForCachedGlyphDraw(*cache);
|
||||
}
|
||||
|
||||
QOpenGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate)?QOpenGLTextureGlyphCache::Linear:QOpenGLTextureGlyphCache::Nearest;
|
||||
if (lastMaskTextureUsed != cache->texture() || cache->filterMode() != filterMode) {
|
||||
GLenum textureUnit = QT_MASK_TEXTURE_UNIT;
|
||||
if (glyphFormat == QFontEngine::Format_ARGB)
|
||||
textureUnit = QT_IMAGE_TEXTURE_UNIT;
|
||||
|
||||
if (glyphFormat == QFontEngine::Format_ARGB)
|
||||
funcs.glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
|
||||
else
|
||||
funcs.glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT);
|
||||
QOpenGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate) ?
|
||||
QOpenGLTextureGlyphCache::Linear : QOpenGLTextureGlyphCache::Nearest;
|
||||
|
||||
// Need to reset the unit here, until we've made drawCachedGlyphs
|
||||
// use the shared code-path for activating and binding.
|
||||
lastTextureUnitUsed = QT_UNKNOWN_TEXTURE_UNIT;
|
||||
GLenum glFilterMode = filterMode == QOpenGLTextureGlyphCache::Linear ? GL_LINEAR : GL_NEAREST;
|
||||
|
||||
if (lastMaskTextureUsed != cache->texture()) {
|
||||
funcs.glBindTexture(GL_TEXTURE_2D, cache->texture());
|
||||
lastMaskTextureUsed = cache->texture();
|
||||
}
|
||||
|
||||
if (cache->filterMode() != filterMode) {
|
||||
if (filterMode == QOpenGLTextureGlyphCache::Linear) {
|
||||
funcs.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
funcs.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
} else {
|
||||
funcs.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
funcs.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
}
|
||||
cache->setFilterMode(filterMode);
|
||||
}
|
||||
TextureUpdateMode updateMode = UpdateIfNeeded;
|
||||
if (cache->filterMode() != filterMode) {
|
||||
updateMode = ForceUpdate;
|
||||
cache->setFilterMode(filterMode);
|
||||
}
|
||||
|
||||
updateTexture(textureUnit, cache->texture(), GL_REPEAT, glFilterMode, updateMode);
|
||||
|
||||
#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
|
||||
funcs.glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0);
|
||||
funcs.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
@ -2185,7 +2169,6 @@ void QOpenGL2PaintEngineEx::ensureActive()
|
||||
d->transferMode(BrushDrawingMode);
|
||||
d->funcs.glViewport(0, 0, d->width, d->height);
|
||||
d->needsSync = false;
|
||||
d->lastMaskTextureUsed = 0;
|
||||
d->shaderManager->setDirty();
|
||||
d->syncGlState();
|
||||
for (int i = 0; i < 3; ++i)
|
||||
|
@ -186,8 +186,7 @@ public:
|
||||
snapToPixelGrid(false),
|
||||
nativePaintingActive(false),
|
||||
inverseScale(1),
|
||||
lastTextureUnitUsed(QT_UNKNOWN_TEXTURE_UNIT),
|
||||
lastMaskTextureUsed(0)
|
||||
lastTextureUnitUsed(QT_UNKNOWN_TEXTURE_UNIT)
|
||||
{ }
|
||||
|
||||
~QOpenGL2PaintEngineExPrivate();
|
||||
@ -306,7 +305,6 @@ public:
|
||||
|
||||
GLenum lastTextureUnitUsed;
|
||||
GLuint lastTextureUsed;
|
||||
GLuint lastMaskTextureUsed;
|
||||
|
||||
bool needsSync;
|
||||
bool multisamplingAlwaysEnabled;
|
||||
|
Loading…
Reference in New Issue
Block a user