aboutsummaryrefslogtreecommitdiffstats
path: root/android/utils
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2011-01-16 16:25:10 +0100
committerDavid 'Digit' Turner <digit@android.com>2011-01-18 20:53:34 +0100
commit122b335f58e2f52d542854dcddef8723a2b213a4 (patch)
treef801422c45756dfcdfa9562aefce1a4a7f728c4c /android/utils
parent197e5f763ec8a6d514d59647c84ebd9b324eba97 (diff)
downloadexternal_qemu-122b335f58e2f52d542854dcddef8723a2b213a4.zip
external_qemu-122b335f58e2f52d542854dcddef8723a2b213a4.tar.gz
external_qemu-122b335f58e2f52d542854dcddef8723a2b213a4.tar.bz2
Sligh speedup for pixel conversion routines with Duff's device.
Change-Id: If832bc5844945f7a2027b2f8d09393586545d8d5
Diffstat (limited to 'android/utils')
-rw-r--r--android/utils/duff.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/android/utils/duff.h b/android/utils/duff.h
new file mode 100644
index 0000000..a00768c
--- /dev/null
+++ b/android/utils/duff.h
@@ -0,0 +1,71 @@
+/* Copyright (C) 2011 The Android Open Source Project
+**
+** This software is licensed under the terms of the GNU General Public
+** License version 2, as published by the Free Software Foundation, and
+** may be copied, distributed, and modified under those terms.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+*/
+#ifndef ANDROID_UTILS_DUFF_H
+#define ANDROID_UTILS_DUFF_H
+
+/*********************************************************************
+ *********************************************************************
+ *****
+ ***** DUFF'S DEVICES
+ *****
+ *****/
+
+#define DUFF1(_count,_stmnt) \
+ do { \
+ int __n = (_count); \
+ do { \
+ _stmnt; \
+ } while (--__n > 0); \
+ } while (0);
+
+#define DUFF2(_count,_stmnt) \
+ ({ \
+ int __count = (_count); \
+ int __n = (__count +1)/2; \
+ switch (__count & 1) { \
+ case 0: do { _stmnt; \
+ case 1: _stmnt; \
+ } while (--__n > 0); \
+ } \
+ })
+
+#define DUFF4(_count,_stmnt) \
+ ({ \
+ int __count = (_count); \
+ int __n = (__count +3)/4; \
+ switch (__count & 3) { \
+ case 0: do { _stmnt; \
+ case 3: _stmnt; \
+ case 2: _stmnt; \
+ case 1: _stmnt; \
+ } while (--__n > 0); \
+ } \
+ })
+
+#define DUFF8(_count,_stmnt) \
+ ({ \
+ int __count = (_count); \
+ int __n = (__count+7)/8; \
+ switch (__count & 7) { \
+ case 0: do { _stmnt; \
+ case 7: _stmnt; \
+ case 6: _stmnt; \
+ case 5: _stmnt; \
+ case 4: _stmnt; \
+ case 3: _stmnt; \
+ case 2: _stmnt; \
+ case 1: _stmnt; \
+ } while (--__n > 0); \
+ } \
+ })
+
+#endif /* ANDROID_UTILS_DUFF_H */