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

#include <kis_image_pyramid.h>

+ Inheritance diagram for KisImagePyramid:

Public Member Functions

void alignSourceRect (QRect &rect, qreal scale) override
 
QImage convertToQImage (qreal scale, const QRect &unscaledRect, enum Qt::TransformationMode transformMode)
 
QImage convertToQImage (qreal scale, qint32 unscaledX, qint32 unscaledY, qint32 unscaledWidth, qint32 unscaledHeight)
 
void drawFromOriginalImage (QPainter &gc, KisPPUpdateInfoSP info) override
 
void drawImage (qreal scale, QPainter &gc, const QPoint &topLeftScaled, const QRect &unscaledSourceRect)
 
KisImagePatch getNearestPatch (KisPPUpdateInfoSP info) override
 
 KisImagePyramid (qint32 pyramidHeight)
 
void recalculateCache (KisPPUpdateInfoSP info) override
 
void setChannelFlags (const QBitArray &channelFlags) override
 
void setDisplayFilter (QSharedPointer< KisDisplayFilter > displayFilter) override
 
void setImage (KisImageWSP newImage) override
 
void setImageSize (qint32 w, qint32 h) override
 
void setMonitorProfile (const KoColorProfile *monitorProfile, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) override
 
void updateCache (const QRect &dirtyImageRect) override
 
 ~KisImagePyramid () override
 
- Public Member Functions inherited from KisProjectionBackend
virtual ~KisProjectionBackend ()
 

Private Slots

void configChanged ()
 

Private Member Functions

void clearPyramid ()
 
QImage convertToQImageFast (KisPaintDeviceSP paintDevice, const QRect &unscaledRect)
 
QRect downsampleByFactor2 (const QRect &srcRect, KisPaintDevice *src, KisPaintDevice *dst)
 
void downsamplePixels (const quint8 *srcRow0, const quint8 *srcRow1, quint8 *dstRow, qint32 numSrcPixels)
 
int findFirstGoodPlaneIndex (qreal scale, QSize originalSize)
 
void rebuildPyramid ()
 
void retrieveImageData (const QRect &rect)
 

Private Attributes

bool m_allChannelsSelected {false}
 
QBitArray m_channelFlags
 
KoColorConversionTransformation::ConversionFlags m_conversionFlags { KoColorConversionTransformation::Empty }
 
QSharedPointer< KisDisplayFilterm_displayFilter
 
const KoColorSpacem_monitorColorSpace {0}
 
const KoColorProfilem_monitorProfile {0}
 
bool m_onlyOneChannelSelected {false}
 
KisImageWSP m_originalImage
 
QVector< KisPaintDeviceSPm_pyramid
 
qint32 m_pyramidHeight {0}
 
KoColorConversionTransformation::Intent m_renderingIntent { KoColorConversionTransformation::IntentPerceptual }
 
int m_selectedChannelIndex {-1}
 
bool m_useOcio {false}
 

Detailed Description

Definition at line 20 of file kis_image_pyramid.h.

Constructor & Destructor Documentation

◆ KisImagePyramid()

KisImagePyramid::KisImagePyramid ( qint32 pyramidHeight)

Definition at line 87 of file kis_image_pyramid.cpp.

90 , m_pyramidHeight(pyramidHeight)
91{
94}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
static KisConfigNotifier * instance()
const KoColorSpace * m_monitorColorSpace
const KoColorProfile * m_monitorProfile

References configChanged(), connect(), and KisConfigNotifier::instance().

◆ ~KisImagePyramid()

KisImagePyramid::~KisImagePyramid ( )
override

Definition at line 96 of file kis_image_pyramid.cpp.

97{
98 setImage(0);
99}
void setImage(KisImageWSP newImage) override

References setImage().

Member Function Documentation

◆ alignSourceRect()

void KisImagePyramid::alignSourceRect ( QRect & rect,
qreal scale )
overridevirtual

Some backends cannot work with arbitrary areas due to scaling stuff. That's why KisPrescaledProjection asks a backend to align an image rect before any operations.

Assume that KisImage pixels are always positive It allows us to use binary op-s for aligning

Here is a workaround of Qt's QRect::right()/bottom() "historical reasons". It should be one pixel smaller than actual right/bottom position

Reimplemented from KisProjectionBackend.

Definition at line 418 of file kis_image_pyramid.cpp.

