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, 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
 
QMap< int, QMap< int, QMap< qreal, QImage > > > m_thumbnails
 
QReadWriteLock m_thumbnailsLock
 
bool m_thumbnailsValid {false}
 

Detailed Description

Definition at line 15 of file kis_paint_device_cache.h.

Constructor & Destructor Documentation

◆ KisPaintDeviceCache() [1/2]

KisPaintDeviceCache::KisPaintDeviceCache ( KisPaintDevice * paintDevice)
inline

Definition at line 18 of file kis_paint_device_cache.h.

19 : m_paintDevice(paintDevice),
20 m_exactBoundsCache(paintDevice),
21 m_nonDefaultPixelAreaCache(paintDevice),
22 m_regionCache(paintDevice),
24 {
25 }
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,
qreal oversample,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags )
inline

Definition at line 77 of file kis_paint_device_cache.h.

77 {
78 QImage thumbnail;
79
80 if (h == 0 || w == 0) {
81 return thumbnail;
82 }
83
84 {
85 QReadLocker readLocker(&m_thumbnailsLock);
87 if (m_thumbnails.contains(w) && m_thumbnails[w].contains(h) && m_thumbnails[w][h].contains(oversample)) {
88 thumbnail = m_thumbnails[w][h][oversample];
89 }
90 }
91 else {
92 readLocker.unlock();
93 QWriteLocker writeLocker(&m_thumbnailsLock);
94 m_thumbnails.clear();
95 m_thumbnailsValid = true;
96 }
97 }
98
99 if (thumbnail.isNull()) {
100 // the thumbnails in the cache are always generated from exact bounds
101 thumbnail = m_paintDevice->createThumbnail(w, h, m_paintDevice->exactBounds(), oversample, renderingIntent, conversionFlags);
102
103 QWriteLocker writeLocker(&m_thumbnailsLock);
104 m_thumbnails[w][h][oversample] = thumbnail;
105 m_thumbnailsValid = true;
106 }
107
108 return thumbnail;
109 }
const qreal oversample
QMap< int, QMap< int, QMap< qreal, QImage > > > m_thumbnails
QImage createThumbnail(qint32 maxw, qint32 maxh, QRect rect, qreal oversample=1, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags())
QRect exactBounds() const

References KisPaintDevice::createThumbnail(), KisPaintDevice::exactBounds(), m_paintDevice, m_thumbnails, m_thumbnailsLock, m_thumbnailsValid, and oversample.

◆ 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 52 of file kis_paint_device_cache.h.

52 {
53 QRect bounds;
55
56 if (!result) {
64 }
65
66 return bounds;
67 }
bool tryGetValue(T &result, Mode mode) const
QRect extent() const
#define bounds(x, a, b)

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 111 of file kis_paint_device_cache.h.

111 {
112 return m_sequenceNumber;
113 }

References m_sequenceNumber.

◆ setupCache()

void KisPaintDeviceCache::setupCache ( )
inline

Definition at line 36 of file kis_paint_device_cache.h.

36 {
37 invalidate();
38 }

References invalidate().

Member Data Documentation

◆ m_exactBoundsCache

ExactBoundsCache KisPaintDeviceCache::m_exactBoundsCache
private

Definition at line 148 of file kis_paint_device_cache.h.

◆ m_nonDefaultPixelAreaCache

NonDefaultPixelCache KisPaintDeviceCache::m_nonDefaultPixelAreaCache
private

Definition at line 149 of file kis_paint_device_cache.h.

◆ m_paintDevice

KisPaintDevice* KisPaintDeviceCache::m_paintDevice {nullptr}
private

Definition at line 116 of file kis_paint_device_cache.h.

116{nullptr};

◆ m_regionCache

RegionCache KisPaintDeviceCache::m_regionCache
private

Definition at line 150 of file kis_paint_device_cache.h.

◆ m_sequenceNumber

QAtomicInt KisPaintDeviceCache::m_sequenceNumber
private

Definition at line 156 of file kis_paint_device_cache.h.

◆ m_thumbnails

QMap<int, QMap<int, QMap<qreal,QImage> > > KisPaintDeviceCache::m_thumbnails
private

Definition at line 154 of file kis_paint_device_cache.h.

◆ m_thumbnailsLock

QReadWriteLock KisPaintDeviceCache::m_thumbnailsLock
private

Definition at line 152 of file kis_paint_device_cache.h.

◆ m_thumbnailsValid

bool KisPaintDeviceCache::m_thumbnailsValid {false}
private

Definition at line 153 of file kis_paint_device_cache.h.

153{false};

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