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 89 of file kis_image_pyramid.cpp.

92 , m_pyramidHeight(pyramidHeight)
93{
95 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), this, SLOT(configChanged()));
96}
static KisConfigNotifier * instance()
const KoColorSpace * m_monitorColorSpace
const KoColorProfile * m_monitorProfile

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

◆ ~KisImagePyramid()

KisImagePyramid::~KisImagePyramid ( )
override

Definition at line 98 of file kis_image_pyramid.cpp.

99{
100 setImage(0);
101}
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 420 of file kis_image_pyramid.cpp.

421{
422 qint32 index = findFirstGoodPlaneIndex(scale, rect.size());
423 qint32 alignment = 1 << index;
424
425 dbgRender << "Before alignment:\t" << rect;
426
431 Q_ASSERT(rect.left() >= 0 && rect.top() >= 0);
432
433 qint32 x1, y1, x2, y2;
434 rect.getCoords(&x1, &y1, &x2, &y2);
435
436 alignByPow2Lo(x1, alignment);
437 alignByPow2Lo(y1, alignment);
443 alignByPow2ButOneHi(x2, alignment);
444 alignByPow2ButOneHi(y2, alignment);
445
446 rect.setCoords(x1, y1, x2, y2);
447
448 dbgRender << "After alignment:\t" << rect;
449}
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 153 of file kis_image_pyramid.cpp.

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

References m_pyramid, and m_pyramidHeight.

◆ configChanged

void KisImagePyramid::configChanged ( )
privateslot

Definition at line 487 of file kis_image_pyramid.cpp.

488{
489 KisConfig cfg(true);
490 m_useOcio = cfg.useOcio();
491}

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 474 of file kis_image_pyramid.cpp.

476{
477 qint32 x, y, w, h;
478 unscaledRect.getRect(&x, &y, &w, &h);
479
480 QImage image = QImage(w, h, QImage::Format_ARGB32);
481
482 paintDevice->dataManager()->readBytes(image.bits(), x, y, w, h);
483
484 return image;
485}
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 318 of file kis_image_pyramid.cpp.

321{
322 qint32 srcX, srcY, srcWidth, srcHeight;
323 srcRect.getRect(&srcX, &srcY, &srcWidth, &srcHeight);
324 alignRectBy2(srcX, srcY, srcWidth, srcHeight);
325
326 // Nothing to do
327 if (srcWidth < 1) return QRect();
328 if (srcHeight < 1) return QRect();
329
330 qint32 dstX = srcX / 2;
331 qint32 dstY = srcY / 2;
332 qint32 dstWidth = srcWidth / 2;
333 qint32 dstHeight = srcHeight / 2;
334
335 KisHLineConstIteratorSP srcIt0 = src->createHLineConstIteratorNG(srcX, srcY, srcWidth);
336 KisHLineConstIteratorSP srcIt1 = src->createHLineConstIteratorNG(srcX, srcY + 1, srcWidth);
337 KisHLineIteratorSP dstIt = dst->createHLineIteratorNG(dstX, dstY, dstWidth);
338
339 int conseqPixels = 0;
340 for (int row = 0; row < dstHeight; ++row) {
341 do {
342 int srcItConseq = srcIt0->nConseqPixels();
343 int dstItConseq = dstIt->nConseqPixels();
344 conseqPixels = qMin(srcItConseq, dstItConseq * 2);
345
346 Q_ASSERT(!isOdd(conseqPixels));
347
348 downsamplePixels(srcIt0->oldRawData(), srcIt1->oldRawData(),
349 dstIt->rawData(), conseqPixels);
350
351
352 srcIt1->nextPixels(conseqPixels);
353 dstIt->nextPixels(conseqPixels / 2);
354 } while (srcIt0->nextPixels(conseqPixels));
355 srcIt0->nextRow();
356 srcIt0->nextRow();
357 srcIt1->nextRow();
358 srcIt1->nextRow();
359 dstIt->nextRow();
360 }
361 return QRect(dstX, dstY, dstWidth, dstHeight);
362}
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 364 of file kis_image_pyramid.cpp.

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

◆ 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 468 of file kis_image_pyramid.cpp.

469{
470 KisImagePatch patch = getNearestPatch(info);
471 patch.drawMe(gc, info->viewportRect, info->renderHints);
472}
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 397 of file kis_image_pyramid.cpp.