419{
420 qint32 index = findFirstGoodPlaneIndex(scale, rect.size());
421 qint32 alignment = 1 << index;
422
423 dbgRender << "Before alignment:\t" << rect;
424
429 Q_ASSERT(rect.left() >= 0 && rect.top() >= 0);
430
431 qint32 x1, y1, x2, y2;
432 rect.getCoords(&x1, &y1, &x2, &y2);
433
434 alignByPow2Lo(x1, alignment);
435 alignByPow2Lo(y1, alignment);
441 alignByPow2ButOneHi(x2, alignment);
442 alignByPow2ButOneHi(y2, alignment);
443
444 rect.setCoords(x1, y1, x2, y2);
445
446 dbgRender << "After alignment:\t" << rect;
447}
int findFirstGoodPlaneIndex(qreal scale, QSize originalSize)
#define dbgRender
Definition kis_debug.h:55
void alignByPow2Lo(qint32 &value, qint32 alignment)
void alignByPow2ButOneHi(qint32 &value, qint32 alignment)

References alignByPow2ButOneHi(), alignByPow2Lo(), dbgRender, and findFirstGoodPlaneIndex().

◆ clearPyramid()

void KisImagePyramid::clearPyramid ( )
private

Definition at line 151 of file kis_image_pyramid.cpp.

152{
153 for (qint32 i = 0; i < m_pyramidHeight; i++) {
154 m_pyramid[i]->clear();
155 }
156}
QVector< KisPaintDeviceSP > m_pyramid

References m_pyramid, and m_pyramidHeight.

◆ configChanged

void KisImagePyramid::configChanged ( )
privateslot

Definition at line 485 of file kis_image_pyramid.cpp.

486{
487 KisConfig cfg(true);
488 m_useOcio = cfg.useOcio();
489}

References m_useOcio, and KisConfig::useOcio().

◆ convertToQImage() [1/2]

QImage KisImagePyramid::convertToQImage ( qreal scale,
const QRect & unscaledRect,
enum Qt::TransformationMode transformMode )

Render the projection onto a QImage. Color profiling occurs here

◆ convertToQImage() [2/2]

QImage KisImagePyramid::convertToQImage ( qreal scale,
qint32 unscaledX,
qint32 unscaledY,
qint32 unscaledWidth,
qint32 unscaledHeight )

◆ convertToQImageFast()

QImage KisImagePyramid::convertToQImageFast ( KisPaintDeviceSP paintDevice,
const QRect & unscaledRect )
private

Fast workaround for converting paintDevices

Definition at line 472 of file kis_image_pyramid.cpp.

474{
475 qint32 x, y, w, h;
476 unscaledRect.getRect(&x, &y, &w, &h);
477
478 QImage image = QImage(w, h, QImage::Format_ARGB32);
479
480 paintDevice->dataManager()->readBytes(image.bits(), x, y, w, h);
481
482 return image;
483}
void readBytes(quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h, qint32 dataRowStride=-1) const
KisDataManagerSP dataManager() const

References KisPaintDevice::dataManager(), and KisDataManager::readBytes().

◆ downsampleByFactor2()

QRect KisImagePyramid::downsampleByFactor2 ( const QRect & srcRect,
KisPaintDevice * src,
KisPaintDevice * dst )
private

Downsamples @srcRect from @src paint device and writes result into proper place of @dst paint device Returns modified rect of @dst paintDevice

Definition at line 316 of file kis_image_pyramid.cpp.

