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

#include <kis_tile_data_wrapper.h>

Public Types

enum  accessType { READ , WRITE }
 

Public Member Functions

quint8 * data () const
 
 KisTileDataWrapper (KisTiledDataManager *dm, qint32 x, qint32 y, enum KisTileDataWrapper::accessType type)
 
qint32 offset () const
 
KisTileSPtile ()
 
virtual ~KisTileDataWrapper ()
 

Private Attributes

qint32 m_offset
 
KisTileSP m_tile
 
KisTileDataWrapper::accessType m_type
 

Detailed Description

KisTileDataWrapper is a special object, that fetches the tile from the data manager according to the position, locks it and returns a pointer to the needed piece of data

Definition at line 16 of file kis_tile_data_wrapper.h.

Member Enumeration Documentation

◆ accessType

Enumerator
READ 
WRITE 

Definition at line 19 of file kis_tile_data_wrapper.h.

Constructor & Destructor Documentation

◆ KisTileDataWrapper()

KisTileDataWrapper::KisTileDataWrapper ( KisTiledDataManager * dm,
qint32 x,
qint32 y,
enum KisTileDataWrapper::accessType type )
inline

Fetches the tile which contains point (x, y) from the data manager dm with access type

Definition at line 28 of file kis_tile_data_wrapper.h.

31 {
32 const qint32 col = dm->xToCol(x);
33 const qint32 row = dm->yToRow(y);
34
35 /* FIXME: Always positive? */
36 const qint32 xInTile = x - col * KisTileData::WIDTH;
37 const qint32 yInTile = y - row * KisTileData::HEIGHT;
38
39 const qint32 pixelIndex = xInTile + yInTile * KisTileData::WIDTH;
40
41 KisTileSP tile = dm->getTile(col, row, type == WRITE);
42
43 m_tile = tile;
44 m_offset = pixelIndex * dm->pixelSize();
45
46 if (type == READ) {
48 }
49 else {
51 }
52
53 m_type = type;
54 }
KisTileDataWrapper::accessType m_type
static const qint32 HEIGHT
static const qint32 WIDTH
void lockForWrite()
Definition kis_tile.cc:221
void lockForRead() const
Definition kis_tile.cc:208
qint32 yToRow(qint32 y) const
qint32 xToCol(qint32 x) const
KisTileSP getTile(qint32 col, qint32 row, bool writable)

References KisTiledDataManager::getTile(), KisTileData::HEIGHT, KisTile::lockForRead(), KisTile::lockForWrite(), m_offset, m_tile, m_type, KisTiledDataManager::pixelSize(), READ, tile(), KisTileData::WIDTH, WRITE, KisTiledDataManager::xToCol(), and KisTiledDataManager::yToRow().

◆ ~KisTileDataWrapper()

virtual KisTileDataWrapper::~KisTileDataWrapper ( )
inlinevirtual

Definition at line 56 of file kis_tile_data_wrapper.h.

57 {
58 if (m_type == READ) {
60 } else {
62 }
63 }
void unlockForWrite()
Definition kis_tile.cc:264
void unlockForRead() const
Definition kis_tile.cc:275

References m_tile, m_type, READ, KisTile::unlockForRead(), and KisTile::unlockForWrite().

Member Function Documentation

◆ data()

quint8 * KisTileDataWrapper::data ( ) const
inline

Returns the pointer to the pixel, that was passed to the constructor. This points to the raw data of the tile, so you should think about the borders of the tile yourself. When (x,y) is the top-left corner of the tile, the pointer will lead to the beginning of the tile's chunk of memory.

Definition at line 90 of file kis_tile_data_wrapper.h.

91 {
92 return m_tile->data() + m_offset;
93 }
quint8 * data() const
Definition kis_tile.h:85

References KisTile::data(), m_offset, and m_tile.

◆ offset()

qint32 KisTileDataWrapper::offset ( ) const
inline

Returns the offset of the data in the tile's chunk of memory

See also
data()

Definition at line 70 of file kis_tile_data_wrapper.h.

71 {
72 return m_offset;
73 }

References m_offset.

◆ tile()

KisTileSP & KisTileDataWrapper::tile ( )
inline

Returns the fetched tile

Definition at line 78 of file kis_tile_data_wrapper.h.

79 {
80 return m_tile;
81 }

References m_tile.

Member Data Documentation

◆ m_offset

qint32 KisTileDataWrapper::m_offset
private

Definition at line 99 of file kis_tile_data_wrapper.h.

◆ m_tile

KisTileSP KisTileDataWrapper::m_tile
private

Definition at line 98 of file kis_tile_data_wrapper.h.

◆ m_type

KisTileDataWrapper::accessType KisTileDataWrapper::m_type
private

Definition at line 100 of file kis_tile_data_wrapper.h.


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