summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qdrawhelper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting/qdrawhelper.cpp')
-rw-r--r--src/gui/painting/qdrawhelper.cpp496
1 files changed, 211 insertions, 285 deletions
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 71e2e3b..b440fce 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -70,8 +70,10 @@ static uint gccBug(uint value)
constants and structures
*/
-static const int fixed_scale = 1 << 16;
-static const int half_point = 1 << 15;
+enum {
+ fixed_scale = 1 << 16,
+ half_point = 1 << 15
+};
static const int buffer_size = 2048;
struct LinearGradientValues
@@ -175,7 +177,7 @@ Q_STATIC_TEMPLATE_FUNCTION uint * QT_FASTCALL destFetch(uint *buffer, QRasterBuf
# define SPANFUNC_POINTER_DESTFETCH(Arg) destFetch<Arg>
-static const DestFetchProc destFetchProc[QImage::NImageFormats] =
+static DestFetchProc destFetchProc[QImage::NImageFormats] =
{
0, // Format_Invalid
destFetchMono, // Format_Mono,
@@ -323,7 +325,7 @@ Q_STATIC_TEMPLATE_FUNCTION void QT_FASTCALL destStore(QRasterBuffer *rasterBuffe
# define SPANFUNC_POINTER_DESTSTORE(DEST) destStore<DEST>
-static const DestStoreProc destStoreProc[QImage::NImageFormats] =
+static DestStoreProc destStoreProc[QImage::NImageFormats] =
{
0, // Format_Invalid
destStoreMono, // Format_Mono,
@@ -691,37 +693,42 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *
fy -= half_point;
while (b < end) {
int x1 = (fx >> 16);
- int x2 = x1 + 1;
+ int x2;
int y1 = (fy >> 16);
- int y2 = y1 + 1;
-
- int distx = ((fx - (x1 << 16)) >> 8);
- int disty = ((fy - (y1 << 16)) >> 8);
- int idistx = 256 - distx;
- int idisty = 256 - disty;
+ int y2;
if (blendType == BlendTransformedBilinearTiled) {
x1 %= image_width;
+ if (x1 < 0) x1 += image_width;
+ x2 = x1 + 1;
x2 %= image_width;
- y1 %= image_height;
- y2 %= image_height;
- if (x1 < 0) x1 += image_width;
- if (x2 < 0) x2 += image_width;
+ y1 %= image_height;
if (y1 < 0) y1 += image_height;
- if (y2 < 0) y2 += image_height;
-
- Q_ASSERT(x1 >= 0 && x1 < image_width);
- Q_ASSERT(x2 >= 0 && x2 < image_width);
- Q_ASSERT(y1 >= 0 && y1 < image_height);
- Q_ASSERT(y2 >= 0 && y2 < image_height);
+ y2 = y1 + 1;
+ y2 %= image_height;
} else {
- x1 = qBound(0, x1, image_width - 1);
- x2 = qBound(0, x2, image_width - 1);
- y1 = qBound(0, y1, image_height - 1);
- y2 = qBound(0, y2, image_height - 1);
+ if (x1 < 0) {
+ x2 = x1 = 0;
+ } else if (x1 >= image_width - 1) {
+ x2 = x1 = image_width - 1;
+ } else {
+ x2 = x1 + 1;
+ }
+ if (y1 < 0) {
+ y2 = y1 = 0;
+ } else if (y1 >= image_height - 1) {
+ y2 = y1 = image_height - 1;
+ } else {
+ y2 = y1 + 1;
+ }
}
+ Q_ASSERT(x1 >= 0 && x1 < image_width);
+ Q_ASSERT(x2 >= 0 && x2 < image_width);
+ Q_ASSERT(y1 >= 0 && y1 < image_height);
+ Q_ASSERT(y2 >= 0 && y2 < image_height);
+
const uchar *s1 = data->texture.scanLine(y1);
const uchar *s2 = data->texture.scanLine(y2);
@@ -730,6 +737,11 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *
uint bl = fetch(s2, x1, data->texture.colorTable);
uint br = fetch(s2, x2, data->texture.colorTable);
+ int distx = (fx & 0x0000ffff) >> 8;
+ int disty = (fy & 0x0000ffff) >> 8;
+ int idistx = 256 - distx;
+ int idisty = 256 - disty;
+
uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx);
uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx);
*b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty);
@@ -753,9 +765,9 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *
const qreal py = fy * iw - 0.5;
int x1 = int(px) - (px < 0);
- int x2 = x1 + 1;
+ int x2;
int y1 = int(py) - (py < 0);
- int y2 = y1 + 1;
+ int y2;
int distx = int((px - x1) * 256);
int disty = int((py - y1) * 256);
@@ -764,26 +776,36 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *
if (blendType == BlendTransformedBilinearTiled) {
x1 %= image_width;
+ if (x1 < 0) x1 += image_width;
+ x2 = x1 + 1;
x2 %= image_width;
- y1 %= image_height;
- y2 %= image_height;
- if (x1 < 0) x1 += image_width;
- if (x2 < 0) x2 += image_width;
+ y1 %= image_height;
if (y1 < 0) y1 += image_height;
- if (y2 < 0) y2 += image_height;
-
- Q_ASSERT(x1 >= 0 && x1 < image_width);
- Q_ASSERT(x2 >= 0 && x2 < image_width);
- Q_ASSERT(y1 >= 0 && y1 < image_height);
- Q_ASSERT(y2 >= 0 && y2 < image_height);
+ y2 = y1 + 1;
+ y2 %= image_height;
} else {
- x1 = qBound(0, x1, image_width - 1);
- x2 = qBound(0, x2, image_width - 1);
- y1 = qBound(0, y1, image_height - 1);
- y2 = qBound(0, y2, image_height - 1);
+ if (x1 < 0) {
+ x2 = x1 = 0;
+ } else if (x1 >= image_width - 1) {
+ x2 = x1 = image_width - 1;
+ } else {
+ x2 = x1 + 1;
+ }
+ if (y1 < 0) {
+ y2 = y1 = 0;
+ } else if (y1 >= image_height - 1) {
+ y2 = y1 = image_height - 1;
+ } else {
+ y2 = y1 + 1;
+ }
}
+ Q_ASSERT(x1 >= 0 && x1 < image_width);
+ Q_ASSERT(x2 >= 0 && x2 < image_width);
+ Q_ASSERT(y1 >= 0 && y1 < image_height);
+ Q_ASSERT(y2 >= 0 && y2 < image_height);
+
const uchar *s1 = data->texture.scanLine(y1);
const uchar *s2 = data->texture.scanLine(y2);
@@ -2827,7 +2849,7 @@ static void QT_FASTCALL rasterop_SourceAndNotDestination(uint *dest,
}
}
-static const CompositionFunctionSolid functionForModeSolid_C[] = {
+static CompositionFunctionSolid functionForModeSolid_C[] = {
comp_func_solid_SourceOver,
comp_func_solid_DestinationOver,
comp_func_solid_Clear,
@@ -2865,7 +2887,7 @@ static const CompositionFunctionSolid functionForModeSolid_C[] = {
static const CompositionFunctionSolid *functionForModeSolid = functionForModeSolid_C;
-static const CompositionFunction functionForMode_C[] = {
+static CompositionFunction functionForMode_C[] = {
comp_func_SourceOver,
comp_func_DestinationOver,
comp_func_Clear,
@@ -3884,8 +3906,8 @@ inline void interpolate_pixel_unaligned_2(DST *dest, const SRC *src,
template <class DST, class SRC>
inline void interpolate_pixel_2(DST *dest, const SRC *src, quint16 alpha)
{
- Q_ASSERT((long(dest) & 0x3) == 0);
- Q_ASSERT((long(src) & 0x3) == 0);
+ Q_ASSERT((quintptr(dest) & 0x3) == 0);
+ Q_ASSERT((quintptr(src) & 0x3) == 0);
const quint16 a = eff_alpha_2(alpha, dest);
const quint16 ia = eff_ialpha_2(alpha, dest);
@@ -3958,8 +3980,8 @@ template <class DST, class SRC>
inline void interpolate_pixel_2(DST *dest, quint8 a,
const SRC *src, quint8 b)
{
- Q_ASSERT((long(dest) & 0x3) == 0);
- Q_ASSERT((long(src) & 0x3) == 0);
+ Q_ASSERT((quintptr(dest) & 0x3) == 0);
+ Q_ASSERT((quintptr(src) & 0x3) == 0);
Q_ASSERT(!SRC::hasAlpha());
@@ -4007,8 +4029,8 @@ inline void interpolate_pixel_2(qrgb444 *dest, quint8 a,
template <class DST, class SRC>
inline void interpolate_pixel_4(DST *dest, const SRC *src, quint32 alpha)
{
- Q_ASSERT((long(dest) & 0x3) == 0);
- Q_ASSERT((long(src) & 0x3) == 0);
+ Q_ASSERT((quintptr(dest) & 0x3) == 0);
+ Q_ASSERT((quintptr(src) & 0x3) == 0);
const quint32 a = eff_alpha_4(alpha, dest);
const quint32 ia = eff_ialpha_4(alpha, dest);
@@ -4411,7 +4433,7 @@ void QT_FASTCALL blendUntransformed_dest16(DST *dest, const SRC *src,
{
Q_ASSERT(sizeof(DST) == 2);
Q_ASSERT(sizeof(SRC) == 2);
- Q_ASSERT((long(dest) & 0x3) == (long(src) & 0x3));
+ Q_ASSERT((quintptr(dest) & 0x3) == (quintptr(src) & 0x3));
Q_ASSERT(coverage > 0);
const int align = quintptr(dest) & 0x3;
@@ -4479,8 +4501,8 @@ void QT_FASTCALL blendUntransformed_dest16(DST *dest, const SRC *src,
}
while (length >= 2) {
- Q_ASSERT((long(dest) & 3) == 0);
- Q_ASSERT((long(src) & 3) == 0);
+ Q_ASSERT((quintptr(dest) & 3) == 0);
+ Q_ASSERT((quintptr(src) & 3) == 0);
const quint16 a = alpha_2(src);
if (a == 0xffff) {
@@ -4511,7 +4533,7 @@ template <class DST, class SRC>
void QT_FASTCALL blendUntransformed_dest24(DST *dest, const SRC *src,
quint8 coverage, int length)
{
- Q_ASSERT((long(dest) & 0x3) == (long(src) & 0x3));
+ Q_ASSERT((quintptr(dest) & 0x3) == (quintptr(src) & 0x3));
Q_ASSERT(sizeof(DST) == 3);
Q_ASSERT(coverage > 0);
@@ -5141,7 +5163,7 @@ static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData)
}
-template <SpanMethod spanMethod>
+template <SpanMethod spanMethod, TextureBlendType blendType> /* blendType must be either BlendTransformedBilinear or BlendTransformedBilinearTiled */
Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
@@ -5154,10 +5176,12 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const
CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode];
uint buffer[buffer_size];
- int image_x1 = data->texture.x1;
- int image_y1 = data->texture.y1;
- int image_x2 = data->texture.x2;
- int image_y2 = data->texture.y2;
+ const int image_x1 = data->texture.x1;
+ const int image_y1 = data->texture.y1;
+ const int image_x2 = data->texture.x2;
+ const int image_y2 = data->texture.y2;
+ const int image_width = data->texture.width;
+ const int image_height = data->texture.height;
const int scanline_offset = data->texture.bytesPerLine / 4;
if (data->fast_matrix) {
@@ -5187,19 +5211,41 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const
uint *b = buffer;
while (b < end) {
int x1 = (x >> 16);
- int x2 = x1 + 1;
+ int x2;
int y1 = (y >> 16);
- int y2 = y1 + 1;
-
- int distx = ((x - (x1 << 16)) >> 8);
- int disty = ((y - (y1 << 16)) >> 8);
- int idistx = 256 - distx;
- int idisty = 256 - disty;
-
- x1 = qBound(image_x1, x1, image_x2 - 1);
- x2 = qBound(image_x1, x2, image_x2 - 1);
- y1 = qBound(image_y1, y1, image_y2 - 1);
- y2 = qBound(image_y1, y2, image_y2 - 1);
+ int y2;
+
+ if (blendType == BlendTransformedBilinearTiled) {
+ x1 %= image_width;
+ if (x1 < 0) x1 += image_width;
+ x2 = x1 + 1;
+ x2 %= image_width;
+
+ y1 %= image_height;
+ if (y1 < 0) y1 += image_height;
+ y2 = y1 + 1;
+ y2 %= image_height;
+
+ Q_ASSERT(x1 >= 0 && x1 < image_width);
+ Q_ASSERT(x2 >= 0 && x2 < image_width);
+ Q_ASSERT(y1 >= 0 && y1 < image_height);
+ Q_ASSERT(y2 >= 0 && y2 < image_height);
+ } else {
+ if (x1 < image_x1) {
+ x2 = x1 = image_x1;
+ } else if (x1 >= image_x2 - 1) {
+ x2 = x1 = image_x2 - 1;
+ } else {
+ x2 = x1 + 1;
+ }
+ if (y1 < image_y1) {
+ y2 = y1 = image_y1;
+ } else if (y1 >= image_y2 - 1) {
+ y2 = y1 = image_y2 - 1;
+ } else {
+ y2 = y1 + 1;
+ }
+ }
int y1_offset = y1 * scanline_offset;
int y2_offset = y2 * scanline_offset;
@@ -5216,6 +5262,11 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const
uint br = image_bits[y2_offset + x2];
#endif
+ int distx = (x & 0x0000ffff) >> 8;
+ int disty = (y & 0x0000ffff) >> 8;
+ int idistx = 256 - distx;
+ int idisty = 256 - disty;
+
uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx);
uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx);
*b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty);
@@ -5265,19 +5316,46 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const
const qreal py = y * iw - 0.5;
int x1 = int(px) - (px < 0);
- int x2 = x1 + 1;
+ int x2;
int y1 = int(py) - (py < 0);
- int y2 = y1 + 1;
+ int y2;
int distx = int((px - x1) * 256);
int disty = int((py - y1) * 256);
int idistx = 256 - distx;
int idisty = 256 - disty;
- x1 = qBound(image_x1, x1, image_x2 - 1);
- x2 = qBound(image_x1, x2, image_x2 - 1);
- y1 = qBound(image_y1, y1, image_y2 - 1);
- y2 = qBound(image_y1, y2, image_y2 - 1);
+ if (blendType == BlendTransformedBilinearTiled) {
+ x1 %= image_width;
+ if (x1 < 0) x1 += image_width;
+ x2 = x1 + 1;
+ x2 %= image_width;
+
+ y1 %= image_height;
+ if (y1 < 0) y1 += image_height;
+ y2 = y1 + 1;
+ y2 %= image_height;
+
+ Q_ASSERT(x1 >= 0 && x1 < image_width);
+ Q_ASSERT(x2 >= 0 && x2 < image_width);
+ Q_ASSERT(y1 >= 0 && y1 < image_height);
+ Q_ASSERT(y2 >= 0 && y2 < image_height);
+ } else {
+ if (x1 < image_x1) {
+ x2 = x1 = image_x1;
+ } else if (x1 >= image_x2 - 1) {
+ x2 = x1 = image_x2 - 1;
+ } else {
+ x2 = x1 + 1;
+ }
+ if (y1 < image_y1) {
+ y2 = y1 = image_y1;
+ } else if (y1 >= image_y2 - 1) {
+ y2 = y1 = image_y2 - 1;
+ } else {
+ y2 = y1 + 1;
+ }
+ }
int y1_offset = y1 * scanline_offset;
int y2_offset = y2 * scanline_offset;
@@ -5366,17 +5444,27 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan
SRC *b = buffer;
while (b < end) {
int x1 = (x >> 16);
- int x2 = x1 + 1;
+ int x2;
int y1 = (y >> 16);
- int y2 = y1 + 1;
+ int y2;
- const int distx = ((x - (x1 << 16)) >> 8);
- const int disty = ((y - (y1 << 16)) >> 8);
- x1 = qBound(src_minx, x1, src_maxx);
- x2 = qBound(src_minx, x2, src_maxx);
- y1 = qBound(src_miny, y1, src_maxy);
- y2 = qBound(src_miny, y2, src_maxy);
+ const int distx = (x & 0x0000ffff) >> 8;
+ const int disty = (y & 0x0000ffff) >> 8;
+ if (x1 < src_minx) {
+ x2 = x1 = src_minx;
+ } else if (x1 >= src_maxx) {
+ x2 = x1 = src_maxx;
+ } else {
+ x2 = x1 + 1;
+ }
+ if (y1 < src_miny) {
+ y2 = y1 = src_miny;
+ } else if (y1 >= src_maxy) {
+ y2 = y1 = src_maxy;
+ } else {
+ y2 = y1 + 1;
+ }
#if 0
if (x1 == x2) {
if (y1 == y2) {
@@ -5467,17 +5555,27 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan
const qreal py = y * iw - qreal(0.5);
int x1 = int(px) - (px < 0);
- int x2 = x1 + 1;
+ int x2;
int y1 = int(py) - (py < 0);
- int y2 = y1 + 1;
+ int y2;
const int distx = int((px - x1) * 256);
const int disty = int((py - y1) * 256);
- x1 = qBound(src_minx, x1, src_maxx);
- x2 = qBound(src_minx, x2, src_maxx);
- y1 = qBound(src_miny, y1, src_maxy);
- y2 = qBound(src_miny, y2, src_maxy);
+ if (x1 < src_minx) {
+ x2 = x1 = src_minx;
+ } else if (x1 >= src_maxx) {
+ x2 = x1 = src_maxx;
+ } else {
+ x2 = x1 + 1;
+ }
+ if (y1 < src_miny) {
+ y2 = y1 = src_miny;
+ } else if (y1 >= src_maxy) {
+ y2 = y1 = src_maxy;
+ } else {
+ y2 = y1 + 1;
+ }
const SRC *src1 = (SRC*)data->texture.scanLine(y1);
const SRC *src2 = (SRC*)data->texture.scanLine(y2);
@@ -5646,197 +5744,6 @@ static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, voi
}
template <SpanMethod spanMethod>
-Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_tiled_argb(int count, const QSpan *spans, void *userData)
-{
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
- if (data->texture.format != QImage::Format_ARGB32_Premultiplied
- && data->texture.format != QImage::Format_RGB32) {
- blend_src_generic<spanMethod>(count, spans, userData);
- return;
- }
-
- CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode];
- uint buffer[buffer_size];
-
- int image_width = data->texture.width;
- int image_height = data->texture.height;
- const int scanline_offset = data->texture.bytesPerLine / 4;
-
- if (data->fast_matrix) {
- // The increment pr x in the scanline
- int fdx = (int)(data->m11 * fixed_scale);
- int fdy = (int)(data->m12 * fixed_scale);
-
- while (count--) {
- void *t = data->rasterBuffer->scanLine(spans->y);
-
- uint *target = ((uint *)t) + spans->x;
- uint *image_bits = (uint *)data->texture.imageData;
-
- const qreal cx = spans->x + 0.5;
- const qreal cy = spans->y + 0.5;
-
- int x = int((data->m21 * cy
- + data->m11 * cx + data->dx) * fixed_scale) - half_point;
- int y = int((data->m22 * cy
- + data->m12 * cx + data->dy) * fixed_scale) - half_point;
-
- int length = spans->len;
- const int coverage = (spans->coverage * data->texture.const_alpha) >> 8;
- while (length) {
- int l = qMin(length, buffer_size);
- const uint *end = buffer + l;
- uint *b = buffer;
- while (b < end) {
- int x1 = (x >> 16);
- int x2 = (x1 + 1);
- int y1 = (y >> 16);
- int y2 = (y1 + 1);
-
- int distx = ((x - (x1 << 16)) >> 8);
- int disty = ((y - (y1 << 16)) >> 8);
- int idistx = 256 - distx;
- int idisty = 256 - disty;
-
- x1 %= image_width;
- x2 %= image_width;
- y1 %= image_height;
- y2 %= image_height;
-
- if (x1 < 0) x1 += image_width;
- if (x2 < 0) x2 += image_width;
- if (y1 < 0) y1 += image_height;
- if (y2 < 0) y2 += image_height;
-
- Q_ASSERT(x1 >= 0 && x1 < image_width);
- Q_ASSERT(x2 >= 0 && x2 < image_width);
- Q_ASSERT(y1 >= 0 && y1 < image_height);
- Q_ASSERT(y2 >= 0 && y2 < image_height);
-
- int y1_offset = y1 * scanline_offset;
- int y2_offset = y2 * scanline_offset;
-
-#if defined(Q_IRIX_GCC3_3_WORKAROUND)
- uint tl = gccBug(image_bits[y1_offset + x1]);
- uint tr = gccBug(image_bits[y1_offset + x2]);
- uint bl = gccBug(image_bits[y2_offset + x1]);
- uint br = gccBug(image_bits[y2_offset + x2]);
-#else
- uint tl = image_bits[y1_offset + x1];
- uint tr = image_bits[y1_offset + x2];
- uint bl = image_bits[y2_offset + x1];
- uint br = image_bits[y2_offset + x2];
-#endif
-
- uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx);
- uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx);
- *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty);
- ++b;
- x += fdx;
- y += fdy;
- }
- if (spanMethod == RegularSpans)
- func(target, buffer, l, coverage);
- else
- drawBufferSpan(data, buffer, buffer_size,
- spans->x + spans->len - length,
- spans->y, l, coverage);
- target += l;
- length -= l;
- }
- ++spans;
- }
- } else {
- const qreal fdx = data->m11;
- const qreal fdy = data->m12;
- const qreal fdw = data->m13;
- while (count--) {
- void *t = data->rasterBuffer->scanLine(spans->y);
-
- uint *target = ((uint *)t) + spans->x;
- uint *image_bits = (uint *)data->texture.imageData;
-
- const qreal cx = spans->x + 0.5;
- const qreal cy = spans->y + 0.5;
-
- qreal x = data->m21 * cy + data->m11 * cx + data->dx;
- qreal y = data->m22 * cy + data->m12 * cx + data->dy;
- qreal w = data->m23 * cy + data->m13 * cx + data->m33;
-
- int length = spans->len;
- const int coverage = (spans->coverage * data->texture.const_alpha) >> 8;
- while (length) {
- int l = qMin(length, buffer_size);
- const uint *end = buffer + l;
- uint *b = buffer;
- while (b < end) {
- const qreal iw = w == 0 ? 1 : 1 / w;
- const qreal px = x * iw - 0.5;
- const qreal py = y * iw - 0.5;
-
- int x1 = int(px) - (px < 0);
- int x2 = x1 + 1;
- int y1 = int(py) - (py < 0);
- int y2 = y1 + 1;
-
- int distx = int((px - x1) * 256);
- int disty = int((py - y1) * 256);
- int idistx = 256 - distx;
- int idisty = 256 - disty;
-
- x1 %= image_width;
- x2 %= image_width;
- y1 %= image_height;
- y2 %= image_height;
-
- if (x1 < 0) x1 += image_width;
- if (x2 < 0) x2 += image_width;
- if (y1 < 0) y1 += image_height;
- if (y2 < 0) y2 += image_height;
-
- Q_ASSERT(x1 >= 0 && x1 < image_width);
- Q_ASSERT(x2 >= 0 && x2 < image_width);
- Q_ASSERT(y1 >= 0 && y1 < image_height);
- Q_ASSERT(y2 >= 0 && y2 < image_height);
-
- int y1_offset = y1 * scanline_offset;
- int y2_offset = y2 * scanline_offset;
-
-#if defined(Q_IRIX_GCC3_3_WORKAROUND)
- uint tl = gccBug(image_bits[y1_offset + x1]);
- uint tr = gccBug(image_bits[y1_offset + x2]);
- uint bl = gccBug(image_bits[y2_offset + x1]);
- uint br = gccBug(image_bits[y2_offset + x2]);
-#else
- uint tl = image_bits[y1_offset + x1];
- uint tr = image_bits[y1_offset + x2];
- uint bl = image_bits[y2_offset + x1];
- uint br = image_bits[y2_offset + x2];
-#endif
-
- uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx);
- uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx);
- *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty);
- ++b;
- x += fdx;
- y += fdy;
- w += fdw;
- }
- if (spanMethod == RegularSpans)
- func(target, buffer, l, coverage);
- else
- drawBufferSpan(data, buffer, buffer_size,
- spans->x + spans->len - length,
- spans->y, l, coverage);
- target += l;
- length -= l;
- }
- ++spans;
- }
- }
-}
-
-template <SpanMethod spanMethod>
Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_argb(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
@@ -6738,7 +6645,7 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Indexed8
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB32
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32
- SPANFUNC_POINTER(blend_transformed_bilinear_argb, RegularSpans), // ARGB32_Premultiplied
+ blend_transformed_bilinear_argb<RegularSpans, BlendTransformedBilinear>, // ARGB32_Premultiplied
blend_transformed_bilinear_rgb565,
blend_transformed_bilinear_argb8565,
blend_transformed_bilinear_rgb666,
@@ -6757,7 +6664,7 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // Indexed8
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB32
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB32
- SPANFUNC_POINTER(blend_transformed_bilinear_tiled_argb, RegularSpans), // ARGB32_Premultiplied
+ blend_transformed_bilinear_argb<RegularSpans, BlendTransformedBilinearTiled>, // ARGB32_Premultiplied
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB16
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // ARGB8565_Premultiplied
SPANFUNC_POINTER(blend_src_generic, RegularSpans), // RGB666
@@ -6856,7 +6763,7 @@ static const ProcessSpans processTextureSpansCallback[NBlendTypes][QImage::NImag
blend_src_generic<CallbackSpans>, // Indexed8
blend_src_generic<CallbackSpans>, // RGB32
blend_src_generic<CallbackSpans>, // ARGB32
- blend_transformed_bilinear_argb<CallbackSpans>, // ARGB32_Premultiplied
+ blend_transformed_bilinear_argb<CallbackSpans, BlendTransformedBilinear>, // ARGB32_Premultiplied
blend_src_generic<CallbackSpans>, // RGB16
blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied
blend_src_generic<CallbackSpans>, // RGB666
@@ -6875,7 +6782,7 @@ static const ProcessSpans processTextureSpansCallback[NBlendTypes][QImage::NImag
blend_src_generic<CallbackSpans>, // Indexed8
blend_src_generic<CallbackSpans>, // RGB32
blend_src_generic<CallbackSpans>, // ARGB32
- blend_transformed_bilinear_tiled_argb<CallbackSpans>, // ARGB32_Premultiplied
+ blend_transformed_bilinear_argb<CallbackSpans, BlendTransformedBilinearTiled>, // ARGB32_Premultiplied
blend_src_generic<CallbackSpans>, // RGB16
blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied
blend_src_generic<CallbackSpans>, // RGB666
@@ -7135,6 +7042,11 @@ void qt_build_pow_tables() {
int winSmooth;
if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0))
smoothing = winSmooth / 1000.0;
+
+ // Safeguard ourselves against corrupt registry values...
+ if (smoothing > 5 || smoothing < 1)
+ smoothing = 1.4;
+
#endif
#ifdef Q_WS_X11
@@ -7961,6 +7873,20 @@ void qInitDrawhelperAsm()
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon;
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_neon;
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_neon;
+ qBlendFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_rgb16_neon;
+ qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB16] = qt_blend_rgb16_on_argb32_neon;
+
+ qScaleFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_rgb16_neon;
+ qScaleFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_scale_image_rgb16_on_rgb16_neon;
+
+ qTransformFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_transform_image_argb32_on_rgb16_neon;
+ qTransformFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_transform_image_rgb16_on_rgb16_neon;
+
+ qDrawHelper[QImage::Format_RGB16].alphamapBlit = qt_alphamapblit_quint16_neon;
+
+ functionForMode_C[QPainter::CompositionMode_SourceOver] = qt_blend_argb32_on_argb32_scanline_neon;
+ destFetchProc[QImage::Format_RGB16] = qt_destFetchRGB16_neon;
+ destStoreProc[QImage::Format_RGB16] = qt_destStoreRGB16_neon;
}
#endif