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

#include <kis_datamanager.h>

+ Inheritance diagram for KisDataManager:

Public Member Functions

void bitBlt (KisTiledDataManagerSP srcDM, const QRect &rect)
 
void bitBltOldData (KisTiledDataManagerSP srcDM, const QRect &rect)
 
void bitBltRough (KisTiledDataManagerSP srcDM, const QRect &rect)
 
void bitBltRoughOldData (KisTiledDataManagerSP srcDM, const QRect &rect)
 
void clear ()
 
void clear (qint32 x, qint32 y, qint32 w, qint32 h, const quint8 *def)
 
void clear (qint32 x, qint32 y, qint32 w, qint32 h, quint8 def)
 
const quint8 * defaultPixel () const
 
QRect extent () const
 
void extent (qint32 &x, qint32 &y, qint32 &w, qint32 &h) const
 
KisMementoSP getMemento ()
 
bool hasCurrentMemento () const
 
 KisDataManager (const KisDataManager &dm)
 
 KisDataManager (quint32 pixelSize, const quint8 *defPixel)
 
qint32 numContiguousColumns (qint32 x, qint32 minY, qint32 maxY) const
 
qint32 numContiguousRows (qint32 y, qint32 minX, qint32 maxX) const
 
quint32 pixelSize () const
 
void purge (const QRect &area)
 
bool read (QIODevice *io)
 
void readBytes (quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h, qint32 dataRowStride=-1) const
 
QVector< quint8 * > readPlanarBytes (QVector< qint32 > channelsizes, qint32 x, qint32 y, qint32 w, qint32 h) const
 
KisRegion region () const
 
void rollback (KisMementoSP memento)
 
void rollforward (KisMementoSP memento)
 
qint32 rowStride (qint32 x, qint32 y) const
 
void setDefaultPixel (const quint8 *defPixel)
 
void setExtent (const QRect &rect)
 
void setExtent (qint32 x, qint32 y, qint32 w, qint32 h)
 
void setPixel (qint32 x, qint32 y, const quint8 *data)
 
bool write (KisPaintDeviceWriter &writer)
 
void writeBytes (const quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h, qint32 dataRowStride=-1)
 
void writePlanarBytes (QVector< quint8 * > planes, QVector< qint32 > channelsizes, qint32 x, qint32 y, qint32 w, qint32 h)
 
 ~KisDataManager () override
 

Static Public Member Functions

static void releaseInternalPools ()
 

Friends

class KisHLineIterator
 
class KisRectIterator
 
class KisVLineIterator
 

Detailed Description

KisDataManager defines the interface that modules responsible for storing and retrieving data must implement. Data modules, like the tile manager, are responsible for:

  • Storing undo/redo data
  • Offering ordered and unordered iterators over rects of pixels
  • (eventually) efficiently loading and saving data in a format that may allow deferred loading.

A datamanager knows nothing about the type of pixel data except how many quint8's a single pixel takes.

Definition at line 33 of file kis_datamanager.h.

Constructor & Destructor Documentation

◆ KisDataManager() [1/2]

KisDataManager::KisDataManager ( quint32 pixelSize,
const quint8 * defPixel )
inline

Create a new datamanager where every pixel will take pixelSize bytes and will be initialized by default with defPixel. The value of defPixel is copied, the caller still owns the pointer.

Note that if pixelSize > size of the defPixel array, we will happily read beyond the defPixel array.

Definition at line 45 of file kis_datamanager.h.

45: ACTUAL_DATAMGR(pixelSize, defPixel) {}
quint32 pixelSize() const
#define ACTUAL_DATAMGR

◆ KisDataManager() [2/2]

KisDataManager::KisDataManager ( const KisDataManager & dm)
inline

Definition at line 46 of file kis_datamanager.h.

46: ACTUAL_DATAMGR(dm) { }

◆ ~KisDataManager()

KisDataManager::~KisDataManager ( )
inlineoverride

Definition at line 48 of file kis_datamanager.h.

48 {
49 }

Member Function Documentation

◆ bitBlt()

void KisDataManager::bitBlt ( KisTiledDataManagerSP srcDM,
const QRect & rect )
inline

