Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPaintDevice::Private Struct Reference

Classes

class  DeviceChangeColorSpaceCommand
 
class  DeviceChangeProfileCommand
 
class  FrameInsertionCommand
 
class  KisPaintDeviceStrategy
 
class  KisPaintDeviceWrappedStrategy
 
struct  LodDataStructImpl
 
struct  StrategyPolicy
 

Public Member Functions

bool assignProfile (const KoColorProfile *profile, KUndo2Command *parentCommand)
 
KisPaintDeviceCachecache ()
 
KisIteratorCompleteListenercacheInvalidator ()
 
void cloneAllDataObjects (Private *rhs, bool copyFrames)
 
const KoColorSpacecolorSpace () const
 
void convertColorSpace (const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags, KUndo2Command *parentCommand, KoUpdater *progressUpdater)
 
KUndo2CommandcreateChangeInterstrokeDataCommand (KisInterstrokeDataSP value)
 
int createFrame (bool copy, int copySrc, const QPoint &offset, KUndo2Command *parentCommand)
 
LodDataStructcreateLodDataStruct (int lod)
 
int currentFrameId () const
 
KisPaintDeviceStrategycurrentStrategy ()
 
KisDataManagerSP dataManager () const
 
void deleteFrame (int frameID, KUndo2Command *parentCommand)
 
void estimateMemoryStats (qint64 &imageData, qint64 &temporaryData, qint64 &lodData) const
 
bool fastBitBltPossible (KisPaintDeviceSP src)
 
QRect frameBounds (int frameId)
 
KisDataManagerSP frameDataManager (int frameId) const
 
KoColor frameDefaultPixel (int frameId) const
 
const QList< int > frameIds () const
 
QPoint frameOffset (int frameId) const
 
void generateLodCloneDevice (KisPaintDeviceSP dst, const QRect &originalRect, int lod)
 
int getNextFrameId ()
 
void init (const KoColorSpace *cs, const quint8 *defaultPixel)
 
KisInterstrokeDataSP interstrokeData () const
 
void invalidateFrameCache (int frameId)
 
void prepareClone (KisPaintDeviceSP src)
 
 Private (KisPaintDevice *paintDevice)
 
bool readFrame (QIODevice *stream, int frameId)
 
KisRegion regionForLodSyncing () const
 
KUndo2CommandreincarnateWithDetachedHistory (bool copyContent)
 
void setFrameDefaultPixel (const KoColor &defPixel, int frameId)
 
void setFrameOffset (int frameId, const QPoint &offset)
 
void setX (qint32 x)
 
void setY (qint32 y)
 
void testingFetchLodDevice (KisPaintDeviceSP targetDevice)
 
void updateLodDataManager (KisDataManager *srcDataManager, KisDataManager *dstDataManager, const QPoint &srcOffset, const QPoint &dstOffset, const QRect &originalRect, int lod)
 
void updateLodDataStruct (LodDataStruct *dst, const QRect &srcRect)
 
void uploadFrame (int dstFrameId, KisPaintDeviceSP srcDevice)
 
void uploadFrame (int srcFrameId, int dstFrameId, KisPaintDeviceSP srcDevice)
 
void uploadFrameData (DataSP srcData, DataSP dstData)
 
void uploadLodDataStruct (LodDataStruct *dst)
 
bool writeFrame (KisPaintDeviceWriter &store, int frameId)
 
void writeFrameToDevice (int frameId, KisPaintDeviceSP targetDevice)
 
qint32 x () const
 
qint32 y () const
 
 ~Private ()
 

Public Attributes

QScopedPointer< KisPaintDeviceStrategybasicStrategy
 
QScopedPointer< KisRasterKeyframeChannelcontentChannel
 
KisDefaultBoundsBaseSP defaultBounds
 
QScopedPointer< KisPaintDeviceFramesInterfaceframesInterface
 
bool isProjectionDevice
 
QMutex m_wrappedStrategyMutex
 
KisNodeWSP parent
 
KisPaintDeviceq
 
bool supportsWrapAroundMode
 
QScopedPointer< KisPaintDeviceWrappedStrategywrappedStrategy
 

Static Public Attributes

static const KisDefaultBoundsSP transitionalDefaultBounds = new KisDefaultBounds()
 

Private Types

typedef KisPaintDeviceData Data
 
typedef QSharedPointer< DataDataSP
 
typedef QHash< int, DataSPFramesHash
 
typedef KisSequentialIteratorBase< ReadOnlyIteratorPolicy< StrategyPolicy >, StrategyPolicyInternalSequentialConstIterator
 
typedef KisSequentialIteratorBase< WritableIteratorPolicy< StrategyPolicy >, StrategyPolicyInternalSequentialIterator
 

Private Member Functions

QList< Data * > allDataObjects () const
 
DatacurrentData () const
 
DataSP currentFrameData () const
 
DatacurrentNonLodData () const
 
void ensureLodDataPresent () const
 
qint64 estimateDataSize (Data *data) const
 
bool fastBitBltPossibleImpl (Data *srcData)
 
void prepareCloneImpl (KisPaintDeviceSP src, Data *srcData)
 
void transferFromData (Data *data, KisPaintDeviceSP targetDevice)
 

Private Attributes

DataSP m_data
 
QMutex m_dataSwitchLock
 
QScopedPointer< Datam_externalFrameData
 
FramesHash m_frames
 
QScopedPointer< Datam_lodData
 
int m_nextFreeFrameId
 
struct Q_DECL_HIDDEN StrategyPolicy
 

Friends

class KisPaintDeviceFramesInterface
 

Detailed Description

Definition at line 67 of file kis_paint_device.cc.

Member Typedef Documentation

◆ Data

Definition at line 230 of file kis_paint_device.cc.

◆ DataSP

Definition at line 231 of file kis_paint_device.cc.

◆ FramesHash

typedef QHash<int, DataSP> KisPaintDevice::Private::FramesHash
private

Definition at line 232 of file kis_paint_device.cc.

◆ InternalSequentialConstIterator

◆ InternalSequentialIterator

Constructor & Destructor Documentation

◆ Private()

