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)
|
if (newMode == mode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mode != BrushDrawingMode) {
|
|
||||||
lastTextureUsed = GLuint(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newMode == TextDrawingMode) {
|
if (newMode == TextDrawingMode) {
|
||||||
shaderManager->setHasComplexGeometry(true);
|
shaderManager->setHasComplexGeometry(true);
|
||||||
} else {
|
} else {
|
||||||
@ -1934,35 +1930,23 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat gly
|
|||||||
prepareForCachedGlyphDraw(*cache);
|
prepareForCachedGlyphDraw(*cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
QOpenGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate)?QOpenGLTextureGlyphCache::Linear:QOpenGLTextureGlyphCache::Nearest;
|
GLenum textureUnit = QT_MASK_TEXTURE_UNIT;
|
||||||
if (lastMaskTextureUsed != cache->texture() || cache->filterMode() != filterMode) {
|
if (glyphFormat == QFontEngine::Format_ARGB)
|
||||||
|
textureUnit = QT_IMAGE_TEXTURE_UNIT;
|
||||||
|
|
||||||
if (glyphFormat == QFontEngine::Format_ARGB)
|
QOpenGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate) ?
|
||||||
funcs.glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
|
QOpenGLTextureGlyphCache::Linear : QOpenGLTextureGlyphCache::Nearest;
|
||||||
else
|
|
||||||
funcs.glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT);
|
|
||||||
|
|
||||||
// Need to reset the unit here, until we've made drawCachedGlyphs
|
GLenum glFilterMode = filterMode == QOpenGLTextureGlyphCache::Linear ? GL_LINEAR : GL_NEAREST;
|
||||||
// use the shared code-path for activating and binding.
|
|
||||||
lastTextureUnitUsed = QT_UNKNOWN_TEXTURE_UNIT;
|
|
||||||
|
|
||||||
if (lastMaskTextureUsed != cache->texture()) {
|
TextureUpdateMode updateMode = UpdateIfNeeded;
|
||||||
funcs.glBindTexture(GL_TEXTURE_2D, cache->texture());
|
if (cache->filterMode() != filterMode) {
|
||||||
lastMaskTextureUsed = cache->texture();
|
updateMode = ForceUpdate;
|
||||||
}
|
cache->setFilterMode(filterMode);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTexture(textureUnit, cache->texture(), GL_REPEAT, glFilterMode, updateMode);
|
||||||
|
|
||||||
#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
|
#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)
|
||||||
funcs.glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0);
|
funcs.glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0);
|
||||||
funcs.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
funcs.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
@ -2185,7 +2169,6 @@ void QOpenGL2PaintEngineEx::ensureActive()
|
|||||||
d->transferMode(BrushDrawingMode);
|
d->transferMode(BrushDrawingMode);
|
||||||
d->funcs.glViewport(0, 0, d->width, d->height);
|
d->funcs.glViewport(0, 0, d->width, d->height);
|
||||||
d->needsSync = false;
|
d->needsSync = false;
|
||||||
d->lastMaskTextureUsed = 0;
|
|
||||||
d->shaderManager->setDirty();
|
d->shaderManager->setDirty();
|
||||||
d->syncGlState();
|
d->syncGlState();
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
|
@ -186,8 +186,7 @@ public:
|
|||||||
snapToPixelGrid(false),
|
snapToPixelGrid(false),
|
||||||
nativePaintingActive(false),
|
nativePaintingActive(false),
|
||||||
inverseScale(1),
|
inverseScale(1),
|
||||||
lastTextureUnitUsed(QT_UNKNOWN_TEXTURE_UNIT),
|
lastTextureUnitUsed(QT_UNKNOWN_TEXTURE_UNIT)
|
||||||
lastMaskTextureUsed(0)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
~QOpenGL2PaintEngineExPrivate();
|
~QOpenGL2PaintEngineExPrivate();
|
||||||
@ -306,7 +305,6 @@ public:
|
|||||||
|
|
||||||
GLenum lastTextureUnitUsed;
|
GLenum lastTextureUnitUsed;
|
||||||
GLuint lastTextureUsed;
|
GLuint lastTextureUsed;
|
||||||
GLuint lastMaskTextureUsed;
|
|
||||||
|
|
||||||
bool needsSync;
|
bool needsSync;
|
||||||
bool multisamplingAlwaysEnabled;
|
bool multisamplingAlwaysEnabled;
|
||||||
|
Loading…
Reference in New Issue
Block a user