File indexing completed on 2024-05-19 04:29:18

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2022 Emmet O'Neill <emmetoneill.pdx@gmail.com>
0003    SPDX-FileCopyrightText: 2022 Eoin O'Neill <eoinoneill1991@gmail.com>
0004 
0005    SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KISPLAYBACKENGINEQT_H
0009 #define KISPLAYBACKENGINEQT_H
0010 
0011 #include "KisPlaybackEngine.h"
0012 
0013 #include <kritaui_export.h>
0014 
0015 
0016 #include "canvas/KisCanvasAnimationState.h"
0017 #include <boost/optional.hpp>
0018 
0019 #include <QElapsedTimer>
0020 
0021 /**
0022  * @brief The KisPlaybackEngineQT class is an implementation of KisPlaybackEngine
0023  * that drives animation playback using simple Qt functionality alone.
0024  *
0025  * As of right now, this playback engine is used as a fallback for when KisPlaybackEngineMLT is unavailable,
0026  * invalid, or otherwise unwanted.
0027  */
0028 class KRITAUI_EXPORT KisPlaybackEngineQT : public KisPlaybackEngine
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     explicit KisPlaybackEngineQT(QObject *parent = nullptr);
0034     ~KisPlaybackEngineQT();
0035 
0036     void seek(int frameIndex, SeekOptionFlags flags = SEEK_FINALIZE | SEEK_PUSH_AUDIO) override;
0037 
0038     void setMute(bool) override {}
0039     bool isMute() override { return true; }
0040 
0041     bool supportsAudio() override {return false;}
0042     bool supportsVariablePlaybackSpeed() override { return true; }
0043 
0044     void setDropFramesMode(bool value) override;
0045 
0046     boost::optional<int64_t> activeFramesPerSecond() const;
0047 
0048     PlaybackStats playbackStatistics() const override;
0049 
0050 protected Q_SLOTS:
0051     /**
0052      * @brief throttledDriverCallback handles signals from the internal driver
0053      * that drives playback within this engine. It will either increment frame time,
0054      * wrapping within bounds, and communicate with KisFrameDisplayProxy or use the
0055      * driver's desired time to control which frame is visible...
0056      */
0057     void throttledDriverCallback();
0058 
0059 
0060 protected:
0061     void setCanvas(KoCanvasBase* canvas) override;
0062     void unsetCanvas() override;
0063 
0064 private:
0065     struct Private;
0066     QScopedPointer<Private> m_d;
0067 };
0068 
0069 #endif // KISPLAYBACKENGINEQT_H