KisPaintDevice::Private::Private ( KisPaintDevice * paintDevice)

Definition at line 608 of file kis_paint_device.cc.

609 : q(paintDevice),
610 basicStrategy(new KisPaintDeviceStrategy(paintDevice, this)),
611 isProjectionDevice(false),
613 m_data(new Data(paintDevice)),
615{
616}
QScopedPointer< KisPaintDeviceStrategy > basicStrategy

◆ ~Private()

KisPaintDevice::Private::~Private ( )

Definition at line 618 of file kis_paint_device.cc.

619{
620 contentChannel.reset();
621 m_frames.clear();
622}
QScopedPointer< KisRasterKeyframeChannel > contentChannel

References KisPaintDevice::clear().

Member Function Documentation

◆ allDataObjects()

QList< Data * > KisPaintDevice::Private::allDataObjects ( ) const
inlineprivate

Definition at line 568 of file kis_paint_device.cc.

569 {
570 QList<Data*> dataObjects;
571
572 if (m_frames.isEmpty()) {
573 dataObjects << m_data.data();
574 }
575 dataObjects << m_lodData.data();
576 dataObjects << m_externalFrameData.data();
577
578 Q_FOREACH (DataSP value, m_frames.values()) {
579 dataObjects << value.data();
580 }
581
582 return dataObjects;
583 }
float value(const T *src, size_t ch)
QScopedPointer< Data > m_externalFrameData
QScopedPointer< Data > m_lodData
QSharedPointer< Data > DataSP

References m_data, m_externalFrameData, m_frames, m_lodData, and value().

◆ assignProfile()

bool KisPaintDevice::Private::assignProfile ( const KoColorProfile * profile,
KUndo2Command * parentCommand )

Definition at line 1002 of file kis_paint_device.cc.

1003{
1004 if (!profile) return false;
1005
1006 const KoColorSpace *dstColorSpace =
1007 KoColorSpaceRegistry::instance()->colorSpace(colorSpace()->colorModelId().id(), colorSpace()->colorDepthId().id(), profile);
1008 if (!dstColorSpace) return false;
1009
1010 KUndo2Command *mainCommand =
1011 parentCommand ? new DeviceChangeColorSpaceCommand(q, parentCommand) : 0;
1012
1013
1014 QList<Data*> dataObjects = allDataObjects();
1015 Q_FOREACH (Data *data, dataObjects) {
1016 if (!data) continue;
1017 data->assignColorSpace(dstColorSpace, mainCommand);
1018 }
1020
1021 // no undo information is provided here
1022 return true;
1023}
const KoColorSpace * colorSpace() const
QList< Data * > allDataObjects() const
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
static KoColorSpaceRegistry * instance()

References KisPaintDeviceData::assignColorSpace(), KisPaintDevice::colorSpace(), KoColorSpaceRegistry::colorSpace(), KisPaintDevice::emitProfileChanged(), and KoColorSpaceRegistry::instance().

◆ cache()

KisPaintDeviceCache * KisPaintDevice::Private::cache ( )
inline

Definition at line 137 of file kis_paint_device.cc.

138 {
139 return currentData()->cache();
140 }
ALWAYS_INLINE KisPaintDeviceCache * cache()

References KisPaintDeviceData::cache(), and currentData().

◆ cacheInvalidator()

KisIteratorCompleteListener * KisPaintDevice::Private::cacheInvalidator ( )
inline

Definition at line 142 of file kis_paint_device.cc.

142 {
143 return currentData()->cacheInvalidator();
144 }
ALWAYS_INLINE KisIteratorCompleteListener * cacheInvalidator()

References KisPaintDeviceData::cacheInvalidator(), and currentData().

◆ cloneAllDataObjects()

void KisPaintDevice::Private::cloneAllDataObjects ( Private * rhs,
bool copyFrames )
inline

Definition at line 154 of file kis_paint_device.cc.

155 {
156
157 m_lodData.reset();
158 m_externalFrameData.reset();
159
160 if (!m_frames.isEmpty()) {
161 m_frames.clear();
162 }
163
164 if (!copyFrames) {
165 if (m_data) {
166 m_data->prepareClone(rhs->currentNonLodData(), true);
167 } else {
168 m_data = toQShared(new KisPaintDeviceData(q, rhs->currentNonLodData(), true));
169 }
170 } else {
171 if (m_data && !rhs->m_data) {
172 m_data.clear();
173 } else if (!m_data && rhs->m_data) {
174 m_data = toQShared(new KisPaintDeviceData(q, rhs->m_data.data(), true));
175 } else if (m_data && rhs->m_data) {
176 m_data->prepareClone(rhs->m_data.data(), true);
177 }
178
179 if (!rhs->m_frames.isEmpty()) {
180 FramesHash::const_iterator it = rhs->m_frames.constBegin();
181 FramesHash::const_iterator end = rhs->m_frames.constEnd();
182
183 for (; it != end; ++it) {
184 DataSP data = toQShared(new KisPaintDeviceData(q, it.value().data(), true));
185 m_frames.insert(it.key(), data);
186 }
187 }
188 m_nextFreeFrameId = rhs->m_nextFreeFrameId;
189 }
190
191 if (rhs->m_lodData) {
192 m_lodData.reset(new KisPaintDeviceData(q, rhs->m_lodData.data(), true));
193 }
194 }
QSharedPointer< T > toQShared(T *ptr)

◆ colorSpace()

const KoColorSpace * KisPaintDevice::Private::colorSpace ( ) const
inline

Definition at line 111 of file kis_paint_device.cc.

112 {
113 return currentData()->colorSpace();
114 }
ALWAYS_INLINE const KoColorSpace * colorSpace() const

References KisPaintDeviceData::colorSpace(), and currentData().

◆ convertColorSpace()

void KisPaintDevice::Private::convertColorSpace ( const KoColorSpace * dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags,
KUndo2Command * parentCommand,
KoUpdater * progressUpdater )

Definition at line 981 of file kis_paint_device.cc.

