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

#include <kis_fill_painter.h>

+ Inheritance diagram for KisFillPainter:

Public Types

enum  RegionFillingMode { RegionFillingMode_FloodFill , RegionFillingMode_BoundaryFill }
 
- Public Types inherited from KisPainter
enum  FillStyle {
  FillStyleNone , FillStyleForegroundColor , FillStyleBackgroundColor , FillStylePattern ,
  FillStyleGenerator
}
 This enum contains the styles with which we can fill things like polygons and ellipses. More...
 
enum  StrokeStyle { StrokeStyleNone , StrokeStyleBrush }
 The style of the brush stroke around polygons and so. More...
 

Public Member Functions

bool antiAlias () const
 
bool careForSelection () const
 
uint closeGap () const
 
KisPixelSelectionSP createFloodSelection (int startX, int startY, KisPaintDeviceSP sourceDevice, KisPaintDeviceSP existingSelection)
 
KisPixelSelectionSP createFloodSelection (KisPixelSelectionSP newSelection, int startX, int startY, KisPaintDeviceSP sourceDevice, KisPaintDeviceSP existingSelection)
 
void createSimilarColorsSelection (KisPixelSelectionSP outSelection, const KoColor &referenceColor, KisPaintDeviceSP referenceDevice, const QRect &rect, KisPixelSelectionSP mask)
 
QVector< KisStrokeJobData * > createSimilarColorsSelectionJobs (KisPixelSelectionSP outSelection, const QSharedPointer< KoColor > referenceColor, KisPaintDeviceSP referenceDevice, const QRect &rect, KisPixelSelectionSP mask, QSharedPointer< KisProcessingVisitor::ProgressHelper > progressHelper=nullptr)
 
void eraseRect (const QRect &rc)
 
void eraseRect (qint32 x1, qint32 y1, qint32 w, qint32 h)
 
uint feather () const
 
void fillColor (int startX, int startY, KisPaintDeviceSP sourceDevice)
 
void fillPattern (int startX, int startY, KisPaintDeviceSP sourceDevice, QTransform patternTransform=QTransform())
 
void fillRect (const QRect &rc, const KisPaintDeviceSP device, const QRect &deviceRect)
 
void fillRect (const QRect &rc, const KoColor &c)
 
void fillRect (const QRect &rc, const KoColor &c, quint8 opacity)
 
void fillRect (const QRect &rc, const KoPatternSP pattern, const QPoint &offset=QPoint())
 
void fillRect (qint32 x, qint32 y, qint32 w, qint32 h, const KoColor &c)
 
void fillRect (qint32 x, qint32 y, qint32 w, qint32 h, const KoColor &c, quint8 opacity)
 
void fillRect (qint32 x1, qint32 y1, qint32 w, qint32 h, const KisFilterConfigurationSP generator)
 
void fillRect (qint32 x1, qint32 y1, qint32 w, qint32 h, const KisPaintDeviceSP device, const QRect &deviceRect)
 
void fillRect (qint32 x1, qint32 y1, qint32 w, qint32 h, const KoPatternSP pattern, const QPoint &offset=QPoint())
 
void fillRectNoCompose (const QRect &rc, const KoPatternSP pattern, const QTransform transform)
 fillRect Fill a rectangle with a certain pattern. The pattern is repeated if it does not fit the entire rectangle. Differs from other functions that it uses a transform, does not support composite ops in turn.
 
void fillRectNoCompose (qint32 x1, qint32 y1, qint32 w, qint32 h, const KisPaintDeviceSP device, const QRect &deviceRect, const QTransform transform)
 
void fillSelection (const QRect &rc, const KoColor &color)
 
int fillThreshold () const
 
 KisFillPainter ()
 
 KisFillPainter (KisPaintDeviceSP device)
 
 KisFillPainter (KisPaintDeviceSP device, KisSelectionSP selection)
 
int opacitySpread () const
 
KoColor regionFillingBoundaryColor () const
 
RegionFillingMode regionFillingMode () const
 
void setAntiAlias (bool antiAlias)
 
void setCareForSelection (bool set)
 
void setCloseGap (int gap)
 
void setFeather (int feather)
 
void setFillThreshold (int threshold)
 
void setHeight (int h)
 
void setOpacitySpread (int opacitySpread)
 
void setRegionFillingBoundaryColor (const KoColor &regionFillingBoundaryColor)
 
void setRegionFillingMode (RegionFillingMode regionFillingMode)
 
void setSizemod (int sizemod)
 
void setStopGrowingAtDarkestPixel (bool stopGrowingAtDarkestPixel)
 
void setUseCompositing (bool useCompositing)
 
void setUseSelectionAsBoundary (bool useSelectionAsBoundary)
 
void setWidth (int w)
 
int sizemod () const
 
bool stopGrowingAtDarkestPixel () const
 
bool useCompositing () const
 
uint useSelectionAsBoundary () const
 
- Public Member Functions inherited from KisPainter
void addDirtyRect (const QRect &r)
 
void addDirtyRects (const QVector< QRect > &rects)
 
bool antiAliasPolygonFill ()
 Return whether a polygon's filled area should be anti-aliased or not.
 
void applyDevice (const QRect &applyRect, const KisRenderedDab &dab, KisRandomAccessorSP dstIt, const KoColorSpace *srcColorSpace, KoCompositeOp::ParameterInfo &localParamInfo)
 
void applyDeviceWithSelection (const QRect &applyRect, const KisRenderedDab &dab, KisRandomAccessorSP dstIt, KisRandomConstAccessorSP maskIt, const KoColorSpace *srcColorSpace, KoCompositeOp::ParameterInfo &localParamInfo)
 
const KoColorbackgroundColor () const
 Returns the current background color.
 
void begin (KisPaintDeviceSP device)
 
void begin (KisPaintDeviceSP device, KisSelectionSP selection)
 
void beginTransaction (const KUndo2MagicString &transactionName=KUndo2MagicString(), int timedID=-1)
 Begin an undoable paint operation.
 
void bitBlt (const QPoint &pos, const KisPaintDeviceSP srcDev, const QRect &srcRect)
 
void bitBlt (qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
 
void bitBltOldData (const QPoint &pos, const KisPaintDeviceSP srcDev, const QRect &srcRect)
 
void bitBltOldData (qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
 
void bitBltWithFixedSelection (qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, const KisFixedPaintDeviceSP selection, qint32 selX, qint32 selY, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
 
void bitBltWithFixedSelection (qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, const KisFixedPaintDeviceSP selection, qint32 srcWidth, qint32 srcHeight)
 
void bltFixed (const QPoint &pos, const KisFixedPaintDeviceSP srcDev, const QRect &srcRect)
 
void bltFixed (const QRect &rc, const QList< KisRenderedDab > allSrcDevices)
 
void bltFixed (qint32 dstX, qint32 dstY, const KisFixedPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
 
void bltFixedWithFixedSelection (qint32 dstX, qint32 dstY, const KisFixedPaintDeviceSP srcDev, const KisFixedPaintDeviceSP selection, qint32 selX, qint32 selY, qint32 srcX, qint32 srcY, quint32 srcWidth, quint32 srcHeight)
 
void bltFixedWithFixedSelection (qint32 dstX, qint32 dstY, const KisFixedPaintDeviceSP srcDev, const KisFixedPaintDeviceSP selection, quint32 srcWidth, quint32 srcHeight)
 
const QVector< QPair< QPointF, QPointF > > calculateAllMirroredPoints (const QPair< QPointF, QPointF > &pair)
 
const QVector< QPointF > calculateAllMirroredPoints (const QPointF &pos)
 
const QVector< QRect > calculateAllMirroredRects (const QRect &rc)
 
template<class T >
QVector< T > calculateMirroredObjects (const T &object)
 
QBitArray channelFlags ()
 
const KoCompositeOpcompositeOp (const KoColorSpace *srcCS)
 
QString compositeOpId ()
 Returns the current composite op Id.
 
void copyMirrorInformationFrom (const KisPainter *other)
 
void deleteTransaction ()
 
KisPaintDeviceSP device ()
 
const KisPaintDeviceSP device () const
 Returns the current paint device.
 
void drawDDALine (const QPointF &start, const QPointF &end)
 
void drawLine (const QPointF &start, const QPointF &end)
 
void drawLine (const QPointF &start, const QPointF &end, qreal width, bool antialias)
 
void drawPainterPath (const QPainterPath &path, const QPen &pen)
 
void drawPainterPath (const QPainterPath &path, const QPen &pen, const QRect &requestedRect)
 
void drawThickLine (const QPointF &start, const QPointF &end, int startWidth, int endWidth)
 
void drawWobblyLine (const QPointF &start, const QPointF &end)
 
void drawWuLine (const QPointF &start, const QPointF &end)
 
void end ()
 
KUndo2CommandendAndTakeTransaction ()
 
void endTransaction (KisPostExecutionUndoAdapter *undoAdapter)
 
void endTransaction (KisUndoAdapter *undoAdapter)
 Finish the undoable paint operation.
 
void fill (qint32 x, qint32 y, qint32 width, qint32 height, const KoColor &color)
 
void fillPainterPath (const QPainterPath &path)
 
void fillPainterPath (const QPainterPath &path, const QRect &requestedRect)
 
void fillPainterPathImpl (const QPainterPath &path, const QRect &requestedRect)
 
FillStyle fillStyle () const
 Returns the current fill style.
 
qreal flow () const
 
const KisFilterConfigurationSP generator () const
 
void getBezierCurvePoints (const QPointF &pos1, const QPointF &control1, const QPointF &control2, const QPointF &pos2, vQPointF &points) const
 
const KoAbstractGradientSP gradient () const
 
bool hasDirtyRegion () const
 
bool hasHorizontalMirroring () const
 
bool hasMirroring () const
 
bool hasVerticalMirroring () const
 
bool isOpacityUnit () const
 
 KisPainter ()
 Construct painter without a device.
 
 KisPainter (KisPaintDeviceSP device)
 Construct a painter, and begin painting on the device.
 
 KisPainter (KisPaintDeviceSP device, KisSelectionSP selection)
 Construct a painter, and begin painting on the device. All actions will be masked by the given selection.
 
void mirrorDab (Qt::Orientation direction, KisRenderedDab *dab, bool skipMirrorPixels=false) const
 
void mirrorRect (Qt::Orientation direction, QRect *rc) const
 
qreal opacityF () const
 Returns the opacity that is used in painting.
 
void paintAt (const KisPaintInformation &pos, KisDistanceInformation *savedDist)
 
void paintBezierCurve (const KisPaintInformation &pi1, const QPointF &control1, const QPointF &control2, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance)
 
const KoColorpaintColor () const
 Returns the color that will be used to paint with.
 
void paintEllipse (const qreal x, const qreal y, const qreal w, const qreal h)
 
void paintEllipse (const QRectF &rect)
 
void paintLine (const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance)
 
KisPaintOppaintOp () const
 
void paintPainterPath (const QPainterPath &path)
 
void paintPolygon (const vQPointF &points)
 
void paintPolyline (const QVector< QPointF > &points, int index=0, int numPoints=-1)
 
void paintRect (const qreal x, const qreal y, const qreal w, const qreal h)
 
void paintRect (const QRectF &rect)
 
const KoPatternSP pattern () const
 Returns the currently set pattern.
 
QTransform patternTransform ()
 get the current transform on the pattern.
 
KisPaintOpPresetSP preset () const
 Return the paintop preset.
 
 Private (KisPainter *_q)
 
 Private (KisPainter *_q, const KoColorSpace *cs)
 
void putTransaction (KisTransaction *transaction)
 continue a transaction started somewhere else
 
void renderDabWithMirroringNonIncremental (QRect rc, KisPaintDeviceSP dab)
 
void renderMirrorMask (QRect rc, KisFixedPaintDeviceSP dab)
 
void renderMirrorMask (QRect rc, KisFixedPaintDeviceSP dab, KisFixedPaintDeviceSP mask)
 
void renderMirrorMask (QRect rc, KisPaintDeviceSP dab)
 
void renderMirrorMask (QRect rc, KisPaintDeviceSP dab, int sx, int sy, KisFixedPaintDeviceSP mask)
 
void renderMirrorMaskSafe (QRect rc, KisFixedPaintDeviceSP dab, bool preserveDab)
 
void renderMirrorMaskSafe (QRect rc, KisFixedPaintDeviceSP dab, KisFixedPaintDeviceSP mask, bool preserveDab)
 
void renderMirrorMaskSafe (QRect rc, KisPaintDeviceSP dab, int sx, int sy, KisFixedPaintDeviceSP mask, bool preserveMask)
 
void revertTransaction ()
 Cancel all the changes made by the painter.
 
KisRunnableStrokeJobsInterfacerunnableStrokeJobsInterface () const
 
KisSelectionSP selection ()
 
void setAntiAliasPolygonFill (bool antiAliasPolygonFill)
 Set whether a polygon's filled area should be anti-aliased or not. The default is true.
 
void setAverageOpacity (qreal averageOpacity)
 
void setBackgroundColor (const KoColor &color)
 
void setChannelFlags (QBitArray channelFlags)
 
void setColorConversionFlags (KoColorConversionTransformation::ConversionFlags conversionFlags)
 
void setCompositeOpId (const KoCompositeOp *op)
 
void setCompositeOpId (const QString &op)
 Set the composite op for this painter by string.
 
void setFillStyle (FillStyle fillStyle)
 Set the current style with which to fill.
 
void setFlow (qreal flow)
 
void setGenerator (KisFilterConfigurationSP generator)
 Set the current generator (a generator can be used to fill an area.
 
void setGradient (const KoAbstractGradientSP gradient)
 
void setMaskImageSize (qint32 width, qint32 height)
 
void setMirrorInformation (const QPointF &axesCenter, bool mirrorHorizontally, bool mirrorVertically)
 
void setOpacityF (qreal opacity)
 
void setOpacityToUnit ()
 
void setOpacityU8 (quint8 opacity)
 Set the opacity which is used in painting (like filling polygons)
 
void setOpacityUpdateAverage (qreal opacity)
 
void setPaintColor (const KoColor &color)
 
void setPaintOpPreset (KisPaintOpPresetSP preset, KisNodeSP node, KisImageSP image)
 
void setPattern (const KoPatternSP pattern)
 Set the current pattern.
 
void setPatternTransform (QTransform transform)
 Set the transform on the pattern.
 
void setProgress (KoUpdater *progressUpdater)
 
void setRenderingIntent (KoColorConversionTransformation::Intent intent)
 
void setRunnableStrokeJobsInterface (KisRunnableStrokeJobsInterface *interface)
 
void setSelection (KisSelectionSP selection)
 
void setStrokeStyle (StrokeStyle strokeStyle)
 Set the current brush stroke style.
 
StrokeStyle strokeStyle () const
 Returns the current brush stroke style.
 
QVector< QRect > takeDirtyRegion ()
 
KisTransactiontakeTransaction ()
 take transaction out of the reach of KisPainter
 
bool tryReduceSourceRect (const KisPaintDevice *srcDev, QRect *srcRect, qint32 *srcX, qint32 *srcY, qint32 *srcWidth, qint32 *srcHeight, qint32 *dstX, qint32 *dstY)
 
virtual ~KisPainter ()
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Protected Member Functions

KisSelectionSP currentFillSelection () const
 
void genericFillEnd (KisPaintDeviceSP filled)
 
void genericFillStart (int startX, int startY, KisPaintDeviceSP sourceDevice)
 
void setCurrentFillSelection (KisSelectionSP fillSelection)
 
- Protected Member Functions inherited from KisPainter
void fillPolygon (const vQPointF &points, FillStyle fillStyle)
 Fill the polygon defined by points with the fillStyle.
 
void init ()
 Initialize, set everything to '0' or defaults.
 
KoUpdaterprogressUpdater ()
 

Private Member Functions

void initFillPainter ()
 

Private Attributes

bool m_antiAlias
 
bool m_careForSelection
 
int m_closeGap
 
int m_feather
 
KisSelectionSP m_fillSelection
 
int m_height
 
int m_opacitySpread
 
QRect m_rect
 
KoColor m_regionFillingBoundaryColor
 
RegionFillingMode m_regionFillingMode
 
int m_sizemod
 
bool m_stopGrowingAtDarkestPixel
 
int m_threshold
 
bool m_useCompositing
 
bool m_useSelectionAsBoundary
 
int m_width
 

Additional Inherited Members

- Static Public Member Functions inherited from KisPainter
static qreal blendAverageOpacity (qreal opacity, qreal averageOpacity)
 
static bool checkDeviceHasTransparency (KisPaintDeviceSP dev)
 
static KisPaintDeviceSP convertToAlphaAsAlpha (KisPaintDeviceSP src)
 
static KisPaintDeviceSP convertToAlphaAsGray (KisPaintDeviceSP src)
 
static KisPaintDeviceSP convertToAlphaAsPureAlpha (KisPaintDeviceSP src)
 
static void copyAreaOptimized (const QPoint &dstPt, KisPaintDeviceSP src, KisPaintDeviceSP dst, const QRect &originalSrcRect)
 
static void copyAreaOptimized (const QPoint &dstPt, KisPaintDeviceSP src, KisPaintDeviceSP dst, const QRect &originalSrcRect, KisSelectionSP selection)
 
static void copyAreaOptimizedOldData (const QPoint &dstPt, KisPaintDeviceSP src, KisPaintDeviceSP dst, const QRect &originalSrcRect)
 
- Public Attributes inherited from KisPainter
bool antiAliasPolygonFill {true}
 
QPointF axesCenter
 
KoColor backgroundColor
 
const KoCompositeOpcachedCompositeOp {nullptr}
 
const KoColorSpacecachedSourceColorSpace {nullptr}
 
const KoColorSpacecolorSpace {nullptr}
 
QString compositeOpId
 
KoColorConversionTransformation::ConversionFlags conversionFlags {KoColorConversionTransformation::Empty}
 
KoColor customColor
 
KisPaintDeviceSP device
 
QVector< QRect > dirtyRects
 
QPointF duplicateOffset
 
QScopedPointer< KisRunnableStrokeJobsInterfacefakeRunnableStrokeJobsInterface
 
KisFillPainterfillPainter {nullptr}
 
FillStyle fillStyle {FillStyleNone}
 
KisFilterConfigurationSP generator
 
KoAbstractGradientSP gradient
 
bool isOpacityUnit {true}
 
qint32 maskImageHeight {255}
 
qint32 maskImageWidth {255}
 
QPainter * maskPainter {nullptr}
 
bool mirrorHorizontally {false}
 
bool mirrorVertically {false}
 
KoColor paintColor
 
KisPaintOppaintOp {nullptr}
 
KisPaintOpPresetSP paintOpPreset
 
KoCompositeOp::ParameterInfo paramInfo
 
KoPatternSP pattern
 
QTransform patternTransform
 
quint32 pixelSize {0}
 
KisPaintDeviceSP polygon
 
QImage polygonMaskImage
 
KoColorProfileprofile {nullptr}
 
KoUpdaterprogressUpdater {nullptr}
 
KisPainterq {nullptr}
 
KoColorConversionTransformation::Intent renderingIntent {KoColorConversionTransformation::IntentPerceptual}
 
KisRunnableStrokeJobsInterfacerunnableStrokeJobsInterface {nullptr}
 
KisSelectionSP selection
 
KisPaintLayersourceLayer {nullptr}
 
StrokeStyle strokeStyle {StrokeStyleBrush}
 
KisTransactiontransaction {nullptr}
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Detailed Description

This painter can be used to fill paint devices in different ways. This can also be used for flood filling related operations.

Definition at line 33 of file kis_fill_painter.h.

Member Enumeration Documentation

◆ RegionFillingMode

Enumerator
RegionFillingMode_FloodFill 
RegionFillingMode_BoundaryFill 

Definition at line 37 of file kis_fill_painter.h.

Constructor & Destructor Documentation

◆ KisFillPainter() [1/3]

KisFillPainter::KisFillPainter ( )

Construct an empty painter. Use the begin(KisPaintDeviceSP) method to attach to a paint device

Definition at line 51 of file kis_fill_painter.cc.

52 : KisPainter()
53{
55}
KisPainter()
Construct painter without a device.

References initFillPainter().

◆ KisFillPainter() [2/3]

KisFillPainter::KisFillPainter ( KisPaintDeviceSP device)

Start painting on the specified paint device

Definition at line 57 of file kis_fill_painter.cc.

59{
61}
KisPaintDeviceSP device

References initFillPainter().

◆ KisFillPainter() [3/3]

KisFillPainter::KisFillPainter ( KisPaintDeviceSP device,
KisSelectionSP selection )

Definition at line 63 of file kis_fill_painter.cc.

65{
67}
KisSelectionSP selection

References initFillPainter().

Member Function Documentation

◆ antiAlias()

bool KisFillPainter::antiAlias ( ) const
inline

Get if antiAlias should be applied to the selection

Definition at line 353 of file kis_fill_painter.h.

353 {
354 return m_antiAlias;
355 }

◆ careForSelection()

bool KisFillPainter::careForSelection ( ) const
inline

If true, floodfill doesn't fill outside the selected area of a layer

Definition at line 338 of file kis_fill_painter.h.

338 {
339 return m_careForSelection;
340 }

◆ closeGap()

uint KisFillPainter::closeGap ( ) const
inline

Defines the gap closing radius for the contiguous selection and fill operations. Does not affect the fill similar regions operation.

Definition at line 315 of file kis_fill_painter.h.

315 {
316 return m_closeGap;
317 }

◆ createFloodSelection() [1/2]

KisPixelSelectionSP KisFillPainter::createFloodSelection ( int startX,
int startY,
KisPaintDeviceSP sourceDevice,
KisPaintDeviceSP existingSelection )

Returns a selection mask for the floodfill starting at the specified position. This variant basically creates a new selection object and passes it down to the other variant of the function.

Parameters
startXthe X position where the floodfill starts
startYthe Y position where the floodfill starts
sourceDevicethe sourceDevice that determines the area that is floodfilled if sampleMerged is on

Definition at line 342 of file kis_fill_painter.cc.

344{
346 return createFloodSelection(newSelection, startX, startY, sourceDevice, existingSelection);
347}
KisPixelSelectionSP createFloodSelection(int startX, int startY, KisPaintDeviceSP sourceDevice, KisPaintDeviceSP existingSelection)

References createFloodSelection(), and KisPainter::device.

◆ createFloodSelection() [2/2]

KisPixelSelectionSP KisFillPainter::createFloodSelection ( KisPixelSelectionSP newSelection,
int startX,
int startY,
KisPaintDeviceSP sourceDevice,
KisPaintDeviceSP existingSelection )

Returns a selection mask for the floodfill starting at the specified position. This variant requires an empty selection object. It is used in cases where the pointer to the selection must be known beforehand, for example when the selection is filled in a stroke and then the pointer to the pixel selection is needed later.

Parameters
selectionempty new selection object
startXthe X position where the floodfill starts
startYthe Y position where the floodfill starts
sourceDevicethe sourceDevice that determines the area that is floodfilled if sampleMerged is on

Definition at line 349 of file kis_fill_painter.cc.

351{
352
353 if (m_width < 0 || m_height < 0) {
354 if (selection() && m_careForSelection) {
355 QRect rc = selection()->selectedExactRect();
356 m_width = rc.width() - (startX - rc.x());
357 m_height = rc.height() - (startY - rc.y());
358 }
359 }
360 dbgImage << "Width: " << m_width << " Height: " << m_height;
361 // Otherwise the width and height should have been set
362 Q_ASSERT(m_width > 0 && m_height > 0);
363
364 QRect fillBoundsRect(0, 0, m_width, m_height);
365 QPoint startPoint(startX, startY);
366
367 if (!fillBoundsRect.contains(startPoint)) {
368 return pixelSelection;
369 }
370
371 KisScanlineFill gc(sourceDevice, startPoint, fillBoundsRect);
372 gc.setThreshold(m_threshold);
373 gc.setOpacitySpread(m_useCompositing ? m_opacitySpread : 100);
374 gc.setCloseGap(m_closeGap);
375
377 if (m_useSelectionAsBoundary && !pixelSelection.isNull()) {
378 gc.fillSelection(pixelSelection, existingSelection);
379 } else {
380 gc.fillSelection(pixelSelection);
381 }
382 } else {
383 if (m_useSelectionAsBoundary && !pixelSelection.isNull()) {
384 gc.fillSelectionUntilColor(pixelSelection, m_regionFillingBoundaryColor, existingSelection);
385 } else {
386 gc.fillSelectionUntilColor(pixelSelection, m_regionFillingBoundaryColor);
387 }
388 }
389
390 if (m_useCompositing) {
391 if (m_sizemod > 0) {
394 biggy.process(pixelSelection, pixelSelection->selectedRect().adjusted(-m_sizemod, -m_sizemod, m_sizemod, m_sizemod));
395 } else {
397 biggy.process(pixelSelection, pixelSelection->selectedRect().adjusted(-m_sizemod, -m_sizemod, m_sizemod, m_sizemod));
398 }
399 }
400 else if (m_sizemod < 0) {
402 tiny.process(pixelSelection, pixelSelection->selectedRect());
403 }
404 // Since the feathering already smooths the selection, the antiAlias
405 // is not applied if we must feather
406 if (m_feather > 0) {
408 feathery.process(pixelSelection, pixelSelection->selectedRect().adjusted(-m_feather, -m_feather, m_feather, m_feather));
409 } else if (m_antiAlias) {
410 KisAntiAliasSelectionFilter antiAliasFilter;
411 antiAliasFilter.process(pixelSelection, pixelSelection->selectedRect());
412 }
413 }
414
415 return pixelSelection;
416}
AntiAlias filter for selections inspired by FXAA.
void process(KisPixelSelectionSP pixelSelection, const QRect &rect) override
KoColor m_regionFillingBoundaryColor
RegionFillingMode m_regionFillingMode
Filter that dilates a selection and that can stop dilating adaptively at areas of higher darkness or ...
#define dbgImage
Definition kis_debug.h:46
QRect selectedExactRect() const
Slow, but exact way of determining the rectangle that encloses the selection.

References dbgImage, KisScanlineFill::fillSelection(), KisScanlineFill::fillSelectionUntilColor(), KisSharedPtr< T >::isNull(), m_antiAlias, m_careForSelection, m_closeGap, m_feather, m_height, m_opacitySpread, m_regionFillingBoundaryColor, m_regionFillingMode, m_sizemod, m_stopGrowingAtDarkestPixel, m_threshold, m_useCompositing, m_useSelectionAsBoundary, m_width, KisFeatherSelectionFilter::process(), KisGrowSelectionFilter::process(), KisShrinkSelectionFilter::process(), KisAntiAliasSelectionFilter::process(), KisGrowUntilDarkestPixelSelectionFilter::process(), RegionFillingMode_FloodFill, KisSelection::selectedExactRect(), KisPixelSelection::selectedRect(), KisPainter::selection, KisScanlineFill::setCloseGap(), KisScanlineFill::setOpacitySpread(), and KisScanlineFill::setThreshold().

◆ createSimilarColorsSelection()

void KisFillPainter::createSimilarColorsSelection ( KisPixelSelectionSP outSelection,
const KoColor & referenceColor,
KisPaintDeviceSP referenceDevice,
const QRect & rect,
KisPixelSelectionSP mask )

Fills all the pixels of the outSelection device inside rect if the corresponding pixels on referenceDevice are similar to referenceColor

Parameters
outSelectionthe selection where the values are written to
referenceColorthe color that we have to compare pixels to
referenceDevicethe device that we have to use to compare colors
rectthe rectangle that defines the area to be processed
maska selection to mask the results. Set to nullptr if not needed

Definition at line 476 of file kis_fill_painter.cc.

481{
482 if (rect.isEmpty()) {
483 return;
484 }
485
486 KoColor srcColor(referenceColor);
487 srcColor.convertTo(referenceDevice->colorSpace());
488
489 const int pixelSize = referenceDevice->pixelSize();
490 const int softness = 100 - opacitySpread();
491
492 using namespace KisColorSelectionPolicies;
493
494 if (softness == 0) {
496 if (pixelSize == 1) {
498 createSimilarColorsSelectionImpl(outSelection, referenceDevice, rect, mask, dp, sp);
499 } else if (pixelSize == 2) {
501 createSimilarColorsSelectionImpl(outSelection, referenceDevice, rect, mask, dp, sp);
502 } else if (pixelSize == 4) {
504 createSimilarColorsSelectionImpl(outSelection, referenceDevice, rect, mask, dp, sp);
505 } else if (pixelSize == 8) {
507 createSimilarColorsSelectionImpl(outSelection, referenceDevice, rect, mask, dp, sp);
508 } else {
509 SlowDifferencePolicy dp(srcColor, fillThreshold());
510 createSimilarColorsSelectionImpl(outSelection, referenceDevice, rect, mask, dp, sp);
511 }
512 } else {
513 SoftSelectionPolicy sp(fillThreshold(), softness);
514 if (pixelSize == 1) {
516 createSimilarColorsSelectionImpl(outSelection, referenceDevice, rect, mask, dp, sp);
517 } else if (pixelSize == 2) {
519 createSimilarColorsSelectionImpl(outSelection, referenceDevice, rect, mask, dp, sp);
520 } else if (pixelSize == 4) {
522 createSimilarColorsSelectionImpl(outSelection, referenceDevice, rect, mask, dp, sp);
523 } else if (pixelSize == 8) {
525 createSimilarColorsSelectionImpl(outSelection, referenceDevice, rect, mask, dp, sp);
526 } else {
527 SlowDifferencePolicy dp(srcColor, fillThreshold());
528 createSimilarColorsSelectionImpl(outSelection, referenceDevice, rect, mask, dp, sp);
529 }
530 }
531}
int fillThreshold() const
int opacitySpread() const
quint32 pixelSize() const
const KoColorSpace * colorSpace() const
quint32 pixelSize
void createSimilarColorsSelectionImpl(KisPixelSelectionSP outSelection, KisPaintDeviceSP referenceDevice, const QRect &rect, KisPixelSelectionSP mask, DifferencePolicy differencePolicy, SelectionPolicy selectionPolicy, KoUpdater *updater=nullptr)

References KisPaintDevice::colorSpace(), KoColor::convertTo(), createSimilarColorsSelectionImpl(), fillThreshold(), opacitySpread(), KisPaintDevice::pixelSize(), and KisPainter::pixelSize.

◆ createSimilarColorsSelectionJobs()

QVector< KisStrokeJobData * > KisFillPainter::createSimilarColorsSelectionJobs ( KisPixelSelectionSP outSelection,
const QSharedPointer< KoColor > referenceColor,
KisPaintDeviceSP referenceDevice,
const QRect & rect,
KisPixelSelectionSP mask,
QSharedPointer< KisProcessingVisitor::ProgressHelper > progressHelper = nullptr )

Create a list of jobs that will fill synchronously all the pixels of the outSelection device inside rect if the corresponding pixels on referenceDevice are similar to referenceColor. rect is split into smaller rects if needed, and the painting of each one is distributed on several jobs

Parameters
outSelectionthe selection where the values are written to
referenceColorthe color that we have to compare pixels to
referenceDevicethe device that we have to use to compare colors
rectthe rectangle that defines the area to be processed
maska selection to mask the results. Set to nullptr if not needed

Definition at line 533 of file kis_fill_painter.cc.

541{
542 if (rect.isEmpty()) {
543 return {};
544 }
545
547 QVector<QRect> fillPatches =
549 const int threshold = fillThreshold();
550 const int softness = 100 - opacitySpread();
551 const int sizemod = this->sizemod();
553 const int feather = this->feather();
554 const bool antiAlias = this->antiAlias();
555
556 KritaUtils::addJobBarrier(jobsData, nullptr);
557
558 for (const QRect &patch : fillPatches) {
560 jobsData,
561 [referenceDevice, outSelection, mask, referenceColor,
562 threshold, softness, patch, progressHelper]() mutable
563 {
564 if (patch.isEmpty()) {
565 return;
566 }
567
568 KoUpdater *updater = progressHelper ? progressHelper->updater() : nullptr;
569
570 using namespace KisColorSelectionPolicies;
571
572 const int pixelSize = referenceDevice->pixelSize();
573 KoColor srcColor(*referenceColor);
574 srcColor.convertTo(referenceDevice->colorSpace());
575
576 if (softness == 0) {
577 HardSelectionPolicy sp(threshold);
578 if (pixelSize == 1) {
579 OptimizedDifferencePolicy<quint8> dp(srcColor, threshold);
580 createSimilarColorsSelectionImpl(outSelection, referenceDevice, patch, mask, dp, sp, updater);
581 } else if (pixelSize == 2) {
582 OptimizedDifferencePolicy<quint16> dp(srcColor, threshold);
583 createSimilarColorsSelectionImpl(outSelection, referenceDevice, patch, mask, dp, sp, updater);
584 } else if (pixelSize == 4) {
585 OptimizedDifferencePolicy<quint32> dp(srcColor, threshold);
586 createSimilarColorsSelectionImpl(outSelection, referenceDevice, patch, mask, dp, sp, updater);
587 } else if (pixelSize == 8) {
588 OptimizedDifferencePolicy<quint64> dp(srcColor, threshold);
589 createSimilarColorsSelectionImpl(outSelection, referenceDevice, patch, mask, dp, sp, updater);
590 } else {
591 SlowDifferencePolicy dp(srcColor, threshold);
592 createSimilarColorsSelectionImpl(outSelection, referenceDevice, patch, mask, dp, sp, updater);
593 }
594 } else {
595 SoftSelectionPolicy sp(threshold, softness);
596 if (pixelSize == 1) {
597 OptimizedDifferencePolicy<quint8> dp(srcColor, threshold);
598 createSimilarColorsSelectionImpl(outSelection, referenceDevice, patch, mask, dp, sp, updater);
599 } else if (pixelSize == 2) {
600 OptimizedDifferencePolicy<quint16> dp(srcColor, threshold);
601 createSimilarColorsSelectionImpl(outSelection, referenceDevice, patch, mask, dp, sp, updater);
602 } else if (pixelSize == 4) {
603 OptimizedDifferencePolicy<quint32> dp(srcColor, threshold);
604 createSimilarColorsSelectionImpl(outSelection, referenceDevice, patch, mask, dp, sp, updater);
605 } else if (pixelSize == 8) {
606 OptimizedDifferencePolicy<quint64> dp(srcColor, threshold);
607 createSimilarColorsSelectionImpl(outSelection, referenceDevice, patch, mask, dp, sp, updater);
608 } else {
609 SlowDifferencePolicy dp(srcColor, threshold);
610 createSimilarColorsSelectionImpl(outSelection, referenceDevice, patch, mask, dp, sp, updater);
611 }
612 }
613 }
614 );
615 }
616
618 jobsData,
619 [outSelection, referenceDevice, mask,
620 sizemod, stopGrowingAtDarkestPixel, feather, antiAlias, progressHelper]() mutable
621 {
622 KoUpdater *updater = progressHelper ? progressHelper->updater() : nullptr;
623
624 if (sizemod > 0) {
626 KisGrowUntilDarkestPixelSelectionFilter biggy(sizemod, referenceDevice);
627 biggy.process(outSelection, outSelection->selectedRect().adjusted(-sizemod, -sizemod, sizemod, sizemod));
628 } else {
630 biggy.process(outSelection, outSelection->selectedRect().adjusted(-sizemod, -sizemod, sizemod, sizemod));
631 }
632 } else if (sizemod < 0) {
634 tiny.process(outSelection, outSelection->selectedRect());
635 }
636 if (updater) {
637 updater->setProgress(33);
638 }
639
640 // Since the feathering already smooths the selection, the antiAlias
641 // is not applied if we must feather
642 if (feather > 0) {
644 feathery.process(outSelection, outSelection->selectedRect().adjusted(-feather, -feather, feather, feather));
645 } else if (antiAlias) {
646 KisAntiAliasSelectionFilter antiAliasFilter;
647 antiAliasFilter.process(outSelection, outSelection->selectedRect());
648 }
649 if (updater) {
650 updater->setProgress(66);
651 }
652
653 if (mask) {
654 outSelection->applySelection(mask, SELECTION_INTERSECT);
655 }
656 if (updater) {
657 updater->setProgress(100);
658 }
659 }
660 );
661
662 return jobsData;
663}
@ SELECTION_INTERSECT
int sizemod() const
bool antiAlias() const
uint feather() const
bool stopGrowingAtDarkestPixel() const
void setProgress(int percent)
Definition KoUpdater.cpp:38
QVector< QRect > splitRectIntoPatches(const QRect &rc, const QSize &patchSize)
void addJobConcurrent(QVector< Job * > &jobs, Func func)
void addJobSequential(QVector< Job * > &jobs, Func func)
void addJobBarrier(QVector< Job * > &jobs, Func func)
QSize optimalPatchSize()
void applySelection(KisPixelSelectionSP selection, SelectionAction action)

