|
Krita Source Code Documentation
|
#include <kis_tile_data_interface.h>
Public Types | |
| enum | EnumTileDataState { NORMAL = 0 , COMPRESSED , SWAPPED } |
Public Member Functions | |
| bool | acquire () |
| int | age () const |
| void | allocateMemory () |
| void | blockSwapping () |
| KisTileData * | clone () |
| quint8 * | data () const |
| bool | deref () |
| bool | historical () const |
| KisTileData (qint32 pixelSize, const quint8 *defPixel, KisTileDataStore *store, bool checkFreeMemory=true) | |
| void | markOld () |
| bool | mementoed () const |
| qint32 | numUsers () const |
| quint32 | pixelSize () const |
| bool | ref () const |
| bool | release () |
| void | releaseMemory () |
| void | resetAge () |
| void | setData (const quint8 *data) |
| void | setMementoed (bool value) |
| void | setSwapChunk (KisChunk chunk) |
| KisChunk | swapChunk () const |
| void | unblockSwapping () |
| ~KisTileData () | |
Static Public Member Functions | |
| static void | releaseInternalPools () |
Static Public Attributes | |
| static const qint32 | HEIGHT = __TILE_DATA_HEIGHT |
| static const qint32 | WIDTH = __TILE_DATA_WIDTH |
Private Member Functions | |
| void | fillWithPixel (const quint8 *defPixel) |
| KisTileData (const KisTileData &rhs, bool checkFreeMemory=true) | |
Static Private Member Functions | |
| static quint8 * | allocateData (const qint32 pixelSize) |
| static void | freeData (quint8 *ptr, const qint32 pixelSize) |
Private Attributes | |
| int | m_age |
| KisTileDataCache | m_clonesStack |
| quint8 * | m_data |
| qint32 | m_mementoFlag |
| qint32 | m_pixelSize |
| QAtomicInt | m_refCount |
| EnumTileDataState | m_state |
| KisTileDataStore * | m_store |
| KisChunk | m_swapChunk |
| QReadWriteLock | m_swapLock |
| int | m_tileNumber = -1 |
| QAtomicInt | m_usersCount |
Static Private Attributes | |
| static SimpleCache | m_cache |
Friends | |
| class | KisLowMemoryTests |
| class | KisTile |
| class | KisTileDataPooler |
| class | KisTileDataPoolerTest |
| class | KisTileDataStore |
| class | KisTileDataStoreClockIterator |
| class | KisTileDataStoreIterator |
| class | KisTileDataStoreReverseIterator |
Stores actual tile's data
Definition at line 88 of file kis_tile_data_interface.h.
| Enumerator | |
|---|---|
| NORMAL | |
| COMPRESSED | |
| SWAPPED | |
Definition at line 99 of file kis_tile_data_interface.h.
| KisTileData::KisTileData | ( | qint32 | pixelSize, |
| const quint8 * | defPixel, | ||
| KisTileDataStore * | store, | ||
| bool | checkFreeMemory = true ) |
Definition at line 53 of file kis_tile_data.cc.
References allocateData(), KisTileDataStore::checkFreeMemory(), fillWithPixel(), m_data, m_pixelSize, and m_store.
|
private |
Duplicating tiledata
NOTE: the memory allocated by the pooler for clones is not counted by the store in memoryHardLimit. The pooler has it's own slice of memory and keeps track of the its size itself. So we should be able to disable the memory check with checkFreeMemory, otherwise, there is a deadlock.
Definition at line 82 of file kis_tile_data.cc.
References allocateData(), KisTileDataStore::checkFreeMemory(), data(), HEIGHT, m_data, m_pixelSize, m_store, and WIDTH.
| KisTileData::~KisTileData | ( | ) |
Definition at line 100 of file kis_tile_data.cc.
References releaseMemory().
|
inline |
Increments usersCount of a TD and refs shared pointer counter Used by KisTile for COW
We need to ensure the clones in the stack are consistent with the data. When we have a single user, the most probably, the clone has already started stinking. So just clean it up.
Definition at line 35 of file kis_tile_data.h.
References clone(), m_clonesStack, m_usersCount, KisLocklessStack< T >::pop(), and ref().
|
inline |
Controlling methods for setting 'age' marks
Definition at line 110 of file kis_tile_data.h.
References m_age.
|
staticprivate |
Definition at line 135 of file kis_tile_data.cc.
References HEIGHT, m_cache, pixelSize(), SimpleCache::pop(), and WIDTH.
| void KisTileData::allocateMemory | ( | ) |
Used for swapping purposes only. Allocates memory for the tile data after it has been freed in releaseMemory(). NOTE: the new data can be not-initialized and you must fill it yourself!
Definition at line 129 of file kis_tile_data.cc.
References allocateData(), m_data, and m_pixelSize.
|
inline |
Control the access of swapper to the tile data
Definition at line 79 of file kis_tile_data.h.
References KisTileDataStore::ensureTileDataLoaded(), m_data, m_store, m_swapLock, and resetAge().
|
inline |
Creates a clone of the tile data safely. It will try to use the cached clones.
Definition at line 75 of file kis_tile_data.h.
References KisTileDataStore::duplicateTileData(), and m_store.
|
inline |
Information about data stored
Some methods of KisTileData have a cyclic dependency to the KisTileDataStore, so we've moved the class declaration to a separate file, that will be included by the store.
Definition at line 21 of file kis_tile_data.h.
References m_data.
|
inline |
Only refs shared pointer counter. Used only by KisMementoManager without consideration of COW.
Definition at line 65 of file kis_tile_data.h.
References KisTileDataStore::freeTileData(), m_refCount, and m_store.
|
private |
Definition at line 105 of file kis_tile_data.cc.
References HEIGHT, m_data, m_pixelSize, and WIDTH.
|
staticprivate |
Definition at line 156 of file kis_tile_data.cc.
References m_cache, pixelSize(), and SimpleCache::push().
|
inline |
Convenience method. Returns true iff the tile data is linked to information only and therefore can be swapped out easily.
Effectively equivalent to: (mementoed() && numUsers() <= 1)
Definition at line 106 of file kis_tile_data.h.
References mementoed(), and numUsers().
|
inline |
|
inline |
Show whether a tile data is a part of history
Definition at line 99 of file kis_tile_data.h.
References m_mementoFlag.
|
inline |
Returns number of tiles (or memento items), referencing the tile data.
Definition at line 120 of file kis_tile_data.h.
References m_usersCount.
|
inline |
Definition at line 31 of file kis_tile_data.h.
References m_pixelSize.
|
inline |
Only refs shared pointer counter. Used only by KisMementoManager without consideration of COW.
Definition at line 61 of file kis_tile_data.h.
References m_refCount.
|
inline |
Decrements usersCount of a TD and derefs shared pointer counter Used by KisTile for COW
Definition at line 55 of file kis_tile_data.h.
References deref(), and m_usersCount.
|
static |
Releases internal pools, which keep blobs where the tiles are stored. The point is that we don't allocate the tiles from glibc directly, but use pools (implemented via boost) to allocate bigger chunks. This method should be called when one knows that we have just free'd quite a lot of memory and we won't need it anymore. E.g. when a document has been closed.
Definition at line 179 of file kis_tile_data.cc.
References allocateData(), KisTileDataStore::beginIteration(), SimpleCache::clear(), clone(), dbgKrita, KisTileDataStore::endIteration(), KisTileDataStoreIterator::hasNext(), HEIGHT, KisTileDataStore::instance(), m_cache, m_clonesStack, m_data, m_pixelSize, m_swapLock, KisTileDataStoreIterator::next(), KisTileDataStore::numTilesInMemory(), KisLocklessStack< T >::pop(), void(), warnKrita, and WIDTH.
| void KisTileData::releaseMemory | ( | ) |
Used for swapping purposes only. Frees the memory occupied by the tile data. (the caller must save the data beforehand)
Definition at line 114 of file kis_tile_data.cc.
References clone(), freeData(), KisLocklessStack< T >::isEmpty(), m_clonesStack, m_data, m_pixelSize, and KisLocklessStack< T >::pop().
|
inline |
|
inline |
Definition at line 26 of file kis_tile_data.h.
References data(), HEIGHT, m_data, m_pixelSize, and WIDTH.
|
inline |
Definition at line 95 of file kis_tile_data.h.
References m_swapChunk.
|
inline |
The position of the tile data in a swap file
Definition at line 92 of file kis_tile_data.h.
References m_swapChunk.
|
inline |
Definition at line 88 of file kis_tile_data.h.
References m_swapLock.
|
friend |
Definition at line 284 of file kis_tile_data_interface.h.
|
friend |
Definition at line 227 of file kis_tile_data_interface.h.
|
friend |
Definition at line 217 of file kis_tile_data_interface.h.
|
friend |
Definition at line 218 of file kis_tile_data_interface.h.
|
friend |
Definition at line 228 of file kis_tile_data_interface.h.
|
friend |
Definition at line 232 of file kis_tile_data_interface.h.
|
friend |
Definition at line 230 of file kis_tile_data_interface.h.
|
friend |
Definition at line 231 of file kis_tile_data_interface.h.
|
static |
Definition at line 312 of file kis_tile_data_interface.h.
|
private |
Counts up time after last access to the tile data. 0 - recently accessed 1+ - not recently accessed
Definition at line 271 of file kis_tile_data_interface.h.
|
staticprivate |
Definition at line 308 of file kis_tile_data_interface.h.
|
private |
A list of pre-duplicated tiledatas. To make a COW faster, KisTileDataPooler thread duplicates a tile beforehand and stores clones here, in this stack
Definition at line 224 of file kis_tile_data_interface.h.
|
mutableprivate |
FIXME: We should be able to work in const environment even when actual data is swapped out to disk
Definition at line 290 of file kis_tile_data_interface.h.
|
private |
The flag is set by KisMementoItem to show this tile data is going down in history.
(m_mementoFlag && m_usersCount == 1) means that the only user of tile data is a memento manager.
Definition at line 263 of file kis_tile_data_interface.h.
|
private |
Definition at line 304 of file kis_tile_data_interface.h.
|
mutableprivate |
Shared pointer counter
Definition at line 301 of file kis_tile_data_interface.h.
|
mutableprivate |
The state of the tile. Filled in by tileDataStore and checked in KisTile::acquireFor* see also: comment for @m_data
Definition at line 240 of file kis_tile_data_interface.h.
|
private |
Definition at line 307 of file kis_tile_data_interface.h.
|
private |
The chunk of the swap file, that corresponds to this tile data. Used by KisSwappedDataStore.
Definition at line 253 of file kis_tile_data_interface.h.
|
private |
The primitive for controlling swapping of the tile. lockForRead() - used by regular threads to ensure swapper won't touch this tile data. tryLockForWrite() - used by swapper to check no-one reads this tile data
Definition at line 281 of file kis_tile_data_interface.h.
|
private |
Iterator that points to a position in the list where the tile data is stored
Definition at line 246 of file kis_tile_data_interface.h.
|
mutableprivate |
How many tiles/mementoes use this tiledata through COW?
Definition at line 296 of file kis_tile_data_interface.h.
|
static |
Definition at line 311 of file kis_tile_data_interface.h.