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