References KritaUtils::addJobBarrier(), KritaUtils::addJobConcurrent(), KritaUtils::addJobSequential(), antiAlias(), KisPixelSelection::applySelection(), KisPaintDevice::colorSpace(), KoColor::convertTo(), createSimilarColorsSelectionImpl(), feather(), fillThreshold(), opacitySpread(), KritaUtils::optimalPatchSize(), KisPaintDevice::pixelSize(), KisPainter::pixelSize, KisFeatherSelectionFilter::process(), KisGrowSelectionFilter::process(), KisShrinkSelectionFilter::process(), KisAntiAliasSelectionFilter::process(), KisGrowUntilDarkestPixelSelectionFilter::process(), KisPixelSelection::selectedRect(), SELECTION_INTERSECT, KoUpdater::setProgress(), sizemod(), KritaUtils::splitRectIntoPatches(), and stopGrowingAtDarkestPixel().

◆ currentFillSelection()

KisSelectionSP KisFillPainter::currentFillSelection ( ) const
inlineprotected

Definition at line 435 of file kis_fill_painter.h.

436 {
437 return m_fillSelection;
438 }
KisSelectionSP m_fillSelection

◆ eraseRect() [1/2]

void KisFillPainter::eraseRect ( const QRect & rc)
inline

Overloaded version of the above function.

