Merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-drop-shadow-aspect into lp:ubuntu-ui-toolkit/staging

Proposed by Loïc Molinari
Status: Merged
Approved by: Tim Peeters
Approved revision: 1582
Merged at revision: 1585
Proposed branch: lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-drop-shadow-aspect
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-relative-radius
Diff against target: 1355 lines (+707/-273)
10 files modified
components.api (+1/-0)
examples/ubuntu-ui-toolkit-gallery/UbuntuShape.qml (+92/-64)
src/Ubuntu/Components/plugin/shaders/shape.frag (+17/-2)
src/Ubuntu/Components/plugin/ucubuntushape.cpp (+85/-47)
src/Ubuntu/Components/plugin/ucubuntushape.h (+8/-7)
src/Ubuntu/Components/plugin/ucubuntushapetexture.h (+265/-11)
src/Ubuntu/Components/tools/createshapetextures.cpp (+233/-136)
src/Ubuntu/Components/tools/tools.pro (+2/-2)
tests/resources/ubuntushape/UbuntuShapeOverlayTest.qml (+2/-2)
tests/resources/ubuntushape/UbuntuShapeTest.qml (+2/-2)
To merge this branch: bzr merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-drop-shadow-aspect
Reviewer Review Type Date Requested Status
Tim Peeters Approve
PS Jenkins bot continuous-integration Approve
Loïc Molinari (community) Abstain
Review via email: mp+265672@code.launchpad.net

Commit message

[UbuntuShape] Added a DropShadow aspect.

Description of the change

[UbuntuShape] Added a DropShadow aspect.

To post a comment you must log in.
Revision history for this message
Loïc Molinari (loic.molinari) :
review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1581. By Loïc Molinari

Merged parent branch.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Loïc Molinari (loic.molinari) :
review: Abstain
1582. By Loïc Molinari

Fixed incorrect type definition in texture generator.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