399{
400 qint32 nearest = 0;
401
402 for (qint32 i = 0; i < m_pyramidHeight; i++) {
403 qreal planeScale = SCALE_FROM_INDEX(i);
404 if (planeScale < scale) {
405 if (originalSize*scale == originalSize*planeScale)
406 nearest = i;
407 break;
408 }
409 nearest = i;
410 }
411
412 // FOR DEBUGGING
413 //nearest = 0;
414 //nearest = qMin(1, nearest);
415
416 dbgRender << "First good plane:" << nearest << "(sc:" << scale << ")";
417 return nearest;
418}
#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 451 of file kis_image_pyramid.cpp.

452{
453 qint32 index = findFirstGoodPlaneIndex(qMax(info->scaleX, info->scaleY),
454 info->imageRect.size());
455 qreal planeScale = SCALE_FROM_INDEX(index);
456 qint32 alignment = 1 << index;
457
458 alignByPow2Hi(info->borderWidth, alignment);
459
460 KisImagePatch patch(info->imageRect, info->borderWidth,
461 planeScale, planeScale);
462
463 patch.setImage(convertToQImageFast(m_pyramid[index],
464 patch.patchRect()));
465 return patch;
466}
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 145 of file kis_image_pyramid.cpp.

146{
147 m_pyramid.clear();
148 for (qint32 i = 0; i < m_pyramidHeight; i++) {
150 }
151}

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 290 of file kis_image_pyramid.cpp.

291{
293 KisPaintDevice *dst;
294 QRect currentSrcRect = info->dirtyImageRectVar;
295
296 for (int i = FIRST_NOT_ORIGINAL_INDEX; i < m_pyramidHeight; i++) {
297 src = m_pyramid[i-1].data();
298 dst = m_pyramid[i].data();
299 if (!currentSrcRect.isEmpty()) {
300 currentSrcRect = downsampleByFactor2(currentSrcRect, src, dst);
301 }
302 }
303
304#ifdef DEBUG_PYRAMID
306 image.save("./PYRAMID_BASE.png");
307
308 image = m_pyramid[1]->convertToQImage(m_monitorProfile, m_renderingIntent, m_conversionFlags);
309 image.save("./LEVEL1.png");
310
311 image = m_pyramid[2]->convertToQImage(m_monitorProfile, m_renderingIntent, m_conversionFlags);
312 image.save("./LEVEL2.png");
313 image = m_pyramid[3]->convertToQImage(m_monitorProfile, m_renderingIntent, m_conversionFlags);
314 image.save("./LEVEL3.png");
315#endif
316}
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 213 of file kis_image_pyramid.cpp.

214{
215 // XXX: use QThreadStorage to cache the two patches (512x512) of pixels. Note
216 // that when we do that, we need to reset that cache when the projection's
217 // colorspace changes.
218 const KoColorSpace *projectionCs = m_originalImage->projection()->colorSpace();
219 KisPaintDeviceSP originalProjection = m_originalImage->projection();
220 quint32 numPixels = rect.width() * rect.height();
221
222 std::unique_ptr<quint8[]> originalBytes(
223 new quint8[originalProjection->colorSpace()->pixelSize() * numPixels]);
224
225 originalProjection->readBytes(originalBytes.get(), rect);
226
227 if (m_displayFilter &&
228 m_useOcio &&
229 projectionCs->colorModelId() == RGBAColorModelID) {
230
231#ifdef HAVE_OCIO
232 const KoColorProfile *destinationProfile =
233 m_displayFilter->useInternalColorManagement() ?
234 m_monitorProfile : projectionCs->profile();
235
236 const KoColorSpace *floatCs =
240 destinationProfile);
241
242 const KoColorSpace *modifiedMonitorCs =
246 destinationProfile);
247
248 if (projectionCs->colorDepthId() == Float32BitsColorDepthID) {
249 m_displayFilter->filter(originalBytes.get(), numPixels);
250 } else {
251 std::unique_ptr<quint8[]> dst(new quint8[floatCs->pixelSize() * numPixels]);
253 m_displayFilter->filter(dst.get(), numPixels);
254 originalBytes.swap(dst);
255 }
256
257 {
258 std::unique_ptr<quint8[]> dst(new quint8[modifiedMonitorCs->pixelSize() * numPixels]);
259 floatCs->convertPixelsTo(originalBytes.get(), dst.get(), modifiedMonitorCs, numPixels, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags());
260 originalBytes.swap(dst);
261 }
262#endif
263 }
264 else {
265 if (m_channelFlags.size() != projectionCs->channelCount()) {
266 setChannelFlags(QBitArray());
267 }
268 if (!m_channelFlags.isEmpty() && !m_allChannelsSelected) {
269 std::unique_ptr<quint8[]> dst(new quint8[projectionCs->pixelSize() * numPixels]);
270
271 KisConfig cfg(true);
272
273 if (m_onlyOneChannelSelected && !cfg.showSingleChannelAsColor()) {
274 projectionCs->convertChannelToVisualRepresentation(originalBytes.get(), dst.get(), numPixels, m_selectedChannelIndex);
275 }
276 else {
277 projectionCs->convertChannelToVisualRepresentation(originalBytes.get(), dst.get(), numPixels, m_channelFlags);
278 }
279 originalBytes.swap(dst);
280 }
281
282 std::unique_ptr<quint8[]> dst(new quint8[m_monitorColorSpace->pixelSize() * numPixels]);
283 projectionCs->convertPixelsTo(originalBytes.get(), dst.get(), m_monitorColorSpace, numPixels, m_renderingIntent, m_conversionFlags);
284 originalBytes.swap(dst);
285 }
286
287 m_pyramid[ORIGINAL_INDEX]->writeBytes(originalBytes.get(), rect);
288}
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 119 of file kis_image_pyramid.cpp.