986{
987 QList<Data*> dataObjects = allDataObjects();
988 if (dataObjects.isEmpty()) return;
989
990 KUndo2Command *mainCommand =
991 parentCommand ? new DeviceChangeColorSpaceCommand(q, parentCommand) : 0;
992
993 Q_FOREACH (Data *data, dataObjects) {
994 if (!data) continue;
995
996 data->convertDataColorSpace(dstColorSpace, renderingIntent, conversionFlags, mainCommand, progressUpdater);
997 }
998
1000}

References KisPaintDeviceData::convertDataColorSpace(), and KisPaintDevice::emitColorSpaceChanged().

◆ createChangeInterstrokeDataCommand()

KUndo2Command * KisPaintDevice::Private::createChangeInterstrokeDataCommand ( KisInterstrokeDataSP value)
inline

Definition at line 150 of file kis_paint_device.cc.

150 {
152 }
ALWAYS_INLINE KUndo2Command * createChangeInterstrokeDataCommand(KisInterstrokeDataSP value)

◆ createFrame()

int KisPaintDevice::Private::createFrame ( bool copy,
int copySrc,
const QPoint & offset,
KUndo2Command * parentCommand )
inline

Here we move the contents of the paint device to the new frame and clear m_data to make the "background" for the areas where there is no frame at all.

Definition at line 284 of file kis_paint_device.cc.

285 {
286 DataSP data;
287 bool initialFrame = false;
288
289 if (m_frames.isEmpty()) {
295 data = toQShared(new Data(q, m_data.data(), true));
296 m_data->dataManager()->clear();
297 m_data->cache()->invalidate();
298 initialFrame = true;
299
300 } else if (copy) {
301 DataSP srcData = m_frames[copySrc];
302 data = toQShared(new Data(q, srcData.data(), true));
303 } else {
304 DataSP srcData = m_frames.begin().value();
305 data = toQShared(new Data(q, srcData.data(), false));
306 }
307
308 if (!initialFrame && !copy) {
309 data->setX(offset.x());
310 data->setY(offset.y());
311 }
312
313 int frameId = getNextFrameId();
314
315 if (parentCommand) {
316 KUndo2Command *cmd =
317 new FrameInsertionCommand(&m_frames,
318 data,
319 frameId, true,
320 parentCommand);
321
322 cmd->redo();
323 } else {
324 m_frames.insert(frameId, data);
325 }
326
327 return frameId;
328 }
virtual void redo()
QPoint offset() const

References getNextFrameId(), m_data, m_frames, KisPaintDevice::offset(), q, KUndo2Command::redo(), and toQShared().

◆ createLodDataStruct()

KisPaintDevice::LodDataStruct * KisPaintDevice::Private::createLodDataStruct ( int lod)

We compare color spaces as pure pointers, because they must be exactly the same, since they come from the common source.

Definition at line 688 of file kis_paint_device.cc.

689{
691
692 Data *srcData = currentNonLodData();
693
694 Data *lodData = new Data(q, srcData, false);
695 LodDataStruct *lodStruct = new LodDataStructImpl(lodData);
696
697 int expectedX = KisLodTransform::coordToLodCoord(srcData->x(), newLod);
698 int expectedY = KisLodTransform::coordToLodCoord(srcData->y(), newLod);
699
704 if (lodData->levelOfDetail() != newLod ||
705 lodData->colorSpace() != srcData->colorSpace() ||
706 lodData->x() != expectedX ||
707 lodData->y() != expectedY) {
708
709
710 lodData->prepareClone(srcData);
711
712 lodData->setLevelOfDetail(newLod);
713 lodData->setX(expectedX);
714 lodData->setY(expectedY);
715
716 // FIXME: different kind of synchronization
717 }
718
719 lodData->cache()->invalidate();
720
721 return lodStruct;
722}
static int coordToLodCoord(int x, int lod)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References KisPaintDeviceData::cache(), KisPaintDeviceData::colorSpace(), KisLodTransformBase::coordToLodCoord(), KisPaintDeviceCache::invalidate(), KIS_SAFE_ASSERT_RECOVER_NOOP, KisPaintDeviceData::levelOfDetail(), KisPaintDeviceData::prepareClone(), KisPaintDeviceData::setLevelOfDetail(), KisPaintDeviceData::setX(), KisPaintDeviceData::setY(), KisPaintDeviceData::x(), and KisPaintDeviceData::y().

◆ currentData()

Data * KisPaintDevice::Private::currentData ( ) const
inlineprivate

Definition at line 522 of file kis_paint_device.cc.

523 {
524 Data *data;
525
528 data = m_lodData.data();
529 } else {
530 data = currentNonLodData();
531 }
532
533 return data;
534 }
virtual int currentLevelOfDetail() const =0
KisDefaultBoundsBaseSP defaultBounds

References KisDefaultBoundsBase::currentLevelOfDetail(), currentNonLodData(), defaultBounds, ensureLodDataPresent(), and m_lodData.

◆ currentFrameData()

DataSP KisPaintDevice::Private::currentFrameData ( ) const
inlineprivate

Definition at line 466 of file kis_paint_device.cc.

467 {
468 DataSP data;
469
470 const int vFramesCount = contentChannel->keyframeCount();
471
472 if (vFramesCount >= 1) {
474 if (!keyframe || keyframe->frameID() < 0) {
475 return m_data;
476 }
477
478 const int frameID = keyframe->frameID();
479 KIS_ASSERT_RECOVER(m_frames.contains(frameID)) {
480 return m_data;
481 }
482
483 data = m_frames[frameID];
484 } else {
485 data = m_data;
486 }
487
488 return data;
489 }
virtual int currentTime() const =0
The KisRasterKeyframe class is a concrete subclass of KisKeyframe that wraps a physical raster image ...
#define KIS_ASSERT_RECOVER(cond)
Definition kis_assert.h:55

References contentChannel, KisDefaultBoundsBase::currentTime(), defaultBounds, KIS_ASSERT_RECOVER, m_data, and m_frames.

◆ currentFrameId()

int KisPaintDevice::Private::currentFrameId ( ) const
inline

◆ currentNonLodData()

Data * KisPaintDevice::Private::currentNonLodData ( ) const
inlineprivate

Definition at line 491 of file kis_paint_device.cc.

