summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-07-02 08:01:56 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-07-02 08:05:40 (GMT)
commitb1832b5a32e1ff5536e5fe9efeca3013ba947eec (patch)
treed5e0ed6231035939e15f9f3316dc1b0a8ead58d9 /src/opengl
parentef9fad3391f7b5c59d3fe62b491a4760c2917810 (diff)
downloadQt-b1832b5a32e1ff5536e5fe9efeca3013ba947eec.zip
Qt-b1832b5a32e1ff5536e5fe9efeca3013ba947eec.tar.gz
Qt-b1832b5a32e1ff5536e5fe9efeca3013ba947eec.tar.bz2
Made GL blur filter use the new FBO pool for improved performance.
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qglpixmapfilter.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp
index 6812c43..4e859d4 100644
--- a/src/opengl/qglpixmapfilter.cpp
+++ b/src/opengl/qglpixmapfilter.cpp
@@ -116,7 +116,6 @@ private:
static QByteArray generateBlurShader(int radius, bool gaussianBlur);
mutable QGLShader *m_shader;
- mutable QGLFramebufferObject *m_fbo;
mutable QSize m_textureSize;
@@ -310,13 +309,11 @@ bool QGLPixmapConvolutionFilter::processGL(QPainter *, const QPointF &pos, const
}
QGLPixmapBlurFilter::QGLPixmapBlurFilter()
- : m_fbo(0)
{
}
QGLPixmapBlurFilter::~QGLPixmapBlurFilter()
{
- delete m_fbo;
}
bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &) const
@@ -328,15 +325,20 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const
blurShader->compile(generateBlurShader(radius(), quality() == Qt::SmoothTransformation));
customShader->setShader(blurShader);
+ }
- m_fbo = new QGLFramebufferObject(src.size());
+ QGLFramebufferObjectFormat format;
+ format.setInternalFormat(src.hasAlphaChannel() ? GL_RGBA : GL_RGB);
+ QGLFramebufferObject *fbo = qgl_fbo_pool()->acquire(src.size(), format);
- glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
+ if (!fbo)
+ return false;
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glBindTexture(GL_TEXTURE_2D, 0);
- }
+ glBindTexture(GL_TEXTURE_2D, fbo->texture());
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glBindTexture(GL_TEXTURE_2D, 0);
QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx *>(painter->paintEngine());
QGLEngineShaderManager *manager = engine->shaderManager();
@@ -351,18 +353,20 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const
m_textureSize = src.size();
// first pass, to fbo
- m_fbo->bind();
+ fbo->bind();
manager->setCustomShader(customShader);
engine->drawPixmap(src.rect(), src, src.rect());
- m_fbo->release();
+ fbo->release();
// second pass, to widget
m_program->setUniformValue("delta", 0.0, 1.0);
- engine->drawTexture(src.rect().translated(pos.x(), pos.y()), m_fbo->texture(), src.size(), src.rect());
+ engine->drawTexture(src.rect().translated(pos.x(), pos.y()), fbo->texture(), src.size(), src.rect());
manager->setCustomShader(0);
painter->restore();
+ qgl_fbo_pool()->release(fbo);
+
return true;
}