[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / utility / npatch-helper.h
1 #ifndef DALI_TOOLKIT_NPATCH_HELPER_H
2 #define DALI_TOOLKIT_NPATCH_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 // EXTERNAL INCLUDES
22 #include <dali/devel-api/rendering/renderer-devel.h>
23 #include <dali/public-api/math/uint-16-pair.h>
24 #include <dali/public-api/rendering/geometry.h>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/devel-api/utility/npatch-utilities.h>
28 #include <dali-toolkit/public-api/dali-toolkit-common.h>
29
30 namespace Dali
31 {
32 namespace Toolkit
33 {
34 namespace Internal
35 {
36 class NPatchData;
37 }
38
39 namespace NPatchHelper
40 {
41 /**
42  * @brief Creates a Npatch Geometry object
43  *
44  * @param[in] gridSize The gridSize for creating a geometry
45  * @return The Geometry for NPatch
46  */
47 DALI_TOOLKIT_API Geometry CreateGridGeometry(Uint16Pair gridSize);
48
49 /**
50  * @brief Creates a geometry with the border only for the grid size to be used by this visuals' shaders
51  * e.g. a 5x4 grid would create a geometry that would look like:
52  *
53  *   ---------------------
54  *   |  /|  /|  /|  /|  /|
55  *   |/  |/  |/  |/  |/  |
56  *   ---------------------
57  *   |  /|           |  /|
58  *   |/  |           |/  |
59  *   -----           -----
60  *   |  /|           |  /|
61  *   |/  |           |/  |
62  *   ---------------------
63  *   |  /|  /|  /|  /|  /|
64  *   |/  |/  |/  |/  |/  |
65  *   ---------------------
66  *
67  * @param[in] gridSize The grid size of the solid geometry to create
68  * @return Returns the created geometry for the grid size
69  */
70 DALI_TOOLKIT_API Geometry CreateBorderGeometry(Uint16Pair gridSize);
71
72 /**
73  * @brief Registers a properties for Stretch Ranges
74  *
75  * @param[in,out] renderer The renderer for broken image
76  * @param[in] uniformName The name of the uniform
77  * @param[in] stretchPixels The stretchable pixels in the cropped image space
78  * @param[in] imageExtent The imageExtent
79  */
80 void RegisterStretchProperties(Renderer& renderer, const char* uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent);
81
82 /**
83  * @brief Apply a texture and uniforms
84  *
85  * @param[in,out] renderer The renderer for broken image
86  * @param[in] data The pointer of npatch-data
87  */
88 void ApplyTextureAndUniforms(Renderer& renderer, const Internal::NPatchData* data);
89
90 } // namespace NPatchHelper
91
92 } // namespace Toolkit
93
94 } // namespace Dali
95
96 #endif // DALI_TOOLKIT_NPATCH_HELPER_H