492 {
493 Data *data = m_data.data();
494
495 if (contentChannel) {
496 data = currentFrameData().data();
498 if (!m_externalFrameData) {
499 QMutexLocker l(&m_dataSwitchLock);
500 if (!m_externalFrameData) {
501 m_externalFrameData.reset(new Data(q, m_data.data(), false));
502 }
503 }
504 data = m_externalFrameData.data();
505 }
506
507 return data;
508 }
virtual bool externalFrameActive() const =0

References contentChannel, currentFrameData(), defaultBounds, KisDefaultBoundsBase::externalFrameActive(), isProjectionDevice, m_data, m_dataSwitchLock, m_externalFrameData, and q.

◆ currentStrategy()

KisPaintDevice::Private::KisPaintDeviceStrategy * KisPaintDevice::Private::currentStrategy ( )

Definition at line 624 of file kis_paint_device.cc.

625{
627 return basicStrategy.data();
628 }
629
630 const QRect wrapRect = defaultBounds->imageBorderRect();
631
632 if (!wrappedStrategy || wrappedStrategy->wrapRect() != wrapRect) {
633 QMutexLocker locker(&m_wrappedStrategyMutex);
634
635 if (!wrappedStrategy) {
636 wrappedStrategy.reset(new KisPaintDeviceWrappedStrategy(wrapRect, q, this));
637 } else if (wrappedStrategy->wrapRect() != wrapRect) {
638 wrappedStrategy->setWrapRect(wrapRect);
639 }
640 }
641
642 return wrappedStrategy.data();
643}
virtual bool wrapAroundMode() const =0
virtual QRect imageBorderRect() const
QScopedPointer< KisPaintDeviceWrappedStrategy > wrappedStrategy

References KisPaintDevice::defaultBounds(), KisDefaultBoundsBase::imageBorderRect(), and KisDefaultBoundsBase::wrapAroundMode().

◆ dataManager()

KisDataManagerSP KisPaintDevice::Private::dataManager ( ) const
inline

Definition at line 115 of file kis_paint_device.cc.

116 {
117 return currentData()->dataManager();
118 }
ALWAYS_INLINE KisDataManagerSP dataManager() const

References currentData(), and KisPaintDeviceData::dataManager().

◆ deleteFrame()

void KisPaintDevice::Private::deleteFrame ( int frameID,
KUndo2Command * parentCommand )
inline

Definition at line 330 of file kis_paint_device.cc.

331 {
332 KIS_SAFE_ASSERT_RECOVER_RETURN(m_frames.contains(frameID));
333 DataSP deletedData = m_frames[frameID];
334
335 if(parentCommand) {
336 KUndo2Command *cmd =
337 new FrameInsertionCommand(&m_frames,
338 deletedData,
339 frameID, false,
340 parentCommand);
341 cmd->redo();
342 } else {
343 m_frames.take(frameID);
344 }
345 }
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References KIS_SAFE_ASSERT_RECOVER_RETURN, m_frames, and KUndo2Command::redo().

◆ ensureLodDataPresent()

void KisPaintDevice::Private::ensureLodDataPresent ( ) const
inlineprivate

Definition at line 510 of file kis_paint_device.cc.

511 {
512 if (!m_lodData) {
513 Data *srcData = currentNonLodData();
514
515 QMutexLocker l(&m_dataSwitchLock);
516 if (!m_lodData) {
517 m_lodData.reset(new Data(q, srcData, false));
518 }
519 }
520 }

References currentNonLodData(), m_dataSwitchLock, m_lodData, and q.

◆ estimateDataSize()

qint64 KisPaintDevice::Private::estimateDataSize ( Data * data) const
inlineprivate

Definition at line 434 of file kis_paint_device.cc.

434 {
435 const QRect &rc = data->dataManager()->extent();
436 return qint64(rc.width()) * rc.height() * data->colorSpace()->pixelSize();
437 }

References KisPaintDeviceData::colorSpace(), KisPaintDeviceData::dataManager(), KisDataManager::extent(), and KoColorSpace::pixelSize().

◆ estimateMemoryStats()

void KisPaintDevice::Private::estimateMemoryStats ( qint64 & imageData,
qint64 & temporaryData,
qint64 & lodData ) const
inline

Definition at line 441 of file kis_paint_device.cc.

441 {
442 imageData = 0;
443 temporaryData = 0;
444 lodData = 0;
445
446 if (m_data) {
447 imageData += estimateDataSize(m_data.data());
448 }
449
450 if (m_lodData) {
451 lodData += estimateDataSize(m_lodData.data());
452 }
453
455 temporaryData += estimateDataSize(m_externalFrameData.data());
456 }
457
458 Q_FOREACH (DataSP value, m_frames.values()) {
459 imageData += estimateDataSize(value.data());
460 }
461 }
qint64 estimateDataSize(Data *data) const

References estimateDataSize(), m_data, m_externalFrameData, m_frames, m_lodData, and value().

◆ fastBitBltPossible()

bool KisPaintDevice::Private::fastBitBltPossible ( KisPaintDeviceSP src)
inline

Definition at line 202 of file kis_paint_device.cc.

203 {
204 return fastBitBltPossibleImpl(src->m_d->currentData());
205 }
bool fastBitBltPossibleImpl(Data *srcData)

References fastBitBltPossibleImpl().

◆ fastBitBltPossibleImpl()

bool KisPaintDevice::Private::fastBitBltPossibleImpl ( Data * srcData)
inlineprivate

Definition at line 562 of file kis_paint_device.cc.

563 {
564 return x() == srcData->x() && y() == srcData->y() &&
565 *colorSpace() == *srcData->colorSpace();
566 }

References colorSpace(), KisPaintDeviceData::colorSpace(), x(), KisPaintDeviceData::x(), y(), and KisPaintDeviceData::y().

◆ frameBounds()

QRect KisPaintDevice::Private::frameBounds ( int frameId)
inline

Definition at line 347 of file kis_paint_device.cc.