Looks good, happroving.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2015-07-27 10:33:47 +0000
3+++ components.api 2015-07-27 16:39:42 +0000
4@@ -1316,6 +1316,7 @@
5 property bool stretched
6 property VAlignment verticalAlignment
7 Ubuntu.Components.UbuntuShape.Aspect: Enum
8+ DropShadow
9 Flat
10 Inset
11 Ubuntu.Components.UbuntuShape.BackgroundMode: Enum
12
13=== modified file 'examples/ubuntu-ui-toolkit-gallery/UbuntuShape.qml'
14--- examples/ubuntu-ui-toolkit-gallery/UbuntuShape.qml 2015-04-09 09:42:36 +0000
15+++ examples/ubuntu-ui-toolkit-gallery/UbuntuShape.qml 2015-07-27 16:39:42 +0000
16@@ -25,28 +25,95 @@
17 className: "UbuntuShape"
18
19 TemplateRow {
20- title: i18n.tr("Color")
21- titleWidth: units.gu(6)
22- height: units.gu(8)
23-
24- UbuntuShape {
25- objectName: "ubuntushape_backgroundcolor_orange"
26- backgroundColor: UbuntuColors.orange
27- }
28-
29- UbuntuShape {
30- objectName: "ubuntushape_verticalgradient"
31- backgroundColor: UbuntuColors.lightAubergine
32- secondaryBackgroundColor: Qt.rgba(
33- UbuntuColors.lightAubergine.r, UbuntuColors.lightAubergine.g,
34- UbuntuColors.lightAubergine.b, 0.25)
35- backgroundMode: UbuntuShape.VerticalGradient
36+ title: i18n.tr("Aspect")
37+ titleWidth: units.gu(8)
38+ height: units.gu(8)
39+
40+ UbuntuShape {
41+ objectName: "ubuntushape_aspect_inset"
42+ backgroundColor: UbuntuColors.orange
43+ radius: "medium"
44+ aspect: UbuntuShape.Inset
45+ Label {
46+ anchors.centerIn: parent
47+ text: "Inset"
48+ fontSize: "x-small"
49+ color: theme.palette.normal.foregroundText
50+ }
51+ }
52+
53+ UbuntuShape {
54+ objectName: "ubuntushape_aspect_dropshadow"
55+ backgroundColor: UbuntuColors.orange
56+ radius: "medium"
57+ aspect: UbuntuShape.DropShadow
58+ Label {
59+ anchors.centerIn: parent
60+ text: "DropShadow"
61+ fontSize: "xx-small"
62+ color: theme.palette.normal.foregroundText
63+ }
64+ }
65+
66+ UbuntuShape {
67+ objectName: "ubuntushape_aspect_flat"
68+ backgroundColor: UbuntuColors.orange
69+ radius: "medium"
70+ aspect: UbuntuShape.Flat
71+ Label {
72+ anchors.centerIn: parent
73+ text: "Flat"
74+ fontSize: "xx-small"
75+ color: theme.palette.normal.foregroundText
76+ }
77+ }
78+ }
79+
80+ TemplateRow {
81+ title: i18n.tr("Radius")
82+ titleWidth: units.gu(8)
83+ height: units.gu(8)
84+
85+ UbuntuShape {
86+ objectName: "ubuntushape_radius_small"
87+ backgroundColor: theme.palette.normal.foreground
88+ radius: "small"
89+ Label {
90+ anchors.centerIn: parent
91+ text: "small"
92+ fontSize: "xx-small"
93+ color: theme.palette.normal.foregroundText
94+ }
95+ }
96+
97+ UbuntuShape {
98+ objectName: "ubuntushape_radius_medium"
99+ backgroundColor: theme.palette.normal.foreground
100+ radius: "medium"
101+ Label {
102+ anchors.centerIn: parent
103+ text: "medium"
104+ fontSize: "xx-small"
105+ color: theme.palette.normal.foregroundText
106+ }
107+ }
108+
109+ UbuntuShape {
110+ objectName: "ubuntushape_radius_medium"
111+ backgroundColor: theme.palette.normal.foreground
112+ radius: "large"
113+ Label {
114+ anchors.centerIn: parent
115+ text: "large"
116+ fontSize: "xx-small"
117+ color: theme.palette.normal.foregroundText
118+ }
119 }
120 }
121
122 TemplateRow {
123 title: i18n.tr("Image")
124- titleWidth: units.gu(6)
125+ titleWidth: units.gu(8)
126 height: units.gu(8)
127
128 UbuntuShape {
129@@ -64,56 +131,17 @@
130 }
131
132 TemplateRow {
133- title: i18n.tr("Radius")
134- titleWidth: units.gu(6)
135+ title: i18n.tr("Gradient")
136+ titleWidth: units.gu(8)
137 height: units.gu(8)
138
139 UbuntuShape {
140- objectName: "ubuntushape_radius_small"
141-
142- backgroundColor: theme.palette.normal.foreground
143- radius: "small"
144-
145- Label {
146- anchors.centerIn: parent
147- text: "small"
148- fontSize: "x-small"
149- color: theme.palette.normal.foregroundText
150- }
151- }
152-
153- UbuntuShape {
154- objectName: "ubuntushape_radius_medium"
155- backgroundColor: theme.palette.normal.foreground
156- radius: "medium"
157-
158- Label {
159- anchors.centerIn: parent
160- text: "medium"
161- fontSize: "x-small"
162- color: theme.palette.normal.foregroundText
163- }
164- }
165- }
166-
167- TemplateRow {
168- title: i18n.tr("Sizes")
169- titleWidth: units.gu(6)
170- height: units.gu(20)
171-
172- UbuntuShape {
173- objectName: "ubuntushape_sizes_15_6"
174- backgroundColor: theme.palette.normal.foreground
175- width: units.gu(15)
176- height: units.gu(6)
177- anchors.verticalCenter: parent.verticalCenter
178- }
179-
180- UbuntuShape {
181- objectName: "ubuntushape_sizes_10_14"
182- backgroundColor: theme.palette.normal.foreground
183- width: units.gu(10)
184- height: units.gu(14)
185+ objectName: "ubuntushape_verticalgradient"
186+ backgroundColor: UbuntuColors.lightAubergine
187+ secondaryBackgroundColor: Qt.rgba(
188+ UbuntuColors.lightAubergine.r, UbuntuColors.lightAubergine.g,
189+ UbuntuColors.lightAubergine.b, 0.25)
190+ backgroundMode: UbuntuShape.VerticalGradient
191 }
192 }
193 }
194
195=== modified file 'src/Ubuntu/Components/plugin/shaders/shape.frag'
196--- src/Ubuntu/Components/plugin/shaders/shape.frag 2015-04-16 11:59:56 +0000
197+++ src/Ubuntu/Components/plugin/shaders/shape.frag 2015-07-27 16:39:42 +0000
198@@ -35,8 +35,9 @@
199 varying mediump vec4 sourceCoord;
200 varying lowp vec4 backgroundColor;
201
202-const mediump int FLAT = 0x08; // 1 << 3
203-const mediump int INSET = 0x10; // 1 << 4
204+const mediump int FLAT = 0x08; // 1 << 3
205+const mediump int INSET = 0x10; // 1 << 4
206+const mediump int DROP_SHADOW = 0x20; // 1 << 5
207
208 void main(void)
209 {
210@@ -88,6 +89,20 @@
211 // Mask the current color then blend the bevel over the resulting color. We simply use
212 // additive blending since the bevel has already been masked.
213 color = (color * vec4(mask[int(shapeSide)])) + vec4(bevel);
214+
215+ } else if (aspect == DROP_SHADOW) {
216+ // The vertex layout of the shape is made so that the derivative is negative from top to
217+ // middle and positive from middle to bottom.
218+ lowp float shapeSide = dfdt * dfdtFactors.y <= 0.0 ? 0.0 : 1.0;
219+ // Get the anti-aliased and resolution independent shape mask using distance fields.
220+ lowp float distanceMin = abs(dfdt) * -distanceAA + 0.5;
221+ lowp float distanceMax = abs(dfdt) * distanceAA + 0.5;
222+ lowp float mask = smoothstep(distanceMin, distanceMax, shapeData[int(shapeSide)]);
223+ // Get the shadow color outside of the shape mask.
224+ lowp float shadow = (shapeData.b * -mask) + shapeData.b; // -ab + a = a(1 - b)
225+ // Mask the current color then blend the shadow over the resulting color. We simply use
226+ // additive blending since the shadow has already been masked.
227+ color = (color * vec4(mask)) + vec4(0.0, 0.0, 0.0, shadow);
228 }
229
230 gl_FragColor = color * opacityFactors.xxxy;
231
232=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.cpp'
233--- src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-07-24 17:59:13 +0000
234+++ src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-07-27 16:39:42 +0000
235@@ -90,7 +90,7 @@
236 const ShapeMaterial::Data* data = static_cast<ShapeMaterial*>(newEffect)->constData();
237
238 // Bind shape texture.
239- glBindTexture(GL_TEXTURE_2D, data->shapeTexture);
240+ glBindTexture(GL_TEXTURE_2D, data->shapeTextureId);
241
242 // Bind source texture on the 2nd texture unit and update uniforms.
243 bool textured = false;
244@@ -119,8 +119,7 @@
245 }
246 }
247 program()->setUniformValue(m_texturedId, textured);
248- program()->setUniformValue(
249- m_aspectId, data->flags & (ShapeMaterial::Data::Flat | ShapeMaterial::Data::Inset));
250+ program()->setUniformValue(m_aspectId, data->flags & ShapeMaterial::Data::AspectMask);
251
252 // The pressed aspect is implemented by scaling the final RGB fragment color. It's not a real
253 // blending as it was done before deprecation, so for instance transparent colors remain the
254@@ -136,7 +135,7 @@
255 // and by 255 for distanceAAFactor dequantization. The factor is 1 most of the time apart when
256 // the radius size is low, it linearly goes from 1 to 0 to make the corners prettier and to
257 // prevent the opacity of the whole shape to slightly lower.
258- const float distanceAA = (shapeTextureInfo.distanceAA * distanceAApx) / (2.0 * 255.0f);
259+ const float distanceAA = (shapeTextureDistanceAA * distanceAApx) / (2.0 * 255.0f);
260 program()->setUniformValue(m_distanceAAId, data->distanceAAFactor * distanceAA);
261
262 // Send screen-space derivative factors. Note that when rendering is redirected to a
263@@ -246,12 +245,16 @@
264
265 // --- QtQuick item ---
266
267-static QHash<QOpenGLContext*, quint32> shapeTextureHash;
268-static bool isPrimaryOrientationLandscape = false;
269-
270 const float implicitWidthGU = 8.0f;
271 const float implicitHeightGU = 8.0f;
272 const float radiusGuMap[3] = { 1.45f, 2.55f, 3.65f };
273+const int maxShapeTextures = 16;
274+
275+static struct { QOpenGLContext* openglContext; quint32 textureId[shapeTextureCount]; }
276+ shapeTextures[maxShapeTextures];
277+static bool isPrimaryOrientationLandscape = false;
278+
279+static int getShapeTexturesIndex(const QOpenGLContext* openglContext);
280
281 /*! \qmltype UbuntuShape
282 \instantiates UCUbuntuShape
283@@ -1003,9 +1006,11 @@
284
285 void UCUbuntuShape::_q_openglContextDestroyed()
286 {
287- // Delete the shape texture that's stored per context and shared by all the shape items.
288- quint32 shapeTexture = shapeTextureHash.take(qobject_cast<QOpenGLContext*>(sender()));
289- glDeleteTextures(1, &shapeTexture);
290+ // Delete the shape textures that are stored per context and shared by all the shape items.
291+ const int index = getShapeTexturesIndex(qobject_cast<QOpenGLContext*>(sender()));
292+ Q_ASSERT(index >= 0);
293+ shapeTextures[index].openglContext = NULL;
294+ glDeleteTextures(shapeTextureCount, shapeTextures[index].textureId);
295 }
296
297 void UCUbuntuShape::_q_gridUnitChanged()
298@@ -1034,6 +1039,34 @@
299 m_flags |= DirtySourceTransform;
300 }
301
302+// Gets the shapeTextures' slot used by the given context, or -1 if not stored.
303+static int getShapeTexturesIndex(const QOpenGLContext* openglContext)
304+{
305+ int index = 0;
306+ while (shapeTextures[index].openglContext != openglContext) {
307+ index++;
308+ if (index == maxShapeTextures) {
309+ return -1;
310+ }
311+ }
312+ return index;
313+}
314+
315+// Gets an empty shapeTextures' slot.
316+static int getEmptyShapeTexturesIndex()
317+{
318+ int index = 0;
319+ while (shapeTextures[index].openglContext) {
320+ index++;
321+ if (index == maxShapeTextures) {
322+ // Don't bother with a dynamic array, let's just set a high enough maxShapeTextures and
323+ // increase the static array size if ever needed.
324+ qFatal("reached maximum number of OpenGL contexts supported by UbuntuShape");
325+ }
326+ }
327+ return index;
328+}
329+
330 // Gets the nearest boundary to coord in the texel grid of the given size.
331 static Q_DECL_CONSTEXPR float roundTextureCoord(float coord, float size)
332 {
333@@ -1118,20 +1151,24 @@
334 Q_ASSERT(window());
335 QOpenGLContext* openglContext = window()->openglContext();
336 Q_ASSERT(openglContext);
337- quint32 shapeTexture = shapeTextureHash[openglContext];
338- if (!shapeTexture) {
339- glGenTextures(1, &shapeTexture);
340- glBindTexture(GL_TEXTURE_2D, shapeTexture);
341- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
342- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
343- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
344- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
345- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, shapeTextureInfo.size, shapeTextureInfo.size, 0,
346- GL_RGBA, GL_UNSIGNED_BYTE, shapeTextureInfo.data);
347- shapeTextureHash[openglContext] = shapeTexture;
348+ int index = getShapeTexturesIndex(openglContext);
349+ if (index < 0) {
350+ index = getEmptyShapeTexturesIndex();
351+ shapeTextures[index].openglContext = openglContext;
352+ glGenTextures(shapeTextureCount, shapeTextures[index].textureId);
353+ for (int i = 0; i < shapeTextureCount; i++) {
354+ glBindTexture(GL_TEXTURE_2D, shapeTextures[index].textureId[i]);
355+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
356+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
357+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
358+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
359+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, shapeTextureSize, shapeTextureSize, 0, GL_RGBA,
360+ GL_UNSIGNED_BYTE, shapeTextureData[i]);
361+ }
362 QObject::connect(openglContext, SIGNAL(aboutToBeDestroyed()), this,
363 SLOT(_q_openglContextDestroyed()), Qt::DirectConnection);
364 }
365+ const quint32 shapeTextureId = shapeTextures[index].textureId[m_aspect != DropShadow ? 0 : 1];
366
367 // Get the source texture info and update the source transform if needed.
368 QSGTextureProvider* provider = m_source ? m_source->textureProvider() : NULL;
369@@ -1187,7 +1224,7 @@
370 radius = qMin(itemSize.width(), itemSize.height()) * 0.5f * (m_relativeRadius * 0.01f);
371 }
372
373- updateMaterial(node, radius, shapeTexture, sourceTexture && m_sourceOpacity);
374+ updateMaterial(node, radius, shapeTextureId, sourceTexture && m_sourceOpacity);
375
376 // Get the affine transformation for the source texture coordinates.
377 const QVector4D sourceCoordTransform(
378@@ -1231,7 +1268,7 @@
379 };
380
381 updateGeometry(
382- node, itemSize, radius, shapeTextureInfo.offset, sourceCoordTransform, sourceMaskTransform,
383+ node, itemSize, radius, shapeTextureOffset, sourceCoordTransform, sourceMaskTransform,
384 backgroundColor);
385
386 return node;
387@@ -1242,12 +1279,13 @@
388 return new ShapeNode;
389 }
390
391-void UCUbuntuShape::updateMaterial(QSGNode* node, float radius, quint32 shapeTexture, bool textured)
392+void UCUbuntuShape::updateMaterial(
393+ QSGNode* node, float radius, quint32 shapeTextureId, bool textured)
394 {
395 ShapeMaterial::Data* materialData = static_cast<ShapeNode*>(node)->material()->data();
396 quint8 flags = 0;
397
398- materialData->shapeTexture = shapeTexture;
399+ materialData->shapeTextureId = shapeTextureId;
400 if (textured) {
401 materialData->sourceTextureProvider = m_sourceTextureProvider;
402 materialData->sourceOpacity = m_sourceOpacity;
403@@ -1266,8 +1304,8 @@
404 // Mapping of radius size range from [0, 4] to [0, 1] with clamping, plus quantization.
405 const float start = 0.0f + radiusSizeOffset;
406 const float end = 4.0f + radiusSizeOffset;
407- materialData->distanceAAFactor = qMin(
408- (radius / (end - start)) - (start / (end - start)), 1.0f) * 255.0f;
409+ materialData->distanceAAFactor =
410+ qMin((radius / (end - start)) - (start / (end - start)), 1.0f) * 255.0f;
411
412 // Screen-space derivatives factors for fragment shaders depend on the primary orientation and
413 // content orientation. A flag indicating a 90° rotation around the primary orientation is
414@@ -1293,12 +1331,12 @@
415 // optimal performance.
416 if (radius > radiusSizeOffset) {
417 const quint8 aspectFlags[] = {
418- ShapeMaterial::Data::Flat, ShapeMaterial::Data::Inset,
419+ ShapeMaterial::Data::Flat, ShapeMaterial::Data::Inset, ShapeMaterial::Data::DropShadow,
420 ShapeMaterial::Data::Inset | ShapeMaterial::Data::Pressed
421 };
422 flags |= aspectFlags[m_aspect];
423 } else {
424- const quint8 aspectFlags[] = { 0, 0, ShapeMaterial::Data::Pressed };
425+ const quint8 aspectFlags[] = { 0, 0, 0, ShapeMaterial::Data::Pressed };
426 flags |= aspectFlags[m_aspect];
427 }
428
429@@ -1320,8 +1358,8 @@
430 // Set top row of 3 vertices.
431 v[0].position[0] = 0.0f;
432 v[0].position[1] = 0.0f;
433- v[0].shapeCoordinate[0] = shapeTextureInfo.offset;
434- v[0].shapeCoordinate[1] = shapeTextureInfo.offset;
435+ v[0].shapeCoordinate[0] = shapeTextureOffset;
436+ v[0].shapeCoordinate[1] = shapeTextureOffset;
437 v[0].sourceCoordinate[0] = sourceCoordTransform.z();
438 v[0].sourceCoordinate[1] = sourceCoordTransform.w();
439 v[0].sourceCoordinate[2] = sourceMaskTransform.z();
440@@ -1329,8 +1367,8 @@
441 v[0].backgroundColor = backgroundColor[0];
442 v[1].position[0] = 0.5f * itemSize.width();
443 v[1].position[1] = 0.0f;
444- v[1].shapeCoordinate[0] = (0.5f * itemSize.width()) / radius - shapeTextureInfo.offset;
445- v[1].shapeCoordinate[1] = shapeTextureInfo.offset;
446+ v[1].shapeCoordinate[0] = (0.5f * itemSize.width()) / radius - shapeTextureOffset;
447+ v[1].shapeCoordinate[1] = shapeTextureOffset;
448 v[1].sourceCoordinate[0] = 0.5f * sourceCoordTransform.x() + sourceCoordTransform.z();
449 v[1].sourceCoordinate[1] = sourceCoordTransform.w();
450 v[1].sourceCoordinate[2] = 0.5f * sourceMaskTransform.x() + sourceMaskTransform.z();
451@@ -1338,8 +1376,8 @@
452 v[1].backgroundColor = backgroundColor[0];
453 v[2].position[0] = itemSize.width();
454 v[2].position[1] = 0.0f;
455- v[2].shapeCoordinate[0] = shapeTextureInfo.offset;
456- v[2].shapeCoordinate[1] = shapeTextureInfo.offset;
457+ v[2].shapeCoordinate[0] = shapeTextureOffset;
458+ v[2].shapeCoordinate[1] = shapeTextureOffset;
459 v[2].sourceCoordinate[0] = sourceCoordTransform.x() + sourceCoordTransform.z();
460 v[2].sourceCoordinate[1] = sourceCoordTransform.w();
461 v[2].sourceCoordinate[2] = sourceMaskTransform.x() + sourceMaskTransform.z();
462@@ -1349,8 +1387,8 @@
463 // Set middle row of 3 vertices.
464 v[3].position[0] = 0.0f;
465 v[3].position[1] = 0.5f * itemSize.height();
466- v[3].shapeCoordinate[0] = shapeTextureInfo.offset;
467- v[3].shapeCoordinate[1] = (0.5f * itemSize.height()) / radius - shapeTextureInfo.offset;
468+ v[3].shapeCoordinate[0] = shapeTextureOffset;
469+ v[3].shapeCoordinate[1] = (0.5f * itemSize.height()) / radius - shapeTextureOffset;
470 v[3].sourceCoordinate[0] = sourceCoordTransform.z();
471 v[3].sourceCoordinate[1] = 0.5f * sourceCoordTransform.y() + sourceCoordTransform.w();
472 v[3].sourceCoordinate[2] = sourceMaskTransform.z();
473@@ -1358,8 +1396,8 @@
474 v[3].backgroundColor = backgroundColor[1];
475 v[4].position[0] = 0.5f * itemSize.width();
476 v[4].position[1] = 0.5f * itemSize.height();
477- v[4].shapeCoordinate[0] = (0.5f * itemSize.width()) / radius - shapeTextureInfo.offset;
478- v[4].shapeCoordinate[1] = (0.5f * itemSize.height()) / radius - shapeTextureInfo.offset;
479+ v[4].shapeCoordinate[0] = (0.5f * itemSize.width()) / radius - shapeTextureOffset;
480+ v[4].shapeCoordinate[1] = (0.5f * itemSize.height()) / radius - shapeTextureOffset;
481 v[4].sourceCoordinate[0] = 0.5f * sourceCoordTransform.x() + sourceCoordTransform.z();
482 v[4].sourceCoordinate[1] = 0.5f * sourceCoordTransform.y() + sourceCoordTransform.w();
483 v[4].sourceCoordinate[2] = 0.5f * sourceMaskTransform.x() + sourceMaskTransform.z();
484@@ -1367,8 +1405,8 @@
485 v[4].backgroundColor = backgroundColor[1];
486 v[5].position[0] = itemSize.width();
487 v[5].position[1] = 0.5f * itemSize.height();
488- v[5].shapeCoordinate[0] = shapeTextureInfo.offset;
489- v[5].shapeCoordinate[1] = (0.5f * itemSize.height()) / radius - shapeTextureInfo.offset;
490+ v[5].shapeCoordinate[0] = shapeTextureOffset;
491+ v[5].shapeCoordinate[1] = (0.5f * itemSize.height()) / radius - shapeTextureOffset;
492 v[5].sourceCoordinate[0] = sourceCoordTransform.x() + sourceCoordTransform.z();
493 v[5].sourceCoordinate[1] = 0.5f * sourceCoordTransform.y() + sourceCoordTransform.w();
494 v[5].sourceCoordinate[2] = sourceMaskTransform.x() + sourceMaskTransform.z();
495@@ -1378,8 +1416,8 @@
496 // Set bottom row of 3 vertices.
497 v[6].position[0] = 0.0f;
498 v[6].position[1] = itemSize.height();
499- v[6].shapeCoordinate[0] = shapeTextureInfo.offset;
500- v[6].shapeCoordinate[1] = shapeTextureInfo.offset;
501+ v[6].shapeCoordinate[0] = shapeTextureOffset;
502+ v[6].shapeCoordinate[1] = shapeTextureOffset;
503 v[6].sourceCoordinate[0] = sourceCoordTransform.z();
504 v[6].sourceCoordinate[1] = sourceCoordTransform.y() + sourceCoordTransform.w();
505 v[6].sourceCoordinate[2] = sourceMaskTransform.z();
506@@ -1387,8 +1425,8 @@
507 v[6].backgroundColor = backgroundColor[2];
508 v[7].position[0] = 0.5f * itemSize.width();
509 v[7].position[1] = itemSize.height();
510- v[7].shapeCoordinate[0] = (0.5f * itemSize.width()) / radius - shapeTextureInfo.offset;
511- v[7].shapeCoordinate[1] = shapeTextureInfo.offset;
512+ v[7].shapeCoordinate[0] = (0.5f * itemSize.width()) / radius - shapeTextureOffset;
513+ v[7].shapeCoordinate[1] = shapeTextureOffset;
514 v[7].sourceCoordinate[0] = 0.5f * sourceCoordTransform.x() + sourceCoordTransform.z();
515 v[7].sourceCoordinate[1] = sourceCoordTransform.y() + sourceCoordTransform.w();
516 v[7].sourceCoordinate[2] = 0.5f * sourceMaskTransform.x() + sourceMaskTransform.z();
517@@ -1396,8 +1434,8 @@
518 v[7].backgroundColor = backgroundColor[2];
519 v[8].position[0] = itemSize.width();
520 v[8].position[1] = itemSize.height();
521- v[8].shapeCoordinate[0] = shapeTextureInfo.offset;
522- v[8].shapeCoordinate[1] = shapeTextureInfo.offset;
523+ v[8].shapeCoordinate[0] = shapeTextureOffset;
524+ v[8].shapeCoordinate[1] = shapeTextureOffset;
525 v[8].sourceCoordinate[0] = sourceCoordTransform.x() + sourceCoordTransform.z();
526 v[8].sourceCoordinate[1] = sourceCoordTransform.y() + sourceCoordTransform.w();
527 v[8].sourceCoordinate[2] = sourceMaskTransform.x() + sourceMaskTransform.z();
528
529=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.h'
530--- src/Ubuntu/Components/plugin/ucubuntushape.h 2015-07-22 15:51:14 +0000
531+++ src/Ubuntu/Components/plugin/ucubuntushape.h 2015-07-27 16:39:42 +0000
532@@ -62,10 +62,12 @@
533 Repeated = (HorizontallyRepeated | VerticallyRepeated),
534 Flat = (1 << 3),
535 Inset = (1 << 4),
536- Pressed = (1 << 5)
537+ DropShadow = (1 << 5),
538+ AspectMask = (Flat | Inset | DropShadow),
539+ Pressed = (1 << 6)
540 };
541 QSGTextureProvider* sourceTextureProvider;
542- quint32 shapeTexture;
543+ quint32 shapeTextureId;
544 quint8 distanceAAFactor;
545 quint8 sourceOpacity;
546 quint8 dfdtFactors;
547@@ -178,7 +180,7 @@
548 public:
549 UCUbuntuShape(QQuickItem* parent=0);
550
551- enum Aspect { Flat = 0, Inset = 1 }; // Don't forget to update private enum if extended.
552+ enum Aspect { Flat = 0, Inset = 1, DropShadow = 2 }; // Don't forget to update private enum.
553 enum BackgroundMode { SolidColor = 0, VerticalGradient = 1 };
554 enum HAlignment { AlignLeft = 0, AlignHCenter = 1, AlignRight = 2 };
555 enum VAlignment { AlignTop = 0, AlignVCenter = 1, AlignBottom = 2 };
556@@ -287,7 +289,7 @@
557
558 // Virtual functions for extended shapes.
559 virtual QSGNode* createSceneGraphNode() const;
560- virtual void updateMaterial(QSGNode* node, float radius, quint32 shapeTexture, bool textured);
561+ virtual void updateMaterial(QSGNode* node, float radius, quint32 shapeTextureId, bool textured);
562 virtual void updateGeometry(
563 QSGNode* node, const QSizeF& itemSize, float radius, float shapeOffset,
564 const QVector4D& sourceCoordTransform, const QVector4D& sourceMaskTransform,
565@@ -312,7 +314,7 @@
566 VAlignment verticalAlignment, const QSize& textureSize);
567
568 enum Radius { Small = 0, Medium = 1, Large = 2 };
569- enum { Pressed = 2 }; // Aspect extension (to keep support for deprecated aspects).
570+ enum { Pressed = 3 }; // Aspect extension (to keep support for deprecated aspects).
571 enum {
572 AspectSet = (1 << 0),
573 GradientColorSet = (1 << 1),
574@@ -331,7 +333,7 @@
575 QVector4D m_sourceTransform;
576 Radius m_radius : 2;
577 quint8 m_relativeRadius : 6;
578- quint8 m_aspect : 2;
579+ quint8 m_aspect : 3;
580 HAlignment m_imageHorizontalAlignment : 2;
581 VAlignment m_imageVerticalAlignment : 2;
582 BackgroundMode m_backgroundMode : 1;
583@@ -340,7 +342,6 @@
584 FillMode m_sourceFillMode : 2;
585 WrapMode m_sourceHorizontalWrapMode : 1;
586 WrapMode m_sourceVerticalWrapMode : 1;
587- quint8 __explicit_padding : 1;
588 quint8 m_sourceOpacity;
589 quint8 m_flags;
590
591
592=== modified file 'src/Ubuntu/Components/plugin/ucubuntushapetexture.h'
593--- src/Ubuntu/Components/plugin/ucubuntushapetexture.h 2015-04-08 10:46:56 +0000
594+++ src/Ubuntu/Components/plugin/ucubuntushapetexture.h 2015-07-27 16:39:42 +0000
595@@ -1,15 +1,12 @@
596 // Copyright 2015 Canonical Ltd.
597-// Automatically generated by the createshapeimage tool.
598-
599-static const struct {
600- float offset;
601- float distanceAA;
602- int size;
603- unsigned char data[4097];
604-} shapeTextureInfo = {
605- 0.0625,
606- 4,
607- 32,
608+// Automatically generated by the createshapetextures tool.
609+
610+const int shapeTextureCount = 2;
611+const int shapeTextureSize = 32;
612+const float shapeTextureOffset = 0.0625;
613+const int shapeTextureDistanceAA = 4;
614+
615+static const unsigned char shapeTextureData[2][4097] = {
616 "\x5e\x5e\x00\x00\x5e\x5e\x00\x00\x5e\x5e\x00\x00\x5e\x5e\x00\x00"
617 "\x5e\x5e\x00\x00\x5e\x5e\x00\x00\x5e\x5e\x00\x00\x5e\x5e\x00\x00"
618 "\x5e\x5e\x00\x00\x5e\x5e\x00\x00\x5e\x5e\x00\x00\x5e\x5e\x06\x00"
619@@ -266,4 +263,261 @@
620 "\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
621 "\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
622 "\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff\x00\x00\xff\xff"
623+ ,
624+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
625+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
626+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
627+ "\x08\x00\x00\x00\x12\x00\x00\x00\x1a\x00\x00\x00\x1f\x00\x00\x00"
628+ "\x29\x00\x00\x00\x2e\x00\x00\x00\x33\x00\x00\x00\x38\x01\x00\x00"
629+ "\x3d\x05\x00\x00\x40\x09\x00\x00\x43\x0b\x00\x00\x46\x0e\x00\x00"
630+ "\x48\x10\x00\x00\x49\x12\x00\x00\x4a\x12\x00\x00\x4b\x13\x00\x00"
631+ "\x4c\x14\x00\x00\x4d\x15\x00\x00\x4d\x15\x00\x00\x4e\x16\x00\x00"
632+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
633+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
634+ "\x00\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x1a\x00\x00\x00"
635+ "\x25\x00\x00\x00\x30\x00\x00\x00\x38\x03\x00\x00\x3f\x0a\x00\x00"
636+ "\x47\x12\x00\x00\x4e\x16\x00\x00\x53\x1b\x00\x00\x58\x20\x00\x00"
637+ "\x5d\x25\x00\x00\x60\x29\x00\x00\x63\x2b\x00\x00\x66\x2e\x00\x00"
638+ "\x68\x30\x00\x00\x69\x31\x00\x00\x6a\x32\x00\x00\x6b\x33\x00\x00"
639+ "\x6c\x34\x00\x00\x6c\x35\x00\x00\x6d\x35\x00\x00\x6e\x36\x00\x00"
640+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
641+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
642+ "\x0b\x00\x00\x00\x1b\x00\x00\x00\x28\x00\x00\x00\x38\x03\x00\x00"
643+ "\x3f\x0f\x00\x00\x50\x1a\x00\x00\x57\x22\x00\x00\x5f\x27\x00\x00"
644+ "\x67\x30\x00\x00\x6e\x36\x00\x00\x73\x3b\x00\x00\x78\x40\x00\x00"
645+ "\x7d\x45\x01\x00\x80\x48\x05\x00\x83\x4b\x0a\x00\x85\x4e\x0e\x00"
646+ "\x88\x50\x11\x00\x89\x51\x12\x00\x8a\x52\x14\x00\x8b\x53\x15\x00"
647+ "\x8c\x54\x16\x00\x8c\x54\x17\x00\x8d\x55\x19\x00\x8e\x56\x1a\x00"
648+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
649+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x13\x00\x00\x00"
650+ "\x26\x00\x00\x00\x36\x06\x00\x00\x46\x13\x00\x00\x52\x22\x00\x00"
651+ "\x5f\x2c\x00\x00\x6c\x37\x00\x00\x78\x3f\x00\x00\x7f\x47\x0a\x00"
652+ "\x86\x50\x17\x00\x8e\x56\x20\x00\x93\x5b\x28\x00\x98\x60\x30\x00"
653+ "\x9c\x65\x36\x00\xa0\x68\x3a\x00\xa3\x6b\x3e\x00\xa5\x6e\x42\x00"
654+ "\xa8\x70\x44\x00\xa9\x71\x45\x00\xaa\x72\x46\x00\xab\x73\x47\x00"
655+ "\xab\x74\x48\x00\xac\x74\x49\x00\xad\x75\x4a\x00\xae\x76\x4c\x00"
656+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
657+ "\x00\x00\x00\x00\x03\x00\x00\x00\x18\x00\x00\x00\x2c\x00\x00\x00"
658+ "\x40\x12\x00\x00\x51\x23\x00\x00\x61\x2f\x00\x00\x71\x3f\x00\x00"
659+ "\x7f\x47\x10\x00\x8a\x53\x25\x00\x96\x5f\x33\x00\x9f\x67\x3f\x00"
660+ "\xa6\x6e\x49\x00\xae\x76\x51\x00\xb3\x7b\x58\x00\xb8\x80\x5e\x00"
661+ "\xbc\x84\x63\x00\xc0\x88\x66\x00\xc3\x8b\x6a\x00\xc5\x8d\x6d\x00"
662+ "\xc8\x90\x6f\x00\xc9\x91\x70\x00\xca\x92\x71\x00\xcb\x93\x71\x00"
663+ "\xcb\x93\x72\x00\xcc\x94\x73\x00\xcd\x95\x74\x00\xce\x96\x75\x00"
664+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
665+ "\x00\x00\x00\x00\x18\x00\x00\x00\x30\x05\x00\x00\x45\x19\x00\x00"
666+ "\x59\x2c\x00\x00\x6d\x3e\x00\x00\x7e\x4e\x15\x00\x8e\x59\x31\x00"
667+ "\x9e\x67\x44\x00\xab\x74\x55\x00\xb6\x7f\x60\x00\xbf\x86\x6a\x00"
668+ "\xc6\x8f\x73\x00\xcd\x96\x7a\x00\xd3\x9b\x7f\x00\xd7\xa0\x84\x00"
669+ "\xdc\xa4\x88\x00\xe0\xa8\x8b\x00\xe2\xab\x8d\x00\xe5\xad\x90\x00"
670+ "\xe8\xb0\x92\x00\xe9\xb1\x92\x00\xea\xb2\x93\x00\xea\xb3\x94\x00"
671+ "\xeb\xb3\x94\x00\xec\xb4\x95\x00\xed\xb5\x96\x00\xed\xb6\x97\x00"
672+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
673+ "\x14\x00\x00\x00\x2c\x09\x00\x00\x45\x1e\x00\x00\x5d\x32\x00\x00"
674+ "\x72\x46\x07\x00\x86\x57\x2a\x00\x9a\x69\x44\x00\xab\x79\x58\x00"
675+ "\xb9\x86\x6f\x00\xcb\x93\x77\x00\xd1\x9e\x83\x00\xdc\xa7\x8e\x00"
676+ "\xe4\xae\x93\x00\xeb\xb6\x9a\x00\xf3\xbb\x9e\x00\xf7\xc0\xa2\x00"
677+ "\xfb\xc4\xa5\x00\xff\xc8\xa7\x00\xff\xcb\xa9\x00\xff\xcd\xab\x00"
678+ "\xff\xd0\xac\x00\xff\xd1\xad\x00\xff\xd2\xad\x00\xff\xd2\xae\x00"
679+ "\xff\xd3\xae\x00\xff\xd4\xaf\x00\xff\xd5\xaf\x00\xff\xd5\xb0\x00"
680+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0d\x00\x00\x00"
681+ "\x27\x04\x00\x00\x41\x1d\x00\x00\x59\x36\x00\x00\x72\x4b\x0d\x00"
682+ "\x8a\x5f\x31\x00\x9f\x73\x4e\x00\xb3\x84\x67\x00\xc5\x96\x7d\x00"
683+ "\xd7\xa6\x8b\x00\xe4\xaf\x96\x00\xef\xbe\xa0\x00\xfa\xc6\xa9\x00"
684+ "\xff\xcd\xac\x00\xff\xd5\xb2\x00\xff\xdb\xb4\x00\xff\xdf\xb7\x00"
685+ "\xff\xe4\xba\x00\xff\xe8\xbc\x00\xff\xea\xbd\x00\xff\xed\xbe\x00"
686+ "\xff\xf0\xbf\x00\xff\xf1\xbf\x00\xff\xf1\xc0\x00\xff\xf2\xc0\x00"
687+ "\xff\xf3\xc0\x00\xff\xf4\xc0\x00\xff\xf5\xc1\x00\xff\xf5\xc1\x00"
688+ "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1d\x00\x00\x00"
689+ "\x38\x19\x00\x00\x52\x32\x00\x00\x6e\x4a\x07\x00\x86\x63\x31\x00"
690+ "\x9f\x78\x54\x00\xb7\x8c\x6f\x00\xcc\xa0\x86\x00\xe0\xb1\x97\x00"
691+ "\xf1\xbf\xa4\x00\xff\xcf\xaf\x00\xff\xda\xb6\x00\xff\xe3\xbb\x00"
692+ "\xff\xeb\xbf\x00\xff\xf5\xc2\x00\xff\xfa\xc4\x00\xff\xff\xc5\x00"
693+ "\xff\xff\xc7\x00\xff\xff\xc8\x00\xff\xff\xc8\x00\xff\xff\xc9\x00"
694+ "\xff\xff\xc9\x00\xff\xff\xca\x00\xff\xff\xca\x00\xff\xff\xca\x00"
695+ "\xff\xff\xca\x00\xff\xff\xca\x00\xff\xff\xca\x00\xff\xff\xca\x00"
696+ "\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x00\x00\x00\x2a\x10\x00\x00"
697+ "\x48\x2c\x00\x00\x63\x46\x00\x00\x80\x5f\x2a\x00\x9b\x77\x4f\x00"
698+ "\xb4\x90\x6f\x00\xcc\xa5\x8a\x00\xe4\xb9\x9e\x00\xf9\xcc\xad\x00"
699+ "\xff\xdd\xb8\x00\xff\xeb\xbf\x00\xff\xf7\xc4\x00\xff\xff\xc7\x00"
700+ "\xff\xff\xc9\x00\xff\xff\xcb\x00\xff\xff\xcb\x00\xff\xff\xcc\x00"
701+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
702+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
703+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
704+ "\x00\x00\x00\x00\x00\x00\x00\x00\x1d\x06\x00\x00\x3a\x23\x00\x00"
705+ "\x54\x3c\x00\x00\x73\x56\x16\x00\x90\x73\x45\x00\xad\x8c\x68\x00"
706+ "\xc7\xa4\x86\x00\xe1\xbd\x9e\x00\xf9\xd2\xb0\x00\xff\xe6\xbc\x00"
707+ "\xff\xf7\xc4\x00\xff\xff\xc9\x00\xff\xff\xcb\x00\xff\xff\xcc\x00"
708+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
709+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
710+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
711+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
712+ "\x00\x00\x00\x00\x0a\x00\x00\x00\x27\x11\x00\x00\x42\x2f\x00\x00"
713+ "\x62\x4e\x00\x00\x81\x69\x31\x00\xa0\x83\x58\x00\xba\xa0\x7d\x00"
714+ "\xd8\xb9\x97\x00\xf2\xd2\xae\x00\xff\xea\xbc\x00\xff\xff\xc6\x00"
715+ "\xff\xff\xcb\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
716+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
717+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
718+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
719+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
720+ "\x00\x00\x00\x00\x15\x01\x00\x00\x33\x20\x00\x00\x50\x3d\x00\x00"
721+ "\x6e\x56\x10\x00\x8d\x77\x45\x00\xad\x96\x6f\x00\xcd\xb0\x8b\x00"
722+ "\xe6\xcb\xa4\x00\xff\xe6\xb8\x00\xff\xff\xc4\x00\xff\xff\xcb\x00"
723+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
724+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
725+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
726+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
727+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
728+ "\x00\x00\x00\x00\x1d\x0d\x00\x00\x3b\x2a\x00\x00\x59\x45\x00\x00"
729+ "\x7b\x65\x25\x00\x99\x83\x55\x00\xb9\xa4\x77\x00\xd4\xbe\x96\x00"
730+ "\xf2\xdb\xaf\x00\xff\xf6\xbf\x00\xff\xff\xc9\x00\xff\xff\xcc\x00"
731+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
732+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
733+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
734+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
735+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
736+ "\x06\x00\x00\x00\x24\x17\x00\x00\x42\x35\x00\x00\x62\x52\x00\x00"
737+ "\x82\x71\x33\x00\xa2\x91\x60\x00\xc1\xae\x83\x00\xde\xce\xa0\x00"
738+ "\xfd\xea\xb6\x00\xff\xff\xc4\x00\xff\xff\xcb\x00\xff\xff\xcc\x00"
739+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
740+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
741+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
742+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
743+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
744+ "\x0d\x01\x00\x00\x2a\x1f\x00\x00\x4a\x3c\x00\x00\x6a\x5c\x09\x00"
745+ "\x89\x7d\x3f\x00\xaa\x9c\x6a\x00\xc9\xbc\x8e\x00\xe7\xd7\xa9\x00"
746+ "\xff\xf4\xbb\x00\xff\xff\xc7\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
747+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
748+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
749+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
750+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
751+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
752+ "\x12\x08\x00\x00\x32\x26\x00\x00\x52\x44\x00\x00\x71\x64\x18\x00"
753+ "\x91\x83\x4a\x00\xb1\xa4\x73\x00\xd0\xc4\x93\x00\xee\xe1\xac\x00"
754+ "\xff\xff\xbf\x00\xff\xff\xc9\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
755+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
756+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
757+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
758+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
759+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
760+ "\x17\x0e\x00\x00\x37\x2c\x00\x00\x57\x4c\x00\x00\x78\x6c\x21\x00"
761+ "\x96\x8b\x51\x00\xb6\xab\x7a\x00\xd6\xcb\x9a\x00\xf5\xe9\xb2\x00"
762+ "\xff\xff\xc2\x00\xff\xff\xcb\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
763+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
764+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
765+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
766+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
767+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
768+ "\x1c\x13\x00\x00\x3c\x33\x00\x00\x5b\x53\x00\x00\x7c\x73\x28\x00"
769+ "\x9b\x93\x58\x00\xbb\xb2\x7f\x00\xdb\xd2\x9e\x00\xfb\xf0\xb5\x00"
770+ "\xff\xff\xc4\x00\xff\xff\xcb\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
771+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
772+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
773+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
774+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
775+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
776+ "\x20\x18\x00\x00\x40\x38\x00\x00\x60\x58\x00\x00\x80\x79\x30\x00"
777+ "\xa0\x98\x5e\x00\xc0\xb7\x84\x00\xe0\xd7\xa2\x00\xff\xf7\xb7\x00"
778+ "\xff\xff\xc5\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
779+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
780+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
781+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
782+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
783+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
784+ "\x24\x1d\x00\x00\x44\x3d\x00\x00\x64\x5d\x01\x00\x83\x7d\x36\x00"
785+ "\xa4\x9c\x63\x00\xc4\xbc\x88\x00\xe4\xdc\xa5\x00\xff\xfb\xba\x00"
786+ "\xff\xff\xc7\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
787+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
788+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
789+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
790+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
791+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
792+ "\x27\x22\x00\x00\x47\x42\x00\x00\x67\x61\x05\x00\x85\x81\x3a\x00"
793+ "\xa6\xa1\x67\x00\xc6\xc1\x8b\x00\xe6\xe1\xa7\x00\xff\xff\xbc\x00"
794+ "\xff\xff\xc8\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
795+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
796+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
797+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
798+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
799+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
800+ "\x2a\x25\x00\x00\x49\x45\x00\x00\x69\x65\x08\x00\x88\x84\x3e\x00"
801+ "\xa9\xa4\x6a\x00\xc9\xc4\x8e\x00\xe9\xe4\xa9\x00\xff\xff\xbd\x00"
802+ "\xff\xff\xc8\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
803+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
804+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
805+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
806+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
807+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
808+ "\x2c\x28\x00\x00\x4c\x47\x00\x00\x6c\x67\x0c\x00\x8b\x86\x42\x00"
809+ "\xac\xa7\x6d\x00\xcb\xc7\x90\x00\xeb\xe7\xab\x00\xff\xff\xbe\x00"
810+ "\xff\xff\xc9\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
811+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
812+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
813+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
814+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
815+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
816+ "\x2e\x2a\x00\x00\x4d\x4a\x00\x00\x6d\x6a\x0f\x00\x8d\x89\x44\x00"
817+ "\xad\xaa\x6f\x00\xcd\xca\x92\x00\xed\xe9\xac\x00\xff\xff\xbf\x00"
818+ "\xff\xff\xc9\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
819+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
820+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
821+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
822+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
823+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
824+ "\x2e\x2d\x00\x00\x4e\x4d\x00\x00\x6e\x6c\x11\x00\x8f\x8c\x45\x00"
825+ "\xae\xac\x70\x00\xce\xcc\x92\x00\xee\xec\xad\x00\xff\xff\xbf\x00"
826+ "\xff\xff\xca\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
827+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
828+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
829+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
830+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
831+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
832+ "\x2f\x2e\x00\x00\x4f\x4e\x00\x00\x6f\x6d\x12\x00\x8f\x8e\x46\x00"
833+ "\xaf\xad\x71\x00\xcf\xcd\x93\x00\xef\xed\xad\x00\xff\xff\xc0\x00"
834+ "\xff\xff\xca\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
835+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
836+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
837+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
838+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
839+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
840+ "\x30\x2e\x00\x00\x50\x4e\x00\x00\x70\x6e\x14\x00\x90\x8f\x47\x00"
841+ "\xaf\xae\x71\x00\xcf\xce\x94\x00\xef\xee\xae\x00\xff\xff\xc0\x00"
842+ "\xff\xff\xca\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
843+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
844+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
845+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
846+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
847+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
848+ "\x30\x2f\x00\x00\x50\x4f\x00\x00\x70\x6f\x16\x00\x90\x8f\x48\x00"
849+ "\xb0\xaf\x72\x00\xd0\xcf\x94\x00\xf0\xef\xae\x00\xff\xff\xc0\x00"
850+ "\xff\xff\xca\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
851+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
852+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
853+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
854+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
855+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
856+ "\x31\x30\x00\x00\x51\x50\x00\x00\x70\x70\x18\x00\x91\x90\x49\x00"
857+ "\xb1\xb0\x73\x00\xd1\xcf\x95\x00\xf0\xef\xaf\x00\xff\xff\xc0\x00"
858+ "\xff\xff\xca\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
859+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
860+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
861+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
862+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
863+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
864+ "\x32\x30\x00\x00\x52\x50\x00\x00\x72\x70\x1a\x00\x92\x90\x4b\x00"
865+ "\xb2\xb0\x74\x00\xd1\xd0\x96\x00\xf1\xf0\xaf\x00\xff\xff\xc1\x00"
866+ "\xff\xff\xca\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
867+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
868+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
869+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
870+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
871+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
872+ "\x33\x31\x00\x00\x53\x51\x00\x00\x73\x71\x1a\x00\x92\x91\x4c\x00"
873+ "\xb2\xb1\x75\x00\xd2\xd1\x97\x00\xf2\xf1\xb0\x00\xff\xff\xc1\x00"
874+ "\xff\xff\xca\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
875+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
876+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
877+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
878+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
879+ "\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00\xff\xff\xcc\x00"
880 };
881
882=== renamed file 'src/Ubuntu/Components/tools/createshapeimage.cpp' => 'src/Ubuntu/Components/tools/createshapetextures.cpp'
883--- src/Ubuntu/Components/tools/createshapeimage.cpp 2015-04-08 10:51:43 +0000
884+++ src/Ubuntu/Components/tools/createshapetextures.cpp 2015-07-27 16:39:42 +0000
885@@ -24,7 +24,7 @@
886 // In order to generate a new file, the following commands must be used:
887 // $ cd tools
888 // $ qmake && make
889-// $ ./createshapeimage shape.svg ../plugin/ucubuntushapetexture.h
890+// $ ./createshapetextures shape.svg ../plugin/ucubuntushapetexture.h
891
892 #include <QtCore/QFile>
893 #include <QtCore/QTextStream>
894@@ -35,16 +35,10 @@
895 #include "3rd_party/edtaa3func.c"
896
897 // Input data.
898+const int textureCount = 2;
899 const int textureSize = 32; // Must be a power-of-2.
900 const double distanceScale = 4.0;
901-const double shadowScale = 7.5;
902-const double shadowTranslucency = 0.37;
903 const double shapeOffset = 0.0625;
904-const double distanceBottomTY = 0.0546875; // From shapeOffset.
905-const double shadowTopTX = -0.01171875; // From shapeOffset.
906-const double shadowTopTY = 0.03125; // From shapeOffset.
907-const double shadowBottomTX = -0.01171875; // From shapeOffset.
908-const double shadowBottomTY = -0.00390625; // From shapeOffset.
909
910 // Sizes.
911 const int width = textureSize;
912@@ -66,13 +60,224 @@
913 static double gradientX[size];
914 static double gradientY[size];
915
916-// Final image buffer.
917-static uint imageData[size];
918+// Final texture buffers.
919+static uint textureData[2][size];
920+
921+// Creates the inset and flat aspect texture.
922+static void createTexture1(QSvgRenderer* svg, QPainter* painter)
923+{
924+ // Input data.
925+ const double shadowScale = 7.5;
926+ const double shadowTranslucency = 0.37;
927+ const double distanceBottomTY = 0.0546875; // From shapeOffset.
928+ const double shadowTopTX = -0.01171875; // From shapeOffset.
929+ const double shadowTopTY = 0.03125; // From shapeOffset.
930+ const double shadowBottomTX = -0.01171875; // From shapeOffset.
931+ const double shadowBottomTY = -0.00390625; // From shapeOffset.
932+
933+ // Render and store the distance field used for masking the top of the shape, for masking the
934+ // bevel and for masking the unstyled shape.
935+ painter->translate(shapeOffset * width, shapeOffset * width);
936+ svg->render(painter);
937+ for (int i = 0; i < size; i++) {
938+ shapeNormalized[i] = static_cast<double>(shapeData[i] >> 24) / 255.0;
939+ }
940+ computegradient(shapeNormalized, width, height, gradientX, gradientY);
941+ edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
942+ distanceOut);
943+ for (int i = 0; i < size; i++) {
944+ shapeNormalized[i] = 1.0 - shapeNormalized[i];
945+ }
946+ memset(gradientX, 0, size * sizeof(double));
947+ memset(gradientY, 0, size * sizeof(double));
948+ computegradient(shapeNormalized, width, height, gradientX, gradientY);
949+ edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
950+ distanceIn);
951+ for (int i = 0; i < size; i++) {
952+ const double distance = qMax(0.0, distanceIn[i]) - qMax(0.0, distanceOut[i]);
953+ const uint value = qBound(0, qRound(distance * distanceScale * imageScale + 127.5), 255);
954+ textureData[0][i] = value << 16; // Stored in channel R (exposed as B in the shaders).
955+ }
956+
957+ // Render and store the distance field used for masking the bottom of the shape and for masking
958+ // the bevel.
959+ memset(shapeData, 0, size * sizeof(uint));
960+ painter->resetTransform();
961+ painter->translate(shapeOffset * width, (shapeOffset + distanceBottomTY) * width);
962+ svg->render(painter);
963+ for (int i = 0; i < size; i++) {
964+ shapeNormalized[i] = static_cast<double>(shapeData[i] >> 24) / 255.0;
965+ }
966+ computegradient(shapeNormalized, width, height, gradientX, gradientY);
967+ edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
968+ distanceOut);
969+ for (int i = 0; i < size; i++) {
970+ shapeNormalized[i] = 1.0 - shapeNormalized[i];
971+ }
972+ memset(gradientX, 0, size * sizeof(double));
973+ memset(gradientY, 0, size * sizeof(double));
974+ computegradient(shapeNormalized, width, height, gradientX, gradientY);
975+ edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
976+ distanceIn);
977+ for (int i = 0; i < size; i++) {
978+ const double distance = qMax(0.0, distanceIn[i]) - qMax(0.0, distanceOut[i]);
979+ const uint value = qBound(0, qRound(distance * distanceScale * imageScale + 127.5), 255);
980+ textureData[0][i] |= value << 24; // Stored in channel A.
981+ }
982+
983+ // Render and store the top inner shadow.
984+ memset(shapeData, 0, size * sizeof(uint));
985+ painter->resetTransform();
986+ painter->translate((shapeOffset + shadowTopTX) * width, (shapeOffset + shadowTopTY) * width);
987+ svg->render(painter);
988+ for (int i = 0; i < size; i++) {
989+ shapeNormalized[i] = 1.0 - (static_cast<double>(shapeData[i] >> 24) / 255.0);
990+ }
991+ computegradient(shapeNormalized, width, height, gradientX, gradientY);
992+ edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
993+ distanceIn);
994+ for (int i = 0; i < size; i++) {
995+ double shadow = qBound(0.0, (distanceIn[i] * shadowScale * imageScale) / 255.0, 1.0);
996+ shadow = (1.0 - (2.0 * shadow - shadow * shadow)) * 255.0;
997+ const uint value = qBound(0, qRound(shadow * shadowTranslucency), 255);
998+ textureData[0][i] |= value << 0; // Stored in channel B (exposed as R in the shaders).
999+ }
1000+
1001+ // Render and store the bottom inner shadow.
1002+ memset(shapeData, 0, size * sizeof(uint));
1003+ painter->resetTransform();
1004+ painter->translate(
1005+ (shapeOffset + shadowBottomTX) * width, (shapeOffset + shadowBottomTY) * width);
1006+ svg->render(painter);
1007+ for (int i = 0; i < size; i++) {
1008+ shapeNormalized[i] = 1.0 - (static_cast<double>(shapeData[i] >> 24) / 255.0);
1009+ }
1010+ computegradient(shapeNormalized, width, height, gradientX, gradientY);
1011+ edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
1012+ distanceIn);
1013+ for (int i = 0; i < size; i++) {
1014+ double shadow = qBound(0.0, (distanceIn[i] * shadowScale * imageScale) / 255.0, 1.0);
1015+ shadow = (1.0 - (2.0 * shadow - shadow * shadow)) * 255.0;
1016+ const uint value = qBound(0, qRound(shadow * shadowTranslucency), 255);
1017+ textureData[0][i] |= value << 8; // Stored in channel G.
1018+ }
1019+}
1020+
1021+// Creates the drop shadow aspect texture.
1022+static void createTexture2(QSvgRenderer* svg, QPainter* painter)
1023+{
1024+ // Input data.
1025+ const double shadowScale = 4.5;
1026+ const double shadowTranslucency = 0.8;
1027+ const double distanceBottomTY = 0.0546875; // From shapeOffset.
1028+ const double distanceTx = distanceBottomTY * 0.5; // From shapeOffset.
1029+
1030+ // Render and store the distance field used for masking the top of the shape.
1031+ memset(shapeData, 0, size * sizeof(uint));
1032+ painter->resetTransform();
1033+ painter->translate((shapeOffset + distanceTx) * width, shapeOffset * width);
1034+ svg->render(painter);
1035+ for (int i = 0; i < size; i++) {
1036+ shapeNormalized[i] = static_cast<double>(shapeData[i] >> 24) / 255.0;
1037+ }
1038+ computegradient(shapeNormalized, width, height, gradientX, gradientY);
1039+ edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
1040+ distanceOut);
1041+ for (int i = 0; i < size; i++) {
1042+ shapeNormalized[i] = 1.0 - shapeNormalized[i];
1043+ }
1044+ memset(gradientX, 0, size * sizeof(double));
1045+ memset(gradientY, 0, size * sizeof(double));
1046+ computegradient(shapeNormalized, width, height, gradientX, gradientY);
1047+ edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
1048+ distanceIn);
1049+ for (int i = 0; i < size; i++) {
1050+ const double distance = qMax(0.0, distanceIn[i]) - qMax(0.0, distanceOut[i]);
1051+ const uint value = qBound(0, qRound(distance * distanceScale * imageScale + 127.5), 255);
1052+ textureData[1][i] = value << 0; // Stored in channel B (exposed as R in the shaders).
1053+ }
1054+
1055+ // Render and store the distance field used for masking the bottom of the shape.
1056+ memset(shapeData, 0, size * sizeof(uint));
1057+ painter->resetTransform();
1058+ painter->translate((shapeOffset + distanceTx) * width,
1059+ (shapeOffset + distanceBottomTY) * width);
1060+ svg->render(painter);
1061+ for (int i = 0; i < size; i++) {
1062+ shapeNormalized[i] = static_cast<double>(shapeData[i] >> 24) / 255.0;
1063+ }
1064+ computegradient(shapeNormalized, width, height, gradientX, gradientY);
1065+ edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
1066+ distanceOut);
1067+ for (int i = 0; i < size; i++) {
1068+ shapeNormalized[i] = 1.0 - shapeNormalized[i];
1069+ }
1070+ memset(gradientX, 0, size * sizeof(double));
1071+ memset(gradientY, 0, size * sizeof(double));
1072+ computegradient(shapeNormalized, width, height, gradientX, gradientY);
1073+ edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
1074+ distanceIn);
1075+ for (int i = 0; i < size; i++) {
1076+ const double distance = qMax(0.0, distanceIn[i]) - qMax(0.0, distanceOut[i]);
1077+ const uint value = qBound(0, qRound(distance * distanceScale * imageScale + 127.5), 255);
1078+ textureData[1][i] |= value << 8; // Stored in channel G.
1079+ }
1080+
1081+ // Render and store the top inner shadow.
1082+ memset(shapeData, 0, size * sizeof(uint));
1083+ painter->resetTransform();
1084+ painter->translate(shapeOffset * width, shapeOffset * width);
1085+ svg->render(painter);
1086+ for (int i = 0; i < size; i++) {
1087+ shapeNormalized[i] = 1.0 - (static_cast<double>(shapeData[i] >> 24) / 255.0);
1088+ }
1089+ computegradient(shapeNormalized, width, height, gradientX, gradientY);
1090+ edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
1091+ distanceIn);
1092+ for (int i = 0; i < size; i++) {
1093+ double shadow = qBound(0.0, (distanceIn[i] * shadowScale * imageScale) / 255.0, 1.0);
1094+ shadow = (2.0 * shadow - shadow * shadow) * 255.0;
1095+ const uint value = qBound(0, qRound(shadow * shadowTranslucency), 255);
1096+ textureData[1][i] |= value << 16; // Stored in channel R (exposed as B in the shaders).
1097+ }
1098+}
1099+
1100+static void dumpTexture(QTextStream& cppOut, const uint* textureData)
1101+{
1102+ cppOut.setIntegerBase(16);
1103+ cppOut.setFieldWidth(2);
1104+ cppOut.setPadChar('0');
1105+ for (int i = 0; i < size; i += 4) {
1106+ cppOut << " \""
1107+ << "\\x" << (textureData[i] & 0xff)
1108+ << "\\x" << ((textureData[i] >> 8) & 0xff)
1109+ << "\\x" << ((textureData[i] >> 16) & 0xff)
1110+ << "\\x" << ((textureData[i] >> 24) & 0xff)
1111+ << "\\x" << (textureData[i+1] & 0xff)
1112+ << "\\x" << ((textureData[i+1] >> 8) & 0xff)
1113+ << "\\x" << ((textureData[i+1] >> 16) & 0xff)
1114+ << "\\x" << ((textureData[i+1] >> 24) & 0xff)
1115+ << "\\x" << (textureData[i+2] & 0xff)
1116+ << "\\x" << ((textureData[i+2] >> 8) & 0xff)
1117+ << "\\x" << ((textureData[i+2] >> 16) & 0xff)
1118+ << "\\x" << ((textureData[i+2] >> 24) & 0xff)
1119+ << "\\x" << (textureData[i+3] & 0xff)
1120+ << "\\x" << ((textureData[i+3] >> 8) & 0xff)
1121+ << "\\x" << ((textureData[i+3] >> 16) & 0xff)
1122+ << "\\x" << ((textureData[i+3] >> 24) & 0xff);
1123+ cppOut.setFieldWidth(1);
1124+ cppOut << "\"\n";
1125+ cppOut.setFieldWidth(2);
1126+ }
1127+ cppOut.setIntegerBase(10);
1128+ cppOut.setFieldWidth(0);
1129+ cppOut.setPadChar(' ');
1130+}
1131
1132 int main(int argc, char* argv[])
1133 {
1134 if (argc != 3) {
1135- qWarning("Usage: createshapeimage input_svg output_cpp");
1136+ qWarning("Usage: createshapetextures input_svg output_cpp");
1137 return 1;
1138 }
1139 const char* svgFilename = argv[1];
1140@@ -90,142 +295,34 @@
1141 return 1;
1142 }
1143
1144+ // Create the textures.
1145 QImage shape(reinterpret_cast<uchar*>(shapeData), width, height, width * 4,
1146 QImage::Format_ARGB32_Premultiplied);
1147 QPainter painter(&shape);
1148-
1149- // Render and store the distance field used for masking the top of the shape, for masking the
1150- // bevel and for masking the unstyled shape.
1151- painter.translate(shapeOffset * width, shapeOffset * width);
1152- svg.render(&painter);
1153- for (int i = 0; i < size; i++) {
1154- shapeNormalized[i] = static_cast<double>(shapeData[i] >> 24) / 255.0;
1155- }
1156- computegradient(shapeNormalized, width, height, gradientX, gradientY);
1157- edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
1158- distanceOut);
1159- for (int i = 0; i < size; i++) {
1160- shapeNormalized[i] = 1.0 - shapeNormalized[i];
1161- }
1162- memset(gradientX, 0, size * sizeof(double));
1163- memset(gradientY, 0, size * sizeof(double));
1164- computegradient(shapeNormalized, width, height, gradientX, gradientY);
1165- edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
1166- distanceIn);
1167- for (int i = 0; i < size; i++) {
1168- const double distance = qMax(0.0, distanceIn[i]) - qMax(0.0, distanceOut[i]);
1169- const uint value = qBound(0, qRound(distance * distanceScale * imageScale + 127.5), 255);
1170- imageData[i] = value << 16; // Stored in channel R (exposed as B in the shaders).
1171- }
1172-
1173- // Render and store the distance field used for masking the bottom of the shape and for masking
1174- // the bevel.
1175- memset(shapeData, 0, size * sizeof(uint));
1176- painter.resetTransform();
1177- painter.translate(shapeOffset * width, (shapeOffset + distanceBottomTY) * width);
1178- svg.render(&painter);
1179- for (int i = 0; i < size; i++) {
1180- shapeNormalized[i] = static_cast<double>(shapeData[i] >> 24) / 255.0;
1181- }
1182- computegradient(shapeNormalized, width, height, gradientX, gradientY);
1183- edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
1184- distanceOut);
1185- for (int i = 0; i < size; i++) {
1186- shapeNormalized[i] = 1.0 - shapeNormalized[i];
1187- }
1188- memset(gradientX, 0, size * sizeof(double));
1189- memset(gradientY, 0, size * sizeof(double));
1190- computegradient(shapeNormalized, width, height, gradientX, gradientY);
1191- edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
1192- distanceIn);
1193- for (int i = 0; i < size; i++) {
1194- const double distance = qMax(0.0, distanceIn[i]) - qMax(0.0, distanceOut[i]);
1195- const uint value = qBound(0, qRound(distance * distanceScale * imageScale + 127.5), 255);
1196- imageData[i] |= value << 24; // Stored in channel A.
1197- }
1198-
1199- // Render and store the top inner shadow.
1200- memset(shapeData, 0, size * sizeof(uint));
1201- painter.resetTransform();
1202- painter.translate((shapeOffset + shadowTopTX) * width, (shapeOffset + shadowTopTY) * width);
1203- svg.render(&painter);
1204- for (int i = 0; i < size; i++) {
1205- shapeNormalized[i] = 1.0 - (static_cast<double>(shapeData[i] >> 24) / 255.0);
1206- }
1207- computegradient(shapeNormalized, width, height, gradientX, gradientY);
1208- edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
1209- distanceIn);
1210- for (int i = 0; i < size; i++) {
1211- double shadow = qBound(0.0, (distanceIn[i] * shadowScale * imageScale) / 255.0, 1.0);
1212- shadow = (1.0 - (2.0 * shadow - shadow * shadow)) * 255.0;
1213- const uint value = qBound(0, qRound(shadow * shadowTranslucency), 255);
1214- imageData[i] |= value << 0; // Stored in channel B (exposed as R in the shaders).
1215- }
1216-
1217- // Render and store the bottom inner shadow.
1218- memset(shapeData, 0, size * sizeof(uint));
1219- painter.resetTransform();
1220- painter.translate(
1221- (shapeOffset + shadowBottomTX) * width, (shapeOffset + shadowBottomTY) * width);
1222- svg.render(&painter);
1223- for (int i = 0; i < size; i++) {
1224- shapeNormalized[i] = 1.0 - (static_cast<double>(shapeData[i] >> 24) / 255.0);
1225- }
1226- computegradient(shapeNormalized, width, height, gradientX, gradientY);
1227- edtaa3(shapeNormalized, gradientX, gradientY, width, height, distanceX, distanceY,
1228- distanceIn);
1229- for (int i = 0; i < size; i++) {
1230- double shadow = qBound(0.0, (distanceIn[i] * shadowScale * imageScale) / 255.0, 1.0);
1231- shadow = (1.0 - (2.0 * shadow - shadow * shadow)) * 255.0;
1232- const uint value = qBound(0, qRound(shadow * shadowTranslucency), 255);
1233- imageData[i] |= value << 8; // Stored in channel G.
1234- }
1235+ createTexture1(&svg, &painter);
1236+ createTexture2(&svg, &painter);
1237
1238 // Write the C++ file.
1239 QTextStream cppOut(&cppFile);
1240 cppOut << "// Copyright 2015 Canonical Ltd.\n"
1241- << "// Automatically generated by the createshapeimage tool.\n"
1242- << "\n"
1243- << "static const struct {\n"
1244- << " float offset;\n"
1245- << " float distanceAA;\n"
1246- << " int size;\n"
1247- << " unsigned char data[" << size * 4 + 1 << "];\n" // + 1 for the string terminator.
1248- << "} shapeTextureInfo = {\n"
1249- << " " << shapeOffset << ",\n"
1250- << " " << distanceScale << ",\n"
1251- << " " << width << ",\n";
1252- cppOut.setIntegerBase(16);
1253- cppOut.setFieldWidth(2);
1254- cppOut.setPadChar('0');
1255- for (int i = 0; i < size; i += 4) {
1256- cppOut << " \""
1257- << "\\x" << (imageData[i] & 0xff)
1258- << "\\x" << ((imageData[i] >> 8) & 0xff)
1259- << "\\x" << ((imageData[i] >> 16) & 0xff)
1260- << "\\x" << ((imageData[i] >> 24) & 0xff)
1261- << "\\x" << (imageData[i+1] & 0xff)
1262- << "\\x" << ((imageData[i+1] >> 8) & 0xff)
1263- << "\\x" << ((imageData[i+1] >> 16) & 0xff)
1264- << "\\x" << ((imageData[i+1] >> 24) & 0xff)
1265- << "\\x" << (imageData[i+2] & 0xff)
1266- << "\\x" << ((imageData[i+2] >> 8) & 0xff)
1267- << "\\x" << ((imageData[i+2] >> 16) & 0xff)
1268- << "\\x" << ((imageData[i+2] >> 24) & 0xff)
1269- << "\\x" << (imageData[i+3] & 0xff)
1270- << "\\x" << ((imageData[i+3] >> 8) & 0xff)
1271- << "\\x" << ((imageData[i+3] >> 16) & 0xff)
1272- << "\\x" << ((imageData[i+3] >> 24) & 0xff);
1273- cppOut.setFieldWidth(1);
1274- cppOut << "\"\n";
1275- cppOut.setFieldWidth(2);
1276- }
1277+ << "// Automatically generated by the createshapetextures tool.\n"
1278+ << "\n"
1279+ << "const int shapeTextureCount = " << textureCount << ";\n"
1280+ << "const int shapeTextureSize = " << textureSize << ";\n"
1281+ << "const float shapeTextureOffset = " << shapeOffset << ";\n"
1282+ << "const int shapeTextureDistanceAA = " << distanceScale << ";\n"
1283+ << "\n"
1284+ << "static const unsigned char shapeTextureData[" << textureCount
1285+ << "][" << size * 4 + 1 << "] = {\n"; // + 1 for the string terminator.
1286+ dumpTexture(cppOut, textureData[0]);
1287+ cppOut << " ,\n";
1288+ dumpTexture(cppOut, textureData[1]);
1289 cppOut << "};\n";
1290
1291 // Save the file as a PNG for debugging purpose.
1292- // QImage image(reinterpret_cast<uchar*>(imageData), width, height, width * 4,
1293+ // QImage image(reinterpret_cast<uchar*>(textureData[0]), width, height, width * 4,
1294 // QImage::Format_ARGB32);
1295- // image.save("test.png");
1296+ // image.save("texture1.png");
1297
1298 return 0;
1299 }
1300
1301=== modified file 'src/Ubuntu/Components/tools/tools.pro'
1302--- src/Ubuntu/Components/tools/tools.pro 2015-03-02 18:16:02 +0000
1303+++ src/Ubuntu/Components/tools/tools.pro 2015-07-27 16:39:42 +0000
1304@@ -1,5 +1,5 @@
1305 TEMPLATE = app
1306-TARGET = createshapeimage
1307+TARGET = createshapetextures
1308 QT += gui svg
1309 QMAKE_CXXFLAGS += -Werror -Wno-unused-variable
1310-SOURCES += createshapeimage.cpp
1311+SOURCES += createshapetextures.cpp
1312
1313=== modified file 'tests/resources/ubuntushape/UbuntuShapeOverlayTest.qml'
1314--- tests/resources/ubuntushape/UbuntuShapeOverlayTest.qml 2015-07-23 11:49:38 +0000
1315+++ tests/resources/ubuntushape/UbuntuShapeOverlayTest.qml 2015-07-27 16:39:42 +0000
1316@@ -25,7 +25,7 @@
1317
1318 // Enum to string tables.
1319 property variant aspectTable: [
1320- "Flat", "Inset"
1321+ "Flat", "Inset", "DropShadow"
1322 ]
1323 property variant backgroundModeTable: [
1324 "SolidColor", "VerticalGradient"
1325@@ -225,7 +225,7 @@
1326 shape.radius = (shape.radius == "large") ? "small" :
1327 ((shape.radius == "small") ? "medium" : "large");
1328 } else if (event.key == Qt.Key_T) {
1329- shape.aspect = (shape.aspect + 1) % 2;
1330+ shape.aspect = (shape.aspect + 1) % 3;
1331 } else if (event.key == Qt.Key_Y) {
1332 shape.relativeRadius = Math.max(0.0, Math.min(
1333 1.0, shape.relativeRadius + ((event.modifiers & shift) ? 0.01 : -0.01)));
1334
1335=== modified file 'tests/resources/ubuntushape/UbuntuShapeTest.qml'
1336--- tests/resources/ubuntushape/UbuntuShapeTest.qml 2015-07-23 11:49:38 +0000
1337+++ tests/resources/ubuntushape/UbuntuShapeTest.qml 2015-07-27 16:39:42 +0000
1338@@ -25,7 +25,7 @@
1339
1340 // Enum to string tables.
1341 property variant aspectTable: [
1342- "Flat", "Inset"
1343+ "Flat", "Inset", "DropShadow"
1344 ]
1345 property variant backgroundModeTable: [
1346 "SolidColor", "VerticalGradient"
1347@@ -222,7 +222,7 @@
1348 shape.radius = (shape.radius == "large") ? "small" :
1349 ((shape.radius == "small") ? "medium" : "large");
1350 } else if (event.key == Qt.Key_T) {
1351- shape.aspect = (shape.aspect + 1) % 2;
1352+ shape.aspect = (shape.aspect + 1) % 3;
1353 } else if (event.key == Qt.Key_Y) {
1354 shape.relativeRadius = Math.max(0.0, Math.min(
1355 1.0, shape.relativeRadius + ((event.modifiers & shift) ? 0.01 : -0.01)));

Subscribers

People subscribed via source and target branches