Definition at line 140 of file kis_fill_painter.h.

141 {
143 KoColor c(Qt::black, cs);
144 fillRect(rc.x(),
145 rc.y(),
146 rc.width(),
147 rc.height(),
148 c,
150 }
const quint8 OPACITY_TRANSPARENT_U8
void fillRect(qint32 x, qint32 y, qint32 w, qint32 h, const KoColor &c, quint8 opacity)
static KoColorSpaceRegistry * instance()
const KoColorSpace * rgb8(const QString &profileName=QString())

References KoColorSpaceRegistry::instance(), OPACITY_TRANSPARENT_U8, and KoColorSpaceRegistry::rgb8().

◆ eraseRect() [2/2]

void KisFillPainter::eraseRect ( qint32 x1,
qint32 y1,
qint32 w,
qint32 h )
inline

Fill a rectangle with black transparent pixels (0, 0, 0, 0 for RGBA).

Definition at line 130 of file kis_fill_painter.h.

131 {
133 KoColor c(Qt::black, cs);
134 fillRect(x1, y1, w, h, c, OPACITY_TRANSPARENT_U8);
135 }

References KoColorSpaceRegistry::instance(), OPACITY_TRANSPARENT_U8, and KoColorSpaceRegistry::rgb8().

◆ feather()

uint KisFillPainter::feather ( ) const
inline

defines the feathering radius for selection flood operations, this affects every fill operation except fillRect

Definition at line 375 of file kis_fill_painter.h.

375 {
376 return m_feather;
377 }

◆ fillColor()

void KisFillPainter::fillColor ( int startX,
int startY,
KisPaintDeviceSP sourceDevice )

Fills the enclosed area around the point with the set color. If there is a selection, the whole selection is filled. Note that you must have set the width and height on the painter if you don't have a selection.

Parameters
startXthe X position where the floodfill starts
startYthe Y position where the floodfill starts
sourceDevicethe sourceDevice that determines the area that is floodfilled if sampleMerged is on

Definition at line 234 of file kis_fill_painter.cc.

235{
236 if (!m_useCompositing) {
237 if (m_sizemod || m_feather ||
239 !isOpacityUnit() ||
240 sourceDevice != device()) {
241
242 warnKrita << "WARNING: Fast Flood Fill (no compositing mode)"
243 << "does not support compositeOps, opacity, "
244 << "selection enhancements and separate source "
245 << "devices";
246 }
247
248 QRect fillBoundsRect(0, 0, m_width, m_height);
249 QPoint startPoint(startX, startY);
250
251 if (!fillBoundsRect.contains(startPoint)) return;
252
253 KisScanlineFill gc(device(), startPoint, fillBoundsRect);
254 gc.setThreshold(m_threshold);
256 gc.fill(paintColor());
257 } else {
258 gc.fillUntilColor(paintColor(), m_regionFillingBoundaryColor);
259 }
260
261 addDirtyRect(gc.fillExtent());
262
263 } else {
264 genericFillStart(startX, startY, sourceDevice);
265
266 // Now create a layer and fill it
268 Q_CHECK_PTR(filled);
269 KisFillPainter painter(filled);
270 painter.fillRect(0, 0, m_width, m_height, paintColor());
271 painter.end();
272
273 genericFillEnd(filled);
274 }
275}
const QString COMPOSITE_OVER
void genericFillEnd(KisPaintDeviceSP filled)
void genericFillStart(int startX, int startY, KisPaintDeviceSP sourceDevice)
KisPaintDeviceSP createCompositionSourceDevice() const
QString compositeOpId
bool isOpacityUnit
KoColor paintColor
void addDirtyRect(const QRect &r)
#define warnKrita
Definition kis_debug.h:87

