aboutsummaryrefslogtreecommitdiffstats
path: root/libfonts_get_subpixel_order_class.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-01-07 20:24:56 +0100
committerMattias Andrée <maandree@kth.se>2023-01-07 20:24:56 +0100
commita0a215b02de9a4f32097a8e98208f911c8d1e027 (patch)
treebd11effbe838b1a0b731877774bddcde6b8edb53 /libfonts_get_subpixel_order_class.c
parentAdd LIBFONTS_SUBPIXEL_ORDER_BALANCED_??_?? subpixels orders (diff)
downloadlibfonts-a0a215b02de9a4f32097a8e98208f911c8d1e027.tar.gz
libfonts-a0a215b02de9a4f32097a8e98208f911c8d1e027.tar.bz2
libfonts-a0a215b02de9a4f32097a8e98208f911c8d1e027.tar.xz
Add libfonts_{get,unget}_subpixel_order_class
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libfonts_get_subpixel_order_class.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/libfonts_get_subpixel_order_class.c b/libfonts_get_subpixel_order_class.c
new file mode 100644
index 0000000..577b0f0
--- /dev/null
+++ b/libfonts_get_subpixel_order_class.c
@@ -0,0 +1,41 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+enum libfonts_subpixel_order_class
+libfonts_get_subpixel_order_class(enum libfonts_subpixel_order order,
+ enum libfonts_subpixel_colour *cell1p,
+ enum libfonts_subpixel_colour *cell2p,
+ enum libfonts_subpixel_colour *cell3p)
+{
+ enum libfonts_subpixel_colour c1, c2, c3;
+ enum libfonts_subpixel_order_class layout;
+ int i; /* RGB, RBG, GRB, GBR, BRG, BGR */
+
+ if (order >= LIBFONTS_SUBPIXEL_ORDER_RGB && order <= LIBFONTS_SUBPIXEL_ORDER_G_R_B) {
+ layout = ((order - LIBFONTS_SUBPIXEL_ORDER_RGB) & 1) + LIBFONTS_SUBPIXEL_ORDER_CLASS_123;
+ i = (order - LIBFONTS_SUBPIXEL_ORDER_RGB) / 2;
+ i = ((int []){0, 5, 3, 1, 4, 2})[i];
+
+ } else if (order >= LIBFONTS_SUBPIXEL_ORDER_RR_GB && order <= LIBFONTS_SUBPIXEL_ORDER_BALANCED_BR_BG) {
+ layout = ((order - LIBFONTS_SUBPIXEL_ORDER_RR_GB) & 3) + LIBFONTS_SUBPIXEL_ORDER_CLASS_11_23;
+ if (order >= LIBFONTS_SUBPIXEL_ORDER_BALANCED_RR_GB)
+ layout += 4;
+ i = (order - LIBFONTS_SUBPIXEL_ORDER_RR_GB) / 4 % 6;
+
+ } else {
+ layout = LIBFONTS_SUBPIXEL_ORDER_CLASS_OTHER;
+ i = 0;
+ }
+
+ c1 = i / 2;
+ c2 = (i + 1 + i / 3) % 3;
+ c3 = 3 - c1 - c2;
+ if (cell1p)
+ *cell1p = c1;
+ if (cell2p)
+ *cell2p = c2;
+ if (cell3p)
+ *cell3p = c3;
+ return layout;
+}