summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure4
-rw-r--r--examples/effects/customshader/blureffect.cpp4
-rw-r--r--examples/effects/customshader/blureffect.h4
-rw-r--r--examples/effects/customshader/customshadereffect.h2
-rw-r--r--src/gui/effects/qgraphicseffect.cpp1
-rw-r--r--src/opengl/opengl.pro2
-rw-r--r--src/opengl/qgl.cpp45
-rw-r--r--src/opengl/qgl.h8
-rw-r--r--src/opengl/qgl_p.h21
-rw-r--r--src/opengl/qgraphicsshadereffect.cpp18
-rw-r--r--src/opengl/qgraphicsshadereffect_p.h (renamed from src/opengl/qgraphicsshadereffect.h)17
-rw-r--r--src/testlib/qtestmouse.h3
-rw-r--r--tests/auto/qgl/tst_qgl.cpp97
13 files changed, 192 insertions, 34 deletions
diff --git a/configure b/configure
index 9ef0b45..70c91c2 100755
--- a/configure
+++ b/configure
@@ -3874,7 +3874,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"
@@ -3886,7 +3886,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."
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<BlurEffect *>(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 <QGraphicsEffect>
-#include <QGraphicsShaderEffect>
+#include <QtOpenGL/private/qgraphicsshadereffect_p.h>
#include <QGraphicsItem>
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/qgl.cpp b/src/opengl/qgl.cpp
index dde4eba..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;
@@ -1256,7 +1286,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/src/opengl/qgl.h b/src/opengl/qgl.h
index 1d9f623..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);
@@ -403,10 +404,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)
};
@@ -447,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;
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_p.h
index a186074..a313846 100644
--- a/src/opengl/qgraphicsshadereffect.h
+++ b/src/opengl/qgraphicsshadereffect_p.h
@@ -39,8 +39,19 @@
**
****************************************************************************/
-#ifndef QGRAPHICSSHADEREFFECT_H
-#define QGRAPHICSSHADEREFFECT_H
+#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 <QtGui/qgraphicseffect.h>
@@ -80,4 +91,4 @@ QT_END_NAMESPACE
QT_END_HEADER
-#endif // QGRAPHICSSHADEREFFECT_H
+#endif // QGRAPHICSSHADEREFFECT_P_H
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<int>(action)]).toAscii().data());
}
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index 77e32ef..0fefbf3 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -402,6 +402,103 @@ 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));
+
+ // 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)