References KisPainter::addDirtyRect(), COMPOSITE_OVER, KisPainter::compositeOpId, KisPaintDevice::createCompositionSourceDevice(), KisPainter::device, KisPainter::end(), KisScanlineFill::fill(), KisScanlineFill::fillExtent, fillRect(), KisScanlineFill::fillUntilColor(), genericFillEnd(), genericFillStart(), KisPainter::isOpacityUnit, m_feather, m_height, m_regionFillingBoundaryColor, m_regionFillingMode, m_sizemod, m_threshold, m_useCompositing, m_width, KisPainter::paintColor, RegionFillingMode_FloodFill, KisScanlineFill::setThreshold(), and warnKrita.

◆ fillPattern()

void KisFillPainter::fillPattern ( int startX,
int startY,
KisPaintDeviceSP sourceDevice,
QTransform patternTransform = QTransform() )

Fills the enclosed area around the point with the set pattern. If there is a selection, the whole selection is filled. Note that you must have set the width and height on the painter if you don't have a selection.

Parameters
startXthe X position where the floodfill starts
startYthe Y position where the floodfill starts
sourceDevicethe sourceDevice that determines the area that is floodfilled if sampleMerged is on
patternTransformtransform applied to the pattern;

Definition at line 277 of file kis_fill_painter.cc.

