diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-06-19 05:58:16 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-06-19 05:58:16 (GMT) |
commit | 0b59aed42d27584ef3493305c565dd47f66d179d (patch) | |
tree | 5714e8f4fcd37e7500e85dfedb902fdf997eedae /src/declarative/fx | |
parent | bbdaf08826a9c93d2c0f56cbe064ee4c47a04f0f (diff) | |
download | Qt-0b59aed42d27584ef3493305c565dd47f66d179d.zip Qt-0b59aed42d27584ef3493305c565dd47f66d179d.tar.gz Qt-0b59aed42d27584ef3493305c565dd47f66d179d.tar.bz2 |
Remove OpenGL support from Fluid UI primitives
Diffstat (limited to 'src/declarative/fx')
26 files changed, 0 insertions, 1549 deletions
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 166ad58..801725d 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -2,7 +2,6 @@ HEADERS += \ fx/qfxanchors.h \ fx/qfxanchors_p.h \ fx/qfxanimatedimageitem.h \ - fx/qfxblendedimage.h \ fx/qfxcomponentinstance.h \ fx/qfxcomponentinstance_p.h \ fx/qfxcontentwrapper.h \ @@ -50,7 +49,6 @@ HEADERS += \ SOURCES += \ fx/qfxanchors.cpp \ fx/qfxanimatedimageitem.cpp \ - fx/qfxblendedimage.cpp \ fx/qfxcomponentinstance.cpp \ fx/qfxcontentwrapper.cpp \ fx/qfxevents.cpp \ diff --git a/src/declarative/fx/qfxblendedimage.cpp b/src/declarative/fx/qfxblendedimage.cpp deleted file mode 100644 index 0c93fef..0000000 --- a/src/declarative/fx/qfxblendedimage.cpp +++ /dev/null @@ -1,308 +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 "qfxblendedimage.h" -#include <QtDeclarative/qmlcontext.h> - -#if defined(QFX_RENDER_OPENGL2) -#include <glbasicshaders.h> -#endif - -QT_BEGIN_NAMESPACE - -/*! - \qmlclass BlendedImage - \brief The BlendedImage elements blends two different images depending on a blend ratio. - - This element can be used to simulate blur on slow devices by setting secondaryUrl with - a pre-rendered blurred version of primaryUrl. - - Note that this class will only work under OpenGL. On the software canvas it will display - only the primary image unless the blend is > 0.75, in which case it will display only the - secondary image. -*/ - -/*! - \internal - \class QFxBlendedImage - \brief The QFxBlendedImage blends two different images depending on a blend ratio. - - This class can be used to simulate blur on slow devices by setting secondaryUrl with - a pre-rendered blurred version of primaryUrl. - - Note that this class will only work under OpenGL. On the software canvas it will display - only the primary image unless the blend is > 0.75, in which case it will display only the - secondary image. -*/ -QFxBlendedImage::QFxBlendedImage(QFxItem *parent) -: QFxItem(parent), _blend(0), _smooth(false), dirty(false) -{ -#if defined(QFX_RENDER_OPENGL2) - setOptions(HasContents); -#endif -} - -/*! - Cancels any pending image loads and destroys the image. -*/ -QFxBlendedImage::~QFxBlendedImage() -{ - if (!primUrl.isEmpty()) - QFxPixmap::cancelGet(primUrl,this); - if (!secUrl.isEmpty()) - QFxPixmap::cancelGet(secUrl,this); -} - -/*! - \qmlproperty string BlendedImage::primaryUrl - The URL of the first image to be displayed in this item. -*/ -QUrl QFxBlendedImage::primaryUrl() const -{ - return primUrl; -} - -void QFxBlendedImage::primaryLoaded() -{ - primPix = QFxPixmap(primUrl); - dirty = true; - update(); -} - -void QFxBlendedImage::setPrimaryUrl(const QUrl &url) -{ - if (primUrl == url) - return; - if (!primUrl.isEmpty()) - QFxPixmap::cancelGet(primUrl,this); - Q_ASSERT(!url.isRelative()); - primUrl = url; - if (!primUrl.isEmpty()) - QFxPixmap::get(qmlEngine(this), primUrl,this,SLOT(primaryLoaded())); -} - -/*! - \qmlproperty string BlendedImage::secondaryUrl - The URL of the second image to be displayed in this item. -*/ -QUrl QFxBlendedImage::secondaryUrl() const -{ - return secUrl; -} - -void QFxBlendedImage::secondaryLoaded() -{ - secPix = QFxPixmap(secUrl); - dirty = true; - update(); -} - -void QFxBlendedImage::setSecondaryUrl(const QUrl &url) -{ - if (secUrl == url) - return; - if (!secUrl.isEmpty()) - QFxPixmap::cancelGet(secUrl,this); - Q_ASSERT(!url.isRelative()); - secUrl = url; - if (!secUrl.isEmpty()) - QFxPixmap::get(qmlEngine(this), secUrl,this,SLOT(secondaryLoaded())); -} - -/*! - \qmlproperty real BlendedImage::blend - The ratio used to blend the two images. - - If blend has a value of 0, only the first image will be displayed. - If blend has a value of 1, only the second image will be displayed. -*/ -qreal QFxBlendedImage::blend() const -{ - return _blend; -} - -void QFxBlendedImage::setBlend(qreal b) -{ - _blend = b; - update(); -} - -/*! - \qmlproperty bool BlendedImage::smooth - - Set this property if you want the image to be smoothly filtered when scaled or - transformed. Smooth filtering gives better visual quality, but is slower. If - the BlendedImage is displayed at its natural size, this property has no visual or - performance effect. - - \note Generally scaling artifacts are only visible if the image is stationary on - the screen. A common pattern when animating an image is to disable smooth - filtering at the beginning of the animation and reenable it at the conclusion. - */ -bool QFxBlendedImage::smoothTransform() const -{ - return _smooth; -} - -void QFxBlendedImage::setSmoothTransform(bool s) -{ - if (_smooth == s) - return; - _smooth = s; - update(); -} - -#if defined(QFX_RENDER_QPAINTER) - -void QFxBlendedImage::paintContents(QPainter &p) -{ - if (primUrl.isEmpty() && secUrl.isEmpty()) - return; - - if (_smooth) { - p.save(); - p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, _smooth); - } - - if (_blend < 0.75) - p.drawPixmap(0, 0, primPix); - else - p.drawPixmap(0, 0, secPix); - - if (_smooth) { - p.restore(); - } -} - -#elif defined(QFX_RENDER_OPENGL2) - -void QFxBlendedImage::paintGLContents(GLPainter &p) -{ - static DualTextureBlendShader *shader = 0; - if (!shader) - shader = new DualTextureBlendShader(); - - if (dirty) { - prim.clear(); - sec.clear(); - prim.setImage(primPix.toImage()); - sec.setImage(secPix.toImage()); - - dirty = false; - } - - if (prim.isNull() || sec.isNull()) { - - return; - } - - GLfloat vertices[8]; - GLfloat texVertices[8]; - - float widthV = width(); - float heightV = height(); - if (!widthV) - widthV = qMax(primPix.width(), secPix.width()); - if (!heightV) - heightV = qMax(primPix.height(), secPix.height()); - - vertices[0] = 0; vertices[1] = heightV; - vertices[2] = widthV; vertices[3] = heightV; - vertices[4] = 0; vertices[5] = 0; - vertices[6] = widthV; vertices[7] = 0; - - texVertices[0] = 0; texVertices[1] = 0; - texVertices[2] = 1; texVertices[3] = 0; - texVertices[4] = 0; texVertices[5] = 1; - texVertices[6] = 1; texVertices[7] = 1; - - if (_blend == 0 || _blend == 1) { - QGLShaderProgram *tshader = p.useTextureShader(); - - GLTexture *tex = 0; - - if (_blend == 0) - tex = &prim; - else - tex = &sec; - - tshader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2); - tshader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2); - - glBindTexture(GL_TEXTURE_2D, tex->texture()); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - tshader->disableAttributeArray(SingleTextureShader::Vertices); - tshader->disableAttributeArray(SingleTextureShader::TextureCoords); - } else { - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, prim.texture()); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, sec.texture()); - - shader->enable(); - shader->setOpacity(1); - qreal b = _blend; - if (b > 1) b = 1; - else if (b < 0) b = 0; - shader->setBlend(b); - shader->setTransform(p.activeTransform); - - shader->setAttributeArray(DualTextureBlendShader::Vertices, vertices, 2); - shader->setAttributeArray(DualTextureBlendShader::TextureCoords, texVertices, 2); - shader->setAttributeArray(DualTextureBlendShader::BlendTextureCoords, texVertices, 2); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - shader->disableAttributeArray(DualTextureBlendShader::Vertices); - shader->disableAttributeArray(DualTextureBlendShader::TextureCoords); - shader->disableAttributeArray(DualTextureBlendShader::BlendTextureCoords); - - glBindTexture(GL_TEXTURE_2D, 0); - glActiveTexture(GL_TEXTURE0); - } -} -#endif - -QML_DEFINE_TYPE(QFxBlendedImage,BlendedImage) - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxblendedimage.h b/src/declarative/fx/qfxblendedimage.h deleted file mode 100644 index 248cc9d..0000000 --- a/src/declarative/fx/qfxblendedimage.h +++ /dev/null @@ -1,110 +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 QFXBLENDEDIMAGE_H -#define QFXBLENDEDIMAGE_H - -#include <QtDeclarative/qfxitem.h> -#if defined(QFX_RENDER_OPENGL2) -#include <gltexture.h> -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class Q_DECLARATIVE_EXPORT QFxBlendedImage : public QFxItem -{ - Q_OBJECT - - Q_PROPERTY(QUrl primaryUrl READ primaryUrl WRITE setPrimaryUrl) - Q_PROPERTY(QUrl secondaryUrl READ secondaryUrl WRITE setSecondaryUrl) - Q_PROPERTY(qreal blend READ blend WRITE setBlend) - Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform) -public: - QFxBlendedImage(QFxItem *parent=0); - ~QFxBlendedImage(); - - QUrl primaryUrl() const; - void setPrimaryUrl(const QUrl &); - - QUrl secondaryUrl() const; - void setSecondaryUrl(const QUrl &); - - qreal blend() const; - void setBlend(qreal); - - bool smoothTransform() const; - void setSmoothTransform(bool); - -#if defined(QFX_RENDER_QPAINTER) - void paintContents(QPainter &painter); -#elif defined(QFX_RENDER_OPENGL2) - void paintGLContents(GLPainter &); -#endif - -private Q_SLOTS: - void primaryLoaded(); - void secondaryLoaded(); - -private: - QUrl primUrl; - QUrl secUrl; - - qreal _blend; - bool _smooth; - bool dirty; -#if defined(QFX_RENDER_OPENGL2) - GLTexture prim; - GLTexture sec; -#endif - QPixmap primPix; - QPixmap secPix; -}; -QML_DECLARE_TYPE(QFxBlendedImage) - - -QT_END_NAMESPACE - -QT_END_HEADER -#endif // QFXBLENDEDIMAGE_H diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp index 4c02e74..0957c2f 100644 --- a/src/declarative/fx/qfxflipable.cpp +++ b/src/declarative/fx/qfxflipable.cpp @@ -220,21 +220,12 @@ void QFxFlipablePrivate::setBackTransform() axisRotation.setAngle(rotation); QSimpleCanvas::Matrix mat; -#ifdef QFX_RENDER_OPENGL - mat.translate(back->width()/2,back->height()/2, 0); - if (back->width() && p1.x() >= p2.x()) - mat.rotate(180, 0, 1, 0); - if (back->height() && p2.y() >= p3.y()) - mat.rotate(180, 1, 0, 0); - mat.translate(-back->width()/2,-back->height()/2, 0); -#else mat.translate(back->width()/2,back->height()/2); if (back->width() && p1.x() >= p2.x()) mat.rotate(180, Qt::YAxis); if (back->height() && p2.y() >= p3.y()) mat.rotate(180, Qt::XAxis); mat.translate(-back->width()/2,-back->height()/2); -#endif back->setTransform(mat); } @@ -318,21 +309,12 @@ void QFxFlipable::transformChanged(const QSimpleCanvas::Matrix &trans) d->current = newSide; if (d->current==Back) { QSimpleCanvas::Matrix mat; -#ifdef QFX_RENDER_OPENGL - mat.translate(d->back->width()/2,d->back->height()/2, 0); - if (d->back->width() && p1.x() >= p2.x()) - mat.rotate(180, 0, 1, 0); - if (d->back->height() && p2.y() >= p3.y()) - mat.rotate(180, 1, 0, 0); - mat.translate(-d->back->width()/2,-d->back->height()/2, 0); -#else mat.translate(d->back->width()/2,d->back->height()/2); if (d->back->width() && p1.x() >= p2.x()) mat.rotate(180, Qt::YAxis); if (d->back->height() && p2.y() >= p3.y()) mat.rotate(180, Qt::XAxis); mat.translate(-d->back->width()/2,-d->back->height()/2); -#endif d->back->setTransform(mat); } if (d->front) diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h index 6630633..f00e023 100644 --- a/src/declarative/fx/qfxflipable.h +++ b/src/declarative/fx/qfxflipable.h @@ -44,9 +44,6 @@ #include <QtCore/QObject> #include <QtGui/QTransform> -#if defined(QFX_RENDER_OPENGL) -#include <QtGui/qmatrix4x4.h> -#endif #include <QtDeclarative/qfxitem.h> QT_BEGIN_HEADER diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 40389c4..2ac035d 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -42,9 +42,6 @@ #include "qfximage.h" #include "qfximage_p.h" #include <qfxperf.h> -#if defined(QFX_RENDER_OPENGL) -#include <glsave.h> -#endif #include <QNetworkRequest> #include <QNetworkReply> #include <QFile> @@ -131,12 +128,6 @@ QFxImage::~QFxImage() QFxPixmap::cancelGet(d->url, this); if (!d->sciurl.isEmpty()) QFxPixmap::cancelGet(d->sciurl, this); -#if defined(QFX_RENDER_OPENGL) - if (d->tex) { - d->tex->release(); - d->tex = 0; - } -#endif } /*! @@ -164,13 +155,6 @@ void QFxImage::setPixmap(const QPixmap &pix) setImplicitWidth(d->pix.width()); setImplicitHeight(d->pix.height()); -#if defined(QFX_RENDER_OPENGL) - d->texDirty = true; - if (d->tex) { - d->tex->release(); - d->tex = 0; - } -#endif update(); } @@ -329,7 +313,6 @@ void QFxImage::dump(int depth) QFxItem::dump(depth); } -#if defined(QFX_RENDER_QPAINTER) void QFxImage::paintContents(QPainter &p) { Q_D(QFxImage); @@ -431,333 +414,6 @@ void QFxImage::paintContents(QPainter &p) if (d->smooth) p.setRenderHints(oldHints); } -#elif defined(QFX_RENDER_OPENGL) -uint QFxImage::glSimpleItemData(float *vertices, float *texVertices, - GLTexture **texture, uint count) -{ - Q_D(QFxImage); - - if (d->pix.isNull() || (d->scaleGrid && !d->scaleGrid->isNull())) - return 0; - - if (count < 8) - return 8; - - d->checkDirty(); - - float widthV = width(); - float heightV = height(); - - vertices[0] = 0; vertices[1] = heightV; - vertices[2] = widthV; vertices[3] = heightV; - vertices[4] = 0; vertices[5] = 0; - vertices[6] = widthV; vertices[7] = 0; - - *texture = d->tex; - - if (d->tiled) { - float tileWidth = widthV / d->pix.width(); - float tileHeight = heightV / d->pix.height(); - texVertices[0] = 0; texVertices[1] = 0; - texVertices[2] = tileWidth; texVertices[3] = 0; - texVertices[4] = 0; texVertices[5] = tileHeight; - texVertices[6] = tileWidth; texVertices[7] = tileHeight; - } else { - texVertices[0] = 0; texVertices[1] = 0; - texVertices[2] = d->tex->glWidth(); texVertices[3] = 0; - texVertices[4] = 0; texVertices[5] = d->tex->glHeight(); - texVertices[6] = d->tex->glWidth(); texVertices[7] = d->tex->glHeight(); - } - - return 8; -} - -void QFxImagePrivate::checkDirty() -{ - Q_Q(QFxImage); - if (texDirty && !pix.isNull()) - tex = q->cachedTexture(url.toString(), pix); - texDirty = false; -} - -#if defined(QFX_RENDER_OPENGL2) -void QFxImage::paintGLContents(GLPainter &p) -{ - Q_D(QFxImage); - if (d->pix.isNull()) - return; - - QGLShaderProgram *shader = p.useTextureShader(); - - bool restoreBlend = false; - if (p.blendEnabled && isOpaque() && p.activeOpacity == 1) { - glDisable(GL_BLEND); - restoreBlend = true; - } - - d->checkDirty(); - - if (d->tiled || (!d->scaleGrid || d->scaleGrid->isNull())) { - - if (!d->tiled) { - - float widthV = width(); - float heightV = height(); - float glWidth = d->tex->glWidth(); - float glHeight = d->tex->glHeight(); - - float deltaX = 0.5 / qreal(d->tex->glSize().width()); - float deltaY = 0.5 / qreal(d->tex->glSize().height()); - glWidth -= deltaX; - glHeight -= deltaY; - - - float vert[] = { - 0, heightV, - widthV, heightV, - 0, 0, - - widthV, heightV, - 0, 0, - widthV, 0 }; - - float tex[] = { - deltaX, deltaY, - glWidth, deltaY, - deltaX, glHeight, - - glWidth, deltaY, - deltaX, glHeight, - glWidth, glHeight - }; - - shader->setAttributeArray(SingleTextureShader::Vertices, vert, 2); - shader->setAttributeArray(SingleTextureShader::TextureCoords, tex, 2); - glBindTexture(GL_TEXTURE_2D, d->tex->texture()); - glDrawArrays(GL_TRIANGLES, 0, 6); - - } else { - - GLfloat vertices[8]; - GLfloat texVertices[8]; - GLTexture *tex = 0; - - QFxImage::glSimpleItemData(vertices, texVertices, &tex, 8); - - shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2); - shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2); - - glBindTexture(GL_TEXTURE_2D, tex->texture()); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } - - } else { - - float imgWidth = d->pix.width(); - float imgHeight = d->pix.height(); - if (!imgWidth || !imgHeight) { - if (restoreBlend) - glEnable(GL_BLEND); - return; - } - - float widthV = width(); - float heightV = height(); - float glWidth = d->tex->glWidth(); - float glHeight = d->tex->glHeight(); - float deltaX = 0.5 / qreal(d->tex->glSize().width()); - float deltaY = 0.5 / qreal(d->tex->glSize().height()); - glHeight -= deltaY; - glWidth -= deltaX; - - float texleft = deltaX; - float texright = glWidth; - float textop = glHeight; - float texbottom = deltaY; - float imgleft = 0; - float imgright = widthV; - float imgtop = 0; - float imgbottom = heightV; - - const int sgl = d->scaleGrid->left(); - const int sgr = d->scaleGrid->right(); - const int sgt = d->scaleGrid->top(); - const int sgb = d->scaleGrid->bottom(); - - if (sgl) { - texleft = deltaX + d->tex->glWidth() * float(sgl) / imgWidth; - imgleft = sgl; - } - if (sgr) { - texright = d->tex->glWidth() - float(sgr) / imgWidth - deltaX; - imgright = widthV - sgr; - } - if (sgt) { - textop = d->tex->glHeight() - float(sgb) / imgHeight - deltaY; - imgtop = sgt; - } - if (sgb) { - texbottom = deltaY + d->tex->glHeight() * float(sgt) / imgHeight; - imgbottom = heightV - sgb; - } - - float vert1[] = { 0, 0, - 0, imgtop, - imgleft, 0, - - 0, imgtop, - imgleft, 0, - imgleft, imgtop, - - imgleft, 0, - imgleft, imgtop, - imgright, 0, - - imgleft, imgtop, - imgright, 0, - imgright, imgtop, - - imgright, 0, - imgright, imgtop, - widthV, 0, - - imgright, imgtop, - widthV, 0, - widthV, imgtop, - - 0, imgtop, - 0, imgbottom, - imgleft, imgtop, - - 0, imgbottom, - imgleft, imgtop, - imgleft, imgbottom, - - imgleft, imgtop, - imgleft, imgbottom, - imgright, imgtop, - - imgleft, imgbottom, - imgright, imgtop, - imgright, imgbottom, - - imgright, imgtop, - imgright, imgbottom, - widthV, imgtop, - - imgright, imgbottom, - widthV, imgtop, - widthV, imgbottom, - - 0, imgbottom, - 0, heightV, - imgleft, imgbottom, - - 0, heightV, - imgleft, imgbottom, - imgleft, heightV, - - imgleft, imgbottom, - imgleft, heightV, - imgright, imgbottom, - - imgleft, heightV, - imgright, imgbottom, - imgright, heightV, - - imgright, imgbottom, - imgright, heightV, - widthV, imgbottom, - - imgright, heightV, - widthV, imgbottom, - widthV, heightV }; - - float tex1[] = { deltaX, glHeight, - deltaX, textop, - texleft, glHeight, - - deltaX, textop, - texleft, glHeight, - texleft, textop, - - texleft, glHeight, - texleft, textop, - texright, glHeight, - - texleft, textop, - texright, glHeight, - texright, textop, - - texright, glHeight, - texright, textop, - glWidth, glHeight, - - texright, textop, - glWidth, glHeight, - glWidth, textop, - - deltaX, textop, - deltaX, texbottom, - texleft, textop, - - deltaX, texbottom, - texleft, textop, - texleft, texbottom, - - texleft, textop, - texleft, texbottom, - texright, textop, - - texleft, texbottom, - texright, textop, - texright, texbottom, - - texright, textop, - texright, texbottom, - glWidth, textop, - - texright, texbottom, - glWidth, textop, - glWidth, texbottom, - - deltaX, texbottom, - deltaX, deltaY, - texleft, texbottom, - - deltaX, deltaY, - texleft, texbottom, - texleft, deltaY, - - texleft, texbottom, - texleft, deltaY, - texright, texbottom, - - texleft, deltaY, - texright, texbottom, - texright, deltaY, - - texright, texbottom, - texright, deltaY, - glWidth, texbottom, - - texright, deltaY, - glWidth, texbottom, - glWidth, deltaY }; - - glBindTexture(GL_TEXTURE_2D, d->tex->texture()); - - shader->setAttributeArray(SingleTextureShader::Vertices, vert1, 2); - shader->setAttributeArray(SingleTextureShader::TextureCoords, tex1, 2); - glDrawArrays(GL_TRIANGLES, 0, 54); - } - - if (restoreBlend) - glEnable(GL_BLEND); -} -#endif - -#endif QString QFxImage::propertyInfo() const { @@ -867,13 +523,6 @@ void QFxImage::setSource(const QUrl &url) d->progress = 1.0; setImplicitWidth(0); setImplicitHeight(0); -#if defined(QFX_RENDER_OPENGL) - d->texDirty = true; - if (d->tex) { - d->tex->release(); - d->tex = 0; - } -#endif emit statusChanged(d->status); emit sourceChanged(d->url); emit progressChanged(1.0); @@ -931,13 +580,6 @@ void QFxImage::requestFinished() if (d->status == Loading) d->status = Idle; d->progress = 1.0; -#if defined(QFX_RENDER_OPENGL) - d->texDirty = true; - if (d->tex) { - d->tex->release(); - d->tex = 0; - } -#endif emit statusChanged(d->status); emit sourceChanged(d->url); emit progressChanged(1.0); diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h index 35b921a..039334a 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -93,13 +93,7 @@ public: virtual void dump(int depth); virtual QString propertyInfo() const; -#if defined(QFX_RENDER_QPAINTER) void paintContents(QPainter &painter); -#elif defined(QFX_RENDER_OPENGL) - void paintGLContents(GLPainter &); - uint glSimpleItemData(float *vertices, float *texVertices, - GLTexture **texture, uint count); -#endif Q_SIGNALS: void sourceChanged(const QUrl &); diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h index 1785abb..e4a3a90 100644 --- a/src/declarative/fx/qfximage_p.h +++ b/src/declarative/fx/qfximage_p.h @@ -55,10 +55,6 @@ #include "qfxitem_p.h" -#if defined(QFX_RENDER_OPENGL) -#include "gltexture.h" -#endif - QT_BEGIN_NAMESPACE class QSvgRenderer; @@ -73,9 +69,6 @@ class QFxImagePrivate : public QFxItemPrivate public: QFxImagePrivate() : scaleGrid(0), tiled(false), smooth(false), opaque(false), -#if defined(QFX_RENDER_OPENGL) - texDirty(true), tex(0), -#endif status(QFxImage::Idle), sciReply(0), progress(0.0) { } @@ -99,11 +92,6 @@ public: bool tiled : 1; bool smooth : 1; bool opaque : 1; -#if defined(QFX_RENDER_OPENGL) - bool texDirty : 1; - void checkDirty(); - QSimpleCanvasItem::CachedTexture *tex; -#endif QFxImage::Status status; QUrl url; diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 079d691..b4de109 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -62,7 +62,6 @@ #include "qfxitem_p.h" #include "qfxitem.h" #include "qfxevents_p.h" -#include <qsimplecanvasfilter.h> #include <qmlcomponent.h> @@ -73,7 +72,6 @@ QT_BEGIN_NAMESPACE QML_DEFINE_NOCREATE_TYPE(QFxContents) QML_DEFINE_TYPE(QFxItem,Item) -QML_DEFINE_NOCREATE_TYPE(QSimpleCanvasFilter) /*! \group group_animation @@ -1483,18 +1481,10 @@ void QFxItem::setRotation(qreal rotation) if (d->_rotation == rotation) return; d->_rotation = rotation; -#if defined(QFX_RENDER_OPENGL) - QMatrix4x4 trans; - QPointF to = transformOriginPoint(); - trans.translate(to.x(), to.y()); - trans.rotate(d->_rotation, 0, 0, 1); - trans.translate(-to.x(), -to.y()); -#else QPointF to = d->transformOrigin(); QTransform trans = QTransform::fromTranslate(to.x(), to.y()); trans.rotate(d->_rotation); trans.translate(-to.x(), -to.y()); -#endif setTransform(trans); emit rotationChanged(); } diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 3c872e1..3188516 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -131,7 +131,6 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) - Q_PROPERTY(QSimpleCanvasFilter *filter READ filter WRITE setFilter) Q_PROPERTY(bool clip READ clip WRITE setClip) Q_PROPERTY(bool focusable READ isFocusable WRITE setFocusable) Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged) @@ -269,8 +268,6 @@ private: }; QML_DECLARE_TYPE(QFxItem) -QML_DECLARE_TYPE(QSimpleCanvasFilter) - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 44adba7..850f20a 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -49,11 +49,6 @@ #include <QApplication> #include <QGraphicsSceneMouseEvent> -#if defined(QFX_RENDER_OPENGL2) -#include <QtOpenGL/qglframebufferobject.h> -#include <glsave.h> -#endif - QT_BEGIN_NAMESPACE /*! @@ -211,26 +206,16 @@ void QFxPaintedItem::init() connect(this,SIGNAL(visibleChanged()),this,SLOT(clearCache())); } -#if defined(QFX_RENDER_QPAINTER) /*! \reimp */ void QFxPaintedItem::paintContents(QPainter &p) -#elif defined(QFX_RENDER_OPENGL) -/*! - \reimp -*/ -void QFxPaintedItem::paintGLContents(GLPainter &p) -#else -#error "What render?" -#endif { Q_D(QFxPaintedItem); const QRect content(QPoint(0,0),d->contentsSize); if (content.width() <= 0 || content.height() <= 0) return; -#if defined(QFX_RENDER_QPAINTER) bool oldAntiAliasing = p.testRenderHint(QPainter::Antialiasing); bool oldSmoothPixmap = p.testRenderHint(QPainter::SmoothPixmapTransform); if (d->smooth) { @@ -243,29 +228,12 @@ void QFxPaintedItem::paintGLContents(GLPainter &p) else clipf = mapToScene(clipf); -#elif defined(QFX_RENDER_OPENGL2) - p.useTextureShader(); - const QRectF clipf = p.sceneClipRect; - -#elif defined(QFX_RENDER_OPENGL1) - p.useTextureShader(); - const QRectF clipf = p.sceneClipRect; -#endif - const QRect clip = mapFromScene(clipf).toRect(); QRegion topaint(clip); topaint &= content; QRegion uncached(content); -#if defined(QFX_RENDER_OPENGL2) - glEnableVertexAttribArray(SingleTextureShader::Vertices); - glEnableVertexAttribArray(SingleTextureShader::TextureCoords); -#elif defined(QFX_RENDER_OPENGL1) - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); -#endif - int cachesize=0; for (int i=0; i<d->imagecache.count(); ++i) { QRect area = d->imagecache[i]->area; @@ -312,29 +280,16 @@ void QFxPaintedItem::paintGLContents(GLPainter &p) } QFxPaintedItemPrivate::ImageCacheItem *newitem = new QFxPaintedItemPrivate::ImageCacheItem; newitem->area = r; -#if defined(QFX_RENDER_QPAINTER) newitem->image = img; -#else - newitem->image.setImage(img.toImage()); -#endif d->imagecache.append(newitem); QRectF target(r.x(), r.y(), r.width(), r.height()); p.drawPixmap(target.toRect(), newitem->image); } } -#if defined(QFX_RENDER_OPENGL2) - glDisableVertexAttribArray(SingleTextureShader::Vertices); - glDisableVertexAttribArray(SingleTextureShader::TextureCoords); -#elif defined(QFX_RENDER_OPENGL1) - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); -#endif -#if defined(QFX_RENDER_QPAINTER) if (d->smooth) { p.setRenderHints(QPainter::Antialiasing, oldAntiAliasing); p.setRenderHints(QPainter::SmoothPixmapTransform, oldSmoothPixmap); } -#endif } QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h index e086894..ed254ce 100644 --- a/src/declarative/fx/qfxpainteditem.h +++ b/src/declarative/fx/qfxpainteditem.h @@ -63,11 +63,7 @@ public: Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize) Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth) -#if defined(QFX_RENDER_QPAINTER) void paintContents(QPainter &painter); -#elif defined(QFX_RENDER_OPENGL) - void paintGLContents(GLPainter &); -#endif bool isSmooth() const; QSize contentsSize() const; diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h index d8d1a2a..ec507fb 100644 --- a/src/declarative/fx/qfxpainteditem_p.h +++ b/src/declarative/fx/qfxpainteditem_p.h @@ -56,10 +56,6 @@ #include <private/qfxitem_p.h> #include <QtDeclarative/qsimplecanvas.h> -#if defined(QFX_RENDER_OPENGL) -#include "gltexture.h" -#endif - QT_BEGIN_NAMESPACE class QFxPaintedItemPrivate : public QFxItemPrivate @@ -77,11 +73,7 @@ public: ~ImageCacheItem() { } int age; QRect area; -#if defined(QFX_RENDER_QPAINTER) QPixmap image; -#else - GLTexture image; -#endif }; QList<ImageCacheItem*> imagecache; diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp index 4cd34c4..5e84c88 100644 --- a/src/declarative/fx/qfxparticles.cpp +++ b/src/declarative/fx/qfxparticles.cpp @@ -40,9 +40,6 @@ ****************************************************************************/ #include "qfxitem_p.h" -#if defined(QFX_RENDER_OPENGL) -#include "gltexture.h" -#endif #include <stdlib.h> #include <math.h> @@ -350,11 +347,7 @@ public: maxX = minX = maxY = minY = 0; } -#if defined(QFX_RENDER_QPAINTER) void paintContents(QPainter &p); -#elif defined(QFX_RENDER_OPENGL2) - void paintGLContents(GLPainter &); -#endif void updateSize(); @@ -375,9 +368,6 @@ public: , angle(0), angleDev(0), velocity(0), velocityDev(0) , addParticleTime(0), addParticleCount(0), lastAdvTime(0), stream(false), streamDelay(0) , emitting(true), motion(0), clock(this) -#if defined(QFX_RENDER_OPENGL) - , texDirty(true) -#endif { } @@ -418,10 +408,6 @@ public: QList<QFxParticle> particles; QTickAnimationProxy<QFxParticlesPrivate, &QFxParticlesPrivate::tick> clock; -#if defined(QFX_RENDER_OPENGL) - bool texDirty; - GLTexture tex; -#endif }; //TODO: Stop the clock if no visible particles and not emitting (restart on emittingChanged) @@ -654,10 +640,6 @@ void QFxParticles::imageLoaded() { Q_D(QFxParticles); d->image = QFxPixmap(d->url); -#if defined(QFX_RENDER_OPENGL) - d->texDirty = true; - d->tex.clear(); -#endif update(); } @@ -673,10 +655,6 @@ void QFxParticles::setSource(const QUrl &name) if (name.isEmpty()) { d->url = name; d->image = QPixmap(); -#if defined(QFX_RENDER_OPENGL) - d->texDirty = true; - d->tex.clear(); -#endif update(); } else { d->url = name; @@ -1106,7 +1084,6 @@ void QFxParticlesPainter::updateSize(){ setY(myY); } -#if defined(QFX_RENDER_QPAINTER) void QFxParticles::paintContents(QPainter &p) { Q_UNUSED(p); @@ -1129,64 +1106,6 @@ void QFxParticlesPainter::paintContents(QPainter &p) } update();//Should I need this? (GV does) } -#elif defined(QFX_RENDER_OPENGL2) -void QFxParticles::paintGLContents(GLPainter &) -{ - //painting is done by the ParticlesPainter, so it can have the right size -} - -void QFxParticlesPainter::paintGLContents(GLPainter &p) -{ - - if (d->image.isNull()) - return; - - updateSize(); - - if (d->texDirty && !d->image.isNull()) { - d->tex.setImage(d->image.toImage()); - d->tex.setHorizontalWrap(GLTexture::Repeat); - d->tex.setVerticalWrap(GLTexture::Repeat); - } - d->texDirty = false; - - SingleTextureOpacityShader *shader = basicShaders()->singleTextureOpacity(); - shader->enable(); - shader->setTransform(p.activeTransform); - - glBindTexture(GL_TEXTURE_2D, d->tex.texture()); - - const int myX = (int)(x() + parent()->x()); - const int myY = (int)(y() + parent()->y()); - float widthV = d->image.width(); - float heightV = d->image.height(); - for (int i = 0; i < d->particles.count(); ++i) { - const QFxParticle &particle = d->particles.at(i); - float left = particle.x - myX; - float right = particle.x - myX + widthV; - float top = particle.y - myY; - float bottom = particle.y - myY + heightV; - - GLfloat vertices[] = { left, bottom, - right, bottom, - left, top, - right, top }; - - GLfloat texVertices[] = { 0, 0, - 1, 0, - 0, 1, - 1, 1 }; - - shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2); - shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2); - shader->setOpacity(particle.opacity * p.activeOpacity); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } - - shader->disableAttributeArray(SingleTextureShader::Vertices); - shader->disableAttributeArray(SingleTextureShader::TextureCoords); -} -#endif void QFxParticles::componentComplete() { diff --git a/src/declarative/fx/qfxparticles.h b/src/declarative/fx/qfxparticles.h index b3a569b..a0373d7 100644 --- a/src/declarative/fx/qfxparticles.h +++ b/src/declarative/fx/qfxparticles.h @@ -44,10 +44,6 @@ #include <QtDeclarative/qfxitem.h> -#if defined(QFX_RENDER_OPENGL) -#include "gltexture.h" -#endif - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -214,11 +210,7 @@ public: virtual void dump(int depth); virtual QString propertyInfo() const; -#if defined(QFX_RENDER_QPAINTER) void paintContents(QPainter &p); -#elif defined(QFX_RENDER_OPENGL2) - void paintGLContents(GLPainter &); -#endif protected: virtual void componentComplete(); diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index fd8d9ca..03ab426 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -251,17 +251,8 @@ QFxRect::QFxRect(QFxRectPrivate &dd, QFxItem *parent) void QFxRect::doUpdate() { -#if defined(QFX_RENDER_QPAINTER) Q_D(QFxRect); d->rectImage = QPixmap(); -#endif -#if defined(QFX_RENDER_OPENGL) - Q_D(QFxRect); - if (d->rectTexture) { - d->rectTexture->release(); - d->rectTexture = 0; - } -#endif const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; setPaintMargin((pw+1)/2); update(); @@ -361,14 +352,7 @@ void QFxRect::setRadius(qreal radius) return; d->radius = radius; -#if defined(QFX_RENDER_QPAINTER) d->rectImage = QPixmap(); -#elif defined(QFX_RENDER_OPENGL) - if (d->rectTexture) { - d->rectTexture->release(); - d->rectTexture = 0; - } -#endif update(); } @@ -412,15 +396,7 @@ void QFxRect::setColor(const QColor &c) return; d->color = c; -#if defined(QFX_RENDER_QPAINTER) d->rectImage = QPixmap(); -#endif -#if defined(QFX_RENDER_OPENGL) - if (d->rectTexture) { - d->rectTexture->release(); - d->rectTexture = 0; - } -#endif update(); } @@ -488,7 +464,6 @@ QColor QFxRectPrivate::getColor() } -#if defined(QFX_RENDER_QPAINTER) void QFxRect::generateRoundedRect() { Q_D(QFxRect); @@ -528,65 +503,7 @@ void QFxRect::generateBorderedRect() p.drawRect(qreal(pw+1)/2, qreal(pw+1)/2, d->rectImage.width()-(pw+1)/2*2, d->rectImage.height()-(pw+1)/2*2); } } -#elif defined(QFX_RENDER_OPENGL) -void QFxRect::generateRoundedRect() -{ - Q_D(QFxRect); - if (!d->rectTexture) { - const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; - QString key = QString("QFxRect://r_%1_%2_%3_%4").arg(pw).arg(d->radius).arg((d->pen && d->pen->isValid())?d->pen->color().name():QString()).arg(d->color.name()); - - d->rectTexture = cachedTexture(key); - - if (!d->rectTexture) { - QPixmap roundRect(d->radius*2 + 4 + pw*2, d->radius*2 + 4 + pw*2); - roundRect.fill(Qt::transparent); - QPainter p(&roundRect); - p.setRenderHint(QPainter::Antialiasing); - if (d->pen && d->pen->isValid()) { - QPen pn(QColor(pen()->color()), pen()->width()); - p.setPen(pn); - } else { - p.setPen(Qt::NoPen); - } - p.setBrush(d->color); - p.drawRoundedRect((pw+1)/2, (pw+1)/2, roundRect.width()-(pw+1)/2*2, roundRect.height()-(pw+1)/2*2, d->radius, d->radius); - - d->rectTexture = cachedTexture(key, roundRect); - } - } -} -void QFxRect::generateBorderedRect() -{ - Q_D(QFxRect); - if (!d->rectTexture) { - const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; - QString key = QString("QFxRect://b_%1_%2_%3_%4").arg(pw).arg(d->radius).arg((d->pen && d->pen->isValid())?d->pen->color().name():QString()).arg(d->color.name()); - - d->rectTexture = cachedTexture(key); - - if (!d->rectTexture) { - QPixmap borderedRect(pw*2 + 4, pw*2 + 4); - borderedRect.fill(Qt::transparent); - QPainter p(&(borderedRect)); - p.setRenderHint(QPainter::Antialiasing); - if (d->pen && d->pen->isValid()) { - QPen pn(QColor(pen()->color()), pen()->width()); - p.setPen(pn); - } else { - p.setPen(Qt::NoPen); - } - p.setBrush(d->color); - p.drawRect(qreal(pw+1)/2, qreal(pw+1)/2, borderedRect.width()-(pw+1)/2*2, borderedRect.height()-(pw+1)/2*2); - d->rectTexture = cachedTexture(key, borderedRect); - } - } -} -#endif - - -#if defined(QFX_RENDER_QPAINTER) void QFxRect::paintContents(QPainter &p) { Q_D(QFxRect); @@ -687,258 +604,5 @@ void QFxRect::drawRect(QPainter &p) QRect(d->rectImage.width()-xOffset, d->rectImage.height() - yOffset, xOffset, yOffset)); } } -#endif - -#if defined(QFX_RENDER_OPENGL2) -#include "glbasicshaders.h" - -void QFxRect::paintGLContents(GLPainter &p) -{ - Q_D(QFxRect); - if (d->radius == 0 && (!d->pen || !d->pen->isValid())) { - if (d->gradient) { - float widthV = width(); - float heightV = height(); - - GLfloat vertices[] = { 0, heightV, - widthV, heightV, - 0, 0, - widthV, 0 }; - - int count = d->gradient->stops()->size(); - GLfloat colors[count*8]; - for (int i = 0; i < count; i += 8) { - QFxGradientStop *g = d->gradient->stops()->at(i); - QColor c = g->color(); - colors[i] = c.redF(); colors[i+4] = colors[i]; - colors[i+1] = c.greenF(); colors[i+5] = colors[i+1]; - colors[i+2] = c.blueF(); colors[i+6] = colors[i+2]; - colors[i+3] = c.alphaF() * p.activeOpacity; colors[i+7] = colors[i+3]; - } - - p.invalidate(); - ColorShader *shader = basicShaders()->color(); - shader->enable(); - shader->setTransform(p.activeTransform); - - shader->setAttributeArray(ColorShader::Vertices, vertices, 2); - shader->setAttributeArray(ColorShader::Colors, colors, 4); - glDrawArrays(GL_TRIANGLE_STRIP, 0, count*2); - shader->disableAttributeArray(ColorShader::Vertices); - shader->disableAttributeArray(ColorShader::Colors); - } else { - - p.fillRect(QRectF(0, 0, width(), height()), d->getColor()); - - } - } else { - qreal offset = 0; - qreal pw = d->pen && d->pen->isValid() ? d->pen->width() : 0.0; - - if (d->radius > 0) { - generateRoundedRect(); - offset = d->radius + pw+1.5; - } else { - generateBorderedRect(); - offset = pw+1.5; - } - - QGLShaderProgram *shader = p.useTextureShader(); - - float texWidth = d->rectTexture->width(); - float texHeight = d->rectTexture->height(); - if (!texWidth || !texHeight) - return; - - float widthV = qreal(width())+pw/2; - float heightV = qreal(height())+pw/2; - - float xOffset = offset; - bool xMiddles = true; - if (xOffset*2 > width()+pw) { - xMiddles = false; - xOffset = (width()+pw)/2; - } - float yOffset = offset; - bool yMiddles = true; - if (yOffset*2 > height()+pw) { - yMiddles = false; - yOffset = (height()+pw)/2; - } - - float texleft = xOffset / texWidth; - float imgleft = xOffset-pw/2; - float texright = (texWidth-xOffset) / texWidth; - float imgright = widthV - xOffset; - - float textop = yOffset / texHeight; - float imgtop = yOffset-pw/2; - float texbottom = (texHeight-yOffset) / texHeight; - float imgbottom = heightV - yOffset; - - //Bug 231768: Inappropriate interpolation was occuring on 3x3 textures - if (offset==1) - texleft=texright=textop=texbottom=0.5; - - texleft *= d->rectTexture->glWidth(); - texright *= d->rectTexture->glWidth(); - textop *= d->rectTexture->glHeight(); - texbottom *= d->rectTexture->glHeight(); - - float vert1[] = { -pw/2, -pw/2, - -pw/2, imgtop, - imgleft, -pw/2, - - -pw/2, imgtop, - imgleft, -pw/2, - imgleft, imgtop, - - imgleft, -pw/2, - imgleft, imgtop, - imgright, -pw/2, - - imgleft, imgtop, - imgright, -pw/2, - imgright, imgtop, - - imgright, -pw/2, - imgright, imgtop, - widthV, -pw/2, - - imgright, imgtop, - widthV, -pw/2, - widthV, imgtop, - - -pw/2, heightV, - -pw/2, imgbottom, - imgleft, heightV, - - -pw/2, imgbottom, - imgleft, heightV, - imgleft, imgbottom, - - imgleft, heightV, - imgleft, imgbottom, - imgright, heightV, - - imgleft, imgbottom, - imgright, heightV, - imgright, imgbottom, - - imgright, heightV, - imgright, imgbottom, - widthV, heightV, - - imgright, imgbottom, - widthV, heightV, - widthV, imgbottom, - - -pw/2, imgtop, - -pw/2, imgbottom, - imgleft, imgtop, - - -pw/2, imgbottom, - imgleft, imgtop, - imgleft, imgbottom, - - imgleft, imgtop, - imgleft, imgbottom, - imgright, imgtop, - - imgleft, imgbottom, - imgright, imgtop, - imgright, imgbottom, - - imgright, imgtop, - imgright, imgbottom, - widthV, imgtop, - - imgright, imgbottom, - widthV, imgtop, - widthV, imgbottom }; - - - float tex1[] = { 0, 0, - 0, textop, - texleft, 0, - - 0, textop, - texleft, 0, - texleft, textop, - - texleft, 0, - texleft, textop, - texright, 0, - - texleft, textop, - texright, 0, - texright, textop, - - texright, 0, - texright, textop, - d->rectTexture->glWidth(), 0, - - texright, textop, - d->rectTexture->glWidth(), 0, - d->rectTexture->glWidth(), textop, - - 0, d->rectTexture->glHeight(), - 0, texbottom, - texleft, d->rectTexture->glHeight(), - - 0, texbottom, - texleft, d->rectTexture->glHeight(), - texleft, texbottom, - - texleft, d->rectTexture->glHeight(), - texleft, texbottom, - texright, d->rectTexture->glHeight(), - - texleft, texbottom, - texright, d->rectTexture->glHeight(), - texright, texbottom, - - texright, d->rectTexture->glHeight(), - texright, texbottom, - d->rectTexture->glWidth(), d->rectTexture->glHeight(), - - texright, texbottom, - d->rectTexture->glWidth(), d->rectTexture->glHeight(), - d->rectTexture->glWidth(), texbottom, - - 0, textop, - 0, texbottom, - texleft, textop, - - 0, texbottom, - texleft, textop, - texleft, texbottom, - - texleft, textop, - texleft, texbottom, - texright, textop, - - texleft, texbottom, - texright, textop, - texright, texbottom, - - texright, textop, - texright, texbottom, - d->rectTexture->glWidth(), textop, - - texright, texbottom, - d->rectTexture->glWidth(), textop, - d->rectTexture->glWidth(), texbottom }; - - - - glBindTexture(GL_TEXTURE_2D, d->rectTexture->texture()); - - shader->setAttributeArray(SingleTextureShader::Vertices, vert1, 2); - shader->setAttributeArray(SingleTextureShader::TextureCoords, tex1, 2); - glDrawArrays(GL_TRIANGLES, 0, 36 + (yMiddles?18:0)); - } -} -#endif QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h index c279a1c..d232328 100644 --- a/src/declarative/fx/qfxrect.h +++ b/src/declarative/fx/qfxrect.h @@ -160,13 +160,7 @@ public: void setRadius(qreal radius); virtual void dump(int depth); -#if defined(QFX_RENDER_QPAINTER) void paintContents(QPainter &painter); -#endif - -#if defined(QFX_RENDER_OPENGL) - void paintGLContents(GLPainter &); -#endif private Q_SLOTS: void doUpdate(); diff --git a/src/declarative/fx/qfxrect_p.h b/src/declarative/fx/qfxrect_p.h index 23bb944..3544d36 100644 --- a/src/declarative/fx/qfxrect_p.h +++ b/src/declarative/fx/qfxrect_p.h @@ -55,10 +55,6 @@ #include "qfxitem_p.h" -#if defined(QFX_RENDER_OPENGL) -#include "gltexture.h" -#endif - QT_BEGIN_NAMESPACE class QFxGradient; @@ -69,9 +65,6 @@ class QFxRectPrivate : public QFxItemPrivate public: QFxRectPrivate() : -#if defined(QFX_RENDER_OPENGL) - rectTexture(0), -#endif //QFX_RENDER_OPENGL color(Qt::white), gradient(0), pen(0), radius(0) { } @@ -85,9 +78,6 @@ public: { } -#if defined(QFX_RENDER_OPENGL) - QSimpleCanvasItem::CachedTexture *rectTexture; -#endif QColor getColor(); QColor color; QFxGradient *gradient; diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index 031c0f8..a5361e1 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -44,10 +44,6 @@ #include <private/qtextcontrol_p.h> -#if defined(QFX_RENDER_OPENGL2) -#include "glbasicshaders.h" -#endif - #include <qfxperf.h> #include <QTextLayout> #include <QTextLine> @@ -695,14 +691,9 @@ void QFxTextPrivate::checkImgCache() break; } -#if defined(QFX_RENDER_OPENGL) - tex.setImage(imgCache.toImage(), GLTexture::PowerOfTwo); -#endif - imgDirty = false; } -#if defined(QFX_RENDER_QPAINTER) void QFxText::paintContents(QPainter &p) { Q_D(QFxText); @@ -752,85 +743,6 @@ void QFxText::paintContents(QPainter &p) p.restore(); } -#elif defined(QFX_RENDER_OPENGL2) -void QFxText::paintGLContents(GLPainter &p) -{ - //return; - Q_D(QFxText); - d->checkImgCache(); - if (d->imgCache.isNull()) - return; - - int w = width(); - int h = height(); - - float x = 0; - float y = 0; - - switch (d->hAlign) { - case AlignLeft: - x = 0; - break; - case AlignRight: - x = w - d->imgCache.width(); - break; - case AlignHCenter: - x = (w - d->imgCache.width()) / 2; - break; - } - - switch (d->vAlign) { - case AlignTop: - y = 0; - break; - case AlignBottom: - y = h - d->imgCache.height(); - break; - case AlignVCenter: - y = (h - d->imgCache.height()) / 2; - break; - } - - float widthV = d->imgCache.width(); - float heightV = d->imgCache.height(); - float glWidth = d->tex.glWidth(); - float glHeight = d->tex.glHeight(); - - QGLShaderProgram *shader = p.useTextureShader(); - - float deltaX = 0.5 / qreal(d->tex.glSize().width()); - float deltaY = 0.5 / qreal(d->tex.glSize().height()); - glWidth -= deltaX; - glHeight -= deltaY; - - GLfloat vertices[] = { x, y + heightV, - x + widthV, y + heightV, - x, y, - - x + widthV, y + heightV, - x, y, - x + widthV, y }; - - GLfloat texVertices[] = { deltaX, deltaY, - glWidth, deltaY, - deltaX, glHeight, - - glWidth, deltaY, - deltaX, glHeight, - glWidth, glHeight }; - - shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2); - shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2); - - glBindTexture(GL_TEXTURE_2D, d->tex.texture()); - glDrawArrays(GL_TRIANGLES, 0, 6); - - shader->disableAttributeArray(SingleTextureShader::Vertices); - shader->disableAttributeArray(SingleTextureShader::TextureCoords); -} - -#endif - void QFxText::componentComplete() { Q_D(QFxText); diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h index 99ab2be..35e8b03 100644 --- a/src/declarative/fx/qfxtext.h +++ b/src/declarative/fx/qfxtext.h @@ -117,11 +117,7 @@ public: virtual void dump(int depth); virtual QString propertyInfo() const; -#if defined(QFX_RENDER_QPAINTER) void paintContents(QPainter &p); -#elif defined(QFX_RENDER_OPENGL) - void paintGLContents(GLPainter &); -#endif virtual void componentComplete(); diff --git a/src/declarative/fx/qfxtext_p.h b/src/declarative/fx/qfxtext_p.h index dfaef63..e0b1909 100644 --- a/src/declarative/fx/qfxtext_p.h +++ b/src/declarative/fx/qfxtext_p.h @@ -58,10 +58,6 @@ #include "qml.h" #include <QtGui/qtextlayout.h> -#if defined(QFX_RENDER_OPENGL) -#include "gltexture.h" -#endif - QT_BEGIN_NAMESPACE class QTextLayout; @@ -115,9 +111,6 @@ public: QColor styleColor; QString activeLink; bool imgDirty; -#if defined(QFX_RENDER_OPENGL) - GLTexture tex; -#endif QPixmap imgCache; QPixmap imgStyleCache; QFxText::HAlignment hAlign; diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index 5f2f36c..3c117ee 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -44,10 +44,6 @@ #include <private/qtextcontrol_p.h> -#if defined(QFX_RENDER_OPENGL2) -#include "glbasicshaders.h" -#endif - #include <qfxperf.h> #include "qfxevents_p.h" #include <QTextLayout> diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h index f733a4c..403bd18 100644 --- a/src/declarative/fx/qfxtextedit_p.h +++ b/src/declarative/fx/qfxtextedit_p.h @@ -86,9 +86,6 @@ public: QString style; QColor styleColor; bool imgDirty; -#if defined(QFX_RENDER_OPENGL) - GLTexture texture; -#endif QPixmap imgCache; QPixmap imgStyleCache; QFxTextEdit::HAlignment hAlign; diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp index a4c5d22..8d9084f 100644 --- a/src/declarative/fx/qfxtransform.cpp +++ b/src/declarative/fx/qfxtransform.cpp @@ -254,7 +254,6 @@ bool QFxRotation::isIdentity() const return (_angle == 0.); } -#if defined(QFX_RENDER_QPAINTER) QTransform QFxRotation::transform() const { if (_dirty) { @@ -266,19 +265,6 @@ QTransform QFxRotation::transform() const } return _transform; } -#elif defined(QFX_RENDER_OPENGL) -QMatrix4x4 QFxRotation::transform() const -{ - if (_dirty) { - _transform = QMatrix4x4(); - _dirty = false; - _transform.translate(_originX, _originY); - _transform.rotate(_angle, 0, 0, 1); - _transform.translate(-_originX, -_originY); - } - return _transform; -} -#endif void QFxRotation::update() { @@ -351,7 +337,6 @@ bool QFxRotation3D::isIdentity() const return (_angle == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX()); } -#if defined(QFX_RENDER_QPAINTER) const qreal inv_dist_to_plane = 1. / 1024.; QTransform QFxRotation3D::transform() const { @@ -396,29 +381,6 @@ QTransform QFxRotation3D::transform() const return _transform; } -#elif defined(QFX_RENDER_OPENGL) -QMatrix4x4 QFxRotation3D::transform() const -{ - if (_dirty) { - _dirty = false; - _transform = QMatrix4x4(); - - if (!isIdentity()) { - if (angle() != 0.) { - qreal x = _axis.endX() - _axis.startX(); - qreal y = _axis.endY() - _axis.startY(); - qreal z = _axis.endZ(); - - _transform.translate(_axis.startX(), _axis.startY(), 0); - _transform.rotate(angle(), x, y, z); - _transform.translate(-_axis.startX(), -_axis.startY(), 0); - } - } - } - - return _transform; -} -#endif void QFxRotation3D::update() { @@ -506,7 +468,6 @@ bool QFxTranslation3D::isIdentity() const return (_distance == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX()); } -#if defined(QFX_RENDER_QPAINTER) QTransform QFxTranslation3D::transform() const { if (_dirty) { @@ -526,35 +487,14 @@ QTransform QFxTranslation3D::transform() const return _transform; } -#elif defined(QFX_RENDER_OPENGL) -QMatrix4x4 QFxTranslation3D::transform() const -{ - if (_dirty) { - _dirty = false; - _transform = QMatrix4x4(); - - if (!isIdentity()) { - if (distance() != 0.) - _transform.translate((_axis.endX() - _axis.startX()) * distance(), - (_axis.endY() - _axis.startY()) * distance(), - (_axis.endZ()) * distance()); - - } - } - - return _transform; -} -#endif void QFxTranslation3D::update() { _dirty = true; -#if !defined(QFX_RENDER_OPENGL) if (_axis.endZ() != 0. && distance() != 0.) { qmlInfo(this) << "QTransform cannot translate along Z-axis."; } -#endif QFxTransform::update(); } @@ -579,24 +519,6 @@ QFxPerspective::~QFxPerspective() { } -#if defined(QFX_RENDER_OPENGL) -bool QFxPerspective::isIdentity() const -{ - return false; -} - -QMatrix4x4 QFxPerspective::transform() const -{ - QMatrix4x4 rv; - rv.translate(_x, _y); - rv.perspective(_angle, _aspect, 1, 1024 * 1024); - rv.translate(-_x, -_y, -1); - rv.scale(1, 1, 1. / _scale); - - return rv; -} -#endif - /*! \qmlproperty real Perspective::angle */ @@ -863,7 +785,6 @@ bool QFxSquish::isIdentity() const return false; } -#if defined(QFX_RENDER_QPAINTER) QTransform QFxSquish::transform() const { QPolygonF poly; @@ -875,21 +796,5 @@ QTransform QFxSquish::transform() const QTransform::quadToQuad(poly, poly2, t); return t; } -#elif defined(QFX_RENDER_OPENGL) -QMatrix4x4 QFxSquish::transform() const -{ - QPolygonF poly; - poly << p << QPointF(p.x() + s.width(), p.y()) << QPointF(p.x() + s.width(), p.y() + s.height()) << QPointF(p.x(), p.y() + s.height()); - QPolygonF poly2; - poly2 << p1 << p2 << p4 << p3; - - QTransform t; - QMatrix4x4 rv; - if (QTransform::quadToQuad(poly, poly2, t)) - rv = QMatrix4x4(t); - - return rv; -} -#endif QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h index 7be8adc..0a17917 100644 --- a/src/declarative/fx/qfxtransform.h +++ b/src/declarative/fx/qfxtransform.h @@ -44,9 +44,6 @@ #include <QtCore/QObject> #include <QtGui/QTransform> -#if defined(QFX_RENDER_OPENGL) -#include <QtGui/qmatrix4x4.h> -#endif #include <QtDeclarative/qfxitem.h> QT_BEGIN_HEADER @@ -233,10 +230,6 @@ public: qreal scale() const { return _scale; } void setScale(qreal v) { _scale = v; update(); } -#if defined(QFX_RENDER_OPENGL) - virtual bool isIdentity() const; - virtual QMatrix4x4 transform() const; -#endif private: qreal _scale; qreal _x; diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index dc7f60e..91579e9 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -58,16 +58,7 @@ #include "qsimplecanvas.h" #include "qlistmodelinterface.h" -#if defined(QFX_RENDER_OPENGL2) -#include <QtOpenGL/qglframebufferobject.h> -#include <glsave.h> -#endif -#if defined(QFX_RENDER_OPENGL) -#include <gltexture.h> -#endif - #include "qfxwebview.h" -#include <qsimplecanvasfilter.h> #include <private/qfxpainteditem_p.h> QT_BEGIN_NAMESPACE @@ -160,11 +151,7 @@ public: ~ImageCacheItem() { } int age; QRect area; -#if defined(QFX_RENDER_QPAINTER) QPixmap image; -#else - GLTexture image; -#endif }; QList<ImageCacheItem*> imagecache; void dirtyCache(const QRect& dirt) |