Debian Codegraph @

libs/ui/canvas/kis_prescaled_projection.h

raw symbols SCIP
1 /*
2 * SPDX-FileCopyrightText: 2006 Boudewijn Rempt <[email protected]>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 #ifndef KIS_PRESCALED_PROJECTION_H
7 #define KIS_PRESCALED_PROJECTION_H
8
9 #include <QObject>
10
11 #include <kritaui_export.h>
12 #include <kis_shared.h>
13
14 #include "KoColorConversionTransformation.h"
15 class QImage;
16 class QRect;
17 class QSize;
18 class QPainter;
19
20 class KoColorProfile;
21 class KisCoordinatesConverter;
22 class KisDisplayFilter;
23 class KisDisplayConfig;
24 class KisCanvasState;
25
26 #include <kis_types.h>
27 #include "kis_ui_types.h"
28
29
30 /**
31 * KisPrescaledProjection is responsible for keeping around a
32 * prescaled QImage representation that is always suitable for
33 * painting onto the canvas.
34 *
35 * Note: the export macro is only for the unittest.
36 */
37 class KRITAUI_EXPORT KisPrescaledProjection : public QObject, public KisShared
38 {
39 Q_OBJECT
40 public:
41
42 KisPrescaledProjection();
43 ~KisPrescaledProjection() override;
44
45 void setImage(KisImageWSP image);
46
47 /**
48 * Return the prescaled QImage. The prescaled image is exactly as big as
49 * the canvas widget in pixels.
50 */
51 QImage prescaledQImage() const;
52
53 void setCoordinatesConverter(KisCoordinatesConverter *coordinatesConverter);
54
55 public Q_SLOTS:
56
57 /**
58 * Retrieves image's data from KisImage object and updates
59 * internal cache
60 * @param dirtyImageRect the rect changed on the image
61 * @see recalculateCache
62 */
63 KisUpdateInfoSP updateCache(const QRect &dirtyImageRect);
64
65 /**
66 * Updates the prescaled cache at current zoom level
67 * @param info update structure returned by updateCache
68 * @see updateCache
69 */
70 void recalculateCache(KisUpdateInfoSP info);
71
72 /**
73 * Called whenever the configuration settings change.
74 */
75 void updateSettings();
76
77 void notifyCanvasStateChanged(const KisCanvasState &state);
78
79 /**
80 * Called whenever the size of the KisImage changes.
81 * It is a part of a complex update ritual, when the size
82 * of the image changes. This method just resizes the storage
83 * for the image cache, it doesn't update any cached data.
84 */
85 void slotImageSizeChanged(qint32 w, qint32 h);
86
87 /**
88 * Checks whether it is needed to resize the prescaled image and
89 * updates it. The size is given in canvas widget pixels.
90 */
91 void notifyCanvasSizeChanged(const QSize &widgetSize);
92
93 /**
94 * Set the current monitor profile
95 */
96 void setDisplayConfig(const KisDisplayConfig &config);
97
98 void setChannelFlags(const QBitArray &channelFlags);
99
100 void setDisplayFilter(QSharedPointer<KisDisplayFilter> displayFilter);
101
102 /**
103 * Called whenever the zoom level changes or another chunk of the
104 * image becomes visible. The currently visible area of the image
105 * is complete scaled again.
106 */
107 void preScale();
108
109 private:
110
111 friend class KisPrescaledProjectionTest;
112
113 KisPrescaledProjection(const KisPrescaledProjection &);
114 KisPrescaledProjection operator=(const KisPrescaledProjection &);
115
116 void updateViewportSize();
117
118 /**
119 * Called whenever the view widget needs to show a different part of
120 * the document
121 */
122 void viewportMoved(const QPointF &offset);
123
124 /**
125 * This creates an empty update information and fills it with the only
126 * parameter: @p dirtyImageRect
127 * This function is supposed to be run in the context of the image
128 * threads, so it does no accesses to zoom or any UI specific values.
129 * All the needed information for zooming will be fetched in the context
130 * of the UI thread in fillInUpdateInformation().
131 *
132 * @see fillInUpdateInformation()
133 */
134 KisPPUpdateInfoSP getInitialUpdateInformation(const QRect &dirtyImageRect);
135
136 /**
137 * Prepare all the information about rects needed during
138 * projection updating.
139 *
140 * @param viewportRect the part of the viewport that has to be updated
141 * @param info the structure to be filled in. It's member dirtyImageRect
142 * is supposed to have already been set up in the previous step of the
143 * update in getInitialUpdateInformation(). Though it is allowed to
144 * be null rect.
145 *
146 * @see getInitialUpdateInformation()
147 */
148 void fillInUpdateInformation(const QRect &viewportRect,
149 KisPPUpdateInfoSP info);
150
151 /**
152 * Initiates the process of prescaled image update
153 *
154 * @param info prepared information
155 */
156 void updateScaledImage(KisPPUpdateInfoSP info);
157
158 /**
159 * Actual drawing is done here
160 * @param info prepared information
161 * @param gc The painter we draw on
162 */
163 void drawUsingBackend(QPainter &gc, KisPPUpdateInfoSP info);
164
165 struct Private;
166 Private * const m_d;
167 };
168
169 #endif