120{
121 m_channelFlags = channelFlags;
122 int selectedChannels = 0;
123 const KoColorSpace *projectionCs = m_originalImage->projection()->colorSpace();
124 const QList<KoChannelInfo*> channelInfo = projectionCs->channels();
125
126 if (channelInfo.size() != m_channelFlags.size()) {
127 m_channelFlags = QBitArray();
128 }
129
130 for (int i = 0; i < m_channelFlags.size(); ++i) {
131 if (m_channelFlags.testBit(i) && channelInfo[i]->channelType() == KoChannelInfo::COLOR) {
132 selectedChannels++;
134 }
135 }
136 m_allChannelsSelected = (selectedChannels == m_channelFlags.size());
137 m_onlyOneChannelSelected = (selectedChannels == 1);
138}
@ 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 140 of file kis_image_pyramid.cpp.

141{
142 m_displayFilter = displayFilter;
143}

References m_displayFilter.

◆ setImage()

void KisImagePyramid::setImage ( KisImageWSP image)
overridevirtual

Those methods are related to KisPrescaledProjection's equivalents

Implements KisProjectionBackend.

Definition at line 160 of file kis_image_pyramid.cpp.

161{
162 if (newImage) {
163 m_originalImage = newImage;
164
165 clearPyramid();
167
168 // Get the full image size
169 QRect rc = m_originalImage->projection()->exactBounds();
170
171 KisImageConfig config(true);
172
173 int patchWidth = config.updatePatchWidth();
174 int patchHeight = config.updatePatchHeight();
175
176 if (rc.width() * rc.height() <= patchWidth * patchHeight) {
178 }
179 else {
180 qint32 firstCol = rc.x() / patchWidth;
181 qint32 firstRow = rc.y() / patchHeight;
182
183 qint32 lastCol = (rc.x() + rc.width()) / patchWidth;
184 qint32 lastRow = (rc.y() + rc.height()) / patchHeight;
185
186 for(qint32 i = firstRow; i <= lastRow; i++) {
187 for(qint32 j = firstCol; j <= lastCol; j++) {
188 QRect maxPatchRect(j * patchWidth,
189 i * patchHeight,
190 patchWidth, patchHeight);
191 QRect patchRect = rc & maxPatchRect;
192 retrieveImageData(patchRect);
193 }
194 }
195
196 }
197 //TODO: check whether there is needed recalculateCache()
198 }
199}
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 201 of file kis_image_pyramid.cpp.

202{
203 Q_UNUSED(w);
204 Q_UNUSED(h);
205 /* nothing interesting */
206}

◆ 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 103 of file kis_image_pyramid.cpp.

106{
107 m_monitorProfile = monitorProfile;
113 m_renderingIntent = renderingIntent;
114 m_conversionFlags = conversionFlags;
115
117}
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 208 of file kis_image_pyramid.cpp.

209{
210 retrieveImageData(dirtyImageRect);
211}

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: