Merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-drop-shadow-support-to-shape-overlay into lp:ubuntu-ui-toolkit/staging

Proposed by Loïc Molinari
Status: Merged
Approved by: Tim Peeters
Approved revision: 1587
Merged at revision: 1589
Proposed branch: lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-drop-shadow-support-to-shape-overlay
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-shape-content-orientation-workaround-removal
Diff against target: 36 lines (+17/-2)
1 file modified
src/Ubuntu/Components/plugin/shaders/shapeoverlay.frag (+17/-2)
To merge this branch: bzr merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-drop-shadow-support-to-shape-overlay
Reviewer Review Type Date Requested Status
Tim Peeters Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+266531@code.launchpad.net

Commit message

[UbuntuShape] Added support drop shadow aspect support to UbuntuShapeOverlay.

Description of the change

[UbuntuShape] Added support drop shadow aspect support to UbuntuShapeOverlay.

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 :

good, thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/shaders/shapeoverlay.frag'
2--- src/Ubuntu/Components/plugin/shaders/shapeoverlay.frag 2015-07-31 10:32:16 +0000
3+++ src/Ubuntu/Components/plugin/shaders/shapeoverlay.frag 2015-07-31 10:32:16 +0000
4@@ -37,8 +37,9 @@
5 varying mediump vec2 overlayCoord;
6 varying lowp vec4 overlayColor;
7
8-const mediump int FLAT = 0x08; // 1 << 3
9-const mediump int INSET = 0x10; // 1 << 4
10+const mediump int FLAT = 0x08; // 1 << 3
11+const mediump int INSET = 0x10; // 1 << 4
12+const mediump int DROP_SHADOW = 0x20; // 1 << 5
13
14 void main(void)
15 {
16@@ -96,6 +97,20 @@
17 // Mask the current color then blend the bevel over the resulting color. We simply use
18 // additive blending since the bevel has already been masked.
19 color = (color * vec4(mask[int(shapeSide)])) + vec4(bevel);
20+
21+ } else if (aspect == DROP_SHADOW) {
22+ // The vertex layout of the shape is made so that the derivative is negative from top to
23+ // middle and positive from middle to bottom.
24+ lowp int shapeSide = dfdt * dfdtFactor <= 0.0 ? 0 : 1;
25+ // Get the anti-aliased and resolution independent shape mask using distance fields.
26+ lowp float distanceMin = abs(dfdt) * -distanceAA + 0.5;
27+ lowp float distanceMax = abs(dfdt) * distanceAA + 0.5;
28+ lowp float mask = smoothstep(distanceMin, distanceMax, shapeData[shapeSide]);
29+ // Get the shadow color outside of the shape mask.
30+ lowp float shadow = (shapeData.b * -mask) + shapeData.b; // -ab + a = a(1 - b)
31+ // Mask the current color then blend the shadow over the resulting color. We simply use
32+ // additive blending since the shadow has already been masked.
33+ color = (color * vec4(mask)) + vec4(0.0, 0.0, 0.0, shadow);
34 }
35
36 gl_FragColor = color * opacityFactors.xxxy;

Subscribers

People subscribed via source and target branches