1 /**
2 * @file lv_vglite_matrix.c
3 *
4 */
5
6 /**
7 * Copyright 2023 NXP
8 *
9 * SPDX-License-Identifier: MIT
10 */
11
12 /*********************
13 * INCLUDES
14 *********************/
15
16 #include "lv_vglite_matrix.h"
17
18 #if LV_USE_DRAW_VGLITE
19
20 /*********************
21 * DEFINES
22 *********************/
23
24 /**********************
25 * TYPEDEFS
26 **********************/
27
28 /**********************
29 * STATIC PROTOTYPES
30 **********************/
31
32 /**********************
33 * STATIC VARIABLES
34 **********************/
35
36 static vg_lite_matrix_t _vgmatrix;
37
38 /**********************
39 * MACROS
40 **********************/
41
42 /**********************
43 * GLOBAL FUNCTIONS
44 **********************/
45
vglite_get_matrix(void)46 vg_lite_matrix_t * vglite_get_matrix(void)
47 {
48 return &_vgmatrix;
49 }
50
vglite_set_translation_matrix(const lv_area_t * dest_area)51 void vglite_set_translation_matrix(const lv_area_t * dest_area)
52 {
53 vg_lite_identity(&_vgmatrix);
54 vg_lite_translate((vg_lite_float_t)dest_area->x1, (vg_lite_float_t)dest_area->y1, &_vgmatrix);
55 }
56
vglite_set_transformation_matrix(const lv_area_t * dest_area,const lv_draw_image_dsc_t * dsc)57 void vglite_set_transformation_matrix(const lv_area_t * dest_area, const lv_draw_image_dsc_t * dsc)
58 {
59 vglite_set_translation_matrix(dest_area);
60
61 bool has_scale = (dsc->scale_x != LV_SCALE_NONE || dsc->scale_y != LV_SCALE_NONE);
62 bool has_rotation = (dsc->rotation != 0);
63
64 if(has_scale || has_rotation) {
65 vg_lite_translate(dsc->pivot.x, dsc->pivot.y, &_vgmatrix);
66 if(has_rotation)
67 vg_lite_rotate(dsc->rotation / 10.0f, &_vgmatrix); /* angle is 1/10 degree */
68 if(has_scale) {
69 vg_lite_float_t scale_x = 1.0f * dsc->scale_x / LV_SCALE_NONE;
70 vg_lite_float_t scale_y = 1.0f * dsc->scale_y / LV_SCALE_NONE;
71 vg_lite_scale(scale_x, scale_y, &_vgmatrix);
72 }
73 vg_lite_translate(0.0f - dsc->pivot.x, 0.0f - dsc->pivot.y, &_vgmatrix);
74 }
75 }
76
77 /**********************
78 * STATIC FUNCTIONS
79 **********************/
80
81 #endif /*LV_USE_DRAW_VGLITE*/
82