summaryrefslogtreecommitdiff
path: root/packages/xorg-lib/pixman/pixman-arm.patch
blob: 224b6125480bf380a1e0782cc1b0148e3d5d1aac (plain)
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
commit 23a7d5dea599efec1f459bac64cf9edc4bd5ae11
Author: Ilpo Ruotsalainen <ilpo.ruotsalainen@movial.fi>
Date:   Thu Nov 29 12:29:59 2007 +0000

    Implement ARM optimized version of fill routines.

diff --git a/configure.ac b/configure.ac
index 22a91ef..3ac2a40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -148,6 +148,32 @@ fi
 AM_CONDITIONAL(USE_SSE, test $have_sse_intrinsics = yes)
 
 dnl ========================================================
+
+dnl Test for architechture specific optimizations for this platform
+
+AC_MSG_CHECKING(for architechture specific optimizations)
+
+use_arch_opts=no
+
+case "$host_cpu" in
+arm)
+	if test "$GCC" = "yes" ; then
+		use_arch_opts=yes
+		ARCH_OPT_SOURCES='pixman-arch-arm.lo'
+	fi
+	;;
+esac
+
+AC_MSG_RESULT($use_arch_opts)
+
+if test $use_arch_opts = yes ; then
+	AC_DEFINE(USE_ARCH_OPTS, 1, [use architechture specific optimizations])
+fi
+
+AC_SUBST([ARCH_OPT_SOURCES])
+AM_CONDITIONAL(USE_ARCH_OPTS, test $use_arch_opts = yes)
+
+dnl ========================================================
 AC_SUBST(MMX_CFLAGS)
 
 PKG_CHECK_MODULES(GTK, [gtk+-2.0], [HAVE_GTK=yes], [HAVE_GTK=no])
diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index 66283a2..dab6363 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -20,6 +20,11 @@ libpixman_1_la_SOURCES =		\
 libpixmanincludedir = $(includedir)/pixman-1/
 libpixmaninclude_HEADERS = pixman.h
 
+if USE_ARCH_OPTS
+libpixman_1_la_LIBADD += $(ARCH_OPT_SOURCES)
+libpixman_1_la_DEPENDENCIES = $(ARCH_OPT_SOURCES)
+endif
+
 # mmx code
 if USE_MMX
 noinst_LTLIBRARIES = libpixman-mmx.la
