Changeset View
Changeset View
Standalone View
Standalone View
libs/image/kis_filter_weights_applicator.h
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 123 | struct BlendSpan { | |||
---|---|---|---|---|---|
126 | KisFixedPoint offset; | 126 | KisFixedPoint offset; | ||
127 | KisFixedPoint offsetInc; | 127 | KisFixedPoint offsetInc; | ||
128 | }; | 128 | }; | ||
129 | 129 | | |||
130 | inline BlendSpan calculateBlendSpan(int dst_l, int line, KisFilterWeightsBuffer *buffer) const { | 130 | inline BlendSpan calculateBlendSpan(int dst_l, int line, KisFilterWeightsBuffer *buffer) const { | ||
131 | KisFixedPoint dst_c = l_to_c(dst_l); | 131 | KisFixedPoint dst_c = l_to_c(dst_l); | ||
132 | KisFixedPoint dst_c_in_src = dstToSrc(dst_c.toFloat(), line); | 132 | KisFixedPoint dst_c_in_src = dstToSrc(dst_c.toFloat(), line); | ||
133 | 133 | | |||
134 | // gives the nearest center of the pixel in src ( x e (0, 1> => f(x) = 0.5, x e (1, 2> => f(x) = 1.5 etc. ) | ||||
134 | KisFixedPoint next_c_in_src = (dst_c_in_src - qreal(0.5)).toIntCeil() + qreal(0.5); | 135 | KisFixedPoint next_c_in_src = (dst_c_in_src - qreal(0.5)).toIntCeil() + qreal(0.5); | ||
135 | 136 | | |||
136 | BlendSpan span; | 137 | BlendSpan span; | ||
137 | span.offset = (next_c_in_src - dst_c_in_src) * buffer->weightsPositionScale(); | 138 | span.offset = (next_c_in_src - dst_c_in_src) * buffer->weightsPositionScale(); | ||
138 | span.offsetInc = buffer->weightsPositionScale(); | 139 | span.offsetInc = buffer->weightsPositionScale(); | ||
139 | 140 | | |||
140 | Q_ASSERT(span.offset <= span.offsetInc); | 141 | Q_ASSERT(span.offset <= span.offsetInc); | ||
141 | 142 | | |||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 213 | else { | |||
214 | dstEnd = findAntialiasedDstEnd(srcLine.start(), filterSupport, line); | 215 | dstEnd = findAntialiasedDstEnd(srcLine.start(), filterSupport, line); | ||
215 | 216 | | |||
216 | leftSrcBorder = getLeftSrcNeedBorder(dstEnd - 1, line, buffer); | 217 | leftSrcBorder = getLeftSrcNeedBorder(dstEnd - 1, line, buffer); | ||
217 | rightSrcBorder = getRightSrcNeedBorder(dstStart, line, buffer); | 218 | rightSrcBorder = getRightSrcNeedBorder(dstStart, line, buffer); | ||
218 | } | 219 | } | ||
219 | 220 | | |||
220 | if (dstStart >= dstEnd) return LinePos(dstStart, 0); | 221 | if (dstStart >= dstEnd) return LinePos(dstStart, 0); | ||
221 | if (leftSrcBorder >= rightSrcBorder) return LinePos(dstStart, 0); | 222 | if (leftSrcBorder >= rightSrcBorder) return LinePos(dstStart, 0); | ||
222 | if (leftSrcBorder > srcLine.start()) return LinePos(dstStart, 0); | 223 | if (leftSrcBorder > srcLine.start()) { | ||
223 | if (srcLine.end() > rightSrcBorder) return LinePos(dstStart, 9); | 224 | leftSrcBorder = srcLine.start(); | ||
225 | } | ||||
226 | if (srcLine.end() > rightSrcBorder) { | ||||
227 | rightSrcBorder = srcLine.end(); | ||||
228 | } | ||||
224 | 229 | | |||
225 | int pixelSize = m_src->pixelSize(); | 230 | int pixelSize = m_src->pixelSize(); | ||
226 | KoMixColorsOp *mixOp = m_src->colorSpace()->mixColorsOp(); | 231 | KoMixColorsOp *mixOp = m_src->colorSpace()->mixColorsOp(); | ||
227 | const KoColor defaultPixelObject = m_src->defaultPixel(); | 232 | const KoColor defaultPixelObject = m_src->defaultPixel(); | ||
228 | const quint8 *defaultPixel = defaultPixelObject.data(); | 233 | const quint8 *defaultPixel = defaultPixelObject.data(); | ||
229 | const quint8 *borderPixel = defaultPixel; | 234 | const quint8 *borderPixel = defaultPixel; | ||
230 | quint8 *srcLineBuf = new quint8[pixelSize * (rightSrcBorder - leftSrcBorder)]; | 235 | quint8 *srcLineBuf = new quint8[pixelSize * (rightSrcBorder - leftSrcBorder)]; | ||
231 | 236 | | |||
▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines |