File indexing completed on 2025-01-05 03:57:25
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2017-05-24 0007 * Description : images transition manager. 0008 * 0009 * SPDX-FileCopyrightText: 2017-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_TRANSITION_MNGR_PRIVATE_H 0016 #define DIGIKAM_TRANSITION_MNGR_PRIVATE_H 0017 0018 // C++ includes 0019 0020 #include <cmath> 0021 0022 // Qt includes 0023 0024 #include <QPainter> 0025 #include <QPainterPath> 0026 #include <QPolygon> 0027 #include <QRandomGenerator> 0028 0029 // Local includes 0030 0031 #include "transitionmngr.h" 0032 #include "digikam_config.h" 0033 #include "digikam_debug.h" 0034 0035 namespace Digikam 0036 { 0037 0038 class Q_DECL_HIDDEN TransitionMngr::Private 0039 { 0040 public: 0041 0042 typedef int (TransitionMngr::Private::*TransMethod)(bool); 0043 0044 public: 0045 0046 explicit Private() 0047 : eff_isRunning (false), 0048 eff_curTransition(TransitionMngr::None), 0049 eff_x (0), 0050 eff_y (0), 0051 eff_w (0), 0052 eff_h (0), 0053 eff_dx (0), 0054 eff_dy (0), 0055 eff_ix (0), 0056 eff_iy (0), 0057 eff_i (0), 0058 eff_j (0), 0059 eff_subType (0), 0060 eff_x0 (0), 0061 eff_y0 (0), 0062 eff_x1 (0), 0063 eff_y1 (0), 0064 eff_wait (0), 0065 eff_fx (0), 0066 eff_fy (0), 0067 eff_alpha (0), 0068 eff_fd (0), 0069 eff_intArray (nullptr), 0070 eff_pdone (0), 0071 eff_pixelMatrix (nullptr), 0072 eff_pa (QPolygon(4)), 0073 eff_px (0), 0074 eff_py (0), 0075 eff_psx (0), 0076 eff_psy (0) 0077 { 0078 registerTransitions(); 0079 randomGenerator = QRandomGenerator::global(); 0080 } 0081 0082 ~Private() 0083 { 0084 if (eff_intArray) 0085 { 0086 delete [] eff_intArray; 0087 } 0088 } 0089 0090 QMap<TransitionMngr::TransType, TransMethod> eff_transList; 0091 0092 QImage eff_inImage; 0093 QImage eff_outImage; 0094 QImage eff_curFrame; 0095 QSize eff_outSize; 0096 0097 bool eff_isRunning; 0098 TransitionMngr::TransType eff_curTransition; 0099 0100 // values for state of various transitions: 0101 int eff_x; 0102 int eff_y; 0103 int eff_w; 0104 int eff_h; 0105 int eff_dx; 0106 int eff_dy; 0107 int eff_ix; 0108 int eff_iy; 0109 int eff_i; 0110 int eff_j; 0111 int eff_subType; 0112 int eff_x0; 0113 int eff_y0; 0114 int eff_x1; 0115 int eff_y1; 0116 int eff_wait; 0117 double eff_fx; 0118 double eff_fy; 0119 double eff_alpha; 0120 double eff_fd; 0121 int* eff_intArray; 0122 bool eff_pdone; 0123 bool** eff_pixelMatrix; 0124 0125 //static 0126 QPolygon eff_pa; 0127 0128 int eff_px; 0129 int eff_py; 0130 int eff_psx; 0131 int eff_psy; 0132 0133 public: 0134 0135 void registerTransitions(); 0136 0137 TransitionMngr::TransType getRandomTransition() const; 0138 0139 private: 0140 0141 // Internal functions to render an effect frame. 0142 // aInit is to true when effect is initialized (first call). 0143 // The returned integer value is a tempo in ms to wait between frames, 0144 // or -1 if the effect is completed. 0145 0146 int transitionNone(bool aInit); 0147 int transitionChessboard(bool aInit); 0148 int transitionMeltdown(bool aInit); 0149 int transitionSweep(bool aInit); 0150 int transitionMosaic(bool aInit); 0151 int transitionCubism(bool aInit); 0152 int transitionRandom(bool aInit); 0153 int transitionGrowing(bool aInit); 0154 int transitionHorizLines(bool aInit); 0155 int transitionVertLines(bool aInit); 0156 int transitionMultiCircleOut(bool aInit); 0157 int transitionSpiralIn(bool aInit); 0158 int transitionCircleOut(bool aInit); 0159 int transitionBlobs(bool aInit); 0160 int transitionFade(bool aInit); 0161 int transitionSlideL2R(bool aInit); 0162 int transitionSlideR2L(bool aInit); 0163 int transitionSlideT2B(bool aInit); 0164 int transitionSlideB2T(bool aInit); 0165 int transitionPushL2R(bool aInit); 0166 int transitionPushR2L(bool aInit); 0167 int transitionPushT2B(bool aInit); 0168 int transitionPushB2T(bool aInit); 0169 int transitionSwapL2R(bool aInit); 0170 int transitionSwapR2L(bool aInit); 0171 int transitionSwapT2B(bool aInit); 0172 int transitionSwapB2T(bool aInit); 0173 int transitionBlurIn(bool aInit); 0174 int transitionBlurOut(bool aInit); 0175 0176 private: 0177 0178 QRgb convertFromPremult(const QRgb& p) const; 0179 QImage fastBlur(const QImage& img, int radius) const; 0180 0181 private: 0182 0183 QRandomGenerator* randomGenerator = nullptr; 0184 }; 0185 0186 } // namespace Digikam 0187 0188 #endif // DIGIKAM_TRANSITION_MNGR_PRIVATE_H