Contents of /trunk/qt4/patches/qt-4.8.5-qtbug-31579.patch
Parent Directory | Revision Log
Revision 2278 -
(show annotations)
(download)
Tue Sep 3 07:33:26 2013 UTC (11 years ago) by niro
File size: 5840 byte(s)
Tue Sep 3 07:33:26 2013 UTC (11 years ago) by niro
File size: 5840 byte(s)
-upstream fixes for 4.8.5
1 | From 2a6537f0629aaff53a42d993ad94ad4de3cd3030 Mon Sep 17 00:00:00 2001 |
2 | From: Gunnar Sletta <gunnar.sletta@digia.com> |
3 | Date: Thu, 4 Jul 2013 16:20:40 +1000 |
4 | Subject: [PATCH] Fix drawing of 0-width polylines from outside the devicerect. |
5 | |
6 | This was broken by a previous fix which aimed to fix gaps in |
7 | polylines with tiny line segments. The result was that we |
8 | skipped updating the origin point when stroke() didn't produce |
9 | pixels which accidentally included the case of the line |
10 | being completely outside the deviceRect. I fixed this |
11 | by returning the value of clipLine in drawLine to the caller |
12 | so we could still update the origin for this case. |
13 | |
14 | Task-number: QTBUG-31579 |
15 | Change-Id: Iac29436f042da7658bbeaf9370351dc6f2c95065 |
16 | (cherry picked from qtbase/900cccfd459fcbdbc4aa3d313afe12cfbf68fd87) |
17 | Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com> |
18 | --- |
19 | src/gui/painting/qcosmeticstroker.cpp | 42 ++++++++++++++++++++------------ |
20 | src/gui/painting/qcosmeticstroker_p.h | 2 +- |
21 | 2 files changed, 27 insertions(+), 17 deletions(-) |
22 | |
23 | diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp |
24 | index 0061ecb..4413170 100644 |
25 | --- a/src/gui/painting/qcosmeticstroker.cpp |
26 | +++ b/src/gui/painting/qcosmeticstroker.cpp |
27 | @@ -133,10 +133,15 @@ struct NoDasher { |
28 | |
29 | }; |
30 | |
31 | +/* |
32 | + * The return value is the result of the clipLine() call performed at the start |
33 | + * of each of the two functions, aka "false" means completely outside the devices |
34 | + * rect. |
35 | + */ |
36 | template<DrawPixel drawPixel, class Dasher> |
37 | -static void drawLine(QCosmeticStroker *stroker, qreal x1, qreal y1, qreal x2, qreal y2, int caps); |
38 | +static bool drawLine(QCosmeticStroker *stroker, qreal x1, qreal y1, qreal x2, qreal y2, int caps); |
39 | template<DrawPixel drawPixel, class Dasher> |
40 | -static void drawLineAA(QCosmeticStroker *stroker, qreal x1, qreal y1, qreal x2, qreal y2, int caps); |
41 | +static bool drawLineAA(QCosmeticStroker *stroker, qreal x1, qreal y1, qreal x2, qreal y2, int caps); |
42 | |
43 | inline void drawPixel(QCosmeticStroker *stroker, int x, int y, int coverage) |
44 | { |
45 | @@ -602,17 +607,20 @@ void QCosmeticStroker::drawPath(const QVectorPath &path) |
46 | caps |= CapEnd; |
47 | |
48 | QCosmeticStroker::Point last = this->lastPixel; |
49 | - stroke(this, p.x(), p.y(), p2.x(), p2.y(), caps); |
50 | + bool unclipped = stroke(this, p.x(), p.y(), p2.x(), p2.y(), caps); |
51 | |
52 | /* fix for gaps in polylines with fastpen and aliased in a sequence |
53 | of points with small distances: if current point p2 has been dropped |
54 | - out, keep last non dropped point p. */ |
55 | - if (fastPenAliased) { |
56 | - if (last.x != lastPixel.x || last.y != lastPixel.y || |
57 | - points == begin + 2 || points == end - 2 ) { |
58 | - { |
59 | - p = p2; |
60 | - } |
61 | + out, keep last non dropped point p. |
62 | + |
63 | + However, if the line was completely outside the devicerect, we |
64 | + still need to update p to avoid drawing the line after this one from |
65 | + a bad starting position. |
66 | + */ |
67 | + if (fastPenAliased && unclipped) { |
68 | + if (last.x != lastPixel.x || last.y != lastPixel.y |
69 | + || points == begin + 2 || points == end - 2) { |
70 | + p = p2; |
71 | } |
72 | } else { |
73 | p = p2; |
74 | @@ -720,10 +728,10 @@ static inline void capAdjust(int caps, int &x1, int &x2, int &y, int yinc) |
75 | the drawing shifts from horizontal to vertical or back. |
76 | */ |
77 | template<DrawPixel drawPixel, class Dasher> |
78 | -static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, qreal ry2, int caps) |
79 | +static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, qreal ry2, int caps) |
80 | { |
81 | if (stroker->clipLine(rx1, ry1, rx2, ry2)) |
82 | - return; |
83 | + return false; |
84 | |
85 | static const int half = 31; |
86 | int x1 = toF26Dot6(rx1) + half; |
87 | @@ -813,7 +821,7 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, |
88 | } else { |
89 | // horizontal |
90 | if (!dx) |
91 | - return; |
92 | + return true; |
93 | |
94 | QCosmeticStroker::Direction dir = QCosmeticStroker::LeftToRight; |
95 | |
96 | @@ -886,14 +894,15 @@ static void drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, |
97 | } |
98 | } |
99 | stroker->lastPixel = last; |
100 | + return true; |
101 | } |
102 | |
103 | |
104 | template<DrawPixel drawPixel, class Dasher> |
105 | -static void drawLineAA(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, qreal ry2, int caps) |
106 | +static bool drawLineAA(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, qreal ry2, int caps) |
107 | { |
108 | if (stroker->clipLine(rx1, ry1, rx2, ry2)) |
109 | - return; |
110 | + return false; |
111 | |
112 | int x1 = toF26Dot6(rx1); |
113 | int y1 = toF26Dot6(ry1); |
114 | @@ -967,7 +976,7 @@ static void drawLineAA(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx |
115 | } else { |
116 | // horizontal |
117 | if (!dx) |
118 | - return; |
119 | + return true; |
120 | |
121 | int yinc = F16Dot16FixedDiv(dy, dx); |
122 | |
123 | @@ -1029,6 +1038,7 @@ static void drawLineAA(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx |
124 | drawPixel(stroker, x, (y>>16) + 1, alpha * alphaEnd >> 6); |
125 | } |
126 | } |
127 | + return true; |
128 | } |
129 | |
130 | QT_END_NAMESPACE |
131 | diff --git a/src/gui/painting/qcosmeticstroker_p.h b/src/gui/painting/qcosmeticstroker_p.h |
132 | index 870738b..3216856 100644 |
133 | --- a/src/gui/painting/qcosmeticstroker_p.h |
134 | +++ b/src/gui/painting/qcosmeticstroker_p.h |
135 | @@ -56,7 +56,7 @@ QT_MODULE(Gui) |
136 | class QCosmeticStroker; |
137 | |
138 | |
139 | -typedef void (*StrokeLine)(QCosmeticStroker *stroker, qreal x1, qreal y1, qreal x2, qreal y2, int caps); |
140 | +typedef bool (*StrokeLine)(QCosmeticStroker *stroker, qreal x1, qreal y1, qreal x2, qreal y2, int caps); |
141 | |
142 | class QCosmeticStroker |
143 | { |
144 | -- |
145 | 1.7.1 |
146 |