[Libreoffice-commits] core.git: 5 commits - slideshow/opengl slideshow/Package_opengl.mk slideshow/source vcl/source

Emmanuel Gil Peyrot emmanuel.peyrot at collabora.com
Tue Jan 5 06:06:28 PST 2016


 slideshow/Package_opengl.mk                                          |    1 
 slideshow/opengl/basicVertexShader.glsl                              |   45 ++
 slideshow/opengl/glitterFragmentShader.glsl                          |    2 
 slideshow/opengl/glitterVertexShader.glsl                            |   65 +++-
 slideshow/opengl/reflectionVertexShader.glsl                         |   45 ++
 slideshow/opengl/rippleFragmentShader.glsl                           |   44 ++
 slideshow/opengl/vortexFragmentShader.glsl                           |   40 --
 slideshow/opengl/vortexVertexShader.glsl                             |  153 +++++++---
 slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx |   46 ++-
 vcl/source/opengl/OpenGLContext.cxx                                  |    6 
 10 files changed, 333 insertions(+), 114 deletions(-)

New commits:
commit a301da7cb6c562cd21983d9b3b34dc01235a82a5
Author: Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com>
Date:   Mon Dec 21 21:25:35 2015 +0000

    slideshow: Define inverse() to bring back the GLSL version to 1.20
    
    Change-Id: Ib0372d6a98734724d99b979f2d01abc1ee317847

diff --git a/slideshow/opengl/basicVertexShader.glsl b/slideshow/opengl/basicVertexShader.glsl
index e9febff..730da36 100644
--- a/slideshow/opengl/basicVertexShader.glsl
+++ b/slideshow/opengl/basicVertexShader.glsl
@@ -26,7 +26,7 @@
  *
  ************************************************************************/
 
-#version 140
+#version 120
 
 attribute vec3 a_position;
 attribute vec3 a_normal;
@@ -41,6 +41,49 @@ uniform mat4 u_operationsTransformMatrix;
 varying vec2 v_texturePosition;
 varying vec3 v_normal;
 
