From f8b043f1d73906be593232cf02aa06e576ae4e27 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Sun, 6 Sep 2009 07:46:20 +1000 Subject: Fixed "multiple definition of `QTest::mouseActionNames'" error in projects where two separate compilation units include `qtestmouse.h'. --- src/testlib/qtestmouse.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h index bfa5c25..8b06a29 100644 --- a/src/testlib/qtestmouse.h +++ b/src/testlib/qtestmouse.h @@ -67,7 +67,6 @@ QT_MODULE(Test) namespace QTest { enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDClick, MouseMove }; - const char *mouseActionNames[] = { "MousePress", "MouseRelease", "MouseClick", "MouseDClick", "MouseMove" }; static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1) @@ -115,6 +114,8 @@ namespace QTest } QSpontaneKeyEvent::setSpontaneous(&me); if (!qApp->notify(widget, &me)) { + static const char *mouseActionNames[] = + { "MousePress", "MouseRelease", "MouseClick", "MouseDClick", "MouseMove" }; QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget"); QTest::qWarn(warning.arg(mouseActionNames[static_cast(action)]).toAscii().data()); } -- cgit v0.12 From 3f109fd85cbdc49dc3ef1c14066073079f4e34bf Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 7 Sep 2009 08:25:01 +1000 Subject: Make QGraphicsShaderEffect private API for 4.6 The custom shader code in the OpenGL2 paint engine needs time to mature before we make this official public API. Reviewed-by: trustme --- examples/effects/customshader/blureffect.cpp | 4 +- examples/effects/customshader/blureffect.h | 4 +- examples/effects/customshader/customshadereffect.h | 2 +- src/gui/effects/qgraphicseffect.cpp | 1 - src/opengl/opengl.pro | 2 +- src/opengl/qgraphicsshadereffect.cpp | 18 ++--- src/opengl/qgraphicsshadereffect.h | 83 ------------------- src/opengl/qgraphicsshadereffect_p.h | 94 ++++++++++++++++++++++ 8 files changed, 109 insertions(+), 99 deletions(-) delete mode 100644 src/opengl/qgraphicsshadereffect.h create mode 100644 src/opengl/qgraphicsshadereffect_p.h diff --git a/examples/effects/customshader/blureffect.cpp b/examples/effects/customshader/blureffect.cpp index 6fe8e86..f9e046e 100644 --- a/examples/effects/customshader/blureffect.cpp +++ b/examples/effects/customshader/blureffect.cpp @@ -56,10 +56,10 @@ void BlurEffect::adjustForItem() setBlurRadius(radius); } -QRectF BlurEffect::boundingRectFor(const QRectF &rect) const +QRectF BlurEffect::boundingRect() const { const_cast(this)->adjustForItem(); - return QGraphicsBlurEffect::boundingRectFor(rect); + return QGraphicsBlurEffect::boundingRect(); } void BlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source) diff --git a/examples/effects/customshader/blureffect.h b/examples/effects/customshader/blureffect.h index 0cafd80..7c12ccf 100644 --- a/examples/effects/customshader/blureffect.h +++ b/examples/effects/customshader/blureffect.h @@ -52,9 +52,9 @@ public: void setBaseLine(qreal y) { m_baseLine = y; } - QRectF boundingRectFor(const QRectF &) const; + QRectF boundingRect() const; - void draw(QPainter *painter, QGraphicsEffectSource*); + void draw(QPainter *painter, QGraphicsEffectSource *source); private: void adjustForItem(); diff --git a/examples/effects/customshader/customshadereffect.h b/examples/effects/customshader/customshadereffect.h index 9ba5f15..6892d96 100644 --- a/examples/effects/customshader/customshadereffect.h +++ b/examples/effects/customshader/customshadereffect.h @@ -43,7 +43,7 @@ #define CUSTOMSHADEREFFECT_H #include -#include +#include #include class CustomShaderEffect: public QGraphicsShaderEffect diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 6629a6d..dd64ced 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -67,7 +67,6 @@ \o QGraphicsOpacityEffect - renders the item with an opacity \o QGraphicsPixelizeEffect - pixelizes the item with any pixel size \o QGraphicsGrayscaleEffect - renders the item in shades of gray - \o QGraphicsShaderEffect - renders the item with a pixel shader fragment \endlist \img graphicseffect-effects.png diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 458aa7e..560d31f 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -38,7 +38,7 @@ SOURCES += qgl.cpp \ !contains(QT_CONFIG, opengles1):!contains(QT_CONFIG, opengles1cl) { HEADERS += qglshaderprogram.h \ qglpixmapfilter_p.h \ - qgraphicsshadereffect.h \ + qgraphicsshadereffect_p.h \ qgraphicssystem_gl_p.h \ qwindowsurface_gl_p.h \ qpixmapdata_gl_p.h \ diff --git a/src/opengl/qgraphicsshadereffect.cpp b/src/opengl/qgraphicsshadereffect.cpp index f1558d1..f733109 100644 --- a/src/opengl/qgraphicsshadereffect.cpp +++ b/src/opengl/qgraphicsshadereffect.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qgraphicsshadereffect.h" +#include "qgraphicsshadereffect_p.h" #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) #include "qglshaderprogram.h" #include "gl2paintengineex/qglcustomshaderstage_p.h" @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE -/*! +/*# \class QGraphicsShaderEffect \brief The QGraphicsShaderEffect class is the base class for creating custom GLSL shader effects in a QGraphicsScene. @@ -175,7 +175,7 @@ public: #endif }; -/*! +/*# Constructs a shader effect and attaches it to \a parent. */ QGraphicsShaderEffect::QGraphicsShaderEffect(QObject *parent) @@ -183,7 +183,7 @@ QGraphicsShaderEffect::QGraphicsShaderEffect(QObject *parent) { } -/*! +/*# Destroys this shader effect. */ QGraphicsShaderEffect::~QGraphicsShaderEffect() @@ -194,7 +194,7 @@ QGraphicsShaderEffect::~QGraphicsShaderEffect() #endif } -/*! +/*# Returns the source code for the pixel shader fragment for this shader effect. The default is a shader that copies its incoming pixmap directly to the output with no effect @@ -208,7 +208,7 @@ QByteArray QGraphicsShaderEffect::pixelShaderFragment() const return d->pixelShaderFragment; } -/*! +/*# Sets the source code for the pixel shader fragment for this shader effect to \a code. @@ -238,7 +238,7 @@ void QGraphicsShaderEffect::setPixelShaderFragment(const QByteArray& code) } } -/*! +/*# \reimp */ void QGraphicsShaderEffect::draw(QPainter *painter, QGraphicsEffectSource *source) @@ -277,7 +277,7 @@ void QGraphicsShaderEffect::draw(QPainter *painter, QGraphicsEffectSource *sourc #endif } -/*! +/*# Sets the custom uniform variables on this shader effect to be dirty. The setUniforms() function will be called the next time the shader program corresponding to this effect is used. @@ -296,7 +296,7 @@ void QGraphicsShaderEffect::setUniformsDirty() #endif } -/*! +/*# Sets custom uniform variables on the current GL context when \a program is about to be used by the paint engine. diff --git a/src/opengl/qgraphicsshadereffect.h b/src/opengl/qgraphicsshadereffect.h deleted file mode 100644 index a186074..0000000 --- a/src/opengl/qgraphicsshadereffect.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtOpenGL module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSHADEREFFECT_H -#define QGRAPHICSSHADEREFFECT_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(OpenGL) - -class QGLShaderProgram; -class QGLCustomShaderEffectStage; -class QGraphicsShaderEffectPrivate; - -class Q_OPENGL_EXPORT QGraphicsShaderEffect : public QGraphicsEffect -{ - Q_OBJECT -public: - QGraphicsShaderEffect(QObject *parent = 0); - virtual ~QGraphicsShaderEffect(); - - QByteArray pixelShaderFragment() const; - void setPixelShaderFragment(const QByteArray& code); - -protected: - void draw(QPainter *painter, QGraphicsEffectSource *source); - void setUniformsDirty(); - virtual void setUniforms(QGLShaderProgram *program); - -private: - Q_DECLARE_PRIVATE(QGraphicsShaderEffect) - Q_DISABLE_COPY(QGraphicsShaderEffect) - - friend class QGLCustomShaderEffectStage; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGRAPHICSSHADEREFFECT_H diff --git a/src/opengl/qgraphicsshadereffect_p.h b/src/opengl/qgraphicsshadereffect_p.h new file mode 100644 index 0000000..a313846 --- /dev/null +++ b/src/opengl/qgraphicsshadereffect_p.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSHADEREFFECT_P_H +#define QGRAPHICSSHADEREFFECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(OpenGL) + +class QGLShaderProgram; +class QGLCustomShaderEffectStage; +class QGraphicsShaderEffectPrivate; + +class Q_OPENGL_EXPORT QGraphicsShaderEffect : public QGraphicsEffect +{ + Q_OBJECT +public: + QGraphicsShaderEffect(QObject *parent = 0); + virtual ~QGraphicsShaderEffect(); + + QByteArray pixelShaderFragment() const; + void setPixelShaderFragment(const QByteArray& code); + +protected: + void draw(QPainter *painter, QGraphicsEffectSource *source); + void setUniformsDirty(); + virtual void setUniforms(QGLShaderProgram *program); + +private: + Q_DECLARE_PRIVATE(QGraphicsShaderEffect) + Q_DISABLE_COPY(QGraphicsShaderEffect) + + friend class QGLCustomShaderEffectStage; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QGRAPHICSSHADEREFFECT_P_H -- cgit v0.12 From d7bae8cd7684dd509fee56415f823b0c19b5d879 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 7 Sep 2009 08:42:10 +1000 Subject: Code cleanup: remove friend declarations for non-existent functions Reviewed-by: Alex --- src/opengl/qgl.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 1d9f623..89f1676 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -403,10 +403,6 @@ private: #endif friend class QGLFramebufferObject; friend class QGLFramebufferObjectPrivate; -#ifdef Q_WS_WIN - friend bool qt_resolve_GLSL_functions(QGLContext *ctx); - friend bool qt_createGLSLProgram(QGLContext *ctx, GLuint &program, const char *shader_src, GLuint &shader); -#endif private: Q_DISABLE_COPY(QGLContext) }; -- cgit v0.12 From a470652c5ffadfa039dde48a88348e8314a6bc9a Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 7 Sep 2009 09:17:08 +1000 Subject: Update QGLFormat::operator== to include all fields. The documentation says "Returns true if all the options of the two QGLFormats are equal", but that's not what it was doing. Reviewed-by: Sarah Smith --- src/opengl/qgl.cpp | 7 +++- tests/auto/qgl/tst_qgl.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index dde4eba..ef07447 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1256,7 +1256,12 @@ bool operator==(const QGLFormat& a, const QGLFormat& b) { return (int) a.d->opts == (int) b.d->opts && a.d->pln == b.d->pln && a.d->alphaSize == b.d->alphaSize && a.d->accumSize == b.d->accumSize && a.d->stencilSize == b.d->stencilSize - && a.d->depthSize == b.d->depthSize; + && a.d->depthSize == b.d->depthSize + && a.d->redSize == b.d->redSize + && a.d->greenSize == b.d->greenSize + && a.d->blueSize == b.d->blueSize + && a.d->numSamples == b.d->numSamples + && a.d->swapInterval == b.d->swapInterval; } diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 77e32ef..6c444e4 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -402,6 +402,89 @@ void tst_QGL::getSetCheck() obj1.setPlane(TEST_INT_MAX); QCOMPARE(TEST_INT_MAX, obj1.plane()); + // operator== and operator!= for QGLFormat + QGLFormat format1; + QGLFormat format2; + + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + format1.setDoubleBuffer(false); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setDoubleBuffer(false); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + + format1.setDepthBufferSize(8); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setDepthBufferSize(8); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + + format1.setAccumBufferSize(8); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setAccumBufferSize(8); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + + format1.setRedBufferSize(8); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setRedBufferSize(8); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + + format1.setGreenBufferSize(8); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setGreenBufferSize(8); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + + format1.setBlueBufferSize(8); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setBlueBufferSize(8); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + + format1.setAlphaBufferSize(8); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setAlphaBufferSize(8); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + + format1.setStencilBufferSize(8); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setStencilBufferSize(8); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + + format1.setSamples(8); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setSamples(8); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + + format1.setSwapInterval(8); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setSwapInterval(8); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + + format1.setPlane(8); + QVERIFY(!(format1 == format2)); + QVERIFY(format1 != format2); + format2.setPlane(8); + QVERIFY(format1 == format2); + QVERIFY(!(format1 != format2)); + MyGLContext obj2(obj1); // bool QGLContext::windowCreated() // void QGLContext::setWindowCreated(bool) -- cgit v0.12 From 203158b2444c9eb98714292d057c0c87a037ce3b Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 7 Sep 2009 09:30:20 +1000 Subject: Unit tests for QGLFormat copy constructor and operator= Reviewed-by: trustme --- tests/auto/qgl/tst_qgl.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 6c444e4..0fefbf3 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -485,6 +485,20 @@ void tst_QGL::getSetCheck() QVERIFY(format1 == format2); QVERIFY(!(format1 != format2)); + // Copy constructor and assignment for QGLFormat. + QGLFormat format3(format1); + QGLFormat format4; + QVERIFY(format1 == format3); + QVERIFY(format1 != format4); + format4 = format1; + QVERIFY(format1 == format4); + + // Check that modifying a copy doesn't affect the original. + format3.setRedBufferSize(16); + format4.setPlane(16); + QCOMPARE(format1.redBufferSize(), 8); + QCOMPARE(format1.plane(), 8); + MyGLContext obj2(obj1); // bool QGLContext::windowCreated() // void QGLContext::setWindowCreated(bool) -- cgit v0.12 From 6d908473ec1a8c72f4bbb9d772e801024c3a62a0 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 7 Sep 2009 10:18:46 +1000 Subject: Performance: Convert QGLFormat to use implicit sharing QGLFormat was being deep-copied many times per frame because of code like this: if (context()->format().doubleBuffer()) { ... This change modifies QGLFormat to use implicit sharing to reduce the overhead of the above type of checks. Reviewed-by: Sarah Smith --- src/opengl/qgl.cpp | 38 ++++++++++++++++++++++++++++++++++---- src/opengl/qgl.h | 4 ++-- src/opengl/qgl_p.h | 21 ++++++++++++++++++++- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index ef07447..aa67677 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -349,13 +349,26 @@ QGLFormat::QGLFormat(QGL::FormatOptions options, int plane) } /*! + \internal +*/ +void QGLFormat::detach() +{ + if (d->ref != 1) { + QGLFormatPrivate *newd = new QGLFormatPrivate(d); + if (!d->ref.deref()) + delete d; + d = newd; + } +} + +/*! Constructs a copy of \a other. */ QGLFormat::QGLFormat(const QGLFormat &other) { - d = new QGLFormatPrivate; - *d = *other.d; + d = other.d; + d->ref.ref(); } /*! @@ -364,7 +377,12 @@ QGLFormat::QGLFormat(const QGLFormat &other) QGLFormat &QGLFormat::operator=(const QGLFormat &other) { - *d = *other.d; + if (d != other.d) { + other.d->ref.ref(); + if (!d->ref.deref()) + delete d; + d = other.d; + } return *this; } @@ -373,7 +391,8 @@ QGLFormat &QGLFormat::operator=(const QGLFormat &other) */ QGLFormat::~QGLFormat() { - delete d; + if (!d->ref.deref()) + delete d; } /*! @@ -649,6 +668,7 @@ int QGLFormat::samples() const */ void QGLFormat::setSamples(int numSamples) { + detach(); if (numSamples < 0) { qWarning("QGLFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples); return; @@ -676,6 +696,7 @@ void QGLFormat::setSamples(int numSamples) */ void QGLFormat::setSwapInterval(int interval) { + detach(); d->swapInterval = interval; } @@ -743,6 +764,7 @@ int QGLFormat::plane() const */ void QGLFormat::setPlane(int plane) { + detach(); d->pln = plane; } @@ -754,6 +776,7 @@ void QGLFormat::setPlane(int plane) void QGLFormat::setOption(QGL::FormatOptions opt) { + detach(); if (opt & 0xffff) d->opts |= opt; else @@ -783,6 +806,7 @@ bool QGLFormat::testOption(QGL::FormatOptions opt) const */ void QGLFormat::setDepthBufferSize(int size) { + detach(); if (size < 0) { qWarning("QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size); return; @@ -809,6 +833,7 @@ int QGLFormat::depthBufferSize() const */ void QGLFormat::setRedBufferSize(int size) { + detach(); if (size < 0) { qWarning("QGLFormat::setRedBufferSize: Cannot set negative red buffer size %d", size); return; @@ -837,6 +862,7 @@ int QGLFormat::redBufferSize() const */ void QGLFormat::setGreenBufferSize(int size) { + detach(); if (size < 0) { qWarning("QGLFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size); return; @@ -865,6 +891,7 @@ int QGLFormat::greenBufferSize() const */ void QGLFormat::setBlueBufferSize(int size) { + detach(); if (size < 0) { qWarning("QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size); return; @@ -892,6 +919,7 @@ int QGLFormat::blueBufferSize() const */ void QGLFormat::setAlphaBufferSize(int size) { + detach(); if (size < 0) { qWarning("QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size); return; @@ -918,6 +946,7 @@ int QGLFormat::alphaBufferSize() const */ void QGLFormat::setAccumBufferSize(int size) { + detach(); if (size < 0) { qWarning("QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size); return; @@ -942,6 +971,7 @@ int QGLFormat::accumBufferSize() const */ void QGLFormat::setStencilBufferSize(int size) { + detach(); if (size < 0) { qWarning("QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size); return; diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 89f1676..0d72469 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -255,6 +255,8 @@ public: private: QGLFormatPrivate *d; + void detach(); + friend Q_OPENGL_EXPORT bool operator==(const QGLFormat&, const QGLFormat&); friend Q_OPENGL_EXPORT bool operator!=(const QGLFormat&, const QGLFormat&); }; @@ -277,7 +279,6 @@ public: bool isSharing() const; void reset(); - // ### Qt 5: make format() return a const ref instead QGLFormat format() const; QGLFormat requestedFormat() const; void setFormat(const QGLFormat& format); @@ -443,7 +444,6 @@ public: bool doubleBuffer() const; void swapBuffers(); - // ### Qt 5: make format() return a const ref instead QGLFormat format() const; void setFormat(const QGLFormat& format); diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 72ec35e..d4b7597 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -59,6 +59,7 @@ #include "QtCore/qthread.h" #include "QtCore/qthreadstorage.h" #include "QtCore/qhash.h" +#include "QtCore/qatomic.h" #include "private/qwidget_p.h" #include "qcache.h" @@ -127,7 +128,9 @@ QT_END_INCLUDE_NAMESPACE class QGLFormatPrivate { public: - QGLFormatPrivate() { + QGLFormatPrivate() + : ref(1) + { opts = QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba | QGL::DirectRendering | QGL::StencilBuffer; #if defined(QT_OPENGL_ES_2) opts |= QGL::SampleBuffers; @@ -137,6 +140,22 @@ public: numSamples = -1; swapInterval = -1; } + QGLFormatPrivate(const QGLFormatPrivate *other) + : ref(1), + opts(other->opts), + pln(other->pln), + depthSize(other->depthSize), + accumSize(other->accumSize), + stencilSize(other->stencilSize), + redSize(other->redSize), + greenSize(other->greenSize), + blueSize(other->blueSize), + alphaSize(other->alphaSize), + numSamples(other->numSamples), + swapInterval(other->swapInterval) + { + } + QAtomicInt ref; QGL::FormatOptions opts; int pln; int depthSize; -- cgit v0.12 From 91443717927ee648a0c1c4185aae171ccdf87e2b Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Mon, 7 Sep 2009 10:37:42 +1000 Subject: Fixed compile on Solaris. The `test' builtin in Solaris' /bin/sh does not understand `-e', use `-f' instead. Fixes: configure: test: argument expected Note, using the `-nokia-developer' configure option hides this breakage. Reviewed-by: Rhys Weatherley --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index af8c209..2e2b474 100755 --- a/configure +++ b/configure @@ -3742,7 +3742,7 @@ elif [ "$Edition" = "OpenSource" ]; then while true; do echo "You are licensed to use this software under the terms of" echo "the Lesser GNU General Public License (LGPL) versions 2.1." - if [ -e "$relpath/LICENSE.GPL3" ]; then + if [ -f "$relpath/LICENSE.GPL3" ]; then echo "You are also licensed to use this software under the terms of" echo "the GNU General Public License (GPL) versions 3." affix="either" @@ -3754,7 +3754,7 @@ elif [ "$Edition" = "OpenSource" ]; then echo "You have already accepted the terms of the $LicenseType license." acceptance=yes else - if [ -e "$relpath/LICENSE.GPL3" ]; then + if [ -f "$relpath/LICENSE.GPL3" ]; then echo "Type '3' to view the GNU General Public License version 3." fi echo "Type 'L' to view the Lesser GNU General Public License version 2.1." -- cgit v0.12