278{
279 genericFillStart(startX, startY, sourceDevice);
280
281 // Now create a layer and fill it
283 Q_CHECK_PTR(filled);
284 KisFillPainter painter(filled);
285 painter.fillRectNoCompose(QRect(0, 0, m_width, m_height), pattern(), patternTransform);
286 painter.end();
287
288 genericFillEnd(filled);
289}
QTransform patternTransform
KoPatternSP pattern

References KisPaintDevice::createCompositionSourceDevice(), KisPainter::device, KisPainter::end(), fillRectNoCompose(), genericFillEnd(), genericFillStart(), m_height, m_width, KisPainter::pattern, and KisPainter::patternTransform.

◆ fillRect() [1/9]

void KisFillPainter::fillRect ( const QRect & rc,
const KisPaintDeviceSP device,
const QRect & deviceRect )

Overloaded version of the above function.

Definition at line 174 of file kis_fill_painter.cc.

175{
176 fillRect(rc.x(), rc.y(), rc.width(), rc.height(), device, deviceRect);
177}

References KisPainter::device, and fillRect().

◆ fillRect() [2/9]

void KisFillPainter::fillRect ( const QRect & rc,
const KoColor & c )
inline

Overloaded version of the above function.

Definition at line 98 of file kis_fill_painter.h.

99 {
100 fillRect(rc.x(), rc.y(), rc.width(), rc.height(), c, OPACITY_OPAQUE_U8);
101 }
const quint8 OPACITY_OPAQUE_U8

References OPACITY_OPAQUE_U8.

◆ fillRect() [3/9]

void KisFillPainter::fillRect ( const QRect & rc,
const KoColor & c,
quint8 opacity )
inline

Overloaded version of the above function.

Definition at line 81 of file kis_fill_painter.h.

82 {
83 fillRect(rc.x(), rc.y(), rc.width(), rc.height(), c, opacity);
84 }

◆ fillRect() [4/9]

void KisFillPainter::fillRect ( const QRect & rc,
const KoPatternSP pattern,
const QPoint & offset = QPoint() )

Overloaded version of the above function.

Definition at line 112 of file kis_fill_painter.cc.

113{
114 fillRect(rc.x(), rc.y(), rc.width(), rc.height(), pattern, offset);
115}

References fillRect(), and KisPainter::pattern.

◆ fillRect() [5/9]

void KisFillPainter::fillRect ( qint32 x,
qint32 y,
qint32 w,
qint32 h,
const KoColor & c )
inline

Fill a rectangle with a certain color.

Definition at line 90 of file kis_fill_painter.h.

91 {
92 fillRect(x, y, w, h, c, OPACITY_OPAQUE_U8);
93 }

References OPACITY_OPAQUE_U8.

◆ fillRect() [6/9]

void KisFillPainter::fillRect ( qint32 x,
qint32 y,
qint32 w,
qint32 h,
const KoColor & c,
quint8 opacity )

Fill a rectangle with a certain color and opacity.

Definition at line 96 of file kis_fill_painter.cc.

97{
98 if (w > 0 && h > 0) {
99 // Make sure we're in the right colorspace
100
101 KoColor kc2(kc); // get rid of const
102 kc2.convertTo(device()->colorSpace());
103 quint8 * data = kc2.data();
104 device()->colorSpace()->setOpacity(data, opacity, 1);
105
106 device()->fill(x1, y1, w, h, data);
107
108 addDirtyRect(QRect(x1, y1, w, h));
109 }
110}
void fill(const QRect &rc, const KoColor &color)
const KoColorSpace * colorSpace
virtual void setOpacity(quint8 *pixels, quint8 alpha, qint32 nPixels) const =0

References KisPainter::addDirtyRect(), KisPaintDevice::colorSpace(), KisPainter::colorSpace, KoColor::convertTo(), KoColor::data(), KisPainter::device, KisPaintDevice::fill(), and KoColorSpace::setOpacity().

◆ fillRect() [7/9]

void KisFillPainter::fillRect ( qint32 x1,
qint32 y1,
qint32 w,
qint32 h,
const KisFilterConfigurationSP generator )

Fill the specified area with the output of the generator plugin that is configured in the generator parameter

Definition at line 215 of file kis_fill_painter.cc.

216{
217 if (!generator) return;
219 if (!device()) return;
220 if (w < 1) return;
221 if (h < 1) return;
222
223 QRect tmpRc(x1, y1, w, h);
224
225 KisProcessingInformation dstCfg(device(), tmpRc.topLeft(), 0);
226
227 g->generate(dstCfg, tmpRc.size(), generator);
228
229 addDirtyRect(tmpRc);
230}
static KisGeneratorRegistry * instance()
virtual void generate(KisProcessingInformation dst, const QSize &size, const KisFilterConfigurationSP config, KoUpdater *progressUpdater) const =0
KisFilterConfigurationSP generator
const T value(const QString &id) const

References KisPainter::addDirtyRect(), KisPainter::device, KisGenerator::generate(), KisPainter::generator, KisGeneratorRegistry::instance(), and KoGenericRegistry< T >::value().

◆ fillRect() [8/9]

void KisFillPainter::fillRect ( qint32 x1,
qint32 y1,
qint32 w,
qint32 h,
const KisPaintDeviceSP device,
const QRect & deviceRect )

Fill a rectangle with a certain pattern. The pattern is repeated if it does not fit the entire rectangle.

This one uses blitting and thus makes use of proper composition.

Definition at line 179 of file kis_fill_painter.cc.

180{
181 const QRect &patternRect = deviceRect;
182 const QRect fillRect(x1, y1, w, h);
183
184 auto toPatternLocal = [](int value, int offset, int width) {
185 const int normalizedValue = value - offset;
186 return offset + (normalizedValue >= 0 ?
187 normalizedValue % width :
188 width - (-normalizedValue - 1) % width - 1);
189 };
190
191 int dstY = fillRect.y();
192 while (dstY <= fillRect.bottom()) {
193 const int dstRowsRemaining = fillRect.bottom() - dstY + 1;
194
195 const int srcY = toPatternLocal(dstY, patternRect.y(), patternRect.height());
196 const int height = qMin(patternRect.height() - srcY + patternRect.y(), dstRowsRemaining);
197
198 int dstX = fillRect.x();
199 while (dstX <= fillRect.right()) {
200 const int dstColumnsRemaining = fillRect.right() - dstX + 1;
201
202 const int srcX = toPatternLocal(dstX, patternRect.x(), patternRect.width());
203 const int width = qMin(patternRect.width() - srcX + patternRect.x(), dstColumnsRemaining);
204
205 bitBlt(dstX, dstY, device, srcX, srcY, width, height);
206
207 dstX += width;
208 }
209 dstY += height;
210 }
211
212 addDirtyRect(QRect(x1, y1, w, h));
213}
float value(const T *src, size_t ch)
void bitBlt(qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)

References KisPainter::addDirtyRect(), KisPainter::bitBlt(), KisPainter::device, fillRect(), and value().

◆ fillRect() [9/9]

