diff options
-rw-r--r-- | src/declarative/fx/fx.pri | 8 | ||||
-rw-r--r-- | src/declarative/fx/qfxblurfilter.cpp | 467 | ||||
-rw-r--r-- | src/declarative/fx/qfxblurfilter.h | 82 | ||||
-rw-r--r-- | src/declarative/fx/qfxhighlightfilter.cpp | 320 | ||||
-rw-r--r-- | src/declarative/fx/qfxhighlightfilter.h | 98 | ||||
-rw-r--r-- | src/declarative/fx/qfxreflectionfilter.cpp | 352 | ||||
-rw-r--r-- | src/declarative/fx/qfxreflectionfilter.h | 96 | ||||
-rw-r--r-- | src/declarative/fx/qfxshadowfilter.cpp | 214 | ||||
-rw-r--r-- | src/declarative/fx/qfxshadowfilter.h | 86 |
9 files changed, 0 insertions, 1723 deletions
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 1c819e7..166ad58 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -3,7 +3,6 @@ HEADERS += \ fx/qfxanchors_p.h \ fx/qfxanimatedimageitem.h \ fx/qfxblendedimage.h \ - fx/qfxblurfilter.h \ fx/qfxcomponentinstance.h \ fx/qfxcomponentinstance_p.h \ fx/qfxcontentwrapper.h \ @@ -16,7 +15,6 @@ HEADERS += \ fx/qfxfocusrealm.h \ fx/qfxgridview.h \ fx/qfxflowview.h \ - fx/qfxhighlightfilter.h \ fx/qfximage.h \ fx/qfxpainteditem.h \ fx/qfxpainteditem_p.h \ @@ -36,11 +34,9 @@ HEADERS += \ fx/qfxpathview_p.h \ fx/qfxrect.h \ fx/qfxrect_p.h \ - fx/qfxreflectionfilter.h \ fx/qfxrepeater.h \ fx/qfxrepeater_p.h \ fx/qfxscalegrid.h \ - fx/qfxshadowfilter.h \ fx/qfxtextedit.h \ fx/qfxtextedit_p.h \ fx/qfxtext.h \ @@ -55,7 +51,6 @@ SOURCES += \ fx/qfxanchors.cpp \ fx/qfxanimatedimageitem.cpp \ fx/qfxblendedimage.cpp \ - fx/qfxblurfilter.cpp \ fx/qfxcomponentinstance.cpp \ fx/qfxcontentwrapper.cpp \ fx/qfxevents.cpp \ @@ -65,7 +60,6 @@ SOURCES += \ fx/qfxfocusrealm.cpp \ fx/qfxgridview.cpp \ fx/qfxflowview.cpp \ - fx/qfxhighlightfilter.cpp \ fx/qfximage.cpp \ fx/qfxpainteditem.cpp \ fx/qfxitem.cpp \ @@ -77,10 +71,8 @@ SOURCES += \ fx/qfxpath.cpp \ fx/qfxpathview.cpp \ fx/qfxrect.cpp \ - fx/qfxreflectionfilter.cpp \ fx/qfxrepeater.cpp \ fx/qfxscalegrid.cpp \ - fx/qfxshadowfilter.cpp \ fx/qfxtext.cpp \ fx/qfxtextedit.cpp \ fx/qfxtransform.cpp \ diff --git a/src/declarative/fx/qfxblurfilter.cpp b/src/declarative/fx/qfxblurfilter.cpp deleted file mode 100644 index 84799ec..0000000 --- a/src/declarative/fx/qfxblurfilter.cpp +++ /dev/null @@ -1,467 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfxblurfilter.h" -#include <private/qsimplecanvasitem_p.h> - -#if defined(QFX_RENDER_OPENGL2) -#include <glsave.h> -#include <QtOpenGL/qglframebufferobject.h> -#include <glbasicshaders.h> -#endif - -QT_BEGIN_NAMESPACE -class QFxBlurFilterPrivate -{ -public: - QFxBlurFilterPrivate() - : radius(0) - { - } - qreal radius; -}; - -/*! - \qmlclass Blur - \brief The Blur filter blurs an item and its contents. - \inherits Filter - - Blurring reduces the clarity of a visual item. The following example - shows an icon at a blur radius of 0, 5 and 10. - - \table - \row - \o - \qml -HorizontalLayout { - Image { - source: "icon.png" - filter: Blur { radius: 0 } - } - Image { - source: "icon.png" - filter: Blur { radius: 5 } - } - Image { - source: "icon.png" - filter: Blur { radius: 10 } - } -} - \endqml - \row - \o \image blur_example.png - \endtable - - Bluring is only supported when Qt Declarative is compiled for OpenGL ES 2.0. - Otherwise the Blur filter has no effect. - */ -/*! - \internal - \class QFxBlurFilter - \ingroup group_effects - \brief The QFxBlurFilter class allows you to blur an item. -*/ - -QFxBlurFilter::QFxBlurFilter(QObject *parent) -: QSimpleCanvasFilter(parent), d(new QFxBlurFilterPrivate) -{ -} - -QFxBlurFilter::~QFxBlurFilter() -{ - delete d; d = 0; -} - -/*! - \qmlproperty real Blur::radius - - Sets the blur kernel radius. - The larger the radius the more blurry the item will appear. - A radius of 0 (or less) is equivalent to no blur. - */ - -/*! - \property QFxBlurFilter::radius - \brief the radius of the blur. -*/ -qreal QFxBlurFilter::radius() const -{ - return d->radius; -} - -void QFxBlurFilter::setRadius(qreal radius) -{ - if (d->radius == radius) return; - d->radius = radius; - emit radiusChanged(radius); - update(); -} - -QRectF QFxBlurFilter::itemBoundingRect(const QRectF &r) const -{ - QRectF rv = r; - if (d->radius > 0) - rv.adjust(-d->radius, -d->radius, d->radius, d->radius); - return rv; -} - -#include <math.h> -void QFxBlurFilter::filterGL(QSimpleCanvasItem::GLPainter &p) -{ -#if defined(QFX_RENDER_OPENGL2) -#if 1 - if (d->radius <= 0) { - renderToScreen(); - return; - } - float radius = d->radius; - QSimpleCanvasItem *item = this->item(); - - QRect r = item->itemBoundingRect(); - float blurScale = 1.0; - QRect tr = QRect(QPoint(0, 0), r.size() * blurScale); - radius *= blurScale; - - QGLFramebufferObject *fbo = renderToFBO(blurScale); - if (!fbo) - return; - - float height = r.height(); - float width = r.width(); - - float texWidth = float(tr.width()) / float(fbo->width()); - float texHeight = float(tr.height()) / float(fbo->height()); - - int steps = int(::ceil(radius)); - int dispSteps = int(::ceil(d->radius)); - float xstep = texWidth * radius / float(steps * fbo->width()); - float xinc = steps / float(fbo->width()); - - glDisable(GL_BLEND); - - // Render x pass - QSize xSize(tr.width() + 2 * steps, tr.height()); - QGLFramebufferObject *xBlur = acquireFBO(xSize); - float xWidth = float(xSize.width()) / float(xBlur->width()); - float xHeight = float(xSize.height()) / float(xBlur->height()); - { - xBlur->bind(); - - GLSaveViewport sv; GLSaveScissor ss; - glClearColor(0,0,0,0); - glDisable(GL_SCISSOR_TEST); - glViewport(0, 0, xBlur->width(), xBlur->height()); - glClear(GL_COLOR_BUFFER_BIT); - - float vert[] = { 0, xHeight, - xWidth, xHeight, - 0, 0, - xWidth, 0 }; - float texVert[] = { -xinc, 0, - texWidth + xinc, 0, - -xinc, texHeight, - texWidth + xinc, texHeight }; - - QMatrix4x4 trans; - trans.translate(-1, -1); - trans.scale(2, 2); - BlurTextureShader *shader = item->basicShaders()->blurTexture(); - shader->enable(); - shader->setTransform(trans); - if (steps > 1) { - shader->setStep(xstep * 2); - shader->setSteps(steps / 2); - } else { - shader->setStep(xstep); - shader->setSteps(steps); - } - shader->setMode(BlurTextureShader::Horizontal); - - glBindTexture(GL_TEXTURE_2D, fbo->texture()); - - shader->setAttributeArray(BlurTextureShader::Vertices, vert, 2); - shader->setAttributeArray(BlurTextureShader::TextureCoords, texVert, 2); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - shader->disableAttributeArray(BlurTextureShader::Vertices); - shader->disableAttributeArray(BlurTextureShader::TextureCoords); - xBlur->release(); - } - - // Render y pass - QSize ySize(xSize.width(), tr.height() + 2 * steps); - QGLFramebufferObject *yBlur = acquireFBO(ySize); - - float yWidth = float(ySize.width()) / float(yBlur->width()); - float yHeight = float(ySize.height()) / float(yBlur->height()); - float ystep = radius / float(steps * xBlur->height()); - float yinc = steps / float(xBlur->height()); - { - yBlur->bind(); - - GLSaveViewport sv; GLSaveScissor ss; - glClearColor(0,0,0,0); - glDisable(GL_SCISSOR_TEST); - glViewport(0, 0, yBlur->width(), yBlur->height()); - glClear(GL_COLOR_BUFFER_BIT); - - float vert[] = { 0, yHeight, - yWidth, yHeight, - 0, 0, - yWidth, 0 }; - float texVert[] = { 0, -yinc, - xWidth, -yinc, - 0, xHeight + yinc, - xWidth, xHeight + yinc }; - - QMatrix4x4 trans; - trans.translate(-1, -1); - trans.scale(2, 2); - BlurTextureShader *shader = item->basicShaders()->blurTexture(); - shader->enable(); - shader->setTransform(trans); - if (steps > 1) { - shader->setStep(ystep * 2); - shader->setSteps(steps / 2); - } else { - shader->setStep(ystep); - shader->setSteps(steps); - } - shader->setMode(BlurTextureShader::Vertical); - - glBindTexture(GL_TEXTURE_2D, xBlur->texture()); - - shader->setAttributeArray(BlurTextureShader::Vertices, vert, 2); - shader->setAttributeArray(BlurTextureShader::TextureCoords, texVert, 2); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - shader->disableAttributeArray(BlurTextureShader::Vertices); - shader->disableAttributeArray(BlurTextureShader::TextureCoords); - yBlur->release(); - } - - glEnable(GL_BLEND); - - // Render display pass - { - glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - float vert[] = { -dispSteps, height + dispSteps, - width + dispSteps, height + dispSteps, - -dispSteps, -dispSteps, - width + dispSteps, -dispSteps }; - float texVert[] = { 0, 0, - yWidth, 0, - 0, yHeight, - yWidth, yHeight }; - SingleTextureShader *shader = item->basicShaders()->singleTexture(); - shader->enable(); - shader->setTransform(p.activeTransform); - - glBindTexture(GL_TEXTURE_2D, yBlur->texture()); - - shader->setAttributeArray(SingleTextureShader::Vertices, vert, 2); - shader->setAttributeArray(SingleTextureShader::TextureCoords, texVert, 2); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - shader->disableAttributeArray(SingleTextureShader::Vertices); - shader->disableAttributeArray(SingleTextureShader::TextureCoords); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } - - releaseFBO(yBlur); - releaseFBO(xBlur); - releaseFBO(fbo); -#else -#if 0 - if (d->radius <= 0) { - renderToScreen(); - return; - } - QSimpleCanvasItem *item = this->item(); - - QRect r = item->itemBoundingRect(); - - float scale = 0.5; - float scalePercent = scale / d->radius; - QGLFramebufferObject *fbo = renderToFBO(scalePercent); - if (!fbo) - return; - - QGLFramebufferObject *xfbo = acquireFBO(QSize(scale * r.width(), fbo->height())); - QGLFramebufferObject *yfbo = acquireFBO(QSize(scale * r.width(), scale * r.height())); - - - BlurTextureShader *shader = item->basicShaders()->blurTexture(); - shader->enable(); - shader->setTransform(QMatrix4x4()); - - // Render up - x - { - shader->setMode(BlurTextureShader::Horizontal); - shader->setStep(1. / float(xfbo->width())); - - GLSaveViewport vp; - xfbo->bind(); - glClearColor(0,0,0,0); - glViewport(0, 0, xfbo->width(), xfbo->height()); - glClear(GL_COLOR_BUFFER_BIT); - - float oWidth = -1. + 2. * float(r.width()) * scale / float(xfbo->width()); - float oHeight = -1. + 2. * float(r.height()) * scalePercent / float(xfbo->height()); - float vert[] = { - -1, -1, - oWidth, -1, - -1, oHeight, - - -1, oHeight, - oWidth, oHeight, - oWidth, -1 - }; - - float tWidth = r.width() * scalePercent / fbo->width(); - float tHeight = r.height() * scalePercent / fbo->height(); - float texVert[] = { - 0, 0, - tWidth, 0, - 0, tHeight, - - 0, tHeight, - tWidth, tHeight, - tWidth, 0 - }; - - glBindTexture(GL_TEXTURE_2D, fbo->texture()); - shader->setAttributeArray(BlurTextureShader::Vertices, vert, 2); - shader->setAttributeArray(BlurTextureShader::TextureCoords, texVert, 2); - - glDrawArrays(GL_TRIANGLES, 0, 6); - - xfbo->release(); - } - - // Render up - y - { - shader->setMode(BlurTextureShader::Vertical); - shader->setStep(1. / float(yfbo->height())); - - GLSaveViewport vp; - yfbo->bind(); - glClearColor(0,0,0,0); - glViewport(0, 0, yfbo->width(), yfbo->height()); - glClear(GL_COLOR_BUFFER_BIT); - - float oWidth = -1. + 2. * r.width() * scale / yfbo->width(); - float oHeight = -1. + 2. * r.height() * scale / yfbo->height(); - float vert[] = { - -1, -1, - oWidth, -1, - -1, oHeight, - - -1, oHeight, - oWidth, oHeight, - oWidth, -1 - }; - - float tWidth = r.width() * scale / xfbo->width(); - float tHeight = r.height() * scalePercent / xfbo->height(); - float texVert[] = { - 0, 0, - tWidth, 0, - 0, tHeight, - - 0, tHeight, - tWidth, tHeight, - tWidth, 0 - }; - - glBindTexture(GL_TEXTURE_2D, xfbo->texture()); - shader->setAttributeArray(BlurTextureShader::Vertices, vert, 2); - shader->setAttributeArray(BlurTextureShader::TextureCoords, texVert, 2); - - glDrawArrays(GL_TRIANGLES, 0, 6); - - yfbo->release(); - } - - shader->disableAttributeArray(BlurTextureShader::Vertices); - shader->disableAttributeArray(BlurTextureShader::TextureCoords); - - float width = r.width(); - float height = r.height(); - //paint to screen - { - float texWidth = r.width() * scale / float(yfbo->width()); - float texHeight = r.height() * scale / float(yfbo->height()); - - GLfloat vertices[] = { 0, height, - width, height, - 0, 0, - width, 0 }; - GLfloat texVertices[] = { 0, 0, - texWidth, 0, - 0, texHeight, - texWidth, texHeight }; - - glBindTexture(GL_TEXTURE_2D, yfbo->texture()); - - SingleTextureOpacityShader *shader = - item->basicShaders()->singleTextureOpacity(); - shader->enable(); - shader->setTransform(p.activeTransform); - shader->setOpacity(p.activeOpacity); - shader->setAttributeArray(SingleTextureVertexOpacityShader::Vertices, vertices, 2); - shader->setAttributeArray(SingleTextureVertexOpacityShader::TextureCoords, texVertices, 2); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - shader->disableAttributeArray(SingleTextureVertexOpacityShader::Vertices); - shader->disableAttributeArray(SingleTextureVertexOpacityShader::TextureCoords); - } - - - releaseFBO(fbo); - releaseFBO(xfbo); - releaseFBO(yfbo); -#endif -#endif -#else - Q_UNUSED(p); -#endif - -} - -QML_DEFINE_TYPE(QFxBlurFilter,Blur) -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxblurfilter.h b/src/declarative/fx/qfxblurfilter.h deleted file mode 100644 index 90285de..0000000 --- a/src/declarative/fx/qfxblurfilter.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXBLURFILTER_H -#define QFXBLURFILTER_H - -#include <QtDeclarative/qsimplecanvasfilter.h> -#include <QtDeclarative/qml.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QFxBlurFilterPrivate; -class Q_DECLARATIVE_EXPORT QFxBlurFilter : public QSimpleCanvasFilter -{ - Q_OBJECT - Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged) -public: - QFxBlurFilter(QObject *parent=0); - virtual ~QFxBlurFilter(); - - qreal radius() const; - void setRadius(qreal); - -Q_SIGNALS: - void radiusChanged(qreal); - -protected: - virtual QRectF itemBoundingRect(const QRectF &) const; - virtual void filterGL(QSimpleCanvasItem::GLPainter &p); - -private: - QFxBlurFilterPrivate *d; -}; -QML_DECLARE_TYPE(QFxBlurFilter) - - -QT_END_NAMESPACE - -QT_END_HEADER -#endif // QFXBLURFILTER_H diff --git a/src/declarative/fx/qfxhighlightfilter.cpp b/src/declarative/fx/qfxhighlightfilter.cpp deleted file mode 100644 index 1671fc6..0000000 --- a/src/declarative/fx/qfxhighlightfilter.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfxhighlightfilter.h" -#include <qfxpixmap.h> -#include <qmlcontext.h> - -#if defined(QFX_RENDER_OPENGL2) -#include <gltexture.h> -#include <glbasicshaders.h> -#include <QtOpenGL/qglframebufferobject.h> -#include <glsave.h> -#endif - -QT_BEGIN_NAMESPACE - -class QFxHighlightFilterPrivate -{ -public: - QFxHighlightFilterPrivate() - : xOffset(0), yOffset(0), tiled(false) {} - - QUrl url; - int xOffset; - int yOffset; - bool tiled; -#if defined(QFX_RENDER_OPENGL2) - GLTexture tex; -#endif -}; - -/*! - \qmlclass Highlight - \brief The Highlight filter adds a highlight to an item. - \inherits Filter - - \qml -Text { - id: highlighttext - color: "red" - font.size: 32 - text: "Highlight" - filter: Highlight { - source: "pics/highlight.png" - xOffset: NumericAnimation { - running: true - repeat: true - from: 320 - to: -320 - duration: 2000 - } - } -} - \endqml - \image highlight.gif - - Highlighting is only supported when Qt Declarative is compiled for OpenGL ES 2.0. - Otherwise the Highlight filter has no effect. -*/ - -/*! - \internal - \class QFxHighlightFilter - \ingroup group_effects - \brief The QFxHightlightFilter class allows you to add a highlight to an item. -*/ - -QFxHighlightFilter::QFxHighlightFilter(QObject *parent) -: QSimpleCanvasFilter(parent), d(new QFxHighlightFilterPrivate) -{ -#if defined(QFX_RENDER_OPENGL2) - d->tex.setHorizontalWrap(GLTexture::ClampToEdge); - d->tex.setVerticalWrap(GLTexture::ClampToEdge); -#endif -} - -QFxHighlightFilter::~QFxHighlightFilter() -{ - if (!d->url.isEmpty()) - QFxPixmap::cancelGet(d->url, this); - delete d; - d = 0; -} - -/*! - \qmlproperty string Highlight::source - This property holds the URL of the image to be used as the highlight. -*/ - -/*! - \property QFxHighlightFilter::source - \brief the URL of the image to be used as the highlight. -*/ -QUrl QFxHighlightFilter::source() const -{ - return d->url; -} - -void QFxHighlightFilter::imageLoaded() -{ - QPixmap img = QFxPixmap(d->url); -#if defined(QFX_RENDER_OPENGL2) - if (!img.isNull()) - d->tex.setImage(img.toImage()); -#endif - emit sourceChanged(d->url); - update(); -} - -void QFxHighlightFilter::setSource(const QUrl &f) -{ - if (d->url == f) - return; - if (!d->url.isEmpty()) - QFxPixmap::cancelGet(d->url, this); - Q_ASSERT(!f.isRelative()); - d->url = f; -#if defined(QFX_RENDER_OPENGL2) - d->tex.clear(); -#endif - if (!f.isEmpty()) - QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded())); - else - emit sourceChanged(d->url); -} - -/*! - \qmlproperty bool Highlight::tiled - This property holds whether or not the highlight should be tiled. -*/ - -/*! - \property QFxHighlightFilter::tiled - \brief whether or not the highlight should be tiled. -*/ -bool QFxHighlightFilter::tiled() const -{ - return d->tiled; -} - -void QFxHighlightFilter::setTiled(bool t) -{ - if (t == d->tiled) - return; - - d->tiled = t; - -#if defined(QFX_RENDER_OPENGL2) - if (d->tiled) { - d->tex.setHorizontalWrap(GLTexture::ClampToEdge); - d->tex.setVerticalWrap(GLTexture::ClampToEdge); - } else { - d->tex.setHorizontalWrap(GLTexture::Repeat); - d->tex.setVerticalWrap(GLTexture::Repeat); - } -#endif - - emit tiledChanged(d->tiled); -} - -/*! - \qmlproperty int Highlight::xOffset - \qmlproperty int Highlight::yOffset - These properties hold the position of the highlight, relative to the item. -*/ - -/*! - \property QFxHighlightFilter::xOffset - \brief the x position of the highlight, relative to the item. -*/ -int QFxHighlightFilter::xOffset() const -{ - return d->xOffset; -} - -void QFxHighlightFilter::setXOffset(int x) -{ - if (x == d->xOffset) - return; - - d->xOffset = x; - emit offsetChanged(d->xOffset, d->yOffset); -#if defined(QFX_RENDER_OPENGL2) - update(); -#endif -} - -/*! - \property QFxHighlightFilter::yOffset - \brief the y position of the highlight, relative to the item. -*/ -int QFxHighlightFilter::yOffset() const -{ - return d->yOffset; -} - -void QFxHighlightFilter::setYOffset(int y) -{ - if (y == d->yOffset) - return; - - d->yOffset = y; - emit offsetChanged(d->xOffset, d->yOffset); -#if defined(QFX_RENDER_OPENGL2) - update(); -#endif -} - -void QFxHighlightFilter::filterGL(QSimpleCanvasItem::GLPainter &p) -{ -#if defined(QFX_RENDER_OPENGL2) - if (d->tex.isNull()) { - renderToScreen(); - } else { - QSimpleCanvasItem *item = this->item(); - - QRect r = item->itemBoundingRect(); - - QGLFramebufferObject *fbo = renderToFBO(); - - float width = r.width(); - float height = r.height(); - - float texWidth = width / float(fbo->width()); - float texHeight = height / float(fbo->height()); - - GLfloat vert[] = { 0, height, - width, height, - 0, 0, - width, 0 }; - GLfloat texVert[] = { 0, 0, - texWidth, 0, - 0, texHeight, - texWidth, texHeight }; - float texXOffset = 0; - float texYOffset = 0; - - if (xOffset()) - texXOffset = float(xOffset()) / float(d->tex.width()); - if (yOffset()) - texYOffset = float(yOffset()) / float(d->tex.height()); - - GLfloat addTexVert[] = { texXOffset, texYOffset, - 1 + texXOffset, texYOffset, - texXOffset, 1 + texYOffset, - 1 + texXOffset, 1 + texYOffset }; - - glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, fbo->texture()); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, d->tex.texture()); - - DualTextureAddShader *shader = item->basicShaders()->dualTextureAdd(); - shader->enable(); - shader->setTransform(p.activeTransform); - shader->setOpacity(p.activeOpacity); - - shader->setAttributeArray(DualTextureAddShader::Vertices, vert, 2); - shader->setAttributeArray(DualTextureAddShader::TextureCoords, texVert, 2); - shader->setAttributeArray(DualTextureAddShader::AddTextureCoords, addTexVert, 2); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - shader->disableAttributeArray(DualTextureAddShader::Vertices); - shader->disableAttributeArray(DualTextureAddShader::TextureCoords); - shader->disableAttributeArray(DualTextureAddShader::AddTextureCoords); - - glActiveTexture(GL_TEXTURE0); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - - releaseFBO(fbo); - } -#else - Q_UNUSED(p); -#endif -} - -QML_DEFINE_TYPE(QFxHighlightFilter,Highlight) - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxhighlightfilter.h b/src/declarative/fx/qfxhighlightfilter.h deleted file mode 100644 index 33f0963..0000000 --- a/src/declarative/fx/qfxhighlightfilter.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXHIGHLIGHTFILTER_H -#define QFXHIGHLIGHTFILTER_H - -#include <QtDeclarative/qsimplecanvasfilter.h> -#include <QtDeclarative/qml.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QFxHighlightFilterPrivate; -class Q_DECLARATIVE_EXPORT QFxHighlightFilter : public QSimpleCanvasFilter -{ - Q_OBJECT - - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(bool tiled READ tiled WRITE setTiled NOTIFY tiledChanged) - Q_PROPERTY(int xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged) - Q_PROPERTY(int yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged) -public: - QFxHighlightFilter(QObject *parent=0); - virtual ~QFxHighlightFilter(); - - QUrl source() const; - void setSource(const QUrl &); - - bool tiled() const; - void setTiled(bool); - - int xOffset() const; - void setXOffset(int); - int yOffset() const; - void setYOffset(int); - -Q_SIGNALS: - void sourceChanged(const QUrl &); - void offsetChanged(int x, int y); - void tiledChanged(bool); - -private Q_SLOTS: - void imageLoaded(); - -protected: - virtual void filterGL(QSimpleCanvasItem::GLPainter &p); - -private: - QFxHighlightFilterPrivate *d; -}; -QML_DECLARE_TYPE(QFxHighlightFilter) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QFXHIGHLIGHTFILTER_H diff --git a/src/declarative/fx/qfxreflectionfilter.cpp b/src/declarative/fx/qfxreflectionfilter.cpp deleted file mode 100644 index c66deb7..0000000 --- a/src/declarative/fx/qfxreflectionfilter.cpp +++ /dev/null @@ -1,352 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfxreflectionfilter.h" - -#if defined(QFX_RENDER_OPENGL2) -#include <glsave.h> -#include <QtOpenGL/qglframebufferobject.h> -#include <glbasicshaders.h> -#include <gltexture.h> -#endif - -QT_BEGIN_NAMESPACE -class QFxReflectionFilterPrivate -{ -public: - QFxReflectionFilterPrivate() - : alpha(1), height(-1), offset(0), scale(1) - { - } - qreal alpha; - int height; - int offset; - qreal scale; -}; - -/*! - \qmlclass Reflection - \inherits Filter - \brief The Reflection filter reflects an item and its contents. - - Here is an example of various Reflections applied to an image. - - \qml -HorizontalLayout { - Image { - source: "icon.png" - filter: Reflection { } - } - Image { - source: "icon.png" - filter: Reflection { offset: 1 } - } - Image { - source: "icon.png" - filter: Reflection { offset: 1; alpha: 0.5 } - } - Image { - source: "icon.png" - filter: Reflection { offset: 1; alpha: 0.5; height: 50 } - } - Image { - source: "icon.png" - filter: Reflection { offset: 1; alpha: 0.5; height: 50; scale: 0.5 } - } -} - \endqml - - \image reflection_example.png - - Reflection is only supported when Qt Declarative is compiled for OpenGL ES 2.0. - Otherwise the Reflection filter has no effect. -*/ - -/*! - \internal - \class QFxReflectionFilter - \ingroup group_effects - \brief The QFxReflectionFilter class allows you to add a reflection to an item. -*/ -QFxReflectionFilter::QFxReflectionFilter(QObject *parent) -: QSimpleCanvasFilter(parent), d(new QFxReflectionFilterPrivate) -{ -} - -QFxReflectionFilter::~QFxReflectionFilter() -{ - delete d; d = 0; -} - -/*! - \property QFxReflectionFilter::alpha - \brief the starting opacity of the reflection. - - The starting opacity is the opacity closest to the item. The opacity will fade - from this value to zero over the height of the reflection. -*/ -qreal QFxReflectionFilter::alpha() const -{ - return d->alpha; -} - -void QFxReflectionFilter::setAlpha(qreal a) -{ - if (d->alpha == a) return; - d->alpha = a; - emit alphaChanged(a); - update(); -} - -/*! - \qmlproperty int Reflection::height - - The height property controls how much of the item, in pixels, to reflect. - If it is set to the default value of -1, the whole item is reflected. If - it is set to 50, the bottom 50 pixels of the item are reflected. Data - binding could be used to reflect a percentage of the item. - - \qml -Image { - id: myImage - source: "album.png" - filter: Reflection { - height: myImage.height * 0.5 - } -} - \endqml - */ -/*! - \qmlproperty int Reflection::offset - - The offset controls how far from the base of the item, in pixels, the - start of the reflection is placed. This can be used to create a nice - sliver of space between the item and its reflection or for more advanced - effects. - - The default offset is 0 pixels. -*/ - -/*! - \qmlproperty real Reflection::alpha - - The alpha value controls the starting opacity of the reflected item. If - set to the default value of 1, the reflected item starts completely opaque - and gradually fades to completely transparent. If set to less than one, the - reflection starts out partially transparent as though the item was sitting - on a visually less reflective surface. - - Valid values are from 0 (which would be silly, but is allowed) to 1. -*/ -/*! - \qmlproperty real Reflection::scale - - When set to the default value of 1, the reflection is a 1:1 reflection of - the item. That is, each horizontal pixel in the item corresponds to one - horizontal pixel in the reflection. - - When set a value other than 1, the reflection is scaled acordingly - less - than 1 scales it down and greater than 1 scales it up. The scale is applied - after the height parameter and does not effect the reflection offset. -*/ - -/*! - \property QFxReflectionFilter::height - \brief the height of the reflection, in pixels. -*/ -int QFxReflectionFilter::height() const -{ - return d->height; -} - -void QFxReflectionFilter::setHeight(int h) -{ - if (d->height == h) return; - d->height = h; - emit heightChanged(h); - update(); -} - -/*! - \property QFxReflectionFilter::offset - \brief the distance of the reflection from the item, in pixels. -*/ -int QFxReflectionFilter::offset() -{ - return d->offset; -} - -void QFxReflectionFilter::setOffset(int o) -{ - if (d->offset == o) return; - d->offset = o; - emit offsetChanged(o); - update(); -} - -/*! - \property QFxReflectionFilter::scale - \brief the scale of the reflection relative to the item. -*/ -qreal QFxReflectionFilter::scale() const -{ - return d->scale; -} - -void QFxReflectionFilter::setScale(qreal s) -{ - if (d->scale == s) return; - d->scale = s; - emit scaleChanged(s); - update(); -} - -static inline float floatmin(float a, float b) -{ - return (a < b)?a:b; -} - -void QFxReflectionFilter::filterGL(QSimpleCanvasItem::GLPainter &p) -{ -#if defined(QFX_RENDER_OPENGL2) - QSimpleCanvasItem *item = this->item(); - - QRect r = item->itemBoundingRect(); - if (r.isEmpty()) - return; - float width = r.width(); - float height = r.height(); - - float refHeight = height; - if (d->height > 0) - refHeight = floatmin(height, d->height); - - QSimpleCanvas::Matrix simpMat; - QSimpleCanvasItem *simpItem = 0; - if (isSimpleItem(&simpItem, &simpMat) && - simpItem->glSimpleItemData(0, 0, 0, 0)) { - - GLfloat vertices[8]; - GLfloat texVertices[8]; - GLTexture *texture = 0; - - simpItem->glSimpleItemData(vertices, texVertices, &texture, 8); - - GLfloat opacity[4]; - - float invRefHeight = 1. / refHeight; - for (int ii = 0; ii < 4; ++ii) { - float vertex = vertices[ii * 2 + 1]; - float o = (1. - (height - vertex) * invRefHeight); - opacity[ii] = o * d->alpha * p.activeOpacity; - } - - QSimpleCanvas::Matrix trans = p.activeTransform; - trans.rotate(180, 1, 0, 0); - trans.translate(0, -r.height() - d->offset); - if (d->scale != 1) - trans.scale(1, d->scale, 1); - trans.translate(0, -r.height()); - trans *= simpMat; - - glBindTexture(GL_TEXTURE_2D, texture->texture()); - - SingleTextureVertexOpacityShader *shader = - item->basicShaders()->singleTextureVertexOpacity(); - shader->enable(); - shader->setTransform(trans); - shader->setAttributeArray(SingleTextureVertexOpacityShader::Vertices, vertices, 2); - shader->setAttributeArray(SingleTextureVertexOpacityShader::TextureCoords, texVertices, 2); - shader->setAttributeArray(SingleTextureVertexOpacityShader::OpacityCoords, opacity, 1); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - shader->disableAttributeArray(SingleTextureVertexOpacityShader::Vertices); - shader->disableAttributeArray(SingleTextureVertexOpacityShader::TextureCoords); - shader->disableAttributeArray(SingleTextureVertexOpacityShader::OpacityCoords); - - } else { - QGLFramebufferObject *fbo = renderToFBO(); - - float texWidth = width / float(fbo->width()); - float texHeight = refHeight / float(fbo->height()); - - GLfloat invVertices[] = { width, height + d->scale * refHeight + d->offset, - 0, height + d->scale * refHeight + d->offset, - width, height + d->offset, - 0, height + d->offset }; - GLfloat invTexVertices[] = { texWidth, texHeight, - 0, texHeight, - texWidth, 0, - 0, 0 }; - GLfloat invOpacity[] = { 0, 0, d->alpha * p.activeOpacity, d->alpha * p.activeOpacity}; - - glBindTexture(GL_TEXTURE_2D, fbo->texture()); - - SingleTextureVertexOpacityShader *shader = - item->basicShaders()->singleTextureVertexOpacity(); - shader->enable(); - shader->setTransform(p.activeTransform); - shader->setAttributeArray(SingleTextureVertexOpacityShader::Vertices, invVertices, 2); - shader->setAttributeArray(SingleTextureVertexOpacityShader::TextureCoords, invTexVertices, 2); - shader->setAttributeArray(SingleTextureVertexOpacityShader::OpacityCoords, invOpacity, 1); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - shader->disableAttributeArray(SingleTextureVertexOpacityShader::Vertices); - shader->disableAttributeArray(SingleTextureVertexOpacityShader::TextureCoords); - shader->disableAttributeArray(SingleTextureVertexOpacityShader::OpacityCoords); - - releaseFBO(fbo); - } - - renderToScreen(); - -#else - Q_UNUSED(p); -#endif -} - -QRectF QFxReflectionFilter::itemBoundingRect(const QRectF &r) const -{ - QRectF rv = r; - rv |= r.translated(0, r.height() + d->offset); - return rv; -} - -QML_DEFINE_TYPE(QFxReflectionFilter,Reflection) -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxreflectionfilter.h b/src/declarative/fx/qfxreflectionfilter.h deleted file mode 100644 index 6e56b5e..0000000 --- a/src/declarative/fx/qfxreflectionfilter.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXREFLECTIONFILTER_H -#define QFXREFLECTIONFILTER_H - -#include <QtDeclarative/qsimplecanvasfilter.h> -#include <QtDeclarative/qml.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QFxReflectionFilterPrivate; -class Q_DECLARATIVE_EXPORT QFxReflectionFilter : public QSimpleCanvasFilter -{ - Q_OBJECT - - Q_PROPERTY(qreal alpha READ alpha WRITE setAlpha NOTIFY alphaChanged) - Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) - Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged) - Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) -public: - QFxReflectionFilter(QObject *parent=0); - virtual ~QFxReflectionFilter(); - - qreal alpha() const; - void setAlpha(qreal); - int height() const; - void setHeight(int); - int offset(); - void setOffset(int); - qreal scale() const; - void setScale(qreal); - -Q_SIGNALS: - void alphaChanged(qreal); - void heightChanged(int); - void offsetChanged(int); - void scaleChanged(qreal); - -protected: - virtual void filterGL(QSimpleCanvasItem::GLPainter &p); - virtual QRectF itemBoundingRect(const QRectF &r) const; - -private: - Q_DISABLE_COPY(QFxReflectionFilter) - QFxReflectionFilterPrivate *d; -}; -QML_DECLARE_TYPE(QFxReflectionFilter) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QFXREFLECTIONFILTER_H diff --git a/src/declarative/fx/qfxshadowfilter.cpp b/src/declarative/fx/qfxshadowfilter.cpp deleted file mode 100644 index 10c332c..0000000 --- a/src/declarative/fx/qfxshadowfilter.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfxshadowfilter.h" - -#if defined(QFX_RENDER_OPENGL2) -#include <glsave.h> -#include <QtOpenGL/qglframebufferobject.h> -#include <glbasicshaders.h> -#endif - -class QFxShadowFilterPrivate - -QT_BEGIN_NAMESPACE -{ -public: - QFxShadowFilterPrivate() - : x(0), y(0) - { - } - - int x; - int y; -}; - -/*! - \qmlclass Shadow - \brief The Shadow filter casts a drop shadow. - \inherits Filter - - Shadows work on all visual elements - including transparent and masked - images. - - \table - \row - \o \image shadow_example.png - \o - \qml -Rect { - radius: 5 - color: "lightsteelblue" - width: 100 - height: 100 - filter: Shadow { - yOffset: 8 - xOffset: 8 - } -} - -Image { - source: "pics/qtlogo.png" - filter: Shadow { - yOffset: 8 - xOffset: 8 - } -} - \endqml - \endtable - - Shadows are only supported when Qt Qt Declarative is compiled for OpenGL ES 2.0. - Otherwise the Shadow filter has no effect. -*/ - -/*! - \internal - \class QFxShadowFilter - \ingroup group_effects - \brief The QFxShadowFilter class allows you to add a shadow to an item. -*/ - -QFxShadowFilter::QFxShadowFilter(QObject *parent) -: QSimpleCanvasFilter(parent), d(new QFxShadowFilterPrivate) -{ -} - -QFxShadowFilter::~QFxShadowFilter() -{ - delete d; d = 0; -} - -/*! - \qmlproperty int Shadow::xOffset - \qmlproperty int Shadow::yOffset - - Specify the x and y offset of the shadow relative to the item. -*/ - -int QFxShadowFilter::xOffset() const -{ - return d->x; -} - -/*! - \property QFxShadowFilter::xOffset - \brief the x offset of the shadow relative to the item. -*/ -void QFxShadowFilter::setXOffset(int offset) -{ - if (d->x == offset) return; - d->x = offset; - emit offsetChanged(d->x, d->y); -} - -/*! - \property QFxShadowFilter::yOffset - \brief the y offset of the shadow relative to the item. -*/ -int QFxShadowFilter::yOffset() const -{ - return d->y; -} - -void QFxShadowFilter::setYOffset(int offset) -{ - if (d->y == offset) return; - d->y = offset; - emit offsetChanged(d->x, d->y); -} - -QRectF QFxShadowFilter::itemBoundingRect(const QRectF &r) const -{ - QRectF rv = r; - rv |= r.translated(xOffset(), yOffset()); - return rv; -} - -void QFxShadowFilter::filterGL(QSimpleCanvasItem::GLPainter &p) -{ -#if defined(QFX_RENDER_OPENGL2) - - QSimpleCanvasItem *item = this->item(); - - QRect r = item->itemBoundingRect(); - - QGLFramebufferObject *fbo = renderToFBO(); - - float width = r.width(); - float height = r.height(); - - float texWidth = width / float(fbo->width()); - float texHeight = height / float(fbo->height()); - - GLfloat vertices[] = { d->x, height + d->y, - width + d->x, height + d->y, - d->x, d->y, - d->x + width, d->y }; - GLfloat texVertices[] = { 0, 0, - texWidth, 0, - 0, texHeight, - texWidth, texHeight }; - - SingleTextureShadowShader *shader = item->basicShaders()->singleTextureShadow(); - shader->enable(); - shader->setOpacity(0.8 * p.activeOpacity); - shader->setTransform(p.activeTransform); - - shader->setAttributeArray(SingleTextureShadowShader::Vertices, vertices, 2); - shader->setAttributeArray(SingleTextureShadowShader::TextureCoords, texVertices, 2); - - glBindTexture(GL_TEXTURE_2D, fbo->texture()); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - shader->disableAttributeArray(SingleTextureShadowShader::Vertices); - shader->disableAttributeArray(SingleTextureShadowShader::TextureCoords); - - releaseFBO(fbo); - - renderToScreen(); -#else - Q_UNUSED(p); -#endif -} - -QML_DEFINE_TYPE(QFxShadowFilter,Shadow) - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxshadowfilter.h b/src/declarative/fx/qfxshadowfilter.h deleted file mode 100644 index 67d165a..0000000 --- a/src/declarative/fx/qfxshadowfilter.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXSHADOWFILTER_H -#define QFXSHADOWFILTER_H - -#include <QtDeclarative/qsimplecanvasfilter.h> -#include <QtDeclarative/qml.h> - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QFxShadowFilterPrivate; -class Q_DECLARATIVE_EXPORT QFxShadowFilter : public QSimpleCanvasFilter -{ - Q_OBJECT - Q_PROPERTY(int xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged) - Q_PROPERTY(int yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged) -public: - QFxShadowFilter(QObject *parent=0); - virtual ~QFxShadowFilter(); - - int xOffset() const; - void setXOffset(int offset); - - int yOffset() const; - void setYOffset(int offset); - -Q_SIGNALS: - void offsetChanged(int, int); - -protected: - virtual QRectF itemBoundingRect(const QRectF &) const; - virtual void filterGL(QSimpleCanvasItem::GLPainter &p); - -private: - QFxShadowFilterPrivate *d; -}; -QML_DECLARE_TYPE(QFxShadowFilter) - - -QT_END_NAMESPACE - -QT_END_HEADER -#endif // _QFXSHADOWFILTER_H_ |