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

#include <kis_paint_device.h>

+ Inheritance diagram for KisPaintDevice:

Classes

struct  LodDataStruct
 
struct  MemoryReleaseObject
 
struct  Private
 

Signals

void colorSpaceChanged (const KoColorSpace *colorspace)
 
void profileChanged (const KoColorProfile *profile)
 

Public Member Functions

bool burnKeyframe ()
 
bool burnKeyframe (int frameID)
 burnKeyframe
 
QRect calculateExactBounds (bool nonDefaultOnly) const
 
quint32 channelCount () const
 
virtual void clear ()
 
void clear (const QRect &rc)
 
void clearSelection (KisSelectionSP selection)
 
const KoColorSpacecolorSpace () const
 
virtual const KoColorSpacecompositionSourceColorSpace () const
 
void convertFromQImage (const QImage &image, const KoColorProfile *profile, qint32 offsetX=0, qint32 offsetY=0)
 
void convertTo (const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags(), KUndo2Command *parentCommand=nullptr, KoUpdater *progressUpdater=nullptr)
 
QImage convertToQImage (const KoColorProfile *dstProfile, const QRect &rc, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags()) const
 
QImage convertToQImage (const KoColorProfile *dstProfile, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags()) const
 
QImage convertToQImage (const KoColorProfile *dstProfile, qint32 x, qint32 y, qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags()) const
 
KUndo2CommandcreateChangeInterstrokeDataCommand (KisInterstrokeDataSP data)
 set interstroke data to the device
 
KisPaintDeviceSP createCompositionSourceDevice () const
 
KisPaintDeviceSP createCompositionSourceDevice (KisPaintDeviceSP cloneSource) const
 
KisPaintDeviceSP createCompositionSourceDevice (KisPaintDeviceSP cloneSource, const QRect roughRect) const
 
KisFixedPaintDeviceSP createCompositionSourceDeviceFixed () const
 
KisHLineConstIteratorSP createHLineConstIteratorNG (qint32 x, qint32 y, qint32 w) const
 
KisHLineIteratorSP createHLineIteratorNG (qint32 x, qint32 y, qint32 w)
 
KisRasterKeyframeChannelcreateKeyframeChannel (const KoID &id)
 
LodDataStructcreateLodDataStruct (int lod)
 
KisRandomAccessorSP createRandomAccessorNG ()
 
KisRandomConstAccessorSP createRandomConstAccessorNG () const
 
KisRandomSubAccessorSP createRandomSubAccessor () const
 
KisRepeatHLineConstIteratorSP createRepeatHLineConstIterator (qint32 x, qint32 y, qint32 w, const QRect &_dataWidth) const
 
KisRepeatVLineConstIteratorSP createRepeatVLineConstIterator (qint32 x, qint32 y, qint32 h, const QRect &_dataWidth) const
 
QImage createThumbnail (qint32 maxw, qint32 maxh, qreal oversample=1, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags())
 
QImage createThumbnail (qint32 maxw, qint32 maxh, QRect rect, qreal oversample=1, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags())
 
QImage createThumbnail (qint32 maxw, qint32 maxh, Qt::AspectRatioMode aspectRatioMode, qreal oversample=1, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags())
 
KisPaintDeviceSP createThumbnailDevice (qint32 w, qint32 h, QRect rect=QRect(), QRect outputRect=QRect()) const
 
KisPaintDeviceSP createThumbnailDeviceOversampled (qint32 w, qint32 h, qreal oversample, QRect rect=QRect(), QRect outputRect=QRect()) const
 
KisVLineConstIteratorSP createVLineConstIteratorNG (qint32 x, qint32 y, qint32 h) const
 
KisVLineIteratorSP createVLineIteratorNG (qint32 x, qint32 y, qint32 h)
 
void crop (const QRect &r)
 Convenience method for the above.
 
void crop (qint32 x, qint32 y, qint32 w, qint32 h)
 
KisDataManagerSP dataManager () const
 
KisDefaultBoundsBaseSP defaultBounds () const
 
KoColor defaultPixel () const
 
void estimateMemoryStats (qint64 &imageData, qint64 &temporaryData, qint64 &lodData) const
 
QRect exactBounds () const
 
QRect exactBoundsAmortized () const
 
QRect extent () const
 
void extent (qint32 &x, qint32 &y, qint32 &w, qint32 &h) const
 Convenience method for the above.
 
void fill (const QRect &rc, const KoColor &color)
 
void fill (qint32 x, qint32 y, qint32 w, qint32 h, const quint8 *fillPixel)
 
KisPaintDeviceFramesInterfaceframesInterface ()
 
void generateLodCloneDevice (KisPaintDeviceSP dst, const QRect &originalRect, int lod)
 
KisInterstrokeDataSP interstrokeData () const
 
KisRasterKeyframeChannelkeyframeChannel () const
 
 KisPaintDevice (const KisPaintDevice &rhs, KritaUtils::DeviceCopyMode copyMode=KritaUtils::CopySnapshot, KisNode *newParentNode=0)
 
 KisPaintDevice (const KoColorSpace *colorSpace, const QString &name=QString())
 
 KisPaintDevice (KisNodeWSP parent, const KoColorSpace *colorSpace, KisDefaultBoundsBaseSP defaultBounds=KisDefaultBoundsBaseSP(), const QString &name=QString())
 
void makeCloneFrom (KisPaintDeviceSP src, const QRect &rect)
 
void makeCloneFromRough (KisPaintDeviceSP src, const QRect &minimalRect)
 
void makeFullCopyFrom (const KisPaintDevice &rhs, KritaUtils::DeviceCopyMode copyMode=KritaUtils::CopySnapshot, KisNode *newParentNode=0)
 
virtual void moveTo (const QPoint &pt)
 
void moveTo (qint32 x, qint32 y)
 
QRect nonDefaultPixelArea () const
 
QPoint offset () const
 
KoColor pixel (const QPoint &pos) const
 
bool pixel (qint32 x, qint32 y, KoColor *kc) const
 
bool pixel (qint32 x, qint32 y, QColor *c) const
 
quint32 pixelSize () const
 
void prepareClone (KisPaintDeviceSP src)
 
void purgeDefaultPixels ()
 
bool read (QIODevice *stream)
 
void readBytes (quint8 *data, const QRect &rect) const
 
void readBytes (quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h) const
 
QVector< quint8 * > readPlanarBytes (qint32 x, qint32 y, qint32 w, qint32 h) const
 
KisRegion region () const
 
KisRegion regionExact () const
 
KisRegion regionForLodSyncing () const
 
KUndo2CommandreincarnateWithDetachedHistory (bool copyContent)
 
void requestTimeSwitch (int time)
 
int sequenceNumber () const
 
void setDataManager (KisDataManagerSP data, const KoColorSpace *colorSpace=0)
 
void setDefaultBounds (KisDefaultBoundsBaseSP bounds)
 
void setDefaultPixel (const KoColor &defPixel)
 
void setDirty ()
 
void setDirty (const KisRegion &region)
 
void setDirty (const QRect &rc)
 
void setDirty (const QVector< QRect > &rects)
 
void setParentNode (KisNodeWSP parent)
 
bool setPixel (qint32 x, qint32 y, const KoColor &kc)
 Convenience method for the above.
 
bool setPixel (qint32 x, qint32 y, const QColor &c)
 
bool setProfile (const KoColorProfile *profile, KUndo2Command *parentCommand)
 
void setProjectionDevice (bool value)
 
void setSupportsWraparoundMode (bool value)
 
void setX (qint32 x)
 
void setY (qint32 y)
 
bool supportsWraproundMode () const
 
void testingFetchLodDevice (KisPaintDeviceSP targetDevice)
 
void updateLodDataStruct (LodDataStruct *dst, const QRect &srcRect)
 
void uploadLodDataStruct (LodDataStruct *dst)
 
bool write (KisPaintDeviceWriter &store)
 
void writeBytes (const quint8 *data, const QRect &rect)
 
void writeBytes (const quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h)
 
void writePlanarBytes (QVector< quint8 * > planes, qint32 x, qint32 y, qint32 w, qint32 h)
 
qint32 x () const
 
qint32 y () const
 
 ~KisPaintDevice () override
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 

Static Public Member Functions

static MemoryReleaseObjectcreateMemoryReleaseObject ()
 

Protected Member Functions

void fastBitBlt (KisPaintDeviceSP src, const QRect &rect)
 
void fastBitBltOldData (KisPaintDeviceSP src, const QRect &rect)
 
bool fastBitBltPossible (KisPaintDeviceSP src)
 
void fastBitBltRough (KisPaintDeviceSP src, const QRect &rect)
 
void fastBitBltRoughOldData (KisPaintDeviceSP src, const QRect &rect)
 
 KisPaintDevice (KisDataManagerSP explicitDataManager, KisPaintDeviceSP src, const QString &name=QString())
 
KisNodeWSP parentNode () const
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 

Private Member Functions

QVector< qint32 > channelSizes () const
 
void emitColorSpaceChanged ()
 
void emitProfileChanged ()
 
void init (const KoColorSpace *colorSpace, KisDefaultBoundsBaseSP defaultBounds, KisNodeWSP parent, const QString &name)
 
KisPaintDeviceoperator= (const KisPaintDevice &)
 

Private Attributes

Private *const m_d
 

Friends

class DataReaderThread
 
class KisPaintDeviceFramesInterface
 
class KisPaintDeviceTest
 
class KisPainter
 
class KisSelectionTest
 
class PaintDeviceCache
 

Detailed Description

A paint device contains the actual pixel data and offers methods to read and write pixels. A paint device has an integer x, y position (it is not positioned on the image with sub-pixel accuracy). A KisPaintDevice doesn't have any fixed size, the size changes dynamically when pixels are accessed by an iterator.

Definition at line 65 of file kis_paint_device.h.

Constructor & Destructor Documentation

◆ KisPaintDevice() [1/4]

KisPaintDevice::KisPaintDevice ( const KoColorSpace * colorSpace,
const QString & name = QString() )
explicit

Create a new paint device with the specified colorspace.

Parameters
colorSpacethe colorspace of this paint device
namefor debugging purposes

Definition at line 1043 of file kis_paint_device.cc.

1044 : QObject(0)
1045 , m_d(new Private(this))
1046{
1047 init(colorSpace, new KisDefaultBounds(), 0, name);
1048}
Private *const m_d
void init(const KoColorSpace *colorSpace, KisDefaultBoundsBaseSP defaultBounds, KisNodeWSP parent, const QString &name)
const KoColorSpace * colorSpace() const

References colorSpace(), and init().

◆ KisPaintDevice() [2/4]

KisPaintDevice::KisPaintDevice ( KisNodeWSP parent,
const KoColorSpace * colorSpace,
KisDefaultBoundsBaseSP defaultBounds = KisDefaultBoundsBaseSP(),
const QString & name = QString() )

Create a new paint device with the specified colorspace. The parent node will be notified of changes to this paint device.

