summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2015-10-26 17:05:38 +0200
committerTor Lillqvist <tml@collabora.com>2015-10-27 14:39:48 +0200
commit30cdd16cbfaaa34fd0da010bf4de18f9d649d22e (patch)
tree59ced89373a03d755050b5ae3d91f3d447428cce
parentf8d0dc09e15b36ae83a5e89280d1f7fbc01da48b (diff)
Initial work on a "Vortex" transition
The actual transition is not yet at all like the one in the competing product. But some basic ideas are in place. Change-Id: Ie17a4fe03ae93abe51a2f1f760f417ee4b193e2c
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/Effects.xcu5
-rw-r--r--sd/xml/transitions-ogl.xml3
-rw-r--r--slideshow/Package_opengl.mk2
-rwxr-xr-xslideshow/opengl/vortexFragmentShader.glsl48
-rwxr-xr-xslideshow/opengl/vortexVertexShader.glsl88
-rw-r--r--slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx203
-rw-r--r--slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx7
-rw-r--r--slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx4
8 files changed, 360 insertions, 0 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Effects.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Effects.xcu
index 41f351181ad3..84376c424382 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Effects.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Effects.xcu
@@ -1675,6 +1675,11 @@
<value xml:lang="en-US">Fine Dissolve</value>
</prop>
</node>
+ <node oor:name="vortex" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Vortex</value>
+ </prop>
+ </node>
</node>
</node>
<node oor:name="Presets">
diff --git a/sd/xml/transitions-ogl.xml b/sd/xml/transitions-ogl.xml
index 09c130754f6f..26de5693d2e2 100644
--- a/sd/xml/transitions-ogl.xml
+++ b/sd/xml/transitions-ogl.xml
@@ -59,6 +59,9 @@
<anim:par pres:preset-id="finedissolve">
<anim:transitionFilter smil:type="miscShapeWipe" smil:subtype="bottomCenter"/>
</anim:par>
+ <anim:par pres:preset-id="vortex">
+ <anim:transitionFilter smil:type="miscShapeWipe" smil:subtype="vertical"/>
+ </anim:par>
<anim:par pres:preset-id="zoom-rotate-in">
<anim:transitionFilter smil:type="zoom" smil:subtype="rotateIn"/>
</anim:par>
diff --git a/slideshow/Package_opengl.mk b/slideshow/Package_opengl.mk
index d5634a426a3f..440c03d0ac1a 100644
--- a/slideshow/Package_opengl.mk
+++ b/slideshow/Package_opengl.mk
@@ -13,6 +13,8 @@ $(eval $(call gb_Package_add_files,slideshow_opengl_shader,$(LIBO_ETC_FOLDER)/op
basicVertexShader.glsl \
dissolveFragmentShader.glsl \
staticFragmentShader.glsl \
+ vortexFragmentShader.glsl \
+ vortexVertexShader.glsl \
))
# vim: set noet sw=4 ts=4:
diff --git a/slideshow/opengl/vortexFragmentShader.glsl b/slideshow/opengl/vortexFragmentShader.glsl
new file mode 100755
index 000000000000..48ac1fcf8e83
--- /dev/null
+++ b/slideshow/opengl/vortexFragmentShader.glsl
@@ -0,0 +1,48 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+uniform sampler2D leavingSlideTexture;
+uniform sampler2D enteringSlideTexture;
+uniform sampler2D permTexture;
+uniform float time;
+varying vec2 v_texturePosition;
+
+float snoise(vec2 p)
+{
+ return texture2D(permTexture, p).r;
+}
+
+void main()
+{
+ if (time <= 0.5)
+ gl_FragColor = texture2D(leavingSlideTexture, v_texturePosition);
+ else
+ gl_FragColor = texture2D(enteringSlideTexture, v_texturePosition);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/slideshow/opengl/vortexVertexShader.glsl b/slideshow/opengl/vortexVertexShader.glsl
new file mode 100755
index 000000000000..63e80e4fc0bd
--- /dev/null
+++ b/slideshow/opengl/vortexVertexShader.glsl
@@ -0,0 +1,88 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define M_PI 3.1415926535897932384626433832795
+
+uniform float time;
+uniform sampler2D permTexture;
+attribute vec2 center;
+attribute int tileXIndex;
+attribute int tileYIndex;
+attribute int vertexIndexInTile;
+varying vec2 v_texturePosition;
+
+float snoise(vec2 p)
+{
+ return texture2D(permTexture, p).r;
+}
+
+mat4 rotationMatrix(vec3 axis, float angle)
+{
+ axis = normalize(axis);
+ float s = sin(angle);
+ float c = cos(angle);
+ float oc = 1.0 - c;
+
+ return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
+ oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
+ oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+}
+
+mat4 translateMatrix(vec2 whereTo)
+{
+ return mat4(1, 0, 0, whereTo.x,
+ 0, 1, 0, whereTo.y,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+}
+
+void main( void )
+{
+ vec4 v = gl_Vertex;
+
+ // Of course this is nothing like what it will eventually be; just
+ // experimenting to get at least something.
+
+ v -= vec4(center, 0, 0);
+ if (time <= 0.5)
+ v = rotationMatrix(vec3(0, 1, 0), time*M_PI) * v;
+ else
+ v = rotationMatrix(vec3(0, 1, 0), -(1-time)*M_PI) * v;
+ v += vec4(center, 0, 0);
+
+ // v.z += 10 * (snoise(vec2(tileXIndex, tileYIndex))-0.5) * (1 - abs(time-0.5)*2);
+
+ v.z += ((((tileXIndex << 3) ^ tileYIndex) % 10) - 5) * (1 - abs(time-0.5)*2) + 0*vertexIndexInTile;
+
+ gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * v;
+
+ v_texturePosition = gl_MultiTexCoord0.xy;
+}
+
+/* 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 f0696bba70d9..aff37e7478d3 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx
@@ -142,6 +142,10 @@ void OGLTransitionImpl::prepare( double, double, double, double, double )
{
}
+void OGLTransitionImpl::finish( double, double, double, double, double )
+{
+}
+
void OGLTransitionImpl::prepareTransition( ::sal_Int32, ::sal_Int32 )
{
}
@@ -1634,6 +1638,205 @@ std::shared_ptr<OGLTransitionImpl> makeDissolve()
return makeDissolveTransition(aLeavingSlide, aEnteringSlide, aSettings);
}
+namespace
+{
+
+float fdiv(int a, int b)
+{
+ return static_cast<float>(a)/b;
+}
+
+class VortexTransition : public ShaderTransition
+{
+public:
+ VortexTransition(const TransitionScene& rScene, const TransitionSettings& rSettings, int nNX, int nNY)
+ : ShaderTransition(rScene, rSettings),
+ mnNX(nNX),
+ mnNY(nNY)
+ {
+ mvCenters.resize(6*mnNX*mnNY);
+ mvTileXIndexes.resize(6*mnNX*mnNY);
+ mvTileYIndexes.resize(6*mnNX*mnNY);
+ mvVertexIndexesInTiles.resize(6*mnNX*mnNY);
+ }
+
+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() override;
+
+ GLint mnCenterLocation;
+ GLint mnTileXIndexLocation;
+ GLint mnTileYIndexLocation;
+ GLint mnVertexIndexInTileLocation;
+ GLuint mnCenterBuffer;
+ GLuint mnTileXIndexBuffer;
+ GLuint mnTileYIndexBuffer;
+ GLuint mnVertexIndexInTileBuffer;
+
+ int mnNX, mnNY;
+
+ std::vector<glm::vec2> mvCenters;
+ std::vector<GLint> mvTileXIndexes;
+ std::vector<GLint> mvTileYIndexes;
+ std::vector<GLint> mvVertexIndexesInTiles;
+};
+
+void VortexTransition::prepare( double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight )
+{
+ glDisable(GL_CULL_FACE);
+
+ glBindBuffer(GL_ARRAY_BUFFER, mnCenterBuffer);
+ CHECK_GL_ERROR();
+ glEnableVertexAttribArray(mnCenterLocation);
+ CHECK_GL_ERROR();
+ glVertexAttribPointer(mnCenterLocation, 2, GL_FLOAT, GL_FALSE, 0, 0);
+ CHECK_GL_ERROR();
+
+ glBindBuffer(GL_ARRAY_BUFFER, mnTileXIndexBuffer);
+ CHECK_GL_ERROR();
+ glEnableVertexAttribArray(mnTileXIndexLocation);
+ CHECK_GL_ERROR();
+ glVertexAttribIPointer(mnTileXIndexLocation, 1, GL_INT, 0, 0);
+ CHECK_GL_ERROR();
+
+ glBindBuffer(GL_ARRAY_BUFFER, mnTileYIndexBuffer);
+ CHECK_GL_ERROR();
+ glEnableVertexAttribArray(mnTileYIndexLocation);
+ CHECK_GL_ERROR();
+ glVertexAttribIPointer(mnTileYIndexLocation, 1, GL_INT, 0, 0);
+ CHECK_GL_ERROR();
+
+ glBindBuffer(GL_ARRAY_BUFFER, mnVertexIndexInTileBuffer);
+ CHECK_GL_ERROR();
+ glEnableVertexAttribArray(mnVertexIndexInTileLocation);
+ CHECK_GL_ERROR();
+ glVertexAttribIPointer(mnVertexIndexInTileLocation, 1, GL_INT, 0, 0);
+ CHECK_GL_ERROR();
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ CHECK_GL_ERROR();
+}
+
+void VortexTransition::finish( double, double, double, double, double )
+{
+ glEnable(GL_CULL_FACE);
+}
+
+GLuint VortexTransition::makeShader()
+{
+ GLuint nProgram = OpenGLHelper::LoadShaders( "vortexVertexShader", "vortexFragmentShader" );
+
+ mnCenterLocation = glGetAttribLocation(nProgram, "center");
+ CHECK_GL_ERROR();
+ mnTileXIndexLocation = glGetAttribLocation(nProgram, "tileXIndex");
+ CHECK_GL_ERROR();
+ mnTileYIndexLocation = glGetAttribLocation(nProgram, "tileYIndex");
+ CHECK_GL_ERROR();
+ mnVertexIndexInTileLocation = glGetAttribLocation(nProgram, "vertexIndexInTile");
+ CHECK_GL_ERROR();
+
+ glGenBuffers(1, &mnCenterBuffer);
+ CHECK_GL_ERROR();
+ glGenBuffers(1, &mnTileXIndexBuffer);
+ CHECK_GL_ERROR();
+ glGenBuffers(1, &mnTileYIndexBuffer);
+ CHECK_GL_ERROR();
+ glGenBuffers(1, &mnVertexIndexInTileBuffer);
+ CHECK_GL_ERROR();
+
+ // Two triangles, i.e. six vertices, per tile
+ {
+ int n = 0;
+ for (int x = 0; x < mnNX; x++)
+ {
+ for (int y = 0; y < mnNY; y++)
+ {
+ for (int v = 0; v < 6; v++)
+ {
+ // Note that Primitive::pushTriangle() has mapped the coordinates from the 0..1
+ // passed to it (by makeVortex() in this case) to -1..1, and also reflected the Y
+ // coordinates. Why the code can't use those from the start I don't
+ // know... Confusing. Anyway, so here when we store the center of each rectangle
+ // that the vertices belong to, we need to use the actual coordinates.
+ mvCenters[n] = glm::vec2(2*((x+0.5)/mnNX) - 1, -2*((y+0.5)/mnNY) + 1);
+
+ mvTileXIndexes[n] = x;
+ mvTileYIndexes[n] = y;
+ mvVertexIndexesInTiles[n] = v;
+ n++;
+ }
+ }
+ }
+ }
+
+ glBindBuffer(GL_ARRAY_BUFFER, mnCenterBuffer);
+ CHECK_GL_ERROR();
+ glBufferData(GL_ARRAY_BUFFER, mvCenters.size()*sizeof(glm::vec2), mvCenters.data(), GL_STATIC_DRAW);
+ CHECK_GL_ERROR();
+
+ glBindBuffer(GL_ARRAY_BUFFER, mnTileXIndexBuffer);
+ CHECK_GL_ERROR();
+ glBufferData(GL_ARRAY_BUFFER, mvTileXIndexes.size()*sizeof(GLint), mvTileXIndexes.data(), GL_STATIC_DRAW);
+ CHECK_GL_ERROR();
+
+ glBindBuffer(GL_ARRAY_BUFFER, mnTileYIndexBuffer);
+ CHECK_GL_ERROR();
+ glBufferData(GL_ARRAY_BUFFER, mvTileYIndexes.size()*sizeof(GLint), mvTileYIndexes.data(), GL_STATIC_DRAW);
+ CHECK_GL_ERROR();
+
+ glBindBuffer(GL_ARRAY_BUFFER, mnVertexIndexInTileBuffer);
+ CHECK_GL_ERROR();
+ glBufferData(GL_ARRAY_BUFFER, mvVertexIndexesInTiles.size()*sizeof(GLint), mvVertexIndexesInTiles.data(), GL_STATIC_DRAW);
+ CHECK_GL_ERROR();
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ CHECK_GL_ERROR();
+
+ return nProgram;
+}
+
+std::shared_ptr<OGLTransitionImpl>
+makeVortexTransition(const Primitives_t& rLeavingSlidePrimitives,
+ const Primitives_t& rEnteringSlidePrimitives,
+ const TransitionSettings& rSettings,
+ int NX,
+ int NY)
+{
+ return std::make_shared<VortexTransition>(TransitionScene(rLeavingSlidePrimitives, rEnteringSlidePrimitives),
+ rSettings,
+ NX, NY);
+}
+
+}
+
+std::shared_ptr<OGLTransitionImpl> makeVortex()
+{
+ const int NX = 40, NY = 40;
+ Primitive Slide;
+
+ for (int x = 0; x < NX; x++)
+ {
+ for (int y = 0; y < NY; y++)
+ {
+ Slide.pushTriangle (glm::vec2 (fdiv(x,NX),fdiv(y,NY)), glm::vec2 (fdiv(x+1,NX),fdiv(y,NY)), glm::vec2 (fdiv(x,NX),fdiv(y+1,NY)));
+ Slide.pushTriangle (glm::vec2 (fdiv(x+1,NX),fdiv(y,NY)), glm::vec2 (fdiv(x,NX),fdiv(y+1,NY)), glm::vec2 (fdiv(x+1,NX),fdiv(y+1,NY)));
+ }
+ }
+ Primitives_t aLeavingSlide;
+ aLeavingSlide.push_back (Slide);
+ Primitives_t aEnteringSlide;
+ aEnteringSlide.push_back (Slide);
+
+ TransitionSettings aSettings;
+ aSettings.mbUseMipMapLeaving = aSettings.mbUseMipMapEntering = false;
+ aSettings.mnRequiredGLVersion = 2.0;
+
+ return makeVortexTransition(aLeavingSlide, aEnteringSlide, aSettings, NX, NY);
+}
+
std::shared_ptr<OGLTransitionImpl> makeNewsflash()
{
Primitive Slide;
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx
index 0b9b9d9ca006..772f2bf20db8 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx
@@ -189,6 +189,12 @@ private:
*/
virtual void prepare( double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight );
+ /** This function is called in display method to prepare the slides, scene, etc.
+ *
+ * Default implementation does nothing.
+ */
+ virtual void finish( double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight );
+
/** This function is called after glx context is ready to let the transition prepare GL related things, like GLSL program.
*
* Default implementation does nothing.
@@ -228,6 +234,7 @@ std::shared_ptr<OGLTransitionImpl> makeRochade();
std::shared_ptr<OGLTransitionImpl> makeVenetianBlinds( bool vertical, int parts );
std::shared_ptr<OGLTransitionImpl> makeStatic();
std::shared_ptr<OGLTransitionImpl> makeDissolve();
+std::shared_ptr<OGLTransitionImpl> makeVortex();
std::shared_ptr<OGLTransitionImpl> makeNewsflash();
/** 2D replacements
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
index 7b00fda9e488..fe96fd58ef24 100644
--- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
+++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx
@@ -1429,6 +1429,7 @@ public:
case animations::TransitionSubType::BOTTOMCENTER: // 9
case animations::TransitionSubType::CORNERSIN: // 11
case animations::TransitionSubType::CORNERSOUT: // 12
+ case animations::TransitionSubType::VERTICAL: // 13
case animations::TransitionSubType::CIRCLE: // 27
case animations::TransitionSubType::FANOUTHORIZONTAL: // 55
case animations::TransitionSubType::ACROSS: // 108
@@ -1502,6 +1503,9 @@ public:
case animations::TransitionSubType::CORNERSOUT:
pTransition = makeOutsideCubeFaceToLeft();
break;
+ case animations::TransitionSubType::VERTICAL:
+ pTransition = makeVortex();
+ break;
case animations::TransitionSubType::CIRCLE:
pTransition = makeRevolvingCircles(8,128);
break;