unclipped texture blending optimization

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-09-17 16:53:05 +03:00
parent f8a31f30ab
commit 649a655c37
2 changed files with 10 additions and 74 deletions

View file

@ -559,7 +559,7 @@ Q_GUI_EXPORT void qt_grayscale(const QImage &image, QImage &dest)
unsigned int *outData = (unsigned int *)dest.bits(); unsigned int *outData = (unsigned int *)dest.bits();
if (dest.size() == image.size() && image.rect() == srcRect) { if (dest.size() == image.size() && image.rect() == srcRect) {
const unsigned int *data = (const unsigned int *)image.bits(); const unsigned int *data = (const unsigned int *)image.constBits();
// a bit faster loop for grayscaling everything // a bit faster loop for grayscaling everything
int pixels = dest.width() * dest.height(); int pixels = dest.width() * dest.height();
for (int i = 0; i < pixels; ++i) { for (int i = 0; i < pixels; ++i) {
@ -569,7 +569,7 @@ Q_GUI_EXPORT void qt_grayscale(const QImage &image, QImage &dest)
} else { } else {
int yd = destRect.top(); int yd = destRect.top();
for (int y = srcRect.top(); y <= srcRect.bottom() && y < image.height(); y++) { for (int y = srcRect.top(); y <= srcRect.bottom() && y < image.height(); y++) {
const unsigned int *data = (const unsigned int*)image.scanLine(y); const unsigned int *data = (const unsigned int*)image.constScanLine(y);
outData = (unsigned int*)dest.scanLine(yd++); outData = (unsigned int*)dest.scanLine(yd++);
int xd = destRect.left(); int xd = destRect.left();
for (int x = srcRect.left(); x <= srcRect.right() && x < image.width(); x++) { for (int x = srcRect.left(); x <= srcRect.right() && x < image.width(); x++) {

View file

@ -2826,81 +2826,17 @@ static void blend_tiled_generic(int count, const QSpan *spans, void *userData)
} }
} }
/* Image formats here are target formats */
static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats] = {
// Untransformed
{
0, // Invalid
blend_untransformed_generic, // Mono
blend_untransformed_generic, // MonoLsb
blend_untransformed_generic, // Indexed8
blend_untransformed_generic, // RGB32
blend_untransformed_generic, // ARGB32
blend_untransformed_generic, // ARGB32_Premultiplied
blend_untransformed_generic // RGB16
},
// Tiled
{
0, // Invalid
blend_tiled_generic, // Mono
blend_tiled_generic, // MonoLsb
blend_tiled_generic, // Indexed8
blend_tiled_generic, // RGB32
blend_tiled_generic, // ARGB32
blend_tiled_generic, // ARGB32_Premultiplied
blend_tiled_generic // RGB16
},
// Transformed
{
0, // Invalid
blend_src_generic, // Mono
blend_src_generic, // MonoLsb
blend_src_generic, // Indexed8
blend_src_generic, // RGB32
blend_src_generic, // ARGB32
blend_src_generic, // ARGB32_Premultiplied
blend_src_generic // RGB16
},
// TransformedTiled
{
0,
blend_src_generic, // Mono
blend_src_generic, // MonoLsb
blend_src_generic, // Indexed8
blend_src_generic, // RGB32
blend_src_generic, // ARGB32
blend_src_generic, // ARGB32_Premultiplied
blend_src_generic // RGB16
},
// Bilinear
{
0,
blend_src_generic, // Mono
blend_src_generic, // MonoLsb
blend_src_generic, // Indexed8
blend_src_generic, // RGB32
blend_src_generic, // ARGB32
blend_src_generic, // ARGB32_Premultiplied
blend_src_generic // RGB16
},
// BilinearTiled
{
0,
blend_src_generic, // Mono
blend_src_generic, // MonoLsb
blend_src_generic, // Indexed8
blend_src_generic, // RGB32
blend_src_generic, // ARGB32
blend_src_generic, // ARGB32_Premultiplied
blend_src_generic // RGB16
}
};
void qBlendTexture(int count, const QSpan *spans, void *userData) void qBlendTexture(int count, const QSpan *spans, void *userData)
{ {
QSpanData *data = reinterpret_cast<QSpanData *>(userData); QSpanData *data = reinterpret_cast<QSpanData *>(userData);
ProcessSpans proc = processTextureSpans[getBlendType(data)][data->rasterBuffer->format]; Q_ASSERT(data->rasterBuffer->format != QImage::Format_Invalid);
proc(count, spans, userData); if (data->txop <= QTransform::TxTranslate && data->texture.type == QTextureData::Tiled) {
blend_tiled_generic(count, spans, userData);
} else if (data->txop <= QTransform::TxTranslate) {
blend_untransformed_generic(count, spans, userData);
} else {
blend_src_generic(count, spans, userData);
}
} }
template <class DST> template <class DST>