Parameters
parentthe node that contains this paint device
colorSpacethe colorspace of this paint device
defaultBoundsboundaries of the device in case it is empty
namefor debugging purposes

Definition at line 1050 of file kis_paint_device.cc.

1051 : QObject(0)
1052 , m_d(new Private(this))
1053{
1054 init(colorSpace, defaultBounds, parent, name);
1055}
KisDefaultBoundsBaseSP defaultBounds() const

References colorSpace(), defaultBounds(), and init().

◆ KisPaintDevice() [3/4]

KisPaintDevice::KisPaintDevice ( const KisPaintDevice & rhs,
KritaUtils::DeviceCopyMode copyMode = KritaUtils::CopySnapshot,
KisNode * newParentNode = 0 )

Creates a copy of this device.

If copyMode is CopySnapshot, the newly created device clones the current frame of rhs only (default and efficient behavior). If copyFrames is CopyAllFrames, the new device is a deep copy of the source with all the frames included.

Definition at line 1082 of file kis_paint_device.cc.

1083 : QObject()
1084 , KisShared()
1085 , m_d(new Private(this))
1086{
1087 if (this != &rhs) {
1088 makeFullCopyFrom(rhs, copyMode, newParentNode);
1089 }
1090}
void makeFullCopyFrom(const KisPaintDevice &rhs, KritaUtils::DeviceCopyMode copyMode=KritaUtils::CopySnapshot, KisNode *newParentNode=0)

References makeFullCopyFrom().

◆ ~KisPaintDevice()

KisPaintDevice::~KisPaintDevice ( )
override

Definition at line 1112 of file kis_paint_device.cc.

1113{
1114 delete m_d;
1115}

References m_d.

◆ KisPaintDevice() [4/4]

KisPaintDevice::KisPaintDevice ( KisDataManagerSP explicitDataManager,
KisPaintDeviceSP src,
const QString & name = QString() )
protected

A special constructor for usage in KisPixelSelection. It allows two paint devices to share a data manager.

Parameters
explicitDataManagerdata manager to use inside paint device
srcsource paint device to copy parameters from
namefor debugging purposes

Member Function Documentation

◆ burnKeyframe() [1/2]

bool KisPaintDevice::burnKeyframe ( )

Definition at line 2209 of file kis_paint_device.cc.

2210{
2211 if (m_d->framesInterface) {
2212 return burnKeyframe(m_d->framesInterface->currentFrameId());
2213 }
2214 return true;
2215}
QScopedPointer< KisPaintDeviceFramesInterface > framesInterface

References burnKeyframe(), KisPaintDevice::Private::framesInterface, and m_d.

◆ burnKeyframe() [2/2]

bool KisPaintDevice::burnKeyframe ( int frameID)

burnKeyframe

Take a frame from the keyframe channel, Copy the contents onto the "base" frame, and completely remove the keyframe channel.

Should be useful for copy+paste operations where we shouldn't expect keyframe data to persist.

Parameterless version simply gets the current frameID.

Parameters
frameID– frameID (from the framesInterface, not the time) to burn to device.
Returns
success

Definition at line 2188 of file kis_paint_device.cc.

2189{
2190 KIS_ASSERT_RECOVER_RETURN_VALUE(m_d->framesInterface.data()->frames().contains(frameID), false);
2191
2192 // Preserve keyframe data from frameID...
2194 m_d->framesInterface->writeFrameToDevice(frameID, holder);
2195
2196 // Remove all keyframes..
2197 QSet<int> times = m_d->contentChannel->allKeyframeTimes();
2198 Q_FOREACH( const int& time, times ) {
2199 m_d->contentChannel->removeKeyframe(time);
2200 }
2201
2202 // TODO: Eventually rewrite this to completely remove contentChannel.
2203 // For now, importing it as frame 0 will be close enough.
2204 m_d->contentChannel->importFrame(0, holder, nullptr);
2205
2206 return true;
2207}
KisPaintDevice(const KoColorSpace *colorSpace, const QString &name=QString())
#define KIS_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:85
const KoColorSpace * colorSpace() const
QScopedPointer< KisRasterKeyframeChannel > contentChannel

References KisPaintDevice::Private::colorSpace(), KisPaintDevice::Private::contentChannel, KisPaintDevice::Private::framesInterface, KIS_ASSERT_RECOVER_RETURN_VALUE, KisPaintDevice(), and m_d.

◆ calculateExactBounds()

QRect KisPaintDevice::calculateExactBounds ( bool nonDefaultOnly) const

Calculates exact bounds of the device. Used internally by a transparent caching system. The solution is very slow because it does a linear scanline search. So the complexity is n*n at worst.

See also
exactBounds(), nonDefaultPixelArea()

We will calculate exact bounds only outside of the image bounds, and that'll be nondefault area only.

Definition at line 1435 of file kis_paint_device.cc.

1436{
1437 QRect startRect = extent();
1438 QRect endRect;
1439
1440 quint8 defaultOpacity = defaultPixel().opacityU8();
1441 if (defaultOpacity != OPACITY_TRANSPARENT_U8) {
1442 if (!nonDefaultOnly) {
1448 endRect = defaultBounds()->bounds();
1449 nonDefaultOnly = true;
1450
1451 } else {
1452 startRect = region().boundingRect();
1453 }
1454 }
1455
1456 if (nonDefaultOnly) {
1457 const KoColor defaultPixel = this->defaultPixel();
1459 endRect = Impl::calculateExactBoundsImpl(this, startRect, endRect, compareOp);
1460 } else {
1462 endRect = Impl::calculateExactBoundsImpl(this, startRect, endRect, compareOp);
1463 }
1464
1465 return endRect;
1466}
const quint8 OPACITY_TRANSPARENT_U8
virtual QRect bounds() const =0
quint32 pixelSize() const
KisRegion region() const
QRect extent() const
KoColor defaultPixel() const
QRect boundingRect() const
quint8 * data()
Definition KoColor.h:144
quint8 opacityU8() const
Definition KoColor.cpp:341
QRect calculateExactBoundsImpl(const KisPaintDevice *device, const QRect &startRect, const QRect &endRect, ComparePixelOp compareOp)

References KisRegion::boundingRect(), KisDefaultBoundsBase::bounds(), Impl::calculateExactBoundsImpl(), KisPaintDevice::Private::colorSpace(), KoColor::data(), defaultBounds(), defaultPixel(), extent(), m_d, OPACITY_TRANSPARENT_U8, KoColor::opacityU8(), pixelSize(), and region().

◆ channelCount()

quint32 KisPaintDevice::channelCount ( ) const

Return the number of channels a pixel takes

Definition at line 2030 of file kis_paint_device.cc.

2031{
2032 quint32 _channelCount = m_d->colorSpace()->channelCount();
2033 Q_ASSERT(_channelCount > 0);
2034 return _channelCount;
2035}
virtual quint32 channelCount() const =0

References KoColorSpace::channelCount(), KisPaintDevice::Private::colorSpace(), and m_d.

◆ channelSizes()

QVector< qint32 > KisPaintDevice::channelSizes ( ) const
private

Return a vector with in order the size in bytes of the channels in the colorspace of this paint device.

Definition at line 2122 of file kis_paint_device.cc.

2123{
2124 QVector<qint32> sizes;
2126 std::sort(channels.begin(), channels.end());
2127
2128 Q_FOREACH (KoChannelInfo * channelInfo, channels) {
2129 sizes.append(channelInfo->size());
2130 }
2131 return sizes;
2132}
qint32 size() const
QList< KoChannelInfo * > channels

References KoColorSpace::channels, colorSpace(), and KoChannelInfo::size().

◆ clear() [1/2]

void KisPaintDevice::clear ( )
virtual

Complete erase the current paint device. Its size will become 0. This does not take the selection into account.

Reimplemented in KisPixelSelection.

Definition at line 1523 of file kis_paint_device.cc.

1524{
1525 m_d->dataManager()->clear();
1526 m_d->cache()->invalidate();
1527}
void clear(qint32 x, qint32 y, qint32 w, qint32 h, quint8 def)
KisDataManagerSP dataManager() const
KisPaintDeviceCache * cache()

References KisPaintDevice::Private::cache(), KisDataManager::clear(), KisPaintDevice::Private::dataManager(), KisPaintDeviceCache::invalidate(), and m_d.

◆ clear() [2/2]

void KisPaintDevice::clear ( const QRect & rc)

Clear the given rectangle to transparent black. The paint device will expand to contain the given rect.

Definition at line 1529 of file kis_paint_device.cc.

1530{
1531 m_d->currentStrategy()->clear(rc);
1532}
KisPaintDeviceStrategy * currentStrategy()

References KisPaintDevice::Private::KisPaintDeviceStrategy::clear(), KisPaintDevice::Private::currentStrategy(), and m_d.

◆ clearSelection()

void KisPaintDevice::clearSelection ( KisSelectionSP selection)

Clear the selected pixels from the paint device

Definition at line 1875 of file kis_paint_device.cc.

1876{
1878 const QRect r = selection->selectedExactRect();
1879
1880 if (r.isValid()) {
1881
1882 {
1883 KisHLineIteratorSP devIt = createHLineIteratorNG(r.x(), r.y(), r.width());
1884 KisHLineConstIteratorSP selectionIt = selection->projection()->createHLineConstIteratorNG(r.x(), r.y(), r.width());
1885
1886 const KoColor defaultPixel = this->defaultPixel();
1887 bool transparentDefault = (defaultPixel.opacityU8() == OPACITY_TRANSPARENT_U8);
1888 for (qint32 y = 0; y < r.height(); y++) {
1889
1890 do {
1891 // XXX: Optimize by using stretches
1892 colorSpace->applyInverseAlphaU8Mask(devIt->rawData(), selectionIt->rawDataConst(), 1);
1893 if (transparentDefault && colorSpace->opacityU8(devIt->rawData()) == OPACITY_TRANSPARENT_U8) {
1894 memcpy(devIt->rawData(), defaultPixel.data(), colorSpace->pixelSize());
1895 }
1896 } while (devIt->nextPixel() && selectionIt->nextPixel());
1897 devIt->nextRow();
1898 selectionIt->nextRow();
1899 }
1900 }
1901
1902 // purge() must be executed **after** all iterators have been destroyed!
1903 m_d->dataManager()->purge(r.translated(-m_d->x(), -m_d->y()));
1904
1905 setDirty(r);
1906 }
1907}
virtual const quint8 * rawDataConst() const =0
virtual bool nextPixel()=0
void purge(const QRect &area)
virtual void nextRow()=0
KisHLineIteratorSP createHLineIteratorNG(qint32 x, qint32 y, qint32 w)
KisHLineConstIteratorSP createHLineConstIteratorNG(qint32 x, qint32 y, qint32 w) const
virtual quint32 pixelSize() const =0
virtual void applyInverseAlphaU8Mask(quint8 *pixels, const quint8 *alpha, qint32 nPixels) const =0
virtual quint8 opacityU8(const quint8 *pixel) const =0
KisPixelSelectionSP projection() const
QRect selectedExactRect() const
Slow, but exact way of determining the rectangle that encloses the selection.

