From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- slideshow/source/engine/opengl/Operation.cxx | 225 +++++++++++++++++++++++++++ 1 file changed, 225 insertions(+) create mode 100644 slideshow/source/engine/opengl/Operation.cxx (limited to 'slideshow/source/engine/opengl/Operation.cxx') diff --git a/slideshow/source/engine/opengl/Operation.cxx b/slideshow/source/engine/opengl/Operation.cxx new file mode 100644 index 000000000..ec83d6b74 --- /dev/null +++ b/slideshow/source/engine/opengl/Operation.cxx @@ -0,0 +1,225 @@ +/* -*- 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 2015 by Collabora, Ltd. + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include + +#include "Operation.hxx" + +#include + +#include +#include + +SRotate::SRotate(const glm::vec3& Axis, const glm::vec3& Origin, + double Angle, bool bInter, double T0, double T1): + Operation(bInter, T0, T1), + axis(Axis), + origin(Origin), + angle(basegfx::deg2rad(Angle)) +{ +} + +SScale::SScale(const glm::vec3& Scale, const glm::vec3& Origin, + bool bInter, double T0, double T1): + Operation(bInter, T0, T1), + scale(Scale), + origin(Origin) +{ +} + +RotateAndScaleDepthByWidth::RotateAndScaleDepthByWidth(const glm::vec3& Axis, + const glm::vec3& Origin, double Angle, bool bScale, bool bInter, double T0, double T1): + Operation(bInter, T0, T1), + axis(Axis), + origin(Origin), + angle(basegfx::deg2rad(Angle)), + scale(bScale) +{ +} + +RotateAndScaleDepthByHeight::RotateAndScaleDepthByHeight(const glm::vec3& Axis, + const glm::vec3& Origin, double Angle, bool bScale, bool bInter, double T0, double T1): + Operation(bInter, T0, T1), + axis(Axis), + origin(Origin), + angle(basegfx::deg2rad(Angle)), + scale(bScale) +{ +} + + +STranslate::STranslate(const glm::vec3& Vector, bool bInter, double T0, double T1): + Operation(bInter, T0, T1), + vector(Vector) +{ +} + +std::shared_ptr +makeSRotate(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1) +{ + return std::make_shared(Axis, Origin, Angle, bInter, T0, T1); +} + +std::shared_ptr +makeSScale(const glm::vec3& Scale, const glm::vec3& Origin,bool bInter, double T0, double T1) +{ + return std::make_shared(Scale, Origin, bInter, T0, T1); +} + +std::shared_ptr +makeSTranslate(const glm::vec3& Vector,bool bInter, double T0, double T1) +{ + return std::make_shared(Vector, bInter, T0, T1); +} + +std::shared_ptr +makeSEllipseTranslate(double dWidth, double dHeight, double dStartPosition, double dEndPosition, bool bInter, double T0, double T1) +{ + return std::make_shared(dWidth, dHeight, dStartPosition, dEndPosition, bInter, T0, T1); +} + +std::shared_ptr +makeRotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1) +{ + return std::make_shared(Axis, Origin, Angle, bScale, bInter, T0, T1); +} + +std::shared_ptr +makeRotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bScale, bool bInter, double T0, double T1) +{ + return std::make_shared(Axis, Origin, Angle, bScale, bInter, T0, T1); +} + +static double intervalInter(double t, double T0, double T1) +{ + return ( t - T0 ) / ( T1 - T0 ); +} + +void STranslate::interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const +{ + if(t <= mnT0) + return; + if(!mbInterpolate || t > mnT1) + t = mnT1; + t = intervalInter(t,mnT0,mnT1); + matrix = glm::translate(matrix, glm::vec3(SlideWidthScale*t*vector.x, SlideHeightScale*t*vector.y, t*vector.z)); +} + +void SRotate::interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const +{ + if(t <= mnT0) + return; + if(!mbInterpolate || t > mnT1) + t = mnT1; + t = intervalInter(t,mnT0,mnT1); + glm::vec3 translation_vector(SlideWidthScale*origin.x, SlideHeightScale*origin.y, origin.z); + glm::vec3 scale_vector(SlideWidthScale * SlideWidthScale, SlideHeightScale * SlideHeightScale, 1); + matrix = glm::translate(matrix, translation_vector); + matrix = glm::scale(matrix, scale_vector); + matrix = glm::rotate(matrix, static_cast(t*angle), axis); + matrix = glm::scale(matrix, 1.f / scale_vector); + matrix = glm::translate(matrix, -translation_vector); +} + +void SScale::interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const +{ + if(t <= mnT0) + return; + if(!mbInterpolate || t > mnT1) + t = mnT1; + t = intervalInter(t,mnT0,mnT1); + glm::vec3 translation_vector(SlideWidthScale*origin.x, SlideHeightScale*origin.y, origin.z); + matrix = glm::translate(matrix, translation_vector); + matrix = glm::scale(matrix, static_cast(1 - t) + static_cast(t) * scale); + matrix = glm::translate(matrix, -translation_vector); +} + +void RotateAndScaleDepthByWidth::interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const +{ + if(t <= mnT0) + return; + if(!mbInterpolate || t > mnT1) + t = mnT1; + t = intervalInter(t,mnT0,mnT1); + glm::vec3 translation_vector(SlideWidthScale*origin.x, SlideHeightScale*origin.y, SlideWidthScale*origin.z); + glm::vec3 scale_vector(SlideWidthScale * SlideWidthScale, SlideHeightScale * SlideHeightScale, 1); + matrix = glm::translate(matrix, translation_vector); + if (scale) + matrix = glm::scale(matrix, scale_vector); + matrix = glm::rotate(matrix, static_cast(t*angle), axis); + if (scale) + matrix = glm::scale(matrix, 1.f / scale_vector); + matrix = glm::translate(matrix, -translation_vector); +} + +void RotateAndScaleDepthByHeight::interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const +{ + if(t <= mnT0) + return; + if(!mbInterpolate || t > mnT1) + t = mnT1; + t = intervalInter(t,mnT0,mnT1); + glm::vec3 translation_vector(SlideWidthScale*origin.x, SlideHeightScale*origin.y, SlideHeightScale*origin.z); + glm::vec3 scale_vector(SlideWidthScale * SlideWidthScale, SlideHeightScale * SlideHeightScale, 1); + matrix = glm::translate(matrix, translation_vector); + if (scale) + matrix = glm::scale(matrix, scale_vector); + matrix = glm::rotate(matrix, static_cast(t*angle), axis); + if (scale) + matrix = glm::scale(matrix, 1.f / scale_vector); + matrix = glm::translate(matrix, -translation_vector); +} + +SEllipseTranslate::SEllipseTranslate(double dWidth, double dHeight, double dStartPosition, + double dEndPosition, bool bInter, double T0, double T1): + Operation(bInter, T0, T1) +{ + width = dWidth; + height = dHeight; + startPosition = dStartPosition; + endPosition = dEndPosition; +} + +void SEllipseTranslate::interpolate(glm::mat4& matrix, double t, double /* SlideWidthScale */, double /* SlideHeightScale */) const +{ + if(t <= mnT0) + return; + if(!mbInterpolate || t > mnT1) + t = mnT1; + t = intervalInter(t,mnT0,mnT1); + + double a1, a2, x, y; + a1 = startPosition*2*M_PI; + a2 = (startPosition + t*(endPosition - startPosition))*2*M_PI; + x = width*(cos (a2) - cos (a1))/2; + y = height*(sin (a2) - sin (a1))/2; + + matrix = glm::translate(matrix, glm::vec3(x, 0, y)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3