Merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-update-shadereffectsource-based-shapes into lp:ubuntu-ui-toolkit/staging

Proposed by Loïc Molinari
Status: Merged
Approved by: Tim Peeters
Approved revision: 1495
Merged at revision: 1499
Proposed branch: lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-update-shadereffectsource-based-shapes
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 147 lines (+78/-0)
5 files modified
modules/Ubuntu/Components/plugin/ucubuntushape.cpp (+11/-0)
modules/Ubuntu/Components/plugin/ucubuntushape.h (+2/-0)
modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.cpp (+1/-0)
modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.h (+1/-0)
tests/resources/ubuntushape/AnimatedShaderEffectSource.qml (+63/-0)
To merge this branch: bzr merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-update-shadereffectsource-based-shapes
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Tim Peeters Approve
Review via email: mp+257228@code.launchpad.net

Commit message

[UbuntuShape] Ensured QSGLayer-based source textures (like ShaderEffectSource) are updated before rendering.

Description of the change

[UbuntuShape] Ensured QSGLayer-based source textures (like ShaderEffectSource) are updated before rendering.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

works fine, thanks.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/plugin/ucubuntushape.cpp'
2--- modules/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-04-22 20:51:37 +0000
3+++ modules/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-04-23 08:32:05 +0000
4@@ -34,6 +34,7 @@
5 #include <QtQuick/QQuickWindow>
6 #include <QtQuick/QSGTextureProvider>
7 #include <QtQuick/private/qquickimage_p.h>
8+#include <QtQuick/private/qsgadaptationlayer_p.h>
9 #include <math.h>
10
11 // Anti-aliasing distance of the contour in pixels.
12@@ -208,6 +209,15 @@
13 | (m_data.flags & ShapeMaterial::Data::Repeated);
14 }
15
16+void ShapeMaterial::updateTextures()
17+{
18+ if (m_data.flags & ShapeMaterial::Data::Textured && m_data.sourceTextureProvider) {
19+ if (QSGLayer* texture = qobject_cast<QSGLayer*>(m_data.sourceTextureProvider->texture())) {
20+ texture->updateTexture();
21+ }
22+ }
23+}
24+
25 // --- Scene graph node ---
26
27 ShapeNode::ShapeNode()
28@@ -215,6 +225,7 @@
29 , m_material()
30 , m_geometry(attributeSet(), vertexCount, indexCount, indexType)
31 {
32+ QSGNode::setFlag(UsePreprocess, true);
33 memcpy(m_geometry.indexData(), indices(), indexCount * indexTypeSize);
34 m_geometry.setDrawingMode(drawingMode);
35 m_geometry.setIndexDataPattern(indexDataPattern);
36
37=== modified file 'modules/Ubuntu/Components/plugin/ucubuntushape.h'
38--- modules/Ubuntu/Components/plugin/ucubuntushape.h 2015-04-14 21:50:54 +0000
39+++ modules/Ubuntu/Components/plugin/ucubuntushape.h 2015-04-23 08:32:05 +0000
40@@ -75,6 +75,7 @@
41 virtual QSGMaterialType* type() const;
42 virtual QSGMaterialShader* createShader() const;
43 virtual int compare(const QSGMaterial* other) const;
44+ virtual void updateTextures();
45 const Data* constData() const { return &m_data; }
46 Data* data() { return &m_data; }
47
48@@ -107,6 +108,7 @@
49 ShapeNode();
50 ShapeMaterial* material() { return &m_material; }
51 QSGGeometry* geometry() { return &m_geometry; }
52+ void preprocess() { m_material.updateTextures(); }
53
54 private:
55 ShapeMaterial m_material;
56
57=== modified file 'modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.cpp'
58--- modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.cpp 2015-04-22 20:51:37 +0000
59+++ modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.cpp 2015-04-23 08:32:05 +0000
60@@ -60,6 +60,7 @@
61 , m_geometry(attributeSet(), ShapeNode::vertexCount, ShapeNode::indexCount,
62 ShapeNode::indexType)
63 {
64+ QSGNode::setFlag(UsePreprocess, true);
65 memcpy(m_geometry.indexData(), ShapeNode::indices(),
66 ShapeNode::indexCount * ShapeNode::indexTypeSize);
67 m_geometry.setDrawingMode(ShapeNode::drawingMode);
68
69=== modified file 'modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.h'
70--- modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.h 2015-03-10 18:49:20 +0000
71+++ modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.h 2015-04-23 08:32:05 +0000
72@@ -57,6 +57,7 @@
73
74 ShapeOverlayNode();
75 QSGGeometry* geometry() { return &m_geometry; }
76+ void preprocess() { m_material.updateTextures(); }
77
78 private:
79 ShapeOverlayMaterial m_material;
80
81=== added file 'tests/resources/ubuntushape/AnimatedShaderEffectSource.qml'
82--- tests/resources/ubuntushape/AnimatedShaderEffectSource.qml 1970-01-01 00:00:00 +0000
83+++ tests/resources/ubuntushape/AnimatedShaderEffectSource.qml 2015-04-23 08:32:05 +0000
84@@ -0,0 +1,63 @@
85+/*
86+ * Copyright 2015 Canonical Ltd.
87+ *
88+ * This program is free software; you can redistribute it and/or modify
89+ * it under the terms of the GNU Lesser General Public License as published by
90+ * the Free Software Foundation; version 3.
91+ *
92+ * This program is distributed in the hope that it will be useful,
93+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
94+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
95+ * GNU Lesser General Public License for more details.
96+ *
97+ * You should have received a copy of the GNU Lesser General Public License
98+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
99+ */
100+
101+// Test if the UbuntuShape is correctly updated when its source is a ShaderEffectSource.
102+
103+import QtQuick 2.4
104+import Ubuntu.Components 1.2
105+
106+Rectangle {
107+ id: root
108+ width: 300
109+ height: 150
110+ color: "#c0c0c0"
111+
112+ Text {
113+ id: text
114+ anchors.centerIn: parent
115+ font.family: "Ubuntu"
116+ font.pixelSize: 34
117+ color: "#c0c0c0"
118+ text: "This is a scrolling text... "
119+ font.bold: true
120+ }
121+
122+ ShaderEffectSource {
123+ id: effectSource
124+ sourceItem: text
125+ hideSource: true
126+ visible: false
127+ }
128+
129+ UbuntuShape {
130+ id: shape
131+ anchors.fill: parent
132+ anchors.margins: 50
133+ backgroundColor: "black"
134+ radius: "medium"
135+ source: effectSource
136+ sourceFillMode: UbuntuShape.Pad
137+ sourceHorizontalAlignment: UbuntuShape.AlignLeft
138+ sourceHorizontalWrapMode: UbuntuShape.Repeat
139+
140+ PropertyAnimation on sourceTranslation {
141+ from: Qt.vector2d(0.0, 0.0)
142+ to: Qt.vector2d(-text.width / shape.width, 0.0)
143+ loops: Animation.Infinite
144+ duration: 2500
145+ }
146+ }
147+}

Subscribers

People subscribed via source and target branches