diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-04-12 12:57:02 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-04-12 12:57:02 +0200 |
commit | efbe857edb52522244814185c79112670c885934 (patch) | |
tree | 44fa2d8b0d07e369c7f5bd42a25791a627d4eac4 /src/declarative/scenegraph | |
parent | ece51dc25ab266109a018364362d7f92fe10987f (diff) | |
parent | c7ede5617019f3918fe6f8f4c347281461a9f460 (diff) |
Merge branch 'qtquick2' of scm.dev.nokia.troll.no:qt/qt-qml-team into qtquick2
Conflicts:
src/declarative/scenegraph/util/qsgpainternode.cpp
Diffstat (limited to 'src/declarative/scenegraph')
-rw-r--r-- | src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp | 10 | ||||
-rw-r--r-- | src/declarative/scenegraph/scenegraph.pri | 6 | ||||
-rw-r--r-- | src/declarative/scenegraph/util/qsgpainternode.cpp | 228 | ||||
-rw-r--r-- | src/declarative/scenegraph/util/qsgpainternode_p.h | 107 |
4 files changed, 12 insertions, 339 deletions
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp index 6ae1560e76..e332434138 100644 --- a/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp +++ b/src/declarative/scenegraph/qsgdistancefieldglyphnode_p.cpp @@ -561,8 +561,18 @@ const char *QSGSubPixelDistanceFieldTextMaterialShader::fragmentShader() const { " highp float c = texture2D(texture, sampleCoord).a; \n" " n.z = texture2DProj(texture, sampleNearRight).a; \n" " n.w = texture2DProj(texture, sampleFarRight).a; \n" +#if 0 + // Blurrier, faster. " n = smoothstep(alphaMin, alphaMax, n); \n" " c = smoothstep(alphaMin, alphaMax, c); \n" +#else + // Sharper, slower. + " highp vec2 d = min(abs(n.yw - n.xz) * 2., 0.67); \n" + " highp vec2 lo = mix(vec2(alphaMin), vec2(0.5), d); \n" + " highp vec2 hi = mix(vec2(alphaMax), vec2(0.5), d); \n" + " n = smoothstep(lo.xxyy, hi.xxyy, n); \n" + " c = smoothstep(lo.x + lo.y, hi.x + hi.y, 2. * c); \n" +#endif " gl_FragColor = vec4(0.333 * (n.xyz + n.yzw + c), c) * color.w; \n" "}"; } diff --git a/src/declarative/scenegraph/scenegraph.pri b/src/declarative/scenegraph/scenegraph.pri index 23b02158bd..3c69113e9c 100644 --- a/src/declarative/scenegraph/scenegraph.pri +++ b/src/declarative/scenegraph/scenegraph.pri @@ -35,8 +35,7 @@ HEADERS += \ $$PWD/util/qsgvertexcolormaterial_p.h \ $$PWD/util/qsgtexture.h \ $$PWD/util/qsgtexture_p.h \ - $$PWD/util/qsgtextureprovider_p.h \ - $$PWD/util/qsgpainternode_p.h + $$PWD/util/qsgtextureprovider_p.h SOURCES += \ $$PWD/util/qsgareaallocator.cpp \ $$PWD/util/qsgflatcolormaterial.cpp \ @@ -45,8 +44,7 @@ SOURCES += \ $$PWD/util/qsgtexturematerial.cpp \ $$PWD/util/qsgvertexcolormaterial.cpp \ $$PWD/util/qsgtexture.cpp \ - $$PWD/util/qsgtextureprovider.cpp \ - $$PWD/util/qsgpainternode.cpp + $$PWD/util/qsgtextureprovider.cpp # QML / Adaptations API diff --git a/src/declarative/scenegraph/util/qsgpainternode.cpp b/src/declarative/scenegraph/util/qsgpainternode.cpp deleted file mode 100644 index 1d4bc3febc..0000000000 --- a/src/declarative/scenegraph/util/qsgpainternode.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsgpainternode_p.h" - -#include "qsgpainteditem_p.h" -#include "private/qsgtexture_p.h" -#include "private/qsgcontext_p.h" -#include <qglframebufferobject.h> - -QT_BEGIN_NAMESPACE - -QSGPainterNode::QSGPainterNode() - : QSGGeometryNode() - , m_fbo(0) - , m_multisampledFbo(0) - , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4) - , m_size(1, 1) - , m_opaquePainting(false) - , m_linear_filtering(false) - , m_smoothPainting(false) - , m_extensionsChecked(false) - , m_multisamplingSupported(false) - , m_dirtyGeometry(false) - , m_dirtyFBO(false) - , m_dirtyTexture(false) -{ - setMaterial(&m_materialO); - setOpaqueMaterial(&m_material); - setGeometry(&m_geometry); -} - -QSGPainterNode::~QSGPainterNode() -{ - delete m_fbo; - delete m_multisampledFbo; -} - -void QSGPainterNode::paint(QSGPaintedItem *item) -{ - if (!item) - return; - - Q_ASSERT(m_fbo != 0); - - QPainter fbo_painter; - if (m_multisampledFbo) - fbo_painter.begin(m_multisampledFbo); - else - fbo_painter.begin(m_fbo); - - if (m_smoothPainting) - fbo_painter.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); - fbo_painter.setCompositionMode(QPainter::CompositionMode_Source); - fbo_painter.fillRect(QRectF(QPointF(0, 0), m_fbo->size()), Qt::transparent); - fbo_painter.setCompositionMode(QPainter::CompositionMode_SourceOver); - item->paint(&fbo_painter); - fbo_painter.end(); - - if (m_multisampledFbo) { - QRect r(0, 0, m_size.width(), m_size.height()); - QGLFramebufferObject::blitFramebuffer(m_fbo, r, m_multisampledFbo, r); - } - - markDirty(DirtyMaterial); -} - -bool QSGPainterNode::update() -{ - bool fboChanged = false; - - if (m_dirtyGeometry) - updateGeometry(); - if (m_dirtyFBO || m_dirtyGeometry) - fboChanged = updateFBO(); - if (m_dirtyFBO || m_dirtyTexture) - updateTexture(); - - m_dirtyGeometry = false; - m_dirtyFBO = false; - m_dirtyTexture = false; - - return fboChanged; -} - -void QSGPainterNode::updateTexture() -{ - QSGPlainTexture *texture = new QSGPlainTexture; - texture->setTextureId(m_fbo->texture()); - texture->setTextureSize(m_fbo->size()); - texture->setHasAlphaChannel(!m_opaquePainting); - texture->setOwnsTexture(false); - m_texture = QSGTextureRef(texture); - - m_material.setTexture(m_texture); - m_material.setFiltering(m_linear_filtering ? QSGTexture::Linear : QSGTexture::Nearest); - m_materialO.setTexture(m_texture); - m_materialO.setFiltering(m_linear_filtering ? QSGTexture::Linear : QSGTexture::Nearest); - - markDirty(DirtyMaterial); -} - -void QSGPainterNode::updateGeometry() -{ - QSGGeometry::updateTexturedRectGeometry(&m_geometry, - QRectF(0, 0, m_size.width(), m_size.height()), - QRectF(0, 1, 1, -1)); - markDirty(DirtyGeometry); -} - -bool QSGPainterNode::updateFBO() -{ - const QGLContext *ctx = QSGContext::current->glContext(); - if (!m_extensionsChecked) { - QList<QByteArray> extensions = QByteArray((const char *)glGetString(GL_EXTENSIONS)).split(' '); - m_multisamplingSupported = extensions.contains("GL_EXT_framebuffer_multisample") - && extensions.contains("GL_EXT_framebuffer_blit"); - m_extensionsChecked = true; - } - - if (m_fbo && !m_dirtyGeometry && (!ctx->format().sampleBuffers() || !m_multisamplingSupported)) - return false; - - delete m_fbo; - delete m_multisampledFbo; - m_fbo = m_multisampledFbo = 0; - - if (m_smoothPainting && ctx->format().sampleBuffers() && m_multisamplingSupported) { - if (!m_multisampledFbo) { - QGLFramebufferObjectFormat format; - format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); - format.setSamples(ctx->format().samples()); - m_multisampledFbo = new QGLFramebufferObject(m_size, format); - } - { - QGLFramebufferObjectFormat format; - format.setAttachment(QGLFramebufferObject::NoAttachment); - m_fbo = new QGLFramebufferObject(m_size, format); - } - } else { - QGLFramebufferObjectFormat format; - format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); - m_fbo = new QGLFramebufferObject(m_size, format); - } - - return true; -} - -void QSGPainterNode::setSize(const QSize &size) -{ - if (size == m_size) - return; - - m_size = size; - m_dirtyGeometry = true; - m_dirtyFBO = true; -} - -void QSGPainterNode::setOpaquePainting(bool opaque) -{ - if (opaque == m_opaquePainting) - return; - - m_opaquePainting = opaque; - m_dirtyTexture = true; -} - -void QSGPainterNode::setLinearFiltering(bool linearFiltering) -{ - if (linearFiltering == m_linear_filtering) - return; - - m_linear_filtering = linearFiltering; - - m_material.setFiltering(linearFiltering ? QSGTexture::Linear : QSGTexture::Nearest); - m_materialO.setFiltering(linearFiltering ? QSGTexture::Linear : QSGTexture::Nearest); - markDirty(DirtyMaterial); -} - -void QSGPainterNode::setSmoothPainting(bool s) -{ - if (s == m_smoothPainting) - return; - - m_smoothPainting = s; - m_dirtyFBO = true; -} - - -QT_END_NAMESPACE diff --git a/src/declarative/scenegraph/util/qsgpainternode_p.h b/src/declarative/scenegraph/util/qsgpainternode_p.h deleted file mode 100644 index 41741052b0..0000000000 --- a/src/declarative/scenegraph/util/qsgpainternode_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSGPAINTERNODE_P_H -#define QSGPAINTERNODE_P_H - -#include "qsgnode.h" -#include "qsgtexturematerial.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QSGPaintedItem; -class QGLFramebufferObject; - -class Q_DECLARATIVE_EXPORT QSGPainterNode : public QSGGeometryNode -{ -public: - QSGPainterNode(); - virtual ~QSGPainterNode(); - - void setSize(const QSize &size); - QSize size() const { return m_size; } - - void setOpaquePainting(bool opaque); - bool opaquePainting() const { return m_opaquePainting; } - - void setLinearFiltering(bool linearFiltering); - bool linearFiltering() const { return m_linear_filtering; } - - void setSmoothPainting(bool s); - bool smoothPainting() const { return m_smoothPainting; } - - bool update(); - - void paint(QSGPaintedItem *item); - -private: - void updateTexture(); - void updateGeometry(); - bool updateFBO(); - - QGLFramebufferObject *m_fbo; - QGLFramebufferObject *m_multisampledFbo; - QSGTextureMaterial m_material; - QSGTextureMaterialWithOpacity m_materialO; - QSGGeometry m_geometry; - QSGTextureRef m_texture; - - QSize m_size; - bool m_opaquePainting; - bool m_linear_filtering; - bool m_smoothPainting; - bool m_extensionsChecked; - bool m_multisamplingSupported; - - bool m_dirtyGeometry; - bool m_dirtyFBO; - bool m_dirtyTexture; -}; - -QT_END_HEADER - -QT_END_NAMESPACE - -#endif // QSGPAINTERNODE_P_H |