Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_cached_paint_device.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef __KIS_CACHED_PAINT_DEVICE_H
8#define __KIS_CACHED_PAINT_DEVICE_H
9
10#include "kis_lockless_stack.h"
11#include "kis_default_bounds.h"
13#include "kis_paint_device.h"
14#include "kis_selection.h"
15#include "KoColorSpace.h"
16#include "KoColor.h"
17
19{
20public:
22 KisPaintDeviceSP device;
23
24 if(!m_stack.pop(device)) {
25 device = new KisPaintDevice(prototype->colorSpace());
26 }
27
28 device->prepareClone(prototype);
29 return device;
30 }
31
33 KisPaintDeviceSP device;
34
35 if(!m_stack.pop(device)) {
36 device = new KisPaintDevice(colorSpace);
37 } else {
38 device->convertTo(colorSpace);
39 }
40
41 device->setDefaultPixel(KoColor(colorSpace));
42 device->setDefaultBounds(prototype->defaultBounds());
43 device->setX(prototype->x());
44 device->setY(prototype->y());
45
46 return device;
47 }
48
50 device->clear();
52 m_stack.push(device);
53 }
54
55 bool isEmpty() const {
56 return m_stack.isEmpty();
57 }
58
59 struct Guard {
61 : m_parent(parent)
62 {
63 m_device = m_parent.getDevice(prototype);
64 }
65
67 : m_parent(parent)
68 {
69 m_device = m_parent.getDevice(prototype, cs);
70 }
71
75
77 return m_device;
78 }
79
80 private:
83 };
84
85private:
87};
88
90{
91public:
93 KisSelectionSP selection;
94
95 if(!m_stack.pop(selection)) {
97 }
98
99 return selection;
100 }
101
102 void putSelection(KisSelectionSP selection) {
103 selection->clear();
106 selection->pixelSelection()->moveTo(QPoint());
107 m_stack.push(selection);
108 }
109
110 bool isEmpty() const {
111 return m_stack.isEmpty();
112 }
113
114 struct Guard {
116 : m_parent(parent)
117 {
119 }
120
124
126 return m_selection;
127 }
128
129 private:
132 };
133
134private:
136};
137
138#endif /* __KIS_CACHED_PAINT_DEVICE_H */
KisLocklessStack< KisPaintDeviceSP > m_stack
KisPaintDeviceSP getDevice(KisPaintDeviceSP prototype)
void putDevice(KisPaintDeviceSP device)
KisPaintDeviceSP getDevice(KisPaintDeviceSP prototype, const KoColorSpace *colorSpace)
void putSelection(KisSelectionSP selection)
KisSelectionSP getSelection()
KisLocklessStack< KisSelectionSP > m_stack
static KisImageResolutionProxySP identity()
void setX(qint32 x)
virtual void clear()
void setDefaultPixel(const KoColor &defPixel)
void setDefaultBounds(KisDefaultBoundsBaseSP bounds)
const KoColorSpace * colorSpace() const
KisDefaultBoundsBaseSP defaultBounds() const
void prepareClone(KisPaintDeviceSP src)
void convertTo(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags(), KUndo2Command *parentCommand=nullptr, KoUpdater *progressUpdater=nullptr)
void setY(qint32 y)
Guard(KisPaintDeviceSP prototype, const KoColorSpace *cs, KisCachedPaintDevice &parent)
Guard(KisPaintDeviceSP prototype, KisCachedPaintDevice &parent)
KisPaintDeviceSP device() const
Guard(KisCachedSelection &parent)
void moveTo(const QPoint &pt) override
void setResolutionProxy(KisImageResolutionProxySP proxy)
KisPixelSelectionSP pixelSelection
void setDefaultBounds(KisDefaultBoundsBaseSP bounds)