References KoColorSpace::applyInverseAlphaU8Mask(), KisPaintDevice::Private::colorSpace(), colorSpace(), createHLineConstIteratorNG(), createHLineIteratorNG(), KoColor::data(), KisPaintDevice::Private::dataManager(), defaultPixel(), m_d, KisBaseConstIteratorNG::nextPixel(), KisHLineConstIteratorNG::nextRow(), OPACITY_TRANSPARENT_U8, KoColor::opacityU8(), KoColorSpace::opacityU8(), KoColorSpace::pixelSize(), KisSelection::projection(), KisDataManager::purge(), KisBaseConstAccessor::rawDataConst(), KisSelection::selectedExactRect(), setDirty(), KisPaintDevice::Private::x(), KisPaintDevice::Private::y(), and y().

◆ colorSpace()

const KoColorSpace * KisPaintDevice::colorSpace ( ) const
Returns
the colorspace of the pixels in this paint device

Definition at line 2075 of file kis_paint_device.cc.

2076{
2077 Q_ASSERT(m_d->colorSpace() != 0);
2078 return m_d->colorSpace();
2079}

References KisPaintDevice::Private::colorSpace(), and m_d.

◆ colorSpaceChanged

void KisPaintDevice::colorSpaceChanged ( const KoColorSpace * colorspace)
signal

◆ compositionSourceColorSpace()

const KoColorSpace * KisPaintDevice::compositionSourceColorSpace ( ) const
virtual

This is a lowlevel method for the principle used in createCompositionSourceDevice(). In most of the cases the paint device creation methods should be used instead of this function.

See also
createCompositionSourceDevice()
createCompositionSourceDeviceFixed()

Reimplemented in KisPixelSelection.

Definition at line 2117 of file kis_paint_device.cc.

2118{
2119 return colorSpace();
2120}

References colorSpace().

◆ convertFromQImage()

void KisPaintDevice::convertFromQImage ( const QImage & image,
const KoColorProfile * profile,
qint32 offsetX = 0,
qint32 offsetY = 0 )

Fill this paint device with the data from image; starting at (offsetX, offsetY)

Parameters
imagethe image
profilename of the RGB profile to interpret the image as. 0 is interpreted as sRGB
offsetXx offset
offsetYy offset

Definition at line 1595 of file kis_paint_device.cc.

1597{
1598 QImage image = _image;
1599
1600 if (image.format() != QImage::Format_ARGB32) {
1601 image.convertTo(QImage::Format_ARGB32);
1602 }
1603 // Don't convert if not no profile is given and both paint dev and qimage are rgba.
1604 if (!profile && colorSpace()->id() == "RGBA") {
1605 writeBytes(image.constBits(), offsetX, offsetY, image.width(), image.height());
1606 } else {
1607 try {
1608 quint8 * dstData = new quint8[image.width() * image.height() * pixelSize()];
1611 ->convertPixelsTo(image.constBits(), dstData, colorSpace(), image.width() * image.height(),
1614
1615 writeBytes(dstData, offsetX, offsetY, image.width(), image.height());
1616 delete[] dstData;
1617 } catch (const std::bad_alloc&) {
1618 warnKrita << "KisPaintDevice::convertFromQImage: Could not allocate" << image.width() * image.height() * pixelSize() << "bytes";
1619 return;
1620 }
1621 }
1622 m_d->cache()->invalidate();
1623}
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
void writeBytes(const quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h)
virtual bool convertPixelsTo(const quint8 *src, quint8 *dst, const KoColorSpace *dstColorSpace, quint32 numPixels, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const
QString id() const
Definition KoID.cpp:63
#define warnKrita
Definition kis_debug.h:87
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
static KoColorSpaceRegistry * instance()

References KisPaintDevice::Private::cache(), colorSpace(), KoColorSpaceRegistry::colorSpace(), KoColorSpace::convertPixelsTo(), KoID::id(), KoColorSpaceRegistry::instance(), Integer8BitsColorDepthID, KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), KisPaintDeviceCache::invalidate(), m_d, pixelSize(), RGBAColorModelID, warnKrita, and writeBytes().

◆ convertTo()

void KisPaintDevice::convertTo ( const KoColorSpace * dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(),
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags(),
KUndo2Command * parentCommand = nullptr,
KoUpdater * progressUpdater = nullptr )

Converts the paint device to a different colorspace

Definition at line 1571 of file kis_paint_device.cc.

1576{
1577 m_d->convertColorSpace(dstColorSpace, renderingIntent, conversionFlags, parentCommand, progressUpdater);
1578}
void convertColorSpace(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags, KUndo2Command *parentCommand, KoUpdater *progressUpdater)

References KisPaintDevice::Private::convertColorSpace(), and m_d.

◆ convertToQImage() [1/3]

QImage KisPaintDevice::convertToQImage ( const KoColorProfile * dstProfile,
const QRect & rc,
KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(),
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags() ) const

Overridden method for convenience

Definition at line 1641 of file kis_paint_device.cc.

1645{
1646 return convertToQImage(dstProfile,
1647 rc.x(), rc.y(), rc.width(), rc.height(),
1648 renderingIntent, conversionFlags);
1649}
QImage convertToQImage(const KoColorProfile *dstProfile, qint32 x, qint32 y, qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags()) const

References convertToQImage().

◆ convertToQImage() [2/3]

QImage KisPaintDevice::convertToQImage ( const KoColorProfile * dstProfile,
KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(),
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags() ) const

Create an RGBA QImage from a rectangle in the paint device. The rectangle is defined by the parent image's bounds.

Parameters
dstProfileRGB profile to use in conversion. May be 0, in which case it's up to the color strategy to choose a profile (most like sRGB).
renderingIntentRendering intent
conversionFlagsConversion flags

Definition at line 1625 of file kis_paint_device.cc.

1626{
1627 qint32 x1;
1628 qint32 y1;
1629 qint32 w;
1630 qint32 h;
1631
1632 QRect rc = exactBounds();
1633 x1 = rc.x();
1634 y1 = rc.y();
1635 w = rc.width();
1636 h = rc.height();
1637
1638 return convertToQImage(dstProfile, x1, y1, w, h, renderingIntent, conversionFlags);
1639}
QRect exactBounds() const

References convertToQImage(), and exactBounds().

◆ convertToQImage() [3/3]

QImage KisPaintDevice::convertToQImage ( const KoColorProfile * dstProfile,
qint32 x,
qint32 y,
qint32 w,
qint32 h,
KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(),
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags() ) const

Create an RGBA QImage from a rectangle in the paint device.

Parameters
dstProfileRGB profile to use in conversion. May be 0, in which case it's up to the color strategy to choose a profile (most like sRGB).
xLeft coordinate of the rectangle
yTop coordinate of the rectangle
wWidth of the rectangle in pixels
hHeight of the rectangle in pixels
renderingIntentRendering intent
conversionFlagsConversion flags

Definition at line 1651 of file kis_paint_device.cc.

1652{
1653
1654 if (w < 0)
1655 return QImage();
1656
1657 if (h < 0)
1658 return QImage();
1659
1660 quint8 *data = 0;
1661 try {
1662 data = new quint8 [w * h * pixelSize()];
1663 } catch (const std::bad_alloc&) {
1664 warnKrita << "KisPaintDevice::convertToQImage std::bad_alloc for " << w << " * " << h << " * " << pixelSize();
1665 //delete[] data; // data is not allocated, so don't free it
1666 return QImage();
1667 }
1668 Q_CHECK_PTR(data);
1669
1670 // XXX: Is this really faster than converting line by line and building the QImage directly?
1671 // This copies potentially a lot of data.
1672 readBytes(data, x1, y1, w, h);
1673 QImage image = colorSpace()->convertToQImage(data, w, h, dstProfile, renderingIntent, conversionFlags);
1674 delete[] data;
1675
1676 return image;
1677}
void readBytes(quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h) const
virtual QImage convertToQImage(const quint8 *data, qint32 width, qint32 height, const KoColorProfile *dstProfile, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const

References colorSpace(), KoColorSpace::convertToQImage(), pixelSize(), readBytes(), and warnKrita.

◆ createChangeInterstrokeDataCommand()

KUndo2Command * KisPaintDevice::createChangeInterstrokeDataCommand ( KisInterstrokeDataSP data)

set interstroke data to the device

Interstroke data is managed by KisTransaction, don't call this method manually unless you really know what you are doing.

See also
interstrokeData()

Definition at line 2042 of file kis_paint_device.cc.

2043{
2045}
KUndo2Command * createChangeInterstrokeDataCommand(KisInterstrokeDataSP value)

References KisPaintDevice::Private::createChangeInterstrokeDataCommand(), and m_d.

◆ createCompositionSourceDevice() [1/3]

KisPaintDeviceSP KisPaintDevice::createCompositionSourceDevice ( ) const

There is quite a common technique in Krita. It is used in cases, when we want to paint something over a paint device using the composition, opacity or selection. E.g. painting a dab in a paint op, filling the selection in the Fill Tool. Such work is usually done in the following way:

1) Create a paint device

2) Fill it with the desired color or data

3) Create a KisPainter and set all the properties of the transaction: selection, compositeOp, opacity and etc.

4) Paint a newly created paint device over the destination device.

The following two methods (createCompositionSourceDevice() or createCompositionSourceDeviceFixed())should be used for the accomplishing the step 1). The point is that the desired color space of the temporary device may not coincide with the color space of the destination. That is the case, for example, for the alpha8() colorspace used in the selections. So for such devices the temporary target would have a different (grayscale) color space.

So there are two rules of thumb:

1) If you need a temporary device which you are going to fill with some data and then paint over the paint device, create it with either createCompositionSourceDevice() or createCompositionSourceDeviceFixed().

2) Do not expect that the color spaces of the destination and the temporary device would coincide. If you need to copy a single pixel from one device to another, you can use KisCrossDeviceColorSampler class, that will handle all the necessary conversions for you.

See also
createCompositionSourceDeviceFixed()
compositionSourceColorSpace()
KisCrossDeviceColorSampler
KisCrossDeviceColorSamplerInt

Definition at line 2081 of file kis_paint_device.cc.

2082{
2086 return device;
2087}
bool supportsWraproundMode() const
void setDefaultBounds(KisDefaultBoundsBaseSP bounds)
virtual const KoColorSpace * compositionSourceColorSpace() const
void setSupportsWraparoundMode(bool value)

References compositionSourceColorSpace(), defaultBounds(), KisPaintDevice(), setDefaultBounds(), setSupportsWraparoundMode(), and supportsWraproundMode().

◆ createCompositionSourceDevice() [2/3]

KisPaintDeviceSP KisPaintDevice::createCompositionSourceDevice ( KisPaintDeviceSP cloneSource) const

The same as createCompositionSourceDevice(), but initializes the newly created device with the content of cloneSource

See also
createCompositionSourceDevice()

Definition at line 2089 of file kis_paint_device.cc.