319{
320 qint32 srcX, srcY, srcWidth, srcHeight;
321 srcRect.getRect(&srcX, &srcY, &srcWidth, &srcHeight);
322 alignRectBy2(srcX, srcY, srcWidth, srcHeight);
323
324 // Nothing to do
325 if (srcWidth < 1) return QRect();
326 if (srcHeight < 1) return QRect();
327
328 qint32 dstX = srcX / 2;
329 qint32 dstY = srcY / 2;
330 qint32 dstWidth = srcWidth / 2;
331 qint32 dstHeight = srcHeight / 2;
332
333 KisHLineConstIteratorSP srcIt0 = src->createHLineConstIteratorNG(srcX, srcY, srcWidth);
334 KisHLineConstIteratorSP srcIt1 = src->createHLineConstIteratorNG(srcX, srcY + 1, srcWidth);
335 KisHLineIteratorSP dstIt = dst->createHLineIteratorNG(dstX, dstY, dstWidth);
336
337 int conseqPixels = 0;
338 for (int row = 0; row < dstHeight; ++row) {
339 do {
340 int srcItConseq = srcIt0->nConseqPixels();
341 int dstItConseq = dstIt->nConseqPixels();
342 conseqPixels = qMin(srcItConseq, dstItConseq * 2);
343
344 Q_ASSERT(!isOdd(conseqPixels));
345
346 downsamplePixels(srcIt0->oldRawData(), srcIt1->oldRawData(),
347 dstIt->rawData(), conseqPixels);
348
349
350 srcIt1->nextPixels(conseqPixels);
351 dstIt->nextPixels(conseqPixels / 2);
352 } while (srcIt0->nextPixels(conseqPixels));
353 srcIt0->nextRow();
354 srcIt0->nextRow();
355 srcIt1->nextRow();
356 srcIt1->nextRow();
357 dstIt->nextRow();
358 }
359 return QRect(dstX, dstY, dstWidth, dstHeight);
360}
virtual const quint8 * oldRawData() const =0
virtual qint32 nConseqPixels() const =0
virtual bool nextPixels(qint32 n)=0
virtual void nextRow()=0
void downsamplePixels(const quint8 *srcRow0, const quint8 *srcRow1, quint8 *dstRow, qint32 numSrcPixels)
KisHLineIteratorSP createHLineIteratorNG(qint32 x, qint32 y, qint32 w)
void alignRectBy2(qint32 &x, qint32 &y, qint32 &w, qint32 &h)
#define isOdd(x)

References alignRectBy2(), KisPaintDevice::createHLineIteratorNG(), downsamplePixels(), isOdd, KisBaseConstIteratorNG::nConseqPixels(), KisBaseConstIteratorNG::nextPixels(), KisHLineConstIteratorNG::nextRow(), and KisBaseConstAccessor::oldRawData().

◆ downsamplePixels()

void KisImagePyramid::downsamplePixels ( const quint8 * srcRow0,
const quint8 * srcRow1,
quint8 * dstRow,
qint32 numSrcPixels )
private

Auxiliary function. Downsamples two lines in @srcRow0 and @srcRow1 into one line @dstRow Note: @numSrcPixels must be EVEN

FIXME (mandatory): Use SSE and friends here.

Definition at line 362 of file kis_image_pyramid.cpp.

366{
371 qint16 b = 0;
372 qint16 g = 0;
373 qint16 r = 0;
374 qint16 a = 0;
375
376 static const qint32 pixelSize = 4; // This is preview argb8 mode
377
378 for (qint32 i = 0; i < numSrcPixels / 2; i++) {
379 b = srcRow0[0] + srcRow1[0] + srcRow0[4] + srcRow1[4];
380 g = srcRow0[1] + srcRow1[1] + srcRow0[5] + srcRow1[5];
381 r = srcRow0[2] + srcRow1[2] + srcRow0[6] + srcRow1[6];
382 a = srcRow0[3] + srcRow1[3] + srcRow0[7] + srcRow1[7];
383
384 dstRow[0] = b / 4;
385 dstRow[1] = g / 4;
386 dstRow[2] = r / 4;
387 dstRow[3] = a / 4;
388
389 dstRow += pixelSize;
390 srcRow0 += 2 * pixelSize;
391 srcRow1 += 2 * pixelSize;
392 }
393}

◆ drawFromOriginalImage()

void KisImagePyramid::drawFromOriginalImage ( QPainter & gc,
KisPPUpdateInfoSP info )
overridevirtual

Draws a piece of original image onto gc 's canvas info.imageRect - area in KisImage pixels where to read from info.viewportRect - area in canvas pixels where to write to If info.imageRect and info.viewportRect don't agree, the image will be scaled info.borderWidth has the same meaning as in getNearestPatch info.renderHints - hints, transmitted to QPainter during drawing

Implements KisProjectionBackend.

Definition at line 466 of file kis_image_pyramid.cpp.

467{
468 KisImagePatch patch = getNearestPatch(info);
469 patch.drawMe(gc, info->viewportRect, info->renderHints);
470}
void drawMe(QPainter &gc, const QRectF &dstRect, QPainter::RenderHints renderHints)
KisImagePatch getNearestPatch(KisPPUpdateInfoSP info) override

References KisImagePatch::drawMe(), and getNearestPatch().

◆ drawImage()

void KisImagePyramid::drawImage ( qreal scale,
QPainter & gc,
const QPoint & topLeftScaled,
const QRect & unscaledSourceRect )