348 {
349 DataSP data = m_frames[frameId];
350
351 QRect extent = data->dataManager()->extent();
352 extent.translate(data->x(), data->y());
353
354 quint8 defaultOpacity = data->colorSpace()->opacityU8(data->dataManager()->defaultPixel());
355
356 if (defaultOpacity != OPACITY_TRANSPARENT_U8) {
358 }
359
360 return extent;
361 }
const quint8 OPACITY_TRANSPARENT_U8
virtual QRect bounds() const =0
QRect extent() const

References KisDefaultBoundsBase::bounds(), defaultBounds, KisPaintDevice::extent(), m_frames, and OPACITY_TRANSPARENT_U8.

◆ frameDataManager()

KisDataManagerSP KisPaintDevice::Private::frameDataManager ( int frameId) const
inline

Definition at line 217 of file kis_paint_device.cc.

218 {
219 DataSP data = m_frames[frameId];
220 return data->dataManager();
221 }

References m_frames.

◆ frameDefaultPixel()

KoColor KisPaintDevice::Private::frameDefaultPixel ( int frameId) const
inline

Definition at line 406 of file kis_paint_device.cc.

407 {
408 DataSP data = m_frames[frameId];
409 return KoColor(data->dataManager()->defaultPixel(),
410 data->colorSpace());
411 }

References m_frames.

◆ frameIds()

const QList< int > KisPaintDevice::Private::frameIds ( ) const
inline

Definition at line 377 of file kis_paint_device.cc.

378 {
379 return m_frames.keys();
380 }

References m_frames.

◆ frameOffset()

QPoint KisPaintDevice::Private::frameOffset ( int frameId) const
inline

Definition at line 363 of file kis_paint_device.cc.

364 {
365 DataSP data = m_frames[frameId];
366 return QPoint(data->x(), data->y());
367 }

References m_frames.

◆ generateLodCloneDevice()

void KisPaintDevice::Private::generateLodCloneDevice ( KisPaintDeviceSP dst,
const QRect & originalRect,
int lod )

Definition at line 824 of file kis_paint_device.cc.

825{
827
828 Data *srcData = currentNonLodData();
829 updateLodDataManager(srcData->dataManager().data(), dst->dataManager().data(),
830 QPoint(srcData->x(), srcData->y()),
831 QPoint(dst->x(), dst->y()),
832 originalRect, lod);
833}
KisDataManagerSP dataManager() const
bool fastBitBltPossible(KisPaintDeviceSP src)
void updateLodDataManager(KisDataManager *srcDataManager, KisDataManager *dstDataManager, const QPoint &srcOffset, const QPoint &dstOffset, const QRect &originalRect, int lod)

References KisSharedPtr< T >::data(), KisPaintDevice::dataManager(), KisPaintDeviceData::dataManager(), KisPaintDevice::fastBitBltPossible(), KIS_SAFE_ASSERT_RECOVER_RETURN, KisPaintDevice::x(), KisPaintDeviceData::x(), KisPaintDevice::y(), and KisPaintDeviceData::y().

◆ getNextFrameId()

int KisPaintDevice::Private::getNextFrameId ( )
inline

Definition at line 276 of file kis_paint_device.cc.

276 {
277 int frameId = 0;
278 while (m_frames.contains(frameId = m_nextFreeFrameId++));
279 KIS_SAFE_ASSERT_RECOVER_NOOP(!m_frames.contains(frameId));
280
281 return frameId;
282 }

References KIS_SAFE_ASSERT_RECOVER_NOOP, m_frames, and m_nextFreeFrameId.

◆ init()

void KisPaintDevice::Private::init ( const KoColorSpace * cs,
const quint8 * defaultPixel )

Definition at line 1032 of file kis_paint_device.cc.

1033{
1034 QList<Data*> dataObjects = allDataObjects();
1035 Q_FOREACH (Data *data, dataObjects) {
1036 if (!data) continue;
1037
1039 data->init(cs, dataManager);
1040 }
1041}
KoColor defaultPixel() const
virtual quint32 pixelSize() const =0
KisDataManagerSP dataManager() const

References KisPaintDevice::dataManager(), KisPaintDevice::defaultPixel(), KisPaintDeviceData::init(), and KoColorSpace::pixelSize().

◆ interstrokeData()

KisInterstrokeDataSP KisPaintDevice::Private::interstrokeData ( ) const
inline

Definition at line 146 of file kis_paint_device.cc.

146 {
147 return currentData()->interstrokeData();
148 }
ALWAYS_INLINE KisInterstrokeDataSP interstrokeData() const

References currentData(), and KisPaintDeviceData::interstrokeData().

◆ invalidateFrameCache()

void KisPaintDevice::Private::invalidateFrameCache ( int frameId)
inline

Definition at line 223 of file kis_paint_device.cc.

224 {
225 DataSP data = m_frames[frameId];
226 return data->cache()->invalidate();
227 }

References m_frames.

◆ prepareClone()

void KisPaintDevice::Private::prepareClone ( KisPaintDeviceSP src)
inline

Definition at line 196 of file kis_paint_device.cc.

197 {
198 prepareCloneImpl(src, src->m_d->currentData());
200 }
void prepareCloneImpl(KisPaintDeviceSP src, Data *srcData)

◆ prepareCloneImpl()

void KisPaintDevice::Private::prepareCloneImpl ( KisPaintDeviceSP src,
Data * srcData )
inlineprivate

The result of currentData() depends on the current level of detail and animation frame index. So we should first connect the device to the new default bounds object, and only after that ask currentData() to start cloning.

Default pixel must be updated after the color space of the device has been adjusted in prepareClone(). Otherwise, colorSpace() of the resulting KoColor object will be incorrect.

Definition at line 536 of file kis_paint_device.cc.

537 {
545 q->setDefaultBounds(src->defaultBounds());
546 q->setSupportsWraparoundMode(src->supportsWraproundMode());
547
548 currentData()->prepareClone(srcData);
549
550
557 KIS_SAFE_ASSERT_RECOVER_RETURN(*colorSpace() == *src->colorSpace());
558 q->setDefaultPixel(KoColor(srcData->dataManager()->defaultPixel(), colorSpace()));
559
560 }
void prepareClone(const KisPaintDeviceData *srcData, bool copyContent=false)
void setDefaultPixel(const KoColor &defPixel)
void setDefaultBounds(KisDefaultBoundsBaseSP bounds)
void setSupportsWraparoundMode(bool value)

