Merge "Add BuildPickingRay to devel api" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / node-helper.h
1 #ifndef DALI_INTERNAL_SCENEGRAPH_NODE_HELPER_H
2 #define DALI_INTERNAL_SCENEGRAPH_NODE_HELPER_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 /*
21  * Defines the given value, and adds an enumeration that contains it's
22  * size.  The enumeration can be used by the wrapper templated types
23  * below during structure definition. ("offsetof" requires the
24  * structure to be completely defined before use, so cannot be
25  * utilized here).
26  */
27 #define BASE(_TYPE, _X)         \
28   _TYPE _X;                     \
29   enum                          \
30   {                             \
31     OFFSET_##_X = sizeof(_TYPE) \
32   };
33
34 /*
35  * Create a property template instance, passing in the previously
36  * stored element, which utilizes that element's OFFSET enumeration to
37  * compute the offset of the BASE element.
38  *
39  * It is expected that _TEMPLATE is a TransformManagerPropertyVector3
40  * which takes a TransformManagerProperty enumeration and an offset
41  * to the BASE TransformManagerData.
42  *
43  * It is assumed that successive elements are aligned, and that no padding
44  * is inserted by the compiler.
45  */
46 #define PROPERTY_WRAPPER(_BASE_ELEMENT, _TEMPLATE, _PROPERTY, _ELEMENT)      \
47   using _TEMPLATE##_ELEMENT = _TEMPLATE<_PROPERTY, OFFSET_##_BASE_ELEMENT>;  \
48   _TEMPLATE##_ELEMENT _ELEMENT;                                              \
49   enum                                                                       \
50   {                                                                          \
51     OFFSET_##_ELEMENT = sizeof(_TEMPLATE##_ELEMENT) + OFFSET_##_BASE_ELEMENT \
52   };
53
54 /*
55  * Create a template instance, passing in the previously stored
56  * element, utilizing that element's OFFSET enumeration to compute the offset
57  * of the BASE element.
58  *
59  * It is expected that _TEMPLATE is a TransformManagerPropertyNNNN template
60  * which takes an offset to the BASE TransformManagerData.
61  *
62  * It is assumed that successive elements are aligned, and that no padding
63  * is inserted by the compiler.
64  */
65 #define TEMPLATE_WRAPPER(_BASE_ELEMENT, _TEMPLATE, _ELEMENT)                 \
66   using _TEMPLATE##_ELEMENT = _TEMPLATE<OFFSET_##_BASE_ELEMENT>;             \
67   _TEMPLATE##_ELEMENT _ELEMENT;                                              \
68   enum                                                                       \
69   {                                                                          \
70     OFFSET_##_ELEMENT = sizeof(_TEMPLATE##_ELEMENT) + OFFSET_##_BASE_ELEMENT \
71   };
72
73 #endif // DALI_INTERNAL_SCENEGRAPH_NODE_HELPER_H