Draw the projection onto a QPainter. Color profiling occurs here

◆ findFirstGoodPlaneIndex()

int KisImagePyramid::findFirstGoodPlaneIndex ( qreal scale,
QSize originalSize )
private

Searches for the last pyramid plane that can cover canvas on current zoom level

Definition at line 395 of file kis_image_pyramid.cpp.

397{
398 qint32 nearest = 0;
399
400 for (qint32 i = 0; i < m_pyramidHeight; i++) {
401 qreal planeScale = SCALE_FROM_INDEX(i);
402 if (planeScale < scale) {
403 if (originalSize*scale == originalSize*planeScale)
404 nearest = i;
405 break;
406 }
407 nearest = i;
408 }
409
410 // FOR DEBUGGING
411 //nearest = 0;
412 //nearest = qMin(1, nearest);
413
414 dbgRender << "First good plane:" << nearest << "(sc:" << scale << ")";
415 return nearest;
416}
#define SCALE_FROM_INDEX(idx)

References dbgRender, m_pyramidHeight, and SCALE_FROM_INDEX.

◆ getNearestPatch()

KisImagePatch KisImagePyramid::getNearestPatch ( KisPPUpdateInfoSP info)
overridevirtual

Gets a patch from a backend that can draw a info.imageRect on some QPainter in future. info.scaleX and info.scaleY are the scales of planned drawing, btw, it doesn't mean that an QImage inside the patch will have these scales - it'll have the nearest suitable scale or even original scale (e.g. KisProjectionCache)

If info.borderWidth is non-zero, info.requestedRect will be expended by info.borderWidth pixels to all directions and image of this rect will actually be written to the patch's QImage. That is done to eliminate border effects in smooth scaling.

Implements KisProjectionBackend.

Definition at line 449 of file kis_image_pyramid.cpp.

450{
451 qint32 index = findFirstGoodPlaneIndex(qMax(info->scaleX, info->scaleY),
452 info->imageRect.size());
453 qreal planeScale = SCALE_FROM_INDEX(index);
454 qint32 alignment = 1 << index;
455
456 alignByPow2Hi(info->borderWidth, alignment);
457
458 KisImagePatch patch(info->imageRect, info->borderWidth,
459 planeScale, planeScale);
460
461 patch.setImage(convertToQImageFast(m_pyramid[index],
462 patch.patchRect()));
463 return patch;
464}
QImage convertToQImageFast(KisPaintDeviceSP paintDevice, const QRect &unscaledRect)
void alignByPow2Hi(qint32 &value, qint32 alignment)

References alignByPow2Hi(), convertToQImageFast(), findFirstGoodPlaneIndex(), m_pyramid, KisImagePatch::patchRect(), SCALE_FROM_INDEX, and KisImagePatch::setImage().

◆ rebuildPyramid()

void KisImagePyramid::rebuildPyramid ( )
private

Definition at line 143 of file kis_image_pyramid.cpp.

144{
145 m_pyramid.clear();
146 for (qint32 i = 0; i < m_pyramidHeight; i++) {
148 }
149}

References m_monitorColorSpace, m_pyramid, and m_pyramidHeight.

◆ recalculateCache()

void KisImagePyramid::recalculateCache ( KisPPUpdateInfoSP info)
overridevirtual

Prescales the cache of the backend. It is intended to be called from a separate thread where you can easily do the calculations. No data transfers with KisImage should happen during this phase

Implements KisProjectionBackend.

Definition at line 288 of file kis_image_pyramid.cpp.

289{
291 KisPaintDevice *dst;
292 QRect currentSrcRect = info->dirtyImageRectVar;
293
294 for (int i = FIRST_NOT_ORIGINAL_INDEX; i < m_pyramidHeight; i++) {
295 src = m_pyramid[i-1].data();
296 dst = m_pyramid[i].data();
297 if (!currentSrcRect.isEmpty()) {
298 currentSrcRect = downsampleByFactor2(currentSrcRect, src, dst);
299 }
300 }
301
302#ifdef DEBUG_PYRAMID
304 image.save("./PYRAMID_BASE.png");
305
306 image = m_pyramid[1]->convertToQImage(m_monitorProfile, m_renderingIntent, m_conversionFlags);
307 image.save("./LEVEL1.png");
308
309 image = m_pyramid[2]->convertToQImage(m_monitorProfile, m_renderingIntent, m_conversionFlags);
310 image.save("./LEVEL2.png");
311 image = m_pyramid[3]->convertToQImage(m_monitorProfile, m_renderingIntent, m_conversionFlags);
312 image.save("./LEVEL3.png");
313#endif
314}
QRect downsampleByFactor2(const QRect &srcRect, KisPaintDevice *src, KisPaintDevice *dst)
KoColorConversionTransformation::Intent m_renderingIntent
KoColorConversionTransformation::ConversionFlags m_conversionFlags
#define FIRST_NOT_ORIGINAL_INDEX
#define ORIGINAL_INDEX

