1 #ifndef DALI_TOOLKIT_NPATCH_HELPER_H
2 #define DALI_TOOLKIT_NPATCH_HELPER_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/math/uint-16-pair.h>
23 #include <dali/public-api/rendering/geometry.h>
24 #include <dali/devel-api/rendering/renderer-devel.h>
25 #include <memory> ///< for std::shared_ptr
28 #include <dali-toolkit/public-api/dali-toolkit-common.h>
29 #include <dali-toolkit/internal/visuals/npatch-data.h>
35 namespace NPatchHelper
38 * The list that includes stretch pixel ranges
40 using StretchRanges = Dali::Vector<Uint16Pair>;
43 * @brief Creates a Npatch Geometry object
45 * @param[in] gridSize The gridSize for creating a geometry
46 * @return The Geometry for NPatch
48 DALI_TOOLKIT_API Geometry CreateGridGeometry(Uint16Pair gridSize);
51 * @brief Creates a geometry with the border only for the grid size to be used by this visuals' shaders
52 * e.g. a 5x4 grid would create a geometry that would look like:
54 * ---------------------
57 * ---------------------
63 * ---------------------
66 * ---------------------
68 * @param[in] gridSize The grid size of the solid geometry to create
69 * @return Returns the created geometry for the grid size
71 DALI_TOOLKIT_API Geometry CreateBorderGeometry(Uint16Pair gridSize);
75 * @brief Registers a properties for Stretch Ranges
77 * @param[in,out] renderer The renderer for broken image
78 * @param[in] uniformName The name of the uniform
79 * @param[in] stretchPixels The stretchable pixels in the cropped image space
80 * @param[in] imageExtent The imageExtent
82 void RegisterStretchProperties(Renderer& renderer, const char* uniformName, const NPatchUtility::StretchRanges& stretchPixels, uint16_t imageExtent);
85 * @brief Apply a texture and uniforms
87 * @param[in,out] renderer The renderer for broken image
88 * @param[in] data The pointer of npatch-data
90 void ApplyTextureAndUniforms(Renderer& renderer, const std::shared_ptr<const Internal::NPatchData> data);
92 } // namespace NPatchUtility
94 } // namespace Toolkit
98 #endif // DALI_TOOLKIT_NPATCH_HELPER_H