diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-04-11 16:06:39 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-04-13 09:22:18 +0000 |
commit | 96a7afec18542396f8e9a0b0f75d219a08725b3f (patch) | |
tree | ba2ed094f071214a93afea29dd100e6669641fbb /src/quick/items/qquickopenglshadereffect_p.h | |
parent | e188a3d864a5310bf18c3ad759a12560013deb64 (diff) |
Route ShaderEffect through the old GL impl
Register the common QQuickShaderEffect class as ShaderEffect to QML.
In case of GL this will route to QQuickOpenGLShaderEffect. For others
the default no-op implementation is used (at least for now). Later this
new implementation will route to a backend-specific scenegraph node via
the adaptation layer.
This also means that QQuickOpenGLShaderEffect is no longer a QQuickItem
and QQuickShaderEffect must handle everything item-related and forward.
Change-Id: I1ff4b674253543a04978a69f4a3b67f3a44dd983
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Diffstat (limited to 'src/quick/items/qquickopenglshadereffect_p.h')
-rw-r--r-- | src/quick/items/qquickopenglshadereffect_p.h | 56 |
1 files changed, 17 insertions, 39 deletions
diff --git a/src/quick/items/qquickopenglshadereffect_p.h b/src/quick/items/qquickopenglshadereffect_p.h index 1b72367e9f..80e1e5ee8e 100644 --- a/src/quick/items/qquickopenglshadereffect_p.h +++ b/src/quick/items/qquickopenglshadereffect_p.h @@ -96,36 +96,12 @@ struct Q_QUICK_PRIVATE_EXPORT QQuickOpenGLShaderEffectCommon }; -class Q_QUICK_PRIVATE_EXPORT QQuickOpenGLShaderEffect : public QQuickItem +class Q_QUICK_PRIVATE_EXPORT QQuickOpenGLShaderEffect : public QObject { Q_OBJECT - Q_PROPERTY(QByteArray fragmentShader READ fragmentShader WRITE setFragmentShader NOTIFY fragmentShaderChanged) - Q_PROPERTY(QByteArray vertexShader READ vertexShader WRITE setVertexShader NOTIFY vertexShaderChanged) - Q_PROPERTY(bool blending READ blending WRITE setBlending NOTIFY blendingChanged) - Q_PROPERTY(QVariant mesh READ mesh WRITE setMesh NOTIFY meshChanged) - Q_PROPERTY(CullMode cullMode READ cullMode WRITE setCullMode NOTIFY cullModeChanged) - Q_PROPERTY(QString log READ log NOTIFY logChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_PROPERTY(bool supportsAtlasTextures READ supportsAtlasTextures WRITE setSupportsAtlasTextures NOTIFY supportsAtlasTexturesChanged REVISION 1) public: - enum CullMode - { - NoCulling = QQuickShaderEffect::NoCulling, - BackFaceCulling = QQuickShaderEffect::BackFaceCulling, - FrontFaceCulling = QQuickShaderEffect::FrontFaceCulling - }; - Q_ENUM(CullMode) - - enum Status - { - Compiled, - Uncompiled, - Error - }; - Q_ENUM(Status) - - QQuickOpenGLShaderEffect(QQuickItem *parent = 0); + QQuickOpenGLShaderEffect(QQuickShaderEffect *item, QObject *parent = 0); ~QQuickOpenGLShaderEffect(); QByteArray fragmentShader() const { return m_common.source.sourceCode[Key::FragmentShader]; } @@ -140,19 +116,17 @@ public: QVariant mesh() const; void setMesh(const QVariant &mesh); - CullMode cullMode() const { return m_cullMode; } - void setCullMode(CullMode face); + QQuickShaderEffect::CullMode cullMode() const { return m_cullMode; } + void setCullMode(QQuickShaderEffect::CullMode face); QString log() const { return m_log; } - Status status() const { return m_status; } + QQuickShaderEffect::Status status() const { return m_status; } bool supportsAtlasTextures() const { return m_supportsAtlasTextures; } void setSupportsAtlasTextures(bool supports); QString parseLog(); - bool event(QEvent *) Q_DECL_OVERRIDE; - Q_SIGNALS: void fragmentShaderChanged(); void vertexShaderChanged(); @@ -164,17 +138,18 @@ Q_SIGNALS: void supportsAtlasTexturesChanged(); protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; - void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; + void handleEvent(QEvent *); + void handleGeometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); + QSGNode *handleUpdatePaintNode(QSGNode *, QQuickItem::UpdatePaintNodeData *); + void handleComponentComplete(); + void handleItemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value); + void handleSourceDestroyed(QObject *object); + void handlePropertyChanged(int mappedId); private Q_SLOTS: void updateGeometry(); void updateGeometryIfAtlased(); void updateLogAndStatus(const QString &log, int status); - void sourceDestroyed(QObject *object); - void propertyChanged(int mappedId); private: friend class QQuickCustomMaterialShader; @@ -183,12 +158,13 @@ private: typedef QQuickOpenGLShaderEffectMaterialKey Key; typedef QQuickOpenGLShaderEffectMaterial::UniformData UniformData; + QQuickShaderEffect *m_item; QSize m_meshResolution; QQuickShaderEffectMesh *m_mesh; QQuickGridMesh m_defaultMesh; - CullMode m_cullMode; + QQuickShaderEffect::CullMode m_cullMode; QString m_log; - Status m_status; + QQuickShaderEffect::Status m_status; QQuickOpenGLShaderEffectCommon m_common; @@ -202,6 +178,8 @@ private: uint m_dirtyGeometry : 1; uint m_customVertexShader : 1; uint m_supportsAtlasTextures : 1; + + friend class QQuickShaderEffect; }; QT_END_NAMESPACE |