+#if __VERSION__ < 140
+mat4 inverse(mat4 m)
+{
+    float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3];
+    float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3];
+    float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3];
+    float a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];
+
+    float b00 = a00 * a11 - a01 * a10;
+    float b01 = a00 * a12 - a02 * a10;
+    float b02 = a00 * a13 - a03 * a10;
+    float b03 = a01 * a12 - a02 * a11;
+    float b04 = a01 * a13 - a03 * a11;
+    float b05 = a02 * a13 - a03 * a12;
+    float b06 = a20 * a31 - a21 * a30;
+    float b07 = a20 * a32 - a22 * a30;
+    float b08 = a20 * a33 - a23 * a30;
+    float b09 = a21 * a32 - a22 * a31;
+    float b10 = a21 * a33 - a23 * a31;
+    float b11 = a22 * a33 - a23 * a32;
+
+    float det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
+
+    return mat4(
+        a11 * b11 - a12 * b10 + a13 * b09,
+        a02 * b10 - a01 * b11 - a03 * b09,
+        a31 * b05 - a32 * b04 + a33 * b03,
+        a22 * b04 - a21 * b05 - a23 * b03,
+        a12 * b08 - a10 * b11 - a13 * b07,
+        a00 * b11 - a02 * b08 + a03 * b07,
+        a32 * b02 - a30 * b05 - a33 * b01,
+        a20 * b05 - a22 * b02 + a23 * b01,
+        a10 * b10 - a11 * b08 + a13 * b06,
+        a01 * b08 - a00 * b10 - a03 * b06,
+        a30 * b04 - a31 * b02 + a33 * b00,
+        a21 * b02 - a20 * b04 - a23 * b00,
+        a11 * b07 - a10 * b09 - a12 * b06,
+        a00 * b09 - a01 * b07 + a02 * b06,
+        a31 * b01 - a30 * b03 - a32 * b00,
+        a20 * b03 - a21 * b01 + a22 * b00) / det;
+}
+#endif
+
 void main( void )
 {
     mat4 modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
diff --git a/slideshow/opengl/glitterFragmentShader.glsl b/slideshow/opengl/glitterFragmentShader.glsl
index 1bec201..7188174 100644
--- a/slideshow/opengl/glitterFragmentShader.glsl
+++ b/slideshow/opengl/glitterFragmentShader.glsl
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#version 130
+#version 120
 
 #define M_PI 3.1415926535897932384626433832795
 
diff --git a/slideshow/opengl/glitterVertexShader.glsl b/slideshow/opengl/glitterVertexShader.glsl
index 64bb6de..3704efd 100644
--- a/slideshow/opengl/glitterVertexShader.glsl
+++ b/slideshow/opengl/glitterVertexShader.glsl
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#version 140
+#version 120
 
 #define M_PI 3.1415926535897932384626433832795
 
@@ -29,6 +29,49 @@ uniform ivec2 numTiles;
 uniform sampler2D permTexture;
 varying float angle;
 
+#if __VERSION__ < 140
+mat4 inverse(mat4 m)
+{
+    float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3];
+    float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3];
+    float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3];
+    float a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];
+
+    float b00 = a00 * a11 - a01 * a10;
+    float b01 = a00 * a12 - a02 * a10;
+    float b02 = a00 * a13 - a03 * a10;
+    float b03 = a01 * a12 - a02 * a11;
+    float b04 = a01 * a13 - a03 * a11;
+    float b05 = a02 * a13 - a03 * a12;
+    float b06 = a20 * a31 - a21 * a30;
+    float b07 = a20 * a32 - a22 * a30;
+    float b08 = a20 * a33 - a23 * a30;
+    float b09 = a21 * a32 - a22 * a31;
+    float b10 = a21 * a33 - a23 * a31;
+    float b11 = a22 * a33 - a23 * a32;
+
+    float det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
+
+    return mat4(
+        a11 * b11 - a12 * b10 + a13 * b09,
+        a02 * b10 - a01 * b11 - a03 * b09,
+        a31 * b05 - a32 * b04 + a33 * b03,
+        a22 * b04 - a21 * b05 - a23 * b03,
+        a12 * b08 - a10 * b11 - a13 * b07,
+        a00 * b11 - a02 * b08 + a03 * b07,
+        a32 * b02 - a30 * b05 - a33 * b01,
+        a20 * b05 - a22 * b02 + a23 * b01,
+        a10 * b10 - a11 * b08 + a13 * b06,
+        a01 * b08 - a00 * b10 - a03 * b06,
+        a30 * b04 - a31 * b02 + a33 * b00,
+        a21 * b02 - a20 * b04 - a23 * b00,
+        a11 * b07 - a10 * b09 - a12 * b06,
+        a00 * b09 - a01 * b07 + a02 * b06,
+        a31 * b01 - a30 * b03 - a32 * b00,
+        a20 * b03 - a21 * b01 + a22 * b00) / det;
+}
+#endif
+
 float snoise(vec2 p)
 {
     return texture2D(permTexture, p).r;
diff --git a/slideshow/opengl/reflectionVertexShader.glsl b/slideshow/opengl/reflectionVertexShader.glsl
index c7e6b58..a0bcc27 100644
--- a/slideshow/opengl/reflectionVertexShader.glsl
+++ b/slideshow/opengl/reflectionVertexShader.glsl
@@ -26,7 +26,7 @@
  *
  ************************************************************************/
 
-#version 140
+#version 130
 
 attribute vec3 a_position;
 attribute vec3 a_normal;
@@ -42,6 +42,49 @@ varying vec2 v_texturePosition;
 varying vec3 v_normal;
 varying float v_isShadow;
 
+#if __VERSION__ < 140
+mat4 inverse(mat4 m)
+{
+    float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3];
+    float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3];
+    float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3];
+    float a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];
+
+    float b00 = a00 * a11 - a01 * a10;
+    float b01 = a00 * a12 - a02 * a10;
+    float b02 = a00 * a13 - a03 * a10;
+    float b03 = a01 * a12 - a02 * a11;
+    float b04 = a01 * a13 - a03 * a11;
+    float b05 = a02 * a13 - a03 * a12;
+    float b06 = a20 * a31 - a21 * a30;
+    float b07 = a20 * a32 - a22 * a30;
+    float b08 = a20 * a33 - a23 * a30;
+    float b09 = a21 * a32 - a22 * a31;
+    float b10 = a21 * a33 - a23 * a31;
+    float b11 = a22 * a33 - a23 * a32;
+
+    float det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
+
+    return mat4(
+        a11 * b11 - a12 * b10 + a13 * b09,
+        a02 * b10 - a01 * b11 - a03 * b09,
+        a31 * b05 - a32 * b04 + a33 * b03,
+        a22 * b04 - a21 * b05 - a23 * b03,
+        a12 * b08 - a10 * b11 - a13 * b07,
+        a00 * b11 - a02 * b08 + a03 * b07,
+        a32 * b02 - a30 * b05 - a33 * b01,
+        a20 * b05 - a22 * b02 + a23 * b01,
+        a10 * b10 - a11 * b08 + a13 * b06,
+        a01 * b08 - a00 * b10 - a03 * b06,
+        a30 * b04 - a31 * b02 + a33 * b00,
+        a21 * b02 - a20 * b04 - a23 * b00,
+        a11 * b07 - a10 * b09 - a12 * b06,
+        a00 * b09 - a01 * b07 + a02 * b06,
+        a31 * b01 - a30 * b03 - a32 * b00,
+        a20 * b03 - a21 * b01 + a22 * b00) / det;
+}
+#endif
+
 void main( void )
 {
     mat4 modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
diff --git a/slideshow/opengl/vortexVertexShader.glsl b/slideshow/opengl/vortexVertexShader.glsl
index 226d6fd..e01b331 100644
--- a/slideshow/opengl/vortexVertexShader.glsl
+++ b/slideshow/opengl/vortexVertexShader.glsl
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#version 140
+#version 120
 
 #define M_PI 3.1415926535897932384626433832795
 
@@ -32,6 +32,49 @@ uniform float slide;
 
 varying vec4 debug;
 
+#if __VERSION__ < 140
+mat4 inverse(mat4 m)
+{
+    float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3];
+    float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3];
+    float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3];
+    float a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];
+
+    float b00 = a00 * a11 - a01 * a10;
+    float b01 = a00 * a12 - a02 * a10;
+    float b02 = a00 * a13 - a03 * a10;
+    float b03 = a01 * a12 - a02 * a11;
+    float b04 = a01 * a13 - a03 * a11;
+    float b05 = a02 * a13 - a03 * a12;
+    float b06 = a20 * a31 - a21 * a30;
+    float b07 = a20 * a32 - a22 * a30;
+    float b08 = a20 * a33 - a23 * a30;
+    float b09 = a21 * a32 - a22 * a31;
+    float b10 = a21 * a33 - a23 * a31;
+    float b11 = a22 * a33 - a23 * a32;
+
+    float det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
+
+    return mat4(
+        a11 * b11 - a12 * b10 + a13 * b09,
+        a02 * b10 - a01 * b11 - a03 * b09,
+        a31 * b05 - a32 * b04 + a33 * b03,
+        a22 * b04 - a21 * b05 - a23 * b03,
+        a12 * b08 - a10 * b11 - a13 * b07,
+        a00 * b11 - a02 * b08 + a03 * b07,
+        a32 * b02 - a30 * b05 - a33 * b01,
+        a20 * b05 - a22 * b02 + a23 * b01,
+        a10 * b10 - a11 * b08 + a13 * b06,
+        a01 * b08 - a00 * b10 - a03 * b06,
+        a30 * b04 - a31 * b02 + a33 * b00,
+        a21 * b02 - a20 * b04 - a23 * b00,
+        a11 * b07 - a10 * b09 - a12 * b06,
+        a00 * b09 - a01 * b07 + a02 * b06,
+        a31 * b01 - a30 * b03 - a32 * b00,
+        a20 * b03 - a21 * b01 + a22 * b00) / det;
+}
+#endif
+
 float snoise(vec2 p)
 {
     return texture2D(permTexture, p).r;
commit d886fef25c5978dd4b07fa0e3ce2402874a6c29a
Author: Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com>
Date:   Mon Dec 21 21:25:34 2015 +0000

    slideshow: Improve the Vortex transition to match PowerPoint better
    
    Change-Id: I60e0b71d41a726459baeb7e590745d6bfb58e884

diff --git a/slideshow/Package_opengl.mk b/slideshow/Package_opengl.mk
index bed17d9..6b01831 100644
--- a/slideshow/Package_opengl.mk
+++ b/slideshow/Package_opengl.mk
@@ -23,7 +23,6 @@ $(eval $(call gb_Package_add_files,slideshow_opengl_shader,$(LIBO_ETC_FOLDER)/op
 		reflectionVertexShader.glsl \
 		reflectionFragmentShader.glsl \
 		staticFragmentShader.glsl \
-		vortexFragmentShader.glsl \
 		vortexVertexShader.glsl \
 		rippleFragmentShader.glsl \
 ))
diff --git a/slideshow/opengl/vortexFragmentShader.glsl b/slideshow/opengl/vortexFragmentShader.glsl
deleted file mode 100644
index 3e104b2..0000000
--- a/slideshow/opengl/vortexFragmentShader.glsl
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#version 120
-
-uniform sampler2D leavingSlideTexture;
-uniform sampler2D enteringSlideTexture;
-uniform float time;
-varying vec2 v_texturePosition;
-varying float v_textureSelect;
-varying vec3 v_normal;
-
-void main()
-{
-    vec3 lightVector = vec3(0.0, 0.0, 1.0);
-    float light = abs(dot(lightVector, v_normal));
-    vec4 fragment;
-
-    if (v_textureSelect == 0)
-    {
-        fragment = texture2D(leavingSlideTexture, v_texturePosition);
-    }
-    else
-    {
-        vec2 pos = v_texturePosition;
-        pos.x = 1 - pos.x;
-        fragment = texture2D(enteringSlideTexture, pos);
-    }
-
-    vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
-    gl_FragColor = mix(black, fragment, light);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/slideshow/opengl/vortexVertexShader.glsl b/slideshow/opengl/vortexVertexShader.glsl
index f4a30a3..226d6fd 100644
--- a/slideshow/opengl/vortexVertexShader.glsl
+++ b/slideshow/opengl/vortexVertexShader.glsl
@@ -28,13 +28,30 @@ uniform float time;
 uniform ivec2 numTiles;
 uniform sampler2D permTexture;
 attribute float tileInfo;
-varying float v_textureSelect;
+uniform float slide;
+
+varying vec4 debug;
 
 float snoise(vec2 p)
 {
     return texture2D(permTexture, p).r;
 }
 
+mat4 identityMatrix(void)
+{
+    return mat4(1.0, 0.0, 0.0, 0.0,
+                0.0, 1.0, 0.0, 0.0,
+                0.0, 0.0, 1.0, 0.0,
+                0.0, 0.0, 0.0, 1.0);
+}
+
+mat4 translationMatrix(vec3 axis)
+{
+    mat4 matrix = identityMatrix();
+    matrix[3] = vec4(axis, 1.0);
+    return matrix;
+}
+
 mat4 rotationMatrix(vec3 axis, float angle)
 {
     axis = normalize(axis);
@@ -53,13 +70,6 @@ void main( void )
     vec4 v = vec4(a_position, 1.0);
     vec4 normal = vec4(a_normal, 1.0);
 
-    // Not sure it this is like what it should eventually be; just
-    // experimenting to get at least something.
-
-    // Move the tile on a semicircular path so that it will end up at
-    // the correct place. All tiles move the same direction around the
-    // vertical centre axis.
-
     // Each tile moves during only half of the transition. The letmost
     // tiles start moving at the start and arrive at their end
     // position around time=0.5, when the tiles there (the rightmost
@@ -70,49 +80,69 @@ void main( void )
 
     int tileXIndex = int(mod(int(tileInfo), 256));
     int tileYIndex = int(mod(int(tileInfo) / 256, 256));
-    int vertexIndexInTile = int(mod(int(tileInfo) / (256*256), 256));
 
-    // A semi-random number 0..1, different for neighbouring tiles.
-    float fuzz = snoise(vec2(float(tileXIndex)/(numTiles.x-1), float(tileYIndex)/(numTiles.y-1)));
+    // A semi-random number 0..1, different for neighbouring tiles, to know when they should start moving.
+    float startTimeFuzz = snoise(vec2(float(tileXIndex)/(numTiles.x-1), float(tileYIndex)/(numTiles.y-1)));
 
-    // Semi-random rotation direction, identical for tiles that rotate into each other's location
-    // so that they don't pass through each others in flight, which looks ugly.
-    float direction = (snoise(vec2(floor(abs(float(numTiles.x-1)/2-tileXIndex))/(float(numTiles.x-1)/2), float(tileYIndex)/(numTiles.y-1))) < 0.5 ? -1 : 1);
+    // A semi-random number -1.5..1.5, different for neighbouring tiles, to specify their rotation center.
+    // The additional 0.5 on each side is because we want some tiles to rotate outside.
+    float rotationFuzz = snoise(vec2(float(numTiles.x + tileXIndex)/(numTiles.x-1), float(tileYIndex)/(numTiles.y-1))) * 3.0 - 1.5;
 
-    float startTime = float(tileXIndex)/(numTiles.x-1) * 0.5 + fuzz*0.2;
-    float endTime = min(startTime + 0.5, 1.0);
+    float startTime = float(tileXIndex)/(numTiles.x-1) * 0.2 + startTimeFuzz * 0.2;
+    float endTime = min(startTime + 0.7, 1.0);
 
-    const float ALMOST_ONE = 0.999;
+    bool isLeavingSlide = (slide < 0.5);
+    const vec4 invalidPosition = vec4(-256.0, -256.0, -256.0, -256.0);
 
-    if (time <= startTime)
-    {
-        // Still at start location, nothing needed
-        v_textureSelect = 0;
-    }
-    else if (time > startTime && time <= endTime)
-    {
-        // Moving
-        float rotation = direction * (time - startTime) / (endTime - startTime);
+    float nTime;
 
-        // Avoid z fighting
-        mat4 matrix = rotationMatrix(vec3(0, 1, 0), max(min(rotation, ALMOST_ONE), -ALMOST_ONE)*M_PI);
-        v = matrix * v;
-        normal = matrix * normal;
-
-        v_textureSelect = float(rotation > 0.5 || rotation < -0.5);
+    // Don’t display the tile before or after its rotation, depending on the slide.
+    if (!isLeavingSlide)
+    {
+        if (time < max(0.3, startTime))
+        {
+            gl_Position = invalidPosition;
+            return;
+        }
+        nTime = 1.0 - time;
     }
     else
     {
-        // At end location. Tile is 180 degrees rotated
-
-        // Avoid z fighting
-        mat4 matrix = rotationMatrix(vec3(0, 1, 0), direction*ALMOST_ONE*M_PI);
-        v = matrix * v;
-        normal = matrix * normal;
+        if (time > endTime)
+        {
+            gl_Position = invalidPosition;
+            return;
+        }
+        nTime = time;
+    }
 
-        v_textureSelect = 1;
+    mat4 transform = identityMatrix();
+    if (nTime > startTime && nTime <= endTime)
+    {
+        // We are in the rotation part.
+        float rotation = -(nTime - startTime) / (endTime - startTime);
+
+        // Translation vector to set the origin of the rotation.
+        vec3 translationVector = vec3(rotationFuzz, 0.0, 0.0);
+
+        // Compute the actual rotation matrix.
+        transform = translationMatrix(translationVector)
+                  * rotationMatrix(vec3(0, 1, 0), clamp(rotation, -1.0, 1.0) * M_PI)
+                  * translationMatrix(-translationVector)
+                  * transform;
+
+        // Add a translation movement to the leaving slide so it doesn’t exactly mirror the entering one.
+        if (isLeavingSlide && nTime > 0.3)
+        {
+            float movement = smoothstep(0.0, 1.0, (nTime - 0.3) * 2.0);
+            transform = translationMatrix(vec3(-movement, 0.0, -0.5 * movement)) * transform;
+        }
     }
 
+    // Apply our transform operations.
+    v = transform * v;
+    normal = transform * normal;
+
     mat4 modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
     mat3 normalMatrix = mat3(transpose(inverse(modelViewMatrix)));
     gl_Position = u_projectionMatrix * modelViewMatrix * v;
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
index cafc8ae..19c92b7 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
@@ -1557,12 +1557,12 @@ public:
 private:
     virtual void prepare( double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight ) override;
 
-    virtual void finish( double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight ) override;
-
     virtual GLuint makeShader() const override;
 
     virtual void prepareTransition( sal_Int32 glLeavingSlideTex, sal_Int32 glEnteringSlideTex ) override;
 
+    virtual void displaySlides_( double nTime, sal_Int32 glLeavingSlideTex, sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale ) override;
+
     GLint mnTileInfoLocation;
     GLuint mnTileInfoBuffer;
 
@@ -1573,8 +1573,6 @@ private:
 
 void VortexTransition::prepare( double, double, double, double, double )
 {
-    glDisable(GL_CULL_FACE);
-
     glBindBuffer(GL_ARRAY_BUFFER, mnTileInfoBuffer);
     CHECK_GL_ERROR();
     glEnableVertexAttribArray(mnTileInfoLocation);
@@ -1586,14 +1584,9 @@ void VortexTransition::prepare( double, double, double, double, double )
     CHECK_GL_ERROR();
 }
 
-void VortexTransition::finish( double, double, double, double, double )
-{
-    glEnable(GL_CULL_FACE);
-}
-
 GLuint VortexTransition::makeShader() const
 {
-    return OpenGLHelper::LoadShaders( "vortexVertexShader", "vortexFragmentShader" );
+    return OpenGLHelper::LoadShaders( "vortexVertexShader", "basicFragmentShader" );
 }
 
 void VortexTransition::prepareTransition( sal_Int32 glLeavingSlideTex, sal_Int32 glEnteringSlideTex )
@@ -1643,6 +1636,26 @@ void VortexTransition::prepareTransition( sal_Int32 glLeavingSlideTex, sal_Int32
     CHECK_GL_ERROR();
 }
 
+void VortexTransition::displaySlides_( double nTime, sal_Int32 glLeavingSlideTex, sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale )
+{
+    CHECK_GL_ERROR();
+    applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale );
+
+    GLint location = glGetUniformLocation( m_nProgramObject, "time" );
+    if( location != -1 )
+        glUniform1f( location, nTime );
+
+    location = glGetUniformLocation( m_nProgramObject, "slide" );
+
+    if( location != -1 )
+        glUniform1f( location, 0.0 );
+    displaySlide( nTime, glLeavingSlideTex, getScene().getLeavingSlide(), SlideWidthScale, SlideHeightScale );
+    if( location != -1 )
+        glUniform1f( location, 1.0 );
+    displaySlide( nTime, glEnteringSlideTex, getScene().getEnteringSlide(), SlideWidthScale, SlideHeightScale );
+    CHECK_GL_ERROR();
+}
+
 std::shared_ptr<OGLTransitionImpl>
 makeVortexTransition(const Primitives_t& rLeavingSlidePrimitives,
                      const Primitives_t& rEnteringSlidePrimitives,
@@ -1659,7 +1672,7 @@ makeVortexTransition(const Primitives_t& rLeavingSlidePrimitives,
 
 std::shared_ptr<OGLTransitionImpl> makeVortex()
 {
-    const int NX = 40, NY = 40;
+    const int NX = 64, NY = 64;
     Primitive Slide;
 
     for (int x = 0; x < NX; x++)
commit 1d411cad5a7d78ead8cffb5da522f1e0fba31187
Author: Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com>
Date:   Mon Dec 21 21:25:33 2015 +0000

    slideshow: Improve the Ripple transition to match PowerPoint better
    
    Change-Id: I0b8a78fc6bce5cb737cc7070b1b69184c5f6991c

diff --git a/slideshow/opengl/rippleFragmentShader.glsl b/slideshow/opengl/rippleFragmentShader.glsl
index ac6b8ac..ec641d6 100644
--- a/slideshow/opengl/rippleFragmentShader.glsl
+++ b/slideshow/opengl/rippleFragmentShader.glsl
@@ -15,21 +15,43 @@ uniform sampler2D leavingSlideTexture;
 uniform sampler2D enteringSlideTexture;
 uniform float time;
 uniform vec2 center;
+uniform float slideRatio;
+
 varying vec2 v_texturePosition;
 
+// This function returns the distance between two points, taking into account the slide ratio.
+float betterDistance(vec2 p1, vec2 p2)
+{
+    p1.x *= slideRatio;
+    p2.x *= slideRatio;
+    return distance(p1, p2);
+}
+
 void main()
 {
-    float d = length(v_texturePosition - center);
-    float w = 0;
-    w = max(w, length(center - vec2(0, 0)));
-    w = max(w, length(center - vec2(1, 0)));
-    w = max(w, length(center - vec2(1, 1)));
-    w = max(w, length(center - vec2(0, 1)));
-    float v = 0.2;
-    float smoothtime = smoothstep(0, 1, time);
-    float a = smoothstep(smoothtime*w-v, smoothtime*w+v, d);
-    a += (0.5 - abs(a-0.5))*sin(d*M_PI*30);
-    gl_FragColor = mix(texture2D(enteringSlideTexture, v_texturePosition), texture2D(leavingSlideTexture, v_texturePosition), a);
+    const float w = 0.5;
+    const float v = 0.1;
+
+    // Distance from this fragment to the center, in slide coordinates.
+    float dist = betterDistance(center, v_texturePosition);
+
+    // We want the ripple to span all of the slide at the end of the transition.
+    float t = time * (sqrt(2.0) * (slideRatio < 1.0 ? 1.0 / slideRatio : slideRatio));
+
+    // Interpolate the distance to the center in fonction of the time.
+    float mixed = smoothstep(t*w-v, t*w+v, dist);
+
+    // Get the displacement offset from the current pixel, for fragments that have been touched by the ripple already.
+    vec2 offset = (v_texturePosition - center) * (sin(dist * 64.0 - time * 16.0) + 0.5) / 32.0;
+    vec2 wavyTexCoord = mix(v_texturePosition + offset, v_texturePosition, time);
+
+    // Get the final position we will sample from.
+    vec2 pos = mix(wavyTexCoord, v_texturePosition, mixed);
+
+    // Sample from the textures and mix that together.
+    vec4 leaving = texture2D(leavingSlideTexture, pos);
+    vec4 entering = texture2D(enteringSlideTexture, pos);
+    gl_FragColor = mix(entering, leaving, mixed);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
index 7effc68..cafc8ae 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
@@ -1696,8 +1696,10 @@ public:
 private:
     virtual GLuint makeShader() const override;
     virtual void prepareTransition( sal_Int32 glLeavingSlideTex, sal_Int32 glEnteringSlideTex ) override;
+    virtual void prepare( double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight ) override;
 
     glm::vec2 maCenter;
+    GLint maSlideRatioLocation = -1;
 };
 
 GLuint RippleTransition::makeShader() const
@@ -1712,6 +1714,15 @@ void RippleTransition::prepareTransition( sal_Int32, sal_Int32 )
 
     glUniform2fv(nCenterLocation, 1, glm::value_ptr(maCenter));
     CHECK_GL_ERROR();
+
+    maSlideRatioLocation = glGetUniformLocation(m_nProgramObject, "slideRatio");
+    CHECK_GL_ERROR();
+}
+
+void RippleTransition::prepare( double /* nTime */, double SlideWidth, double SlideHeight, double /* DispWidth */, double /* DispHeight */ )
+{
+    if( maSlideRatioLocation != -1 )
+        glUniform1f( maSlideRatioLocation, SlideWidth / SlideHeight );
 }
 
 std::shared_ptr<OGLTransitionImpl>
commit 22480b20130d10f4691cdf0a658040be7f36e47b
Author: Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com>
Date:   Mon Dec 21 21:25:32 2015 +0000

    slideshow: Fix a few issues in the Glitter transition
    
    Remove an unused variable, add comments, reduce the time a tile stays
    black, and don’t rely on implicit casts of integers into floats.
    
    Change-Id: Ifacf49fe99818a62ad0430d86dc15c3bf51cf326

diff --git a/slideshow/opengl/glitterVertexShader.glsl b/slideshow/opengl/glitterVertexShader.glsl
index 8a65a57..64bb6de 100644
--- a/slideshow/opengl/glitterVertexShader.glsl
+++ b/slideshow/opengl/glitterVertexShader.glsl
@@ -57,22 +57,28 @@ mat4 rotationMatrix(vec3 axis, float angle)
 
 void main( void )
 {
-    // There are 18 vertices in an hexagon
-    int instanceID = gl_VertexID / 18;
+    vec2 pos = (center.xy + 1.0) / 2.0;
 
-    vec2 pos = (center.xy + 1) / 2;
+    // 0..1 pseudo-random value used to randomize the tile’s start time.
     float fuzz = snoise(pos);
+
     float startTime = pos.x * 0.5 + fuzz * 0.25;
     float endTime = startTime + 0.25;
-    float actualTime = clamp((time - startTime) / (endTime - startTime), 0, 1);
-    angle = actualTime * M_PI * 2;
+
+    // Scale the transition time to minimize the time a tile will stay black.
+    float transitionTime = clamp((time - startTime) / (endTime - startTime), 0.0, 1.0);
+    if (transitionTime < 0.5)
+        transitionTime = transitionTime * 0.3 / 0.5;
+    else
+        transitionTime = (transitionTime * 0.3 / 0.5) + 0.4;
+    angle = transitionTime * M_PI * 2.0;
 
     mat4 modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
-    mat4 transformMatrix = translationMatrix(center) * rotationMatrix(vec3(0, 1, 0), angle) * translationMatrix(-center);
+    mat4 transformMatrix = translationMatrix(center) * rotationMatrix(vec3(0.0, 1.0, 0.0), angle) * translationMatrix(-center);
 
     mat3 normalMatrix = mat3(transpose(inverse(transformMatrix)));
     gl_Position = u_projectionMatrix * modelViewMatrix * transformMatrix * vec4(a_position, 1.0);
-    v_texturePosition = vec2((a_position.x + 1) / 2, (1 - a_position.y) / 2);
+    v_texturePosition = vec2((a_position.x + 1.0) / 2.0, (1.0 - a_position.y) / 2.0);
     v_normal = normalize(normalMatrix * a_normal);
 }
 
commit 928fe134ff6ea85f732b36a1ab11336f1d829531
Author: Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com>
Date:   Mon Dec 21 21:25:31 2015 +0000

    vcl: Ignore i965’s shader compiler debug
    
    Change-Id: I94c5759d47a17e93f0614bfd95b52d64f9d2d896

diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index d4397a1..5226e34 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -1043,11 +1043,17 @@ void OpenGLContext::InitGLEWDebugging()
         {
             glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
             glDebugMessageCallbackARB(&debug_callback, nullptr);
+
+            // Ignore i965’s shader compiler notification flood.
+            glDebugMessageControlARB(GL_DEBUG_SOURCE_SHADER_COMPILER_ARB, GL_DEBUG_TYPE_OTHER_ARB, GL_DEBUG_SEVERITY_NOTIFICATION_ARB, 0, nullptr, true);
         }
         else if ( glDebugMessageCallback )
         {
             glEnable(GL_DEBUG_OUTPUT);
             glDebugMessageCallback(&debug_callback, nullptr);
+
+            // Ignore i965’s shader compiler notification flood.
+            glDebugMessageControl(GL_DEBUG_SOURCE_SHADER_COMPILER, GL_DEBUG_TYPE_OTHER, GL_DEBUG_SEVERITY_NOTIFICATION, 0, nullptr, true);
         }
     }
 


More information about the Libreoffice-commits mailing list