summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-08-25 16:51:55 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-08-26 07:34:15 (GMT)
commit39b7982de7bb8f80dd915591b8a391e18476e456 (patch)
tree4b08ec09782ca6572ba8b0d18359b64c87e38f8f /src/gui/painting
parent441b462c537f2b2ec61d3e1acba71c6cada34ff8 (diff)
downloadQt-39b7982de7bb8f80dd915591b8a391e18476e456.zip
Qt-39b7982de7bb8f80dd915591b8a391e18476e456.tar.gz
Qt-39b7982de7bb8f80dd915591b8a391e18476e456.tar.bz2
Revert "Refactor blend_transformed_bilinear to simplify the blend type checking"
This reverts commit d2089600ea247b5d6354e8eee4becf40802c4693. Reverting in order to avoid conflict in the master branch. We are going to consider backporting the changes to Qt 4.7.1 Reviewed-by: Benjamin Poulain
Diffstat (limited to 'src/gui/painting')
-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;