summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-10-28 16:57:12 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-10-29 09:47:15 (GMT)
commit7881773800c05c09f0e85a80c1cbb678981bd6c0 (patch)
tree00972a67b9313dde592bb272444e8378639cda7b /src
parent8f527513fd2bc280d3613759d411e8e4e96a522e (diff)
downloadQt-7881773800c05c09f0e85a80c1cbb678981bd6c0.zip
Qt-7881773800c05c09f0e85a80c1cbb678981bd6c0.tar.gz
Qt-7881773800c05c09f0e85a80c1cbb678981bd6c0.tar.bz2
Made internal FBOs snap to power-of-two when not wasting too much space.
This improves performance on certain OpenGL ES 2.0 platforms. Reviewed-by: Gunnar Sletta
Diffstat (limited to 'src')
-rw-r--r--src/opengl/qpixmapdata_gl.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
index 83ebece..c965947 100644
--- a/src/opengl/qpixmapdata_gl.cpp
+++ b/src/opengl/qpixmapdata_gl.cpp
@@ -76,6 +76,19 @@ static inline int areaDiff(const QSize &size, const QGLFramebufferObject *fbo)
return qAbs(size.width() * size.height() - fbo->width() * fbo->height());
}
+extern int qt_next_power_of_two(int v);
+
+static inline QSize maybeRoundToNextPowerOfTwo(const QSize &sz)
+{
+#ifdef QT_OPENGL_ES_2
+ QSize rounded(qt_next_power_of_two(sz.width()), qt_next_power_of_two(sz.height()));
+ if (rounded.width() * rounded.height() < 1.20 * sz.width() * sz.height())
+ return rounded;
+#endif
+ return sz;
+}
+
+
QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize, const QGLFramebufferObjectFormat &requestFormat)
{
QGLFramebufferObject *chosen = 0;
@@ -106,7 +119,7 @@ QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize
if (sz != fboSize) {
delete candidate;
- candidate = new QGLFramebufferObject(sz, requestFormat);
+ candidate = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(sz), requestFormat);
}
chosen = candidate;
@@ -114,7 +127,7 @@ QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize
}
if (!chosen) {
- chosen = new QGLFramebufferObject(requestSize, requestFormat);
+ chosen = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(requestSize), requestFormat);
}
if (!chosen->isValid()) {