2090{
2091 KisPaintDeviceSP clone = new KisPaintDevice(*cloneSource);
2097 return clone;
2098}
void convertTo(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags(), KUndo2Command *parentCommand=nullptr, KoUpdater *progressUpdater=nullptr)

References compositionSourceColorSpace(), convertTo(), defaultBounds(), KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), KisPaintDevice(), setDefaultBounds(), setSupportsWraparoundMode(), and supportsWraproundMode().

◆ createCompositionSourceDevice() [3/3]

KisPaintDeviceSP KisPaintDevice::createCompositionSourceDevice ( KisPaintDeviceSP cloneSource,
const QRect roughRect ) const

The same as createCompositionSourceDevice(), but initializes the newly created device with the rough roughRect of cloneSource.

"Rough rect" means that it may copy a bit more than requested. It is expected that the caller will not use the area outside roughRect.

See also
createCompositionSourceDevice()

Definition at line 2100 of file kis_paint_device.cc.

2101{
2105 clone->makeCloneFromRough(cloneSource, roughRect);
2109 return clone;
2110}
void makeCloneFromRough(KisPaintDeviceSP src, const QRect &minimalRect)

References colorSpace(), compositionSourceColorSpace(), convertTo(), defaultBounds(), KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), KisPaintDevice(), makeCloneFromRough(), setDefaultBounds(), setSupportsWraparoundMode(), and supportsWraproundMode().

◆ createCompositionSourceDeviceFixed()

KisFixedPaintDeviceSP KisPaintDevice::createCompositionSourceDeviceFixed ( ) const

◆ createHLineConstIteratorNG()

KisHLineConstIteratorSP KisPaintDevice::createHLineConstIteratorNG ( qint32 x,
qint32 y,
qint32 w ) const

◆ createHLineIteratorNG()

KisHLineIteratorSP KisPaintDevice::createHLineIteratorNG ( qint32 x,
qint32 y,
qint32 w )

◆ createKeyframeChannel()

KisRasterKeyframeChannel * KisPaintDevice::createKeyframeChannel ( const KoID & id)

Create a keyframe channel for the content on this device.

Parameters
ididentifier for the channel
Returns
keyframe channel or 0 if there is not one

Definition at line 2047 of file kis_paint_device.cc.

2048{
2049 Q_ASSERT(!m_d->framesInterface);
2051
2052 Q_ASSERT(!m_d->contentChannel);
2053 if (m_d->parent.isValid()) {
2055 } else {
2056 //fallback when paint device is isolated / does not belong to a node.
2058 }
2059
2060 // Raster channels always have at least one frame (representing a static image)
2061 KUndo2Command tempParentCommand;
2062 m_d->contentChannel->addKeyframe(0);
2063
2064 return m_d->contentChannel.data();
2065}
friend class KisPaintDeviceFramesInterface
The KisRasterKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisRas...
bool isValid() const
KisDefaultBoundsBaseSP defaultBounds

References KisPaintDevice::Private::contentChannel, KisPaintDevice::Private::defaultBounds, KisPaintDevice::Private::framesInterface, KisWeakSharedPtr< T >::isValid(), KisPaintDeviceFramesInterface, m_d, and KisPaintDevice::Private::parent.

◆ createLodDataStruct()

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

Definition at line 2153 of file kis_paint_device.cc.

2154{
2155 return m_d->createLodDataStruct(lod);
2156}
LodDataStruct * createLodDataStruct(int lod)

References KisPaintDevice::Private::createLodDataStruct(), and m_d.

◆ createMemoryReleaseObject()

KisPaintDevice::MemoryReleaseObject * KisPaintDevice::createMemoryReleaseObject ( )
static

Definition at line 2139 of file kis_paint_device.cc.

2140{
2141 return new MemoryReleaseObject();
2142}

◆ createRandomAccessorNG()

◆ createRandomConstAccessorNG()

KisRandomConstAccessorSP KisPaintDevice::createRandomConstAccessorNG ( ) const

◆ createRandomSubAccessor()

KisRandomSubAccessorSP KisPaintDevice::createRandomSubAccessor ( ) const

This function create a random accessor which can easily access to sub pixel values.

Definition at line 1869 of file kis_paint_device.cc.

1870{
1871 KisPaintDevice* pd = const_cast<KisPaintDevice*>(this);
1872 return new KisRandomSubAccessor(pd);
1873}

◆ createRepeatHLineConstIterator()

KisRepeatHLineConstIteratorSP KisPaintDevice::createRepeatHLineConstIterator ( qint32 x,
qint32 y,
qint32 w,
const QRect & _dataWidth ) const

Create an iterator that will "artificially" extend the paint device with the value of the border when trying to access values outside the range of data.

Parameters
xx of top left corner
yy of top left corner
wwidth of the border
_dataWidthindicates the rectangle that truly contains data

Definition at line 1848 of file kis_paint_device.cc.

1849{
1850 return new KisRepeatHLineConstIteratorNG(m_d->dataManager().data(), x, y, w, m_d->x(), m_d->y(), _dataWidth, m_d->cacheInvalidator());
1851}
KisRepeatHLineIteratorPixelBase< KisHLineIterator2 > KisRepeatHLineConstIteratorNG
Definition kis_types.h:199
KisIteratorCompleteListener * cacheInvalidator()

References KisPaintDevice::Private::cacheInvalidator(), KisSharedPtr< T >::data(), KisPaintDevice::Private::dataManager(), m_d, KisPaintDevice::Private::x(), x(), KisPaintDevice::Private::y(), and y().

◆ createRepeatVLineConstIterator()

KisRepeatVLineConstIteratorSP KisPaintDevice::createRepeatVLineConstIterator ( qint32 x,
qint32 y,
qint32 h,
const QRect & _dataWidth ) const

Create an iterator that will "artificially" extend the paint device with the value of the border when trying to access values outside the range of data.

Parameters
xx of top left corner
yy of top left corner
hheight of the border
_dataWidthindicates the rectangle that truly contains data

Definition at line 1853 of file kis_paint_device.cc.

1854{
1855 return new KisRepeatVLineConstIteratorNG(m_d->dataManager().data(), x, y, h, m_d->x(), m_d->y(), _dataWidth, m_d->cacheInvalidator());
1856}
KisRepeatVLineIteratorPixelBase< KisVLineIterator2 > KisRepeatVLineConstIteratorNG
Definition kis_types.h:204

References KisPaintDevice::Private::cacheInvalidator(), KisSharedPtr< T >::data(), KisPaintDevice::Private::dataManager(), m_d, KisPaintDevice::Private::x(), x(), KisPaintDevice::Private::y(), and y().

◆ createThumbnail() [1/3]

QImage KisPaintDevice::createThumbnail ( qint32 maxw,
qint32 maxh,
qreal oversample = 1,
KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(),
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags() )

Cached version of createThumbnail(qint32 maxw, qint32 maxh, const KisSelection *selection, QRect rect)

Definition at line 1808 of file kis_paint_device.cc.