Clones rect from another datamanager. The cloned area will be shared between both datamanagers as much as possible using copy-on-write. Parts of the rect that cannot be shared (cross tiles) are deep-copied,

Definition at line 207 of file kis_datamanager.h.

207 {
208 ACTUAL_DATAMGR::bitBlt(const_cast<KisTiledDataManager*>(srcDM.data()), rect);
209 }

References KisSharedPtr< T >::data().

◆ bitBltOldData()

void KisDataManager::bitBltOldData ( KisTiledDataManagerSP srcDM,
const QRect & rect )
inline

The same as bitBlt() but reads old data

Definition at line 214 of file kis_datamanager.h.

214 {
215 ACTUAL_DATAMGR::bitBltOldData(const_cast<KisTiledDataManager*>(srcDM.data()), rect);
216 }

References KisSharedPtr< T >::data().

◆ bitBltRough()

void KisDataManager::bitBltRough ( KisTiledDataManagerSP srcDM,
const QRect & rect )
inline

Clones rect from another datamanager in a rough and fast way. All the tiles touched by rect will be shared, between both devices, that means it will copy a bigger area than was requested. This method is supposed to be used for bitBlt'ing into temporary paint devices.

Definition at line 225 of file kis_datamanager.h.

225 {
226 ACTUAL_DATAMGR::bitBltRough(const_cast<KisTiledDataManager*>(srcDM.data()), rect);
227 }

References KisSharedPtr< T >::data().

◆ bitBltRoughOldData()

void KisDataManager::bitBltRoughOldData ( KisTiledDataManagerSP srcDM,
const QRect & rect )
inline

The same as bitBltRough() but reads old data

Definition at line 232 of file kis_datamanager.h.

232 {
233 ACTUAL_DATAMGR::bitBltRoughOldData(const_cast<KisTiledDataManager*>(srcDM.data()), rect);
234 }

References KisSharedPtr< T >::data().

◆ clear() [1/3]

void KisDataManager::clear ( )
inline

Clear all back to default values.

Definition at line 195 of file kis_datamanager.h.

195 {
196 ACTUAL_DATAMGR::clear();
197 }

◆ clear() [2/3]

void KisDataManager::clear ( qint32 x,
qint32 y,
qint32 w,
qint32 h,
const quint8 * def )
inline

Clear the specified rect to the specified pixel value.

Definition at line 185 of file kis_datamanager.h.

187 {
188 ACTUAL_DATAMGR::clear(x, y, w, h, def);
189 }

◆ clear() [3/3]

void KisDataManager::clear ( qint32 x,
qint32 y,
qint32 w,
qint32 h,
quint8 def )
inline

Clear the specified rect to the specified value.

Definition at line 176 of file kis_datamanager.h.

178 {
179 ACTUAL_DATAMGR::clear(x, y, w, h, def);
180 }

◆ defaultPixel()

const quint8 * KisDataManager::defaultPixel ( ) const
inline

Get a pointer to the default pixel.

Definition at line 63 of file kis_datamanager.h.

63 {
64 return ACTUAL_DATAMGR::defaultPixel();
65 }

◆ extent() [1/2]

QRect KisDataManager::extent ( ) const
inline

Definition at line 150 of file kis_datamanager.h.

150 {
151 return ACTUAL_DATAMGR::extent();
152 }

◆ extent() [2/2]

void KisDataManager::extent ( qint32 & x,
qint32 & y,
qint32 & w,
qint32 & h ) const
inline

Return the extent of the data in x,y,w,h.

Definition at line 146 of file kis_datamanager.h.

146 {
147 return ACTUAL_DATAMGR::extent(x, y, w, h);
148 }

◆ getMemento()

KisMementoSP KisDataManager::getMemento ( )
inline

Requests a memento from the data manager. There is only one memento active at any given moment for a given paint device and all and any write actions on the datamanager builds undo data into this memento necessary to rollback the transaction.

Definition at line 73 of file kis_datamanager.h.

73 {
74 return ACTUAL_DATAMGR::getMemento();
75 }

◆ hasCurrentMemento()

bool KisDataManager::hasCurrentMemento ( ) const
inline
Returns
true if there is a memento active. This means that iterators can rely on the oldData() function.

Definition at line 102 of file kis_datamanager.h.

102 {
103 return ACTUAL_DATAMGR::hasCurrentMemento();
104 }

◆ numContiguousColumns()

qint32 KisDataManager::numContiguousColumns ( qint32 x,
qint32 minY,
qint32 maxY ) const
inline

Get the number of contiguous columns starting at x, valid for all values of y between minY and maxY.

Definition at line 315 of file kis_datamanager.h.

315 {
316 return ACTUAL_DATAMGR::numContiguousColumns(x, minY, maxY);
317 }

◆ numContiguousRows()

qint32 KisDataManager::numContiguousRows ( qint32 y,
qint32 minX,
qint32 maxX ) const
inline

Get the number of contiguous rows starting at y, valid for all values of x between minX and maxX.

Definition at line 324 of file kis_datamanager.h.

324 {
325 return ACTUAL_DATAMGR::numContiguousRows(y, minX, maxX);
326 }

◆ pixelSize()

quint32 KisDataManager::pixelSize ( ) const
inline

Returns the number of bytes a pixel takes

Definition at line 139 of file kis_datamanager.h.

139 {
140 return ACTUAL_DATAMGR::pixelSize();
141 }

◆ purge()

void KisDataManager::purge ( const QRect & area)
inline

Definition at line 120 of file kis_datamanager.h.

120 {
121 ACTUAL_DATAMGR::purge(area);
122 }

◆ read()

bool KisDataManager::read ( QIODevice * io)
inline

Definition at line 116 of file kis_datamanager.h.

116 {
117 return ACTUAL_DATAMGR::read(io);
118 }

◆ readBytes()

void KisDataManager::readBytes ( quint8 * data,
qint32 x,
qint32 y,
qint32 w,
qint32 h,
qint32 dataRowStride = -1 ) const
inline

Copy the bytes in the specified rect to a chunk of memory. The pixelSize in bytes is w * h * pixelSize

Definition at line 250 of file kis_datamanager.h.

253 {
254 ACTUAL_DATAMGR::readBytes(data, x, y, w, h, dataRowStride);
255 }

◆ readPlanarBytes()

QVector< quint8 * > KisDataManager::readPlanarBytes ( QVector< qint32 > channelsizes,
qint32 x,
qint32 y,
qint32 w,
qint32 h ) const
inline

Copy the bytes in the paint device into a vector of arrays of bytes, where the number of arrays is the number of channels in the paint device. If the specified area is larger than the paint device's extent, the default pixel will be read.

Parameters
channelsizesa vector with for every channel its size in bytes
xx coordinate of the top left corner
yy coordinate of the top left corner
wwidth
hheight

Definition at line 281 of file kis_datamanager.h.

281 {
282 return ACTUAL_DATAMGR::readPlanarBytes(channelsizes, x, y, w, h);
283 }

◆ region()

KisRegion KisDataManager::region ( ) const
inline

Definition at line 154 of file kis_datamanager.h.

154 {
155 return ACTUAL_DATAMGR::region();
156 }

◆ releaseInternalPools()

static void KisDataManager::releaseInternalPools ( )
inlinestatic

The tiles may be not allocated directly from the glibc, but instead can be allocated in bigger blobs. After you freed quite a lot of data and are sure you won't need it anymore, you can release these pools to save the memory.

Definition at line 130 of file kis_datamanager.h.

130 {
131 ACTUAL_DATAMGR::releaseInternalPools();
132 }

◆ rollback()

void KisDataManager::rollback ( KisMementoSP memento)
inline

Restores the image data to the state at the time of the getMemento() call.

Note that rollback should be performed with mementos in the reverse order of their creation, as mementos only store incremental changes

Definition at line 83 of file kis_datamanager.h.

83 {
84 ACTUAL_DATAMGR::rollback(memento);
85 }

◆ rollforward()

void KisDataManager::rollforward ( KisMementoSP memento)
inline

Restores the image data to the state at the time of the rollback call of the memento.

