Krita Source Code Documentation
Loading...
Searching...
No Matches
KisBrushStrokePreviewCache.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 Tenzin Rangdol <tenzindraws@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef KIS_BRUSH_STROKE_PREVIEW_CACHE_H
8#define KIS_BRUSH_STROKE_PREVIEW_CACHE_H
9
10#include <QImage>
11#include <QObject>
12#include <QScopedPointer>
13#include <QSize>
14#include <QString>
15#include <QVariant>
16
17#include <kis_paintop_preset.h>
18#include <kritaui_export.h>
19
21
26class KRITAUI_EXPORT KisBrushStrokePreviewCache : public QObject
27{
28 Q_OBJECT
29
30public:
32
34 static bool needsStripedBackground(const QString &paintOpId);
35
37 static bool isNoPreviewEngine(const QString &paintOpId);
38
40 QImage getPreview(int presetId, const QSize &size, qreal pixelRatio);
41
43 void invalidatePreset(int presetId);
44
46 void registerLivePreviewView(KisPresetLivePreviewView *view);
47
48Q_SIGNALS:
50 void sigPreviewReady(int presetId);
51
52public Q_SLOTS:
54 void slotLivePreviewImageReady(int presetId, QImage previewImage);
55
56 void slotPreviewImageReady(int presetId, QImage previewImage);
57
59 void slotPresetSettingsChanged(KisPaintOpPresetSP preset);
60
62 void slotSetCurrentPreset(KisPaintOpPresetSP preset);
63
64private Q_SLOTS:
65 void slotCurrentPresetSettingsChanged();
66
67private:
70 Q_DISABLE_COPY(KisBrushStrokePreviewCache)
71
72 QString generateCacheKey(int presetId) const;
73 QString generateSizedCacheKey(int presetId, const QSize &size) const;
75 void evictIfNeeded();
76 void updateAccessOrder(const QString &key);
77 QImage generatePlaceholder(const QSize &size, qreal pixelRatio) const;
78 QImage generateNoPreviewPlaceholder(const QSize &size, qreal pixelRatio) const;
79 QString generateSettingsFingerprint(KisPaintOpPresetSP preset) const;
80 QImage scalePreviewToSize(const QImage &source, const QSize &targetSize) const;
81
82 // Disk cache
83 void initDiskCache();
84 QString getDiskCacheFilename(int presetId) const;
85 QImage loadFromDiskCache(int presetId);
86 void saveToDiskCache(int presetId, QImage image);
87 bool hasDiskCache(int presetId) const;
88 void removeDiskCache(int presetId);
89
90 void requestPreviewGeneration(int presetId);
91
92 struct Private;
93 QScopedPointer<Private> m_d;
94};
95
96#endif // KIS_BRUSH_STROKE_PREVIEW_CACHE_H
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
PythonPluginManager * instance
void sigPreviewReady(int presetId)
Emitted when a preview is ready; triggers UI repaint.