References downsampleByFactor2(), FIRST_NOT_ORIGINAL_INDEX, m_conversionFlags, m_monitorProfile, m_pyramid, m_pyramidHeight, m_renderingIntent, and ORIGINAL_INDEX.

◆ retrieveImageData()

void KisImagePyramid::retrieveImageData ( const QRect & rect)
private

Definition at line 211 of file kis_image_pyramid.cpp.

212{
213 // XXX: use QThreadStorage to cache the two patches (512x512) of pixels. Note
214 // that when we do that, we need to reset that cache when the projection's
215 // colorspace changes.
216 const KoColorSpace *projectionCs = m_originalImage->projection()->colorSpace();
217 KisPaintDeviceSP originalProjection = m_originalImage->projection();
218 quint32 numPixels = rect.width() * rect.height();
219
220 QScopedArrayPointer<quint8> originalBytes(
221 new quint8[originalProjection->colorSpace()->pixelSize() * numPixels]);
222
223 originalProjection->readBytes(originalBytes.data(), rect);
224
225 if (m_displayFilter &&
226 m_useOcio &&
227 projectionCs->colorModelId() == RGBAColorModelID) {
228
229#ifdef HAVE_OCIO
230 const KoColorProfile *destinationProfile =
231 m_displayFilter->useInternalColorManagement() ?
232 m_monitorProfile : projectionCs->profile();
233
234 const KoColorSpace *floatCs =
238 destinationProfile);
239
240 const KoColorSpace *modifiedMonitorCs =
244 destinationProfile);
245
246 if (projectionCs->colorDepthId() == Float32BitsColorDepthID) {
247 m_displayFilter->filter(originalBytes.data(), numPixels);
248 } else {
249 QScopedArrayPointer<quint8> dst(new quint8[floatCs->pixelSize() * numPixels]);
251 m_displayFilter->filter(dst.data(), numPixels);
252 originalBytes.swap(dst);
253 }
254
255 {
256 QScopedArrayPointer<quint8> dst(new quint8[modifiedMonitorCs->pixelSize() * numPixels]);
257 floatCs->convertPixelsTo(originalBytes.data(), dst.data(), modifiedMonitorCs, numPixels, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags());
258 originalBytes.swap(dst);
259 }
260#endif
261 }
262 else {
263 if (m_channelFlags.size() != projectionCs->channelCount()) {
264 setChannelFlags(QBitArray());
265 }
266 if (!m_channelFlags.isEmpty() && !m_allChannelsSelected) {
267 QScopedArrayPointer<quint8> dst(new quint8[projectionCs->pixelSize() * numPixels]);
268
269 KisConfig cfg(true);
270
271 if (m_onlyOneChannelSelected && !cfg.showSingleChannelAsColor()) {
272 projectionCs->convertChannelToVisualRepresentation(originalBytes.data(), dst.data(), numPixels, m_selectedChannelIndex);
273 }
274 else {
275 projectionCs->convertChannelToVisualRepresentation(originalBytes.data(), dst.data(), numPixels, m_channelFlags);
276 }
277 originalBytes.swap(dst);
278 }
279
280 QScopedArrayPointer<quint8> dst(new quint8[m_monitorColorSpace->pixelSize() * numPixels]);
281 projectionCs->convertPixelsTo(originalBytes.data(), dst.data(), m_monitorColorSpace, numPixels, m_renderingIntent, m_conversionFlags);
282 originalBytes.swap(dst);
283 }
284
285 m_pyramid[ORIGINAL_INDEX]->writeBytes(originalBytes.data(), rect);
286}
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
KisImageWSP m_originalImage
QSharedPointer< KisDisplayFilter > m_displayFilter
void setChannelFlags(const QBitArray &channelFlags) override
KisPaintDeviceSP projection() const
const KoColorSpace * colorSpace() const
void readBytes(quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h) const
virtual quint32 pixelSize() const =0
virtual void convertChannelToVisualRepresentation(const quint8 *src, quint8 *dst, quint32 nPixels, const qint32 selectedChannelIndex) const =0
virtual KoID colorModelId() const =0
virtual quint32 channelCount() const =0
virtual KoID colorDepthId() const =0
virtual bool convertPixelsTo(const quint8 *src, quint8 *dst, const KoColorSpace *dstColorSpace, quint32 numPixels, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const
virtual const KoColorProfile * profile() const =0
QString id() const
Definition KoID.cpp:63
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
static KoColorSpaceRegistry * instance()

References KoColorSpace::channelCount(), KoColorSpace::colorDepthId(), KoColorSpace::colorModelId(), KisPaintDevice::colorSpace(), KoColorSpaceRegistry::colorSpace(), KoColorSpace::convertChannelToVisualRepresentation(), KoColorSpace::convertPixelsTo(), Float32BitsColorDepthID, KoID::id(), KoColorSpaceRegistry::instance(), Integer8BitsColorDepthID, KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), m_allChannelsSelected, m_channelFlags, m_conversionFlags, m_displayFilter, m_monitorColorSpace, m_monitorProfile, m_onlyOneChannelSelected, m_originalImage, m_pyramid, m_renderingIntent, m_selectedChannelIndex, m_useOcio, ORIGINAL_INDEX, KoColorSpace::pixelSize(), KoColorSpace::profile(), KisImage::projection(), KisPaintDevice::readBytes(), RGBAColorModelID, setChannelFlags(), and KisConfig::showSingleChannelAsColor().

