Implement clip part of qt_alphamapblit_quint16
Adds handling of clipping in qt_alphamapblit_quint16, this is also preparing for a generic implementation of alphamapblit. Change-Id: I706f08179abefa74f8de138369a0dc8ce19510fc Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>bb10
parent
3e238113f8
commit
56e9221b36
|
|
@ -5543,32 +5543,57 @@ inline static void qt_bitmapblit_quint16(QRasterBuffer *rasterBuffer,
|
|||
map, mapWidth, mapHeight, mapStride);
|
||||
}
|
||||
|
||||
static void qt_alphamapblit_quint16(QRasterBuffer *rasterBuffer,
|
||||
int x, int y, const QRgba64 &color,
|
||||
const uchar *map,
|
||||
int mapWidth, int mapHeight, int mapStride,
|
||||
const QClipData *, bool /*useGammaCorrection*/)
|
||||
static inline void alphamapblend_quint16(int coverage, quint16 *dest, int x, const quint16 srcColor)
|
||||
{
|
||||
if (coverage == 0) {
|
||||
// nothing
|
||||
} else if (coverage == 255) {
|
||||
dest[x] = srcColor;
|
||||
} else {
|
||||
dest[x] = BYTE_MUL_RGB16(srcColor, coverage)
|
||||
+ BYTE_MUL_RGB16(dest[x], 255 - coverage);
|
||||
}
|
||||
}
|
||||
|
||||
void qt_alphamapblit_quint16(QRasterBuffer *rasterBuffer,
|
||||
int x, int y, const QRgba64 &color,
|
||||
const uchar *map,
|
||||
int mapWidth, int mapHeight, int mapStride,
|
||||
const QClipData *clip, bool /*useGammaCorrection*/)
|
||||
{
|
||||
const quint16 c = color.toRgb16();
|
||||
quint16 *dest = reinterpret_cast<quint16*>(rasterBuffer->scanLine(y)) + x;
|
||||
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint16);
|
||||
|
||||
while (mapHeight--) {
|
||||
for (int i = 0; i < mapWidth; ++i) {
|
||||
const int coverage = map[i];
|
||||
|
||||
if (coverage == 0) {
|
||||
// nothing
|
||||
} else if (coverage == 255) {
|
||||
dest[i] = c;
|
||||
} else {
|
||||
int ialpha = 255 - coverage;
|
||||
dest[i] = BYTE_MUL_RGB16(c, coverage)
|
||||
+ BYTE_MUL_RGB16(dest[i], ialpha);
|
||||
}
|
||||
if (!clip) {
|
||||
quint16 *dest = reinterpret_cast<quint16*>(rasterBuffer->scanLine(y)) + x;
|
||||
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint16);
|
||||
while (mapHeight--) {
|
||||
for (int i = 0; i < mapWidth; ++i)
|
||||
alphamapblend_quint16(map[i], dest, i, c);
|
||||
dest += destStride;
|
||||
map += mapStride;
|
||||
}
|
||||
dest += destStride;
|
||||
map += mapStride;
|
||||
} else {
|
||||
int top = qMax(y, 0);
|
||||
int bottom = qMin(y + mapHeight, rasterBuffer->height());
|
||||
map += (top - y) * mapStride;
|
||||
|
||||
const_cast<QClipData *>(clip)->initialize();
|
||||
for (int yp = top; yp<bottom; ++yp) {
|
||||
const QClipData::ClipLine &line = clip->m_clipLines[yp];
|
||||
|
||||
quint16 *dest = reinterpret_cast<quint16*>(rasterBuffer->scanLine(yp));
|
||||
|
||||
for (int i=0; i<line.count; ++i) {
|
||||
const QSpan &clip = line.spans[i];
|
||||
|
||||
int start = qMax<int>(x, clip.x);
|
||||
int end = qMin<int>(x + mapWidth, clip.x + clip.len);
|
||||
|
||||
for (int xp=start; xp<end; ++xp)
|
||||
alphamapblend_quint16(map[xp - x], dest, xp, c);
|
||||
} // for (i -> line.count)
|
||||
map += mapStride;
|
||||
} // for (yp -> bottom)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -535,12 +535,23 @@ void qt_blend_rgb32_on_rgb32_neon(uchar *destPixels, int dbpl,
|
|||
}
|
||||
|
||||
#if defined(ENABLE_PIXMAN_DRAWHELPERS)
|
||||
extern void qt_alphamapblit_quint16(QRasterBuffer *rasterBuffer,
|
||||
int x, int y, const QRgba64 &color,
|
||||
const uchar *map,
|
||||
int mapWidth, int mapHeight, int mapStride,
|
||||
const QClipData *clip, bool useGammaCorrection);
|
||||
|
||||
void qt_alphamapblit_quint16_neon(QRasterBuffer *rasterBuffer,
|
||||
int x, int y, const QRgba64 &color,
|
||||
const uchar *bitmap,
|
||||
int mapWidth, int mapHeight, int mapStride,
|
||||
const QClipData *, bool /*useGammaCorrection*/)
|
||||
const QClipData *clip, bool useGammaCorrection)
|
||||
{
|
||||
if (clip || useGammaCorrection) {
|
||||
qt_alphamapblit_quint16(rasterBuffer, x, y, color, bitmap, mapWidth, mapHeight, mapStride, clip, useGammaCorrection);
|
||||
return;
|
||||
}
|
||||
|
||||
quint16 *dest = reinterpret_cast<quint16*>(rasterBuffer->scanLine(y)) + x;
|
||||
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint16);
|
||||
|
||||
|
|
|
|||
|
|
@ -2621,7 +2621,7 @@ void QRasterPaintEngine::alphaPenBlt(const void* src, int bpl, int depth, int rx
|
|||
return;
|
||||
}
|
||||
}
|
||||
} else if (d->deviceDepth == 32 && ((depth == 8 && s->penData.alphamapBlit) || (depth == 32 && s->penData.alphaRGBBlit))) {
|
||||
} else if ((depth == 8 && s->penData.alphamapBlit) || (depth == 32 && s->penData.alphaRGBBlit)) {
|
||||
// (A)RGB Alpha mask where the alpha component is not used.
|
||||
if (!clip) {
|
||||
int nx = qMax(0, rx);
|
||||
|
|
|
|||
Loading…
Reference in New Issue