2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <dali-toolkit/dali-toolkit.h>
24 void utc_distance_field_effect_startup(void)
26 test_return_value = TET_UNDEF;
29 void utc_distance_field_effect_cleanup(void)
31 test_return_value = TET_PASS;
36 // Create bitmap image
37 BitmapImage CreateDistanceField()
39 BitmapImage image = BitmapImage::New(256, 256, Pixel::RGBA8888);
40 BitmapImage distanceFieldImage = BitmapImage::New(256, 256, Pixel::L8);
42 PixelBuffer* pixbuf = image.GetBuffer();
44 for(size_t i=0; i<16; i++)
52 // GenerateDistanceFieldMap(distanceFieldImage.GetBuffer(), Size(256, 256), pixbuf, Size(256, 256), 8, 4);
54 return distanceFieldImage;
58 int UtcDaliDistanceFieldEffectUninitialized(void)
60 ToolkitTestApplication application;
62 Toolkit::DistanceFieldEffect effect;
66 // New() must be called to create a DistanceField effect or it wont be valid.
67 effect.SetShadow( true );
68 DALI_TEST_CHECK( false );
70 catch (Dali::DaliException& e)
72 // Tests that a negative test of an assertion succeeds
73 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
74 DALI_TEST_CHECK(!effect);
79 int UtcDaliDistanceFieldEffectPropertyNames(void)
81 ToolkitTestApplication application;
83 Toolkit::DistanceFieldEffect effect = Toolkit::DistanceFieldEffect::New();
85 // Check the names, this names are used in the shaders code,
86 // if they change the shader code has to be updated
87 DALI_TEST_EQUALS( effect.GetColorPropertyName(), "uColor", TEST_LOCATION );
88 DALI_TEST_EQUALS( effect.GetSmoothingPropertyName(), "uSmoothing", TEST_LOCATION );
91 DALI_TEST_EQUALS( effect.GetOutlineEnablePropertyName(), "uDoOutline", TEST_LOCATION );
92 DALI_TEST_EQUALS( effect.GetGlowEnablePropertyName(), "uDoGlow", TEST_LOCATION );
93 DALI_TEST_EQUALS( effect.GetShadowEnablePropertyName(), "uDoShadow", TEST_LOCATION );
95 DALI_TEST_EQUALS( effect.GetGlowBoundaryPropertyName(), "uGlowBoundary", TEST_LOCATION );
96 DALI_TEST_EQUALS( effect.GetGlowColorPropertyName(), "uGlowColor", TEST_LOCATION );
98 DALI_TEST_EQUALS( effect.GetOutlineColorPropertyName(), "uOutlineColor", TEST_LOCATION );
99 DALI_TEST_EQUALS( effect.GetOutlineSizePropertyName(), "uOutlineParams", TEST_LOCATION );
101 DALI_TEST_EQUALS( effect.GetShadowColorPropertyName(), "uShadowColor", TEST_LOCATION );
102 DALI_TEST_EQUALS( effect.GetShadowOffsetPropertyName(), "uShadowOffset", TEST_LOCATION );
107 int UtcDaliDistanceFieldEffectDefaultValues(void)
109 ToolkitTestApplication application;
111 Toolkit::DistanceFieldEffect effect = Toolkit::DistanceFieldEffect::New();
112 DALI_TEST_CHECK( effect );
114 BitmapImage image = CreateDistanceField();
116 ImageActor actor = ImageActor::New( image );
117 actor.SetSize( 100.0f, 100.0f );
118 actor.SetShaderEffect( effect );
119 Stage::GetCurrent().Add( actor );
121 application.SendNotification();
122 application.Render();
125 application.GetGlAbstraction().CheckUniformValue(
126 effect.GetOutlineEnablePropertyName().c_str(),
130 application.GetGlAbstraction().CheckUniformValue(
131 effect.GetGlowEnablePropertyName().c_str(),
135 application.GetGlAbstraction().CheckUniformValue(
136 effect.GetShadowEnablePropertyName().c_str(),
141 int UtcDaliDistanceFieldEffectCustomValues(void)
143 ToolkitTestApplication application;
145 Toolkit::DistanceFieldEffect effect = Toolkit::DistanceFieldEffect::New();
146 DALI_TEST_CHECK( effect );
148 BitmapImage image = CreateDistanceField();
150 ImageActor actor = ImageActor::New( image );
151 actor.SetSize( 100.0f, 100.0f );
153 effect.SetShadowColor(Color::YELLOW);
154 effect.SetGlowColor(Color::BLUE);
156 actor.SetShaderEffect( effect );
157 Stage::GetCurrent().Add( actor );
159 application.SendNotification();
160 application.Render();
162 // Gets converted to opengl viewport coordinates
164 application.GetGlAbstraction().CheckUniformValue(
165 effect.GetShadowColorPropertyName().c_str(),
169 application.GetGlAbstraction().CheckUniformValue(
170 effect.GetGlowColorPropertyName().c_str(),