References colorSpace(), currentData(), KisPaintDeviceData::dataManager(), KisDataManager::defaultPixel(), KIS_SAFE_ASSERT_RECOVER_RETURN, KisPaintDeviceData::prepareClone(), q, KisPaintDevice::setDefaultBounds(), KisPaintDevice::setDefaultPixel(), and KisPaintDevice::setSupportsWraparoundMode().

◆ readFrame()

bool KisPaintDevice::Private::readFrame ( QIODevice * stream,
int frameId )
inline

Definition at line 382 of file kis_paint_device.cc.

383 {
384 bool retval = false;
385 DataSP data = m_frames[frameId];
386 retval = data->dataManager()->read(stream);
387 data->cache()->invalidate();
388 return retval;
389 }

References m_frames.

◆ regionForLodSyncing()

KisRegion KisPaintDevice::Private::regionForLodSyncing ( ) const

Definition at line 682 of file kis_paint_device.cc.

683{
684 Data *srcData = currentNonLodData();
685 return srcData->dataManager()->region().translated(srcData->x(), srcData->y());
686}

References KisPaintDeviceData::dataManager(), KisDataManager::region(), KisRegion::translated(), KisPaintDeviceData::x(), and KisPaintDeviceData::y().

◆ reincarnateWithDetachedHistory()

KUndo2Command * KisPaintDevice::Private::reincarnateWithDetachedHistory ( bool copyContent)

Definition at line 1025 of file kis_paint_device.cc.

1026{
1027 KUndo2Command *mainCommand = new KUndo2Command();
1028 currentData()->reincarnateWithDetachedHistory(copyContent, mainCommand);
1029 return mainCommand;
1030}
void reincarnateWithDetachedHistory(bool copyContent, KUndo2Command *parentCommand)

◆ setFrameDefaultPixel()

void KisPaintDevice::Private::setFrameDefaultPixel ( const KoColor & defPixel,
int frameId )
inline

Definition at line 397 of file kis_paint_device.cc.

398 {
399 DataSP data = m_frames[frameId];
400 KoColor color(defPixel);
401 color.convertTo(data->colorSpace());
402 data->dataManager()->setDefaultPixel(color.data());
403 data->cache()->invalidate();
404 }

References KoColor::convertTo(), KoColor::data(), and m_frames.

◆ setFrameOffset()

void KisPaintDevice::Private::setFrameOffset ( int frameId,
const QPoint & offset )
inline

Definition at line 369 of file kis_paint_device.cc.

370 {
371 DataSP data = m_frames[frameId];
372 data->setX(offset.x());
373 data->setY(offset.y());
374 data->cache()->invalidate();
375 }

References m_frames, and KisPaintDevice::offset().

◆ setX()

void KisPaintDevice::Private::setX ( qint32 x)
inline

Definition at line 128 of file kis_paint_device.cc.

129 {
130 currentData()->setX(x);
131 }
ALWAYS_INLINE void setX(qint32 value)

References currentData(), KisPaintDeviceData::setX(), and x().

◆ setY()

void KisPaintDevice::Private::setY ( qint32 y)
inline

Definition at line 132 of file kis_paint_device.cc.

133 {
134 currentData()->setY(y);
135 }
ALWAYS_INLINE void setY(qint32 value)

References currentData(), KisPaintDeviceData::setY(), and y().

◆ testingFetchLodDevice()

void KisPaintDevice::Private::testingFetchLodDevice ( KisPaintDeviceSP targetDevice)

Definition at line 921 of file kis_paint_device.cc.

922{
923 Data *data = m_lodData.data();
924 Q_ASSERT(data);
925
926 transferFromData(data, targetDevice);
927}
void transferFromData(Data *data, KisPaintDeviceSP targetDevice)

◆ transferFromData()

void KisPaintDevice::Private::transferFromData ( Data * data,
KisPaintDeviceSP targetDevice )
private

Definition at line 849 of file kis_paint_device.cc.

850{
851 QRect extent = data->dataManager()->extent();
852 extent.translate(data->x(), data->y());
853
854 targetDevice->m_d->prepareCloneImpl(q, data);
855 targetDevice->m_d->currentStrategy()->fastBitBltRough(data->dataManager(), extent);
856}
virtual void fastBitBltRough(KisPaintDeviceSP src, const QRect &rect)
Private *const m_d
KisPaintDeviceStrategy * currentStrategy()

References currentStrategy(), KisPaintDeviceData::dataManager(), KisPaintDevice::extent(), KisDataManager::extent(), KisPaintDevice::Private::KisPaintDeviceStrategy::fastBitBltRough(), KisPaintDevice::m_d, prepareCloneImpl(), KisPaintDeviceData::x(), and KisPaintDeviceData::y().

◆ updateLodDataManager()

void KisPaintDevice::Private::updateLodDataManager ( KisDataManager * srcDataManager,
KisDataManager * dstDataManager,
const QPoint & srcOffset,
const QPoint & dstOffset,
const QRect & originalRect,
int lod )

Definition at line 724 of file kis_paint_device.cc.

