Merge "Shader Factory refactoring" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-actor-utils.h
1 #ifndef DALI_TEST_ACTOR_UTILS_H
2 #define DALI_TEST_ACTOR_UTILS_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/public-api/rendering/texture-set.h>
23 #include <dali/public-api/rendering/texture.h>
24 #include <set> // For std::multiset
25 #include <string>
26
27 namespace Dali
28 {
29 class Actor;
30 class Image;
31 class Texture;
32
33 /**
34  * @brief Creates a simple renderable-actor with solid colored quad.
35  * @return An actor with a renderer.
36  */
37 Actor CreateRenderableActor();
38
39 /**
40  * @brief Creates a renderable-actor with a texture.
41  * @param[in] texture Texture to set.
42  * @return An actor with a renderer.
43  */
44 Actor CreateRenderableActor(Texture texture);
45
46 /**
47  * @brief Creates a renderable-actor with a texture and custom shaders.
48  * @param[in] texture Texture to set.
49  * @param[in] vertexShader The vertex-shader.
50  * @param[in] fragmentShader The fragment-shader.
51  * @return An actor with a renderer.
52  */
53 Actor CreateRenderableActor(Texture texture, const std::string& vertexShader, const std::string& fragmentShader);
54
55 /**
56  * @brief Creates a renderable-actor with a texture and custom shaders.
57  * @param[in] textures TextureSet to set.
58  * @param[in] vertexShader The vertex-shader.
59  * @param[in] fragmentShader The fragment-shader.
60  * @return An actor with a renderer.
61  */
62 Actor CreateRenderableActor2(TextureSet textures, const std::string& vertexShader, const std::string& fragmentShader);
63
64 Texture    CreateTexture(TextureType::Type type, Pixel::Format format, int width, int height);
65 TextureSet CreateTextureSet(Pixel::Format format, int width, int height);
66
67 // Check dirtyRect is equal with expected multiset.
68 // Note that the order of damagedRect is not important
69 struct RectSorter
70 {
71   bool operator()(const Rect<int>& lhs, const Rect<int>& rhs) const
72   {
73     if(lhs.x != rhs.x)
74     {
75       return lhs.x < rhs.x;
76     }
77     if(lhs.y != rhs.y)
78     {
79       return lhs.y < rhs.y;
80     }
81     if(lhs.width != rhs.width)
82     {
83       return lhs.width < rhs.width;
84     }
85     return lhs.height < rhs.height;
86   }
87 };
88
89 void DirtyRectChecker(const std::vector<Rect<int>>& damagedRects, std::multiset<Rect<int>, RectSorter> expectedRectList, bool checkRectsExact, const char* testLocation);
90
91 } // namespace Dali
92
93 #endif // DALI_TEST_ACTOR_UTILS_H