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 renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
996 application.SendNotification();
997 application.Render();
999 value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
1000 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
1001 DALI_TEST_CHECK( preMultipliedAlpha );
1003 value = renderer.GetCurrentProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
1004 DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
1005 DALI_TEST_CHECK( preMultipliedAlpha );
1007 srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
1008 destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
1009 srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
1010 destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
1012 DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorRgb, TEST_LOCATION );
1013 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION );
1014 DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION );
1015 DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION );
1017 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
1018 DALI_TEST_EQUALS( actualValue, Vector4(0.5f, 0.0f, 0.5f, 0.5f), TEST_LOCATION );
1023 int UtcDaliRendererConstraint01(void)
1025 TestApplication application;
1027 tet_infoline("Test that a non-uniform renderer property can be constrained");
1029 Shader shader = Shader::New("VertexSource", "FragmentSource");
1030 Geometry geometry = CreateQuadGeometry();
1031 Renderer renderer = Renderer::New( geometry, shader );
1033 Actor actor = Actor::New();
1034 actor.AddRenderer(renderer);
1035 actor.SetSize(400, 400);
1036 Stage::GetCurrent().Add(actor);
1038 Vector4 initialColor = Color::WHITE;
1039 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1041 application.SendNotification();
1042 application.Render(0);
1043 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
1046 Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
1048 application.SendNotification();
1049 application.Render(0);
1051 // Expect no blue component in either buffer - yellow
1052 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::YELLOW, TEST_LOCATION );
1053 application.Render(0);
1054 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::YELLOW, TEST_LOCATION );
1056 renderer.RemoveConstraints();
1057 renderer.SetProperty(colorIndex, Color::WHITE );
1058 application.SendNotification();
1059 application.Render(0);
1060 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::WHITE, TEST_LOCATION );
1065 int UtcDaliRendererConstraint02(void)
1067 TestApplication application;
1069 tet_infoline("Test that a uniform map renderer property can be constrained");
1071 Shader shader = Shader::New("VertexSource", "FragmentSource");
1072 Geometry geometry = CreateQuadGeometry();
1073 Renderer renderer = Renderer::New( geometry, shader );
1075 Actor actor = Actor::New();
1076 actor.AddRenderer(renderer);
1077 actor.SetSize(400, 400);
1078 Stage::GetCurrent().Add(actor);
1079 application.SendNotification();
1080 application.Render(0);
1082 Vector4 initialColor = Color::WHITE;
1083 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1085 TestGlAbstraction& gl = application.GetGlAbstraction();
1087 application.SendNotification();
1088 application.Render(0);
1090 Vector4 actualValue(Vector4::ZERO);
1091 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1092 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1095 Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
1097 application.SendNotification();
1098 application.Render(0);
1100 // Expect no blue component in either buffer - yellow
1101 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1102 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
1104 application.Render(0);
1105 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1106 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
1108 renderer.RemoveConstraints();
1109 renderer.SetProperty(colorIndex, Color::WHITE );
1110 application.SendNotification();
1111 application.Render(0);
1113 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1114 DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
1119 int UtcDaliRendererAnimatedProperty01(void)
1121 TestApplication application;
1123 tet_infoline("Test that a non-uniform renderer property can be animated");
1125 Shader shader = Shader::New("VertexSource", "FragmentSource");
1126 Geometry geometry = CreateQuadGeometry();
1127 Renderer renderer = Renderer::New( geometry, shader );
1129 Actor actor = Actor::New();
1130 actor.AddRenderer(renderer);
1131 actor.SetSize(400, 400);
1132 Stage::GetCurrent().Add(actor);
1134 Vector4 initialColor = Color::WHITE;
1135 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1137 application.SendNotification();
1138 application.Render(0);
1139 DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
1141 Animation animation = Animation::New(1.0f);
1142 KeyFrames keyFrames = KeyFrames::New();
1143 keyFrames.Add(0.0f, initialColor);
1144 keyFrames.Add(1.0f, Color::TRANSPARENT);
1145 animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
1148 application.SendNotification();
1149 application.Render(500);
1151 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::WHITE * 0.5f, TEST_LOCATION );
1153 application.Render(500);
1155 DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::TRANSPARENT, TEST_LOCATION );
1160 int UtcDaliRendererAnimatedProperty02(void)
1162 TestApplication application;
1164 tet_infoline("Test that a uniform map renderer property can be animated");
1166 Shader shader = Shader::New("VertexSource", "FragmentSource");
1167 Geometry geometry = CreateQuadGeometry();
1168 Renderer renderer = Renderer::New( geometry, shader );
1170 Actor actor = Actor::New();
1171 actor.AddRenderer(renderer);
1172 actor.SetSize(400, 400);
1173 Stage::GetCurrent().Add(actor);
1174 application.SendNotification();
1175 application.Render(0);
1177 Vector4 initialColor = Color::WHITE;
1178 Property::Index colorIndex = renderer.RegisterProperty( "uFadeColor", initialColor );
1180 TestGlAbstraction& gl = application.GetGlAbstraction();
1182 application.SendNotification();
1183 application.Render(0);
1185 Vector4 actualValue(Vector4::ZERO);
1186 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1187 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1189 Animation animation = Animation::New(1.0f);
1190 KeyFrames keyFrames = KeyFrames::New();
1191 keyFrames.Add(0.0f, initialColor);
1192 keyFrames.Add(1.0f, Color::TRANSPARENT);
1193 animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
1196 application.SendNotification();
1197 application.Render(500);
1199 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1200 DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
1202 application.Render(500);
1203 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1204 DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
1209 int UtcDaliRendererUniformMapPrecendence01(void)
1211 TestApplication application;
1213 tet_infoline("Test the uniform map precedence is applied properly");
1215 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1217 Shader shader = Shader::New("VertexSource", "FragmentSource");
1218 TextureSet textureSet = CreateTextureSet( image );
1220 Geometry geometry = CreateQuadGeometry();
1221 Renderer renderer = Renderer::New( geometry, shader );
1222 renderer.SetTextures( textureSet );
1224 Actor actor = Actor::New();
1225 actor.AddRenderer(renderer);
1226 actor.SetSize(400, 400);
1227 Stage::GetCurrent().Add(actor);
1228 application.SendNotification();
1229 application.Render(0);
1231 renderer.RegisterProperty( "uFadeColor", Color::RED );
1232 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1233 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
1235 TestGlAbstraction& gl = application.GetGlAbstraction();
1237 application.SendNotification();
1238 application.Render(0);
1240 // Expect that the actor's fade color property is accessed
1241 Vector4 actualValue(Vector4::ZERO);
1242 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1243 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1245 // Animate shader's fade color property. Should be no change to uniform
1246 Animation animation = Animation::New(1.0f);
1247 KeyFrames keyFrames = KeyFrames::New();
1248 keyFrames.Add(0.0f, Color::WHITE);
1249 keyFrames.Add(1.0f, Color::TRANSPARENT);
1250 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1253 application.SendNotification();
1254 application.Render(500);
1256 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1257 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1259 application.Render(500);
1260 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1261 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1266 int UtcDaliRendererUniformMapPrecendence02(void)
1268 TestApplication application;
1270 tet_infoline("Test the uniform map precedence is applied properly");
1272 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1274 Shader shader = Shader::New("VertexSource", "FragmentSource");
1275 TextureSet textureSet = CreateTextureSet( image );
1277 Geometry geometry = CreateQuadGeometry();
1278 Renderer renderer = Renderer::New( geometry, shader );
1279 renderer.SetTextures( textureSet );
1281 Actor actor = Actor::New();
1282 actor.AddRenderer(renderer);
1283 actor.SetSize(400, 400);
1284 Stage::GetCurrent().Add(actor);
1285 application.SendNotification();
1286 application.Render(0);
1288 // Don't add property / uniform map to renderer
1289 actor.RegisterProperty( "uFadeColor", Color::GREEN );
1290 Property::Index shaderFadeColorIndex = shader.RegisterProperty( "uFadeColor", Color::BLUE );
1292 TestGlAbstraction& gl = application.GetGlAbstraction();
1294 application.SendNotification();
1295 application.Render(0);
1297 // Expect that the actor's fade color property is accessed
1298 Vector4 actualValue(Vector4::ZERO);
1299 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1300 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1302 // Animate texture set's fade color property. Should be no change to uniform
1303 Animation animation = Animation::New(1.0f);
1304 KeyFrames keyFrames = KeyFrames::New();
1305 keyFrames.Add(0.0f, Color::WHITE);
1306 keyFrames.Add(1.0f, Color::TRANSPARENT);
1307 animation.AnimateBetween( Property( shader, shaderFadeColorIndex ), keyFrames );
1310 application.SendNotification();
1311 application.Render(500);
1313 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1314 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1316 application.Render(500);
1317 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1318 DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
1324 int UtcDaliRendererUniformMapPrecendence03(void)
1326 TestApplication application;
1328 tet_infoline("Test the uniform map precedence is applied properly");
1330 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1332 Shader shader = Shader::New("VertexSource", "FragmentSource");
1333 TextureSet textureSet = CreateTextureSet( image );
1335 Geometry geometry = CreateQuadGeometry();
1336 Renderer renderer = Renderer::New( geometry, shader );
1337 renderer.SetTextures( textureSet );
1339 Actor actor = Actor::New();
1340 actor.AddRenderer(renderer);
1341 actor.SetSize(400, 400);
1342 Stage::GetCurrent().Add(actor);
1343 application.SendNotification();
1344 application.Render(0);
1346 // Don't add property / uniform map to renderer or actor
1347 shader.RegisterProperty( "uFadeColor", Color::BLACK );
1349 TestGlAbstraction& gl = application.GetGlAbstraction();
1351 application.SendNotification();
1352 application.Render(0);
1354 // Expect that the shader's fade color property is accessed
1355 Vector4 actualValue(Vector4::ZERO);
1356 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1357 DALI_TEST_EQUALS( actualValue, Color::BLACK, TEST_LOCATION );
1362 int UtcDaliRendererUniformMapMultipleUniforms01(void)
1364 TestApplication application;
1366 tet_infoline("Test the uniform maps are collected from all objects (same type)");
1368 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1370 Shader shader = Shader::New("VertexSource", "FragmentSource");
1371 TextureSet textureSet = CreateTextureSet( image );
1373 Geometry geometry = CreateQuadGeometry();
1374 Renderer renderer = Renderer::New( geometry, shader );
1375 renderer.SetTextures( textureSet );
1377 Actor actor = Actor::New();
1378 actor.AddRenderer(renderer);
1379 actor.SetSize(400, 400);
1380 Stage::GetCurrent().Add(actor);
1381 application.SendNotification();
1382 application.Render(0);
1384 renderer.RegisterProperty( "uUniform1", Color::RED );
1385 actor.RegisterProperty( "uUniform2", Color::GREEN );
1386 shader.RegisterProperty( "uUniform3", Color::MAGENTA );
1388 TestGlAbstraction& gl = application.GetGlAbstraction();
1390 application.SendNotification();
1391 application.Render(0);
1393 // Expect that each of the object's uniforms are set
1394 Vector4 uniform1Value(Vector4::ZERO);
1395 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform1", uniform1Value ) );
1396 DALI_TEST_EQUALS( uniform1Value, Color::RED, TEST_LOCATION );
1398 Vector4 uniform2Value(Vector4::ZERO);
1399 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform2", uniform2Value ) );
1400 DALI_TEST_EQUALS( uniform2Value, Color::GREEN, TEST_LOCATION );
1402 Vector4 uniform3Value(Vector4::ZERO);
1403 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform3", uniform3Value ) );
1404 DALI_TEST_EQUALS( uniform3Value, Color::MAGENTA, TEST_LOCATION );
1409 int UtcDaliRendererUniformMapMultipleUniforms02(void)
1411 TestApplication application;
1413 tet_infoline("Test the uniform maps are collected from all objects (different types)");
1415 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1417 Shader shader = Shader::New("VertexSource", "FragmentSource");
1418 TextureSet textureSet = CreateTextureSet( image );
1420 Geometry geometry = CreateQuadGeometry();
1421 Renderer renderer = Renderer::New( geometry, shader );
1422 renderer.SetTextures( textureSet );
1424 Actor actor = Actor::New();
1425 actor.AddRenderer(renderer);
1426 actor.SetSize(400, 400);
1427 Stage::GetCurrent().Add(actor);
1428 application.SendNotification();
1429 application.Render(0);
1431 Property::Value value1(Color::RED);
1432 renderer.RegisterProperty( "uFadeColor", value1 );
1434 Property::Value value2(1.0f);
1435 actor.RegisterProperty( "uFadeProgress", value2 );
1437 Property::Value value3(Matrix3::IDENTITY);
1438 shader.RegisterProperty( "uANormalMatrix", value3 );
1440 TestGlAbstraction& gl = application.GetGlAbstraction();
1442 application.SendNotification();
1443 application.Render(0);
1445 // Expect that each of the object's uniforms are set
1446 Vector4 uniform1Value(Vector4::ZERO);
1447 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", uniform1Value ) );
1448 DALI_TEST_EQUALS( uniform1Value, value1.Get<Vector4>(), TEST_LOCATION );
1450 float uniform2Value(0.0f);
1451 DALI_TEST_CHECK( gl.GetUniformValue<float>( "uFadeProgress", uniform2Value ) );
1452 DALI_TEST_EQUALS( uniform2Value, value2.Get<float>(), TEST_LOCATION );
1454 Matrix3 uniform3Value;
1455 DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uANormalMatrix", uniform3Value ) );
1456 DALI_TEST_EQUALS( uniform3Value, value3.Get<Matrix3>(), TEST_LOCATION );
1462 Renderer CreateRenderer( Actor actor, Geometry geometry, Shader shader, int depthIndex )
1464 Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
1465 TextureSet textureSet0 = CreateTextureSet( image0 );
1466 Renderer renderer0 = Renderer::New( geometry, shader );
1467 renderer0.SetTextures( textureSet0 );
1468 renderer0.SetProperty( Renderer::Property::DEPTH_INDEX, depthIndex );
1469 actor.AddRenderer(renderer0);
1474 Actor CreateActor( Actor parent, int siblingOrder, const char* location )
1476 Actor actor = Actor::New();
1477 actor.SetAnchorPoint(AnchorPoint::CENTER);
1478 actor.SetParentOrigin(AnchorPoint::CENTER);
1479 actor.SetPosition(0.0f,0.0f);
1480 actor.SetSize(100, 100);
1482 actor.SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, siblingOrder );
1483 DALI_TEST_EQUALS( actor.GetProperty<int>( Dali::DevelActor::Property::SIBLING_ORDER), siblingOrder, TEST_INNER_LOCATION(location) );
1488 int UtcDaliRendererRenderOrder2DLayer(void)
1490 TestApplication application;
1491 tet_infoline("Test the rendering order in a 2D layer is correct");
1493 Shader shader = Shader::New("VertexSource", "FragmentSource");
1494 Geometry geometry = CreateQuadGeometry();
1496 Actor root = Stage::GetCurrent().GetRootLayer();
1498 Actor actor0 = CreateActor( root, 0, TEST_LOCATION );
1499 Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 0 );
1501 Actor actor1 = CreateActor( root, 0, TEST_LOCATION );
1502 Renderer renderer1 = CreateRenderer( actor1, geometry, shader, 0 );
1504 Actor actor2 = CreateActor( root, 0, TEST_LOCATION );
1505 Renderer renderer2 = CreateRenderer( actor2, geometry, shader, 0 );
1507 Actor actor3 = CreateActor( root, 0, TEST_LOCATION );
1508 Renderer renderer3 = CreateRenderer( actor3, geometry, shader, 0 );
1510 application.SendNotification();
1511 application.Render(0);
1514 * Create the following hierarchy:
1527 * Expected rendering order : actor2 - actor1 - actor0 - actor3
1532 application.SendNotification();
1533 application.Render(0);
1535 TestGlAbstraction& gl = application.GetGlAbstraction();
1536 gl.EnableTextureCallTrace(true);
1537 application.SendNotification();
1538 application.Render(0);
1540 int textureBindIndex[4];
1541 for( unsigned int i(0); i<4; ++i )
1543 std::stringstream params;
1544 params << GL_TEXTURE_2D<<", "<<i+1;
1545 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1548 //Check that actor1 has been rendered after actor2
1549 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[2], TEST_LOCATION );
1551 //Check that actor0 has been rendered after actor1
1552 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1554 //Check that actor3 has been rendered after actor0
1555 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1560 int UtcDaliRendererRenderOrder2DLayerMultipleRenderers(void)
1562 TestApplication application;
1563 tet_infoline("Test the rendering order in a 2D layer is correct using multiple renderers per actor");
1566 * Creates the following hierarchy:
1568 * actor0------------------------>actor1
1572 * renderer0 renderer1 renderer2 renderer3 renderer4 renderer5
1574 * renderer0 has depth index 2
1575 * renderer1 has depth index 0
1576 * renderer2 has depth index 1
1578 * renderer3 has depth index 1
1579 * renderer4 has depth index 0
1580 * renderer5 has depth index -1
1582 * Expected rendering order: renderer1 - renderer2 - renderer0 - renderer5 - renderer4 - renderer3
1585 Shader shader = Shader::New("VertexSource", "FragmentSource");
1586 Geometry geometry = CreateQuadGeometry();
1588 Actor root = Stage::GetCurrent().GetRootLayer();
1590 Actor actor0 = CreateActor( root, 0, TEST_LOCATION );
1591 Actor actor1 = CreateActor( actor0, 0, TEST_LOCATION );
1592 Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 2 );
1593 Renderer renderer1 = CreateRenderer( actor0, geometry, shader, 0 );
1594 Renderer renderer2 = CreateRenderer( actor0, geometry, shader, 1 );
1595 Renderer renderer3 = CreateRenderer( actor1, geometry, shader, 1 );
1596 Renderer renderer4 = CreateRenderer( actor1, geometry, shader, 0 );
1597 Renderer renderer5 = CreateRenderer( actor1, geometry, shader, -1 );
1599 application.SendNotification();
1600 application.Render(0);
1602 TestGlAbstraction& gl = application.GetGlAbstraction();
1603 gl.EnableTextureCallTrace(true);
1604 application.SendNotification();
1605 application.Render(0);
1607 int textureBindIndex[6];
1608 for( unsigned int i(0); i<6; ++i )
1610 std::stringstream params;
1611 params << GL_TEXTURE_2D<<", "<<i+1;
1612 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1615 //Check that renderer3 has been rendered after renderer4
1616 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[4], TEST_LOCATION );
1618 //Check that renderer0 has been rendered after renderer2
1619 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[5], TEST_LOCATION );
1621 //Check that renderer5 has been rendered after renderer2
1622 DALI_TEST_GREATER( textureBindIndex[5], textureBindIndex[0], TEST_LOCATION );
1624 //Check that renderer0 has been rendered after renderer2
1625 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[2], TEST_LOCATION );
1627 //Check that renderer2 has been rendered after renderer1
1628 DALI_TEST_GREATER( textureBindIndex[2], textureBindIndex[1], TEST_LOCATION );
1634 int UtcDaliRendererRenderOrder2DLayerSiblingOrder(void)
1636 TestApplication application;
1637 tet_infoline("Test the rendering order in a 2D layer is correct using sibling order");
1640 * Creates the following hierarchy:
1648 * actor0 (SIBLING_ORDER:1) actor1 (SIBLING_ORDER:0)
1652 * renderer0 renderer1 actor2 renderer2 renderer3 renderer4
1653 * DI:2 DI:0 | DI:0 DI:1 DI:2
1658 * actor0 has sibling order 1
1659 * actor1 has sibling order 0
1660 * actor2 has sibling order 0
1662 * renderer0 has depth index 2
1663 * renderer1 has depth index 0
1665 * renderer2 has depth index 0
1666 * renderer3 has depth index 1
1667 * renderer4 has depth index 2
1669 * renderer5 has depth index -1
1671 * Expected rendering order: renderer2 - renderer3 - renderer4 - renderer1 - renderer0 - renderer5
1674 Shader shader = Shader::New("VertexSource", "FragmentSource");
1675 Geometry geometry = CreateQuadGeometry();
1676 Actor root = Stage::GetCurrent().GetRootLayer();
1677 Actor actor0 = CreateActor( root, 1, TEST_LOCATION );
1678 Actor actor1 = CreateActor( root, 0, TEST_LOCATION );
1679 Actor actor2 = CreateActor( actor0, 0, TEST_LOCATION );
1681 Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 2 );
1682 Renderer renderer1 = CreateRenderer( actor0, geometry, shader, 0 );
1683 Renderer renderer2 = CreateRenderer( actor1, geometry, shader, 0 );
1684 Renderer renderer3 = CreateRenderer( actor1, geometry, shader, 1 );
1685 Renderer renderer4 = CreateRenderer( actor1, geometry, shader, 2 );
1686 Renderer renderer5 = CreateRenderer( actor2, geometry, shader, -1 );
1688 application.SendNotification();
1689 application.Render();
1691 TestGlAbstraction& gl = application.GetGlAbstraction();
1692 gl.EnableTextureCallTrace(true);
1693 application.SendNotification();
1694 application.Render(0);
1696 int textureBindIndex[6];
1697 for( unsigned int i(0); i<6; ++i )
1699 std::stringstream params;
1700 params << GL_TEXTURE_2D<<", "<<i+1;
1701 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1704 DALI_TEST_EQUALS( textureBindIndex[2], 0, TEST_LOCATION );
1705 DALI_TEST_EQUALS( textureBindIndex[3], 1, TEST_LOCATION );
1706 DALI_TEST_EQUALS( textureBindIndex[4], 2, TEST_LOCATION );
1707 DALI_TEST_EQUALS( textureBindIndex[1], 3, TEST_LOCATION );
1708 DALI_TEST_EQUALS( textureBindIndex[0], 4, TEST_LOCATION );
1709 DALI_TEST_EQUALS( textureBindIndex[5], 5, TEST_LOCATION );
1711 // Change sibling order of actor1
1712 // New Expected rendering order: renderer1 - renderer0 - renderer 5 - renderer2 - renderer3 - renderer4
1713 actor1.SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, 2 );
1715 gl.GetTextureTrace().Reset();
1716 application.SendNotification();
1717 application.Render(0);
1719 for( unsigned int i(0); i<6; ++i )
1721 std::stringstream params;
1722 params << GL_TEXTURE_2D<<", "<<i+1;
1723 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1726 DALI_TEST_EQUALS( textureBindIndex[1], 0, TEST_LOCATION );
1727 DALI_TEST_EQUALS( textureBindIndex[0], 1, TEST_LOCATION );
1728 DALI_TEST_EQUALS( textureBindIndex[5], 2, TEST_LOCATION );
1729 DALI_TEST_EQUALS( textureBindIndex[2], 3, TEST_LOCATION );
1730 DALI_TEST_EQUALS( textureBindIndex[3], 4, TEST_LOCATION );
1731 DALI_TEST_EQUALS( textureBindIndex[4], 5, TEST_LOCATION );
1736 int UtcDaliRendererRenderOrder2DLayerOverlay(void)
1738 TestApplication application;
1739 tet_infoline("Test the rendering order in a 2D layer is correct for overlays");
1741 Shader shader = Shader::New("VertexSource", "FragmentSource");
1742 Geometry geometry = CreateQuadGeometry();
1743 Actor root = Stage::GetCurrent().GetRootLayer();
1746 * Create the following hierarchy:
1753 * (Overlay) (Regular actor)
1763 * Expected rendering order : actor2 - actor4 - actor1 - actor0 - actor3
1766 Actor actor0 = CreateActor( root, 0, TEST_LOCATION );
1767 actor0.SetDrawMode( DrawMode::OVERLAY_2D );
1768 Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 0 );
1770 Actor actor1 = CreateActor( root, 0, TEST_LOCATION );
1771 actor1.SetDrawMode( DrawMode::OVERLAY_2D );
1772 Renderer renderer1 = CreateRenderer( actor1, geometry, shader, 0 );
1774 Actor actor2 = CreateActor( root, 0, TEST_LOCATION );
1775 Renderer renderer2 = CreateRenderer( actor2, geometry, shader, 0 );
1777 Actor actor3 = CreateActor( root, 0, TEST_LOCATION );
1778 actor3.SetDrawMode( DrawMode::OVERLAY_2D );
1779 Renderer renderer3 = CreateRenderer( actor3, geometry, shader, 0 );
1781 Actor actor4 = CreateActor( root, 0, TEST_LOCATION );
1782 Renderer renderer4 = CreateRenderer( actor4, geometry, shader, 0 );
1784 application.SendNotification();
1785 application.Render(0);
1792 TestGlAbstraction& gl = application.GetGlAbstraction();
1793 gl.EnableTextureCallTrace(true);
1794 application.SendNotification();
1795 application.Render(0);
1797 int textureBindIndex[5];
1798 for( unsigned int i(0); i<5; ++i )
1800 std::stringstream params;
1801 params << GL_TEXTURE_2D<<", "<<i+1;
1802 textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
1805 //Check that actor4 has been rendered after actor2
1806 DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[2], TEST_LOCATION );
1808 //Check that actor1 has been rendered after actor4
1809 DALI_TEST_GREATER( textureBindIndex[1], textureBindIndex[4], TEST_LOCATION );
1811 //Check that actor0 has been rendered after actor1
1812 DALI_TEST_GREATER( textureBindIndex[0], textureBindIndex[1], TEST_LOCATION );
1814 //Check that actor3 has been rendered after actor0
1815 DALI_TEST_GREATER( textureBindIndex[3], textureBindIndex[0], TEST_LOCATION );
1820 int UtcDaliRendererSetIndexRange(void)
1824 "attribute vec2 aPosition;\n"
1827 " gl_Position = aPosition;\n"
1833 " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0)\n"
1837 TestApplication application;
1838 tet_infoline("Test setting the range of indices to draw");
1840 TestGlAbstraction& gl = application.GetGlAbstraction();
1841 gl.EnableDrawCallTrace( true );
1843 Actor actor = Actor::New();
1844 actor.SetSize( 100, 100 );
1847 Geometry geometry = Geometry::New();
1848 geometry.SetType( Geometry::LINE_LOOP );
1850 // --------------------------------------------------------------------------
1852 unsigned short indices[] = { 0, 2, 4, 6, 8, // offset = 0, count = 5
1853 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // offset = 5, count = 10
1854 1, 3, 5, 7, 9, 1 }; // offset = 15, count = 6 // line strip
1856 // --------------------------------------------------------------------------
1865 { Vector2( 0.0f, 1.00f) }, { Vector2( 0.0f, -1.00f) },
1866 { Vector2( -0.95f, 0.31f) }, { Vector2( 0.59f, 0.81f) },
1867 { Vector2( -0.59f, -0.81f) }, { Vector2( -0.95f, -0.31f) },
1868 { Vector2( 0.59f, -0.81f) }, { Vector2( 0.95f, -0.31f) },
1869 { Vector2( 0.95f, 0.31f) }, { Vector2( -0.59f, 0.81f) },
1871 Property::Map vertexFormat;
1872 vertexFormat["aPosition"] = Property::VECTOR2;
1873 PropertyBuffer vertexBuffer = PropertyBuffer::New( vertexFormat );
1874 vertexBuffer.SetData( shapes, sizeof(shapes)/sizeof(shapes[0]));
1876 // --------------------------------------------------------------------------
1877 geometry.SetIndexBuffer( indices, sizeof(indices)/sizeof(indices[0]) );
1878 geometry.AddVertexBuffer( vertexBuffer );
1881 Shader shader = Shader::New( vertexShader,fragmentShader );
1882 Renderer renderer = Renderer::New( geometry, shader );
1883 actor.AddRenderer( renderer );
1885 Stage stage = Stage::GetCurrent();
1890 // LINE_LOOP, first 0, count 5
1892 renderer.SetIndexRange( 0, 5 );
1893 application.SendNotification();
1894 application.Render();
1896 Property::Value value = renderer.GetProperty( Renderer::Property::INDEX_RANGE_FIRST );
1898 DALI_TEST_CHECK( value.Get( convertedValue ) );
1899 DALI_TEST_CHECK( convertedValue == 0 );
1901 value = renderer.GetCurrentProperty( Renderer::Property::INDEX_RANGE_FIRST );
1902 DALI_TEST_CHECK( value.Get( convertedValue ) );
1903 DALI_TEST_CHECK( convertedValue == 0 );
1905 value = renderer.GetProperty( Renderer::Property::INDEX_RANGE_COUNT );
1906 DALI_TEST_CHECK( value.Get( convertedValue ) );
1907 DALI_TEST_CHECK( convertedValue == 5 );
1909 value = renderer.GetCurrentProperty( Renderer::Property::INDEX_RANGE_COUNT );
1910 DALI_TEST_CHECK( value.Get( convertedValue ) );
1911 DALI_TEST_CHECK( convertedValue == 5 );
1913 sprintf( buffer, "%u, 5, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
1914 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1915 DALI_TEST_CHECK( result );
1918 // LINE_LOOP, first 5, count 10
1920 renderer.SetIndexRange( 5, 10 );
1921 sprintf( buffer, "%u, 10, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
1922 application.SendNotification();
1923 application.Render();
1924 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1925 DALI_TEST_CHECK( result );
1928 // LINE_STRIP, first 15, count 6
1930 renderer.SetIndexRange( 15, 6 );
1931 geometry.SetType( Geometry::LINE_STRIP );
1932 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
1933 application.SendNotification();
1934 application.Render();
1935 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1936 DALI_TEST_CHECK( result );
1939 // Index out of bounds
1941 renderer.SetIndexRange( 15, 30 );
1942 geometry.SetType( Geometry::LINE_STRIP );
1943 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
1944 application.SendNotification();
1945 application.Render();
1946 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1947 DALI_TEST_CHECK( result );
1950 // drawing whole buffer starting from 15 ( last valid primitive )
1952 renderer.SetIndexRange( 15, 0 );
1953 geometry.SetType( Geometry::LINE_STRIP );
1954 sprintf( buffer, "%u, 6, %u, indices", GL_LINE_STRIP, GL_UNSIGNED_SHORT );
1955 application.SendNotification();
1956 application.Render();
1957 bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
1958 DALI_TEST_CHECK( result );
1965 int UtcDaliRendererSetDepthFunction(void)
1967 TestApplication application;
1969 tet_infoline("Test setting the depth function");
1971 Geometry geometry = CreateQuadGeometry();
1972 Shader shader = CreateShader();
1973 Renderer renderer = Renderer::New( geometry, shader );
1975 Actor actor = Actor::New();
1976 actor.AddRenderer(renderer);
1977 actor.SetSize(400, 400);
1978 Stage stage = Stage::GetCurrent();
1979 stage.GetRootLayer().SetBehavior( Layer::LAYER_3D );
1982 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1983 glAbstraction.EnableEnableDisableCallTrace(true);
1984 glAbstraction.EnableDepthFunctionCallTrace(true);
1986 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
1987 TraceCallStack& glDepthFunctionStack = glAbstraction.GetDepthFunctionTrace();
1989 std::ostringstream depthTestStr;
1990 depthTestStr << GL_DEPTH_TEST;
1994 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::NEVER);
1996 glEnableDisableStack.Reset();
1997 glDepthFunctionStack.Reset();
1998 application.SendNotification();
1999 application.Render();
2001 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", depthTestStr.str().c_str() ) );
2002 std::ostringstream depthFunctionStr;
2003 depthFunctionStr << GL_NEVER;
2004 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2009 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::ALWAYS);
2011 glDepthFunctionStack.Reset();
2012 application.SendNotification();
2013 application.Render();
2015 std::ostringstream depthFunctionStr;
2016 depthFunctionStr << GL_ALWAYS;
2017 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2022 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS);
2024 glDepthFunctionStack.Reset();
2025 application.SendNotification();
2026 application.Render();
2028 std::ostringstream depthFunctionStr;
2029 depthFunctionStr << GL_LESS;
2030 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2035 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER);
2037 glDepthFunctionStack.Reset();
2038 application.SendNotification();
2039 application.Render();
2041 std::ostringstream depthFunctionStr;
2042 depthFunctionStr << GL_GREATER;
2043 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2048 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::EQUAL);
2050 glDepthFunctionStack.Reset();
2051 application.SendNotification();
2052 application.Render();
2054 std::ostringstream depthFunctionStr;
2055 depthFunctionStr << GL_EQUAL;
2056 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2061 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::NOT_EQUAL);
2063 glDepthFunctionStack.Reset();
2064 application.SendNotification();
2065 application.Render();
2067 std::ostringstream depthFunctionStr;
2068 depthFunctionStr << GL_NOTEQUAL;
2069 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2074 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS_EQUAL);
2076 glDepthFunctionStack.Reset();
2077 application.SendNotification();
2078 application.Render();
2080 std::ostringstream depthFunctionStr;
2081 depthFunctionStr << GL_LEQUAL;
2082 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2087 renderer.SetProperty( Renderer::Property::DEPTH_FUNCTION, DepthFunction::GREATER_EQUAL);
2089 glDepthFunctionStack.Reset();
2090 application.SendNotification();
2091 application.Render();
2093 std::ostringstream depthFunctionStr;
2094 depthFunctionStr << GL_GEQUAL;
2095 DALI_TEST_CHECK( glDepthFunctionStack.FindMethodAndParams( "DepthFunc", depthFunctionStr.str().c_str() ) );
2102 * @brief This templatized function checks an enumeration property is setting and getting correctly.
2103 * The checks performed are as follows:
2104 * - Check the initial/default value.
2105 * - Set a different value via enum.
2106 * - Check it was set.
2107 * - Set a different value via string.
2108 * - Check it was set.
2110 template< typename T >
2111 void CheckEnumerationProperty( TestApplication& application, Renderer& renderer, Property::Index propertyIndex, T initialValue, T firstCheckEnumeration, T secondCheckEnumeration, std::string secondCheckString )
2113 application.SendNotification();
2114 application.Render();
2116 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( initialValue ) );
2117 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast<int>( initialValue ) );
2118 renderer.SetProperty( propertyIndex, firstCheckEnumeration );
2119 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
2120 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) != static_cast<int>( firstCheckEnumeration ) );
2122 application.SendNotification();
2123 application.Render();
2125 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
2126 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
2128 renderer.SetProperty( propertyIndex, secondCheckString );
2129 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
2130 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) != static_cast<int>( secondCheckEnumeration ) );
2132 application.SendNotification();
2133 application.Render();
2135 DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
2136 DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
2139 int UtcDaliRendererEnumProperties(void)
2141 TestApplication application;
2142 tet_infoline( "Test Renderer enumeration properties can be set with both integer and string values" );
2144 Geometry geometry = CreateQuadGeometry();
2145 Shader shader = CreateShader();
2146 Renderer renderer = Renderer::New( geometry, shader );
2148 Actor actor = Actor::New();
2149 actor.AddRenderer(renderer);
2150 actor.SetSize(400, 400);
2151 Stage::GetCurrent().Add(actor);
2154 * Here we use a templatized function to perform several checks on each enumeration property.
2155 * @see CheckEnumerationProperty for details of the checks performed.
2158 CheckEnumerationProperty< FaceCullingMode::Type >( application, renderer, Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE, FaceCullingMode::FRONT, FaceCullingMode::BACK, "BACK" );
2159 CheckEnumerationProperty< BlendMode::Type >( application, renderer, Renderer::Property::BLEND_MODE, BlendMode::AUTO, BlendMode::OFF, BlendMode::ON, "ON" );
2160 CheckEnumerationProperty< BlendEquation::Type >( application, renderer, Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" );
2161 CheckEnumerationProperty< BlendEquation::Type >( application, renderer, Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" );
2162 CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2163 CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2164 CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2165 CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
2166 CheckEnumerationProperty< DepthWriteMode::Type >( application, renderer, Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO, DepthWriteMode::OFF, DepthWriteMode::ON, "ON" );
2167 CheckEnumerationProperty< DepthFunction::Type >( application, renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER" );
2168 CheckEnumerationProperty< DepthTestMode::Type >( application, renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON" );
2169 CheckEnumerationProperty< StencilFunction::Type >( application, renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL" );
2170 CheckEnumerationProperty< RenderMode::Type >( application, renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL" );
2171 CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
2172 CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
2173 CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
2178 Renderer RendererTestFixture( TestApplication& application )
2180 Geometry geometry = CreateQuadGeometry();
2181 Shader shader = CreateShader();
2182 Renderer renderer = Renderer::New( geometry, shader );
2184 Actor actor = Actor::New();
2185 actor.AddRenderer( renderer );
2186 actor.SetSize( 400.0f, 400.0f );
2187 Stage stage = Stage::GetCurrent();
2188 stage.GetRootLayer().SetBehavior( Layer::LAYER_3D );
2194 int UtcDaliRendererSetDepthTestMode(void)
2196 TestApplication application;
2197 tet_infoline("Test setting the DepthTestMode");
2199 Renderer renderer = RendererTestFixture( application );
2200 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2201 glAbstraction.EnableEnableDisableCallTrace( true );
2202 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2204 glEnableDisableStack.Reset();
2205 application.SendNotification();
2206 application.Render();
2208 // Check depth-test is enabled by default.
2209 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
2210 DALI_TEST_CHECK( !glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2212 // 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.
2213 renderer.SetProperty( Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::OFF );
2214 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF );
2216 glEnableDisableStack.Reset();
2217 application.SendNotification();
2218 application.Render();
2220 // Check the depth buffer was disabled.
2221 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2223 // Turn on automatic mode depth-testing.
2224 // Layer behavior is currently set to LAYER_3D so AUTO should enable depth-testing.
2225 renderer.SetProperty( Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO );
2227 glEnableDisableStack.Reset();
2228 application.SendNotification();
2229 application.Render();
2231 // Check depth-test is now enabled.
2232 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
2233 DALI_TEST_CHECK( !glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2235 // Change the layer behavior to LAYER_2D.
2236 // Note this will also disable depth testing for the layer by default, we test this first.
2237 Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_2D );
2239 glEnableDisableStack.Reset();
2240 application.SendNotification();
2241 application.Render();
2243 // Check depth-test is disabled.
2244 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
2246 // Turn the layer depth-test flag back on, and confirm that depth testing is now on.
2247 Stage::GetCurrent().GetRootLayer().SetDepthTestDisabled( false );
2249 glEnableDisableStack.Reset();
2250 application.SendNotification();
2251 application.Render();
2253 // Check depth-test is *still* disabled.
2254 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
2259 int UtcDaliRendererSetDepthWriteMode(void)
2261 TestApplication application;
2262 tet_infoline("Test setting the DepthWriteMode");
2264 Renderer renderer = RendererTestFixture( application );
2265 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2267 application.SendNotification();
2268 application.Render();
2270 // Check the default depth-write status first.
2271 DALI_TEST_CHECK( glAbstraction.GetLastDepthMask() );
2273 // Turn off depth-writing.
2274 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::OFF );
2276 application.SendNotification();
2277 application.Render();
2279 // Check depth-write is now disabled.
2280 DALI_TEST_CHECK( !glAbstraction.GetLastDepthMask() );
2282 // Test the AUTO mode for depth-writing.
2283 // As our renderer is opaque, depth-testing should be enabled.
2284 renderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO );
2286 application.SendNotification();
2287 application.Render();
2289 // Check depth-write is now enabled.
2290 DALI_TEST_CHECK( glAbstraction.GetLastDepthMask() );
2292 // Now make the renderer be treated as translucent by enabling blending.
2293 // The AUTO depth-write mode should turn depth-write off in this scenario.
2294 renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
2296 application.SendNotification();
2297 application.Render();
2299 // Check depth-write is now disabled.
2300 DALI_TEST_CHECK( !glAbstraction.GetLastDepthMask() );
2305 int UtcDaliRendererCheckStencilDefaults(void)
2307 TestApplication application;
2308 tet_infoline("Test the stencil defaults");
2310 Renderer renderer = RendererTestFixture( application );
2311 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2312 glAbstraction.EnableEnableDisableCallTrace( true );
2313 glAbstraction.EnableStencilFunctionCallTrace( true );
2314 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2315 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2317 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2319 // Check the defaults:
2320 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::ALWAYS ), TEST_LOCATION );
2321 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2322 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), 0x00, TEST_LOCATION );
2323 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2324 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL ).Get<int>() ), static_cast<int>( StencilOperation::KEEP ), TEST_LOCATION );
2325 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 );
2326 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 );
2331 int UtcDaliRendererSetRenderModeToUseStencilBuffer(void)
2333 TestApplication application;
2334 tet_infoline("Test setting the RenderMode to use the stencil buffer");
2336 Renderer renderer = RendererTestFixture( application );
2337 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2338 glAbstraction.EnableEnableDisableCallTrace( true );
2339 glAbstraction.EnableStencilFunctionCallTrace( true );
2340 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2341 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2343 // Set the StencilFunction to something other than the default, to confirm it is set as a property,
2344 // but NO GL call has been made while the RenderMode is set to not use the stencil buffer.
2345 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::NONE );
2346 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2348 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::NEVER );
2349 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::NEVER ), TEST_LOCATION );
2351 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2352 std::string methodString( "StencilFunc" );
2353 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2355 // Test the other RenderModes that will not enable the stencil buffer.
2356 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::AUTO );
2357 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2358 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2360 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
2361 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2362 DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
2364 // Now set the RenderMode to modes that will use the stencil buffer, and check the StencilFunction has changed.
2365 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2366 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2368 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
2369 DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) );
2371 // Test the COLOR_STENCIL RenderMode as it also enables the stencil buffer.
2372 // First set a mode to turn off the stencil buffer, so the enable is required.
2373 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
2374 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2375 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL );
2376 // Set a different stencil function as the last one is cached.
2377 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS );
2378 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2380 DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
2381 DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) );
2386 // Helper function for the SetRenderModeToUseColorBuffer test.
2387 void CheckRenderModeColorMask( TestApplication& application, Renderer& renderer, RenderMode::Type renderMode, bool expectedValue )
2389 // Set the RenderMode property to a value that should not allow color buffer writes.
2390 renderer.SetProperty( Renderer::Property::RENDER_MODE, renderMode );
2391 application.SendNotification();
2392 application.Render();
2394 // Check if ColorMask has been called, and that the values are correct.
2395 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2396 const TestGlAbstraction::ColorMaskParams& colorMaskParams( glAbstraction.GetColorMaskParams() );
2398 DALI_TEST_EQUALS<bool>( colorMaskParams.red, expectedValue, TEST_LOCATION );
2399 DALI_TEST_EQUALS<bool>( colorMaskParams.green, expectedValue, TEST_LOCATION );
2400 DALI_TEST_EQUALS<bool>( colorMaskParams.blue, expectedValue, TEST_LOCATION );
2401 DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, expectedValue, TEST_LOCATION );
2404 int UtcDaliRendererSetRenderModeToUseColorBuffer(void)
2406 TestApplication application;
2407 tet_infoline("Test setting the RenderMode to use the color buffer");
2409 Renderer renderer = RendererTestFixture( application );
2411 // Set the RenderMode property to a value that should not allow color buffer writes.
2412 // Then check if ColorMask has been called, and that the values are correct.
2413 CheckRenderModeColorMask( application, renderer, RenderMode::AUTO, true );
2414 CheckRenderModeColorMask( application, renderer, RenderMode::NONE, false );
2415 CheckRenderModeColorMask( application, renderer, RenderMode::COLOR, true );
2416 CheckRenderModeColorMask( application, renderer, RenderMode::STENCIL, false );
2417 CheckRenderModeColorMask( application, renderer, RenderMode::COLOR_STENCIL, true );
2422 int UtcDaliRendererSetStencilFunction(void)
2424 TestApplication application;
2425 tet_infoline("Test setting the StencilFunction");
2427 Renderer renderer = RendererTestFixture( application );
2428 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2429 glAbstraction.EnableEnableDisableCallTrace( true );
2430 glAbstraction.EnableStencilFunctionCallTrace( true );
2431 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2432 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2434 // RenderMode must use the stencil for StencilFunction to operate.
2435 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2436 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2439 * Lookup table for testing StencilFunction.
2440 * Note: This MUST be in the same order as the Dali::StencilFunction enum.
2442 const int StencilFunctionLookupTable[] = {
2451 }; const int StencilFunctionLookupTableCount = sizeof( StencilFunctionLookupTable ) / sizeof( StencilFunctionLookupTable[0] );
2454 * Loop through all types of StencilFunction, checking:
2455 * - The value is cached (set in event thread side)
2456 * - Causes "glStencilFunc" to be called
2457 * - Checks the correct parameters to "glStencilFunc" were used
2459 std::string nonChangingParameters = "0, 255";
2460 std::string methodString( "StencilFunc" );
2461 for( int i = 0; i < StencilFunctionLookupTableCount; ++i )
2463 // Set the property.
2464 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, static_cast<Dali::StencilFunction::Type>( i ) );
2466 // Check GetProperty returns the same value.
2467 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), i, TEST_LOCATION );
2469 // Reset the trace debug.
2470 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2472 // Check the function is called and the parameters are correct.
2473 std::stringstream parameterStream;
2474 parameterStream << StencilFunctionLookupTable[ i ] << ", " << nonChangingParameters;
2476 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2479 // Change the Function Reference only and check the behavior is correct:
2480 // 170 is 0xaa in hex / 10101010 in binary (every other bit set).
2481 int testValueReference = 170;
2482 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE, testValueReference );
2484 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), testValueReference, TEST_LOCATION );
2486 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2488 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), testValueReference, TEST_LOCATION );
2490 std::stringstream parameterStream;
2491 parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", 255";
2493 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2496 // Change the Function Mask only and check the behavior is correct:
2497 // 85 is 0x55 in hex / 01010101 in binary (every other bit set).
2498 int testValueMask = 85;
2499 renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION_MASK, testValueMask );
2501 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), testValueMask, TEST_LOCATION );
2503 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2505 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), testValueMask, TEST_LOCATION );
2507 // Clear the stringstream.
2508 parameterStream.str( std::string() );
2509 parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", " << testValueMask;
2511 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2516 int UtcDaliRendererSetStencilOperation(void)
2518 TestApplication application;
2519 tet_infoline("Test setting the StencilOperation");
2521 Renderer renderer = RendererTestFixture( application );
2522 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2523 glAbstraction.EnableEnableDisableCallTrace( true );
2524 glAbstraction.EnableStencilFunctionCallTrace( true );
2525 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2526 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2528 // RenderMode must use the stencil for StencilOperation to operate.
2529 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2532 * Lookup table for testing StencilOperation.
2533 * Note: This MUST be in the same order as the Dali::StencilOperation enum.
2535 const int StencilOperationLookupTable[] = {
2544 }; const int StencilOperationLookupTableCount = sizeof( StencilOperationLookupTable ) / sizeof( StencilOperationLookupTable[0] );
2546 // Set all 3 StencilOperation properties to a default.
2547 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP );
2548 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::ZERO );
2549 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::ZERO );
2551 // Set our expected parameter list to the equivalent result.
2552 int parameters[] = { StencilOperationLookupTable[ StencilOperation::ZERO ], StencilOperationLookupTable[ StencilOperation::ZERO ], StencilOperationLookupTable[ StencilOperation::ZERO ] };
2554 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2557 * Loop through all types of StencilOperation, checking:
2558 * - The value is cached (set in event thread side)
2559 * - Causes "glStencilFunc" to be called
2560 * - Checks the correct parameters to "glStencilFunc" were used
2561 * - Checks the above for all 3 parameter placements of StencilOperation ( OnFail, OnZFail, OnPass )
2563 std::string methodString( "StencilOp" );
2565 for( int i = 0; i < StencilOperationLookupTableCount; ++i )
2567 for( int j = 0; j < StencilOperationLookupTableCount; ++j )
2569 for( int k = 0; k < StencilOperationLookupTableCount; ++k )
2571 // Set the property (outer loop causes all 3 different properties to be set separately).
2572 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, static_cast<Dali::StencilFunction::Type>( i ) );
2573 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, static_cast<Dali::StencilFunction::Type>( j ) );
2574 renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, static_cast<Dali::StencilFunction::Type>( k ) );
2576 // Check GetProperty returns the same value.
2577 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL ).Get<int>() ), i, TEST_LOCATION );
2578 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL ).Get<int>() ), j, TEST_LOCATION );
2579 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ).Get<int>() ), k, TEST_LOCATION );
2581 // Reset the trace debug.
2582 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2584 // Check the function is called and the parameters are correct.
2585 // Set the expected parameter value at its correct index (only)
2586 parameters[ 0u ] = StencilOperationLookupTable[ i ];
2587 parameters[ 1u ] = StencilOperationLookupTable[ j ];
2588 parameters[ 2u ] = StencilOperationLookupTable[ k ];
2590 // Build the parameter list.
2591 std::stringstream parameterStream;
2592 for( int parameterBuild = 0; parameterBuild < 3; ++parameterBuild )
2594 parameterStream << parameters[ parameterBuild ];
2595 // Comma-separate the parameters.
2596 if( parameterBuild < 2 )
2598 parameterStream << ", ";
2602 // Check the function was called and the parameters were correct.
2603 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
2611 int UtcDaliRendererSetStencilMask(void)
2613 TestApplication application;
2614 tet_infoline("Test setting the StencilMask");
2616 Renderer renderer = RendererTestFixture( application );
2617 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2618 glAbstraction.EnableEnableDisableCallTrace( true );
2619 glAbstraction.EnableStencilFunctionCallTrace( true );
2620 TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
2621 TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
2623 // RenderMode must use the stencil for StencilMask to operate.
2624 renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
2626 // Set the StencilMask property to a value.
2627 renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0x00 );
2629 // Check GetProperty returns the same value.
2630 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0x00, TEST_LOCATION );
2632 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2634 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0x00, TEST_LOCATION );
2636 std::string methodString( "StencilMask" );
2637 std::string parameterString = "0";
2639 // Check the function was called and the parameters were correct.
2640 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterString ) );
2642 // Set the StencilMask property to another value to ensure it has changed.
2643 renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0xFF );
2645 // Check GetProperty returns the same value.
2646 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2648 ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
2650 DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
2652 parameterString = "255";
2654 // Check the function was called and the parameters were correct.
2655 DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterString ) );
2660 int UtcDaliRendererWrongNumberOfTextures(void)
2662 TestApplication application;
2663 tet_infoline("Test renderer does render even if number of textures is different than active samplers in the shader");
2665 //Create a TextureSet with 4 textures (One more texture in the texture set than active samplers)
2666 //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
2667 Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64u, 64u );
2668 TextureSet textureSet = CreateTextureSet();
2669 textureSet.SetTexture(0, texture );
2670 textureSet.SetTexture(1, texture );
2671 textureSet.SetTexture(2, texture );
2672 textureSet.SetTexture(3, texture );
2673 Shader shader = Shader::New("VertexSource", "FragmentSource");
2674 Geometry geometry = CreateQuadGeometry();
2675 Renderer renderer = Renderer::New( geometry, shader );
2676 renderer.SetTextures( textureSet );
2678 Actor actor= Actor::New();
2679 actor.AddRenderer(renderer);
2680 actor.SetPosition(0.0f,0.0f);
2681 actor.SetSize(100, 100);
2682 Stage::GetCurrent().Add(actor);
2684 TestGlAbstraction& gl = application.GetGlAbstraction();
2685 TraceCallStack& drawTrace = gl.GetDrawTrace();
2687 drawTrace.Enable(true);
2689 application.SendNotification();
2690 application.Render(0);
2692 //Test we do the drawcall when TextureSet has more textures than there are active samplers in the shader
2693 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
2695 //Create a TextureSet with 1 texture (two more active samplers than texture in the texture set)
2696 //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
2697 textureSet = CreateTextureSet();
2698 renderer.SetTextures( textureSet );
2699 textureSet.SetTexture(0, texture );
2701 application.SendNotification();
2702 application.Render(0);
2704 //Test we do the drawcall when TextureSet has less textures than there are active samplers in the shader.
2705 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
2710 int UtcDaliRendererOpacity(void)
2712 TestApplication application;
2714 tet_infoline( "Test OPACITY property" );
2716 Geometry geometry = CreateQuadGeometry();
2717 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
2718 Renderer renderer = Renderer::New( geometry, shader );
2720 Actor actor = Actor::New();
2721 actor.AddRenderer( renderer );
2722 actor.SetSize( 400, 400 );
2723 actor.SetColor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
2724 Stage::GetCurrent().Add( actor );
2726 Property::Value value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2728 DALI_TEST_CHECK( value.Get( opacity ) );
2729 DALI_TEST_EQUALS( opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2731 application.SendNotification();
2732 application.Render();
2734 Vector4 actualValue;
2735 TestGlAbstraction& gl = application.GetGlAbstraction();
2736 DALI_TEST_CHECK( gl.GetUniformValue< Vector4 >( "uColor", actualValue ) );
2737 DALI_TEST_EQUALS( actualValue.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2739 renderer.SetProperty( DevelRenderer::Property::OPACITY, 0.5f );
2741 application.SendNotification();
2742 application.Render();
2744 value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2745 DALI_TEST_CHECK( value.Get( opacity ) );
2746 DALI_TEST_EQUALS( opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2748 value = renderer.GetCurrentProperty( DevelRenderer::Property::OPACITY );
2749 DALI_TEST_CHECK( value.Get( opacity ) );
2750 DALI_TEST_EQUALS( opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2752 DALI_TEST_CHECK( gl.GetUniformValue< Vector4 >( "uColor", actualValue ) );
2753 DALI_TEST_EQUALS( actualValue.a, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2758 int UtcDaliRendererOpacityAnimation(void)
2760 TestApplication application;
2762 tet_infoline( "Test OPACITY property animation" );
2764 Geometry geometry = CreateQuadGeometry();
2765 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
2766 Renderer renderer = Renderer::New( geometry, shader );
2768 Actor actor = Actor::New();
2769 actor.AddRenderer( renderer );
2770 actor.SetSize( 400, 400 );
2771 actor.SetColor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
2772 Stage::GetCurrent().Add( actor );
2774 application.SendNotification();
2775 application.Render(0);
2777 Property::Value value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2779 DALI_TEST_CHECK( value.Get( opacity ) );
2780 DALI_TEST_EQUALS( opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2782 Animation animation = Animation::New( 1.0f );
2783 animation.AnimateTo( Property( renderer, DevelRenderer::Property::OPACITY ), 0.0f );
2786 application.SendNotification();
2787 application.Render( 1000 );
2789 value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2790 DALI_TEST_CHECK( value.Get( opacity ) );
2791 DALI_TEST_EQUALS( opacity, 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2793 renderer.SetProperty( DevelRenderer::Property::OPACITY, 0.1f );
2796 animation.AnimateBy( Property( renderer, DevelRenderer::Property::OPACITY ), 0.5f );
2799 application.SendNotification();
2800 application.Render( 1000 );
2802 value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
2803 DALI_TEST_CHECK( value.Get( opacity ) );
2804 DALI_TEST_EQUALS( opacity, 0.6f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
2809 int UtcDaliRendererInvalidProperty(void)
2811 TestApplication application;
2813 tet_infoline( "Test invalid property" );
2815 Geometry geometry = CreateQuadGeometry();
2816 Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
2817 Renderer renderer = Renderer::New( geometry, shader );
2819 Actor actor = Actor::New();
2820 actor.AddRenderer( renderer );
2821 actor.SetSize( 400, 400 );
2822 Stage::GetCurrent().Add( actor );
2824 application.SendNotification();
2825 application.Render(0);
2827 Property::Value value = renderer.GetProperty( Renderer::Property::DEPTH_INDEX + 100 );
2828 DALI_TEST_CHECK( value.GetType() == Property::Type::NONE );
2830 value = renderer.GetCurrentProperty( Renderer::Property::DEPTH_INDEX + 100 );
2831 DALI_TEST_CHECK( value.GetType() == Property::Type::NONE );