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