1809{
1810 QSize size = fixThumbnailSize(QSize(w, h));
1811
1812 return m_d->cache()->createThumbnail(size.width(), size.height(), oversample, renderingIntent, conversionFlags);
1813}
const qreal oversample
QImage createThumbnail(qint32 w, qint32 h, qreal oversample, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
QSize fixThumbnailSize(QSize size)
int size(const Forest< T > &forest)
Definition KisForest.h:1232

References KisPaintDevice::Private::cache(), KisPaintDeviceCache::createThumbnail(), fixThumbnailSize(), m_d, and oversample.

◆ createThumbnail() [2/3]

QImage KisPaintDevice::createThumbnail ( qint32 maxw,
qint32 maxh,
QRect rect,
qreal oversample = 1,
KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(),
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags() )

Creates a thumbnail of the paint device, retaining the aspect ratio. The width and height of the returned QImage won't exceed maxw and maxw, but they may be smaller. The colors are not corrected for display!

Parameters
maxwmaximum width
maxhmaximum height
rectonly this rect will be used for the thumbnail
oversampleratio used for antialiasing
renderingIntentRendering intent
conversionFlagsConversion flags

Definition at line 1799 of file kis_paint_device.cc.

1800{
1801 QSize size = fixThumbnailSize(QSize(w, h));
1802
1804 QImage thumbnail = dev->convertToQImage(KoColorSpaceRegistry::instance()->rgb8()->profile(), 0, 0, w, h, renderingIntent, conversionFlags);
1805 return thumbnail;
1806}
KisPaintDeviceSP createThumbnailDeviceOversampled(qint32 w, qint32 h, qreal oversample, QRect rect=QRect(), QRect outputRect=QRect()) const

References convertToQImage(), createThumbnailDeviceOversampled(), fixThumbnailSize(), KoColorSpaceRegistry::instance(), and oversample.

◆ createThumbnail() [3/3]

QImage KisPaintDevice::createThumbnail ( qint32 maxw,
qint32 maxh,
Qt::AspectRatioMode aspectRatioMode,
qreal oversample = 1,
KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(),
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags() )

Cached version of createThumbnail that also adjusts aspect ratio of the thumbnail to fit the extents of the paint device.

Definition at line 1815 of file kis_paint_device.cc.

1819{
1820 const QRect deviceExtent = exactBounds();
1821 const QSize thumbnailSize = deviceExtent.size().scaled(maxw, maxh, aspectRatioMode);
1822 return createThumbnail(thumbnailSize.width(), thumbnailSize.height(),
1823 oversample, renderingIntent, conversionFlags);
1824}
QImage createThumbnail(qint32 maxw, qint32 maxh, QRect rect, qreal oversample=1, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags())

References createThumbnail(), exactBounds(), and oversample.

◆ createThumbnailDevice()

KisPaintDeviceSP KisPaintDevice::createThumbnailDevice ( qint32 w,
qint32 h,
QRect rect = QRect(),
QRect outputRect = QRect() ) const

Creates a paint device thumbnail of the paint device, retaining the aspect ratio. The width and height of the returned device won't exceed maxw and maxw, but they may be smaller.

Parameters
wmaximum width
hmaximum height
rectonly this rect will be used for the thumbnail
outputRectoutput rectangle

Definition at line 1724 of file kis_paint_device.cc.

1725{
1726 QSize thumbnailSize(w, h);
1727
1728 QRect imageRect = rect.isValid() ? rect : extent();
1729
1730 if ((thumbnailSize.width() > imageRect.width()) || (thumbnailSize.height() > imageRect.height())) {
1731 thumbnailSize.scale(imageRect.size(), Qt::KeepAspectRatio);
1732 }
1733
1734 thumbnailSize = fixThumbnailSize(thumbnailSize);
1735
1736 //can't create thumbnail for an empty device, e.g. layer thumbnail for empty image
1737 if (imageRect.isEmpty() || thumbnailSize.isEmpty()) {
1738 return new KisPaintDevice(colorSpace());
1739 }
1740
1741 int srcWidth, srcHeight;
1742 int srcX0, srcY0;
1743 imageRect.getRect(&srcX0, &srcY0, &srcWidth, &srcHeight);
1744
1745 if (!outputRect.isValid()) {
1746 outputRect = QRect(0, 0, w, h);
1747 }
1748
1749 KisPaintDeviceSP thumbnail = createThumbnailDeviceInternal(this, imageRect.x(), imageRect.y(), imageRect.width(), imageRect.height(),
1750 thumbnailSize.width(), thumbnailSize.height(), outputRect);
1751
1752 return thumbnail;
1753}
static KisPaintDeviceSP createThumbnailDeviceInternal(const KisPaintDevice *srcDev, qint32 srcX0, qint32 srcY0, qint32 srcWidth, qint32 srcHeight, qint32 w, qint32 h, QRect outputRect)

References colorSpace(), createThumbnailDeviceInternal(), extent(), fixThumbnailSize(), and KisPaintDevice().

◆ createThumbnailDeviceOversampled()

KisPaintDeviceSP KisPaintDevice::createThumbnailDeviceOversampled ( qint32 w,
qint32 h,
qreal oversample,
QRect rect = QRect(),
QRect outputRect = QRect() ) const

Definition at line 1755 of file kis_paint_device.cc.

1756{
1757 QSize thumbnailSize(w, h);
1758 qreal oversampleAdjusted = qMax(oversample, 1.);
1759 QSize thumbnailOversampledSize = oversampleAdjusted * thumbnailSize;
1760
1761 QRect outputRect;
1762 QRect imageRect = rect.isValid() ? rect : extent();
1763
1764 qint32 hstart = thumbnailOversampledSize.height();
1765
1766 if ((thumbnailOversampledSize.width() > imageRect.width()) || (thumbnailOversampledSize.height() > imageRect.height())) {
1767 thumbnailOversampledSize.scale(imageRect.size(), Qt::KeepAspectRatio);
1768 }
1769
1770 thumbnailOversampledSize = fixThumbnailSize(thumbnailOversampledSize);
1771
1772 //can't create thumbnail for an empty device, e.g. layer thumbnail for empty image
1773 if (imageRect.isEmpty() || thumbnailSize.isEmpty() || thumbnailOversampledSize.isEmpty()) {
1774 return new KisPaintDevice(colorSpace());
1775 }
1776
1777 oversampleAdjusted *= (hstart > 0) ? ((qreal)thumbnailOversampledSize.height() / hstart) : 1.; //readjusting oversample ratio, given that we had to adjust thumbnail size
1778
1779 outputRect = QRect(0, 0, thumbnailOversampledSize.width(), thumbnailOversampledSize.height());
1780
1781 if (outputTileRect.isValid()) {
1782 //compensating output rectangle for oversampling
1783 outputTileRect = QRect(oversampleAdjusted * outputTileRect.topLeft(), oversampleAdjusted * outputTileRect.bottomRight());
1784 outputRect = outputRect.intersected(outputTileRect);
1785 }
1786
1787 KisPaintDeviceSP thumbnail = createThumbnailDeviceInternal(this, imageRect.x(), imageRect.y(), imageRect.width(), imageRect.height(),
1788 thumbnailOversampledSize.width(), thumbnailOversampledSize.height(), outputRect);
1789
1790 if (oversample != 1. && oversampleAdjusted != 1.) {
1791 KoDummyUpdaterHolder updaterHolder;
1792 KisTransformWorker worker(thumbnail, 1 / oversampleAdjusted, 1 / oversampleAdjusted, 0.0, 0.0, 0.0, 0.0, 0.0,
1793 updaterHolder.updater(), KisFilterStrategyRegistry::instance()->value("Bilinear"));
1794 worker.run();
1795 }
1796 return thumbnail;
1797}
static KisFilterStrategyRegistry * instance()
A holder for an updater that does nothing.
Definition KoUpdater.h:116
KoUpdater * updater()
const T value(const QString &id) const

References colorSpace(), createThumbnailDeviceInternal(), extent(), fixThumbnailSize(), KisFilterStrategyRegistry::instance(), KisPaintDevice(), oversample, KisTransformWorker::run(), KoDummyUpdaterHolder::updater(), and KoGenericRegistry< T >::value().

◆ createVLineConstIteratorNG()

KisVLineConstIteratorSP KisPaintDevice::createVLineConstIteratorNG ( qint32 x,
qint32 y,
qint32 h ) const

◆ createVLineIteratorNG()

KisVLineIteratorSP KisPaintDevice::createVLineIteratorNG ( qint32 x,
qint32 y,
qint32 h )

◆ crop() [1/2]

void KisPaintDevice::crop ( const QRect & r)

Convenience method for the above.

Definition at line 1498 of file kis_paint_device.cc.

1499{
1501}

References KisPaintDevice::Private::KisPaintDeviceStrategy::crop(), KisPaintDevice::Private::currentStrategy(), and m_d.

◆ crop() [2/2]

void KisPaintDevice::crop ( qint32 x,
qint32 y,
qint32 w,
qint32 h )

Cut the paint device down to the specified rect. If the crop area is bigger than the paint device, nothing will happen.

Definition at line 1492 of file kis_paint_device.cc.

1493{
1494 crop(QRect(x, y, w, h));
1495}
void crop(qint32 x, qint32 y, qint32 w, qint32 h)

References crop(), x(), and y().

◆ dataManager()

KisDataManagerSP KisPaintDevice::dataManager ( ) const
Returns
the internal datamanager that keeps the pixels.

Definition at line 1590 of file kis_paint_device.cc.

1591{
1592 return m_d->dataManager();
1593}

References KisPaintDevice::Private::dataManager(), and m_d.

◆ defaultBounds()

KisDefaultBoundsBaseSP KisPaintDevice::defaultBounds ( ) const

the default bounds rect of the paint device

Definition at line 1212 of file kis_paint_device.cc.

1213{
1214 return m_d->defaultBounds;
1215}

References KisPaintDevice::Private::defaultBounds, and m_d.

◆ defaultPixel()

KoColor KisPaintDevice::defaultPixel ( ) const

Get a pointer to the default pixel. If the frame parameter is given, get the default pixel of specified frame. Otherwise use currently active frame.

Definition at line 1518 of file kis_paint_device.cc.

1519{
1521}
const quint8 * defaultPixel() const

References colorSpace(), KisPaintDevice::Private::dataManager(), KisDataManager::defaultPixel(), and m_d.

◆ emitColorSpaceChanged()

void KisPaintDevice::emitColorSpaceChanged ( )
private

Definition at line 1561 of file kis_paint_device.cc.

1562{
1563 Q_EMIT colorSpaceChanged(m_d->colorSpace());
1564}
void colorSpaceChanged(const KoColorSpace *colorspace)

References KisPaintDevice::Private::colorSpace(), colorSpaceChanged(), and m_d.

◆ emitProfileChanged()

void KisPaintDevice::emitProfileChanged ( )
private

Definition at line 1566 of file kis_paint_device.cc.

1567{
1568 Q_EMIT profileChanged(m_d->colorSpace()->profile());
1569}
void profileChanged(const KoColorProfile *profile)
virtual const KoColorProfile * profile() const =0

References KisPaintDevice::Private::colorSpace(), m_d, KoColorSpace::profile(), and profileChanged().

◆ estimateMemoryStats()

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

Definition at line 1189 of file kis_paint_device.cc.

1190{
1191 m_d->estimateMemoryStats(imageData, temporaryData, lodData);
1192}
void estimateMemoryStats(qint64 &imageData, qint64 &temporaryData, qint64 &lodData) const

References KisPaintDevice::Private::estimateMemoryStats(), and m_d.

◆ exactBounds()

QRect KisPaintDevice::exactBounds ( ) const

Get the exact bounds of this paint device. The real solution is very slow because it does a linear scanline search, but it uses caching, so calling to this function without changing the device is quite cheap.

exactBounds follows these rules:

See also
calculateExactBounds()

Definition at line 1277 of file kis_paint_device.cc.

1278{
1279 return m_d->cache()->exactBounds();
1280}

References KisPaintDevice::Private::cache(), KisPaintDeviceCache::exactBounds(), and m_d.

◆ exactBoundsAmortized()

QRect KisPaintDevice::exactBoundsAmortized ( ) const

Relaxed version of the exactBounds() that can be used in tight loops. If the exact bounds value is present in the paint device cache, returns this value. If the cache is invalidated, returns extent() and tries to recalculate the exact bounds not faster than once in 1000 ms.

Definition at line 1282 of file kis_paint_device.cc.

1283{
1284 return m_d->cache()->exactBoundsAmortized();
1285}

References KisPaintDevice::Private::cache(), KisPaintDeviceCache::exactBoundsAmortized(), and m_d.

◆ extent() [1/2]

QRect KisPaintDevice::extent ( ) const

Retrieve the bounds of the paint device. The size is not exact, but may be larger if the underlying datamanager works that way. For instance, the tiled datamanager keeps the extent to the nearest multiple of 64.

If default pixel is not transparent, then the actual extent rect is united with the defaultBounds()->bounds() value (the size of the image, usually).

Definition at line 1262 of file kis_paint_device.cc.

1263{
1264 return m_d->currentStrategy()->extent();
1265}

References KisPaintDevice::Private::currentStrategy(), KisPaintDevice::Private::KisPaintDeviceStrategy::extent(), and m_d.

◆ extent() [2/2]

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

Convenience method for the above.

Definition at line 1253 of file kis_paint_device.cc.

1254{
1255 QRect rc = extent();
1256 x = rc.x();
1257 y = rc.y();
1258 w = rc.width();
1259 h = rc.height();
1260}

References extent(), x(), and y().

◆ fastBitBlt()

void KisPaintDevice::fastBitBlt ( KisPaintDeviceSP src,
const QRect & rect )
protected

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

See also
fastBitBltPossible
fastBitBltRough

Definition at line 1972 of file kis_paint_device.cc.

1973{
1975}
virtual void fastBitBlt(KisPaintDeviceSP src, const QRect &rect)

References KisPaintDevice::Private::currentStrategy(), KisPaintDevice::Private::KisPaintDeviceStrategy::fastBitBlt(), and m_d.

◆ fastBitBltOldData()

void KisPaintDevice::fastBitBltOldData ( KisPaintDeviceSP src,
const QRect & rect )
protected

The same as fastBitBlt() but reads old data

Definition at line 1977 of file kis_paint_device.cc.

1978{
1980}
virtual void fastBitBltOldData(KisPaintDeviceSP src, const QRect &rect)

References KisPaintDevice::Private::currentStrategy(), KisPaintDevice::Private::KisPaintDeviceStrategy::fastBitBltOldData(), and m_d.

◆ fastBitBltPossible()

bool KisPaintDevice::fastBitBltPossible ( KisPaintDeviceSP src)
protected

Checks whether a src paint device can be used as source of fast bitBlt operation. The result of the check may depend on whether color spaces coincide, whether there is any shift of tiles between the devices and etc.

WARNING: This check must be done before performing any fast bitBlt operation!

See also
fastBitBlt
fastBitBltRough

Definition at line 1967 of file kis_paint_device.cc.

1968{
1969 return m_d->fastBitBltPossible(src);
1970}
bool fastBitBltPossible(KisPaintDeviceSP src)

References KisPaintDevice::Private::fastBitBltPossible(), and m_d.

◆ fastBitBltRough()

void KisPaintDevice::fastBitBltRough ( KisPaintDeviceSP src,
const QRect & rect )
protected

Clones rect from another paint device 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.

See also
fastBitBltPossible
fastBitBlt

Definition at line 1982 of file kis_paint_device.cc.

1983{
1985}
virtual void fastBitBltRough(KisPaintDeviceSP src, const QRect &rect)

References KisPaintDevice::Private::currentStrategy(), KisPaintDevice::Private::KisPaintDeviceStrategy::fastBitBltRough(), and m_d.

◆ fastBitBltRoughOldData()

void KisPaintDevice::fastBitBltRoughOldData ( KisPaintDeviceSP src,
const QRect & rect )
protected

The same as fastBitBltRough() but reads old data

Definition at line 1987 of file kis_paint_device.cc.

1988{
1990}
virtual void fastBitBltRoughOldData(KisPaintDeviceSP src, const QRect &rect)

References KisPaintDevice::Private::currentStrategy(), KisPaintDevice::Private::KisPaintDeviceStrategy::fastBitBltRoughOldData(), and m_d.

◆ fill() [1/2]

void KisPaintDevice::fill ( const QRect & rc,
const KoColor & color )

Fill the given rectangle with the given pixel. The paint device will expand to contain the given rect.

Definition at line 1534 of file kis_paint_device.cc.

1535{
1537 m_d->currentStrategy()->fill(rc, color.data());
1538}
virtual void fill(const QRect &rc, const quint8 *fillPixel)
const KoColorSpace * colorSpace() const
return the current colorSpace
Definition KoColor.h:82
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75

References colorSpace(), KoColor::colorSpace(), KisPaintDevice::Private::currentStrategy(), KoColor::data(), KisPaintDevice::Private::KisPaintDeviceStrategy::fill(), KIS_ASSERT_RECOVER_RETURN, and m_d.

◆ fill() [2/2]

void KisPaintDevice::fill ( qint32 x,
qint32 y,
qint32 w,
qint32 h,
const quint8 * fillPixel )

Overloaded function. For legacy purposes only. Please use fill(const QRect & rc, const KoColor &color) instead

Definition at line 1540 of file kis_paint_device.cc.

1541{
1542 m_d->currentStrategy()->fill(QRect(x, y, w, h), fillPixel);
1543}

References KisPaintDevice::Private::currentStrategy(), KisPaintDevice::Private::KisPaintDeviceStrategy::fill(), m_d, x(), and y().

◆ framesInterface()

KisPaintDeviceFramesInterface * KisPaintDevice::framesInterface ( )

An interface to modify/load/save frames stored inside this device

Definition at line 2183 of file kis_paint_device.cc.

2184{
2185 return m_d->framesInterface.data();
2186}

References KisPaintDevice::Private::framesInterface, and m_d.

◆ generateLodCloneDevice()

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

Definition at line 2168 of file kis_paint_device.cc.

2169{
2170 m_d->generateLodCloneDevice(dst, originalRect, lod);
2171}
void generateLodCloneDevice(KisPaintDeviceSP dst, const QRect &originalRect, int lod)

References KisPaintDevice::Private::generateLodCloneDevice(), and m_d.

◆ init()

void KisPaintDevice::init ( const KoColorSpace * colorSpace,
KisDefaultBoundsBaseSP defaultBounds,
KisNodeWSP parent,
const QString & name )
private

Definition at line 1057 of file kis_paint_device.cc.

1060{
1061 Q_ASSERT(colorSpace);
1062 setObjectName(name);
1063
1064 // temporary def. bounds object for the initialization phase only
1066
1067 if (!defaultBounds) {
1068 // Reuse transitionalDefaultBounds here. Change if you change
1069 // semantics of transitionalDefaultBounds
1071 }
1072
1074 m_d->init(colorSpace, color.data());
1075
1076 Q_ASSERT(m_d->colorSpace());
1077
1079 setParentNode(parent);
1080}
void setParentNode(KisNodeWSP parent)
static KoColor createTransparent(const KoColorSpace *cs)
Definition KoColor.cpp:681
void init(const KoColorSpace *cs, const quint8 *defaultPixel)
static const KisDefaultBoundsSP transitionalDefaultBounds

References KisPaintDevice::Private::colorSpace(), colorSpace(), KoColor::createTransparent(), KoColor::data(), KisPaintDevice::Private::defaultBounds, defaultBounds(), KisPaintDevice::Private::init(), m_d, setDefaultBounds(), setParentNode(), and KisPaintDevice::Private::transitionalDefaultBounds.

◆ interstrokeData()

KisInterstrokeDataSP KisPaintDevice::interstrokeData ( ) const
Returns
interstroke data that is attached to the paint device.

This data is managed by KisTransaction and can be used by brushes to store some data that can be shared between the strokes. For example, information about drying of the pigment.

The interstroke data is stored in a per-frame manner, that is, there is a separate per-stroke data for each frame.

Definition at line 2037 of file kis_paint_device.cc.

2038{
2039 return m_d->interstrokeData();
2040}
KisInterstrokeDataSP interstrokeData() const

References KisPaintDevice::Private::interstrokeData(), and m_d.

◆ keyframeChannel()

KisRasterKeyframeChannel * KisPaintDevice::keyframeChannel ( ) const

Definition at line 2067 of file kis_paint_device.cc.

2068{
2069 if (m_d->contentChannel) {
2070 return m_d->contentChannel.data();
2071 }
2072 return 0;
2073}

References KisPaintDevice::Private::contentChannel, and m_d.

◆ makeCloneFrom()

void KisPaintDevice::makeCloneFrom ( KisPaintDeviceSP src,
const QRect & rect )

Make this device to become a clone of src. It will have the same x,y shifts, colorspace and will share pixels inside rect. After calling this function: (this->extent() >= this->exactBounds() == rect).

Rule of thumb:

"Use makeCloneFrom() or makeCloneFromRough() if and only if you are the only owner of the destination paint device and you are 100% sure no other thread has access to it"

Definition at line 1127 of file kis_paint_device.cc.

1128{
1129 prepareClone(src);
1130
1131 // we guarantee that *this is totally empty, so copy pixels that
1132 // are areally present on the source image only
1133 const QRect optimizedRect = rect & src->extent();
1134
1135 fastBitBlt(src, optimizedRect);
1136}
void prepareClone(KisPaintDeviceSP src)
void fastBitBlt(KisPaintDeviceSP src, const QRect &rect)

References fastBitBlt(), and prepareClone().

◆ makeCloneFromRough()

void KisPaintDevice::makeCloneFromRough ( KisPaintDeviceSP src,
const QRect & minimalRect )

Make this device to become a clone of src. It will have the same x,y shifts, colorspace and will share pixels inside rect. Be careful, this function will copy at least rect of pixels. Actual copy area will be a bigger - it will be aligned by tiles borders. So after calling this function: (this->extent() == this->exactBounds() >= rect).

Rule of thumb:

"Use makeCloneFrom() or makeCloneFromRough() if and only if you are the only owner of the destination paint device and you are 100% sure no other thread has access to it"

Definition at line 1138 of file kis_paint_device.cc.

1139{
1140 prepareClone(src);
1141
1142 // we guarantee that *this is totally empty, so copy pixels that
1143 // are areally present on the source image only
1144 const QRect optimizedRect = minimalRect & src->extent();
1145
1146 fastBitBltRough(src, optimizedRect);
1147}
void fastBitBltRough(KisPaintDeviceSP src, const QRect &rect)

References fastBitBltRough(), and prepareClone().

◆ makeFullCopyFrom()

void KisPaintDevice::makeFullCopyFrom ( const KisPaintDevice & rhs,
KritaUtils::DeviceCopyMode copyMode = KritaUtils::CopySnapshot,
KisNode * newParentNode = 0 )

Definition at line 1092 of file kis_paint_device.cc.

1093{
1094 // temporary def. bounds object for the initialization phase only
1096
1097 // copy data objects with or without frames
1099
1100 if (copyMode == KritaUtils::CopyAllFrames && rhs.m_d->framesInterface) {
1104 m_d->contentChannel.reset(new KisRasterKeyframeChannel(*rhs.m_d->contentChannel.data(), this));
1105 }
1106
1109 setParentNode(newParentNode);
1110}
void cloneAllDataObjects(Private *rhs, bool copyFrames)

References KisPaintDevice::Private::cloneAllDataObjects(), KisPaintDevice::Private::contentChannel, KritaUtils::CopyAllFrames, KisPaintDevice::Private::defaultBounds, KisPaintDevice::Private::framesInterface, KIS_ASSERT_RECOVER_RETURN, KisPaintDeviceFramesInterface, m_d, setDefaultBounds(), setParentNode(), KisPaintDevice::Private::supportsWrapAroundMode, and KisPaintDevice::Private::transitionalDefaultBounds.

◆ moveTo() [1/2]

void KisPaintDevice::moveTo ( const QPoint & pt)
virtual

◆ moveTo() [2/2]

void KisPaintDevice::moveTo ( qint32 x,
qint32 y )

Moves the device to these new coordinates (no incremental move)

Definition at line 1228 of file kis_paint_device.cc.

1229{
1230 moveTo(QPoint(x, y));
1231}
void moveTo(qint32 x, qint32 y)

References moveTo(), x(), and y().

◆ nonDefaultPixelArea()

QRect KisPaintDevice::nonDefaultPixelArea ( ) const

Returns exact rectangle of the paint device that contains non-default pixels. For paint devices with fully transparent default pixel is equivalent to exactBounds().

nonDefaultPixelArea() follows these rules:

  • if default pixel is transparent, then exact bounds of actual pixel data are returned. The same as exactBounds()
  • if default pixel is not transparent, then calculates the rectangle of non-default pixels. May be smaller or greater than image bounds
See also
calculateExactBounds()

Definition at line 1272 of file kis_paint_device.cc.

1273{
1274 return m_d->cache()->nonDefaultPixelArea();
1275}

References KisPaintDevice::Private::cache(), m_d, and KisPaintDeviceCache::nonDefaultPixelArea().

◆ offset()

QPoint KisPaintDevice::offset ( ) const

Return an X,Y offset of the device in a convenient form

Definition at line 1223 of file kis_paint_device.cc.

1224{
1225 return QPoint(x(), y());
1226}

References x(), and y().

◆ operator=()

KisPaintDevice & KisPaintDevice::operator= ( const KisPaintDevice & )
private

◆ parentNode()

KisNodeWSP KisPaintDevice::parentNode ( ) const
protected

Definition at line 1201 of file kis_paint_device.cc.

1202{
1203 return m_d->parent;
1204}

References m_d, and KisPaintDevice::Private::parent.

◆ pixel() [1/3]

KoColor KisPaintDevice::pixel ( const QPoint & pos) const

Return pixel value in a form of KoColor. Please don't use this method for iteration, it is highly inefficient. Use iterators instead.

Definition at line 1936 of file kis_paint_device.cc.

1937{
1938 KisHLineConstIteratorSP iter = createHLineConstIteratorNG(pos.x(), pos.y(), 1);
1939 return KoColor(iter->rawDataConst(), m_d->colorSpace());
1940}

References KisPaintDevice::Private::colorSpace(), createHLineConstIteratorNG(), m_d, and KisBaseConstAccessor::rawDataConst().

◆ pixel() [2/3]

bool KisPaintDevice::pixel ( qint32 x,
qint32 y,
KoColor * kc ) const

Fill kc with the values found at x and y. This method differs from the above in using KoColor, which can be of any colorspace

The color values will be transformed from the profile of this paint device to the display profile.

Returns
true if the operation was successful.

Definition at line 1923 of file kis_paint_device.cc.

1924{
1926
1927 const quint8 *pix = iter->rawDataConst();
1928
1929 if (!pix) return false;
1930
1931 kc->setColor(pix, m_d->colorSpace());
1932
1933 return true;
1934}
void setColor(const quint8 *data, const KoColorSpace *colorSpace=0)
Definition KoColor.cpp:186

References KisPaintDevice::Private::colorSpace(), createHLineConstIteratorNG(), m_d, KisBaseConstAccessor::rawDataConst(), KoColor::setColor(), x(), and y().

◆ pixel() [3/3]

bool KisPaintDevice::pixel ( qint32 x,
qint32 y,
QColor * c ) const

Fill c and opacity with the values found at x and y.

The color values will be transformed from the profile of this paint device to the display profile.

Returns
true if the operation was successful.

Definition at line 1909 of file kis_paint_device.cc.

1910{
1912
1913 const quint8 *pix = iter->rawDataConst();
1914
1915 if (!pix) return false;
1916
1917 colorSpace()->toQColor(pix, c);
1918
1919 return true;
1920}
virtual void toQColor(const quint8 *src, QColor *c) const =0

References colorSpace(), createHLineConstIteratorNG(), KisBaseConstAccessor::rawDataConst(), KoColorSpace::toQColor(), x(), and y().

◆ pixelSize()

quint32 KisPaintDevice::pixelSize ( ) const

Return the number of bytes a pixel takes.

Definition at line 2023 of file kis_paint_device.cc.

2024{
2025 quint32 _pixelSize = m_d->colorSpace()->pixelSize();
2026 Q_ASSERT(_pixelSize > 0);
2027 return _pixelSize;
2028}

References KisPaintDevice::Private::colorSpace(), m_d, and KoColorSpace::pixelSize().

◆ prepareClone()

void KisPaintDevice::prepareClone ( KisPaintDeviceSP src)

Prepares the device for fastBitBlt operation. It clears the device, switches x,y shifts and colorspace if needed. After this call fastBitBltPossible will return true. May be used for initialization of temporary devices.

Definition at line 1122 of file kis_paint_device.cc.

1123{
1124 m_d->prepareClone(src);
1125}
void prepareClone(KisPaintDeviceSP src)

References m_d, and KisPaintDevice::Private::prepareClone().

◆ profileChanged

void KisPaintDevice::profileChanged ( const KoColorProfile * profile)
signal

◆ purgeDefaultPixels()

void KisPaintDevice::purgeDefaultPixels ( )

Frees the memory occupied by the pixels containing default values. The extents() and exactBounds() of the paint device will probably also shrink

Definition at line 1503 of file kis_paint_device.cc.

1504{
1506 dm->purge(dm->extent());
1507}
void extent(qint32 &x, qint32 &y, qint32 &w, qint32 &h) const

References KisPaintDevice::Private::dataManager(), KisDataManager::extent(), m_d, and KisDataManager::purge().

◆ read()

bool KisPaintDevice::read ( QIODevice * stream)

Fill this paint device with the pixels from the specified file store.

Definition at line 1551 of file kis_paint_device.cc.

1552{
1553 bool retval;
1554
1555 retval = m_d->dataManager()->read(stream);
1556 m_d->cache()->invalidate();
1557
1558 return retval;
1559}
bool read(QIODevice *io)

References KisPaintDevice::Private::cache(), KisPaintDevice::Private::dataManager(), KisPaintDeviceCache::invalidate(), m_d, and KisDataManager::read().

◆ readBytes() [1/2]

void KisPaintDevice::readBytes ( quint8 * data,
const QRect & rect ) const

Read the bytes representing the rectangle rect into data. If data is not big enough, Krita will gladly overwrite the rest of your precious memory.

Since this is a copy, you need to make sure you have enough memory.

Reading from areas not previously initialized will read the default pixel value into data but not initialize that region.

Parameters
dataThe address of the memory to receive the bytes read
rectThe rectangle in the paint device to read from

Definition at line 1997 of file kis_paint_device.cc.

1998{
1999 m_d->currentStrategy()->readBytes(data, rect);
2000}
virtual void readBytes(quint8 *data, const QRect &rect) const

References KisPaintDevice::Private::currentStrategy(), m_d, and KisPaintDevice::Private::KisPaintDeviceStrategy::readBytes().

◆ readBytes() [2/2]

void KisPaintDevice::readBytes ( quint8 * data,
qint32 x,
qint32 y,
qint32 w,
qint32 h ) const

Read the bytes representing the rectangle described by x, y, w, h into data. If data is not big enough, Krita will gladly overwrite the rest of your precious memory.

Since this is a copy, you need to make sure you have enough memory.

Reading from areas not previously initialized will read the default pixel value into data but not initialize that region.

Definition at line 1992 of file kis_paint_device.cc.

1993{
1994 readBytes(data, QRect(x, y, w, h));
1995}

References readBytes(), x(), and y().

◆ readPlanarBytes()

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

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.

Definition at line 2012 of file kis_paint_device.cc.

2013{
2014 return m_d->currentStrategy()->readPlanarBytes(x, y, w, h);
2015}
virtual QVector< quint8 * > readPlanarBytes(qint32 x, qint32 y, qint32 w, qint32 h) const

References KisPaintDevice::Private::currentStrategy(), m_d, KisPaintDevice::Private::KisPaintDeviceStrategy::readPlanarBytes(), x(), and y().

◆ region()

KisRegion KisPaintDevice::region ( ) const

Returns a rough approximation of region covered by device. For tiled data manager, it region will consist of a number of rects each corresponding to a tile.

Definition at line 1267 of file kis_paint_device.cc.

1268{
1269 return m_d->currentStrategy()->region();
1270}

References KisPaintDevice::Private::currentStrategy(), m_d, and KisPaintDevice::Private::KisPaintDeviceStrategy::region().

◆ regionExact()

KisRegion KisPaintDevice::regionExact ( ) const

The slow version of region() that searches for exact bounds of each rectangle in the region

Definition at line 1468 of file kis_paint_device.cc.

1469{
1470 QVector<QRect> sourceRects = region().rects();
1471 QVector<QRect> resultRects;
1472
1473 const KoColor defaultPixel = this->defaultPixel();
1475
1476 Q_FOREACH (const QRect &rc1, sourceRects) {
1477 const int patchSize = 64;
1478 QVector<QRect> smallerRects = KritaUtils::splitRectIntoPatches(rc1, QSize(patchSize, patchSize));
1479 Q_FOREACH (const QRect &rc2, smallerRects) {
1480
1481 const QRect result =
1482 Impl::calculateExactBoundsImpl(this, rc2, QRect(), compareOp);
1483
1484 if (!result.isEmpty()) {
1485 resultRects << result;
1486 }
1487 }
1488 }
1489 return KisRegion(std::move(resultRects));
1490}
QVector< QRect > rects() const
QVector< QRect > splitRectIntoPatches(const QRect &rc, const QSize &patchSize)

References Impl::calculateExactBoundsImpl(), KoColor::data(), defaultPixel(), pixelSize(), KisRegion::rects(), region(), and KritaUtils::splitRectIntoPatches().

◆ regionForLodSyncing()

KisRegion KisPaintDevice::regionForLodSyncing ( ) const

Definition at line 2148 of file kis_paint_device.cc.

2149{
2150 return m_d->regionForLodSyncing();
2151}
KisRegion regionForLodSyncing() const

References m_d, and KisPaintDevice::Private::regionForLodSyncing().

◆ reincarnateWithDetachedHistory()

KUndo2Command * KisPaintDevice::reincarnateWithDetachedHistory ( bool copyContent)

Converts a paint device into a "new" paint device, that has unconnected history. That is, after reincarnation, the device's life starts a new page. No history. No memories.

When the device is fed up with the new life, it can reincarnate back to its previous life by undoing the command returned by reincarnateWithDetachedHistory(). The old undo will continue working as if nothing has happened.

NOTE: reincarnation affects only the current lod plane and/or current frame. All other frames are kept unaffected.

Parameters
copyContentdecides if the device should take its current content to the new life
Returns
undo command for execution and undoing of the reincarnation

Definition at line 1585 of file kis_paint_device.cc.

1586{
1587 return m_d->reincarnateWithDetachedHistory(copyContent);
1588}
KUndo2Command * reincarnateWithDetachedHistory(bool copyContent)

References m_d, and KisPaintDevice::Private::reincarnateWithDetachedHistory().

◆ requestTimeSwitch()

void KisPaintDevice::requestTimeSwitch ( int time)

Called by KisTransactionData when it thinks current time should be changed. And the requests is forwarded to the image if needed.

Definition at line 1177 of file kis_paint_device.cc.

1178{
1179 if (m_d->parent.isValid()) {
1181 }
1182}
void requestTimeSwitch(int time)
Definition kis_node.cpp:670

References KisWeakSharedPtr< T >::isValid(), m_d, KisPaintDevice::Private::parent, and KisNode::requestTimeSwitch().

◆ sequenceNumber()

int KisPaintDevice::sequenceNumber ( ) const
Returns
a sequence number corresponding to the current paint device state. Every time the paint device is changed, the sequence number is increased

Definition at line 1184 of file kis_paint_device.cc.

1185{
1186 return m_d->cache()->sequenceNumber();
1187}

References KisPaintDevice::Private::cache(), m_d, and KisPaintDeviceCache::sequenceNumber().

◆ setDataManager()

void KisPaintDevice::setDataManager ( KisDataManagerSP data,
const KoColorSpace * colorSpace = 0 )

Replace the pixel data, color strategy, and profile.

◆ setDefaultBounds()

void KisPaintDevice::setDefaultBounds ( KisDefaultBoundsBaseSP bounds)

set the default bounds for the paint device when the default pixel is not completely transparent

Definition at line 1206 of file kis_paint_device.cc.

1207{
1209 m_d->cache()->invalidate();
1210}

References KisPaintDevice::Private::cache(), KisPaintDevice::Private::defaultBounds, defaultBounds(), KisPaintDeviceCache::invalidate(), and m_d.

◆ setDefaultPixel()

void KisPaintDevice::setDefaultPixel ( const KoColor & defPixel)

Sets the default pixel. New data will be initialised with this pixel. The pixel is copied: the caller still owns the pointer and needs to delete it to avoid memory leaks. If frame ID is given, set default pixel for that frame. Otherwise use active frame.

Definition at line 1509 of file kis_paint_device.cc.

1510{
1511 KoColor color(defPixel);
1512 color.convertTo(colorSpace());
1513
1514 m_d->dataManager()->setDefaultPixel(color.data());
1515 m_d->cache()->invalidate();
1516}
void setDefaultPixel(const quint8 *defPixel)

References KisPaintDevice::Private::cache(), colorSpace(), KoColor::convertTo(), KoColor::data(), KisPaintDevice::Private::dataManager(), KisPaintDeviceCache::invalidate(), m_d, and KisDataManager::setDefaultPixel().

◆ setDirty() [1/4]

void KisPaintDevice::setDirty ( )

Set the parent layer completely dirty, if this paint device has as parent layer.

Definition at line 1149 of file kis_paint_device.cc.

1150{
1151 m_d->cache()->invalidate();
1152 if (m_d->parent.isValid())
1153 m_d->parent->setDirty();
1154}
virtual void setDirty()
Definition kis_node.cpp:577

References KisPaintDevice::Private::cache(), KisPaintDeviceCache::invalidate(), KisWeakSharedPtr< T >::isValid(), m_d, KisPaintDevice::Private::parent, and KisNode::setDirty().

◆ setDirty() [2/4]

◆ setDirty() [3/4]

void KisPaintDevice::setDirty ( const QRect & rc)

Add the specified rect to the parent layer's set of dirty rects (if there is a parent layer)

Definition at line 1156 of file kis_paint_device.cc.

1157{
1158 m_d->cache()->invalidate();
1159 if (m_d->parent.isValid())
1160 m_d->parent->setDirty(rc);
1161}

References KisPaintDevice::Private::cache(), KisPaintDeviceCache::invalidate(), KisWeakSharedPtr< T >::isValid(), m_d, KisPaintDevice::Private::parent, and KisNode::setDirty().

◆ setDirty() [4/4]

void KisPaintDevice::setDirty ( const QVector< QRect > & rects)

◆ setParentNode()

void KisPaintDevice::setParentNode ( KisNodeWSP parent)

set the parent node of the paint device

Definition at line 1194 of file kis_paint_device.cc.

1195{
1197 m_d->parent = parent;
1198}
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327

References KIS_SAFE_ASSERT_RECOVER_NOOP, m_d, and KisPaintDevice::Private::parent.

◆ setPixel() [1/2]

bool KisPaintDevice::setPixel ( qint32 x,
qint32 y,
const KoColor & kc )

Convenience method for the above.

Definition at line 1951 of file kis_paint_device.cc.

1952{
1953 const quint8 * pix;
1955 if (kc.colorSpace() != m_d->colorSpace()) {
1956 KoColor kc2(kc, m_d->colorSpace());
1957 pix = kc2.data();
1958 memcpy(iter->rawData(), pix, m_d->colorSpace()->pixelSize());
1959 } else {
1960 pix = kc.data();
1961 memcpy(iter->rawData(), pix, m_d->colorSpace()->pixelSize());
1962 }
1963 m_d->cache()->invalidate();
1964 return true;
1965}

References KisPaintDevice::Private::cache(), KisPaintDevice::Private::colorSpace(), KoColor::colorSpace(), createHLineIteratorNG(), KoColor::data(), KisPaintDeviceCache::invalidate(), m_d, KoColorSpace::pixelSize(), x(), and y().

◆ setPixel() [2/2]

bool KisPaintDevice::setPixel ( qint32 x,
qint32 y,
const QColor & c )

Set the specified pixel to the specified color. Note that this bypasses KisPainter. the PaintDevice is here used as an equivalent to QImage, not QPixmap. This means that this is not undoable; also, there is no compositing with an existing value at this location.

The color values will be transformed from the display profile to the paint device profile.

Note that this will use 8-bit values and may cause a significant degradation when used on 16-bit or hdr quality images.

Returns
true if the operation was successful

Definition at line 1942 of file kis_paint_device.cc.

1943{
1945
1946 colorSpace()->fromQColor(c, iter->rawData());
1947 m_d->cache()->invalidate();
1948 return true;
1949}
virtual void fromQColor(const QColor &color, quint8 *dst) const =0

References KisPaintDevice::Private::cache(), colorSpace(), createHLineIteratorNG(), KoColorSpace::fromQColor(), KisPaintDeviceCache::invalidate(), m_d, x(), and y().

◆ setProfile()

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

Changes the profile of the colorspace of this paint device to the given profile. If the given profile is 0, nothing happens.

Definition at line 1580 of file kis_paint_device.cc.

1581{
1582 return m_d->assignProfile(profile, parentCommand);
1583}
bool assignProfile(const KoColorProfile *profile, KUndo2Command *parentCommand)

References KisPaintDevice::Private::assignProfile(), and m_d.

◆ setProjectionDevice()

void KisPaintDevice::setProjectionDevice ( bool value)

Definition at line 1117 of file kis_paint_device.cc.

1118{
1120}
float value(const T *src, size_t ch)

References KisPaintDevice::Private::isProjectionDevice, m_d, and value().

◆ setSupportsWraparoundMode()

void KisPaintDevice::setSupportsWraparoundMode ( bool value)

Definition at line 2173 of file kis_paint_device.cc.

2174{
2176}

References m_d, KisPaintDevice::Private::supportsWrapAroundMode, and value().

◆ setX()

void KisPaintDevice::setX ( qint32 x)

set the X offset of the paint device

Definition at line 1233 of file kis_paint_device.cc.

1234{
1235 moveTo(QPoint(x, m_d->y()));
1236}

References m_d, moveTo(), x(), and KisPaintDevice::Private::y().

◆ setY()

void KisPaintDevice::setY ( qint32 y)

set the Y offset of the paint device

Definition at line 1238 of file kis_paint_device.cc.

1239{
1240 moveTo(QPoint(m_d->x(), y));
1241}

References m_d, moveTo(), KisPaintDevice::Private::x(), and y().

◆ supportsWraproundMode()

bool KisPaintDevice::supportsWraproundMode ( ) const

Definition at line 2178 of file kis_paint_device.cc.

2179{
2181}

References m_d, and KisPaintDevice::Private::supportsWrapAroundMode.

◆ testingFetchLodDevice()

void KisPaintDevice::testingFetchLodDevice ( KisPaintDeviceSP targetDevice)

Definition at line 2350 of file kis_paint_device.cc.

2351{
2352 m_d->testingFetchLodDevice(targetDevice);
2353}
void testingFetchLodDevice(KisPaintDeviceSP targetDevice)

References m_d, and KisPaintDevice::Private::testingFetchLodDevice().

◆ updateLodDataStruct()

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

Definition at line 2158 of file kis_paint_device.cc.

2159{
2160 m_d->updateLodDataStruct(dst, srcRect);
2161}
void updateLodDataStruct(LodDataStruct *dst, const QRect &srcRect)

References m_d, and KisPaintDevice::Private::updateLodDataStruct().

◆ uploadLodDataStruct()

void KisPaintDevice::uploadLodDataStruct ( LodDataStruct * dst)

Definition at line 2163 of file kis_paint_device.cc.

2164{
2166}
void uploadLodDataStruct(LodDataStruct *dst)

References m_d, and KisPaintDevice::Private::uploadLodDataStruct().

◆ write()

bool KisPaintDevice::write ( KisPaintDeviceWriter & store)

Write the pixels of this paint device into the specified file store.

Definition at line 1546 of file kis_paint_device.cc.

1547{
1548 return m_d->dataManager()->write(store);
1549}
bool write(KisPaintDeviceWriter &writer)

References KisPaintDevice::Private::dataManager(), m_d, and KisDataManager::write().

◆ writeBytes() [1/2]

void KisPaintDevice::writeBytes ( const quint8 * data,
const QRect & rect )

Copy the bytes in data into the rectangle rect. If the data is too small or uninitialized, Krita will happily read parts of memory you never wanted to be read.

If the data is written to areas of the paint device not previously initialized, the paint device will grow.

Parameters
dataThe address of the memory to write bytes from
rectThe rectangle in the paint device to write to

Definition at line 2007 of file kis_paint_device.cc.

2008{
2010}
virtual void writeBytes(const quint8 *data, const QRect &rect)

References KisPaintDevice::Private::currentStrategy(), m_d, and KisPaintDevice::Private::KisPaintDeviceStrategy::writeBytes().

◆ writeBytes() [2/2]

void KisPaintDevice::writeBytes ( const quint8 * data,
qint32 x,
qint32 y,
qint32 w,
qint32 h )

Copy the bytes in data into the rect specified by x, y, w, h. If the data is too small or uninitialized, Krita will happily read parts of memory you never wanted to be read.

If the data is written to areas of the paint device not previously initialized, the paint device will grow.

Definition at line 2002 of file kis_paint_device.cc.

2003{
2004 writeBytes(data, QRect(x, y, w, h));
2005}

References writeBytes(), x(), and y().

◆ writePlanarBytes()

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

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.

XXX: what about undo?

Definition at line 2017 of file kis_paint_device.cc.

2018{
2019 m_d->currentStrategy()->writePlanarBytes(planes, x, y, w, h);
2020}
virtual void writePlanarBytes(QVector< quint8 * > planes, qint32 x, qint32 y, qint32 w, qint32 h)

References KisPaintDevice::Private::currentStrategy(), m_d, KisPaintDevice::Private::KisPaintDeviceStrategy::writePlanarBytes(), x(), and y().

◆ x()

qint32 KisPaintDevice::x ( ) const

The X offset of the paint device

Definition at line 1243 of file kis_paint_device.cc.

1244{
1245 return m_d->x();
1246}

References m_d, and KisPaintDevice::Private::x().

◆ y()

qint32 KisPaintDevice::y ( ) const

The Y offset of the paint device

Definition at line 1248 of file kis_paint_device.cc.

1249{
1250 return m_d->y();
1251}

References m_d, and KisPaintDevice::Private::y().

Friends And Related Symbol Documentation

◆ DataReaderThread

friend class DataReaderThread
friend

Definition at line 355 of file kis_paint_device.h.

◆ KisPaintDeviceFramesInterface

friend class KisPaintDeviceFramesInterface
friend

Definition at line 952 of file kis_paint_device.h.

◆ KisPaintDeviceTest

friend class KisPaintDeviceTest
friend

Definition at line 354 of file kis_paint_device.h.

◆ KisPainter

friend class KisPainter
friend

Definition at line 940 of file kis_paint_device.h.

◆ KisSelectionTest

friend class KisSelectionTest
friend

Definition at line 955 of file kis_paint_device.h.

◆ PaintDeviceCache

friend class PaintDeviceCache
friend

Definition at line 896 of file kis_paint_device.h.

Member Data Documentation

◆ m_d

Private* const KisPaintDevice::m_d
private

Definition at line 960 of file kis_paint_device.h.


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