Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPaintDeviceCache Class Reference

#include <kis_paint_device_cache.h>

Classes

struct  ExactBoundsCache
 
struct  NonDefaultPixelCache
 
struct  RegionCache
 

Public Member Functions

QImage createThumbnail (qint32 w, qint32 h, KisThumbnailBoundsMode boundsMode, qreal oversample, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
 
QRect exactBounds ()
 
QRect exactBoundsAmortized ()
 
void invalidate ()
 
 KisPaintDeviceCache (const KisPaintDeviceCache &rhs)
 
 KisPaintDeviceCache (KisPaintDevice *paintDevice)
 
QRect nonDefaultPixelArea ()
 
KisRegion region ()
 
int sequenceNumber () const
 
void setupCache ()
 

Private Attributes

ExactBoundsCache m_exactBoundsCache
 
NonDefaultPixelCache m_nonDefaultPixelAreaCache
 
KisPaintDevicem_paintDevice {nullptr}
 
RegionCache m_regionCache
 
QAtomicInt m_sequenceNumber
 
QHash< ThumbnailCacheKey, QImage > m_thumbnails
 
QReadWriteLock m_thumbnailsLock
 
bool m_thumbnailsValid {false}
 

Detailed Description

Definition at line 31 of file kis_paint_device_cache.h.

Constructor & Destructor Documentation

◆ KisPaintDeviceCache() [1/2]

KisPaintDeviceCache::KisPaintDeviceCache ( KisPaintDevice * paintDevice)
inline

Definition at line 34 of file kis_paint_device_cache.h.

35 : m_paintDevice(paintDevice),
36 m_exactBoundsCache(paintDevice),
37 m_nonDefaultPixelAreaCache(paintDevice),
38 m_regionCache(paintDevice),
40 {
41 }
NonDefaultPixelCache m_nonDefaultPixelAreaCache
ExactBoundsCache m_exactBoundsCache

◆ KisPaintDeviceCache() [2/2]

KisPaintDeviceCache::KisPaintDeviceCache ( const KisPaintDeviceCache & rhs)
inline

Member Function Documentation

◆ createThumbnail()

QImage KisPaintDeviceCache::createThumbnail ( qint32 w,
qint32 h,
KisThumbnailBoundsMode boundsMode,
qreal oversample,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags )
inline

Definition at line 93 of file kis_paint_device_cache.h.

93 {
94 QImage thumbnail;
95
96 if (h == 0 || w == 0) {
97 return thumbnail;
98 }
99
100 auto key = std::make_tuple(QSize(w, h), oversample, boundsMode);
101
102 {
103 QReadLocker readLocker(&m_thumbnailsLock);
104 if (m_thumbnailsValid) {
105 if (m_thumbnails.contains(key)) {
106 thumbnail = m_thumbnails[key];
107 }
108 }
109 else {
110 readLocker.unlock();
111 QWriteLocker writeLocker(&m_thumbnailsLock);
112 m_thumbnails.clear();
113 m_thumbnailsValid = true;
114 }
115 }
116
117 if (thumbnail.isNull()) {
119 thumbnail = m_paintDevice->createThumbnailUncached(w, h, bounds, oversample, renderingIntent, conversionFlags);
120
121 QWriteLocker writeLocker(&m_thumbnailsLock);
122 m_thumbnails[key] = thumbnail;
123 m_thumbnailsValid = true;
124 }
125
126 return thumbnail;
127 }
const qreal oversample
QHash< ThumbnailCacheKey, QImage > m_thumbnails
QRect exactBounds() const
QRect extent() const
QImage createThumbnailUncached(qint32 maxw, qint32 maxh, QRect rect, qreal oversample=1, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags())
#define bounds(x, a, b)

References bounds, KisPaintDevice::createThumbnailUncached(), KisPaintDevice::exactBounds(), KisPaintDevice::extent(), m_paintDevice, m_thumbnails, m_thumbnailsLock, m_thumbnailsValid, oversample, and Precise.

◆ exactBounds()

QRect KisPaintDeviceCache::exactBounds ( )
inline

◆ exactBoundsAmortized()

QRect KisPaintDeviceCache::exactBoundsAmortized ( )
inline

The calculation of the exact bounds might be too slow in some special cases, e.g. for an empty canvas of 7k by 6k. So we just always return extent, when the exact bounds is not available.

Definition at line 68 of file kis_paint_device_cache.h.

68 {
69 QRect bounds;
71
72 if (!result) {
80 }
81
82 return bounds;
83 }
bool tryGetValue(T &result, Mode mode) const

References bounds, KisPaintDevice::defaultBounds(), KisPaintDevice::extent(), m_exactBoundsCache, m_paintDevice, KisLockFreeCacheWithModeConsistency< T, Mode >::tryGetValue(), and KisDefaultBoundsBase::wrapAroundMode().

◆ invalidate()

◆ nonDefaultPixelArea()

◆ region()

◆ sequenceNumber()

int KisPaintDeviceCache::sequenceNumber ( ) const
inline

Definition at line 129 of file kis_paint_device_cache.h.

129 {
130 return m_sequenceNumber;
131 }

References m_sequenceNumber.

◆ setupCache()

void KisPaintDeviceCache::setupCache ( )
inline

Definition at line 52 of file kis_paint_device_cache.h.

52 {
53 invalidate();
54 }

References invalidate().

Member Data Documentation

◆ m_exactBoundsCache

ExactBoundsCache KisPaintDeviceCache::m_exactBoundsCache
private

Definition at line 166 of file kis_paint_device_cache.h.

◆ m_nonDefaultPixelAreaCache

NonDefaultPixelCache KisPaintDeviceCache::m_nonDefaultPixelAreaCache
private

Definition at line 167 of file kis_paint_device_cache.h.

◆ m_paintDevice

KisPaintDevice* KisPaintDeviceCache::m_paintDevice {nullptr}
private

Definition at line 134 of file kis_paint_device_cache.h.

134{nullptr};

◆ m_regionCache

RegionCache KisPaintDeviceCache::m_regionCache
private

Definition at line 168 of file kis_paint_device_cache.h.

◆ m_sequenceNumber

QAtomicInt KisPaintDeviceCache::m_sequenceNumber
private

Definition at line 175 of file kis_paint_device_cache.h.

◆ m_thumbnails

QHash<ThumbnailCacheKey, QImage> KisPaintDeviceCache::m_thumbnails
private

Definition at line 173 of file kis_paint_device_cache.h.

◆ m_thumbnailsLock

QReadWriteLock KisPaintDeviceCache::m_thumbnailsLock
private

Definition at line 170 of file kis_paint_device_cache.h.

◆ m_thumbnailsValid

bool KisPaintDeviceCache::m_thumbnailsValid {false}
private

Definition at line 171 of file kis_paint_device_cache.h.

171{false};

The documentation for this class was generated from the following file: