summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/graphicsview/padnavigator/form.ui208
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp30
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h2
-rw-r--r--src/opengl/qgl.cpp3
-rw-r--r--src/opengl/qgl.h1
-rw-r--r--src/opengl/qgl_egl.cpp20
-rw-r--r--src/opengl/qgl_p.h8
-rw-r--r--src/opengl/qglpaintdevice.cpp5
8 files changed, 259 insertions, 18 deletions
diff --git a/examples/graphicsview/padnavigator/form.ui b/examples/graphicsview/padnavigator/form.ui
new file mode 100644
index 0000000..fc7d123
--- /dev/null
+++ b/examples/graphicsview/padnavigator/form.ui
@@ -0,0 +1,208 @@
+<ui version="4.0" >
+ <class>Form</class>
+ <widget class="QWidget" name="Form" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>378</width>
+ <height>385</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>BackSide</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <widget class="QGroupBox" name="groupBox" >
+ <property name="title" >
+ <string>Settings</string>
+ </property>
+ <property name="flat" >
+ <bool>true</bool>
+ </property>
+ <property name="checkable" >
+ <bool>true</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Title:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="hostName" >
+ <property name="text" >
+ <string>Pad Navigator Example</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>Modified:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string>Extent</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QSlider" name="horizontalSlider" >
+ <property name="value" >
+ <number>42</number>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinBox" >
+ <property name="value" >
+ <number>42</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QDateTimeEdit" name="dateTimeEdit" />
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2" >
+ <property name="title" >
+ <string>Other input</string>
+ </property>
+ <property name="flat" >
+ <bool>true</bool>
+ </property>
+ <property name="checkable" >
+ <bool>true</bool>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2" >
+ <item>
+ <widget class="QTreeWidget" name="treeWidget" >
+ <column>
+ <property name="text" >
+ <string>Widgets On Graphics View</string>
+ </property>
+ </column>
+ <item>
+ <property name="text" >
+ <string>QGraphicsProxyWidget</string>
+ </property>
+ <item>
+ <property name="text" >
+ <string>QGraphicsWidget</string>
+ </property>
+ <item>
+ <property name="text" >
+ <string>QObject</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>QGraphicsItem</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>QGraphicsLayoutItem</string>
+ </property>
+ </item>
+ </item>
+ </item>
+ <item>
+ <property name="text" >
+ <string>QGraphicsGridLayout</string>
+ </property>
+ <item>
+ <property name="text" >
+ <string>QGraphicsLayout</string>
+ </property>
+ <item>
+ <property name="text" >
+ <string>QGraphicsLayoutItem</string>
+ </property>
+ </item>
+ </item>
+ </item>
+ <item>
+ <property name="text" >
+ <string>QGraphicsLinearLayout</string>
+ </property>
+ <item>
+ <property name="text" >
+ <string>QGraphicsLayout</string>
+ </property>
+ <item>
+ <property name="text" >
+ <string>QGraphicsLayoutItem</string>
+ </property>
+ </item>
+ </item>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <tabstops>
+ <tabstop>groupBox</tabstop>
+ <tabstop>hostName</tabstop>
+ <tabstop>dateTimeEdit</tabstop>
+ <tabstop>horizontalSlider</tabstop>
+ <tabstop>spinBox</tabstop>
+ <tabstop>groupBox_2</tabstop>
+ <tabstop>treeWidget</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>horizontalSlider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>spinBox</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>184</x>
+ <y>125</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>275</x>
+ <y>127</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>spinBox</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>horizontalSlider</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>272</x>
+ <y>114</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>190</x>
+ <y>126</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
index 452d37d..410cf21 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
@@ -57,21 +57,13 @@ QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyph
, ctx(context)
, m_width(0)
, m_height(0)
- , m_broken_fbo_readback(false)
{
// broken FBO readback is a bug in the SGX 1.3 and 1.4 drivers for the N900 where
// copying between FBO's is broken if the texture is either GL_ALPHA or POT. The
// workaround is to use a system-memory copy of the glyph cache for this device.
// Switching to NPOT and GL_RGBA would both cost a lot more graphics memory and
// be slower, so that is not desireable.
-#if defined QT_OPENGL_ES_2 && !defined(QT_NO_EGL)
- if (QByteArray((char*) glGetString(GL_RENDERER)).contains("SGX")) {
- QGLContextPrivate *ctxd = context->d_func();
- m_broken_fbo_readback = QByteArray((char *) eglQueryString(ctxd->eglContext->display(), EGL_VERSION)).contains("1.3");
- }
-#endif
-
- if (!m_broken_fbo_readback)
+ if (!ctx->d_ptr->workaround_brokenFBOReadBack)
glGenFramebuffers(1, &m_fbo);
connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)),
@@ -83,7 +75,7 @@ QGLTextureGlyphCache::~QGLTextureGlyphCache()
if (ctx) {
QGLShareContextScope scope(ctx);
- if (!m_broken_fbo_readback)
+ if (!ctx->d_ptr->workaround_brokenFBOReadBack)
glDeleteFramebuffers(1, &m_fbo);
if (m_width || m_height)
@@ -96,9 +88,15 @@ void QGLTextureGlyphCache::createTextureData(int width, int height)
// create in QImageTextureGlyphCache baseclass is meant to be called
// only to create the initial image and does not preserve the content,
// so we don't call when this function is called from resize.
- if (m_broken_fbo_readback && image().isNull())
+ if (ctx->d_ptr->workaround_brokenFBOReadBack && image().isNull())
QImageTextureGlyphCache::createTextureData(width, height);
+ // Make the lower glyph texture size 16 x 16.
+ if (width < 16)
+ width = 16;
+ if (height < 16)
+ height = 16;
+
glGenTextures(1, &m_texture);
glBindTexture(GL_TEXTURE_2D, m_texture);
@@ -123,10 +121,16 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
int oldWidth = m_width;
int oldHeight = m_height;
+ // Make the lower glyph texture size 16 x 16.
+ if (width < 16)
+ width = 16;
+ if (height < 16)
+ height = 16;
+
GLuint oldTexture = m_texture;
createTextureData(width, height);
- if (m_broken_fbo_readback) {
+ if (ctx->d_ptr->workaround_brokenFBOReadBack) {
QImageTextureGlyphCache::resizeTextureData(width, height);
Q_ASSERT(image().depth() == 8);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, image().constBits());
@@ -209,7 +213,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph)
{
- if (m_broken_fbo_readback) {
+ if (ctx->d_ptr->workaround_brokenFBOReadBack) {
QImageTextureGlyphCache::fillTexture(c, glyph);
glBindTexture(GL_TEXTURE_2D, m_texture);
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
index efb7435..6bcd655 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
@@ -115,8 +115,6 @@ private:
int m_height;
QGLShaderProgram *m_program;
-
- bool m_broken_fbo_readback;
};
QT_END_NAMESPACE
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 7c457de..922a96c 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1612,6 +1612,9 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
current_fbo = 0;
default_fbo = 0;
active_engine = 0;
+ workaround_needsFullClearOnEveryFrame = false;
+ workaround_brokenFBOReadBack = false;
+ workaroundsCached = false;
for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
vertexAttributeArraysEnabledState[i] = false;
}
diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h
index 92a064f..f297009 100644
--- a/src/opengl/qgl.h
+++ b/src/opengl/qgl.h
@@ -431,6 +431,7 @@ private:
friend class QGLFramebufferObjectPrivate;
friend class QGLFBOGLPaintDevice;
friend class QGLPaintDevice;
+ friend class QGLWidgetGLPaintDevice;
friend class QX11GLPixmapData;
friend class QX11GLSharedContexts;
private:
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index 0fbbbf9..44e8ae9 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -185,8 +185,26 @@ void QGLContext::makeCurrent()
return;
}
- if (d->eglContext->makeCurrent(d->eglSurfaceForDevice()))
+ if (d->eglContext->makeCurrent(d->eglSurfaceForDevice())) {
QGLContextPrivate::setCurrentContext(this);
+ if (!d->workaroundsCached) {
+ d->workaroundsCached = true;
+ const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
+ if (strstr(renderer, "SGX") || strstr(renderer, "MBX")) {
+ // PowerVR MBX/SGX chips needs to clear all buffers when starting to render
+ // a new frame, otherwise there will be a performance penalty to pay for
+ // each frame.
+ d->workaround_needsFullClearOnEveryFrame = true;
+
+ // Older PowerVR SGX drivers (like the one in the N900) have a
+ // bug which prevents glCopyTexSubImage2D() to work with a POT
+ // or GL_ALPHA texture bound to an FBO. The only way to
+ // identify that driver is to check the EGL version number for it.
+ if (strstr(eglQueryString(d->eglContext->display(), EGL_VERSION), "1.3"))
+ d->workaround_brokenFBOReadBack = true;
+ }
+ }
+ }
}
void QGLContext::doneCurrent()
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index f19e394..d92f963 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -345,7 +345,7 @@ public:
HDC hbitmap_hdc;
#endif
#ifndef QT_NO_EGL
- bool ownsEglContext;
+ uint ownsEglContext : 1;
QEglContext *eglContext;
EGLSurface eglSurface;
void destroyEglSurfaceForDevice();
@@ -382,6 +382,12 @@ public:
uint internal_context : 1;
uint version_flags_cached : 1;
uint extension_flags_cached : 1;
+
+ // workarounds for driver/hw bugs on different platforms
+ uint workaround_needsFullClearOnEveryFrame : 1;
+ uint workaround_brokenFBOReadBack : 1;
+ uint workaroundsCached : 1;
+
QPaintDevice *paintDevice;
QColor transpColor;
QGLContext *q_ptr;
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index e874e85..e1dcbfd 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -175,7 +175,10 @@ void QGLWidgetGLPaintDevice::beginPaint()
float alpha = c.alphaF();
glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha);
}
- glClear(GL_COLOR_BUFFER_BIT);
+ if (context()->d_func()->workaround_needsFullClearOnEveryFrame)
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+ else
+ glClear(GL_COLOR_BUFFER_BIT);
}
}