void KisFillPainter::fillRect ( qint32 x1,
qint32 y1,
qint32 w,
qint32 h,
const KoPatternSP pattern,
const QPoint & offset = QPoint() )

Fill a rectangle with a certain pattern. The pattern is repeated if it does not fit the entire rectangle.

Definition at line 117 of file kis_fill_painter.cc.

118{
119 if (!pattern) return;
120 if (!pattern->valid()) return;
121 if (!device()) return;
122 if (w < 1) return;
123 if (h < 1) return;
124
125 KisPaintDeviceSP patternLayer = new KisPaintDevice(device()->compositionSourceColorSpace(), pattern->name());
126 patternLayer->convertFromQImage(pattern->pattern(), 0);
127
128 if (!offset.isNull()) {
129 patternLayer->moveTo(offset);
130 }
131
132 fillRect(x1, y1, w, h, patternLayer, QRect(offset.x(), offset.y(), pattern->width(), pattern->height()));
133}
void convertFromQImage(const QImage &image, const KoColorProfile *profile, qint32 offsetX=0, qint32 offsetY=0)
void moveTo(qint32 x, qint32 y)

References KisPaintDevice::convertFromQImage(), KisPainter::device, fillRect(), KisPaintDevice::moveTo(), and KisPainter::pattern.

◆ fillRectNoCompose() [1/2]

void KisFillPainter::fillRectNoCompose ( const QRect & rc,
const KoPatternSP pattern,
const QTransform transform )

fillRect Fill a rectangle with a certain pattern. The pattern is repeated if it does not fit the entire rectangle. Differs from other functions that it uses a transform, does not support composite ops in turn.

Parameters
rcrectangle to fill.
patternpattern to use.
transformtransformation to apply to the pattern.

Definition at line 135 of file kis_fill_painter.cc.

136{
137 if (!pattern) return;
138 if (!pattern->valid()) return;
139 if (!device()) return;
140 if (rc.width() < 1) return;
141 if (rc.height() < 1) return;
142
143 KisPaintDeviceSP patternLayer = new KisPaintDevice(device()->colorSpace(), pattern->name());
144 patternLayer->convertFromQImage(pattern->pattern(), 0);
145
146 fillRectNoCompose(rc.x(), rc.y(), rc.width(), rc.height(), patternLayer, QRect(0, 0, pattern->width(), pattern->height()), transform);
147}
void fillRectNoCompose(const QRect &rc, const KoPatternSP pattern, const QTransform transform)
fillRect Fill a rectangle with a certain pattern. The pattern is repeated if it does not fit the enti...

References KisPainter::colorSpace, KisPaintDevice::convertFromQImage(), KisPainter::device, fillRectNoCompose(), and KisPainter::pattern.

◆ fillRectNoCompose() [2/2]

void KisFillPainter::fillRectNoCompose ( qint32 x1,
qint32 y1,
qint32 w,
qint32 h,
const KisPaintDeviceSP device,
const QRect & deviceRect,
const QTransform transform )

Fill a rectangle with a certain pattern. The pattern is repeated if it does not fit the entire rectangle.

This one supports transforms, but does not use blitting.

Since this function doesn't do any kind of compositing, so the pixel size of the source and destination devices must be exactly the same. The color space should ideally be also the same.

Definition at line 149 of file kis_fill_painter.cc.

150{
156 KIS_SAFE_ASSERT_RECOVER_RETURN(device->pixelSize() == this->device()->pixelSize());
157 KIS_SAFE_ASSERT_RECOVER_NOOP(*device->colorSpace() == *this->device()->colorSpace());
158
159 KisPaintDeviceSP wrapped = device;
160 KisDefaultBoundsBaseSP oldBounds = wrapped->defaultBounds();
161 wrapped->setDefaultBounds(new KisWrapAroundBoundsWrapper(oldBounds, deviceRect));
162 const bool oldSupportsWrapAroundMode = wrapped->supportsWraproundMode();
163 wrapped->setSupportsWraparoundMode(true);
164
165
166 KisPerspectiveTransformWorker worker(this->device(), transform, false, this->progressUpdater());
167 worker.runPartialDst(device, this->device(), QRect(x1, y1, w, h));
168
169 addDirtyRect(QRect(x1, y1, w, h));
170 wrapped->setDefaultBounds(oldBounds);
171 wrapped->setSupportsWraparoundMode(oldSupportsWrapAroundMode);
172}
bool supportsWraproundMode() const
void setDefaultBounds(KisDefaultBoundsBaseSP bounds)
void setSupportsWraparoundMode(bool value)
KisDefaultBoundsBaseSP defaultBounds() const
KoUpdater * progressUpdater
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
The KisWrapAroundBoundsWrapper class wrapper around a KisDefaultBoundsBaseSP to enable wraparound....

References KisPainter::addDirtyRect(), KisPaintDevice::colorSpace(), KisPaintDevice::defaultBounds(), KisPainter::device, KIS_SAFE_ASSERT_RECOVER_NOOP, KIS_SAFE_ASSERT_RECOVER_RETURN, KisPaintDevice::pixelSize(), KisPainter::progressUpdater, KisPerspectiveTransformWorker::runPartialDst(), KisPaintDevice::setDefaultBounds(), KisPaintDevice::setSupportsWraparoundMode(), and KisPaintDevice::supportsWraproundMode().

◆ fillSelection()

void KisFillPainter::fillSelection ( const QRect & rc,
const KoColor & color )

Fill current selection of KisPainter with a specified color.

The filling rect is limited by rc to allow multithreaded filling/processing.

Definition at line 85 of file kis_fill_painter.cc.

86{
87 KisPaintDeviceSP fillDevice = new KisPaintDevice(device()->colorSpace());
88 fillDevice->setDefaultPixel(color);
89
90 bitBlt(rc.topLeft(), fillDevice, rc);
91}
void setDefaultPixel(const KoColor &defPixel)

References KisPainter::bitBlt(), KisPainter::colorSpace, KisPainter::device, and KisPaintDevice::setDefaultPixel().

◆ fillThreshold()

int KisFillPainter::fillThreshold ( ) const
inline

Returns the fill threshold, see setFillThreshold for details

Definition at line 281 of file kis_fill_painter.h.

281 {
282 return m_threshold;
283 }

◆ genericFillEnd()

void KisFillPainter::genericFillEnd ( KisPaintDeviceSP filled)
protected

Apply the real selection to a filled one

Definition at line 306 of file kis_fill_painter.cc.

307{
308 if (progressUpdater() && progressUpdater()->interrupted()) {
309 m_width = m_height = -1;
310 return;
311 }
312
313// TODO: filling using the correct bound of the selection would be better, *but*
314// the selection is limited to the exact bound of a layer, while in reality, we don't
315// want that, since we want a transparent layer to be completely filled
316// QRect rc = m_fillSelection->selectedExactRect();
317
318
322 KisSelectionSP realSelection = selection();
323 QRect rc;
324
325 if (realSelection) {
326 rc = m_fillSelection->selectedExactRect().intersected(realSelection->projection()->selectedExactRect());
328 realSelection->projection(), SELECTION_INTERSECT);
329 } else {
331 }
332
334 bitBlt(rc.topLeft(), filled, rc);
335 setSelection(realSelection);
336
338
339 m_width = m_height = -1;
340}
void setSelection(KisSelectionSP selection)
QRect selectedExactRect() const
KisPixelSelectionSP projection() const
KisPixelSelectionSP pixelSelection

References KisPixelSelection::applySelection(), KisPainter::bitBlt(), m_fillSelection, m_height, m_width, KisSelection::pixelSelection, KisPainter::progressUpdater, KisSelection::projection(), KisPixelSelection::selectedExactRect(), KisSelection::selectedExactRect(), KisPainter::selection, SELECTION_INTERSECT, KoUpdater::setProgress(), and KisPainter::setSelection().

◆ genericFillStart()

void KisFillPainter::genericFillStart ( int startX,
int startY,
KisPaintDeviceSP sourceDevice )
protected

Definition at line 291 of file kis_fill_painter.cc.

292{
293 Q_ASSERT(m_width > 0);
294 Q_ASSERT(m_height > 0);
295
296 // Create a selection from the surrounding area
297
298 KisPixelSelectionSP pixelSelection = createFloodSelection(startX, startY, sourceDevice,
299 (selection().isNull() ? 0 : selection()->pixelSelection()));
300 KisSelectionSP newSelection = new KisSelection(pixelSelection->defaultBounds(),
301 selection() ? selection()->resolutionProxy() : KisImageResolutionProxy::identity());
302 newSelection->pixelSelection()->applySelection(pixelSelection, SELECTION_REPLACE);
303 m_fillSelection = newSelection;
304}
@ SELECTION_REPLACE

