Arm-2D
2D Image Processing Library for Cortex-M Processors
arm_2d_helper.h
1
/*
2
* Copyright (C) 2022 Arm Limited or its affiliates. All rights reserved.
3
*
4
* SPDX-License-Identifier: Apache-2.0
5
*
6
* Licensed under the Apache License, Version 2.0 (the License); you may
7
* not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
10
* www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
14
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*/
18
19
/* ----------------------------------------------------------------------
20
* Project: Arm-2D Library
21
* Title: #include "arm_2d_helper.h"
22
* Description: Public header file for the all helper services
23
*
24
* $Date: 17. June 2022
25
* $Revision: V.1.0.1
26
*
27
* Target Processor: Cortex-M cores
28
* -------------------------------------------------------------------- */
29
30
#ifndef __ARM_2D_HELPER_H__
31
#define __ARM_2D_HELPER_H__
32
33
/*============================ INCLUDES ======================================*/
34
#include "arm_2d.h"
35
#include "./arm_2d_helper_pfb.h"
36
#include "./arm_2d_helper_scene.h"
37
38
#ifdef __cplusplus
39
extern
"C"
{
40
#endif
41
42
#if defined(__clang__)
43
# pragma clang diagnostic push
44
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
45
#endif
46
47
48
/*!
49
* \addtogroup gHelper 7 Helper Services
50
* @{
51
*/
52
/*============================ MACROS ========================================*/
53
/*============================ MACROFIED FUNCTIONS ===========================*/
54
55
#define __declare_tile(__NAME) \
56
extern const arm_2d_tile_t __NAME;
57
#define declare_tile(__NAME) __declare_tile(__NAME)
58
59
#define __implement_tile(__NAME, __WIDTH, __HEIGHT, __TYPE, ...) \
60
ARM_NOINIT static __TYPE \
61
__NAME##Buffer[(__WIDTH) * (__HEIGHT)]; \
62
const arm_2d_tile_t __NAME = { \
63
.tRegion = { \
64
.tSize = {(__WIDTH), (__HEIGHT)}, \
65
}, \
66
.tInfo.bIsRoot = true, \
67
.pchBuffer = (uint8_t *)__NAME##Buffer, \
68
__VA_ARGS__ \
69
};
70
71
#define implement_tile(__NAME, __WIDTH, __HEIGHT, __TYPE, ...) \
72
__implement_tile(__NAME, __WIDTH, __HEIGHT, __TYPE, ##__VA_ARGS__)
73
74
#define get_tile_buffer_pixel_count(__NAME) \
75
(uint32_t)( (__NAME.tRegion.tSize.iWidth) \
76
* (__NAME.tRegion.tSize.iHeight))
77
78
#define get_tile_buffer_size(__NAME, __TYPE) \
79
(get_2d_layer_buffer_pixel_count(__NAME) * sizeof(TYPE))
80
81
82
83
#define __arm_2d_align_centre2(__region, __size) \
84
for (arm_2d_region_t __centre_region = { \
85
.tSize = (__size), \
86
.tLocation = { \
87
.iX = ((__region).tSize.iWidth - (__size).iWidth) >> 1,\
88
.iY = ((__region).tSize.iHeight - (__size).iHeight)>> 1,\
89
}, \
90
}, \
91
*ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr) = NULL; \
92
ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr)++ == NULL; \
93
)
94
95
#define __arm_2d_align_centre3(__region, __width, __height) \
96
for (arm_2d_region_t __centre_region = { \
97
.tSize = { \
98
.iWidth = (__width), \
99
.iHeight = (__height), \
100
}, \
101
.tLocation = { \
102
.iX = ((__region).tSize.iWidth - (__width)) >> 1, \
103
.iY = ((__region).tSize.iHeight - (__height))>> 1, \
104
}, \
105
}, \
106
*ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr) = NULL; \
107
ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr)++ == NULL; \
108
arm_2d_op_wait_async(NULL) \
109
)
110
111
#define arm_2d_align_centre(...) \
112
ARM_CONNECT2( __arm_2d_align_centre, \
113
__ARM_VA_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__)
114
115
/*============================ TYPES =========================================*/
116
/*============================ GLOBAL VARIABLES ==============================*/
117
/*============================ LOCAL VARIABLES ===============================*/
118
/*============================ PROTOTYPES ====================================*/
119
120
/*! @} */
121
122
#if defined(__clang__)
123
# pragma clang diagnostic pop
124
#endif
125
126
#ifdef __cplusplus
127
}
128
#endif
129
130
#endif
Helper
Include
arm_2d_helper.h