◆ setChannelFlags()

void KisImagePyramid::setChannelFlags ( const QBitArray & channelFlags)
overridevirtual

Implements KisProjectionBackend.

Definition at line 117 of file kis_image_pyramid.cpp.

118{
119 m_channelFlags = channelFlags;
120 int selectedChannels = 0;
121 const KoColorSpace *projectionCs = m_originalImage->projection()->colorSpace();
122 const QList<KoChannelInfo*> channelInfo = projectionCs->channels();
123
124 if (channelInfo.size() != m_channelFlags.size()) {
125 m_channelFlags = QBitArray();
126 }
127
128 for (int i = 0; i < m_channelFlags.size(); ++i) {
129 if (m_channelFlags.testBit(i) && channelInfo[i]->channelType() == KoChannelInfo::COLOR) {
130 selectedChannels++;
132 }
133 }
134 m_allChannelsSelected = (selectedChannels == m_channelFlags.size());
135 m_onlyOneChannelSelected = (selectedChannels == 1);
136}
@ COLOR
The channel represents a color.
QList< KoChannelInfo * > channels

References KoColorSpace::channels, KoChannelInfo::COLOR, KisPaintDevice::colorSpace(), m_allChannelsSelected, m_channelFlags, m_onlyOneChannelSelected, m_originalImage, m_selectedChannelIndex, and KisImage::projection().

◆ setDisplayFilter()

void KisImagePyramid::setDisplayFilter ( QSharedPointer< KisDisplayFilter > displayFilter)
overridevirtual

Implements KisProjectionBackend.

Definition at line 138 of file kis_image_pyramid.cpp.

139{
140 m_displayFilter = displayFilter;
141}

References m_displayFilter.

◆ setImage()

void KisImagePyramid::setImage ( KisImageWSP image)
overridevirtual

Those methods are related to KisPrescaledProjection's equivalents

Implements KisProjectionBackend.

Definition at line 158 of file kis_image_pyramid.cpp.

159{
160 if (newImage) {
161 m_originalImage = newImage;
162
163 clearPyramid();
165
166 // Get the full image size
167 QRect rc = m_originalImage->projection()->exactBounds();
168
169 KisImageConfig config(true);
170
171 int patchWidth = config.updatePatchWidth();
172 int patchHeight = config.updatePatchHeight();
173
174 if (rc.width() * rc.height() <= patchWidth * patchHeight) {
176 }
177 else {
178 qint32 firstCol = rc.x() / patchWidth;
179 qint32 firstRow = rc.y() / patchHeight;
180
181 qint32 lastCol = (rc.x() + rc.width()) / patchWidth;
182 qint32 lastRow = (rc.y() + rc.height()) / patchHeight;
183
184 for(qint32 i = firstRow; i <= lastRow; i++) {
185 for(qint32 j = firstCol; j <= lastCol; j++) {
186 QRect maxPatchRect(j * patchWidth,
187 i * patchHeight,
188 patchWidth, patchHeight);
189 QRect patchRect = rc & maxPatchRect;
190 retrieveImageData(patchRect);
191 }
192 }
193
194 }
195 //TODO: check whether there is needed recalculateCache()
196 }
197}
void setImageSize(qint32 w, qint32 h) override
void retrieveImageData(const QRect &rect)
qint32 width() const
qint32 height() const
QRect exactBounds() const