References KisPixelSelection::applySelection(), createFloodSelection(), KisPaintDevice::defaultBounds(), KisImageResolutionProxy::identity(), m_fillSelection, m_height, m_width, KisSelection::pixelSelection, KisPainter::selection, and SELECTION_REPLACE.

◆ initFillPainter()

◆ opacitySpread()

int KisFillPainter::opacitySpread ( ) const
inline

Returns the fill opacity spread, see setOpacitySpread for details

Definition at line 302 of file kis_fill_painter.h.

302 {
303 return m_opacitySpread;
304 }

◆ regionFillingBoundaryColor()

KoColor KisFillPainter::regionFillingBoundaryColor ( ) const
inline

Gets the color of the boundary used when the region filling mode is RegionFillingMode_BoundaryFill

Definition at line 409 of file kis_fill_painter.h.

409 {
411 }

◆ regionFillingMode()

RegionFillingMode KisFillPainter::regionFillingMode ( ) const
inline

Gets the region filling mode

Definition at line 395 of file kis_fill_painter.h.

395 {
396 return m_regionFillingMode;
397 }

◆ setAntiAlias()

void KisFillPainter::setAntiAlias ( bool antiAlias)
inline

Sets if antiAlias should be applied to the selection

Definition at line 348 of file kis_fill_painter.h.

348 {
350 }

◆ setCareForSelection()

void KisFillPainter::setCareForSelection ( bool set)
inline

Set caring for selection. See careForSelection for details

Definition at line 343 of file kis_fill_painter.h.

343 {
344 m_careForSelection = set;
345 }

◆ setCloseGap()

void KisFillPainter::setCloseGap ( int gap)
inline

Sets the gap radius for a gap closing fill.

Definition at line 307 of file kis_fill_painter.h.

307 {
308 m_closeGap = gap;
309 }

◆ setCurrentFillSelection()

void KisFillPainter::setCurrentFillSelection ( KisSelectionSP fillSelection)
inlineprotected

Definition at line 430 of file kis_fill_painter.h.

431 {
433 }
void fillSelection(const QRect &rc, const KoColor &color)

◆ setFeather()

void KisFillPainter::setFeather ( int feather)
inline

Sets feathering radius

Definition at line 369 of file kis_fill_painter.h.

369 {
371 }

◆ setFillThreshold()

void KisFillPainter::setFillThreshold ( int threshold)
inline

Set the threshold for floodfill. The range is 0-255: 0 means the fill will only fill parts that are the exact same color, 255 means anything will be filled

Definition at line 275 of file kis_fill_painter.h.

276 {
277 m_threshold = threshold;
278 }

◆ setHeight()

void KisFillPainter::setHeight ( int h)
inline

Sets the height of the paint device

Definition at line 333 of file kis_fill_painter.h.

◆ setOpacitySpread()

void KisFillPainter::setOpacitySpread ( int opacitySpread)
inline

Set the opacity spread for floodfill. The range is 0-100: 0% means that the fully opaque area only encompasses the pixels exactly equal to the seed point with the other pixels of the selected region being semi-transparent (depending on how similar they are to the seed pixel) up to the region boundary (given by the threshold value). 100 means that the fully opaque area will encompass all the pixels of the selected region up to the contour. Any value in between will make the fully opaque portion of the region vary in size, with semi-transparent pixels in between it and the region boundary

Definition at line 296 of file kis_fill_painter.h.

297 {
299 }

◆ setRegionFillingBoundaryColor()

void KisFillPainter::setRegionFillingBoundaryColor ( const KoColor & regionFillingBoundaryColor)
inline

Sets the color of the boundary used when the region filling mode is RegionFillingMode_BoundaryFill

Definition at line 402 of file kis_fill_painter.h.

◆ setRegionFillingMode()

void KisFillPainter::setRegionFillingMode ( RegionFillingMode regionFillingMode)
inline

Sets the region filling mode

Definition at line 390 of file kis_fill_painter.h.

390 {
392 }
RegionFillingMode regionFillingMode() const

◆ setSizemod()

void KisFillPainter::setSizemod ( int sizemod)
inline

Sets the auto growth/shrinking radius

Definition at line 358 of file kis_fill_painter.h.

358 {
360 }

◆ setStopGrowingAtDarkestPixel()

void KisFillPainter::setStopGrowingAtDarkestPixel ( bool stopGrowingAtDarkestPixel)
inline

Sets if the selection should stop growing at the darkest and/or more opaque pixel when using a positive grow value (sizemod)

Definition at line 417 of file kis_fill_painter.h.

◆ setUseCompositing()

void KisFillPainter::setUseCompositing ( bool useCompositing)
inline

Definition at line 323 of file kis_fill_painter.h.

323 {
325 }
bool useCompositing() const

◆ setUseSelectionAsBoundary()

void KisFillPainter::setUseSelectionAsBoundary ( bool useSelectionAsBoundary)
inline

Sets selection borders being treated as boundary

Definition at line 380 of file kis_fill_painter.h.

◆ setWidth()

void KisFillPainter::setWidth ( int w)
inline

Sets the width of the paint device

Definition at line 328 of file kis_fill_painter.h.

◆ sizemod()

int KisFillPainter::sizemod ( ) const
inline

Sets how much to auto-grow or shrink (if sizemod is negative) the selection flood before painting, this affects every fill operation except fillRect

Definition at line 364 of file kis_fill_painter.h.

364 {
365 return m_sizemod;
366 }

◆ stopGrowingAtDarkestPixel()

bool KisFillPainter::stopGrowingAtDarkestPixel ( ) const
inline

Gets if the selection should stop growing at the darkest and/or more opaque pixel when using a positive grow value (sizemod)

Definition at line 425 of file kis_fill_painter.h.

425 {
427 }

◆ useCompositing()

bool KisFillPainter::useCompositing ( ) const
inline

Definition at line 319 of file kis_fill_painter.h.

319 {
320 return m_useCompositing;
321 }

◆ useSelectionAsBoundary()

uint KisFillPainter::useSelectionAsBoundary ( ) const
inline

defines if the selection borders are treated as boundary in flood fill or not

Definition at line 385 of file kis_fill_painter.h.

385 {
387 }

Member Data Documentation

◆ m_antiAlias

bool KisFillPainter::m_antiAlias
private

Definition at line 449 of file kis_fill_painter.h.

◆ m_careForSelection

bool KisFillPainter::m_careForSelection
private

Definition at line 455 of file kis_fill_painter.h.

◆ m_closeGap

int KisFillPainter::m_closeGap
private

Definition at line 452 of file kis_fill_painter.h.

◆ m_feather

int KisFillPainter::m_feather
private

Definition at line 447 of file kis_fill_painter.h.

◆ m_fillSelection

KisSelectionSP KisFillPainter::m_fillSelection
private

Definition at line 445 of file kis_fill_painter.h.

◆ m_height

int KisFillPainter::m_height
private

Definition at line 453 of file kis_fill_painter.h.

◆ m_opacitySpread

int KisFillPainter::m_opacitySpread
private

Definition at line 451 of file kis_fill_painter.h.

◆ m_rect

QRect KisFillPainter::m_rect
private

Definition at line 454 of file kis_fill_painter.h.

◆ m_regionFillingBoundaryColor

KoColor KisFillPainter::m_regionFillingBoundaryColor
private

Definition at line 459 of file kis_fill_painter.h.

◆ m_regionFillingMode

RegionFillingMode KisFillPainter::m_regionFillingMode
private

Definition at line 458 of file kis_fill_painter.h.

◆ m_sizemod

int KisFillPainter::m_sizemod
private

Definition at line 448 of file kis_fill_painter.h.

◆ m_stopGrowingAtDarkestPixel

bool KisFillPainter::m_stopGrowingAtDarkestPixel
private

Definition at line 460 of file kis_fill_painter.h.

◆ m_threshold

int KisFillPainter::m_threshold
private

Definition at line 450 of file kis_fill_painter.h.

◆ m_useCompositing

bool KisFillPainter::m_useCompositing
private

Definition at line 456 of file kis_fill_painter.h.

◆ m_useSelectionAsBoundary

bool KisFillPainter::m_useSelectionAsBoundary
private

Definition at line 457 of file kis_fill_painter.h.

◆ m_width

int KisFillPainter::m_width
private

Definition at line 453 of file kis_fill_painter.h.


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