summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/eglfs
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-04-17 08:46:13 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-18 22:23:53 +0200
commit197b423e9663c11221172253bb84754adb51742f (patch)
treef0aa476e0241b6e0d3e8bcda7799b2e50abf3d3d /src/plugins/platforms/eglfs
parentc12057df292f6985e42d5c012bafc3accf30c7c9 (diff)
Optimized EGLFS backing store a bit.
Avoid expensive image copying when possible. Change-Id: Ia79919ea7652d7bfdd744198c494c20cb78a0f48 Reviewed-by: Donald Carr <donald.carr@nokia.com> Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Diffstat (limited to 'src/plugins/platforms/eglfs')
-rw-r--r--src/plugins/platforms/eglfs/qeglfsbackingstore.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp b/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp
index 29559dd6a4..5c1919a4f3 100644
--- a/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp
@@ -145,16 +145,37 @@ void QEglFSBackingStore::flush(QWindow *window, const QRegion &region, const QPo
glBindTexture(GL_TEXTURE_2D, m_texture);
- foreach (const QRect &rect, m_dirty.rects()) {
- if (rect == m_image.rect()) {
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE, m_image.constBits());
- } else {
- glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE,
- m_image.copy(rect).constBits());
+ if (!m_dirty.isNull()) {
+ QRect imageRect = m_image.rect();
+
+ QRegion fixed;
+ foreach (const QRect &rect, m_dirty.rects()) {
+ // intersect with image rect to be sure
+ QRect r = imageRect & rect;
+
+ // if the rect is wide enough it's cheaper to just
+ // extend it instead of doing an image copy
+ if (r.width() >= imageRect.width() / 2) {
+ r.setX(0);
+ r.setWidth(imageRect.width());
+ }
+
+ fixed |= r;
+ }
+
+ foreach (const QRect &rect, fixed.rects()) {
+ // if the sub-rect is full-width we can pass the image data directly to
+ // OpenGL instead of copying, since there's no gap between scanlines
+ if (rect.width() == imageRect.width()) {
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE, m_image.constScanLine(rect.y()));
+ } else {
+ glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE,
+ m_image.copy(rect).constBits());
+ }
}
- }
- m_dirty = QRegion();
+ m_dirty = QRegion();
+ }
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);