2 * Copyright (c) 2014 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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
25 void utc_distance_field_effect_startup(void)
27 test_return_value = TET_UNDEF;
30 void utc_distance_field_effect_cleanup(void)
32 test_return_value = TET_PASS;
37 // Create buffer image
38 BufferImage CreateDistanceField()
40 BufferImage image = BufferImage::New(256, 256, Pixel::RGBA8888);
41 BufferImage distanceFieldImage = BufferImage::New(256, 256, Pixel::L8);
43 PixelBuffer* pixbuf = image.GetBuffer();
45 for(size_t i=0; i<16; i++)
53 // GenerateDistanceFieldMap(distanceFieldImage.GetBuffer(), Size(256, 256), pixbuf, Size(256, 256), 8, 4);
55 return distanceFieldImage;
59 int UtcDaliDistanceFieldEffectUninitialized(void)
61 ToolkitTestApplication application;
63 Toolkit::DistanceFieldEffect effect;
67 // New() must be called to create a DistanceField effect or it wont be valid.
68 effect.SetShadow( true );
69 DALI_TEST_CHECK( false );
71 catch (Dali::DaliException& e)
73 // Tests that a negative test of an assertion succeeds
74 DALI_TEST_PRINT_ASSERT( e );
75 DALI_TEST_CHECK(!effect);
80 int UtcDaliDistanceFieldEffectPropertyNames(void)
82 ToolkitTestApplication application;
84 Toolkit::DistanceFieldEffect effect = Toolkit::DistanceFieldEffect::New();
86 // Check the names, this names are used in the shaders code,
87 // if they change the shader code has to be updated
88 DALI_TEST_EQUALS( effect.GetColorPropertyName(), "uColor", TEST_LOCATION );
89 DALI_TEST_EQUALS( effect.GetSmoothingPropertyName(), "uSmoothing", TEST_LOCATION );
92 DALI_TEST_EQUALS( effect.GetOutlineEnablePropertyName(), "uDoOutline", TEST_LOCATION );
93 DALI_TEST_EQUALS( effect.GetGlowEnablePropertyName(), "uDoGlow", TEST_LOCATION );
94 DALI_TEST_EQUALS( effect.GetShadowEnablePropertyName(), "uDoShadow", TEST_LOCATION );
96 DALI_TEST_EQUALS( effect.GetGlowBoundaryPropertyName(), "uGlowBoundary", TEST_LOCATION );
97 DALI_TEST_EQUALS( effect.GetGlowColorPropertyName(), "uGlowColor", TEST_LOCATION );
99 DALI_TEST_EQUALS( effect.GetOutlineColorPropertyName(), "uOutlineColor", TEST_LOCATION );
100 DALI_TEST_EQUALS( effect.GetOutlineSizePropertyName(), "uOutlineParams", TEST_LOCATION );
102 DALI_TEST_EQUALS( effect.GetShadowColorPropertyName(), "uShadowColor", TEST_LOCATION );
103 DALI_TEST_EQUALS( effect.GetShadowOffsetPropertyName(), "uShadowOffset", TEST_LOCATION );
108 int UtcDaliDistanceFieldEffectDefaultValues(void)
110 ToolkitTestApplication application;
112 Toolkit::DistanceFieldEffect effect = Toolkit::DistanceFieldEffect::New();
113 DALI_TEST_CHECK( effect );
115 BufferImage image = CreateDistanceField();
117 ImageActor actor = ImageActor::New( image );
118 actor.SetSize( 100.0f, 100.0f );
119 actor.SetShaderEffect( effect );
120 Stage::GetCurrent().Add( actor );
122 application.SendNotification();
123 application.Render();
126 application.GetGlAbstraction().CheckUniformValue(
127 effect.GetOutlineEnablePropertyName().c_str(),
131 application.GetGlAbstraction().CheckUniformValue(
132 effect.GetGlowEnablePropertyName().c_str(),
136 application.GetGlAbstraction().CheckUniformValue(
137 effect.GetShadowEnablePropertyName().c_str(),
142 int UtcDaliDistanceFieldEffectCustomValues(void)
144 ToolkitTestApplication application;
146 Toolkit::DistanceFieldEffect effect = Toolkit::DistanceFieldEffect::New();
147 DALI_TEST_CHECK( effect );
149 BufferImage image = CreateDistanceField();
151 ImageActor actor = ImageActor::New( image );
152 actor.SetSize( 100.0f, 100.0f );
154 effect.SetShadowColor(Color::YELLOW);
155 effect.SetGlowColor(Color::BLUE);
157 actor.SetShaderEffect( effect );
158 Stage::GetCurrent().Add( actor );
160 application.SendNotification();
161 application.Render();
163 // Gets converted to opengl viewport coordinates
165 application.GetGlAbstraction().CheckUniformValue(
166 effect.GetShadowColorPropertyName().c_str(),
170 application.GetGlAbstraction().CheckUniformValue(
171 effect.GetGlowColorPropertyName().c_str(),