2 * Copyright (c) 2018 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.
19 #include <dali/devel-api/actors/actor-devel.h>
20 #include <dali/devel-api/rendering/renderer-devel.h>
22 #include <dali/public-api/dali-core.h>
23 #include <dali/devel-api/images/texture-set-image.h>
28 #include <dali-test-suite-utils.h>
29 #include <test-trace-call-stack.h>
30 #include <mesh-builder.h>
34 namespace // unnamed namespace
37 const BlendFactor::Type DEFAULT_BLEND_FACTOR_SRC_RGB( BlendFactor::SRC_ALPHA );
38 const BlendFactor::Type DEFAULT_BLEND_FACTOR_DEST_RGB( BlendFactor::ONE_MINUS_SRC_ALPHA );
39 const BlendFactor::Type DEFAULT_BLEND_FACTOR_SRC_ALPHA( BlendFactor::ONE );
40 const BlendFactor::Type DEFAULT_BLEND_FACTOR_DEST_ALPHA( BlendFactor::ONE_MINUS_SRC_ALPHA );
42 const BlendEquation::Type DEFAULT_BLEND_EQUATION_RGB( BlendEquation::ADD );
43 const BlendEquation::Type DEFAULT_BLEND_EQUATION_ALPHA( BlendEquation::ADD );
46 * @brief Get GL stencil test enumeration value as a string.
47 * @return The string representation of the value of GL_STENCIL_TEST
49 std::string GetStencilTestString(void)
51 std::stringstream stream;
52 stream << GL_STENCIL_TEST;
57 * @brief Get GL depth test enumeration value as a string.
58 * @return The string representation of the value of GL_DEPTH_TEST
60 std::string GetDepthTestString(void)
62 std::stringstream stream;
63 stream << GL_DEPTH_TEST;
67 void ResetDebugAndFlush( TestApplication& application, TraceCallStack& glEnableDisableStack, TraceCallStack& glStencilFunctionStack )
69 glEnableDisableStack.Reset();
70 glStencilFunctionStack.Reset();
71 application.SendNotification();
75 void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
80 } // unnamed namespace
82 void renderer_test_startup(void)
84 test_return_value = TET_UNDEF;
87 void renderer_test_cleanup(void)
89 test_return_value = TET_PASS;
93 int UtcDaliRendererNew01(void)
95 TestApplication application;
97 Geometry geometry = CreateQuadGeometry();
98 Shader shader = CreateShader();
99 Renderer renderer = Renderer::New(geometry, shader);
101 DALI_TEST_EQUALS( (bool)renderer, true, TEST_LOCATION );
105 int UtcDaliRendererNew02(void)
107 TestApplication application;
109 DALI_TEST_EQUALS( (bool)renderer, false, TEST_LOCATION );
113 int UtcDaliRendererCopyConstructor(void)
115 TestApplication application;
117 Geometry geometry = CreateQuadGeometry();
118 Shader shader = CreateShader();
119 Renderer renderer = Renderer::New(geometry, shader);
121 Renderer rendererCopy( renderer );
122 DALI_TEST_EQUALS( (bool)rendererCopy, true, TEST_LOCATION );
127 int UtcDaliRendererAssignmentOperator(void)
129 TestApplication application;
131 Geometry geometry = CreateQuadGeometry();
132 Shader shader = CreateShader();
133 Renderer renderer = Renderer::New(geometry, shader);
136 DALI_TEST_EQUALS( (bool)renderer2, false, TEST_LOCATION );
138 renderer2 = renderer;
139 DALI_TEST_EQUALS( (bool)renderer2, true, TEST_LOCATION );
143 int UtcDaliRendererDownCast01(void)
145 TestApplication application;
147 Geometry geometry = CreateQuadGeometry();
148 Shader shader = CreateShader();
149 Renderer renderer = Renderer::New(geometry, shader);
151 BaseHandle handle(renderer);
152 Renderer renderer2 = Renderer::DownCast(handle);
153 DALI_TEST_EQUALS( (bool)renderer2, true, TEST_LOCATION );
157 int UtcDaliRendererDownCast02(void)
159 TestApplication application;
161 Handle handle = Handle::New(); // Create a custom object
162 Renderer renderer = Renderer::DownCast(handle);
163 DALI_TEST_EQUALS( (bool)renderer, false, TEST_LOCATION );
167 int UtcDaliRendererSetGetGeometry(void)
169 TestApplication application;
170 tet_infoline( "Test SetGeometry, GetGeometry" );
172 Geometry geometry1 = CreateQuadGeometry();
173 Geometry geometry2 = CreateQuadGeometry();
175 Shader shader = CreateShader();
176 Renderer renderer = Renderer::New(geometry1, shader);
177 Actor actor = Actor::New();
178 actor.AddRenderer(renderer);
179 actor.SetSize(400, 400);
180 Stage::GetCurrent().Add(actor);
182 application.SendNotification();
183 application.Render(0);
184 DALI_TEST_EQUALS( renderer.GetGeometry(), geometry1, TEST_LOCATION );
186 // Set geometry2 to the renderer
187 renderer.SetGeometry( geometry2 );
189 application.SendNotification();
190 application.Render(0);
191 DALI_TEST_EQUALS( renderer.GetGeometry(), geometry2, TEST_LOCATION );
196 int UtcDaliRendererSetGetShader(void)
198 TestApplication application;
199 tet_infoline( "Test SetShader, GetShader" );
201 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
202 glAbstraction.EnableCullFaceCallTrace(true);
204 Shader shader1 = CreateShader();
205 shader1.RegisterProperty( "uFadeColor", Color::RED );
207 Shader shader2 = CreateShader();
208 shader2.RegisterProperty( "uFadeColor", Color::GREEN );
210 Geometry geometry = CreateQuadGeometry();
211 Renderer renderer = Renderer::New(geometry, shader1);
212 Actor actor = Actor::New();
213 actor.AddRenderer(renderer);
214 actor.SetSize(400, 400);
215 Stage::GetCurrent().Add(actor);
217 TestGlAbstraction& gl = application.GetGlAbstraction();
218 application.SendNotification();
219 application.Render(0);
221 // Expect that the first shaders's fade color property is accessed
222 Vector4 actualValue(Vector4::ZERO);
223 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
224 DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
226 DALI_TEST_EQUALS( renderer.GetShader(), shader1, TEST_LOCATION );
228 // set the second shader to the renderer
229 renderer.SetShader( shader2 );
231 application.SendNotification();
232 application.Render(0);
234 // Expect that the second shader's fade color property is accessed
235 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
236 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
238 DALI_TEST_EQUALS( renderer.GetShader(), shader2, TEST_LOCATION );
243 int UtcDaliRendererSetGetDepthIndex(void)
245 TestApplication application;
247 tet_infoline("Test SetDepthIndex, GetDepthIndex");
249 Shader shader = CreateShader();
250 Geometry geometry = CreateQuadGeometry();
251 Renderer renderer = Renderer::New(geometry, shader);
252 Actor actor = Actor::New();
253 actor.AddRenderer(renderer);
254 actor.SetSize(400, 400);
255 Stage::GetCurrent().Add(actor);
257 application.SendNotification();
258 application.Render(0);
259 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION );
261 renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
263 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
264 DALI_TEST_EQUALS( renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION );
266 application.SendNotification();
267 application.Render(0);
268 DALI_TEST_EQUALS( renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
270 renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 10 );
272 DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION );
273 DALI_TEST_EQUALS( renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
275 application.SendNotification();
276 application.Render(0);
277 DALI_TEST_EQUALS( renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION );
282 int UtcDaliRendererSetGetFaceCullingMode(void)
284 TestApplication application;
286 tet_infoline("Test SetFaceCullingMode(cullingMode)");
287 Geometry geometry = CreateQuadGeometry();
288 Shader shader = CreateShader();
289 Renderer renderer = Renderer::New( geometry, shader );
291 Actor actor = Actor::New();
292 actor.AddRenderer(renderer);
293 actor.SetSize(400, 400);
294 Stage::GetCurrent().Add(actor);
296 // By default, none of the faces should be culled
297 unsigned int cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
298 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::NONE );
300 TestGlAbstraction& gl = application.GetGlAbstraction();
301 TraceCallStack& cullFaceStack = gl.GetCullFaceTrace();
302 gl.EnableCullFaceCallTrace(true);
305 cullFaceStack.Reset();
306 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT_AND_BACK );
307 application.SendNotification();
308 application.Render();
310 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
312 std::ostringstream cullModeString;
313 cullModeString << GL_FRONT_AND_BACK;
315 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
316 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
317 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::FRONT_AND_BACK );
321 cullFaceStack.Reset();
322 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
323 application.SendNotification();
324 application.Render();
326 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
328 std::ostringstream cullModeString;
329 cullModeString << GL_BACK;
331 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
332 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
333 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::BACK );
337 cullFaceStack.Reset();
338 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::FRONT );
339 application.SendNotification();
340 application.Render();
342 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 1, TEST_LOCATION );
344 std::ostringstream cullModeString;
345 cullModeString << GL_FRONT;
347 DALI_TEST_CHECK( cullFaceStack.FindMethodAndParams( "CullFace", cullModeString.str() ) );
348 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
349 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::FRONT );
353 cullFaceStack.Reset();
354 renderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE );
355 application.SendNotification();
356 application.Render();
358 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 0, TEST_LOCATION );
359 cullFace = renderer.GetProperty<int>( Renderer::Property::FACE_CULLING_MODE );
360 DALI_TEST_CHECK( static_cast< FaceCullingMode::Type >( cullFace ) == FaceCullingMode::NONE );
366 int UtcDaliRendererBlendOptions01(void)
368 TestApplication application;
370 tet_infoline("Test BLEND_FACTOR properties ");
372 Geometry geometry = CreateQuadGeometry();
373 Shader shader = CreateShader();
374 Renderer renderer = Renderer::New( geometry, shader );
376 Actor actor = Actor::New();
377 // set a transparent actor color so that blending is enabled
378 actor.SetOpacity( 0.5f );
379 actor.AddRenderer(renderer);
380 actor.SetSize(400, 400);
381 Stage::GetCurrent().Add(actor);
383 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE_MINUS_SRC_COLOR );
384 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::SRC_ALPHA_SATURATE );
385 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_COLOR );
386 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::SRC_ALPHA_SATURATE );
388 // Test that Set was successful:
389 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
390 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
391 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
392 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
394 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION );
395 DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION );
396 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION );
397 DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION );
399 application.SendNotification();
400 application.Render();
402 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
404 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
405 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
406 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
407 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
412 int UtcDaliRendererBlendOptions02(void)
414 TestApplication application;
416 tet_infoline("Test BLEND_FACTOR properties ");
418 Geometry geometry = CreateQuadGeometry();
419 Shader shader = CreateShader();
420 Renderer renderer = Renderer::New( geometry, shader );
422 Actor actor = Actor::New();
423 actor.SetOpacity( 0.5f ); // enable blending
424 actor.AddRenderer(renderer);
425 actor.SetSize(400, 400);
426 Stage::GetCurrent().Add(actor);
428 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::CONSTANT_COLOR );
429 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_CONSTANT_COLOR );
430 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::CONSTANT_ALPHA );
431 renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_CONSTANT_ALPHA );
433 // Test that Set was successful:
435 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
436 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
437 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
438 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
440 DALI_TEST_EQUALS( (int)BlendFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION );
441 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION );
442 DALI_TEST_EQUALS( (int)BlendFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION );
443 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION );
446 application.SendNotification();
447 application.Render();
449 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
450 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
451 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
452 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
453 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
458 int UtcDaliRendererBlendOptions03(void)
460 TestApplication application;
462 tet_infoline("Test GetBlendEquation() defaults ");
464 Geometry geometry = CreateQuadGeometry();
465 Shader shader = CreateShader();
466 Renderer renderer = Renderer::New( geometry, shader );
468 Actor actor = Actor::New();
469 actor.AddRenderer(renderer);
470 actor.SetSize(400, 400);
471 Stage::GetCurrent().Add(actor);
473 // Test the defaults as documented in blending.h
474 int equationRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_RGB );
475 int equationAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_ALPHA );
477 DALI_TEST_EQUALS( (int)BlendEquation::ADD, equationRgb, TEST_LOCATION );
478 DALI_TEST_EQUALS( (int)BlendEquation::ADD, equationAlpha, TEST_LOCATION );
483 int UtcDaliRendererBlendOptions04(void)
485 TestApplication application;
487 tet_infoline("Test SetBlendEquation() ");
489 Geometry geometry = CreateQuadGeometry();
490 Shader shader = CreateShader();
491 Renderer renderer = Renderer::New( geometry, shader );
493 Actor actor = Actor::New();
494 actor.SetOpacity( 0.1f );
495 actor.AddRenderer(renderer);
496 actor.SetSize(400, 400);
497 Stage::GetCurrent().Add(actor);
499 // Test the single blending equation setting
501 renderer.SetProperty( Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT );
502 int equationRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_RGB );
503 DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION );
506 renderer.SetProperty( Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::REVERSE_SUBTRACT );
507 renderer.SetProperty( Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::REVERSE_SUBTRACT );
509 // Test that Set was successful
511 int equationRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_RGB );
512 int equationAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_EQUATION_ALPHA );
513 DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION );
514 DALI_TEST_EQUALS( (int)BlendEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION );
517 // Render & check GL commands
518 application.SendNotification();
519 application.Render();
521 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
522 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION );
523 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION );
528 int UtcDaliRendererSetBlendMode01(void)
530 TestApplication application;
532 tet_infoline("Test setting the blend mode to on with an opaque color renders with blending enabled");
534 Geometry geometry = CreateQuadGeometry();
535 Shader shader = CreateShader();
536 Renderer renderer = Renderer::New( geometry, shader );
538 Actor actor = Actor::New();
539 actor.SetOpacity( 0.98f );
540 actor.AddRenderer(renderer);
541 actor.SetSize(400, 400);
542 Stage::GetCurrent().Add(actor);
544 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON);
546 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
547 glAbstraction.EnableEnableDisableCallTrace(true);
549 application.SendNotification();
550 application.Render();
552 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
553 std::ostringstream blendStr;
554 blendStr << GL_BLEND;
555 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
560 int UtcDaliRendererSetBlendMode01b(void)
562 TestApplication application;
564 tet_infoline("Test setting the blend mode to on with an transparent color renders with blending enabled");
566 Geometry geometry = CreateQuadGeometry();
567 Shader shader = CreateShader();
568 Renderer renderer = Renderer::New( geometry, shader );
570 Actor actor = Actor::New();
571 actor.SetOpacity( 0.0f );
572 actor.AddRenderer(renderer);
573 actor.SetSize(400, 400);
574 Stage::GetCurrent().Add(actor);
576 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON);
578 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
579 glAbstraction.EnableEnableDisableCallTrace(true);
580 glAbstraction.EnableDrawCallTrace( true );
582 application.SendNotification();
583 application.Render();
585 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
586 std::ostringstream blendStr;
587 blendStr << GL_BLEND;
588 DALI_TEST_CHECK( !glEnableStack.FindMethod( "Enable" ) );
590 DALI_TEST_CHECK( !glAbstraction.GetDrawTrace().FindMethod( "DrawElements" ) );
595 int UtcDaliRendererSetBlendMode02(void)
597 TestApplication application;
599 tet_infoline("Test setting the blend mode to off with a transparent color renders with blending disabled (and not enabled)");
601 Geometry geometry = CreateQuadGeometry();
602 Shader shader = CreateShader();
603 Renderer renderer = Renderer::New( geometry, shader );
605 Actor actor = Actor::New();
606 actor.SetOpacity( 0.15f );
607 actor.AddRenderer(renderer);
608 actor.SetSize(400, 400);
609 Stage::GetCurrent().Add(actor);
611 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF);
613 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
614 glAbstraction.EnableEnableDisableCallTrace(true);
616 application.SendNotification();
617 application.Render();
619 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
620 std::ostringstream blendStr;
621 blendStr << GL_BLEND;
622 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
627 int UtcDaliRendererSetBlendMode03(void)
629 TestApplication application;
631 tet_infoline("Test setting the blend mode to auto with a transparent color renders with blending enabled");
633 Geometry geometry = CreateQuadGeometry();
634 Shader shader = CreateShader();
635 Renderer renderer = Renderer::New( geometry, shader );
637 Actor actor = Actor::New();
638 actor.SetOpacity( 0.75f );
639 actor.AddRenderer(renderer);
640 actor.SetSize(400, 400);
641 Stage::GetCurrent().Add(actor);
643 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
645 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
646 glAbstraction.EnableEnableDisableCallTrace(true);
648 application.SendNotification();
649 application.Render();
651 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
652 std::ostringstream blendStr;
653 blendStr << GL_BLEND;
654 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
659 int UtcDaliRendererSetBlendMode04(void)
661 TestApplication application;
663 tet_infoline("Test setting the blend mode to auto with an opaque color renders with blending disabled");
665 Geometry geometry = CreateQuadGeometry();
666 Shader shader = CreateShader();
667 Renderer renderer = Renderer::New( geometry, shader );
669 Actor actor = Actor::New();
670 actor.AddRenderer(renderer);
671 actor.SetSize(400, 400);
672 Stage::GetCurrent().Add(actor);
674 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
676 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
677 glAbstraction.EnableEnableDisableCallTrace(true);
679 application.SendNotification();
680 application.Render();
682 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
683 std::ostringstream blendStr;
684 blendStr << GL_BLEND;
685 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
690 int UtcDaliRendererSetBlendMode04b(void)
692 TestApplication application;
694 tet_infoline("Test setting the blend mode to auto with a transparent actor color renders with blending enabled");
696 Geometry geometry = CreateQuadGeometry();
697 Shader shader = CreateShader();
698 Renderer renderer = Renderer::New( geometry, shader );
700 Actor actor = Actor::New();
701 actor.AddRenderer(renderer);
702 actor.SetSize(400, 400);
703 actor.SetColor( Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
704 Stage::GetCurrent().Add(actor);
706 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
708 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
709 glAbstraction.EnableEnableDisableCallTrace(true);
711 application.SendNotification();
712 application.Render();
714 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
715 std::ostringstream blendStr;
716 blendStr << GL_BLEND;
717 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
722 int UtcDaliRendererSetBlendMode04c(void)
724 TestApplication application;
726 tet_infoline("Test setting the blend mode to auto with an opaque opaque actor color renders with blending disabled");
728 Geometry geometry = CreateQuadGeometry();
729 Shader shader = CreateShader();
730 Renderer renderer = Renderer::New( geometry, shader );
732 Actor actor = Actor::New();
733 actor.AddRenderer(renderer);
734 actor.SetSize(400, 400);
735 actor.SetColor( Color::MAGENTA );
736 Stage::GetCurrent().Add(actor);
738 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
740 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
741 glAbstraction.EnableEnableDisableCallTrace(true);
743 application.SendNotification();
744 application.Render();
746 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
747 std::ostringstream blendStr;
748 blendStr << GL_BLEND;
749 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
754 int UtcDaliRendererSetBlendMode05(void)
756 TestApplication application;
758 tet_infoline("Test setting the blend mode to auto with an opaque color and an image with an alpha channel renders with blending enabled");
760 Geometry geometry = CreateQuadGeometry();
761 BufferImage image = BufferImage::New( 40, 40, Pixel::RGBA8888 );
763 Shader shader = CreateShader();
764 TextureSet textureSet = CreateTextureSet( image );
765 Renderer renderer = Renderer::New( geometry, shader );
766 renderer.SetTextures( textureSet );
768 Actor actor = Actor::New();
769 actor.AddRenderer(renderer);
770 actor.SetSize(400, 400);
771 Stage::GetCurrent().Add(actor);
773 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
775 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
776 glAbstraction.EnableEnableDisableCallTrace(true);
778 application.SendNotification();
779 application.Render();
781 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
782 std::ostringstream blendStr;
783 blendStr << GL_BLEND;
784 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
789 int UtcDaliRendererSetBlendMode06(void)
791 TestApplication application;
792 tet_infoline("Test setting the blend mode to auto with an opaque color and an image without an alpha channel and a shader with the hint OUTPUT_IS_TRANSPARENT renders with blending enabled");
794 Geometry geometry = CreateQuadGeometry();
795 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::Hint::OUTPUT_IS_TRANSPARENT );
797 Renderer renderer = Renderer::New( geometry, shader );
799 Actor actor = Actor::New();
800 actor.AddRenderer(renderer);
801 actor.SetSize(400, 400);
802 Stage::GetCurrent().Add(actor);
804 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
806 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
807 glAbstraction.EnableEnableDisableCallTrace(true);
809 application.SendNotification();
810 application.Render();
812 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
813 std::ostringstream blendStr;
814 blendStr << GL_BLEND;
815 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
820 int UtcDaliRendererSetBlendMode07(void)
822 TestApplication application;
823 tet_infoline("Test setting the blend mode to auto with an opaque color and an image without an alpha channel and a shader with the hint OUTPUT_IS_OPAQUE renders with blending disabled");
825 Geometry geometry = CreateQuadGeometry();
826 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
828 BufferImage image = BufferImage::New( 50, 50, Pixel::RGB888 );
829 TextureSet textureSet = CreateTextureSet( image );
830 Renderer renderer = Renderer::New( geometry, shader );
831 renderer.SetTextures( textureSet );
833 Actor actor = Actor::New();
834 actor.AddRenderer(renderer);
835 actor.SetSize(400, 400);
836 Stage::GetCurrent().Add(actor);
838 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO);
840 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
841 glAbstraction.EnableEnableDisableCallTrace(true);
843 application.SendNotification();
844 application.Render();
846 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
847 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", "GL_BLEND" ) );
852 int UtcDaliRendererGetBlendMode(void)
854 TestApplication application;
856 tet_infoline("Test GetBlendMode()");
858 Geometry geometry = CreateQuadGeometry();
859 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
860 Renderer renderer = Renderer::New( geometry, shader );
863 unsigned int mode = renderer.GetProperty<int>( Renderer::Property::BLEND_MODE );
864 DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::AUTO, TEST_LOCATION );
867 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
868 mode = renderer.GetProperty<int>( Renderer::Property::BLEND_MODE );
869 DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::ON, TEST_LOCATION );
872 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF );
873 mode = renderer.GetProperty<int>( Renderer::Property::BLEND_MODE );
874 DALI_TEST_EQUALS( static_cast< BlendMode::Type >( mode ), BlendMode::OFF, TEST_LOCATION );
879 int UtcDaliRendererSetBlendColor(void)
881 TestApplication application;
883 tet_infoline("Test SetBlendColor(color)");
885 Geometry geometry = CreateQuadGeometry();
886 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
887 TextureSet textureSet = TextureSet::New();
888 BufferImage image = BufferImage::New( 50, 50, Pixel::RGBA8888 );
889 TextureSetImage( textureSet, 0u, image );
890 Renderer renderer = Renderer::New( geometry, shader );
891 renderer.SetTextures( textureSet );
893 Actor actor = Actor::New();
894 actor.AddRenderer(renderer);
895 actor.SetSize(400, 400);
896 Stage::GetCurrent().Add(actor);
898 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
900 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::TRANSPARENT );
902 application.SendNotification();
903 application.Render();
905 DALI_TEST_EQUALS( renderer.GetProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION );
906 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION );
907 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION );
909 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA );
911 DALI_TEST_EQUALS( renderer.GetProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION );
912 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION );
914 application.SendNotification();
915 application.Render();
917 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION );
918 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION );
920 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
921 renderer.SetProperty( Renderer::Property::BLEND_COLOR, color );
922 application.SendNotification();
923 application.Render();
924 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), color, TEST_LOCATION );
929 int UtcDaliRendererGetBlendColor(void)
931 TestApplication application;
933 tet_infoline("Test GetBlendColor()");
935 Geometry geometry = CreateQuadGeometry();
936 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
937 Renderer renderer = Renderer::New( geometry, shader );
939 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::TRANSPARENT, TEST_LOCATION );
941 renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA );
942 application.SendNotification();
943 application.Render();
944 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), Color::MAGENTA, TEST_LOCATION );
946 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
947 renderer.SetProperty( Renderer::Property::BLEND_COLOR, color );
948 application.SendNotification();
949 application.Render();
950 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>( Renderer::Property::BLEND_COLOR ), color, TEST_LOCATION );
955 int UtcDaliRendererPreMultipledAlpha(void)
957 TestApplication application;
959 tet_infoline("Test BLEND_PRE_MULTIPLIED_ALPHA property");
961 Geometry geometry = CreateQuadGeometry();
962 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
963 Renderer renderer = Renderer::New( geometry, shader );
965 Actor actor = Actor::New();
966 actor.AddRenderer(renderer);
967 actor.SetSize(400, 400);
968 actor.SetColor( Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
969 Stage::GetCurrent().Add(actor);
971 Property::Value value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
972 bool preMultipliedAlpha;
973 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
974 DALI_TEST_CHECK( !preMultipliedAlpha );
976 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
977 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
978 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
979 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
981 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_SRC_RGB, srcFactorRgb, TEST_LOCATION );
982 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_DEST_RGB, destFactorRgb, TEST_LOCATION );
983 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_SRC_ALPHA, srcFactorAlpha, TEST_LOCATION );
984 DALI_TEST_EQUALS( (int)DEFAULT_BLEND_FACTOR_DEST_ALPHA, destFactorAlpha, TEST_LOCATION );
986 application.SendNotification();
987 application.Render();
989 Vector4 actualValue(Vector4::ZERO);
990 TestGlAbstraction& gl = application.GetGlAbstraction();
991 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
992 DALI_TEST_EQUALS( actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION );
994 // Enable pre-multiplied alpha
995 renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true );
997 application.SendNotification();
998 application.Render();
1000 value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
1001 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
1002 DALI_TEST_CHECK( preMultipliedAlpha );
1004 value = renderer.GetCurrentProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
1005 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
1006 DALI_TEST_CHECK( preMultipliedAlpha );
1008 srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
1009 destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
1010 srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
1011 destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
1013 DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorRgb, TEST_LOCATION );
1014 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION );
1015 DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION );
1016 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION );
1018 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
1019 DALI_TEST_EQUALS( actualValue, Vector4(0.5f, 0.0f, 0.5f, 0.5f), TEST_LOCATION );
1021 // Disable pre-multiplied alpha again
1022 renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, false );
1024 application.SendNotification();
1025 application.Render();
1027 value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
1028 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
1029 DALI_TEST_CHECK( !preMultipliedAlpha );
1031 value = renderer.GetCurrentProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
1032 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
1033 DALI_TEST_CHECK( !preMultipliedAlpha );
1035 srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
1036 destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
1037 srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
1038 destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
1040 DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA, srcFactorRgb, TEST_LOCATION );
1041 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION );
1042 DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION );
1043 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION );
1045 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
1046 DALI_TEST_EQUALS( actualValue, Vector4( 1.0f, 0.0f, 1.0f, 0.5f ), TEST_LOCATION );
1051 int UtcDaliRendererConstraint01(void)
1053 TestApplication application;
1055 tet_infoline("Test that a non-uniform renderer property can be constrained");
1057 Shader shader = Shader::New("VertexSource", "FragmentSource");
1058 Geometry geometry = CreateQuadGeometry();
1059 Renderer renderer = Renderer::New( geometry, shader );
1061 Actor actor = Actor::New();
1062 actor.AddRenderer(renderer);
1063 actor.SetSize(400, 400);
1064 Stage::GetCurrent().Add(actor);
1066 Vector4 initialColor = Color::WHITE;
1067 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1069 application.SendNotification();
1070 application.Render(0);
1071 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
1074 Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
1076 application.SendNotification();
1077 application.Render(0);
1079 // Expect no blue component in either buffer - yellow
1080 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::YELLOW, TEST_LOCATION );
1081 application.Render(0);
1082 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::YELLOW, TEST_LOCATION );
1084 renderer.RemoveConstraints();
1085 renderer.SetProperty(colorIndex, Color::WHITE );
1086 application.SendNotification();
1087 application.Render(0);
1088 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::WHITE, TEST_LOCATION );
1093 int UtcDaliRendererConstraint02(void)
1095 TestApplication application;
1097 tet_infoline("Test that a uniform map renderer property can be constrained");
1099 Shader shader = Shader::New("VertexSource", "FragmentSource");
1100 Geometry geometry = CreateQuadGeometry();
1101 Renderer renderer = Renderer::New( geometry, shader );
1103 Actor actor = Actor::New();
1104 actor.AddRenderer(renderer);
1105 actor.SetSize(400, 400);
1106 Stage::GetCurrent().Add(actor);
1107 application.SendNotification();
1108 application.Render(0);
1110 Vector4 initialColor = Color::WHITE;
1111 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1113 TestGlAbstraction& gl = application.GetGlAbstraction();
1115 application.SendNotification();
1116 application.Render(0);
1118 Vector4 actualValue(Vector4::ZERO);
1119 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1120 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1123 Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
1125 application.SendNotification();
1126 application.Render(0);
1128 // Expect no blue component in either buffer - yellow
1129 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1130 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
1132 application.Render(0);
1133 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1134 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
1136 renderer.RemoveConstraints();
1137 renderer.SetProperty(colorIndex, Color::WHITE );
1138 application.SendNotification();
1139 application.Render(0);
1141 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1142 DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
1147 int UtcDaliRendererAnimatedProperty01(void)
1149 TestApplication application;
1151 tet_infoline("Test that a non-uniform renderer property can be animated");
1153 Shader shader = Shader::New("VertexSource", "FragmentSource");
1154 Geometry geometry = CreateQuadGeometry();
1155 Renderer renderer = Renderer::New( geometry, shader );
1157 Actor actor = Actor::New();
1158 actor.AddRenderer(renderer);
1159 actor.SetSize(400, 400);
1160 Stage::GetCurrent().Add(actor);
1162 Vector4 initialColor = Color::WHITE;
1163 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1165 application.SendNotification();
1166 application.Render(0);
1167 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
1169 Animation animation = Animation::New(1.0f);
1170 KeyFrames keyFrames = KeyFrames::New();
1171 keyFrames.Add(0.0f, initialColor);
1172 keyFrames.Add(1.0f, Color::TRANSPARENT);
1173 animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
1176 application.SendNotification();
1177 application.Render(500);
1179 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::WHITE * 0.5f, TEST_LOCATION );
1181 application.Render(500);
1183 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::TRANSPARENT, TEST_LOCATION );
1188 int UtcDaliRendererAnimatedProperty02(void)
1190 TestApplication application;
1192 tet_infoline("Test that a uniform map renderer property can be animated");
1194 Shader shader = Shader::New("VertexSource", "FragmentSource");
1195 Geometry geometry = CreateQuadGeometry();
1196 Renderer renderer = Renderer::New( geometry, shader );
1198 Actor actor = Actor::New();
1199 actor.AddRenderer(renderer);
1200 actor.SetSize(400, 400);
1201 Stage::GetCurrent().Add(actor);
1202 application.SendNotification();
1203 application.Render(0);
1205 Vector4 initialColor = Color::WHITE;
1206 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1208 TestGlAbstraction& gl = application.GetGlAbstraction();
1210 application.SendNotification();
1211 application.Render(0);
1213 Vector4 actualValue(Vector4::ZERO);
1214 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1215 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1217 Animation animation = Animation::New(1.0f);
1218 KeyFrames keyFrames = KeyFrames::New();
1219 keyFrames.Add(0.0f, initialColor);
1220 keyFrames.Add(1.0f, Color::TRANSPARENT);
1221 animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
1224 application.SendNotification();
1225 application.Render(500);
1227 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1228 DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
1230 application.Render(500);
1231 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1232 DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
1237 int UtcDaliRendererUniformMapPrecendence01(void)
1239 TestApplication application;
1241 tet_infoline("Test the uniform map precedence is applied properly");
1243 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1245 Shader shader = Shader::New("VertexSource", "FragmentSource");
1246 TextureSet textureSet = CreateTextureSet( image );
1248 Geometry geometry = CreateQuadGeometry();
1249 Renderer renderer = Renderer::New( geometry, shader );
1250 renderer.SetTextures( textureSet );
1252 Actor actor = Actor::New();
1253 actor.AddRenderer(renderer);
1254 actor.SetSize(400, 400);
1255 Stage::GetCurrent().Add(actor);
1256 application.SendNotification();
1257 application.Render(0);
1259 renderer.RegisterProperty( "uFadeColor", Color::RED );
1260 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1261 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
1263 TestGlAbstraction& gl = application.GetGlAbstraction();
1265 application.SendNotification();
1266 application.Render(0);
1268 // Expect that the actor's fade color property is accessed
1269 Vector4 actualValue(Vector4::ZERO);
1270 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1271 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1273 // Animate shader's fade color property. Should be no change to uniform
1274 Animation animation = Animation::New(1.0f);
1275 KeyFrames keyFrames = KeyFrames::New();
1276 keyFrames.Add(0.0f, Color::WHITE);
1277 keyFrames.Add(1.0f, Color::TRANSPARENT);
1278 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1281 application.SendNotification();
1282 application.Render(500);
1284 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1285 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1287 application.Render(500);
1288 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1289 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1294 int UtcDaliRendererUniformMapPrecendence02(void)
1296 TestApplication application;
1298 tet_infoline("Test the uniform map precedence is applied properly");
1300 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1302 Shader shader = Shader::New("VertexSource", "FragmentSource");
1303 TextureSet textureSet = CreateTextureSet( image );
1305 Geometry geometry = CreateQuadGeometry();
1306 Renderer renderer = Renderer::New( geometry, shader );
1307 renderer.SetTextures( textureSet );
1309 Actor actor = Actor::New();
1310 actor.AddRenderer(renderer);
1311 actor.SetSize(400, 400);
1312 Stage::GetCurrent().Add(actor);
1313 application.SendNotification();
1314 application.Render(0);
1316 // Don't add property / uniform map to renderer
1317 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1318 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::BLUE );
1320 TestGlAbstraction& gl = application.GetGlAbstraction();
1322 application.SendNotification();
1323 application.Render(0);
1325 // Expect that the actor's fade color property is accessed
1326 Vector4 actualValue(Vector4::ZERO);
1327 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1328 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1330 // Animate texture set's fade color property. Should be no change to uniform
1331 Animation animation = Animation::New(1.0f);
1332 KeyFrames keyFrames = KeyFrames::New();
1333 keyFrames.Add(0.0f, Color::WHITE);
1334 keyFrames.Add(1.0f, Color::TRANSPARENT);
1335 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1338 application.SendNotification();
1339 application.Render(500);
1341 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1342 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1344 application.Render(500);
1345 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1346 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1352 int UtcDaliRendererUniformMapPrecendence03(void)
1354 TestApplication application;
1356 tet_infoline("Test the uniform map precedence is applied properly");
1358 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1360 Shader shader = Shader::New("VertexSource", "FragmentSource");
1361 TextureSet textureSet = CreateTextureSet( image );
1363 Geometry geometry = CreateQuadGeometry();
1364 Renderer renderer = Renderer::New( geometry, shader );
1365 renderer.SetTextures( textureSet );
1367 Actor actor = Actor::New();
1368 actor.AddRenderer(renderer);
1369 actor.SetSize(400, 400);
1370 Stage::GetCurrent().Add(actor);
1371 application.SendNotification();
1372 application.Render(0);
1374 // Don't add property / uniform map to renderer or actor
1375 shader.RegisterProperty( "uFadeColor", Color::BLACK );
1377 TestGlAbstraction& gl = application.GetGlAbstraction();
1379 application.SendNotification();
1380 application.Render(0);
1382 // Expect that the shader's fade color property is accessed
1383 Vector4 actualValue(Vector4::ZERO);
1384 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1385 DALI_TEST_EQUALS( actualValue, Color::BLACK, TEST_LOCATION );
1390 int UtcDaliRendererUniformMapMultipleUniforms01(void)
1392 TestApplication application;
1394 tet_infoline("Test the uniform maps are collected from all objects (same type)");
1396 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1398 Shader shader = Shader::New("VertexSource", "FragmentSource");
1399 TextureSet textureSet = CreateTextureSet( image );
1401 Geometry geometry = CreateQuadGeometry();
1402 Renderer renderer = Renderer::New( geometry, shader );
1403 renderer.SetTextures( textureSet );
1405 Actor actor = Actor::New();
1406 actor.AddRenderer(renderer);
1407 actor.SetSize(400, 400);
1408 Stage::GetCurrent().Add(actor);
1409 application.SendNotification();
1410 application.Render(0);
1412 renderer.RegisterProperty( "uUniform1", Color::RED );
1413 actor.RegisterProperty( "uUniform2", Color::GREEN );
1414 shader.RegisterProperty( "uUniform3", Color::MAGENTA );
1416 TestGlAbstraction& gl = application.GetGlAbstraction();
1418 application.SendNotification();
1419 application.Render(0);
1421 // Expect that each of the object's uniforms are set
1422 Vector4 uniform1Value(Vector4::ZERO);
1423 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform1", uniform1Value ) );
1424 DALI_TEST_EQUALS( uniform1Value, Color::RED, TEST_LOCATION );
1426 Vector4 uniform2Value(Vector4::ZERO);
1427 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform2", uniform2Value ) );
1428 DALI_TEST_EQUALS( uniform2Value, Color::GREEN, TEST_LOCATION );
1430 Vector4 uniform3Value(Vector4::ZERO);
1431 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform3", uniform3Value ) );
1432 DALI_TEST_EQUALS( uniform3Value, Color::MAGENTA, TEST_LOCATION );
1437 int UtcDaliRendererUniformMapMultipleUniforms02(void)
1439 TestApplication application;
1441 tet_infoline("Test the uniform maps are collected from all objects (different types)");
1443 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1445 Shader shader = Shader::New("VertexSource", "FragmentSource");
1446 TextureSet textureSet = CreateTextureSet( image );
1448 Geometry geometry = CreateQuadGeometry();
1449 Renderer renderer = Renderer::New( geometry, shader );
1450 renderer.SetTextures( textureSet );
1452 Actor actor = Actor::New();
1453 actor.AddRenderer(renderer);
1454 actor.SetSize(400, 400);
1455 Stage::GetCurrent().Add(actor);
1456 application.SendNotification();
1457 application.Render(0);
1459 Property::Value value1(Color::RED);
1460 renderer.RegisterProperty( "uFadeColor", value1 );
1462 Property::Value value2(1.0f);
1463 actor.RegisterProperty( "uFadeProgress", value2 );
1465 Property::Value value3(Matrix3::IDENTITY);
1466 shader.RegisterProperty( "uANormalMatrix", value3 );
1468 TestGlAbstraction& gl = application.GetGlAbstraction();
1470 application.SendNotification();
1471 application.Render(0);
1473 // Expect that each of the object's uniforms are set
1474 Vector4 uniform1Value(Vector4::ZERO);
1475 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", uniform1Value ) );
1476 DALI_TEST_EQUALS( uniform1Value, value1.Get<Vector4>(), TEST_LOCATION );
1478 float uniform2Value(0.0f);
1479 DALI_TEST_CHECK( gl.GetUniformValue<float>( "uFadeProgress", uniform2Value ) );
1480 DALI_TEST_EQUALS( uniform2Value, value2.Get<float>(), TEST_LOCATION );
1482 Matrix3 uniform3Value;
1483 DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uANormalMatrix", uniform3Value ) );
1484 DALI_TEST_EQUALS( uniform3Value, value3.Get<Matrix3>(), TEST_LOCATION );
1490 Renderer CreateRenderer( Actor actor, Geometry geometry, Shader shader, int depthIndex )
1492 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1493 TextureSet textureSet0 = CreateTextureSet( image0 );
1494 Renderer renderer0 = Renderer::New( geometry, shader );
1495 renderer0.SetTextures( textureSet0 );
1496 renderer0.SetProperty( Renderer::Property::DEPTH_INDEX, depthIndex );
1497 actor.AddRenderer(renderer0);
1502 Actor CreateActor( Actor parent, int siblingOrder, const char* location )
1504 Actor actor = Actor::New();
1505 actor.SetAnchorPoint(AnchorPoint::CENTER);
1506 actor.SetParentOrigin(AnchorPoint::CENTER);
1507 actor.SetPosition(0.0f,0.0f);
1508 actor.SetSize(100, 100);
1510 actor.SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, siblingOrder );
1511 DALI_TEST_EQUALS( actor.GetProperty<int>( Dali::DevelActor::Property::SIBLING_ORDER), siblingOrder, TEST_INNER_LOCATION(location) );
1516 int UtcDaliRendererRenderOrder2DLayer(void)
1518 TestApplication application;
1519 tet_infoline("Test the rendering order in a 2D layer is correct");
1521 Shader shader = Shader::New("VertexSource", "FragmentSource");
1522 Geometry geometry = CreateQuadGeometry();
1524 Actor root = Stage::GetCurrent().GetRootLayer();
1526 Actor actor0 = CreateActor( root, 0, TEST_LOCATION );
1527 Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 0 );
1529 Actor actor1 = CreateActor( root, 0, TEST_LOCATION );
1530 Renderer renderer1 = CreateRenderer( actor1, geometry, shader, 0 );
1532 Actor actor2 = CreateActor( root, 0, TEST_LOCATION );
1533 Renderer renderer2 = CreateRenderer( actor2, geometry, shader, 0 );
1535 Actor actor3 = CreateActor( root, 0, TEST_LOCATION );
1536 Renderer renderer3 = CreateRenderer( actor3, geometry, shader, 0 );
1538 application.SendNotification();
1539 application.Render(0);
1542 * Create the following hierarchy:
1555 * Expected rendering order : actor2 - actor1 - actor0 - actor3
1560 application.SendNotification();
1561 application.Render(0);
1563 TestGlAbstraction& gl = application.GetGlAbstraction();
1564 gl.EnableTextureCallTrace(true);
1565 application.SendNotification();
1566 application.Render(0);
1568 int textureBindIndex[4];
1569 for( unsigned int i(0); i<4; ++i )
1571 std::stringstream params;
1572 params << GL_TEXTURE_2D<<", "<<i+1;
1573 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1576 //Check that actor1 has been rendered after actor2
1577 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[2], TEST_LOCATION );
1579 //Check that actor0 has been rendered after actor1
1580 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1582 //Check that actor3 has been rendered after actor0
1583 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1588 int UtcDaliRendererRenderOrder2DLayerMultipleRenderers(void)
1590 TestApplication application;
1591 tet_infoline("Test the rendering order in a 2D layer is correct using multiple renderers per actor");
1594 * Creates the following hierarchy:
1596 * actor0------------------------>actor1
1600 * renderer0 renderer1 renderer2 renderer3 renderer4 renderer5
1602 * renderer0 has depth index 2
1603 * renderer1 has depth index 0
1604 * renderer2 has depth index 1
1606 * renderer3 has depth index 1
1607 * renderer4 has depth index 0
1608 * renderer5 has depth index -1
1610 * Expected rendering order: renderer1 - renderer2 - renderer0 - renderer5 - renderer4 - renderer3
1613 Shader shader = Shader::New("VertexSource", "FragmentSource");
1614 Geometry geometry = CreateQuadGeometry();
1616 Actor root = Stage::GetCurrent().GetRootLayer();
1618 Actor actor0 = CreateActor( root, 0, TEST_LOCATION );
1619 Actor actor1 = CreateActor( actor0, 0, TEST_LOCATION );
1620 Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 2 );
1621 Renderer renderer1 = CreateRenderer( actor0, geometry, shader, 0 );
1622 Renderer renderer2 = CreateRenderer( actor0, geometry, shader, 1 );
1623 Renderer renderer3 = CreateRenderer( actor1, geometry, shader, 1 );
1624 Renderer renderer4 = CreateRenderer( actor1, geometry, shader, 0 );
1625 Renderer renderer5 = CreateRenderer( actor1, geometry, shader, -1 );
1627 application.SendNotification();
1628 application.Render(0);
1630 TestGlAbstraction& gl = application.GetGlAbstraction();
1631 gl.EnableTextureCallTrace(true);
1632 application.SendNotification();
1633 application.Render(0);
1635 int textureBindIndex[6];
1636 for( unsigned int i(0); i<6; ++i )
1638 std::stringstream params;
1639 params << GL_TEXTURE_2D<<", "<<i+1;
1640 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1643 //Check that renderer3 has been rendered after renderer4
1644 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[4], TEST_LOCATION );
1646 //Check that renderer0 has been rendered after renderer2
1647 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[5], TEST_LOCATION );
1649 //Check that renderer5 has been rendered after renderer2
1650 DALI_TEST_GREATER( textureBindIndex[5], textureBindIndex[0], TEST_LOCATION );
1652 //Check that renderer0 has been rendered after renderer2
1653 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[2], TEST_LOCATION );
1655 //Check that renderer2 has been rendered after renderer1
1656 DALI_TEST_GREATER( textureBindIndex[2], textureBindIndex[1], TEST_LOCATION );
1662 int UtcDaliRendererRenderOrder2DLayerSiblingOrder(void)
1664 TestApplication application;
1665 tet_infoline("Test the rendering order in a 2D layer is correct using sibling order");
1668 * Creates the following hierarchy:
1676 * actor0 (SIBLING_ORDER:1) actor1 (SIBLING_ORDER:0)
1680 * renderer0 renderer1 actor2 renderer2 renderer3 renderer4
1681 * DI:2 DI:0 | DI:0 DI:1 DI:2
1686 * actor0 has sibling order 1
1687 * actor1 has sibling order 0
1688 * actor2 has sibling order 0
1690 * renderer0 has depth index 2
1691 * renderer1 has depth index 0
1693 * renderer2 has depth index 0
1694 * renderer3 has depth index 1
1695 * renderer4 has depth index 2
1697 * renderer5 has depth index -1
1699 * Expected rendering order: renderer2 - renderer3 - renderer4 - renderer1 - renderer0 - renderer5
1702 Shader shader = Shader::New("VertexSource", "FragmentSource");
1703 Geometry geometry = CreateQuadGeometry();
1704 Actor root = Stage::GetCurrent().GetRootLayer();
1705 Actor actor0 = CreateActor( root, 1, TEST_LOCATION );
1706 Actor actor1 = CreateActor( root, 0, TEST_LOCATION );
1707 Actor actor2 = CreateActor( actor0, 0, TEST_LOCATION );
1709 Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 2 );
1710 Renderer renderer1 = CreateRenderer( actor0, geometry, shader, 0 );
1711 Renderer renderer2 = CreateRenderer( actor1, geometry, shader, 0 );
1712 Renderer renderer3 = CreateRenderer( actor1, geometry, shader, 1 );
1713 Renderer renderer4 = CreateRenderer( actor1, geometry, shader, 2 );
1714 Renderer renderer5 = CreateRenderer( actor2, geometry, shader, -1 );
1716 application.SendNotification();
1717 application.Render();
1719 TestGlAbstraction& gl = application.GetGlAbstraction();
1720 gl.EnableTextureCallTrace(true);
1721 application.SendNotification();
1722 application.Render(0);
1724 int textureBindIndex[6];
1725 for( unsigned int i(0); i<6; ++i )
1727 std::stringstream params;
1728 params << GL_TEXTURE_2D<<", "<<i+1;
1729 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1732 DALI_TEST_EQUALS( textureBindIndex[2], 0, TEST_LOCATION );
1733 DALI_TEST_EQUALS( textureBindIndex[3], 1, TEST_LOCATION );
1734 DALI_TEST_EQUALS( textureBindIndex[4], 2, TEST_LOCATION );
1735 DALI_TEST_EQUALS( textureBindIndex[1], 3, TEST_LOCATION );
1736 DALI_TEST_EQUALS( textureBindIndex[0], 4, TEST_LOCATION );
1737 DALI_TEST_EQUALS( textureBindIndex[5], 5, TEST_LOCATION );
1739 // Change sibling order of actor1
1740 // New Expected rendering order: renderer1 - renderer0 - renderer 5 - renderer2 - renderer3 - renderer4
1741 actor1.SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, 2 );
1743 gl.GetTextureTrace().Reset();
1744 application.SendNotification();
1745 application.Render(0);
1747 for( unsigned int i(0); i<6; ++i )
1749 std::stringstream params;
1750 params << GL_TEXTURE_2D<<", "<<i+1;
1751 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1754 DALI_TEST_EQUALS( textureBindIndex[1], 0, TEST_LOCATION );
1755 DALI_TEST_EQUALS( textureBindIndex[0], 1, TEST_LOCATION );
1756 DALI_TEST_EQUALS( textureBindIndex[5], 2, TEST_LOCATION );
1757 DALI_TEST_EQUALS( textureBindIndex[2], 3, TEST_LOCATION );
1758 DALI_TEST_EQUALS( textureBindIndex[3], 4, TEST_LOCATION );
1759 DALI_TEST_EQUALS( textureBindIndex[4], 5, TEST_LOCATION );
1764 int UtcDaliRendererRenderOrder2DLayerOverlay(void)
1766 TestApplication application;
1767 tet_infoline("Test the rendering order in a 2D layer is correct for overlays");
1769 Shader shader = Shader::New("VertexSource", "FragmentSource");
1770 Geometry geometry = CreateQuadGeometry();
1771 Actor root = Stage::GetCurrent().GetRootLayer();
1774 * Create the following hierarchy:
1781 * (Overlay) (Regular actor)
1791 * Expected rendering order : actor2 - actor4 - actor1 - actor0 - actor3
1794 Actor actor0 = CreateActor( root, 0, TEST_LOCATION );
1795 actor0.SetDrawMode( DrawMode::OVERLAY_2D );
1796 Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 0 );
1798 Actor actor1 = CreateActor( root, 0, TEST_LOCATION );
1799 actor1.SetDrawMode( DrawMode::OVERLAY_2D );
1800 Renderer renderer1 = CreateRenderer( actor1, geometry, shader, 0 );
1802 Actor actor2 = CreateActor( root, 0, TEST_LOCATION );
1803 Renderer renderer2 = CreateRenderer( actor2, geometry, shader, 0 );
1805 Actor actor3 = CreateActor( root, 0, TEST_LOCATION );
1806 actor3.SetDrawMode( DrawMode::OVERLAY_2D );
1807 Renderer renderer3 = CreateRenderer( actor3, geometry, shader, 0 );
1809 Actor actor4 = CreateActor( root, 0, TEST_LOCATION );
1810 Renderer renderer4 = CreateRenderer( actor4, geometry, shader, 0 );
1812 application.SendNotification();
1813 application.Render(0);
1820 TestGlAbstraction& gl = application.GetGlAbstraction();
1821 gl.EnableTextureCallTrace(true);
1822 application.SendNotification();
1823 application.Render(0);
1825 int textureBindIndex[5];
1826 for( unsigned int i(0); i<5; ++i )
1828 std::stringstream params;
1829 params << GL_TEXTURE_2D<<", "<<i+1;
1830 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1833 //Check that actor4 has been rendered after actor2
1834 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[2], TEST_LOCATION );
1836 //Check that actor1 has been rendered after actor4
1837 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[4], TEST_LOCATION );
1839 //Check that actor0 has been rendered after actor1
1840 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1842 //Check that actor3 has been rendered after actor0
1843 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1848 int UtcDaliRendererSetIndexRange(void)
1852 "attribute vec2 aPosition;\n"
1855 " gl_Position = aPosition;\n"
1861 " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0)\n"
1865 TestApplication application;
1866 tet_infoline("Test setting the range of indices to draw");
1868 TestGlAbstraction& gl = application.GetGlAbstraction();
1869 gl.EnableDrawCallTrace( true );
1871 Actor actor = Actor::New();
1872 actor.SetSize( 100, 100 );
1875 Geometry geometry = Geometry::New();
1876 geometry.SetType( Geometry::LINE_LOOP );
1878 // --------------------------------------------------------------------------
1880 unsigned short indices[] = { 0, 2, 4, 6, 8, // offset = 0, count = 5
1881 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // offset = 5, count = 10
1882 1, 3, 5, 7, 9, 1 }; // offset = 15, count = 6 // line strip
1884 // --------------------------------------------------------------------------
1893 { Vector2( 0.0f, 1.00f) }, { Vector2( 0.0f, -1.00f) },
1894 { Vector2( -0.95f, 0.31f) }, { Vector2( 0.59f, 0.81f) },
1895 { Vector2( -0.59f, -0.81f) }, { Vector2( -0.95f, -0.31f) },
1896 { Vector2( 0.59f, -0.81f) }, { Vector2( 0.95f, -0.31f) },
1897 { Vector2( 0.95f, 0.31f) }, { Vector2( -0.59f, 0.81f) },
1899 Property::Map vertexFormat;
1900 vertexFormat["aPosition"] = Property::VECTOR2;
1901 PropertyBuffer vertexBuffer = PropertyBuffer::New( vertexFormat );
1902 vertexBuffer.SetData( shapes, sizeof(shapes)/sizeof(shapes[0]));
1904 // --------------------------------------------------------------------------
1905 geometry.SetIndexBuffer( indices, sizeof(indices)/sizeof(indices[0]) );
1906 geometry.AddVertexBuffer( vertexBuffer );
1909 Shader shader = Shader::New( vertexShader,fragmentShader );
1910 Renderer renderer = Renderer::New( geometry, shader );
1911 actor.AddRenderer( renderer );
1913 Stage stage = Stage::GetCurrent();
1918 // LINE_LOOP, first 0, count 5
1920 renderer.SetIndexRange( 0, 5 );
1921 application.SendNotification();
1922 application.Render();
1924 Property::Value value = renderer.GetProperty( Renderer::Property::INDEX_RANGE_FIRST );
1926 DALI_TEST_CHECK( value.Get( convertedValue ) );
1927 DALI_TEST_CHECK( convertedValue == 0 );
1929 value = renderer.GetCurrentProperty( Renderer::Property::INDEX_RANGE_FIRST );
1930 DALI_TEST_CHECK( value.Get( convertedValue ) );
1931 DALI_TEST_CHECK( convertedValue == 0 );
1933 value = renderer.GetProperty( Renderer::Property::INDEX_RANGE_COUNT );
1934 DALI_TEST_CHECK( value.Get( convertedValue ) );
1935 DALI_TEST_CHECK( convertedValue == 5 );
1937 value = renderer.GetCurrentProperty( Renderer::Property::INDEX_RANGE_COUNT );
1938 DALI_TEST_CHECK( value.Get( convertedValue ) );
1939 DALI_TEST_CHECK( convertedValue == 5 );
1941 sprintf( buffer, "%u, 5, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
1942 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1943 DALI_TEST_CHECK( result );
1946 // LINE_LOOP, first 5, count 10
1948 renderer.SetIndexRange( 5, 10 );
1949 sprintf( buffer, "%u, 10, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
1950 application.SendNotification();
1951 application.Render();
1952 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1953 DALI_TEST_CHECK( result );
1956 // LINE_STRIP, first 15, count 6
1958 renderer.SetIndexRange( 15, 6 );
1959 geometry.SetType( Geometry::LINE_STRIP );
1960 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
1961 application.SendNotification();
1962 application.Render();
1963 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1964 DALI_TEST_CHECK( result );
1967 // Index out of bounds
1969 renderer.SetIndexRange( 15, 30 );
1970 geometry.SetType( Geometry::LINE_STRIP );
1971 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
1972 application.SendNotification();
1973 application.Render();
1974 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1975 DALI_TEST_CHECK( result );
1978 // drawing whole buffer starting from 15 ( last valid primitive )
1980 renderer.SetIndexRange( 15, 0 );
1981 geometry.SetType( Geometry::LINE_STRIP );
1982 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
1983 application.SendNotification();
1984 application.Render();
1985 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1986 DALI_TEST_CHECK( result );
1993 int UtcDaliRendererSetDepthFunction(void)
1995 TestApplication application;
1997 tet_infoline("Test setting the depth function");
1999 Geometry geometry = CreateQuadGeometry();
2000 Shader shader = CreateShader();
2001 Renderer renderer = Renderer::New( geometry, shader );
2003 Actor actor = Actor::New();
2004 actor.AddRenderer(renderer);
2005 actor.SetSize(400, 400);
2006 Stage stage = Stage::GetCurrent();
2007 stage.GetRootLayer().SetBehavior( Layer::LAYER_3D );
2010 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2011 glAbstraction.EnableEnableDisableCallTrace(true);
2012 glAbstraction.EnableDepthFunctionCallTrace(true);
2014 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2015 TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
2017 std::ostringstream depthTestStr;
2018 depthTestStr << GL_DEPTH_TEST;
2022 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::NEVER);
2024 glEnableDisableStack.Reset();
2025 glDepthFunctionStack.Reset();
2026 application.SendNotification();
2027 application.Render();
2029 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", depthTestStr.str().c_str() ) );
2030 std::ostringstream depthFunctionStr;
2031 depthFunctionStr << GL_NEVER;
2032 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2037 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::ALWAYS);
2039 glDepthFunctionStack.Reset();
2040 application.SendNotification();
2041 application.Render();
2043 std::ostringstream depthFunctionStr;
2044 depthFunctionStr << GL_ALWAYS;
2045 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2050 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS);
2052 glDepthFunctionStack.Reset();
2053 application.SendNotification();
2054 application.Render();
2056 std::ostringstream depthFunctionStr;
2057 depthFunctionStr << GL_LESS;
2058 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2063 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER);
2065 glDepthFunctionStack.Reset();
2066 application.SendNotification();
2067 application.Render();
2069 std::ostringstream depthFunctionStr;
2070 depthFunctionStr << GL_GREATER;
2071 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2076 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::EQUAL);
2078 glDepthFunctionStack.Reset();
2079 application.SendNotification();
2080 application.Render();
2082 std::ostringstream depthFunctionStr;
2083 depthFunctionStr << GL_EQUAL;
2084 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2089 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::NOT_EQUAL);
2091 glDepthFunctionStack.Reset();
2092 application.SendNotification();
2093 application.Render();
2095 std::ostringstream depthFunctionStr;
2096 depthFunctionStr << GL_NOTEQUAL;
2097 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2102 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS_EQUAL);
2104 glDepthFunctionStack.Reset();
2105 application.SendNotification();
2106 application.Render();
2108 std::ostringstream depthFunctionStr;
2109 depthFunctionStr << GL_LEQUAL;
2110 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2115 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER_EQUAL);
2117 glDepthFunctionStack.Reset();
2118 application.SendNotification();
2119 application.Render();
2121 std::ostringstream depthFunctionStr;
2122 depthFunctionStr << GL_GEQUAL;
2123 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2130 * @brief This templatized function checks an enumeration property is setting and getting correctly.
2131 * The checks performed are as follows:
2132 * - Check the initial/default value.
2133 * - Set a different value via enum.
2134 * - Check it was set.
2135 * - Set a different value via string.
2136 * - Check it was set.
2138 template< typename T >
2139 void CheckEnumerationProperty( TestApplication& application, Renderer& renderer, Property::Index propertyIndex, T initialValue, T firstCheckEnumeration, T secondCheckEnumeration, std::string secondCheckString )
2141 application.SendNotification();
2142 application.Render();
2144 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( initialValue ) );
2145 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast<int>( initialValue ) );
2146 renderer.SetProperty( propertyIndex, firstCheckEnumeration );
2147 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
2148 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) != static_cast<int>( firstCheckEnumeration ) );
2150 application.SendNotification();
2151 application.Render();
2153 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
2154 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
2156 renderer.SetProperty( propertyIndex, secondCheckString );
2157 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
2158 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) != static_cast<int>( secondCheckEnumeration ) );
2160 application.SendNotification();
2161 application.Render();
2163 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
2164 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
2167 int UtcDaliRendererEnumProperties(void)
2169 TestApplication application;
2170 tet_infoline( "Test Renderer enumeration properties can be set with both integer and string values" );
2172 Geometry geometry = CreateQuadGeometry();
2173 Shader shader = CreateShader();
2174 Renderer renderer = Renderer::New( geometry, shader );
2176 Actor actor = Actor::New();
2177 actor.AddRenderer(renderer);
2178 actor.SetSize(400, 400);
2179 Stage::GetCurrent().Add(actor);
2182 * Here we use a templatized function to perform several checks on each enumeration property.
2183 * @see CheckEnumerationProperty for details of the checks performed.
2186 CheckEnumerationProperty< FaceCullingMode::Type >( application, renderer, Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE, FaceCullingMode::FRONT, FaceCullingMode::BACK, "BACK" );
2187 CheckEnumerationProperty< BlendMode::Type >( application, renderer, Renderer::Property::BLEND_MODE, BlendMode::AUTO, BlendMode::OFF, BlendMode::ON, "ON" );
2188 CheckEnumerationProperty< BlendEquation::Type >( application, renderer, Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" );
2189 CheckEnumerationProperty< BlendEquation::Type >( application, renderer, Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" );
2190 CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2191 CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2192 CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2193 CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2194 CheckEnumerationProperty< DepthWriteMode::Type >( application, renderer, Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO, DepthWriteMode::OFF, DepthWriteMode::ON, "ON" );
2195 CheckEnumerationProperty< DepthFunction::Type >( application, renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER" );
2196 CheckEnumerationProperty< DepthTestMode::Type >( application, renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON" );
2197 CheckEnumerationProperty< StencilFunction::Type >( application, renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL" );
2198 CheckEnumerationProperty< RenderMode::Type >( application, renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL" );
2199 CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
2200 CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
2201 CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
2206 Renderer RendererTestFixture( TestApplication& application )
2208 Geometry geometry = CreateQuadGeometry();
2209 Shader shader = CreateShader();
2210 Renderer renderer = Renderer::New( geometry, shader );
2212 Actor actor = Actor::New();
2213 actor.AddRenderer( renderer );
2214 actor.SetSize( 400.0f, 400.0f );
2215 Stage stage = Stage::GetCurrent();
2216 stage.GetRootLayer().SetBehavior( Layer::LAYER_3D );
2222 int UtcDaliRendererSetDepthTestMode(void)
2224 TestApplication application;
2225 tet_infoline("Test setting the DepthTestMode");
2227 Renderer renderer = RendererTestFixture( application );
2228 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2229 glAbstraction.EnableEnableDisableCallTrace( true );
2230 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2232 glEnableDisableStack.Reset();
2233 application.SendNotification();
2234 application.Render();
2236 // Check depth-test is enabled by default.
2237 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
2238 DALI_TEST_CHECK( !glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2240 // Turn off depth-testing. We want to check if the depth buffer has been disabled, so we need to turn off depth-write as well for this case.
2241 renderer.SetProperty( Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::OFF );
2242 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF );
2244 glEnableDisableStack.Reset();
2245 application.SendNotification();
2246 application.Render();
2248 // Check the depth buffer was disabled.
2249 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2251 // Turn on automatic mode depth-testing.
2252 // Layer behavior is currently set to LAYER_3D so AUTO should enable depth-testing.
2253 renderer.SetProperty( Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO );
2255 glEnableDisableStack.Reset();
2256 application.SendNotification();
2257 application.Render();
2259 // Check depth-test is now enabled.
2260 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
2261 DALI_TEST_CHECK( !glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2263 // Change the layer behavior to LAYER_2D.
2264 // Note this will also disable depth testing for the layer by default, we test this first.
2265 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_2D );
2267 glEnableDisableStack.Reset();
2268 application.SendNotification();
2269 application.Render();
2271 // Check depth-test is disabled.
2272 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2274 // Turn the layer depth-test flag back on, and confirm that depth testing is now on.
2275 Stage::GetCurrent().GetRootLayer().SetDepthTestDisabled( false );
2277 glEnableDisableStack.Reset();
2278 application.SendNotification();
2279 application.Render();
2281 // Check depth-test is *still* disabled.
2282 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
2287 int UtcDaliRendererSetDepthWriteMode(void)
2289 TestApplication application;
2290 tet_infoline("Test setting the DepthWriteMode");
2292 Renderer renderer = RendererTestFixture( application );
2293 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2295 application.SendNotification();
2296 application.Render();
2298 // Check the default depth-write status first.
2299 DALI_TEST_CHECK( glAbstraction.GetLastDepthMask() );
2301 // Turn off depth-writing.
2302 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF );
2304 application.SendNotification();
2305 application.Render();
2307 // Check depth-write is now disabled.
2308 DALI_TEST_CHECK( !glAbstraction.GetLastDepthMask() );
2310 // Test the AUTO mode for depth-writing.
2311 // As our renderer is opaque, depth-testing should be enabled.
2312 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO );
2314 application.SendNotification();
2315 application.Render();
2317 // Check depth-write is now enabled.
2318 DALI_TEST_CHECK( glAbstraction.GetLastDepthMask() );
2320 // Now make the renderer be treated as translucent by enabling blending.
2321 // The AUTO depth-write mode should turn depth-write off in this scenario.
2322 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
2324 application.SendNotification();
2325 application.Render();
2327 // Check depth-write is now disabled.
2328 DALI_TEST_CHECK( !glAbstraction.GetLastDepthMask() );
2333 int UtcDaliRendererCheckStencilDefaults(void)
2335 TestApplication application;
2336 tet_infoline("Test the stencil defaults");
2338 Renderer renderer = RendererTestFixture( application );
2339 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2340 glAbstraction.EnableEnableDisableCallTrace( true );
2341 glAbstraction.EnableStencilFunctionCallTrace( true );
2342 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2343 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2345 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2347 // Check the defaults:
2348 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::ALWAYS ), TEST_LOCATION );
2349 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2350 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), 0x00, TEST_LOCATION );
2351 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2352 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL ).Get<int>() ), static_cast<int>( StencilOperation::KEEP ), TEST_LOCATION );
2353 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL ).Get<int>() ), static_cast<int>( StencilOperation::KEEP ), TEST_LOCATION );
2354 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ).Get<int>() ), static_cast<int>( StencilOperation::KEEP ), TEST_LOCATION );
2359 int UtcDaliRendererSetRenderModeToUseStencilBuffer(void)
2361 TestApplication application;
2362 tet_infoline("Test setting the RenderMode to use the stencil buffer");
2364 Renderer renderer = RendererTestFixture( application );
2365 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2366 glAbstraction.EnableEnableDisableCallTrace( true );
2367 glAbstraction.EnableStencilFunctionCallTrace( true );
2368 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2369 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2371 // Set the StencilFunction to something other than the default, to confirm it is set as a property,
2372 // but NO GL call has been made while the RenderMode is set to not use the stencil buffer.
2373 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::NONE );
2374 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2376 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::NEVER );
2377 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::NEVER ), TEST_LOCATION );
2379 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2380 std::string methodString( "StencilFunc" );
2381 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2383 // Test the other RenderModes that will not enable the stencil buffer.
2384 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::AUTO );
2385 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2386 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2388 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
2389 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2390 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2392 // Now set the RenderMode to modes that will use the stencil buffer, and check the StencilFunction has changed.
2393 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2394 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2396 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
2397 DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) );
2399 // Test the COLOR_STENCIL RenderMode as it also enables the stencil buffer.
2400 // First set a mode to turn off the stencil buffer, so the enable is required.
2401 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
2402 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2403 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL );
2404 // Set a different stencil function as the last one is cached.
2405 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS );
2406 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2408 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
2409 DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) );
2414 // Helper function for the SetRenderModeToUseColorBuffer test.
2415 void CheckRenderModeColorMask( TestApplication& application, Renderer& renderer, RenderMode::Type renderMode, bool expectedValue )
2417 // Set the RenderMode property to a value that should not allow color buffer writes.
2418 renderer.SetProperty( Renderer::Property::RENDER_MODE, renderMode );
2419 application.SendNotification();
2420 application.Render();
2422 // Check if ColorMask has been called, and that the values are correct.
2423 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2424 const TestGlAbstraction::ColorMaskParams& colorMaskParams( glAbstraction.GetColorMaskParams() );
2426 DALI_TEST_EQUALS<bool>( colorMaskParams.red, expectedValue, TEST_LOCATION );
2427 DALI_TEST_EQUALS<bool>( colorMaskParams.green, expectedValue, TEST_LOCATION );
2428 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, expectedValue, TEST_LOCATION );
2429 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, expectedValue, TEST_LOCATION );
2432 int UtcDaliRendererSetRenderModeToUseColorBuffer(void)
2434 TestApplication application;
2435 tet_infoline("Test setting the RenderMode to use the color buffer");
2437 Renderer renderer = RendererTestFixture( application );
2439 // Set the RenderMode property to a value that should not allow color buffer writes.
2440 // Then check if ColorMask has been called, and that the values are correct.
2441 CheckRenderModeColorMask( application, renderer, RenderMode::AUTO, true );
2442 CheckRenderModeColorMask( application, renderer, RenderMode::NONE, false );
2443 CheckRenderModeColorMask( application, renderer, RenderMode::COLOR, true );
2444 CheckRenderModeColorMask( application, renderer, RenderMode::STENCIL, false );
2445 CheckRenderModeColorMask( application, renderer, RenderMode::COLOR_STENCIL, true );
2450 int UtcDaliRendererSetStencilFunction(void)
2452 TestApplication application;
2453 tet_infoline("Test setting the StencilFunction");
2455 Renderer renderer = RendererTestFixture( application );
2456 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2457 glAbstraction.EnableEnableDisableCallTrace( true );
2458 glAbstraction.EnableStencilFunctionCallTrace( true );
2459 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2460 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2462 // RenderMode must use the stencil for StencilFunction to operate.
2463 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2464 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2467 * Lookup table for testing StencilFunction.
2468 * Note: This MUST be in the same order as the Dali::StencilFunction enum.
2470 const int StencilFunctionLookupTable[] = {
2479 }; const int StencilFunctionLookupTableCount = sizeof( StencilFunctionLookupTable ) / sizeof( StencilFunctionLookupTable[0] );
2482 * Loop through all types of StencilFunction, checking:
2483 * - The value is cached (set in event thread side)
2484 * - Causes "glStencilFunc" to be called
2485 * - Checks the correct parameters to "glStencilFunc" were used
2487 std::string nonChangingParameters = "0, 255";
2488 std::string methodString( "StencilFunc" );
2489 for( int i = 0; i < StencilFunctionLookupTableCount; ++i )
2491 // Set the property.
2492 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, static_cast<Dali::StencilFunction::Type>( i ) );
2494 // Check GetProperty returns the same value.
2495 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), i, TEST_LOCATION );
2497 // Reset the trace debug.
2498 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2500 // Check the function is called and the parameters are correct.
2501 std::stringstream parameterStream;
2502 parameterStream << StencilFunctionLookupTable[ i ] << ", " << nonChangingParameters;
2504 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2507 // Change the Function Reference only and check the behavior is correct:
2508 // 170 is 0xaa in hex / 10101010 in binary (every other bit set).
2509 int testValueReference = 170;
2510 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE, testValueReference );
2512 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), testValueReference, TEST_LOCATION );
2514 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2516 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), testValueReference, TEST_LOCATION );
2518 std::stringstream parameterStream;
2519 parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", 255";
2521 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2524 // Change the Function Mask only and check the behavior is correct:
2525 // 85 is 0x55 in hex / 01010101 in binary (every other bit set).
2526 int testValueMask = 85;
2527 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_MASK, testValueMask );
2529 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), testValueMask, TEST_LOCATION );
2531 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2533 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), testValueMask, TEST_LOCATION );
2535 // Clear the stringstream.
2536 parameterStream.str( std::string() );
2537 parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", " << testValueMask;
2539 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2544 int UtcDaliRendererSetStencilOperation(void)
2546 TestApplication application;
2547 tet_infoline("Test setting the StencilOperation");
2549 Renderer renderer = RendererTestFixture( application );
2550 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2551 glAbstraction.EnableEnableDisableCallTrace( true );
2552 glAbstraction.EnableStencilFunctionCallTrace( true );
2553 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2554 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2556 // RenderMode must use the stencil for StencilOperation to operate.
2557 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2560 * Lookup table for testing StencilOperation.
2561 * Note: This MUST be in the same order as the Dali::StencilOperation enum.
2563 const int StencilOperationLookupTable[] = {
2572 }; const int StencilOperationLookupTableCount = sizeof( StencilOperationLookupTable ) / sizeof( StencilOperationLookupTable[0] );
2574 // Set all 3 StencilOperation properties to a default.
2575 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP );
2576 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::ZERO );
2577 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::ZERO );
2579 // Set our expected parameter list to the equivalent result.
2580 int parameters[] = { StencilOperationLookupTable[ StencilOperation::ZERO ], StencilOperationLookupTable[ StencilOperation::ZERO ], StencilOperationLookupTable[ StencilOperation::ZERO ] };
2582 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2585 * Loop through all types of StencilOperation, checking:
2586 * - The value is cached (set in event thread side)
2587 * - Causes "glStencilFunc" to be called
2588 * - Checks the correct parameters to "glStencilFunc" were used
2589 * - Checks the above for all 3 parameter placements of StencilOperation ( OnFail, OnZFail, OnPass )
2591 std::string methodString( "StencilOp" );
2593 for( int i = 0; i < StencilOperationLookupTableCount; ++i )
2595 for( int j = 0; j < StencilOperationLookupTableCount; ++j )
2597 for( int k = 0; k < StencilOperationLookupTableCount; ++k )
2599 // Set the property (outer loop causes all 3 different properties to be set separately).
2600 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, static_cast<Dali::StencilFunction::Type>( i ) );
2601 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, static_cast<Dali::StencilFunction::Type>( j ) );
2602 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, static_cast<Dali::StencilFunction::Type>( k ) );
2604 // Check GetProperty returns the same value.
2605 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL ).Get<int>() ), i, TEST_LOCATION );
2606 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL ).Get<int>() ), j, TEST_LOCATION );
2607 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ).Get<int>() ), k, TEST_LOCATION );
2609 // Reset the trace debug.
2610 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2612 // Check the function is called and the parameters are correct.
2613 // Set the expected parameter value at its correct index (only)
2614 parameters[ 0u ] = StencilOperationLookupTable[ i ];
2615 parameters[ 1u ] = StencilOperationLookupTable[ j ];
2616 parameters[ 2u ] = StencilOperationLookupTable[ k ];
2618 // Build the parameter list.
2619 std::stringstream parameterStream;
2620 for( int parameterBuild = 0; parameterBuild < 3; ++parameterBuild )
2622 parameterStream << parameters[ parameterBuild ];
2623 // Comma-separate the parameters.
2624 if( parameterBuild < 2 )
2626 parameterStream << ", ";
2630 // Check the function was called and the parameters were correct.
2631 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2639 int UtcDaliRendererSetStencilMask(void)
2641 TestApplication application;
2642 tet_infoline("Test setting the StencilMask");
2644 Renderer renderer = RendererTestFixture( application );
2645 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2646 glAbstraction.EnableEnableDisableCallTrace( true );
2647 glAbstraction.EnableStencilFunctionCallTrace( true );
2648 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2649 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2651 // RenderMode must use the stencil for StencilMask to operate.
2652 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2654 // Set the StencilMask property to a value.
2655 renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0x00 );
2657 // Check GetProperty returns the same value.
2658 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0x00, TEST_LOCATION );
2660 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2662 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0x00, TEST_LOCATION );
2664 std::string methodString( "StencilMask" );
2665 std::string parameterString = "0";
2667 // Check the function was called and the parameters were correct.
2668 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterString ) );
2670 // Set the StencilMask property to another value to ensure it has changed.
2671 renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0xFF );
2673 // Check GetProperty returns the same value.
2674 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2676 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2678 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2680 parameterString = "255";
2682 // Check the function was called and the parameters were correct.
2683 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterString ) );
2688 int UtcDaliRendererWrongNumberOfTextures(void)
2690 TestApplication application;
2691 tet_infoline("Test renderer does render even if number of textures is different than active samplers in the shader");
2693 //Create a TextureSet with 4 textures (One more texture in the texture set than active samplers)
2694 //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
2695 Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64u, 64u );
2696 TextureSet textureSet = CreateTextureSet();
2697 textureSet.SetTexture(0, texture );
2698 textureSet.SetTexture(1, texture );
2699 textureSet.SetTexture(2, texture );
2700 textureSet.SetTexture(3, texture );
2701 Shader shader = Shader::New("VertexSource", "FragmentSource");
2702 Geometry geometry = CreateQuadGeometry();
2703 Renderer renderer = Renderer::New( geometry, shader );
2704 renderer.SetTextures( textureSet );
2706 Actor actor= Actor::New();
2707 actor.AddRenderer(renderer);
2708 actor.SetPosition(0.0f,0.0f);
2709 actor.SetSize(100, 100);
2710 Stage::GetCurrent().Add(actor);
2712 TestGlAbstraction& gl = application.GetGlAbstraction();
2713 TraceCallStack& drawTrace = gl.GetDrawTrace();
2715 drawTrace.Enable(true);
2717 application.SendNotification();
2718 application.Render(0);
2720 //Test we do the drawcall when TextureSet has more textures than there are active samplers in the shader
2721 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
2723 //Create a TextureSet with 1 texture (two more active samplers than texture in the texture set)
2724 //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
2725 textureSet = CreateTextureSet();
2726 renderer.SetTextures( textureSet );
2727 textureSet.SetTexture(0, texture );
2729 application.SendNotification();
2730 application.Render(0);
2732 //Test we do the drawcall when TextureSet has less textures than there are active samplers in the shader.
2733 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
2738 int UtcDaliRendererOpacity(void)
2740 TestApplication application;
2742 tet_infoline( "Test OPACITY property" );
2744 Geometry geometry = CreateQuadGeometry();
2745 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
2746 Renderer renderer = Renderer::New( geometry, shader );
2748 Actor actor = Actor::New();
2749 actor.AddRenderer( renderer );
2750 actor.SetSize( 400, 400 );
2751 actor.SetColor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
2752 Stage::GetCurrent().Add( actor );
2754 Property::Value value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2756 DALI_TEST_CHECK( value.Get( opacity ) );
2757 DALI_TEST_EQUALS( opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2759 application.SendNotification();
2760 application.Render();
2762 Vector4 actualValue;
2763 TestGlAbstraction& gl = application.GetGlAbstraction();
2764 DALI_TEST_CHECK( gl.GetUniformValue< Vector4 >( "uColor", actualValue ) );
2765 DALI_TEST_EQUALS( actualValue.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2767 renderer.SetProperty( DevelRenderer::Property::OPACITY, 0.5f );
2769 application.SendNotification();
2770 application.Render();
2772 value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2773 DALI_TEST_CHECK( value.Get( opacity ) );
2774 DALI_TEST_EQUALS( opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2776 value = renderer.GetCurrentProperty( DevelRenderer::Property::OPACITY );
2777 DALI_TEST_CHECK( value.Get( opacity ) );
2778 DALI_TEST_EQUALS( opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2780 DALI_TEST_CHECK( gl.GetUniformValue< Vector4 >( "uColor", actualValue ) );
2781 DALI_TEST_EQUALS( actualValue.a, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2786 int UtcDaliRendererOpacityAnimation(void)
2788 TestApplication application;
2790 tet_infoline( "Test OPACITY property animation" );
2792 Geometry geometry = CreateQuadGeometry();
2793 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
2794 Renderer renderer = Renderer::New( geometry, shader );
2796 Actor actor = Actor::New();
2797 actor.AddRenderer( renderer );
2798 actor.SetSize( 400, 400 );
2799 actor.SetColor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
2800 Stage::GetCurrent().Add( actor );
2802 application.SendNotification();
2803 application.Render(0);
2805 Property::Value value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2807 DALI_TEST_CHECK( value.Get( opacity ) );
2808 DALI_TEST_EQUALS( opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2810 Animation animation = Animation::New( 1.0f );
2811 animation.AnimateTo( Property( renderer, DevelRenderer::Property::OPACITY ), 0.0f );
2814 application.SendNotification();
2815 application.Render( 1000 );
2817 value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2818 DALI_TEST_CHECK( value.Get( opacity ) );
2819 DALI_TEST_EQUALS( opacity, 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2821 renderer.SetProperty( DevelRenderer::Property::OPACITY, 0.1f );
2824 animation.AnimateBy( Property( renderer, DevelRenderer::Property::OPACITY ), 0.5f );
2827 application.SendNotification();
2828 application.Render( 1000 );
2830 value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2831 DALI_TEST_CHECK( value.Get( opacity ) );
2832 DALI_TEST_EQUALS( opacity, 0.6f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2837 int UtcDaliRendererInvalidProperty(void)
2839 TestApplication application;
2841 tet_infoline( "Test invalid property" );
2843 Geometry geometry = CreateQuadGeometry();
2844 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
2845 Renderer renderer = Renderer::New( geometry, shader );
2847 Actor actor = Actor::New();
2848 actor.AddRenderer( renderer );
2849 actor.SetSize( 400, 400 );
2850 Stage::GetCurrent().Add( actor );
2852 application.SendNotification();
2853 application.Render(0);
2855 Property::Value value = renderer.GetProperty( Renderer::Property::DEPTH_INDEX + 100 );
2856 DALI_TEST_CHECK( value.GetType() == Property::Type::NONE );
2858 value = renderer.GetCurrentProperty( Renderer::Property::DEPTH_INDEX + 100 );
2859 DALI_TEST_CHECK( value.GetType() == Property::Type::NONE );