summaryrefslogtreecommitdiff
path: root/src/controls/Private
diff options
context:
space:
mode:
Diffstat (limited to 'src/controls/Private')
-rw-r--r--src/controls/Private/FastGlow.qml133
-rw-r--r--src/controls/Private/qquicksceneposlistener.cpp2
-rw-r--r--src/controls/Private/qquicksceneposlistener_p.h8
-rw-r--r--src/controls/Private/qquickstyleitem.cpp125
4 files changed, 12 insertions, 256 deletions
diff --git a/src/controls/Private/FastGlow.qml b/src/controls/Private/FastGlow.qml
index a94a3de6..1a8b7a81 100644
--- a/src/controls/Private/FastGlow.qml
+++ b/src/controls/Private/FastGlow.qml
@@ -63,75 +63,9 @@ Item {
hideSource: visible
}
- property string __internalBlurVertexShader: OpenGLInfo.profile === OpenGLInfo.CoreProfile ? "#version 150
- in vec4 qt_Vertex;
- in vec2 qt_MultiTexCoord0;
- uniform mat4 qt_Matrix;
- uniform float yStep;
- uniform float xStep;
- out vec2 qt_TexCoord0;
- out vec2 qt_TexCoord1;
- out vec2 qt_TexCoord2;
- out vec2 qt_TexCoord3;
-
- void main() {
- qt_TexCoord0 = vec2(qt_MultiTexCoord0.x + xStep, qt_MultiTexCoord0.y + yStep * 0.36);
- qt_TexCoord1 = vec2(qt_MultiTexCoord0.x + xStep * 0.36, qt_MultiTexCoord0.y - yStep);
- qt_TexCoord2 = vec2(qt_MultiTexCoord0.x - xStep * 0.36, qt_MultiTexCoord0.y + yStep);
- qt_TexCoord3 = vec2(qt_MultiTexCoord0.x - xStep, qt_MultiTexCoord0.y - yStep * 0.36);
- gl_Position = qt_Matrix * qt_Vertex;
- }
- " : "
- attribute highp vec4 qt_Vertex;
- attribute highp vec2 qt_MultiTexCoord0;
- uniform highp mat4 qt_Matrix;
- uniform highp float yStep;
- uniform highp float xStep;
- varying highp vec2 qt_TexCoord0;
- varying highp vec2 qt_TexCoord1;
- varying highp vec2 qt_TexCoord2;
- varying highp vec2 qt_TexCoord3;
-
- void main() {
- qt_TexCoord0 = vec2(qt_MultiTexCoord0.x + xStep, qt_MultiTexCoord0.y + yStep * 0.36);
- qt_TexCoord1 = vec2(qt_MultiTexCoord0.x + xStep * 0.36, qt_MultiTexCoord0.y - yStep);
- qt_TexCoord2 = vec2(qt_MultiTexCoord0.x - xStep * 0.36, qt_MultiTexCoord0.y + yStep);
- qt_TexCoord3 = vec2(qt_MultiTexCoord0.x - xStep, qt_MultiTexCoord0.y - yStep * 0.36);
- gl_Position = qt_Matrix * qt_Vertex;
- }
- "
- property string __internalBlurFragmentShader: OpenGLInfo.profile === OpenGLInfo.CoreProfile ? "#version 150
- uniform sampler2D source;
- uniform float qt_Opacity;
- in vec2 qt_TexCoord0;
- in vec2 qt_TexCoord1;
- in vec2 qt_TexCoord2;
- in vec2 qt_TexCoord3;
- out vec4 fragColor;
-
- void main() {
- vec4 sourceColor = (texture(source, qt_TexCoord0) +
- texture(source, qt_TexCoord1) +
- texture(source, qt_TexCoord2) +
- texture(source, qt_TexCoord3)) * 0.25;
- fragColor = sourceColor * qt_Opacity;
- }
- " : "
- uniform lowp sampler2D source;
- uniform lowp float qt_Opacity;
- varying highp vec2 qt_TexCoord0;
- varying highp vec2 qt_TexCoord1;
- varying highp vec2 qt_TexCoord2;
- varying highp vec2 qt_TexCoord3;
-
- void main() {
- highp vec4 sourceColor = (texture2D(source, qt_TexCoord0) +
- texture2D(source, qt_TexCoord1) +
- texture2D(source, qt_TexCoord2) +
- texture2D(source, qt_TexCoord3)) * 0.25;
- gl_FragColor = sourceColor * qt_Opacity;
- }
- "
+ property string __internalBlurVertexShader: "qrc:/QtQuick/Controls/Shaders/blur.vert"
+
+ property string __internalBlurFragmentShader: "qrc:/QtQuick/Controls/Shaders/blur.frag"
ShaderEffect {
id: level0
@@ -391,65 +325,6 @@ Item {
onLodChanged: calculateWeights()
- fragmentShader: rootItem.OpenGLInfo.profile === OpenGLInfo.CoreProfile ? "#version 150
- uniform sampler2D source1;
- uniform sampler2D source2;
- uniform sampler2D source3;
- uniform sampler2D source4;
- uniform sampler2D source5;
- uniform float weight1;
- uniform float weight2;
- uniform float weight3;
- uniform float weight4;
- uniform float weight5;
- uniform vec4 color;
- uniform float spread;
- uniform float qt_Opacity;
- in vec2 qt_TexCoord0;
- out vec4 fragColor;
-
- float linearstep(float e0, float e1, float x) {
- return clamp((x - e0) / (e1 - e0), 0.0, 1.0);
- }
-
- void main() {
- vec4 sourceColor = texture(source1, qt_TexCoord0) * weight1;
- sourceColor += texture(source2, qt_TexCoord0) * weight2;
- sourceColor += texture(source3, qt_TexCoord0) * weight3;
- sourceColor += texture(source4, qt_TexCoord0) * weight4;
- sourceColor += texture(source5, qt_TexCoord0) * weight5;
- sourceColor = mix(vec4(0), color, linearstep(0.0, spread, sourceColor.a));
- fragColor = sourceColor * qt_Opacity;
- }
- " : "
- uniform lowp sampler2D source1;
- uniform lowp sampler2D source2;
- uniform lowp sampler2D source3;
- uniform lowp sampler2D source4;
- uniform lowp sampler2D source5;
- uniform mediump float weight1;
- uniform mediump float weight2;
- uniform mediump float weight3;
- uniform mediump float weight4;
- uniform mediump float weight5;
- uniform highp vec4 color;
- uniform highp float spread;
- uniform lowp float qt_Opacity;
- varying mediump vec2 qt_TexCoord0;
-
- highp float linearstep(highp float e0, highp float e1, highp float x) {
- return clamp((x - e0) / (e1 - e0), 0.0, 1.0);
- }
-
- void main() {
- lowp vec4 sourceColor = texture2D(source1, qt_TexCoord0) * weight1;
- sourceColor += texture2D(source2, qt_TexCoord0) * weight2;
- sourceColor += texture2D(source3, qt_TexCoord0) * weight3;
- sourceColor += texture2D(source4, qt_TexCoord0) * weight4;
- sourceColor += texture2D(source5, qt_TexCoord0) * weight5;
- sourceColor = mix(vec4(0), color, linearstep(0.0, spread, sourceColor.a));
- gl_FragColor = sourceColor * qt_Opacity;
- }
- "
+ fragmentShader: "qrc:/QtQuick/Controls/Shaders/glow.frag"
}
}
diff --git a/src/controls/Private/qquicksceneposlistener.cpp b/src/controls/Private/qquicksceneposlistener.cpp
index 4e5a4a5e..872f1bf9 100644
--- a/src/controls/Private/qquicksceneposlistener.cpp
+++ b/src/controls/Private/qquicksceneposlistener.cpp
@@ -124,7 +124,7 @@ void QQuickScenePosListener1::setEnabled(bool enabled)
emit enabledChanged();
}
-void QQuickScenePosListener1::itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &)
+void QQuickScenePosListener1::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &)
{
updateScenePos();
}
diff --git a/src/controls/Private/qquicksceneposlistener_p.h b/src/controls/Private/qquicksceneposlistener_p.h
index f66930e7..61447c7d 100644
--- a/src/controls/Private/qquicksceneposlistener_p.h
+++ b/src/controls/Private/qquicksceneposlistener_p.h
@@ -73,10 +73,10 @@ Q_SIGNALS:
void enabledChanged();
protected:
- void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &);
- void itemParentChanged(QQuickItem *, QQuickItem *parent);
- void itemChildRemoved(QQuickItem *, QQuickItem *child);
- void itemDestroyed(QQuickItem *item);
+ void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override;
+ void itemParentChanged(QQuickItem *, QQuickItem *parent) override;
+ void itemChildRemoved(QQuickItem *, QQuickItem *child) override;
+ void itemDestroyed(QQuickItem *item) override;
private:
void updateScenePos();
diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp
index 95722f93..1d79d634 100644
--- a/src/controls/Private/qquickstyleitem.cpp
+++ b/src/controls/Private/qquickstyleitem.cpp
@@ -45,12 +45,12 @@
#include <qstyle.h>
#include <qstyleoption.h>
#include <qapplication.h>
-#include <qsgsimpletexturenode.h>
#include <qquickwindow.h>
#include "private/qguiapplication_p.h"
#include <QtQuick/private/qquickwindow_p.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QtGui/qpa/qplatformtheme.h>
+#include <QtQuick/qsgninepatchnode.h>
#include "../qquickmenuitem_p.h"
QT_BEGIN_NAMESPACE
@@ -96,122 +96,6 @@ CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
#endif
-class QQuickStyleNode1 : public QSGNinePatchNode
-{
-public:
- QQuickStyleNode1()
- : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
- {
- m_geometry.setDrawingMode(GL_TRIANGLE_STRIP);
- setGeometry(&m_geometry);
- // The texture material has mipmap filtering set to Nearest by default. This is not ideal.
- m_material.setMipmapFiltering(QSGTexture::None);
- setMaterial(&m_material);
- }
-
- ~QQuickStyleNode1()
- {
- delete m_material.texture();
- }
-
- virtual void setTexture(QSGTexture *texture)
- {
- delete m_material.texture();
- m_material.setTexture(texture);
- }
-
- virtual void setBounds(const QRectF &bounds)
- {
- m_bounds = bounds;
- }
-
- virtual void setDevicePixelRatio(qreal ratio)
- {
- m_devicePixelRatio = ratio;
- }
-
- virtual void setPadding(qreal left, qreal top, qreal right, qreal bottom)
- {
- m_paddingLeft = left;
- m_paddingTop = top;
- m_paddingRight = right;
- m_paddingBottom = bottom;
- }
-
- virtual void update() {
- QSGTexture *texture = m_material.texture();
-
- if (m_paddingLeft <= 0 && m_paddingTop <= 0 && m_paddingRight <= 0 && m_paddingBottom <= 0) {
- m_geometry.allocate(4, 0);
- QSGGeometry::updateTexturedRectGeometry(&m_geometry, m_bounds, texture->normalizedTextureSubRect());
- markDirty(QSGNode::DirtyGeometry | QSGNode::DirtyMaterial);
- return;
- }
-
- QRectF tc = texture->normalizedTextureSubRect();
- QSize ts = texture->textureSize();
- ts.setHeight(ts.height() / m_devicePixelRatio);
- ts.setWidth(ts.width() / m_devicePixelRatio);
-
- qreal invtw = tc.width() / ts.width();
- qreal invth = tc.height() / ts.height();
-
- struct Coord { qreal p; qreal t; };
- Coord cx[4] = { { m_bounds.left(), tc.left() },
- { m_bounds.left() + m_paddingLeft, tc.left() + m_paddingLeft * invtw },
- { m_bounds.right() - m_paddingRight, tc.right() - m_paddingRight * invtw },
- { m_bounds.right(), tc.right() }
- };
- Coord cy[4] = { { m_bounds.top(), tc.top() },
- { m_bounds.top() + m_paddingTop, tc.top() + m_paddingTop * invth },
- { m_bounds.bottom() - m_paddingBottom, tc.bottom() - m_paddingBottom * invth },
- { m_bounds.bottom(), tc.bottom() }
- };
-
- m_geometry.allocate(16, 28);
- QSGGeometry::TexturedPoint2D *v = m_geometry.vertexDataAsTexturedPoint2D();
- for (int y=0; y<4; ++y) {
- for (int x=0; x<4; ++x) {
- v->set(cx[x].p, cy[y].p, cx[x].t, cy[y].t);
- ++v;
- }
- }
-
- quint16 *i = m_geometry.indexDataAsUShort();
- for (int r=0; r<3; ++r) {
- if (r > 0)
- *i++ = 4 * r;
- for (int c=0; c<4; ++c) {
- i[0] = 4 * r + c;
- i[1] = 4 * r + c + 4;
- i+=2;
- }
- if (r < 2)
- *i++ = 4 * r + 3 + 4;
- }
-
- markDirty(QSGNode::DirtyGeometry | QSGNode::DirtyMaterial);
-
-// v = m_geometry.vertexDataAsTexturedPoint2D();
-// for (int j=0; j<m_geometry.vertexCount(); ++j)
-// qDebug() << v[j].x << v[j].y << v[j].tx << v[j].ty;
-
-// i = m_geometry.indexDataAsUShort();
-// for (int j=0; j<m_geometry.indexCount(); ++j)
-// qDebug() << i[j];
-
- }
-
- QRectF m_bounds;
- qreal m_devicePixelRatio;
- qreal m_paddingLeft;
- qreal m_paddingTop;
- qreal m_paddingRight;
- qreal m_paddingBottom;
- QSGGeometry m_geometry;
- QSGTextureMaterial m_material;
-};
-
QQuickStyleItem1::QQuickStyleItem1(QQuickItem *parent)
: QQuickItem(parent),
m_styleoption(0),
@@ -1860,11 +1744,8 @@ QSGNode *QQuickStyleItem1::updatePaintNode(QSGNode *node, UpdatePaintNodeData *)
}
QSGNinePatchNode *styleNode = static_cast<QSGNinePatchNode *>(node);
- if (!styleNode) {
- styleNode = QQuickItemPrivate::get(this)->sceneGraphContext()->createNinePatchNode();
- if (!styleNode)
- styleNode = new QQuickStyleNode1;
- }
+ if (!styleNode)
+ styleNode = window()->createNinePatchNode();
#ifdef QSG_RUNTIME_DESCRIPTION
qsgnode_set_description(styleNode,