1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
diff -urN qt-embedded-linux-opensource-src-4.4.3.orig/configure qt-embedded-linux-opensource-src-4.4.3/configure
--- qt-embedded-linux-opensource-src-4.4.3.orig/configure 2008-09-27 11:01:23.000000000 +0200
+++ qt-embedded-linux-opensource-src-4.4.3/configure 2009-01-14 14:30:53.000000000 +0100
@@ -5045,6 +5045,7 @@
echo "Choose pixel-depths to support:"
echo
echo " 1. 1bpp, black/white"
+ echo " 2. 2bpp, grayscale"
echo " 4. 4bpp, grayscale"
echo " 8. 8bpp, paletted"
echo " 12. 12bpp, rgb 4-4-4"
@@ -5063,11 +5064,11 @@
fi
if [ -n "$CFG_QWS_DEPTHS" -a "$PLATFORM_QWS" = "yes" ]; then
if [ "$CFG_QWS_DEPTHS" = "all" ]; then
- CFG_QWS_DEPTHS="1 4 8 12 15 16 18 24 32 generic"
+ CFG_QWS_DEPTHS="1 2 4 8 12 15 16 18 24 32 generic"
fi
for D in `echo "$CFG_QWS_DEPTHS" | sed -e 's/,/ /g'`; do
case $D in
- 1|4|8|12|15|16|18|24|32) QCONFIG_FLAGS="$QCONFIG_FLAGS QT_QWS_DEPTH_$D";;
+ 1|2|4|8|12|15|16|18|24|32) QCONFIG_FLAGS="$QCONFIG_FLAGS QT_QWS_DEPTH_$D";;
generic) QCONFIG_FLAGS="$QCONFIG_FLAGS QT_QWS_DEPTH_GENERIC";;
esac
done
diff -urN qt-embedded-linux-opensource-src-4.4.3.orig/src/gui/embedded/qscreenlinuxfb_qws.cpp qt-embedded-linux-opensource-src-4.4.3/src/gui/embedded/qscreenlinuxfb_qws.cpp
--- qt-embedded-linux-opensource-src-4.4.3.orig/src/gui/embedded/qscreenlinuxfb_qws.cpp 2008-09-27 11:01:28.000000000 +0200
+++ qt-embedded-linux-opensource-src-4.4.3/src/gui/embedded/qscreenlinuxfb_qws.cpp 2009-01-14 17:22:34.000000000 +0100
@@ -404,8 +404,8 @@
setupOffScreen();
// Now read in palette
- if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) {
- screencols= (vinfo.bits_per_pixel==8) ? 256 : 16;
+ if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4) || (vinfo.bits_per_pixel==2)) {
+ screencols= 1 << vinfo.bits_per_pixel;
int loopc;
fb_cmap startcmap;
startcmap.start=0;
diff -urN qt-embedded-linux-opensource-src-4.4.3.orig/src/gui/embedded/qscreen_qws.cpp qt-embedded-linux-opensource-src-4.4.3/src/gui/embedded/qscreen_qws.cpp
--- qt-embedded-linux-opensource-src-4.4.3.orig/src/gui/embedded/qscreen_qws.cpp 2008-09-27 11:01:28.000000000 +0200
+++ qt-embedded-linux-opensource-src-4.4.3/src/gui/embedded/qscreen_qws.cpp 2009-01-14 17:22:44.000000000 +0100
@@ -444,6 +444,58 @@
}
#endif // QT_QWS_DEPTH_4
+#ifdef QT_QWS_DEPTH_2
+static inline void qt_rectfill_gray2(quint8 *dest, quint8 value,
+ int x, int y, int width, int height,
+ int stride)
+{
+ const int pixelsPerByte = 4;
+ const int alignWidth = qMin(width, (4 - (x & 3)) & 3);
+ const int doAlign = (alignWidth > 0 ? 1 : 0);
+ const int alignStart = pixelsPerByte - 1 - (x & 3);
+ const int alignStop = alignStart - (alignWidth - 1);
+ const quint8 alignMask = ((1 << (2 * alignWidth)) - 1) << (2 * alignStop);
+ const int tailWidth = (width - alignWidth) & 3;
+ const int doTail = (tailWidth > 0 ? 1 : 0);
+ const quint8 tailMask = (1 << (2 * (pixelsPerByte - tailWidth))) - 1;
+ const int width8 = (width - alignWidth) / pixelsPerByte;
+
+ dest += y * stride + x / pixelsPerByte;
+ stride -= (doAlign + width8);
+
+ for (int j = 0; j < height; ++j) {
+ if (doAlign) {
+ *dest = (*dest & ~alignMask) | (value & alignMask);
+ ++dest;
+ }
+ if (width8) {
+ qt_memfill<quint8>(dest, value, width8);
+ dest += width8;
+ }
+ if (doTail)
+ *dest = (*dest & tailMask) | (value & ~tailMask);
+ dest += stride;
+ }
+}
+
+static void solidFill_gray2(QScreen *screen, const QColor &color,
+ const QRegion ®ion)
+{
+ quint8 *dest = reinterpret_cast<quint8*>(screen->base());
+ const quint8 c = qGray(color.rgba()) >> 6;
+ const quint8 c8 = (c << 6) | (c << 4) | (c << 2) | c;
+
+ const int stride = screen->linestep();
+ const QVector<QRect> rects = region.rects();
+
+ for (int i = 0; i < rects.size(); ++i) {
+ const QRect r = rects.at(i);
+ qt_rectfill_gray2(dest, c8, r.x(), r.y(), r.width(), r.height(),
+ stride);
+ }
+}
+#endif // QT_QWS_DEPTH_2
+
#ifdef QT_QWS_DEPTH_1
static inline void qt_rectfill_mono(quint8 *dest, quint8 value,
int x, int y, int width, int height,
@@ -551,6 +603,11 @@
screen->d_ptr->solidFill = solidFill_gray4;
break;
#endif
+#ifdef QT_QWS_DEPTH_2
+ case 2:
+ screen->d_ptr->solidFill = solidFill_gray2;
+ break;
+#endif
#ifdef QT_QWS_DEPTH_1
case 1:
screen->d_ptr->solidFill = solidFill_mono;
@@ -958,6 +1015,149 @@
}
#endif // QT_QWS_DEPTH_4
+#ifdef QT_QWS_DEPTH_2
+
+struct qgray2 { quint8 dummy; } Q_PACKED;
+
+template <typename SRC>
+static inline quint8 qt_convertToGray2(SRC color);
+
+template <>
+inline quint8 qt_convertToGray2(quint32 color)
+{
+ return qGray(color) >> 6;
+}
+
+template <>
+inline quint8 qt_convertToGray2(quint16 color)
+{
+ const int r = (color & 0xf800) >> 11;
+ const int g = (color & 0x07e0) >> 6; // only keep 5 bit
+ const int b = (color & 0x001f);
+ return (r * 11 + g * 16 + b * 5) >> 8;
+}
+
+template <>
+inline quint8 qt_convertToGray2(qrgb444 color)
+{
+ return qt_convertToGray2(quint32(color));
+}
+
+template <>
+inline quint8 qt_convertToGray2(qargb4444 color)
+{
+ return qt_convertToGray2(quint32(color));
+}
+
+template <typename SRC>
+static inline void qt_rectconvert_gray2(qgray2 *dest2, const SRC *src,
+ int x, int y, int width, int height,
+ int dstStride, int srcStride)
+{
+ const int pixelsPerByte = 4;
+ quint8 *dest8 = reinterpret_cast<quint8*>(dest2)
+ + y * dstStride + x / pixelsPerByte;
+ const int alignWidth = qMin(width, (4 - (x & 3)) & 3);
+ const int doAlign = (alignWidth > 0 ? 1 : 0);
+ const int alignStart = pixelsPerByte - 1 - (x & 3);
+ const int alignStop = alignStart - (alignWidth - 1);
+ const quint8 alignMask = ((1 << (2 * alignWidth)) - 1) << (2 * alignStop);
+ const int tailWidth = (width - alignWidth) & 3;
+ const int doTail = (tailWidth > 0 ? 1 : 0);
+ const quint8 tailMask = (1 << (2 * (pixelsPerByte - tailWidth))) - 1;
+ const int width8 = (width - alignWidth) / pixelsPerByte;
+
+ srcStride = srcStride / sizeof(SRC) - (width8 * pixelsPerByte + alignWidth);
+ dstStride -= (width8 + doAlign);
+
+ for (int j = 0; j < height; ++j) {
+ if (doAlign) {
+ quint8 d = *dest8 & ~alignMask;
+ for (int i = alignStart; i >= alignStop; --i)
+ d |= qt_convertToGray2<SRC>(*src++) << (2 * i);
+ *dest8++ = d;
+ }
+ for (int i = 0; i < width8; ++i) {
+ *dest8 = (qt_convertToGray2<SRC>(src[0]) << 6)
+ | (qt_convertToGray2<SRC>(src[1]) << 4)
+ | (qt_convertToGray2<SRC>(src[2]) << 2)
+ | (qt_convertToGray2<SRC>(src[3]));
+ src += 4;
+ ++dest8;
+ }
+ if (doTail) {
+ quint8 d = *dest8 & tailMask;
+ switch (tailWidth) {
+ case 3: d |= qt_convertToGray2<SRC>(src[2]) << 2;
+ case 2: d |= qt_convertToGray2<SRC>(src[1]) << 4;
+ case 1: d |= qt_convertToGray2<SRC>(src[0]) << 6;
+ }
+ *dest8 = d;
+ }
+
+ dest8 += dstStride;
+ src += srcStride;
+ }
+}
+
+template <>
+void qt_rectconvert(qgray2 *dest, const quint32 *src,
+ int x, int y, int width, int height,
+ int dstStride, int srcStride)
+{
+ qt_rectconvert_gray2<quint32>(dest, src, x, y, width, height,
+ dstStride, srcStride);
+}
+
+template <>
+void qt_rectconvert(qgray2 *dest, const quint16 *src,
+ int x, int y, int width, int height,
+ int dstStride, int srcStride)
+{
+ qt_rectconvert_gray2<quint16>(dest, src, x, y, width, height,
+ dstStride, srcStride);
+}
+
+template <>
+void qt_rectconvert(qgray2 *dest, const qrgb444 *src,
+ int x, int y, int width, int height,
+ int dstStride, int srcStride)
+{
+ qt_rectconvert_gray2<qrgb444>(dest, src, x, y, width, height,
+ dstStride, srcStride);
+}
+
+template <>
+void qt_rectconvert(qgray2 *dest, const qargb4444 *src,
+ int x, int y, int width, int height,
+ int dstStride, int srcStride)
+{
+ qt_rectconvert_gray2<qargb4444>(dest, src, x, y, width, height,
+ dstStride, srcStride);
+}
+
+static void blit_2(QScreen *screen, const QImage &image,
+ const QPoint &topLeft, const QRegion ®ion)
+{
+ switch (image.format()) {
+ case QImage::Format_ARGB32_Premultiplied:
+ blit_template<qgray2, quint32>(screen, image, topLeft, region);
+ return;
+ case QImage::Format_RGB16:
+ blit_template<qgray2, quint16>(screen, image, topLeft, region);
+ return;
+ case QImage::Format_RGB444:
+ blit_template<qgray2, qrgb444>(screen, image, topLeft, region);
+ return;
+ case QImage::Format_ARGB4444_Premultiplied:
+ blit_template<qgray2, qargb4444>(screen, image, topLeft, region);
+ return;
+ default:
+ qCritical("blit_2(): Image format %d not supported!", image.format());
+ }
+}
+#endif // QT_QWS_DEPTH_2
+
#ifdef QT_QWS_DEPTH_1
struct qmono { quint8 dummy; } Q_PACKED;
@@ -1206,6 +1406,11 @@
screen->d_ptr->blit = blit_4;
break;
#endif
+#ifdef QT_QWS_DEPTH_2
+ case 2:
+ screen->d_ptr->blit = blit_2;
+ break;
+#endif
#ifdef QT_QWS_DEPTH_1
case 1:
screen->d_ptr->blit = blit_1;
@@ -2056,6 +2261,8 @@
}
} else if (d == 4) {
ret = qGray(r, g, b) >> 4;
+ } else if (d == 2) {
+ ret = qGray(r, g, b) >> 6;
} else if (d == 1) {
ret = qGray(r, g, b) >= 128;
} else {
@@ -2126,6 +2333,10 @@
} else if(d==1) {
return true;
#endif
+#ifdef QT_QWS_DEPTH_2
+ } else if(d==2) {
+ return true;
+#endif
#ifdef QT_QWS_DEPTH_4
} else if(d==4) {
return true;
|