730{
731 if (originalRect.isEmpty()) return;
732
733 const int srcStepSize = 1 << lod;
734
736
737 const QRect srcRect = KisLodTransform::alignedRect(originalRect, lod);
738 const QRect dstRect = KisLodTransform::scaledRect(srcRect, lod);
739 if (!srcRect.isValid() || !dstRect.isValid()) return;
740
741 KIS_ASSERT_RECOVER_NOOP(srcRect.width() / srcStepSize == dstRect.width());
742
743 const int pixelSize = srcDataManager->pixelSize();
744
745 int rowsAccumulated = 0;
746 int columnsAccumulated = 0;
747
749
750 QScopedArrayPointer<quint8> blendData(new quint8[srcStepSize * srcRect.width() * pixelSize]);
751 quint8 *blendDataPtr = blendData.data();
752 int blendDataOffset = 0;
753
754 const int srcCellSize = srcStepSize * srcStepSize;
755 const int srcCellStride = srcCellSize * pixelSize;
756 const int srcStepStride = srcStepSize * pixelSize;
757 const int srcColumnStride = (srcStepSize - 1) * srcStepStride;
758
759 InternalSequentialConstIterator srcIntIt(StrategyPolicy(currentStrategy(), srcDataManager, srcOffset.x(), srcOffset.y()), srcRect);
760 InternalSequentialIterator dstIntIt(StrategyPolicy(currentStrategy(), dstDataManager, dstOffset.x(), dstOffset.y()), dstRect);
761
762 int rowsRemaining = srcRect.height();
763 while (rowsRemaining > 0) {
764
765 int colsRemaining = srcRect.width();
766 while (colsRemaining > 0 && srcIntIt.nextPixel()) {
767
768 memcpy(blendDataPtr, srcIntIt.rawDataConst(), pixelSize);
769 blendDataPtr += pixelSize;
770 columnsAccumulated++;
771
772 if (columnsAccumulated >= srcStepSize) {
773 blendDataPtr += srcColumnStride;
774 columnsAccumulated = 0;
775 }
776
777 colsRemaining--;
778 }
779
780 rowsAccumulated++;
781
782 if (rowsAccumulated >= srcStepSize) {
783
784 // blend and write the final data
785 blendDataPtr = blendData.data();
786
787 int colsRemaining = dstRect.width();
788 while (colsRemaining > 0 && dstIntIt.nextPixel()) {
789 mixOp->mixColors(blendDataPtr, srcCellSize, dstIntIt.rawData());
790 blendDataPtr += srcCellStride;
791
792 colsRemaining--;
793 }
794
795 // reset counters
796 rowsAccumulated = 0;
797 blendDataPtr = blendData.data();
798 blendDataOffset = 0;
799 } else {
800 blendDataOffset += srcStepStride;
801 blendDataPtr = blendData.data() + blendDataOffset;
802 }
803
804 rowsRemaining--;
805 }
806}
quint32 pixelSize() const
static QRect alignedRect(const QRect &srcRect, int lod)
static QRect scaledRect(const QRect &srcRect, int lod)
quint32 pixelSize() const
KoMixColorsOp * mixColorsOp
virtual void mixColors(const quint8 *const *colors, const qint16 *weights, int nColors, quint8 *dst, int weightSum=255) const =0
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
#define KIS_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:97
KisSequentialIteratorBase< ReadOnlyIteratorPolicy< StrategyPolicy >, StrategyPolicy > InternalSequentialConstIterator
struct Q_DECL_HIDDEN StrategyPolicy
KisSequentialIteratorBase< WritableIteratorPolicy< StrategyPolicy >, StrategyPolicy > InternalSequentialIterator

References KisLodTransformBase::alignedRect(), KisPaintDevice::colorSpace(), KIS_ASSERT_RECOVER_NOOP, KIS_ASSERT_RECOVER_RETURN, KoMixColorsOp::mixColors(), KoColorSpace::mixColorsOp, KisSequentialIteratorBase< IteratorPolicy, SourcePolicy, ProgressPolicy >::nextPixel(), KisDataManager::pixelSize(), KisPaintDevice::pixelSize(), KisSequentialIteratorBase< IteratorPolicy, SourcePolicy, ProgressPolicy >::rawData(), KisSequentialIteratorBase< IteratorPolicy, SourcePolicy, ProgressPolicy >::rawDataConst(), and KisLodTransformBase::scaledRect().

◆ updateLodDataStruct()

void KisPaintDevice::Private::updateLodDataStruct ( LodDataStruct * dst,
const QRect & srcRect )

Definition at line 808 of file kis_paint_device.cc.

809{
810 LodDataStructImpl *dst = dynamic_cast<LodDataStructImpl*>(_dst);
812
813 Data *lodData = dst->lodData.data();
814 Data *srcData = currentNonLodData();
815
816 const int lod = lodData->levelOfDetail();
817
818 updateLodDataManager(srcData->dataManager().data(), lodData->dataManager().data(),
819 QPoint(srcData->x(), srcData->y()),
820 QPoint(lodData->x(), lodData->y()),
821 originalRect, lod);
822}

References KisSharedPtr< T >::data(), KisPaintDeviceData::dataManager(), KIS_SAFE_ASSERT_RECOVER_RETURN, KisPaintDeviceData::levelOfDetail(), KisPaintDevice::Private::LodDataStructImpl::lodData, KisPaintDeviceData::x(), and KisPaintDeviceData::y().

◆ uploadFrame() [1/2]

void KisPaintDevice::Private::uploadFrame ( int dstFrameId,
KisPaintDeviceSP srcDevice )

Definition at line 875 of file kis_paint_device.cc.

876{
877 DataSP dstData = m_frames[dstFrameId];
879
880 DataSP srcData = srcDevice->m_d->m_data;
882
883 uploadFrameData(srcData, dstData);
884}
void uploadFrameData(DataSP srcData, DataSP dstData)

References KIS_ASSERT_RECOVER_RETURN, KisPaintDevice::m_d, and m_data.

◆ uploadFrame() [2/2]

void KisPaintDevice::Private::uploadFrame ( int srcFrameId,
int dstFrameId,
KisPaintDeviceSP srcDevice )

Definition at line 864 of file kis_paint_device.cc.

865{
866 DataSP dstData = m_frames[dstFrameId];
868
869 DataSP srcData = srcDevice->m_d->m_frames[srcFrameId];
871
872 uploadFrameData(srcData, dstData);
873}

References KIS_ASSERT_RECOVER_RETURN, KisPaintDevice::m_d, and m_frames.

◆ uploadFrameData()

void KisPaintDevice::Private::uploadFrameData ( DataSP srcData,
DataSP dstData )

Definition at line 886 of file kis_paint_device.cc.

