2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <toolkit-event-thread-callback.h>
24 #include <toolkit-text-utils.h>
26 #include <dali-toolkit/internal/visuals/image-visual-shader-feature-builder.h>
28 #include <../dali-toolkit/dali-toolkit-test-utils/dummy-control.h>
29 #include <dummy-visual.h>
32 using namespace Toolkit;
34 int UtcImageVisualShaderFeatureBuilderSetGetProperty01(void)
36 ToolkitTestApplication application;
37 tet_infoline("Register an ImageVisual and and perform an Action on Visual directly");
38 auto featureBuilder = Dali::Toolkit::Internal::ImageVisualShaderFeatureBuilder()
39 .EnableTextureAtlas(Dali::Toolkit::Internal::ImageVisualShaderFeature::TextureAtlas::ENABLED)
40 .ApplyDefaultTextureWrapMode(true);
42 std::string vertexPrefixList;
43 std::string fragmentPrefixList;
44 featureBuilder.GetVertexShaderPrefixList(vertexPrefixList);
45 featureBuilder.GetFragmentShaderPrefixList(fragmentPrefixList);
47 DALI_TEST_EQUALS(vertexPrefixList, std::string(""), TEST_LOCATION);
48 DALI_TEST_EQUALS(fragmentPrefixList, std::string("#define ATLAS_DEFAULT_WARP\n"), TEST_LOCATION);
50 featureBuilder = featureBuilder.ApplyDefaultTextureWrapMode(false);
52 vertexPrefixList.clear();
53 fragmentPrefixList.clear();
54 featureBuilder.GetVertexShaderPrefixList(vertexPrefixList);
55 featureBuilder.GetFragmentShaderPrefixList(fragmentPrefixList);
57 DALI_TEST_EQUALS(vertexPrefixList, std::string(""), TEST_LOCATION);
58 DALI_TEST_EQUALS(fragmentPrefixList, std::string("#define ATLAS_CUSTOM_WARP\n"), TEST_LOCATION);
62 int UtcImageVisualShaderFeatureBuilderSetGetProperty02(void)
64 ToolkitTestApplication application;
65 tet_infoline("Register an ImageVisual and and perform an Action on Visual directly");
66 auto featureBuilder = Dali::Toolkit::Internal::ImageVisualShaderFeatureBuilder()
67 .EnableRoundedCorner(true)
68 .EnableBorderline(true)
69 .EnableAlphaMaskingOnRendering(true)
70 .EnableYuvToRgb(true, false);
72 std::string vertexPrefixList;
73 std::string fragmentPrefixList;
74 featureBuilder.GetVertexShaderPrefixList(vertexPrefixList);
75 featureBuilder.GetFragmentShaderPrefixList(fragmentPrefixList);
77 std::string vertexPrefixListResult;
78 vertexPrefixListResult += "#define IS_REQUIRED_ROUNDED_CORNER\n";
79 vertexPrefixListResult += "#define IS_REQUIRED_BORDERLINE\n";
80 vertexPrefixListResult += "#define IS_REQUIRED_ALPHA_MASKING\n";
82 std::string fragmentPrefixListResult;
83 fragmentPrefixListResult += "#define IS_REQUIRED_ROUNDED_CORNER\n";
84 fragmentPrefixListResult += "#define IS_REQUIRED_BORDERLINE\n";
85 fragmentPrefixListResult += "#define IS_REQUIRED_ALPHA_MASKING\n";
87 DALI_TEST_EQUALS(vertexPrefixList, vertexPrefixListResult, TEST_LOCATION);
88 DALI_TEST_EQUALS(fragmentPrefixList, fragmentPrefixListResult, TEST_LOCATION);
90 featureBuilder = featureBuilder.EnableAlphaMaskingOnRendering(false);
92 vertexPrefixList.clear();
93 fragmentPrefixList.clear();
94 featureBuilder.GetVertexShaderPrefixList(vertexPrefixList);
95 featureBuilder.GetFragmentShaderPrefixList(fragmentPrefixList);
97 vertexPrefixListResult.clear();
98 vertexPrefixListResult += "#define IS_REQUIRED_ROUNDED_CORNER\n";
99 vertexPrefixListResult += "#define IS_REQUIRED_BORDERLINE\n";
101 fragmentPrefixListResult.clear();
102 fragmentPrefixListResult += "#define IS_REQUIRED_ROUNDED_CORNER\n";
103 fragmentPrefixListResult += "#define IS_REQUIRED_BORDERLINE\n";
104 fragmentPrefixListResult += "#define IS_REQUIRED_YUV_TO_RGB\n";
106 DALI_TEST_EQUALS(vertexPrefixList, vertexPrefixListResult, TEST_LOCATION);
107 DALI_TEST_EQUALS(fragmentPrefixList, fragmentPrefixListResult, TEST_LOCATION);
109 featureBuilder = featureBuilder.EnableYuvToRgb(true, true);
111 vertexPrefixList.clear();
112 fragmentPrefixList.clear();
113 featureBuilder.GetVertexShaderPrefixList(vertexPrefixList);
114 featureBuilder.GetFragmentShaderPrefixList(fragmentPrefixList);
116 fragmentPrefixListResult.clear();
117 fragmentPrefixListResult += "#define IS_REQUIRED_ROUNDED_CORNER\n";
118 fragmentPrefixListResult += "#define IS_REQUIRED_BORDERLINE\n";
119 fragmentPrefixListResult += "#define IS_REQUIRED_UNIFIED_YUV_AND_RGB\n";
121 DALI_TEST_EQUALS(vertexPrefixList, vertexPrefixListResult, TEST_LOCATION);
122 DALI_TEST_EQUALS(fragmentPrefixList, fragmentPrefixListResult, TEST_LOCATION);