File indexing completed on 2024-05-12 16:01:48
0001 /* 0002 * SPDX-FileCopyrightText: 2018 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef KISFRAMECACHESTORE_H 0007 #define KISFRAMECACHESTORE_H 0008 0009 #include "kritaui_export.h" 0010 #include <QScopedPointer> 0011 #include "kis_types.h" 0012 0013 #include "opengl/kis_texture_tile_info_pool.h" 0014 0015 class KisOpenGLUpdateInfoBuilder; 0016 0017 class KisOpenGLUpdateInfo; 0018 typedef KisSharedPtr<KisOpenGLUpdateInfo> KisOpenGLUpdateInfoSP; 0019 0020 /** 0021 * KisFrameCacheStore is a middle-level class for reading/writing 0022 * animation frames on disk. Its main responsibilities: 0023 * 0024 * 1) Convert frames from KisOpenGLUpdateInfo format into a serializable 0025 * KisFrameDataSerializer::Frame format. 0026 * 0027 * 2) Calculate differences between the frames and decide which 0028 * frame will be a keyframe for other frames. 0029 * 0030 * 3) The keyframes will be used as a base for difference 0031 * calculation and stored in a short in-memory cache to avoid 0032 * fetching them from disk too often. 0033 * 0034 * 4) The in-memory cache of the keyframes is stored in serializable 0035 * KisFrameDataSerializer::Frame format. 0036 */ 0037 0038 class KRITAUI_EXPORT KisFrameCacheStore 0039 { 0040 public: 0041 KisFrameCacheStore(); 0042 KisFrameCacheStore(const QString &frameCachePath); 0043 0044 ~KisFrameCacheStore(); 0045 0046 // WARNING: after transferring \p info to saveFrame() the object becomes invalid 0047 void saveFrame(int frameId, KisOpenGLUpdateInfoSP info, const QRect &imageBounds); 0048 KisOpenGLUpdateInfoSP loadFrame(int frameId, const KisOpenGLUpdateInfoBuilder &builder); 0049 0050 void moveFrame(int srcFrameId, int dstFrameId); 0051 0052 void forgetFrame(int frameId); 0053 bool hasFrame(int frameId) const; 0054 0055 int frameLevelOfDetail(int frameId) const; 0056 QRect frameDirtyRect(int frameId) const; 0057 0058 private: 0059 struct Private; 0060 const QScopedPointer<Private> m_d; 0061 }; 0062 0063 #endif // KISFRAMECACHESTORE_H