61 const QRect &applyRect,
79 for (
int i = 0; i < size; i++) {
80 const int growSize = initialSize - i - 1;
82 quint8 selectedness = invert ?
83 qRound(qreal(size - i - 1) / size * 255.0) :
84 qRound(qreal(i + 1) / size * 255.0);
92 gc.
bitBlt(changeRect.topLeft(), fillDevice, changeRect);
105 qreal
value = qreal(iValue - 127) / 127.0;
107 qreal slant = std::tan ((
m_contrast + 1) * M_PI_4);
110 return qRound(
value * 255.0);
121 return qRound(qMax(0,
value - 127) * (255.0 / (255 - 127)));
129 return 255 - qRound(qMin(
value, 127) * (255.0 / 127.0));
133template <
class MapOp>
137 const QRect &applyRect)
139 static quint8 mapTable[256];
140 static bool mapInitialized =
false;
142 if (!MapOp::supportsCaching || !mapInitialized) {
143 mapInitialized =
true;
145 for (
int i = 0; i < 256; i++) {
146 mapTable[i] = mapOp(i);
155 quint8 *dstPtr = dstIt.
rawData();
156 *dstPtr = mapTable[*srcPtr];
160template <
class MapOp>
163 const QRect &applyRect)
165 static quint8 mapTable[256];
166 static bool mapInitialized =
false;
168 if (!MapOp::supportsCaching || !mapInitialized) {
169 mapInitialized =
true;
171 for (
int i = 0; i < 256; i++) {
172 mapTable[i] = mapOp(i);
179 quint8 *dstPtr = dstIt.
rawData();
180 *dstPtr = mapTable[*dstPtr];
207 QRect changeRect = applyRect;
225 const int size = config->
size();
226 int limitingGrowSize = 0;
228 switch (config->
style()) {
230 limitingGrowSize = size;
233 limitingGrowSize = 0;
236 const int initialSize = std::ceil(qreal(size) / 2.0);
237 limitingGrowSize = initialSize;
241 const int halfSizeC = std::ceil(qreal(size) / 2.0);
242 limitingGrowSize = halfSizeC;
246 warnKrita <<
"WARNING: Stroke Emboss style is not implemented yet!";
254 const int size = config->
size();
255 int limitingGrowSize = size;
263 const QRect &applyRect,
268 if (applyRect.isEmpty())
return;
278 const int size = config->
size();
280 int limitingGrowSize = 0;
284 switch (config->
style()) {
286 paintBevelSelection(selection, bumpmapSelection, d.applyBevelRect, size, size,
false, env);
287 limitingGrowSize = size;
291 limitingGrowSize = 0;
294 const int initialSize = std::ceil(qreal(size) / 2.0);
295 paintBevelSelection(selection, bumpmapSelection, d.applyBevelRect, size, initialSize,
false, env);
296 limitingGrowSize = initialSize;
300 const int halfSizeF = std::floor(qreal(size) / 2.0);
301 const int halfSizeC = std::ceil(qreal(size) / 2.0);
303 paintBevelSelection(selection, bumpmapSelection, d.applyBevelRect, halfSizeC, halfSizeC,
false, env);
304 paintBevelSelection(selection, bumpmapSelection, d.applyBevelRect, halfSizeF, 0,
true, env);
305 limitingGrowSize = halfSizeC;
309 warnKrita <<
"WARNING: Stroke Emboss style is not implemented yet!";
317 QRect changeRectUnused =
321 Q_UNUSED(changeRectUnused);
344 if (tex_depth >= 0.0) {
345 if (tex_depth <= 100.0) {
346 contrastadj = int(qRound((1-(tex_depth/100.0)) * -127));
348 contrastadj = int(qRound(((tex_depth-100.0)/900.0) * 127));
351 textureSelection->
invert();
352 if (tex_depth >= -100.0) {
353 contrastadj = int(qRound((1-(abs(tex_depth)/100.0)) * -127));
355 contrastadj = int(qRound(((abs(tex_depth)-100.0)/900.0) * 127));
360 qreal contrast = qBound(-1.0, qreal(contrastadj) / 127.0, 1.0);
366 gc.
bitBlt(d.applyTextureRect.topLeft(), textureSelection, d.applyTextureRect);
395 bumpmap(bumpmapSelection, d.applyBumpmapRect, bmvals);
402 d.applyGlossContourRect,
415 bumpmapSelection->
invert();
434 const QRect &fillRect = d.shadowHighlightsFinalRect;
458 const QRect &fillRect = d.shadowHighlightsFinalRect;
471 const QRect &applyRect,
483 applyBevelEmboss(src, dst, applyRect, w.config, style->resourcesInterface(), env);
494 return d.totalNeedRect(
rect, w.config);
505 return d.totalChangeRect(
rect, w.config);
float value(const T *src, size_t ch)
const QString COMPOSITE_COPY
const QString COMPOSITE_MULT
void processDirectly(KisPaintDeviceSP src, KisMultipleProjection *dst, KisLayerStyleKnockoutBlower *blower, const QRect &applyRect, KisPSDLayerStyleSP style, KisLayerStyleFilterEnvironment *env) const override
KisLayerStyleFilter * clone() const override
QRect neededRect(const QRect &rect, KisPSDLayerStyleSP style, KisLayerStyleFilterEnvironment *env) const override
void applyBevelEmboss(KisPaintDeviceSP srcDevice, KisMultipleProjection *dst, const QRect &applyRect, const psd_layer_effects_bevel_emboss *config, KisResourcesInterfaceSP resourcesInterface, KisLayerStyleFilterEnvironment *env) const
QRect changedRect(const QRect &rect, KisPSDLayerStyleSP style, KisLayerStyleFilterEnvironment *env) const override
KisPaintDeviceSP getProjection(const QString &id, const QString &compositeOpId, quint8 opacity, const QBitArray &channelFlags, KisPaintDeviceSP prototype)
void setDefaultPixel(const KoColor &defPixel)
void makeCloneFromRough(KisPaintDeviceSP src, const QRect &minimalRect)
const KoColorSpace * colorSpace() const
static void copyAreaOptimized(const QPoint &dstPt, KisPaintDeviceSP src, KisPaintDeviceSP dst, const QRect &originalSrcRect)
void setSelection(KisSelectionSP selection)
void bitBlt(qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
void setCompositeOpId(const KoCompositeOp *op)
ALWAYS_INLINE quint8 * rawData()
ALWAYS_INLINE const quint8 * rawDataConst() const
bool effectEnabled() const
const quint8 * contourLookupTable() const
void bumpmap(KisPixelSelectionSP device, const QRect &selectionRect, const bumpmap_vals_t &bmvals)
#define KIS_ASSERT_RECOVER_RETURN(cond)
T kisGrowRect(const T &rect, U offset)
void mapPixelValues(KisPixelSelectionSP srcSelection, KisPixelSelectionSP dstSelection, MapOp mapOp, const QRect &applyRect)
void paintBevelSelection(KisPixelSelectionSP srcSelection, KisPixelSelectionSP dstSelection, const QRect &applyRect, int size, int initialSize, bool invert, KisLayerStyleFilterEnvironment *env)
void applyContourCorrection(KisPixelSelectionSP selection, const QRect &applyRect, const quint8 *lookup_table, bool antiAliased, bool edgeHidden)
QRect growSelectionUniform(KisPixelSelectionSP selection, int growSize, const QRect &applyRect)
QRect growRectFromRadius(const QRect &rc, int radius)
void adjustRange(KisPixelSelectionSP selection, const QRect &applyRect, const int range)
void fillPattern(KisPaintDeviceSP fillDevice, const QRect &applyRect, KisLayerStyleFilterEnvironment *env, int scale, KoPatternSP pattern, int horizontalPhase, int verticalPhase, bool alignWithLayer)
bool checkEffectEnabled(const psd_layer_effects_shadow_base *config, KisMultipleProjection *dst)
void selectionFromAlphaChannel(KisPaintDeviceSP srcDevice, KisSelectionSP dstSelection, const QRect &srcRect)
static const int FULL_PERCENT_RANGE
void applyGaussianWithTransaction(KisPixelSelectionSP selection, const QRect &applyRect, qreal radius)
@ psd_bevel_pillow_emboss
@ psd_bevel_stroke_emboss
QRect applyGlossContourRect
QRect calcBevelNeedRect(const QRect &applyRect, const psd_layer_effects_bevel_emboss *config)
QRect totalChangeRect(const QRect &applyRect, const psd_layer_effects_bevel_emboss *config)
BevelEmbossRectCalculator(const QRect &applyRect, const psd_layer_effects_bevel_emboss *config)
QRect calcBevelChangeRect(const QRect &applyRect, const psd_layer_effects_bevel_emboss *config)
QRect shadowHighlightsFinalRect
QRect totalNeedRect(const QRect &applyRect, const psd_layer_effects_bevel_emboss *config)
static const bool supportsCaching
int operator()(int iValue)
ContrastOp(qreal contrast)
static const bool supportsCaching
int operator()(int value)
KisPaintDeviceSP device() const
KisSelectionSP selection() const
KisCachedPaintDevice * cachedPaintDevice()
int currentLevelOfDetail() const
KisCachedSelection * cachedSelection()
void clear(const QRect &r)
QRect selectedRect() const
void applySelection(KisPixelSelectionSP selection, SelectionAction action)
KisPixelSelectionSP pixelSelection
int operator()(int value)
static const bool supportsCaching
QString shadowBlendMode() const
const quint8 * glossContourLookupTable() const
qint32 highlightOpacity() const
psd_bevel_style style() const
bool contourEnabled() const
psd_direction direction() const
bool glossAntiAliased() const
KoPatternSP texturePattern(KisResourcesInterfaceSP resourcesInterface) const
int textureVerticalPhase() const
bool textureInvert() const
qint32 shadowOpacity() const
bool textureEnabled() const
bool textureAlignWithLayer() const
int textureHorizontalPhase() const
QString highlightBlendMode() const
KoColor shadowColor() const
KoColor highlightColor() const