887{
888 if (srcData->colorSpace() != dstData->colorSpace() &&
889 *srcData->colorSpace() != *dstData->colorSpace()) {
890
891 KUndo2Command tempCommand;
892
893 srcData = toQShared(new Data(q, srcData.data(), true));
894 srcData->convertDataColorSpace(dstData->colorSpace(),
897 &tempCommand);
898 }
899
900 /* If the destination data doesn't share a default pixel value
901 * with src, we should make sure that the default pixel is set
902 * properly before clearing and writing contents.
903 */
904 const int defaultPixelcmp =
905 memcmp(srcData->dataManager()->defaultPixel(),
906 dstData->dataManager()->defaultPixel(),
907 dstData->dataManager()->pixelSize());
908 if (defaultPixelcmp != 0) {
909 dstData->dataManager()->setDefaultPixel(srcData->dataManager()->defaultPixel());
910 }
911
912 dstData->dataManager()->clear();
913 dstData->cache()->invalidate();
914
915 const QRect rect = srcData->dataManager()->extent();
916 dstData->dataManager()->bitBltRough(srcData->dataManager(), rect);
917 dstData->setX(srcData->x());
918 dstData->setY(srcData->y());
919}

References KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), and toQShared().

◆ uploadLodDataStruct()

void KisPaintDevice::Private::uploadLodDataStruct ( LodDataStruct * dst)

Definition at line 835 of file kis_paint_device.cc.

836{
837 LodDataStructImpl *dst = dynamic_cast<LodDataStructImpl*>(_dst);
839
841 dst->lodData->levelOfDetail() == defaultBounds->currentLevelOfDetail());
842
844
845 m_lodData->prepareClone(dst->lodData.data());
846 m_lodData->dataManager()->bitBltRough(dst->lodData->dataManager(), dst->lodData->dataManager()->extent());
847}

References KisDefaultBoundsBase::currentLevelOfDetail(), KisPaintDevice::defaultBounds(), KIS_SAFE_ASSERT_RECOVER_RETURN, and KisPaintDevice::Private::LodDataStructImpl::lodData.

◆ writeFrame()

bool KisPaintDevice::Private::writeFrame ( KisPaintDeviceWriter & store,
int frameId )
inline

Definition at line 391 of file kis_paint_device.cc.

392 {
393 DataSP data = m_frames[frameId];
394 return data->dataManager()->write(store);
395 }

References m_frames.

◆ writeFrameToDevice()

void KisPaintDevice::Private::writeFrameToDevice ( int frameId,
KisPaintDeviceSP targetDevice )

Definition at line 858 of file kis_paint_device.cc.

859{
860 DataSP data = m_frames[frameId];
861 transferFromData(data.data(), targetDevice);
862}

◆ x()

qint32 KisPaintDevice::Private::x ( ) const
inline

Definition at line 120 of file kis_paint_device.cc.

121 {
122 return currentData()->x();
123 }
ALWAYS_INLINE qint32 x() const

References currentData(), and KisPaintDeviceData::x().

◆ y()

qint32 KisPaintDevice::Private::y ( ) const
inline

Definition at line 124 of file kis_paint_device.cc.

125 {
126 return currentData()->y();
127 }
ALWAYS_INLINE qint32 y() const

References currentData(), and KisPaintDeviceData::y().

Friends And Related Symbol Documentation

◆ KisPaintDeviceFramesInterface

friend class KisPaintDeviceFramesInterface
friend

Definition at line 592 of file kis_paint_device.cc.

Member Data Documentation

◆ basicStrategy

QScopedPointer<KisPaintDeviceStrategy> KisPaintDevice::Private::basicStrategy

Definition at line 90 of file kis_paint_device.cc.

◆ contentChannel

QScopedPointer<KisRasterKeyframeChannel> KisPaintDevice::Private::contentChannel

Definition at line 88 of file kis_paint_device.cc.

◆ defaultBounds

KisDefaultBoundsBaseSP KisPaintDevice::Private::defaultBounds

Definition at line 89 of file kis_paint_device.cc.

◆ framesInterface

QScopedPointer<KisPaintDeviceFramesInterface> KisPaintDevice::Private::framesInterface

Definition at line 94 of file kis_paint_device.cc.

◆ isProjectionDevice

bool KisPaintDevice::Private::isProjectionDevice

Definition at line 95 of file kis_paint_device.cc.

◆ m_data

DataSP KisPaintDevice::Private::m_data
private

Definition at line 595 of file kis_paint_device.cc.

◆ m_dataSwitchLock

QMutex KisPaintDevice::Private::m_dataSwitchLock
mutableprivate

Definition at line 598 of file kis_paint_device.cc.

◆ m_externalFrameData

QScopedPointer<Data> KisPaintDevice::Private::m_externalFrameData
mutableprivate

Definition at line 597 of file kis_paint_device.cc.

◆ m_frames

FramesHash KisPaintDevice::Private::m_frames
private

Definition at line 600 of file kis_paint_device.cc.

◆ m_lodData

QScopedPointer<Data> KisPaintDevice::Private::m_lodData
mutableprivate

Definition at line 596 of file kis_paint_device.cc.

◆ m_nextFreeFrameId

int KisPaintDevice::Private::m_nextFreeFrameId
private

Definition at line 601 of file kis_paint_device.cc.

◆ m_wrappedStrategyMutex

QMutex KisPaintDevice::Private::m_wrappedStrategyMutex

Definition at line 92 of file kis_paint_device.cc.

◆ parent

KisNodeWSP KisPaintDevice::Private::parent

Definition at line 87 of file kis_paint_device.cc.

◆ q

KisPaintDevice* KisPaintDevice::Private::q

Definition at line 86 of file kis_paint_device.cc.

◆ StrategyPolicy

struct Q_DECL_HIDDEN KisPaintDevice::Private::StrategyPolicy
private

Definition at line 587 of file kis_paint_device.cc.

◆ supportsWrapAroundMode

bool KisPaintDevice::Private::supportsWrapAroundMode

Definition at line 96 of file kis_paint_device.cc.

◆ transitionalDefaultBounds

const KisDefaultBoundsSP KisPaintDevice::Private::transitionalDefaultBounds = new KisDefaultBounds()
static

Used when the paint device is loading to ensure no lod/animation interferes the process.

Definition at line 73 of file kis_paint_device.cc.

◆ wrappedStrategy

QScopedPointer<KisPaintDeviceWrappedStrategy> KisPaintDevice::Private::wrappedStrategy

Definition at line 91 of file kis_paint_device.cc.


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