References clearPyramid(), KisPaintDevice::exactBounds(), KisImage::height(), m_originalImage, KisImage::projection(), retrieveImageData(), setImageSize(), KisImageConfig::updatePatchHeight(), KisImageConfig::updatePatchWidth(), and KisImage::width().

◆ setImageSize()

void KisImagePyramid::setImageSize ( qint32 w,
qint32 h )
overridevirtual

Implements KisProjectionBackend.

Definition at line 199 of file kis_image_pyramid.cpp.

200{
201 Q_UNUSED(w);
202 Q_UNUSED(h);
203 /* nothing interesting */
204}

◆ setMonitorProfile()

void KisImagePyramid::setMonitorProfile ( const KoColorProfile * monitorProfile,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags )
overridevirtual

If you change pixel size here, don't forget to change it in optimized function downsamplePixels()

Implements KisProjectionBackend.

Definition at line 101 of file kis_image_pyramid.cpp.

104{
105 m_monitorProfile = monitorProfile;
111 m_renderingIntent = renderingIntent;
112 m_conversionFlags = conversionFlags;
113
115}
const KoColorSpace * rgb8(const QString &profileName=QString())

References KoColorSpaceRegistry::instance(), m_conversionFlags, m_monitorColorSpace, m_monitorProfile, m_renderingIntent, rebuildPyramid(), and KoColorSpaceRegistry::rgb8().

◆ updateCache()

void KisImagePyramid::updateCache ( const QRect & dirtyImageRect)
overridevirtual

Updates the cache of the backend by reading from an associated image. All data transfers with KisImage should happen here

Implements KisProjectionBackend.

Definition at line 206 of file kis_image_pyramid.cpp.

207{
208 retrieveImageData(dirtyImageRect);
209}

References retrieveImageData().

Member Data Documentation

◆ m_allChannelsSelected

bool KisImagePyramid::m_allChannelsSelected {false}
private

Definition at line 126 of file kis_image_pyramid.h.

126{false};

◆ m_channelFlags

QBitArray KisImagePyramid::m_channelFlags
private

Definition at line 125 of file kis_image_pyramid.h.

◆ m_conversionFlags

KoColorConversionTransformation::ConversionFlags KisImagePyramid::m_conversionFlags { KoColorConversionTransformation::Empty }
private

◆ m_displayFilter

QSharedPointer<KisDisplayFilter> KisImagePyramid::m_displayFilter
private

Definition at line 112 of file kis_image_pyramid.h.

◆ m_monitorColorSpace

const KoColorSpace* KisImagePyramid::m_monitorColorSpace {0}
private

Definition at line 110 of file kis_image_pyramid.h.

110{0};

◆ m_monitorProfile

const KoColorProfile* KisImagePyramid::m_monitorProfile {0}
private

Definition at line 109 of file kis_image_pyramid.h.

109{0};

◆ m_onlyOneChannelSelected

bool KisImagePyramid::m_onlyOneChannelSelected {false}
private

Definition at line 127 of file kis_image_pyramid.h.

127{false};

◆ m_originalImage

KisImageWSP KisImagePyramid::m_originalImage
private

Definition at line 107 of file kis_image_pyramid.h.

◆ m_pyramid

QVector<KisPaintDeviceSP> KisImagePyramid::m_pyramid
private

Definition at line 106 of file kis_image_pyramid.h.

◆ m_pyramidHeight

qint32 KisImagePyramid::m_pyramidHeight {0}
private

Number of planes inside pyramid

Definition at line 121 of file kis_image_pyramid.h.

121{0};

◆ m_renderingIntent

◆ m_selectedChannelIndex

int KisImagePyramid::m_selectedChannelIndex {-1}
private

Definition at line 128 of file kis_image_pyramid.h.

128{-1};

◆ m_useOcio

bool KisImagePyramid::m_useOcio {false}
private

Definition at line 123 of file kis_image_pyramid.h.

123{false};

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