aboutsummaryrefslogtreecommitdiffstats
path: root/libfonts_calculate_subpixel_order.c
blob: 6d269217e2fb653b0f18729bab7a52c4c8661b74 (plain) (blame)
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
/* See LICENSE file for copyright and license details. */
#include "libfonts.h"


enum libfonts_subpixel_order
libfonts_calculate_subpixel_order(enum libfonts_subpixel_order unrotated, enum libfonts_orientation rotation)
{
	int rot;

	switch (rotation) {
	case LIBFONTS_ORIENTATION_UNKNOWN:
	default:
		switch (unrotated) {
		case LIBFONTS_SUBPIXEL_ORDER_UNKNOWN:
		case LIBFONTS_SUBPIXEL_ORDER_NONRGB:
		case LIBFONTS_SUBPIXEL_ORDER_NONLINEAR:
		case LIBFONTS_SUBPIXEL_ORDER_OTHER:
			return unrotated;
		default:
			return LIBFONTS_SUBPIXEL_ORDER_UNKNOWN;
		}
		break;

	case LIBFONTS_ORIENTATION_0_DEGREES_CLOCKWISE:
		return unrotated;

	case LIBFONTS_ORIENTATION_90_DEGREES_CLOCKWISE:
		rot = 1;
		break;

	case LIBFONTS_ORIENTATION_180_DEGREES_CLOCKWISE:
		rot = 2;
		break;

	case LIBFONTS_ORIENTATION_270_DEGREES_CLOCKWISE:
		rot = 3;
		break;

	case LIBFONTS_ORIENTATION_OTHER:
		switch (unrotated) {
		case LIBFONTS_SUBPIXEL_ORDER_UNKNOWN:
		case LIBFONTS_SUBPIXEL_ORDER_NONRGB:
		case LIBFONTS_SUBPIXEL_ORDER_NONLINEAR:
			return unrotated;
		default:
			return LIBFONTS_SUBPIXEL_ORDER_NONLINEAR;
		}
		break;
	}

	switch (unrotated) {
	case LIBFONTS_SUBPIXEL_ORDER_UNKNOWN:
	case LIBFONTS_SUBPIXEL_ORDER_NONRGB:
	case LIBFONTS_SUBPIXEL_ORDER_NONLINEAR:
	case LIBFONTS_SUBPIXEL_ORDER_OTHER:
		return unrotated;
	default:
		return ((unrotated + rot) & 3) + (unrotated & ~3);
	}
}