summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/painting/qdrawhelper.cpp133
1 files changed, 66 insertions, 67 deletions
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 59bef66..be4275c 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -5159,61 +5159,6 @@ static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData)
blend_tiled_generic<RegularSpans>(count, spans, userData);
}
-template<int>
-Q_STATIC_INLINE_FUNCTION void blend_transformed_bilinear_argb_clamp_coordinates (int &x1, int &x2, int &y1, int &y2,
- const int image_width, const int image_height,
- const int image_x1, const int image_x2,
- const int image_y1, const int image_y2);
-
-template<>
-Q_STATIC_INLINE_FUNCTION void blend_transformed_bilinear_argb_clamp_coordinates <BlendTransformedBilinearTiled> (int &x1, int &x2, int &y1, int &y2,
- const int image_width, const int image_height,
- const int image_x1, const int image_x2,
- const int image_y1, const int image_y2)
-{
- Q_UNUSED(image_x1)
- Q_UNUSED(image_x2)
- Q_UNUSED(image_y1)
- Q_UNUSED(image_y2)
- 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);
-}
-
-template <>
-Q_STATIC_INLINE_FUNCTION void blend_transformed_bilinear_argb_clamp_coordinates<BlendTransformedBilinear>(int &x1, int &x2, int &y1, int &y2,
- const int image_width, const int image_height,
- const int image_x1, const int image_x2,
- const int image_y1, const int image_y2)
-{
- Q_UNUSED(image_width)
- Q_UNUSED(image_height)
- if (x1 < image_x1) {
- x2 = x1 = image_x1;
- } else if (x1 >= image_x2) {
- x2 = x1 = image_x2;
- } else {
- x2 = x1 + 1;
- }
- if (y1 < image_y1) {
- y2 = y1 = image_y1;
- } else if (y1 >= image_y2) {
- y2 = y1 = image_y2;
- } else {
- y2 = y1 + 1;
- }
-}
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)
@@ -5230,8 +5175,8 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const
const int image_x1 = data->texture.x1;
const int image_y1 = data->texture.y1;
- const int image_x2 = data->texture.x2 - 1;
- const int image_y2 = data->texture.y2 - 1;
+ 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;
@@ -5261,16 +5206,43 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const
int l = qMin(length, buffer_size);
const uint *end = buffer + l;
uint *b = buffer;
- while (b != end) {
+ while (b < end) {
int x1 = (x >> 16);
int x2;
int y1 = (y >> 16);
int y2;
- blend_transformed_bilinear_argb_clamp_coordinates<blendType>(x1, x2, y1, y2,
- image_width, image_height,
- image_x1, image_x2,
- image_y1, image_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;
@@ -5335,7 +5307,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const
int l = qMin(length, buffer_size);
const uint *end = buffer + l;
uint *b = buffer;
- while (b != end) {
+ 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;
@@ -5350,10 +5322,37 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const
int idistx = 256 - distx;
int idisty = 256 - disty;
- blend_transformed_bilinear_argb_clamp_coordinates<blendType>(x1, x2, y1, y2,
- image_width, image_height,
- image_x1, image_x2,
- image_y1, image_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;