File indexing completed on 2024-12-22 04:12:15
0001 /* 0002 * SPDX-FileCopyrightText: 2022 Eoin O'Neill <eoinoneill1991@gmail.com> 0003 * SPDX-FileCopyrightText: 2022 Emmet O'Neill <emmetoneill.pdx@gmail.com> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef KISFRAMEDISPLAYPROXY_H 0009 #define KISFRAMEDISPLAYPROXY_H 0010 0011 #include <QObject> 0012 #include <QPointer> 0013 0014 #include "kritaui_export.h" 0015 0016 #include "kis_animation_frame_cache.h" 0017 0018 /** 0019 * @brief The KisFrameDisplayProxy class sits between the KisCanvas (within its KisCanvasAnimationState) and its associated KisImage. 0020 * Its mainly responsible for choosing whether to reproject the image (always accurate) OR reuse the canvas' KisAnimationFrameCache (usually fast). :) 0021 */ 0022 class KRITAUI_EXPORT KisFrameDisplayProxy : public QObject 0023 { 0024 Q_OBJECT 0025 public: 0026 KisFrameDisplayProxy(class KisCanvas2 *canvas, QObject *parent = nullptr); 0027 ~KisFrameDisplayProxy(); 0028 0029 /** 0030 * @brief Tell the DisplayProxy to show a new frame. 0031 * @param forceReproject demands that the image used instead of the canvas' animation cache. 0032 */ 0033 bool displayFrame(int frame, bool forceReproject); 0034 0035 /** 0036 * @brief Gets the active frame, the frame that is intended to be shown. 0037 * This should always reflect the actual time position of the canvas at any given point. 0038 * In certain circumstances this value can be different from what is currently being shown. 0039 * (For example, when showing the activeKeyframe instead.) 0040 */ 0041 int activeFrame() const; 0042 0043 Q_SIGNALS: 0044 void sigFrameChange(); 0045 void sigFrameDisplayRefreshed(); 0046 0047 /** 0048 * @brief sigFrameRefreshSkipped tracks whether asynchronous "slow" refreshes are skipped 0049 * due to the frame being the same. In the case of waiting for next frame to render, it is necessary 0050 * to let any binding classes know that the there was no need to refresh the display at all. 0051 */ 0052 void sigFrameRefreshSkipped(); 0053 0054 private: 0055 /** 0056 * @brief Get the active keyframe. This is the latest unique frame that is actually visible. 0057 * It is not always the same as the position of playback, since it only changes when there's new content to be shown. (Consider "held" frames.) 0058 */ 0059 int activeKeyframe() const; 0060 0061 bool shouldUploadFrame(KisAnimationFrameCacheSP cache, int from, int to); 0062 bool needsReprojection(KisAnimationFrameCacheSP cache, int from, int to); 0063 0064 QScopedPointer<struct Private> m_d; 0065 }; 0066 0067 #endif // KISFRAMEDISPLAYPROXY_H