summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorFrans Englich <frans.englich@nokia.com>2009-10-15 08:58:59 (GMT)
committerFrans Englich <frans.englich@nokia.com>2009-10-15 08:58:59 (GMT)
commitd245034a54d20a3ff59575158dbf8705547648a7 (patch)
tree6fdbf2718e6613e8af60b0fa4e77ba9b1f41660a /src/opengl
parent16dab236acbd35c351c1ac1d36dbf018db0d278c (diff)
parent376a5a845ba6d19751a58ea79a8d5701c4ba4d13 (diff)
downloadQt-d245034a54d20a3ff59575158dbf8705547648a7.zip
Qt-d245034a54d20a3ff59575158dbf8705547648a7.tar.gz
Qt-d245034a54d20a3ff59575158dbf8705547648a7.tar.bz2
Merge commit 'origin/4.6' into mmfphonon
Conflicts: src/corelib/kernel/qcoreevent.cpp src/corelib/kernel/qcoreevent.h
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp37
-rw-r--r--src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h5
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp100
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h4
-rw-r--r--src/opengl/qgl.cpp42
-rw-r--r--src/opengl/qgl_egl.cpp2
-rw-r--r--src/opengl/qgl_p.h4
-rw-r--r--src/opengl/qglframebufferobject.cpp6
-rw-r--r--src/opengl/qglframebufferobject_p.h2
-rw-r--r--src/opengl/qglpaintdevice_qws.cpp13
-rw-r--r--src/opengl/qglpixelbuffer_egl.cpp15
-rw-r--r--src/opengl/qwindowsurface_gl.cpp14
12 files changed, 147 insertions, 97 deletions
diff --git a/src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp b/src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp
index 866d1a2..1fe3999 100644
--- a/src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp
+++ b/src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp
@@ -67,7 +67,30 @@ void QGL2PEXVertexArray::addRect(const QRectF &rect)
<< rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
}
-void QGL2PEXVertexArray::addPath(const QVectorPath &path, GLfloat curveInverseScale)
+void QGL2PEXVertexArray::addClosingLine(int index)
+{
+ if (QPointF(vertexArray.at(index)) != QPointF(vertexArray.last()))
+ vertexArray.add(vertexArray.at(index));
+}
+
+void QGL2PEXVertexArray::addCentroid(const QVectorPath &path, int subPathIndex)
+{
+ const QPointF *const points = reinterpret_cast<const QPointF *>(path.points());
+ const QPainterPath::ElementType *const elements = path.elements();
+
+ QPointF sum = points[subPathIndex];
+ int count = 1;
+
+ for (int i = subPathIndex + 1; i < path.elementCount() && (!elements || elements[i] != QPainterPath::MoveToElement); ++i) {
+ sum += points[i];
+ ++count;
+ }
+
+ const QPointF centroid = sum / qreal(count);
+ vertexArray.add(centroid);
+}
+
+void QGL2PEXVertexArray::addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline)
{
const QPointF* const points = reinterpret_cast<const QPointF*>(path.points());
const QPainterPath::ElementType* const elements = path.elements();
@@ -78,6 +101,10 @@ void QGL2PEXVertexArray::addPath(const QVectorPath &path, GLfloat curveInverseSc
boundingRectDirty = false;
}
+ if (!outline)
+ addCentroid(path, 0);
+
+ int lastMoveTo = vertexArray.size();
vertexArray.add(points[0]); // The first element is always a moveTo
do {
@@ -96,8 +123,14 @@ void QGL2PEXVertexArray::addPath(const QVectorPath &path, GLfloat curveInverseSc
const QPainterPath::ElementType elementType = elements[i];
switch (elementType) {
case QPainterPath::MoveToElement:
+ if (!outline)
+ addClosingLine(lastMoveTo);
// qDebug("element[%d] is a MoveToElement", i);
vertexArrayStops.append(vertexArray.size());
+ if (!outline) {
+ addCentroid(path, i);
+ lastMoveTo = vertexArray.size();
+ }
lineToArray(points[i].x(), points[i].y()); // Add the moveTo as a new vertex
break;
case QPainterPath::LineToElement:
@@ -115,6 +148,8 @@ void QGL2PEXVertexArray::addPath(const QVectorPath &path, GLfloat curveInverseSc
}
} while (0);
+ if (!outline)
+ addClosingLine(lastMoveTo);
vertexArrayStops.append(vertexArray.size());
}
diff --git a/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h b/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h
index 08ce234..719904f 100644
--- a/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h
+++ b/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h
@@ -104,7 +104,7 @@ public:
boundingRectDirty(true) {}
void addRect(const QRectF &rect);
- void addPath(const QVectorPath &path, GLfloat curveInverseScale);
+ void addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline = true);
void clear();
QGLPoint* data() {return vertexArray.data();}
@@ -124,6 +124,9 @@ private:
bool boundingRectDirty;
inline void curveToArray(const QGLPoint &cp1, const QGLPoint &cp2, const QGLPoint &ep, GLfloat inverseScale);
+
+ void addClosingLine(int index);
+ void addCentroid(const QVectorPath &path, int subPathIndex);
};
QT_END_NAMESPACE
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 5875124..8130151 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -391,7 +391,6 @@ void QGL2PaintEngineExPrivate::setBrush(const QBrush* brush)
}
-// Unless this gets used elsewhere, it's probably best to merge it into fillStencilWithVertexArray
void QGL2PaintEngineExPrivate::useSimpleShader()
{
shaderManager->simpleProgram()->enable();
@@ -881,26 +880,36 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
|| path.shape() == QVectorPath::ConvexPolygonHint)
{
vertexCoordinateArray.clear();
- vertexCoordinateArray.addPath(path, inverseScale);
+ vertexCoordinateArray.addPath(path, inverseScale, false);
prepareForDraw(currentBrush->isOpaque());
drawVertexArrays(vertexCoordinateArray, GL_TRIANGLE_FAN);
} else {
// The path is too complicated & needs the stencil technique
vertexCoordinateArray.clear();
- vertexCoordinateArray.addPath(path, inverseScale);
+ vertexCoordinateArray.addPath(path, inverseScale, false);
fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill());
- // Stencil the brush onto the dest buffer
- glStencilFunc(GL_EQUAL, GL_STENCIL_HIGH_BIT, GL_STENCIL_HIGH_BIT); // Pass if stencil buff value != 0
- glStencilOp(GL_KEEP, GL_ZERO, GL_ZERO);
- glStencilMask(GL_STENCIL_HIGH_BIT);
+ glStencilMask(0xff);
+ glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
+
+ if (q->state()->clipTestEnabled) {
+ // Pass when high bit is set, replace stencil value with current clip
+ glStencilFunc(GL_NOTEQUAL, q->state()->currentClip, GL_STENCIL_HIGH_BIT);
+ } else if (path.hasWindingFill()) {
+ // Pass when any bit is set, replace stencil value with 0
+ glStencilFunc(GL_NOTEQUAL, 0, 0xff);
+ } else {
+ // Pass when high bit is set, replace stencil value with 0
+ glStencilFunc(GL_NOTEQUAL, 0, GL_STENCIL_HIGH_BIT);
+ }
prepareForDraw(currentBrush->isOpaque());
if (inRenderText)
prepareDepthRangeForRenderText();
+ // Stencil the brush onto the dest buffer
composite(vertexCoordinateArray.boundingRect());
if (inRenderText)
@@ -916,7 +925,7 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(QGL2PEXVertexArray& vertexArray, bool useWindingFill)
{
// qDebug("QGL2PaintEngineExPrivate::fillStencilWithVertexArray()");
- glStencilMask(0xffff); // Enable stencil writes
+ glStencilMask(0xff); // Enable stencil writes
if (dirtyStencilRegion.intersects(currentScissorBounds)) {
QVector<QRect> clearRegion = dirtyStencilRegion.intersected(currentScissorBounds).rects();
@@ -948,39 +957,30 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(QGL2PEXVertexArray& ve
if (useWindingFill) {
if (q->state()->clipTestEnabled) {
+ // Flatten clip values higher than current clip, and set high bit to match current clip
glStencilFunc(GL_LEQUAL, GL_STENCIL_HIGH_BIT | q->state()->currentClip, ~GL_STENCIL_HIGH_BIT);
glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
composite(vertexArray.boundingRect());
glStencilFunc(GL_EQUAL, GL_STENCIL_HIGH_BIT, GL_STENCIL_HIGH_BIT);
- } else {
- glStencilFunc(GL_ALWAYS, 0, 0xffff);
+ } else if (!stencilClean) {
+ // Clear stencil buffer within bounding rect
+ glStencilFunc(GL_ALWAYS, 0, 0xff);
glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);
composite(vertexArray.boundingRect());
}
// Inc. for front-facing triangle
glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_INCR_WRAP, GL_INCR_WRAP);
- //Dec. for back-facing "holes"
+ // Dec. for back-facing "holes"
glStencilOpSeparate(GL_BACK, GL_KEEP, GL_DECR_WRAP, GL_DECR_WRAP);
glStencilMask(~GL_STENCIL_HIGH_BIT);
drawVertexArrays(vertexArray, GL_TRIANGLE_FAN);
if (q->state()->clipTestEnabled) {
- // clear high bit of stencil outside of path
- glStencilFunc(GL_EQUAL, GL_STENCIL_HIGH_BIT | q->state()->currentClip, ~GL_STENCIL_HIGH_BIT);
- glStencilOp(GL_KEEP, GL_INVERT, GL_INVERT);
- glStencilMask(GL_STENCIL_HIGH_BIT);
- composite(vertexArray.boundingRect());
- // reset lower bits of stencil inside path to current clip
- glStencilFunc(GL_EQUAL, GL_STENCIL_HIGH_BIT | q->state()->currentClip, GL_STENCIL_HIGH_BIT);
+ // Clear high bit of stencil outside of path
+ glStencilFunc(GL_EQUAL, q->state()->currentClip, ~GL_STENCIL_HIGH_BIT);
glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
- glStencilMask(~GL_STENCIL_HIGH_BIT);
- composite(vertexArray.boundingRect());
- } else {
- // set high bit of stencil inside path
- glStencilFunc(GL_NOTEQUAL, 0, 0xffff);
- glStencilOp(GL_KEEP, GL_INVERT, GL_INVERT);
glStencilMask(GL_STENCIL_HIGH_BIT);
composite(vertexArray.boundingRect());
}
@@ -1020,7 +1020,7 @@ void QGL2PaintEngineExPrivate::resetClipIfNeeded()
QGLRect rect(bounds.left(), bounds.top(), bounds.right(), bounds.bottom());
// Set high bit on clip region
- glStencilFunc(GL_LEQUAL, q->state()->currentClip, 0xffff);
+ glStencilFunc(GL_LEQUAL, q->state()->currentClip, 0xff);
glStencilOp(GL_KEEP, GL_INVERT, GL_INVERT);
glStencilMask(GL_STENCIL_HIGH_BIT);
composite(rect);
@@ -1028,7 +1028,7 @@ void QGL2PaintEngineExPrivate::resetClipIfNeeded()
// Reset clipping to 1 and everything else to zero
glStencilFunc(GL_NOTEQUAL, 0x01, GL_STENCIL_HIGH_BIT);
glStencilOp(GL_ZERO, GL_REPLACE, GL_REPLACE);
- glStencilMask(0xFFFF);
+ glStencilMask(0xff);
composite(rect);
q->state()->currentClip = 1;
@@ -1625,7 +1625,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
const QSize sz = d->device->size();
d->width = sz.width();
d->height = sz.height();
- d->last_created_state = 0;
d->mode = BrushDrawingMode;
d->brushTextureDirty = true;
d->brushUniformsDirty = true;
@@ -1636,6 +1635,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
d->use_system_clip = !systemClip().isEmpty();
d->dirtyStencilRegion = QRect(0, 0, d->width, d->height);
+ d->stencilClean = true;
// Calling begin paint should make the correct context current. So, any
// code which calls into GL or otherwise needs a current context *must*
@@ -1731,7 +1731,7 @@ void QGL2PaintEngineExPrivate::updateClipScissorTest()
glStencilFunc(GL_LEQUAL, q->state()->currentClip, ~GL_STENCIL_HIGH_BIT);
} else {
glDisable(GL_STENCIL_TEST);
- glStencilFunc(GL_ALWAYS, 0, 0xffff);
+ glStencilFunc(GL_ALWAYS, 0, 0xff);
}
#ifdef QT_GL_NO_SCISSOR_TEST
@@ -1787,7 +1787,7 @@ void QGL2PaintEngineExPrivate::clearClip(uint value)
{
dirtyStencilRegion -= currentScissorBounds;
- glStencilMask(0xffff);
+ glStencilMask(0xff);
glClearStencil(value);
glClear(GL_STENCIL_BUFFER_BIT);
glStencilMask(0x0);
@@ -1802,6 +1802,8 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint value)
if (matrixDirty)
updateMatrix();
+ stencilClean = false;
+
const bool singlePass = !path.hasWindingFill()
&& (((q->state()->currentClip == maxClip - 1) && q->state()->clipTestEnabled)
|| q->state()->needsClipBufferClear);
@@ -1819,10 +1821,10 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint value)
if (q->state()->clipTestEnabled)
glStencilFunc(GL_LEQUAL, q->state()->currentClip, ~GL_STENCIL_HIGH_BIT);
else
- glStencilFunc(GL_ALWAYS, 0, 0xffff);
+ glStencilFunc(GL_ALWAYS, 0, 0xff);
vertexCoordinateArray.clear();
- vertexCoordinateArray.addPath(path, inverseScale);
+ vertexCoordinateArray.addPath(path, inverseScale, false);
if (!singlePass)
fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill());
@@ -1841,9 +1843,17 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint value)
drawVertexArrays(vertexCoordinateArray, GL_TRIANGLE_FAN);
} else {
- glStencilFunc(GL_NOTEQUAL, value, GL_STENCIL_HIGH_BIT);
glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);
- glStencilMask(0xffff);
+ glStencilMask(0xff);
+
+ if (!q->state()->clipTestEnabled && path.hasWindingFill()) {
+ // Pass when any clip bit is set, set high bit
+ glStencilFunc(GL_NOTEQUAL, GL_STENCIL_HIGH_BIT, ~GL_STENCIL_HIGH_BIT);
+ composite(vertexCoordinateArray.boundingRect());
+ }
+
+ // Pass when high bit is set, replace stencil value with new clip value
+ glStencilFunc(GL_NOTEQUAL, value, GL_STENCIL_HIGH_BIT);
composite(vertexCoordinateArray.boundingRect());
}
@@ -2012,27 +2022,32 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state)
QPaintEngineEx::setState(s);
- if (s == d->last_created_state) {
- d->last_created_state = 0;
+ if (s->isNew) {
+ // Newly created state object. The call to setState()
+ // will either be followed by a call to begin(), or we are
+ // setting the state as part of a save().
+ s->isNew = false;
return;
}
- if (old_state == s || s->renderHintsChanged)
+ // Setting the state as part of a restore().
+
+ if (old_state == s || old_state->renderHintsChanged)
renderHintsChanged();
- if (old_state == s || s->matrixChanged) {
+ if (old_state == s || old_state->matrixChanged) {
d->matrixDirty = true;
d->simpleShaderMatrixUniformDirty = true;
d->shaderMatrixUniformDirty = true;
}
- if (old_state == s || s->compositionModeChanged)
+ if (old_state == s || old_state->compositionModeChanged)
d->compositionModeDirty = true;
- if (old_state == s || s->opacityChanged)
+ if (old_state == s || old_state->opacityChanged)
d->opacityUniformDirty = true;
- if (old_state == s || s->clipChanged) {
+ if (old_state == s || old_state->clipChanged) {
if (old_state && old_state != s && old_state->canRestoreClip) {
d->updateClipScissorTest();
glDepthFunc(GL_LEQUAL);
@@ -2044,8 +2059,6 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state)
QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const
{
- Q_D(const QGL2PaintEngineEx);
-
if (orig)
const_cast<QGL2PaintEngineEx *>(this)->ensureActive();
@@ -2061,7 +2074,6 @@ QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const
s->renderHintsChanged = false;
s->clipChanged = false;
- d->last_created_state = s;
return s;
}
@@ -2074,6 +2086,7 @@ void QGL2PaintEngineEx::setRenderTextActive(bool active)
QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState &other)
: QPainterState(other)
{
+ isNew = true;
needsClipBufferClear = other.needsClipBufferClear;
clipTestEnabled = other.clipTestEnabled;
currentClip = other.currentClip;
@@ -2083,6 +2096,7 @@ QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState &oth
QOpenGL2PaintEngineState::QOpenGL2PaintEngineState()
{
+ isNew = true;
needsClipBufferClear = true;
clipTestEnabled = false;
canRestoreClip = true;
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index 28c972e..5704a04 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -82,6 +82,7 @@ public:
QOpenGL2PaintEngineState();
~QOpenGL2PaintEngineState();
+ uint isNew : 1;
uint needsClipBufferClear : 1;
uint clipTestEnabled : 1;
uint canRestoreClip : 1;
@@ -212,8 +213,6 @@ public:
EngineMode mode;
QFontEngineGlyphCache::Type glyphCacheType;
- mutable QOpenGL2PaintEngineState *last_created_state;
-
// Dirty flags
bool matrixDirty; // Implies matrix uniforms are also dirty
bool compositionModeDirty;
@@ -223,6 +222,7 @@ public:
bool shaderMatrixUniformDirty;
bool opacityUniformDirty;
+ bool stencilClean; // Has the stencil not been used for clipping so far?
QRegion dirtyStencilRegion;
QRect currentScissorBounds;
uint maxClip;
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 3f96d1c..5e00b11 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -150,7 +150,25 @@ QGLSignalProxy *QGLSignalProxy::instance()
class QGLEngineSelector
{
public:
- QGLEngineSelector() : engineType(QPaintEngine::MaxUser) { }
+ QGLEngineSelector() : engineType(QPaintEngine::MaxUser)
+ {
+#ifdef Q_WS_MAC
+ // The ATI X1600 driver for Mac OS X does not support return
+ // values from functions in GLSL. Since working around this in
+ // the GL2 engine would require a big, ugly rewrite, we're
+ // falling back to the GL 1 engine..
+ QGLWidget *tmp = 0;
+ if (!QGLContext::currentContext()) {
+ tmp = new QGLWidget();
+ tmp->makeCurrent();
+ }
+ if (strstr((char *) glGetString(GL_RENDERER), "X1600"))
+ setPreferredPaintEngine(QPaintEngine::OpenGL);
+ if (tmp)
+ delete tmp;
+#endif
+
+ }
void setPreferredPaintEngine(QPaintEngine::Type type) {
if (type == QPaintEngine::OpenGL || type == QPaintEngine::OpenGL2)
@@ -4717,16 +4735,19 @@ Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_2_engine)
Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_engine)
#endif
-#ifdef Q_WS_QWS
Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine()
{
-#if !defined(QT_OPENGL_ES_2)
+#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL)
return qt_gl_engine();
+#elif defined(QT_OPENGL_ES_2)
+ return qt_gl_2_engine();
#else
- return 0; // XXX
+ if (qt_gl_preferGL2Engine())
+ return qt_gl_2_engine();
+ else
+ return qt_gl_engine();
#endif
}
-#endif
/*!
\internal
@@ -4736,16 +4757,7 @@ Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine()
*/
QPaintEngine *QGLWidget::paintEngine() const
{
-#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL)
- return qt_gl_engine();
-#elif defined(QT_OPENGL_ES_2)
- return qt_gl_2_engine();
-#else
- if (qt_gl_preferGL2Engine())
- return qt_gl_2_engine();
- else
- return qt_gl_engine();
-#endif
+ return qt_qgl_paint_engine();
}
#ifdef QT3_SUPPORT
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index fa876c7..fbf0349 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -75,7 +75,7 @@ void qt_egl_set_format(QEglProperties& props, int deviceType, const QGLFormat& f
props.setValue(EGL_STENCIL_SIZE, f.stencilBufferSize() == -1 ? 1 : f.stencilBufferSize());
if (f.sampleBuffers()) {
props.setValue(EGL_SAMPLE_BUFFERS, 1);
- props.setValue(EGL_SAMPLES, f.samples());
+ props.setValue(EGL_SAMPLES, f.samples() == -1 ? 1 : f.samples());
} else {
props.setValue(EGL_SAMPLE_BUFFERS, 0);
}
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 8d4f673..129e7f7 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -505,9 +505,7 @@ private:
};
-#ifdef Q_WS_QWS
-extern QPaintEngine* qt_qgl_paint_engine();
-#endif
+extern Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine();
bool qt_gl_preferGL2Engine();
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index 3e54b35..8fc95cf 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -451,6 +451,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
QT_CHECK_GLERROR();
valid = checkFramebufferStatus();
+ glBindTexture(target, 0);
color_buffer = 0;
} else {
@@ -819,7 +820,8 @@ QGLFramebufferObject::~QGLFramebufferObject()
if (isValid() && ctx) {
QGLShareContextScope scope(ctx);
- glDeleteTextures(1, &d->texture);
+ if (d->texture)
+ glDeleteTextures(1, &d->texture);
if (d->color_buffer)
glDeleteRenderbuffers(1, &d->color_buffer);
if (d->depth_stencil_buffer)
@@ -988,7 +990,7 @@ QImage QGLFramebufferObject::toImage() const
bool wasBound = isBound();
if (!wasBound)
const_cast<QGLFramebufferObject *>(this)->bind();
- QImage image = qt_gl_read_framebuffer(d->size, format().textureTarget() != GL_RGB, true);
+ QImage image = qt_gl_read_framebuffer(d->size, format().internalTextureFormat() != GL_RGB, true);
if (!wasBound)
const_cast<QGLFramebufferObject *>(this)->release();
diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h
index 055a752..9fe80b8 100644
--- a/src/opengl/qglframebufferobject_p.h
+++ b/src/opengl/qglframebufferobject_p.h
@@ -127,7 +127,7 @@ private:
class QGLFramebufferObjectPrivate
{
public:
- QGLFramebufferObjectPrivate() : fbo_guard(0), depth_stencil_buffer(0), valid(false), previous_fbo(0), engine(0) {}
+ QGLFramebufferObjectPrivate() : fbo_guard(0), texture(0), depth_stencil_buffer(0), color_buffer(0), valid(false), previous_fbo(0), engine(0) {}
~QGLFramebufferObjectPrivate() {}
void init(QGLFramebufferObject *q, const QSize& sz,
diff --git a/src/opengl/qglpaintdevice_qws.cpp b/src/opengl/qglpaintdevice_qws.cpp
index 600efa6..1512278 100644
--- a/src/opengl/qglpaintdevice_qws.cpp
+++ b/src/opengl/qglpaintdevice_qws.cpp
@@ -52,13 +52,6 @@ public:
QWidget *widget;
};
-class QMetricAccessor : public QWidget {
-public:
- int metric(PaintDeviceMetric m) {
- return QWidget::metric(m);
- }
-};
-
QWSGLPaintDevice::QWSGLPaintDevice(QWidget *widget) :
d_ptr(new QWSGLPaintDevicePrivate)
{
@@ -72,11 +65,7 @@ QWSGLPaintDevice::~QWSGLPaintDevice()
QPaintEngine* QWSGLPaintDevice::paintEngine() const
{
-#if !defined(QT_OPENGL_ES_2)
return qt_qgl_paint_engine();
-#else
- return 0; // XXX
-#endif
}
int QWSGLPaintDevice::metric(PaintDeviceMetric m) const
@@ -84,7 +73,7 @@ int QWSGLPaintDevice::metric(PaintDeviceMetric m) const
Q_D(const QWSGLPaintDevice);
Q_ASSERT(d->widget);
- return ((QMetricAccessor *) d->widget)->metric(m);
+ return qt_paint_device_metric(d->widget, m);
}
QWSGLWindowSurface* QWSGLPaintDevice::windowSurface() const
diff --git a/src/opengl/qglpixelbuffer_egl.cpp b/src/opengl/qglpixelbuffer_egl.cpp
index 4cba1bb..744fbd4 100644
--- a/src/opengl/qglpixelbuffer_egl.cpp
+++ b/src/opengl/qglpixelbuffer_egl.cpp
@@ -151,7 +151,7 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge
bool QGLPixelBufferPrivate::cleanup()
{
- eglDestroySurface(QEglContext::defaultDisplay(0), pbuf);
+ // No need to destroy "pbuf" here - it is done in QGLContext::reset().
return true;
}
@@ -202,13 +202,20 @@ GLuint QGLPixelBuffer::generateDynamicTexture() const
bool QGLPixelBuffer::hasOpenGLPbuffers()
{
// See if we have at least 1 configuration that matches the default format.
- QEglContext ctx;
- if (!ctx.openDisplay(0))
+ EGLDisplay dpy = QEglContext::defaultDisplay(0);
+ if (dpy == EGL_NO_DISPLAY)
return false;
QEglProperties configProps;
qt_egl_set_format(configProps, QInternal::Pbuffer, QGLFormat::defaultFormat());
configProps.setRenderableType(QEgl::OpenGL);
- return ctx.chooseConfig(configProps);
+ do {
+ EGLConfig cfg = 0;
+ EGLint matching = 0;
+ if (eglChooseConfig(dpy, configProps.properties(),
+ &cfg, 1, &matching) && matching > 0)
+ return true;
+ } while (configProps.reduceConfiguration());
+ return false;
}
QT_END_NAMESPACE
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 7f8577a..df84a76 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -280,22 +280,12 @@ QGLContext* QGLWindowSurfaceGLPaintDevice::context() const
int QGLWindowSurfaceGLPaintDevice::metric(PaintDeviceMetric m) const
{
- return d->q_ptr->window()->metric(m);
+ return qt_paint_device_metric(d->q_ptr->window(), m);
}
-Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_window_surface_2_engine)
-
-#if !defined (QT_OPENGL_ES_2)
-Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_window_surface_engine)
-#endif
-
QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
{
-#if !defined(QT_OPENGL_ES_2)
- if (!qt_gl_preferGL2Engine())
- return qt_gl_window_surface_engine();
-#endif
- return qt_gl_window_surface_2_engine();
+ return qt_qgl_paint_engine();
}
QGLWindowSurface::QGLWindowSurface(QWidget *window)