qtbase: patches for WebKit hardware accelerated rendering support

0018 - Offset support for QOpenGLPaintDevice is required for
       speedup WebKit hardware rendering.
0019 - Fix FBO restoring in QOpenGLTextureGlyphCache
       Jira task
0020 - Uses right texture format to exclude extra convertion.

Signed-off-by: Alexander Irhin <alexander.irhin@lge.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
This commit is contained in:
Alexander Irhin 2013-05-24 11:37:02 -07:00 committed by Martin Jansa
parent 6f4e86b621
commit ac8a20d754
7 changed files with 474 additions and 1 deletions

View File

@ -0,0 +1,152 @@
From 2efd051d3093ee4e4091a8947f28d9bd528f2e9e Mon Sep 17 00:00:00 2001
From: Jani Hautakangas <jani.hautakangas@ixonos.com>
Date: Thu, 16 May 2013 09:52:07 +0300
Subject: [PATCH] QOpenGLPaintDevice sub-area support
Allows creating QOpenGLPaintDevice targetting sub-area
of binded framebuffer.
Upstream-Status: Pending
Change-Id: Ida2f079aa1ac0b87d36b54129e226399dbcdda80
---
src/gui/opengl/qopenglpaintdevice.cpp | 12 ++++++++++++
src/gui/opengl/qopenglpaintdevice.h | 2 ++
src/gui/opengl/qopenglpaintengine.cpp | 10 +++++++---
src/gui/opengl/qopenglpaintengine_p.h | 1 +
src/gui/opengl/qopengltextureglyphcache.cpp | 2 +-
5 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp
index f0e7e49..fe9a30c 100644
--- a/src/gui/opengl/qopenglpaintdevice.cpp
+++ b/src/gui/opengl/qopenglpaintdevice.cpp
@@ -111,6 +111,7 @@ class QOpenGLPaintDevicePrivate
public:
QOpenGLPaintDevicePrivate(const QSize &size);
+ QPoint offset;
QSize size;
QOpenGLContext *ctx;
@@ -159,6 +160,12 @@ QOpenGLPaintDevice::QOpenGLPaintDevice(int width, int height)
{
}
+QOpenGLPaintDevice::QOpenGLPaintDevice(int x, int y, int width, int height)
+ : d_ptr(new QOpenGLPaintDevicePrivate(QSize(width, height)))
+{
+ d_ptr->offset = QPoint(x,y);
+}
+
/*!
Destroys the QOpenGLPaintDevice.
*/
@@ -228,6 +235,11 @@ QOpenGLContext *QOpenGLPaintDevice::context() const
return d_ptr->ctx;
}
+QPoint QOpenGLPaintDevice::offset() const
+{
+ return d_ptr->offset;
+}
+
/*!
Returns the pixel size of the paint device.
diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h
index c05571c..01eb1bc 100644
--- a/src/gui/opengl/qopenglpaintdevice.h
+++ b/src/gui/opengl/qopenglpaintdevice.h
@@ -62,12 +62,14 @@ public:
QOpenGLPaintDevice();
explicit QOpenGLPaintDevice(const QSize &size);
QOpenGLPaintDevice(int width, int height);
+ QOpenGLPaintDevice(int x, int y, int width, int height);
virtual ~QOpenGLPaintDevice();
int devType() const { return QInternal::OpenGL; }
QPaintEngine *paintEngine() const;
QOpenGLContext *context() const;
+ QPoint offset() const;
QSize size() const;
void setSize(const QSize &size);
void setDevicePixelRatio(qreal devicePixelRatio);
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
index 0782e42..52afc60 100644
--- a/src/gui/opengl/qopenglpaintengine.cpp
+++ b/src/gui/opengl/qopenglpaintengine.cpp
@@ -1978,7 +1978,10 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev)
for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
d->vertexAttributeArraysEnabledState[i] = false;
+ const QPoint offset = d->device->offset();
const QSize sz = d->device->size();
+ d->x = offset.x();
+ d->y = offset.y();
d->width = sz.width();
d->height = sz.height();
d->mode = BrushDrawingMode;
@@ -2066,7 +2069,7 @@ void QOpenGL2PaintEngineEx::ensureActive()
d->device->ensureActiveTarget();
d->transferMode(BrushDrawingMode);
- glViewport(0, 0, d->width, d->height);
+ glViewport(d->x, d->y, d->width, d->height);
d->needsSync = false;
d->lastMaskTextureUsed = 0;
d->shaderManager->setDirty();
@@ -2109,6 +2112,7 @@ void QOpenGL2PaintEngineExPrivate::updateClipScissorTest()
if (bounds == QRect(0, 0, width, height)) {
glDisable(GL_SCISSOR_TEST);
} else {
+ bounds = QRect(bounds.x(), bounds.y(), bounds.width(), bounds.height());
glEnable(GL_SCISSOR_TEST);
setScissor(bounds);
}
@@ -2117,14 +2121,14 @@ void QOpenGL2PaintEngineExPrivate::updateClipScissorTest()
void QOpenGL2PaintEngineExPrivate::setScissor(const QRect &rect)
{
- const int left = rect.left();
+ const int left = rect.left() + x;
const int width = rect.width();
int bottom = height - (rect.top() + rect.height());
if (device->paintFlipped()) {
bottom = rect.top();
}
+ bottom += y;
const int height = rect.height();
-
glScissor(left, bottom, width, height);
}
diff --git a/src/gui/opengl/qopenglpaintengine_p.h b/src/gui/opengl/qopenglpaintengine_p.h
index d51f0e5..0d4b38d 100644
--- a/src/gui/opengl/qopenglpaintengine_p.h
+++ b/src/gui/opengl/qopenglpaintengine_p.h
@@ -264,6 +264,7 @@ public:
QOpenGL2PaintEngineEx* q;
QOpenGLEngineShaderManager* shaderManager;
QOpenGLPaintDevice* device;
+ int x, y;
int width, height;
QOpenGLContext *ctx;
EngineMode mode;
diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp
index 83f4075..ec29900 100644
--- a/src/gui/opengl/qopengltextureglyphcache.cpp
+++ b/src/gui/opengl/qopengltextureglyphcache.cpp
@@ -268,7 +268,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
funcs.glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_func()->current_fbo);
if (pex != 0) {
- glViewport(0, 0, pex->width, pex->height);
+ glViewport(pex->x, pex->y, pex->width, pex->height);
pex->updateClipScissorTest();
} else {
m_blitProgram->disableAttributeArray(int(QT_VERTEX_COORDS_ATTR));
--
1.7.9.5

View File

@ -0,0 +1,48 @@
From dd2a427857612798071d3f8c23286322654669d6 Mon Sep 17 00:00:00 2001
From: Valery Volgutov <valery.volgutov@lge.com>
Date: Tue, 21 May 2013 12:02:19 -0700
Subject: [PATCH] Fix FBO restoring in QOpenGLTextureGlyphCache
QOpenGLTextureGlyphCache::restoreTextureData restores FBO which
was binded before restoreTextureData call. More specifically,
it restores QOpenGLContextPrivate's current_fbo member. This works
if FBO was binded by QOpenGLFramebufferObject but not if FBO was
binded using glBindFramebufferObject and rendering done via
QOpenGLPaintDevice.
This patch fixes it by querying current FBO using
GL_FRAMEBUFFER_BINDING query and restoring it.
Upstream-Status: Backport
https://codereview.qt-project.org/#change,56608
---
src/gui/opengl/qopengltextureglyphcache.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp
index 4e20f6a..3e66bad 100644
--- a/src/gui/opengl/qopengltextureglyphcache.cpp
+++ b/src/gui/opengl/qopengltextureglyphcache.cpp
@@ -147,6 +147,9 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
return;
}
+ GLuint saveFbo;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &saveFbo);
+
int oldWidth = m_textureResource->m_width;
int oldHeight = m_textureResource->m_height;
@@ -265,7 +268,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
glDeleteTextures(1, &tmp_texture);
glDeleteTextures(1, &oldTexture);
- funcs.glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_func()->current_fbo);
+ funcs.glBindFramebuffer(GL_FRAMEBUFFER, saveFbo);
if (pex != 0) {
glViewport(0, 0, pex->width, pex->height);
--
1.7.9.5

View File

@ -0,0 +1,39 @@
From 9108a53309ae584d6622881b418742a9213cb9f1 Mon Sep 17 00:00:00 2001
From: Jani Hautakangas <jani.hautakangas@ixonos.com>
Date: Mon, 27 May 2013 15:25:25 -0700
Subject: [PATCH] Use BGRA extension in bindTexture
Upstream-Status: Pending
Change-Id: I18aecc87c5c7d4483cabe5555da33ca6bb8580f1
---
src/gui/opengl/qopengltexturecache.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/gui/opengl/qopengltexturecache.cpp b/src/gui/opengl/qopengltexturecache.cpp
index 05e9bd4..a268f23 100644
--- a/src/gui/opengl/qopengltexturecache.cpp
+++ b/src/gui/opengl/qopengltexturecache.cpp
@@ -171,7 +171,7 @@ static inline void qgl_byteSwapImage(QImage &img)
}
}
}
-
+#include <QDebug>
GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, qint64 key, const QImage &image)
{
GLuint id;
@@ -180,9 +180,7 @@ GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, qint64 key, con
QImage tx = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- qgl_byteSwapImage(tx);
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tx.width(), tx.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, const_cast<const QImage &>(tx).bits());
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, tx.width(), tx.height(), 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, const_cast<const QImage &>(tx).bits());
int cost = tx.width() * tx.height() * 4 / 1024;
m_cache.insert(key, new QOpenGLCachedTexture(id, context), cost);
--
1.7.9.5

View File

@ -0,0 +1,152 @@
From 2efd051d3093ee4e4091a8947f28d9bd528f2e9e Mon Sep 17 00:00:00 2001
From: Jani Hautakangas <jani.hautakangas@ixonos.com>
Date: Thu, 16 May 2013 09:52:07 +0300
Subject: [PATCH] QOpenGLPaintDevice sub-area support
Allows creating QOpenGLPaintDevice targetting sub-area
of binded framebuffer.
Upstream-Status: Pending
Change-Id: Ida2f079aa1ac0b87d36b54129e226399dbcdda80
---
src/gui/opengl/qopenglpaintdevice.cpp | 12 ++++++++++++
src/gui/opengl/qopenglpaintdevice.h | 2 ++
src/gui/opengl/qopenglpaintengine.cpp | 10 +++++++---
src/gui/opengl/qopenglpaintengine_p.h | 1 +
src/gui/opengl/qopengltextureglyphcache.cpp | 2 +-
5 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp
index f0e7e49..fe9a30c 100644
--- a/src/gui/opengl/qopenglpaintdevice.cpp
+++ b/src/gui/opengl/qopenglpaintdevice.cpp
@@ -111,6 +111,7 @@ class QOpenGLPaintDevicePrivate
public:
QOpenGLPaintDevicePrivate(const QSize &size);
+ QPoint offset;
QSize size;
QOpenGLContext *ctx;
@@ -159,6 +160,12 @@ QOpenGLPaintDevice::QOpenGLPaintDevice(int width, int height)
{
}
+QOpenGLPaintDevice::QOpenGLPaintDevice(int x, int y, int width, int height)
+ : d_ptr(new QOpenGLPaintDevicePrivate(QSize(width, height)))
+{
+ d_ptr->offset = QPoint(x,y);
+}
+
/*!
Destroys the QOpenGLPaintDevice.
*/
@@ -228,6 +235,11 @@ QOpenGLContext *QOpenGLPaintDevice::context() const
return d_ptr->ctx;
}
+QPoint QOpenGLPaintDevice::offset() const
+{
+ return d_ptr->offset;
+}
+
/*!
Returns the pixel size of the paint device.
diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h
index c05571c..01eb1bc 100644
--- a/src/gui/opengl/qopenglpaintdevice.h
+++ b/src/gui/opengl/qopenglpaintdevice.h
@@ -62,12 +62,14 @@ public:
QOpenGLPaintDevice();
explicit QOpenGLPaintDevice(const QSize &size);
QOpenGLPaintDevice(int width, int height);
+ QOpenGLPaintDevice(int x, int y, int width, int height);
virtual ~QOpenGLPaintDevice();
int devType() const { return QInternal::OpenGL; }
QPaintEngine *paintEngine() const;
QOpenGLContext *context() const;
+ QPoint offset() const;
QSize size() const;
void setSize(const QSize &size);
void setDevicePixelRatio(qreal devicePixelRatio);
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
index 0782e42..52afc60 100644
--- a/src/gui/opengl/qopenglpaintengine.cpp
+++ b/src/gui/opengl/qopenglpaintengine.cpp
@@ -1978,7 +1978,10 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev)
for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
d->vertexAttributeArraysEnabledState[i] = false;
+ const QPoint offset = d->device->offset();
const QSize sz = d->device->size();
+ d->x = offset.x();
+ d->y = offset.y();
d->width = sz.width();
d->height = sz.height();
d->mode = BrushDrawingMode;
@@ -2066,7 +2069,7 @@ void QOpenGL2PaintEngineEx::ensureActive()
d->device->ensureActiveTarget();
d->transferMode(BrushDrawingMode);
- glViewport(0, 0, d->width, d->height);
+ glViewport(d->x, d->y, d->width, d->height);
d->needsSync = false;
d->lastMaskTextureUsed = 0;
d->shaderManager->setDirty();
@@ -2109,6 +2112,7 @@ void QOpenGL2PaintEngineExPrivate::updateClipScissorTest()
if (bounds == QRect(0, 0, width, height)) {
glDisable(GL_SCISSOR_TEST);
} else {
+ bounds = QRect(bounds.x(), bounds.y(), bounds.width(), bounds.height());
glEnable(GL_SCISSOR_TEST);
setScissor(bounds);
}
@@ -2117,14 +2121,14 @@ void QOpenGL2PaintEngineExPrivate::updateClipScissorTest()
void QOpenGL2PaintEngineExPrivate::setScissor(const QRect &rect)
{
- const int left = rect.left();
+ const int left = rect.left() + x;
const int width = rect.width();
int bottom = height - (rect.top() + rect.height());
if (device->paintFlipped()) {
bottom = rect.top();
}
+ bottom += y;
const int height = rect.height();
-
glScissor(left, bottom, width, height);
}
diff --git a/src/gui/opengl/qopenglpaintengine_p.h b/src/gui/opengl/qopenglpaintengine_p.h
index d51f0e5..0d4b38d 100644
--- a/src/gui/opengl/qopenglpaintengine_p.h
+++ b/src/gui/opengl/qopenglpaintengine_p.h
@@ -264,6 +264,7 @@ public:
QOpenGL2PaintEngineEx* q;
QOpenGLEngineShaderManager* shaderManager;
QOpenGLPaintDevice* device;
+ int x, y;
int width, height;
QOpenGLContext *ctx;
EngineMode mode;
diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp
index 83f4075..ec29900 100644
--- a/src/gui/opengl/qopengltextureglyphcache.cpp
+++ b/src/gui/opengl/qopengltextureglyphcache.cpp
@@ -268,7 +268,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
funcs.glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_func()->current_fbo);
if (pex != 0) {
- glViewport(0, 0, pex->width, pex->height);
+ glViewport(pex->x, pex->y, pex->width, pex->height);
pex->updateClipScissorTest();
} else {
m_blitProgram->disableAttributeArray(int(QT_VERTEX_COORDS_ATTR));
--
1.7.9.5

View File

@ -0,0 +1,48 @@
From dd2a427857612798071d3f8c23286322654669d6 Mon Sep 17 00:00:00 2001
From: Valery Volgutov <valery.volgutov@lge.com>
Date: Tue, 21 May 2013 12:02:19 -0700
Subject: [PATCH] Fix FBO restoring in QOpenGLTextureGlyphCache
QOpenGLTextureGlyphCache::restoreTextureData restores FBO which
was binded before restoreTextureData call. More specifically,
it restores QOpenGLContextPrivate's current_fbo member. This works
if FBO was binded by QOpenGLFramebufferObject but not if FBO was
binded using glBindFramebufferObject and rendering done via
QOpenGLPaintDevice.
This patch fixes it by querying current FBO using
GL_FRAMEBUFFER_BINDING query and restoring it.
Upstream-Status: Backport
https://codereview.qt-project.org/#change,56608
---
src/gui/opengl/qopengltextureglyphcache.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp
index 4e20f6a..3e66bad 100644
--- a/src/gui/opengl/qopengltextureglyphcache.cpp
+++ b/src/gui/opengl/qopengltextureglyphcache.cpp
@@ -147,6 +147,9 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
return;
}
+ GLuint saveFbo;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &saveFbo);
+
int oldWidth = m_textureResource->m_width;
int oldHeight = m_textureResource->m_height;
@@ -265,7 +268,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
glDeleteTextures(1, &tmp_texture);
glDeleteTextures(1, &oldTexture);
- funcs.glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_func()->current_fbo);
+ funcs.glBindFramebuffer(GL_FRAMEBUFFER, saveFbo);
if (pex != 0) {
glViewport(0, 0, pex->width, pex->height);
--
1.7.9.5

View File

@ -0,0 +1,31 @@
From 9108a53309ae584d6622881b418742a9213cb9f1 Mon Sep 17 00:00:00 2001
From: Jani Hautakangas <jani.hautakangas@ixonos.com>
Date: Mon, 27 May 2013 15:25:25 -0700
Subject: [PATCH] Use BGRA extension in bindTexture
Upstream-Status: Pending
Change-Id: I18aecc87c5c7d4483cabe5555da33ca6bb8580f1
---
src/gui/opengl/qopengltexturecache.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/gui/opengl/qopengltexturecache.cpp b/src/gui/opengl/qopengltexturecache.cpp
index 94b8288..45aad1f 100644
--- a/src/gui/opengl/qopengltexturecache.cpp
+++ b/src/gui/opengl/qopengltexturecache.cpp
@@ -181,11 +181,7 @@ GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, qint64 key, con
QImage tx = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- // Performance could be improved by skipping qgl_byteSwapImage().
- if (m_useByteSwapImage)
- qgl_byteSwapImage(tx);
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tx.width(), tx.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, const_cast<const QImage &>(tx).bits());
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, tx.width(), tx.height(), 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, const_cast<const QImage &>(tx).bits());
int cost = tx.width() * tx.height() * 4 / 1024;
m_cache.insert(key, new QOpenGLCachedTexture(id, context), cost);
--
1.7.9.5

View File

@ -16,6 +16,9 @@ SRC_URI += " \
file://0013-Disable-mkv8snapshot.patch \
file://0014-enables-tslib-device-to-be-read-from-env-variable.patch \
file://0015-qtbase-allow-build-of-examples.patch \
file://0018-QOpenGLPaintDevice-sub-area-support.patch \
file://0019-Fix-FBO-restoring-in-QOpenGLTextureGlyphCache.patch \
file://0020-Use-BGRA-extension-in-bindTexture.patch \
"
DEPENDS += "qtbase-native freetype jpeg libpng zlib openssl glib-2.0 ${ICU} udev ${XCB_DEPENDS} ${GL_DEPENDS} ${TSLIB_DEPENDS}"
@ -86,7 +89,7 @@ QT_CONFIG_FLAGS += " \
${QT_TSLIB} \
"
INC_PR = "r1"
INC_PR = "r2"
# Qt uses atomic instructions not supported in thumb mode
ARM_INSTRUCTION_SET = "arm"