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
=== modified file 'modules/Ubuntu/Components/plugin/ucubuntushape.cpp'
--- modules/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-04-22 20:51:37 +0000
+++ modules/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-04-23 08:32:05 +0000
@@ -34,6 +34,7 @@
34#include <QtQuick/QQuickWindow>34#include <QtQuick/QQuickWindow>
35#include <QtQuick/QSGTextureProvider>35#include <QtQuick/QSGTextureProvider>
36#include <QtQuick/private/qquickimage_p.h>36#include <QtQuick/private/qquickimage_p.h>
37#include <QtQuick/private/qsgadaptationlayer_p.h>
37#include <math.h>38#include <math.h>
3839
39// Anti-aliasing distance of the contour in pixels.40// Anti-aliasing distance of the contour in pixels.
@@ -208,6 +209,15 @@
208 | (m_data.flags & ShapeMaterial::Data::Repeated);209 | (m_data.flags & ShapeMaterial::Data::Repeated);
209}210}
210211
212void ShapeMaterial::updateTextures()
213{
214 if (m_data.flags & ShapeMaterial::Data::Textured && m_data.sourceTextureProvider) {
215 if (QSGLayer* texture = qobject_cast<QSGLayer*>(m_data.sourceTextureProvider->texture())) {
216 texture->updateTexture();
217 }
218 }
219}
220
211// --- Scene graph node ---221// --- Scene graph node ---
212222
213ShapeNode::ShapeNode()223ShapeNode::ShapeNode()
@@ -215,6 +225,7 @@
215 , m_material()225 , m_material()
216 , m_geometry(attributeSet(), vertexCount, indexCount, indexType)226 , m_geometry(attributeSet(), vertexCount, indexCount, indexType)
217{227{
228 QSGNode::setFlag(UsePreprocess, true);
218 memcpy(m_geometry.indexData(), indices(), indexCount * indexTypeSize);229 memcpy(m_geometry.indexData(), indices(), indexCount * indexTypeSize);
219 m_geometry.setDrawingMode(drawingMode);230 m_geometry.setDrawingMode(drawingMode);
220 m_geometry.setIndexDataPattern(indexDataPattern);231 m_geometry.setIndexDataPattern(indexDataPattern);
221232
=== modified file 'modules/Ubuntu/Components/plugin/ucubuntushape.h'
--- modules/Ubuntu/Components/plugin/ucubuntushape.h 2015-04-14 21:50:54 +0000
+++ modules/Ubuntu/Components/plugin/ucubuntushape.h 2015-04-23 08:32:05 +0000
@@ -75,6 +75,7 @@
75 virtual QSGMaterialType* type() const;75 virtual QSGMaterialType* type() const;
76 virtual QSGMaterialShader* createShader() const;76 virtual QSGMaterialShader* createShader() const;
77 virtual int compare(const QSGMaterial* other) const;77 virtual int compare(const QSGMaterial* other) const;
78 virtual void updateTextures();
78 const Data* constData() const { return &m_data; }79 const Data* constData() const { return &m_data; }
79 Data* data() { return &m_data; }80 Data* data() { return &m_data; }
8081
@@ -107,6 +108,7 @@
107 ShapeNode();108 ShapeNode();
108 ShapeMaterial* material() { return &m_material; }109 ShapeMaterial* material() { return &m_material; }
109 QSGGeometry* geometry() { return &m_geometry; }110 QSGGeometry* geometry() { return &m_geometry; }
111 void preprocess() { m_material.updateTextures(); }
110112
111private:113private:
112 ShapeMaterial m_material;114 ShapeMaterial m_material;
113115
=== modified file 'modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.cpp'
--- modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.cpp 2015-04-22 20:51:37 +0000
+++ modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.cpp 2015-04-23 08:32:05 +0000
@@ -60,6 +60,7 @@
60 , m_geometry(attributeSet(), ShapeNode::vertexCount, ShapeNode::indexCount,60 , m_geometry(attributeSet(), ShapeNode::vertexCount, ShapeNode::indexCount,
61 ShapeNode::indexType)61 ShapeNode::indexType)
62{62{
63 QSGNode::setFlag(UsePreprocess, true);
63 memcpy(m_geometry.indexData(), ShapeNode::indices(),64 memcpy(m_geometry.indexData(), ShapeNode::indices(),
64 ShapeNode::indexCount * ShapeNode::indexTypeSize);65 ShapeNode::indexCount * ShapeNode::indexTypeSize);
65 m_geometry.setDrawingMode(ShapeNode::drawingMode);66 m_geometry.setDrawingMode(ShapeNode::drawingMode);
6667
=== modified file 'modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.h'
--- modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.h 2015-03-10 18:49:20 +0000
+++ modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.h 2015-04-23 08:32:05 +0000
@@ -57,6 +57,7 @@
5757
58 ShapeOverlayNode();58 ShapeOverlayNode();
59 QSGGeometry* geometry() { return &m_geometry; }59 QSGGeometry* geometry() { return &m_geometry; }
60 void preprocess() { m_material.updateTextures(); }
6061
61private:62private:
62 ShapeOverlayMaterial m_material;63 ShapeOverlayMaterial m_material;
6364
=== added file 'tests/resources/ubuntushape/AnimatedShaderEffectSource.qml'
--- tests/resources/ubuntushape/AnimatedShaderEffectSource.qml 1970-01-01 00:00:00 +0000
+++ tests/resources/ubuntushape/AnimatedShaderEffectSource.qml 2015-04-23 08:32:05 +0000
@@ -0,0 +1,63 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17// Test if the UbuntuShape is correctly updated when its source is a ShaderEffectSource.
18
19import QtQuick 2.4
20import Ubuntu.Components 1.2
21
22Rectangle {
23 id: root
24 width: 300
25 height: 150
26 color: "#c0c0c0"
27
28 Text {
29 id: text
30 anchors.centerIn: parent
31 font.family: "Ubuntu"
32 font.pixelSize: 34
33 color: "#c0c0c0"
34 text: "This is a scrolling text... "
35 font.bold: true
36 }
37
38 ShaderEffectSource {
39 id: effectSource
40 sourceItem: text
41 hideSource: true
42 visible: false
43 }
44
45 UbuntuShape {
46 id: shape
47 anchors.fill: parent
48 anchors.margins: 50
49 backgroundColor: "black"
50 radius: "medium"
51 source: effectSource
52 sourceFillMode: UbuntuShape.Pad
53 sourceHorizontalAlignment: UbuntuShape.AlignLeft
54 sourceHorizontalWrapMode: UbuntuShape.Repeat
55
56 PropertyAnimation on sourceTranslation {
57 from: Qt.vector2d(0.0, 0.0)
58 to: Qt.vector2d(-text.width / shape.width, 0.0)
59 loops: Animation.Infinite
60 duration: 2500
61 }
62 }
63}

Subscribers

People subscribed via source and target branches