summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Wilson <alex.wilson@nokia.com>2012-03-27 11:58:10 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-27 06:37:05 +0200
commitb98b2f0b1f208f0a91e05f894dc87586111a6904 (patch)
tree2e51b79cc58b87f9b2680d3f3f25bc6d9f9d0b18
parent69f29041f3ac9d794799575a410f6f3e2bf86c72 (diff)
Setting LinearFiltering bind option should not trigger re-upload
The LinearFlitering bind option can be applied without incrementing imageGeneration and triggering a full-reupload of the texture. This separates handling of this option from the other bind options to allow this use case. Task-number: QTBUG-24985 Change-Id: I097ea7d1334bc82d7985e4b5c222d57b7d840cf9 Reviewed-by: Sarah Jane Smith <sarah.j.smith@nokia.com>
-rw-r--r--src/threed/textures/qgltexture2d.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/threed/textures/qgltexture2d.cpp b/src/threed/textures/qgltexture2d.cpp
index debecf679..698766283 100644
--- a/src/threed/textures/qgltexture2d.cpp
+++ b/src/threed/textures/qgltexture2d.cpp
@@ -503,16 +503,26 @@ QGLTexture2D::BindOptions QGLTexture2D::bindOptions() const
Sets the \a options to use when binding the image() to an
OpenGL context. If the image() has already been bound,
then changing the options will cause it to be recreated
- from image() the next time bind() is called.
+ from image() the next time bind() is called, unless the
+ only change was to the LinearFilteringBindOption, which
+ can be applied without re-creation.
\sa bindOptions(), bind()
*/
void QGLTexture2D::setBindOptions(QGLTexture2D::BindOptions options)
{
Q_D(QGLTexture2D);
- if (d->bindOptions != options) {
+ uint optionDelta = d->bindOptions ^ options;
+ if (optionDelta) {
+ // special case: only LinearFiltering option changed
+ // --> treat this just as a parameter change
+ if (optionDelta == LinearFilteringBindOption) {
+ ++(d->parameterGeneration);
+ } else {
+ // all other options trigger re-upload
+ ++(d->imageGeneration);
+ }
d->bindOptions = options;
- ++(d->imageGeneration);
}
}
@@ -589,8 +599,10 @@ void QGLTexture2D::setVerticalWrap(QGL::TextureWrap value)
To remove the resources from the GL server when this texture is
no longer required, call cleanupResources().
- If setImage() or setSize() was called since the last upload,
- then image() will be re-uploaded to the GL server.
+ If setImage(), setSize() or setBindOptions() were called since
+ the last upload, then image() will be re-uploaded to the GL
+ server, except for the special case where setBindOptions()
+ changed only the LinearFilteringBindOption.
Returns false if the texture could not be bound for some reason.
@@ -681,6 +693,9 @@ bool QGLTexture2DPrivate::bind(GLenum target)
// If the parameter generation has changed, then alter the parameters.
if (parameterGeneration != texInfo->parameterGeneration) {
texInfo->parameterGeneration = parameterGeneration;
+ uint v = ((bindOptions & QGLTexture2D::LinearFilteringBindOption) ? GL_LINEAR : GL_NEAREST);
+ q_glTexParameteri(target, GL_TEXTURE_MIN_FILTER, v);
+ q_glTexParameteri(target, GL_TEXTURE_MAG_FILTER, v);
q_glTexParameteri(target, GL_TEXTURE_WRAP_S, horizontalWrap);
q_glTexParameteri(target, GL_TEXTURE_WRAP_T, verticalWrap);
}