Note that rollforward must only be called when an rollback have previously been performed, and no intermittent actions have been performed (though it's ok to rollback other mementos and roll them forward again)

Definition at line 94 of file kis_datamanager.h.

94 {
95 ACTUAL_DATAMGR::rollforward(memento);
96 }

◆ rowStride()

qint32 KisDataManager::rowStride ( qint32 x,
qint32 y ) const
inline

Get the row stride at pixel (x, y). This is the number of bytes to add to a pointer to pixel (x, y) to access (x, y + 1).

Definition at line 333 of file kis_datamanager.h.

333 {
334 return ACTUAL_DATAMGR::rowStride(x, y);
335 }

◆ setDefaultPixel()

void KisDataManager::setDefaultPixel ( const quint8 * defPixel)
inline

Sets the default pixel. New data will be initialised with this pixel. The pixel is copied: the caller still owns the pointer.

Definition at line 56 of file kis_datamanager.h.

56 {
57 return ACTUAL_DATAMGR::setDefaultPixel(defPixel);
58 }

◆ setExtent() [1/2]

void KisDataManager::setExtent ( const QRect & rect)
inline

Definition at line 167 of file kis_datamanager.h.

167 {
168 setExtent(rect.x(), rect.y(), rect.width(), rect.height());
169 }
void setExtent(qint32 x, qint32 y, qint32 w, qint32 h)

References setExtent().

◆ setExtent() [2/2]

void KisDataManager::setExtent ( qint32 x,
qint32 y,
qint32 w,
qint32 h )
inline

Crop or extend the data to x, y, w, h.

Definition at line 163 of file kis_datamanager.h.

163 {
164 return ACTUAL_DATAMGR::setExtent(x, y, w, h);
165 }

◆ setPixel()

void KisDataManager::setPixel ( qint32 x,
qint32 y,
const quint8 * data )
inline

Write the specified data to x, y. There is no checking on pixelSize!

Definition at line 241 of file kis_datamanager.h.

241 {
242 ACTUAL_DATAMGR::setPixel(x, y, data);
243 }

◆ write()

bool KisDataManager::write ( KisPaintDeviceWriter & writer)
inline

Reads and writes the tiles

Definition at line 112 of file kis_datamanager.h.

112 {
113 return ACTUAL_DATAMGR::write(writer);
114 }

◆ writeBytes()

void KisDataManager::writeBytes ( const quint8 * data,
qint32 x,
qint32 y,
qint32 w,
qint32 h,
qint32 dataRowStride = -1 )
inline

Copy the bytes to the specified rect. w * h * pixelSize bytes will be read, whether the caller prepared them or not.

Definition at line 261 of file kis_datamanager.h.

264 {
265 ACTUAL_DATAMGR::writeBytes(data, x, y, w, h, dataRowStride);
266 }

◆ writePlanarBytes()

void KisDataManager::writePlanarBytes ( QVector< quint8 * > planes,
QVector< qint32 > channelsizes,
qint32 x,
qint32 y,
qint32 w,
qint32 h )
inline

Write the data in the separate arrays to the channels. If there are less vectors than channels, the remaining channels will not be copied. If any of the arrays points to 0, the channel in that location will not be touched. If the specified area is larger than the paint device, the paint device will be extended. There are no guards: if the area covers more pixels than there are bytes in the arrays, krita will happily fill your paint device with areas of memory you never wanted to be read. Krita may also crash.

Parameters
planesa vector with a byte array for every plane
channelsizesa vector with for every channel its size in bytes
xx coordinate of the top left corner
yy coordinate of the top left corner
wwidth
hheight

XXX: what about undo?

Definition at line 306 of file kis_datamanager.h.

306 {
307 ACTUAL_DATAMGR::writePlanarBytes(planes, channelsizes, x, y, w, h);
308 }

Friends And Related Symbol Documentation

◆ KisHLineIterator

friend class KisHLineIterator
friend

Definition at line 339 of file kis_datamanager.h.

◆ KisRectIterator

friend class KisRectIterator
friend

Definition at line 338 of file kis_datamanager.h.

◆ KisVLineIterator

friend class KisVLineIterator
friend

Definition at line 340 of file kis_datamanager.h.


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