21#include <boost/random/mersenne_twister.hpp>
41KisLayerStyleFilterEnvironment::Private::
42generateRandomSelection(
const QRect &rc)
47 boost::mt11213b uniformSource;
49 if (uniformSource.max() >= 0x00FFFFFF) {
50 while (dstIt.nextPixel()) {
51 int randValue = uniformSource();
52 *dstIt.rawData() = (quint8) randValue;
54 if (!dstIt.nextPixel())
break;
56 *dstIt.rawData() = (quint8) randValue;
58 if (!dstIt.nextPixel())
break;
60 *dstIt.rawData() = (quint8) randValue;
64 while (dstIt.nextPixel()) {
65 *dstIt.rawData() = (quint8) uniformSource();
85 return m_d->sourceLayer ?
m_d->sourceLayer->projection()->exactBounds() : QRect();
90 return m_d->sourceLayer ?
91 m_d->sourceLayer->original()->defaultBounds()->bounds() : QRect();
96 return m_d->sourceLayer ?
97 m_d->sourceLayer->original()->defaultBounds()->currentLevelOfDetail() : 0;
102 const QBitArray &channelFlags)
const
104 Q_ASSERT(
m_d->sourceLayer);
120 if (!existingRect.contains(requestedRect)) {
121 m_d->cachedRandomSelection =
122 Private::generateRandomSelection(requestedRect | existingRect);
125 return m_d->cachedRandomSelection;
130 if (!pattern->hasAlpha())
return pattern;
134 KoPatternSP resultPattern =
source.bestMatch(
"", pattern->filename(), pattern->name());
135 if (resultPattern)
return resultPattern;
137 KoPatternSP flattenedPattern = pattern->cloneWithoutAlpha();
139 m_d->cachedFlattenedPattern.addResource(flattenedPattern);
141 return flattenedPattern;
146 return &
m_d->globalCachedSelection;
151 return &
m_d->globalCachedPaintDevice;
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
const quint8 OPACITY_OPAQUE_U8
a KisResourcesInterface-like resources storage for preloaded resources
void setOpacityF(qreal opacity)
void setChannelFlags(QBitArray channelFlags)
qreal mergeOpacityF(qreal opacity, qreal parentOpacity)
QBitArray mergeChannelFlags(const QBitArray &childFlags, const QBitArray &parentFlags)
KisLocalStrokeResources cachedFlattenedPattern
KisCachedPaintDevice globalCachedPaintDevice
KisCachedPaintDevice * cachedPaintDevice()
KisCachedSelection globalCachedSelection
KisLayerStyleFilterEnvironment(KisLayer *sourceLayer)
void setupFinalPainter(KisPainter *gc, quint8 opacity, const QBitArray &channelFlags) const
const QScopedPointer< Private > m_d
KisPixelSelectionSP cachedRandomSelection
QRect layerBounds() const
QRect defaultBounds() const
int currentLevelOfDetail() const
~KisLayerStyleFilterEnvironment()
static KisPixelSelectionSP generateRandomSelection(const QRect &rc)
KisCachedSelection * cachedSelection()
QRect selectedExactRect() const