c9ef2d0a52adf8dfacb36393bc94a9029018b468
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-graphics-reflection.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "test-graphics-reflection.h"
18 #include <dali/public-api/object/property-map.h>
19
20 namespace Dali
21 {
22 TestGraphicsReflection::TestGraphicsReflection(TestGlAbstraction& gl, Property::Array& vfs)
23 : mGl(gl)
24 {
25   for(Property::Array::SizeType i = 0; i < vfs.Count(); ++i)
26   {
27     Property::Map* vertexFormat = vfs[i].GetMap();
28     if(vertexFormat)
29     {
30       for(Property::Map::SizeType j = 0; j < vertexFormat->Count(); ++j)
31       {
32         auto key = vertexFormat->GetKeyAt(j);
33         if(key.type == Property::Key::STRING)
34         {
35           mAttributes.push_back(key.stringKey);
36         }
37       }
38     }
39   }
40 }
41
42 uint32_t TestGraphicsReflection::GetVertexAttributeLocation(const std::string& name) const
43 {
44   // Automatically assign locations to named attributes when requested
45   auto iter = std::find(mAttributes.begin(), mAttributes.end(), name);
46   if(iter != mAttributes.end())
47   {
48     return iter - mAttributes.begin();
49   }
50   else
51   {
52     uint32_t location = mAttributes.size();
53     mAttributes.push_back(name);
54     return location;
55   }
56   return 0u;
57 }
58
59 Dali::Graphics::VertexInputAttributeFormat TestGraphicsReflection::GetVertexAttributeFormat(uint32_t location) const
60 {
61   return Dali::Graphics::VertexInputAttributeFormat{};
62 }
63
64 std::string TestGraphicsReflection::GetVertexAttributeName(uint32_t location) const
65 {
66   return 0u;
67 }
68
69 std::vector<uint32_t> TestGraphicsReflection::GetVertexAttributeLocations() const
70 {
71   std::vector<uint32_t> locs;
72   for(uint32_t i = 0; i < mAttributes.size(); ++i)
73   {
74     locs.push_back(i);
75   }
76   return locs;
77 }
78
79 uint32_t TestGraphicsReflection::GetUniformBlockCount() const
80 {
81   return 0u;
82 }
83
84 uint32_t TestGraphicsReflection::GetUniformBlockBinding(uint32_t index) const
85 {
86   return 0u;
87 }
88
89 uint32_t TestGraphicsReflection::GetUniformBlockSize(uint32_t index) const
90 {
91   return 0u;
92 }
93
94 bool TestGraphicsReflection::GetUniformBlock(uint32_t index, Dali::Graphics::UniformBlockInfo& out) const
95 {
96   return true;
97 }
98
99 std::vector<uint32_t> TestGraphicsReflection::GetUniformBlockLocations() const
100 {
101   return std::vector<uint32_t>{};
102 }
103
104 std::string TestGraphicsReflection::GetUniformBlockName(uint32_t blockIndex) const
105 {
106   return std::string{};
107 }
108
109 uint32_t TestGraphicsReflection::GetUniformBlockMemberCount(uint32_t blockIndex) const
110 {
111   return 0u;
112 }
113
114 std::string TestGraphicsReflection::GetUniformBlockMemberName(uint32_t blockIndex, uint32_t memberLocation) const
115 {
116   return std::string{};
117 }
118
119 uint32_t TestGraphicsReflection::GetUniformBlockMemberOffset(uint32_t blockIndex, uint32_t memberLocation) const
120 {
121   return 0u;
122 }
123
124 bool TestGraphicsReflection::GetNamedUniform(const std::string& name, Dali::Graphics::UniformInfo& out) const
125 {
126   return true;
127 }
128
129 std::vector<Dali::Graphics::UniformInfo> TestGraphicsReflection::GetSamplers() const
130 {
131   return std::vector<Dali::Graphics::UniformInfo>{};
132 }
133
134 Graphics::ShaderLanguage TestGraphicsReflection::GetLanguage() const
135 {
136   return Graphics::ShaderLanguage::GLSL_3_1;
137 }
138
139 } // namespace Dali