summaryrefslogtreecommitdiffstats
path: root/src/opengl/qpixmapdata_gl.cpp
diff options
context:
space:
mode:
authorhjk <qtc-committer@nokia.com>2009-10-30 11:15:11 (GMT)
committerhjk <qtc-committer@nokia.com>2009-10-30 11:15:11 (GMT)
commit7c04935b278db196b3e67a6b501ec14d852acabd (patch)
tree2424c1a9c90757947cb13e67a4a61ad3473fdd7a /src/opengl/qpixmapdata_gl.cpp
parent1bed105d048531e3e260eff0ef2533d7cc8ba7fb (diff)
parent83fff2f970b9a7b41861336c7dca0eadbda28099 (diff)
downloadQt-7c04935b278db196b3e67a6b501ec14d852acabd.zip
Qt-7c04935b278db196b3e67a6b501ec14d852acabd.tar.gz
Qt-7c04935b278db196b3e67a6b501ec14d852acabd.tar.bz2
Merge commit 'mainline/4.6' into 4.6
Diffstat (limited to 'src/opengl/qpixmapdata_gl.cpp')
-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()) {