diff --git a/pixman/pixman-arch-arm.c b/pixman/pixman-arch-arm.c
new file mode 100644
index 0000000..655092c
--- /dev/null
+++ b/pixman/pixman-arch-arm.c
@@ -0,0 +1,205 @@
+/*
+ * Copyright © 2007 Movial Creative Technologies Inc
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Ilpo Ruotsalainen <ilpo.ruotsalainen@movial.fi>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "pixman.h"
+#include "pixman-private.h"
+
+static void
+pixman_fill8 (uint32_t  *bits,
+	      int	stride,
+	      int	x,
+	      int	y,
+	      int	width,
+	      int	height,
+	      uint32_t  xor)
+{
+    int byte_stride = stride * sizeof (uint32_t);
+    uint8_t *dst = (uint8_t *) bits;
+    uint8_t v = xor & 0xff;
+
+    xor = v | (v << 8);
+    xor |= xor << 16;
+
+    dst = dst + y * byte_stride + x;
+
+    while (height--)
+    {
+	uint32_t dummy1, dummy2;
+
+	asm volatile(
+	    /* Check if the fill width is very small */
+	    "	cmp	%0, #8\n"
+	    "	bcc	2f\n"
+	    /* Output single pixels until aligned to word boundary */
+	    "1:	tst	%1, #3\n"
+	    "	strneb	%4, [%1], #1\n"
+	    "	subne	%0, %0, #1\n"
+	    "	bne	1b\n"
+	    /* Output up to 16 pixels per iteration */
+	    "1:	subs	%0, %0, #8\n"
+	    "	strcs	%4, [%1], #4\n"
+	    "	strcs	%4, [%1], #4\n"
+	    "	subcss	%0, %0, #8\n"
+	    "	strcs	%4, [%1], #4\n"
+	    "	strcs	%4, [%1], #4\n"
+	    "	bcs	1b\n"
+	    /* Finish up any remaining pixels */
+	    "	and	%0, %0, #7\n"
+	    "2:	subs	%0, %0, #1\n"
+	    "	strcsb	%4, [%1], #1\n"
+	    "	subcss	%0, %0, #1\n"
+	    "	strcsb	%4, [%1], #1\n"
+	    "	bcs	2b\n"
+	    : "=r" (dummy1), "=r" (dummy2)
+	    : "0" (width), "1" (dst), "r" (xor)
+	    : "cc", "memory"
+	    );
+
+	dst += byte_stride;
+    }
+}
+
+static void
+pixman_fill16 (uint32_t *bits,
+	       int       stride,
+	       int       x,
+	       int       y,
+	       int       width,
+	       int       height,
+	       uint32_t  xor)
+{
+    int short_stride = (stride * sizeof (uint32_t)) / sizeof (uint16_t);
+    uint16_t *dst = (uint16_t *)bits;
+    uint16_t v = xor & 0xffff;
+
+    xor = v | v << 16;
+
+    dst = dst + y * short_stride + x;
+
+    while (height--)
+    {
+	uint32_t dummy1, dummy2;
+
+	asm volatile(
+	    /* Check if the fill width is very small */
+	    "	cmp	%0, #4\n"
+	    "	bcc	2f\n"
+	    /* Output single pixels until aligned to word boundary */
+	    "1:	tst	%1, #2\n"
+	    "	strneh	%4, [%1], #2\n"
+	    "	subne	%0, %0, #1\n"
+	    "	bne	1b\n"
+	    /* Output up to 8 pixels per iteration */
+	    "1:	subs	%0, %0, #4\n"
+	    "	strcs	%4, [%1], #4\n"
+	    "	strcs	%4, [%1], #4\n"
+	    "	subcss	%0, %0, #4\n"
+	    "	strcs	%4, [%1], #4\n"
+	    "	strcs	%4, [%1], #4\n"
+	    "	bcs	1b\n"
+	    /* Finish up any remaining pixels */
+	    "	and	%0, %0, #3\n"
+	    "2:	subs	%0, %0, #1\n"
+	    "	strcsh	%4, [%1], #2\n"
+	    "	bcs	2b\n"
+	    : "=r" (dummy1), "=r" (dummy2)
+	    : "0" (width), "1" (dst), "r" (xor)
+	    : "cc", "memory"
+	    );
+
+	dst += short_stride;
+    }
+}
+
+static void
+pixman_fill32 (uint32_t *bits,
+	       int       stride,
+	       int       x,
+	       int       y,
+	       int       width,
+	       int       height,
+	       uint32_t  xor)
+{
+    bits = bits + y * stride + x;
+    
+    while (height--)
+    {
+	uint32_t dummy1, dummy2;
+
+	asm volatile(
+	    /* Check if the fill width is very small */
+	    "	cmp	%0, #2\n"
+	    "	bcc	2f\n"
+	    /* Output up to 4 pixels per iteration */
+	    "1:	subs	%0, %0, #2\n"
+	    "	strcs	%4, [%1], #4\n"
+	    "	strcs	%4, [%1], #4\n"
+	    "	subcss	%0, %0, #2\n"
+	    "	strcs	%4, [%1], #4\n"
+	    "	strcs	%4, [%1], #4\n"
+	    "	bcs	1b\n"
+	    /* Output last pixel if necessary */
+	    "2:	tst	%0, #1\n"
+	    "	strne	%4, [%1], #4\n"
+	    : "=r" (dummy1), "=r" (dummy2)
+	    : "0" (width), "1" (bits), "r" (xor)
+	    : "cc", "memory"
+	    );
+
+	bits += stride;
+    }
+}
+
+pixman_bool_t
+pixman_fill (uint32_t *bits,
+	     int stride,
+	     int bpp,
+	     int x,
+	     int y,
+	     int width,
+	     int height,
+	     uint32_t xor)
+{
+    switch (bpp)
+    {
+    case 8:
+	pixman_fill8 (bits, stride, x, y, width, height, xor);
+	break;
+	
+    case 16:
+	pixman_fill16 (bits, stride, x, y, width, height, xor);
+	break;
+	
+    case 32:
+	pixman_fill32 (bits, stride, x, y, width, height, xor);
+	break;
+
+    default:
+	return FALSE;
+	break;
+    }
+	
+    return TRUE;
+}
diff --git a/pixman/pixman-arch.h b/pixman/pixman-arch.h
new file mode 100644
index 0000000..1eee9d3
--- /dev/null
+++ b/pixman/pixman-arch.h
@@ -0,0 +1,7 @@
+#ifdef USE_ARCH_OPTS
+
+#ifdef __arm__
+#define USE_ARCH_FILL
+#endif
+
+#endif
--- /tmp/pixman-utils.c	2008-08-14 12:38:44.000000000 +0200
+++ pixman-0.11.8/pixman/pixman-utils.c	2008-08-14 12:40:03.503198000 +0200
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 
 #include "pixman-private.h"
+#include "pixman-arch.h"
 #include "pixman-mmx.h"
 
 PIXMAN_EXPORT pixman_bool_t
@@ -84,6 +85,7 @@
 	return FALSE;
 }
 
+#ifndef USE_ARCH_FILL
 static void
 pixman_fill8 (uint32_t  *bits,
 	      int	stride,
@@ -197,7 +199,7 @@
 
     return TRUE;
 }
-
+#endif
 
 /*
  * Compute the smallest value no less than y which is on a