/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// EXTERNAL INCLUDES
+#include <dali/devel-api/actors/actor-devel.h>
+#include <dali/devel-api/rendering/renderer-devel.h>
+
#include <dali/public-api/dali-core.h>
#include <dali/devel-api/images/texture-set-image.h>
+#include <dali/integration-api/render-task-list-integ.h>
#include <cstdio>
#include <string>
test_return_value = TET_PASS;
}
-
int UtcDaliRendererNew01(void)
{
TestApplication application;
END_TEST;
}
+// using a template to auto deduce the parameter types
+template< typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
+void TEST_RENDERER_PROPERTY( P1 renderer, P2 stringName, P3 type, P4 isWriteable, P5 isAnimateable, P6 isConstraintInput, P7 enumName, P8 LOCATION )
+{
+ DALI_TEST_EQUALS( renderer.GetPropertyName( enumName ), stringName, LOCATION );
+ DALI_TEST_EQUALS( renderer.GetPropertyIndex( stringName ), static_cast<Property::Index>(enumName), LOCATION );
+ DALI_TEST_EQUALS( renderer.GetPropertyType( enumName ), type, LOCATION );
+ DALI_TEST_EQUALS( renderer.IsPropertyWritable( enumName ), isWriteable, LOCATION );
+ DALI_TEST_EQUALS( renderer.IsPropertyAnimatable( enumName ), isAnimateable, LOCATION );
+ DALI_TEST_EQUALS( renderer.IsPropertyAConstraintInput( enumName ), isConstraintInput, LOCATION );
+}
+
+int UtcDaliRendererDefaultProperties(void)
+{
+ TestApplication application;
+/* from renderer-impl.cpp
+ DALI_PROPERTY( "depthIndex", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX )
+ DALI_PROPERTY( "faceCullingMode", INTEGER, true, false, false, Dali::Renderer::Property::FACE_CULLING_MODE )
+ DALI_PROPERTY( "blendMode", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_MODE )
+ DALI_PROPERTY( "blendEquationRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_RGB )
+ DALI_PROPERTY( "blendEquationAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA )
+ DALI_PROPERTY( "blendFactorSrcRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB )
+ DALI_PROPERTY( "blendFactorDestRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB )
+ DALI_PROPERTY( "blendFactorSrcAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA )
+ DALI_PROPERTY( "blendFactorDestAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA )
+ DALI_PROPERTY( "blendColor", VECTOR4, true, false, false, Dali::Renderer::Property::BLEND_COLOR )
+ DALI_PROPERTY( "blendPreMultipliedAlpha", BOOLEAN, true, false, false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA )
+ DALI_PROPERTY( "indexRangeFirst", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_FIRST )
+ DALI_PROPERTY( "indexRangeCount", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_COUNT )
+ DALI_PROPERTY( "depthWriteMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_WRITE_MODE )
+ DALI_PROPERTY( "depthFunction", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_FUNCTION )
+ DALI_PROPERTY( "depthTestMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_TEST_MODE )
+ DALI_PROPERTY( "renderMode", INTEGER, true, false, false, Dali::Renderer::Property::RENDER_MODE )
+ DALI_PROPERTY( "stencilFunction", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION )
+ DALI_PROPERTY( "stencilFunctionMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK )
+ DALI_PROPERTY( "stencilFunctionReference", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE )
+ DALI_PROPERTY( "stencilMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MASK )
+ DALI_PROPERTY( "stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL )
+ DALI_PROPERTY( "stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL )
+ DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS )
+ DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali::DevelRenderer::Property::OPACITY )
+ DALI_PROPERTY( "renderingBehavior", INTEGER, true, false, false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR )
+*/
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New(geometry, shader);
+ DALI_TEST_EQUALS( renderer.GetPropertyCount(), 26, TEST_LOCATION );
+
+ TEST_RENDERER_PROPERTY( renderer, "depthIndex", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_INDEX, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "faceCullingMode", Property::INTEGER, true, false, false, Renderer::Property::FACE_CULLING_MODE, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "blendMode", Property::INTEGER, true, false, false, Renderer::Property::BLEND_MODE, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "blendEquationRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_RGB, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "blendEquationAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_EQUATION_ALPHA, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "blendFactorSrcRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_RGB, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "blendFactorDestRgb", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_RGB, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "blendFactorSrcAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "blendFactorDestAlpha", Property::INTEGER, true, false, false, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "blendColor", Property::VECTOR4, true, false, false, Renderer::Property::BLEND_COLOR, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "blendPreMultipliedAlpha", Property::BOOLEAN, true, false, false, Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "indexRangeFirst", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_FIRST, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "indexRangeCount", Property::INTEGER, true, false, false, Renderer::Property::INDEX_RANGE_COUNT, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "depthWriteMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_WRITE_MODE, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "depthFunction", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_FUNCTION, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "depthTestMode", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_TEST_MODE, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "renderMode", Property::INTEGER, true, false, false, Renderer::Property::RENDER_MODE, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "stencilFunction", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "stencilFunctionMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_MASK, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "stencilFunctionReference",Property::INTEGER, true, false, false, Renderer::Property::STENCIL_FUNCTION_REFERENCE, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "stencilMask", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_MASK, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_FAIL, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnZFail", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "stencilOperationOnZPass", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "opacity", Property::FLOAT, true, true, true, DevelRenderer::Property::OPACITY, TEST_LOCATION );
+ TEST_RENDERER_PROPERTY( renderer, "renderingBehavior", Property::INTEGER, true, false, false, DevelRenderer::Property::RENDERING_BEHAVIOR, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliRendererSetGetGeometry(void)
{
TestApplication application;
renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
+ DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 0, TEST_LOCATION );
+
application.SendNotification();
application.Render(0);
- DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
renderer.SetProperty( Renderer::Property::DEPTH_INDEX, 10 );
+ DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 1, TEST_LOCATION );
+
application.SendNotification();
application.Render(0);
- DALI_TEST_EQUALS( renderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer.GetCurrentProperty<int>(Renderer::Property::DEPTH_INDEX), 10, TEST_LOCATION );
END_TEST;
}
END_TEST;
}
+int UtcDaliRendererSetBlendMode01b(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test setting the blend mode to on with an transparent color renders with blending enabled");
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New( geometry, shader );
+
+ Actor actor = Actor::New();
+ actor.SetOpacity( 0.0f );
+ actor.AddRenderer(renderer);
+ actor.SetSize(400, 400);
+ Stage::GetCurrent().Add(actor);
+
+ renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON);
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ glAbstraction.EnableEnableDisableCallTrace(true);
+ glAbstraction.EnableDrawCallTrace( true );
+
+ application.SendNotification();
+ application.Render();
+
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
+ std::ostringstream blendStr;
+ blendStr << GL_BLEND;
+ DALI_TEST_CHECK( !glEnableStack.FindMethod( "Enable" ) );
+
+ DALI_TEST_CHECK( !glAbstraction.GetDrawTrace().FindMethod( "DrawElements" ) );
+
+ END_TEST;
+}
+
int UtcDaliRendererSetBlendMode02(void)
{
TestApplication application;
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::TRANSPARENT );
+
application.SendNotification();
application.Render();
+
+ DALI_TEST_EQUALS( renderer.GetProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION );
DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION );
renderer.SetProperty( Renderer::Property::BLEND_COLOR, Color::MAGENTA );
+
+ DALI_TEST_EQUALS( renderer.GetProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::TRANSPARENT, TEST_LOCATION );
+
application.SendNotification();
application.Render();
+
+ DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >(Renderer::Property::BLEND_COLOR), Color::MAGENTA, TEST_LOCATION );
DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION );
Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
DALI_TEST_EQUALS( actualValue, Vector4(1.0f, 0.0f, 1.0f, 0.5f), TEST_LOCATION );
- renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
+ // Enable pre-multiplied alpha
+ renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true );
application.SendNotification();
application.Render();
DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
DALI_TEST_CHECK( preMultipliedAlpha );
+ value = renderer.GetCurrentProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
+ DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
+ DALI_TEST_CHECK( preMultipliedAlpha );
+
srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorRgb, TEST_LOCATION );
DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION );
DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION );
- DALI_TEST_EQUALS( (int)BlendFactor::ONE, destFactorAlpha, TEST_LOCATION );
+ DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION );
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
DALI_TEST_EQUALS( actualValue, Vector4(0.5f, 0.0f, 0.5f, 0.5f), TEST_LOCATION );
+ // Disable pre-multiplied alpha again
+ renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, false );
+
+ application.SendNotification();
+ application.Render();
+
+ value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
+ DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
+ DALI_TEST_CHECK( !preMultipliedAlpha );
+
+ value = renderer.GetCurrentProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
+ DALI_TEST_CHECK( value.Get( preMultipliedAlpha ) );
+ DALI_TEST_CHECK( !preMultipliedAlpha );
+
+ srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
+ destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
+ srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
+ destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
+
+ DALI_TEST_EQUALS( (int)BlendFactor::SRC_ALPHA, srcFactorRgb, TEST_LOCATION );
+ DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorRgb, TEST_LOCATION );
+ DALI_TEST_EQUALS( (int)BlendFactor::ONE, srcFactorAlpha, TEST_LOCATION );
+ DALI_TEST_EQUALS( (int)BlendFactor::ONE_MINUS_SRC_ALPHA, destFactorAlpha, TEST_LOCATION );
+
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uColor", actualValue ) );
+ DALI_TEST_EQUALS( actualValue, Vector4( 1.0f, 0.0f, 1.0f, 0.5f ), TEST_LOCATION );
+
END_TEST;
}
application.Render(0);
// Expect no blue component in either buffer - yellow
- DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::YELLOW, TEST_LOCATION );
application.Render(0);
- DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::YELLOW, TEST_LOCATION );
renderer.RemoveConstraints();
renderer.SetProperty(colorIndex, Color::WHITE );
application.SendNotification();
application.Render(0);
- DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::WHITE, TEST_LOCATION );
END_TEST;
}
application.SendNotification();
application.Render(500);
- DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::WHITE * 0.5f, TEST_LOCATION );
application.Render(500);
- DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
+ DALI_TEST_EQUALS( renderer.GetCurrentProperty< Vector4 >( colorIndex ), Color::TRANSPARENT, TEST_LOCATION );
END_TEST;
}
END_TEST;
}
+
+Renderer CreateRenderer( Actor actor, Geometry geometry, Shader shader, int depthIndex )
+{
+ Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
+ TextureSet textureSet0 = CreateTextureSet( image0 );
+ Renderer renderer0 = Renderer::New( geometry, shader );
+ renderer0.SetTextures( textureSet0 );
+ renderer0.SetProperty( Renderer::Property::DEPTH_INDEX, depthIndex );
+ actor.AddRenderer(renderer0);
+ return renderer0;
+}
+
+
+Actor CreateActor( Actor parent, int siblingOrder, const char* location )
+{
+ Actor actor = Actor::New();
+ actor.SetAnchorPoint(AnchorPoint::CENTER);
+ actor.SetParentOrigin(AnchorPoint::CENTER);
+ actor.SetPosition(0.0f,0.0f);
+ actor.SetSize(100, 100);
+ parent.Add(actor);
+ actor.SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, siblingOrder );
+ DALI_TEST_EQUALS( actor.GetProperty<int>( Dali::DevelActor::Property::SIBLING_ORDER), siblingOrder, TEST_INNER_LOCATION(location) );
+
+ return actor;
+}
+
int UtcDaliRendererRenderOrder2DLayer(void)
{
TestApplication application;
Shader shader = Shader::New("VertexSource", "FragmentSource");
Geometry geometry = CreateQuadGeometry();
- Actor actor0 = Actor::New();
- actor0.SetAnchorPoint(AnchorPoint::CENTER);
- actor0.SetParentOrigin(AnchorPoint::CENTER);
- actor0.SetPosition(0.0f,0.0f);
- Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet0 = CreateTextureSet( image0 );
- Renderer renderer0 = Renderer::New( geometry, shader );
- renderer0.SetTextures( textureSet0 );
- actor0.AddRenderer(renderer0);
- actor0.SetSize(1, 1);
- Stage::GetCurrent().Add(actor0);
- application.SendNotification();
- application.Render(0);
+ Actor root = Stage::GetCurrent().GetRootLayer();
- Actor actor1 = Actor::New();
- actor1.SetAnchorPoint(AnchorPoint::CENTER);
- actor1.SetParentOrigin(AnchorPoint::CENTER);
- actor1.SetPosition(0.0f,0.0f);
- Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet1 = CreateTextureSet( image1 );
- Renderer renderer1 = Renderer::New( geometry, shader );
- renderer1.SetTextures( textureSet1 );
- actor1.AddRenderer(renderer1);
- actor1.SetSize(1, 1);
- Stage::GetCurrent().Add(actor1);
- application.SendNotification();
- application.Render(0);
+ Actor actor0 = CreateActor( root, 0, TEST_LOCATION );
+ Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 0 );
- Actor actor2 = Actor::New();
- actor2.SetAnchorPoint(AnchorPoint::CENTER);
- actor2.SetParentOrigin(AnchorPoint::CENTER);
- actor2.SetPosition(0.0f,0.0f);
- Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet2 = CreateTextureSet( image2 );
- Renderer renderer2 = Renderer::New( geometry, shader );
- renderer2.SetTextures( textureSet2 );
- actor2.AddRenderer(renderer2);
- actor2.SetSize(1, 1);
- Stage::GetCurrent().Add(actor2);
- application.SendNotification();
- application.Render(0);
+ Actor actor1 = CreateActor( root, 0, TEST_LOCATION );
+ Renderer renderer1 = CreateRenderer( actor1, geometry, shader, 0 );
+
+ Actor actor2 = CreateActor( root, 0, TEST_LOCATION );
+ Renderer renderer2 = CreateRenderer( actor2, geometry, shader, 0 );
+
+ Actor actor3 = CreateActor( root, 0, TEST_LOCATION );
+ Renderer renderer3 = CreateRenderer( actor3, geometry, shader, 0 );
- Actor actor3 = Actor::New();
- actor3.SetAnchorPoint(AnchorPoint::CENTER);
- actor3.SetParentOrigin(AnchorPoint::CENTER);
- actor3.SetPosition(0.0f,0.0f);
- Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet3 = CreateTextureSet( image3 );
- Renderer renderer3 = Renderer::New( geometry, shader );
- renderer3.SetTextures( textureSet3 );
- actor3.AddRenderer(renderer3);
- actor3.SetSize(1, 1);
- Stage::GetCurrent().Add(actor3);
application.SendNotification();
application.Render(0);
Shader shader = Shader::New("VertexSource", "FragmentSource");
Geometry geometry = CreateQuadGeometry();
- Actor actor0 = Actor::New();
- actor0.SetAnchorPoint(AnchorPoint::CENTER);
- actor0.SetParentOrigin(AnchorPoint::CENTER);
- actor0.SetPosition(0.0f,0.0f);
- actor0.SetSize(1, 1);
- Stage::GetCurrent().Add(actor0);
-
- Actor actor1 = Actor::New();
- actor1.SetAnchorPoint(AnchorPoint::CENTER);
- actor1.SetParentOrigin(AnchorPoint::CENTER);
- actor1.SetPosition(0.0f,0.0f);
- actor1.SetSize(1, 1);
- actor0.Add(actor1);
-
- //Renderer0
- Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet0 = CreateTextureSet( image0 );
- Renderer renderer0 = Renderer::New( geometry, shader );
- renderer0.SetTextures( textureSet0 );
- renderer0.SetProperty( Renderer::Property::DEPTH_INDEX, 2 );
- actor0.AddRenderer(renderer0);
- application.SendNotification();
- application.Render(0);
-
- //Renderer1
- Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet1 = CreateTextureSet( image1 );
- Renderer renderer1 = Renderer::New( geometry, shader );
- renderer1.SetTextures( textureSet1 );
- renderer1.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
- actor0.AddRenderer(renderer1);
- application.SendNotification();
- application.Render(0);
-
- //Renderer2
- Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet2 = CreateTextureSet( image2 );
- Renderer renderer2 = Renderer::New( geometry, shader );
- renderer2.SetTextures( textureSet2 );
- renderer2.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
- actor0.AddRenderer(renderer2);
- application.SendNotification();
- application.Render(0);
-
- //Renderer3
- Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet3 = CreateTextureSet( image3 );
- Renderer renderer3 = Renderer::New( geometry, shader );
- renderer3.SetTextures( textureSet3 );
- renderer3.SetProperty( Renderer::Property::DEPTH_INDEX, 1 );
- actor1.AddRenderer(renderer3);
- application.SendNotification();
- application.Render(0);
+ Actor root = Stage::GetCurrent().GetRootLayer();
- //Renderer4
- Image image4= BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet4 = CreateTextureSet( image4 );
- Renderer renderer4 = Renderer::New( geometry, shader );
- renderer4.SetTextures( textureSet4 );
- renderer4.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
- actor1.AddRenderer(renderer4);
- application.SendNotification();
- application.Render(0);
+ Actor actor0 = CreateActor( root, 0, TEST_LOCATION );
+ Actor actor1 = CreateActor( actor0, 0, TEST_LOCATION );
+ Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 2 );
+ Renderer renderer1 = CreateRenderer( actor0, geometry, shader, 0 );
+ Renderer renderer2 = CreateRenderer( actor0, geometry, shader, 1 );
+ Renderer renderer3 = CreateRenderer( actor1, geometry, shader, 1 );
+ Renderer renderer4 = CreateRenderer( actor1, geometry, shader, 0 );
+ Renderer renderer5 = CreateRenderer( actor1, geometry, shader, -1 );
- //Renderer5
- Image image5= BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet5 = CreateTextureSet( image5 );
- Renderer renderer5 = Renderer::New( geometry, shader );
- renderer5.SetTextures( textureSet5 );
- renderer5.SetProperty( Renderer::Property::DEPTH_INDEX, -1 );
- actor1.AddRenderer(renderer5);
application.SendNotification();
application.Render(0);
-
TestGlAbstraction& gl = application.GetGlAbstraction();
gl.EnableTextureCallTrace(true);
application.SendNotification();
//Check that renderer0 has been rendered after renderer2
DALI_TEST_GREATER( textureBindIndex[4], textureBindIndex[5], TEST_LOCATION );
- //Check that renderer0 has been rendered after renderer2
+ //Check that renderer5 has been rendered after renderer2
DALI_TEST_GREATER( textureBindIndex[5], textureBindIndex[0], TEST_LOCATION );
//Check that renderer0 has been rendered after renderer2
END_TEST;
}
-int UtcDaliRendererRenderOrder2DLayerOverlay(void)
+
+int UtcDaliRendererRenderOrder2DLayerSiblingOrder(void)
{
TestApplication application;
- tet_infoline("Test the rendering order in a 2D layer is correct for overlays");
+ tet_infoline("Test the rendering order in a 2D layer is correct using sibling order");
+
+ /*
+ * Creates the following hierarchy:
+ *
+ * Layer
+ * / \
+ * / \
+ * / \
+ * / \
+ * / \
+ * actor0 (SIBLING_ORDER:1) actor1 (SIBLING_ORDER:0)
+ * / | \ / | \
+ * / | \ / | \
+ * / | \ / | \
+ * renderer0 renderer1 actor2 renderer2 renderer3 renderer4
+ * DI:2 DI:0 | DI:0 DI:1 DI:2
+ * |
+ * renderer5
+ * DI:-1
+ *
+ * actor0 has sibling order 1
+ * actor1 has sibling order 0
+ * actor2 has sibling order 0
+ *
+ * renderer0 has depth index 2
+ * renderer1 has depth index 0
+ *
+ * renderer2 has depth index 0
+ * renderer3 has depth index 1
+ * renderer4 has depth index 2
+ *
+ * renderer5 has depth index -1
+ *
+ * Expected rendering order: renderer2 - renderer3 - renderer4 - renderer1 - renderer0 - renderer5
+ */
Shader shader = Shader::New("VertexSource", "FragmentSource");
Geometry geometry = CreateQuadGeometry();
+ Actor root = Stage::GetCurrent().GetRootLayer();
+ Actor actor0 = CreateActor( root, 1, TEST_LOCATION );
+ Actor actor1 = CreateActor( root, 0, TEST_LOCATION );
+ Actor actor2 = CreateActor( actor0, 0, TEST_LOCATION );
- Actor actor0 = Actor::New();
- actor0.SetAnchorPoint(AnchorPoint::CENTER);
- actor0.SetParentOrigin(AnchorPoint::CENTER);
- Image image0 = BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet0 = CreateTextureSet( image0 );
- Renderer renderer0 = Renderer::New( geometry, shader );
- renderer0.SetTextures( textureSet0 );
- actor0.AddRenderer(renderer0);
- actor0.SetPosition(0.0f,0.0f);
- actor0.SetSize(100, 100);
- Stage::GetCurrent().Add(actor0);
- actor0.SetDrawMode( DrawMode::OVERLAY_2D );
- application.SendNotification();
- application.Render(0);
+ Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 2 );
+ Renderer renderer1 = CreateRenderer( actor0, geometry, shader, 0 );
+ Renderer renderer2 = CreateRenderer( actor1, geometry, shader, 0 );
+ Renderer renderer3 = CreateRenderer( actor1, geometry, shader, 1 );
+ Renderer renderer4 = CreateRenderer( actor1, geometry, shader, 2 );
+ Renderer renderer5 = CreateRenderer( actor2, geometry, shader, -1 );
- Actor actor1 = Actor::New();
- actor1.SetAnchorPoint(AnchorPoint::CENTER);
- actor1.SetParentOrigin(AnchorPoint::CENTER);
- Image image1= BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet1 = CreateTextureSet( image1 );
- Renderer renderer1 = Renderer::New( geometry, shader );
- renderer1.SetTextures( textureSet1 );
- actor1.SetPosition(0.0f,0.0f);
- actor1.AddRenderer(renderer1);
- actor1.SetSize(100, 100);
- Stage::GetCurrent().Add(actor1);
- actor1.SetDrawMode( DrawMode::OVERLAY_2D );
application.SendNotification();
- application.Render(0);
+ application.Render();
- Actor actor2 = Actor::New();
- actor2.SetAnchorPoint(AnchorPoint::CENTER);
- actor2.SetParentOrigin(AnchorPoint::CENTER);
- Image image2= BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet2 = CreateTextureSet( image2 );
- Renderer renderer2 = Renderer::New( geometry, shader );
- renderer2.SetTextures( textureSet2 );
- actor2.AddRenderer(renderer2);
- actor2.SetPosition(0.0f,0.0f);
- actor2.SetSize(100, 100);
- Stage::GetCurrent().Add(actor2);
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ gl.EnableTextureCallTrace(true);
application.SendNotification();
application.Render(0);
- Actor actor3 = Actor::New();
- actor3.SetAnchorPoint(AnchorPoint::CENTER);
- actor3.SetParentOrigin(AnchorPoint::CENTER);
- Image image3 = BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet3 = CreateTextureSet( image3 );
- Renderer renderer3 = Renderer::New( geometry, shader );
- renderer3.SetTextures( textureSet3 );
- actor3.SetPosition(0.0f,0.0f);
- actor3.AddRenderer(renderer3);
- actor3.SetSize(100, 100);
- Stage::GetCurrent().Add(actor3);
- actor3.SetDrawMode( DrawMode::OVERLAY_2D );
- application.SendNotification();
- application.Render(0);
+ int textureBindIndex[6];
+ for( unsigned int i(0); i<6; ++i )
+ {
+ std::stringstream params;
+ params << GL_TEXTURE_2D<<", "<<i+1;
+ textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
+ }
+
+ DALI_TEST_EQUALS( textureBindIndex[2], 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureBindIndex[3], 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureBindIndex[4], 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureBindIndex[1], 3, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureBindIndex[0], 4, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureBindIndex[5], 5, TEST_LOCATION );
- Actor actor4 = Actor::New();
- actor4.SetAnchorPoint(AnchorPoint::CENTER);
- actor4.SetParentOrigin(AnchorPoint::CENTER);
- Image image4 = BufferImage::New( 64, 64, Pixel::RGB888 );
- TextureSet textureSet4 = CreateTextureSet( image4 );
- Renderer renderer4 = Renderer::New( geometry, shader );
- renderer4.SetTextures( textureSet4 );
- actor4.AddRenderer(renderer4);
- actor4.SetPosition(0.0f,0.0f);
- actor4.SetSize(100, 100);
- Stage::GetCurrent().Add(actor4);
+ // Change sibling order of actor1
+ // New Expected rendering order: renderer1 - renderer0 - renderer 5 - renderer2 - renderer3 - renderer4
+ actor1.SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, 2 );
+
+ gl.GetTextureTrace().Reset();
application.SendNotification();
application.Render(0);
+ for( unsigned int i(0); i<6; ++i )
+ {
+ std::stringstream params;
+ params << GL_TEXTURE_2D<<", "<<i+1;
+ textureBindIndex[i] = gl.GetTextureTrace().FindIndexFromMethodAndParams("BindTexture", params.str() );
+ }
+
+ DALI_TEST_EQUALS( textureBindIndex[1], 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureBindIndex[0], 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureBindIndex[5], 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureBindIndex[2], 3, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureBindIndex[3], 4, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureBindIndex[4], 5, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererRenderOrder2DLayerOverlay(void)
+{
+ TestApplication application;
+ tet_infoline("Test the rendering order in a 2D layer is correct for overlays");
+
+ Shader shader = Shader::New("VertexSource", "FragmentSource");
+ Geometry geometry = CreateQuadGeometry();
+ Actor root = Stage::GetCurrent().GetRootLayer();
+
/*
* Create the following hierarchy:
*
*
* Expected rendering order : actor2 - actor4 - actor1 - actor0 - actor3
*/
- Stage::GetCurrent().Add( actor2 );
+
+ Actor actor0 = CreateActor( root, 0, TEST_LOCATION );
+ actor0.SetDrawMode( DrawMode::OVERLAY_2D );
+ Renderer renderer0 = CreateRenderer( actor0, geometry, shader, 0 );
+
+ Actor actor1 = CreateActor( root, 0, TEST_LOCATION );
+ actor1.SetDrawMode( DrawMode::OVERLAY_2D );
+ Renderer renderer1 = CreateRenderer( actor1, geometry, shader, 0 );
+
+ Actor actor2 = CreateActor( root, 0, TEST_LOCATION );
+ Renderer renderer2 = CreateRenderer( actor2, geometry, shader, 0 );
+
+ Actor actor3 = CreateActor( root, 0, TEST_LOCATION );
+ actor3.SetDrawMode( DrawMode::OVERLAY_2D );
+ Renderer renderer3 = CreateRenderer( actor3, geometry, shader, 0 );
+
+ Actor actor4 = CreateActor( root, 0, TEST_LOCATION );
+ Renderer renderer4 = CreateRenderer( actor4, geometry, shader, 0 );
+
+ application.SendNotification();
+ application.Render(0);
+
actor2.Add(actor1);
actor2.Add(actor4);
actor1.Add(actor0);
actor0.Add(actor3);
- application.SendNotification();
- application.Render(0);
TestGlAbstraction& gl = application.GetGlAbstraction();
gl.EnableTextureCallTrace(true);
renderer.SetIndexRange( 0, 5 );
application.SendNotification();
application.Render();
+
+ Property::Value value = renderer.GetProperty( Renderer::Property::INDEX_RANGE_FIRST );
+ int convertedValue;
+ DALI_TEST_CHECK( value.Get( convertedValue ) );
+ DALI_TEST_CHECK( convertedValue == 0 );
+
+ value = renderer.GetCurrentProperty( Renderer::Property::INDEX_RANGE_FIRST );
+ DALI_TEST_CHECK( value.Get( convertedValue ) );
+ DALI_TEST_CHECK( convertedValue == 0 );
+
+ value = renderer.GetProperty( Renderer::Property::INDEX_RANGE_COUNT );
+ DALI_TEST_CHECK( value.Get( convertedValue ) );
+ DALI_TEST_CHECK( convertedValue == 5 );
+
+ value = renderer.GetCurrentProperty( Renderer::Property::INDEX_RANGE_COUNT );
+ DALI_TEST_CHECK( value.Get( convertedValue ) );
+ DALI_TEST_CHECK( convertedValue == 5 );
+
sprintf( buffer, "%u, 5, %u, indices", GL_LINE_LOOP, GL_UNSIGNED_SHORT );
bool result = gl.GetDrawTrace().FindMethodAndParams( "DrawElements" , buffer );
DALI_TEST_CHECK( result );
END_TEST;
}
+/**
+ * @brief This templatized function checks an enumeration property is setting and getting correctly.
+ * The checks performed are as follows:
+ * - Check the initial/default value.
+ * - Set a different value via enum.
+ * - Check it was set.
+ * - Set a different value via string.
+ * - Check it was set.
+ */
+template< typename T >
+void CheckEnumerationProperty( TestApplication& application, Renderer& renderer, Property::Index propertyIndex, T initialValue, T firstCheckEnumeration, T secondCheckEnumeration, std::string secondCheckString )
+{
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( initialValue ) );
+ DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast<int>( initialValue ) );
+ renderer.SetProperty( propertyIndex, firstCheckEnumeration );
+ DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
+ DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) != static_cast<int>( firstCheckEnumeration ) );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
+ DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast<int>( firstCheckEnumeration ) );
+
+ renderer.SetProperty( propertyIndex, secondCheckString );
+ DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
+ DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) != static_cast<int>( secondCheckEnumeration ) );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( renderer.GetProperty<int>( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
+ DALI_TEST_CHECK( renderer.GetCurrentProperty< int >( propertyIndex ) == static_cast<int>( secondCheckEnumeration ) );
+}
+
+int UtcDaliRendererEnumProperties(void)
+{
+ TestApplication application;
+ tet_infoline( "Test Renderer enumeration properties can be set with both integer and string values" );
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = CreateShader();
+ Renderer renderer = Renderer::New( geometry, shader );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetSize(400, 400);
+ Stage::GetCurrent().Add(actor);
+
+ /*
+ * Here we use a templatized function to perform several checks on each enumeration property.
+ * @see CheckEnumerationProperty for details of the checks performed.
+ */
+
+ CheckEnumerationProperty< FaceCullingMode::Type >( application, renderer, Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::NONE, FaceCullingMode::FRONT, FaceCullingMode::BACK, "BACK" );
+ CheckEnumerationProperty< BlendMode::Type >( application, renderer, Renderer::Property::BLEND_MODE, BlendMode::AUTO, BlendMode::OFF, BlendMode::ON, "ON" );
+ CheckEnumerationProperty< BlendEquation::Type >( application, renderer, Renderer::Property::BLEND_EQUATION_RGB, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" );
+ CheckEnumerationProperty< BlendEquation::Type >( application, renderer, Renderer::Property::BLEND_EQUATION_ALPHA, BlendEquation::ADD, BlendEquation::SUBTRACT, BlendEquation::REVERSE_SUBTRACT, "REVERSE_SUBTRACT" );
+ CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
+ CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
+ CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::SRC_COLOR, "SRC_COLOR" );
+ CheckEnumerationProperty< BlendFactor::Type >( application, renderer, Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::SRC_COLOR, "SRC_COLOR" );
+ CheckEnumerationProperty< DepthWriteMode::Type >( application, renderer, Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::AUTO, DepthWriteMode::OFF, DepthWriteMode::ON, "ON" );
+ CheckEnumerationProperty< DepthFunction::Type >( application, renderer, Renderer::Property::DEPTH_FUNCTION, DepthFunction::LESS, DepthFunction::ALWAYS, DepthFunction::GREATER, "GREATER" );
+ CheckEnumerationProperty< DepthTestMode::Type >( application, renderer, Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::AUTO, DepthTestMode::OFF, DepthTestMode::ON, "ON" );
+ CheckEnumerationProperty< StencilFunction::Type >( application, renderer, Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS, StencilFunction::LESS, StencilFunction::EQUAL, "EQUAL" );
+ CheckEnumerationProperty< RenderMode::Type >( application, renderer, Renderer::Property::RENDER_MODE, RenderMode::AUTO, RenderMode::NONE, RenderMode::STENCIL, "STENCIL" );
+ CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
+ CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
+ CheckEnumerationProperty< StencilOperation::Type >( application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT" );
+
+ END_TEST;
+}
+
Renderer RendererTestFixture( TestApplication& application )
{
Geometry geometry = CreateQuadGeometry();
DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
DALI_TEST_CHECK( !glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
- // Change the layer behavior to LAYER_2D.
+ // Change the layer behavior to LAYER_UI.
// Note this will also disable depth testing for the layer by default, we test this first.
- Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_2D );
+ Stage::GetCurrent().GetRootLayer().SetBehavior( Layer::LAYER_UI );
glEnableDisableStack.Reset();
application.SendNotification();
// Check depth-test is disabled.
DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
- // Turn the layer depth-test flag back on, and confirm that depth testing is *still* off.
- // This is because our renderer has DepthTestMode::AUTO and our layer behavior is LAYER_2D.
+ // Turn the layer depth-test flag back on, and confirm that depth testing is now on.
Stage::GetCurrent().GetRootLayer().SetDepthTestDisabled( false );
glEnableDisableStack.Reset();
application.Render();
// Check depth-test is *still* disabled.
- DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Disable", GetDepthTestString() ) );
+ DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetDepthTestString() ) );
END_TEST;
}
END_TEST;
}
-int UtcDaliRendererSetStencilMode(void)
+int UtcDaliRendererSetRenderModeToUseStencilBuffer(void)
{
TestApplication application;
- tet_infoline("Test setting the StencilMode");
+ tet_infoline("Test setting the RenderMode to use the stencil buffer");
Renderer renderer = RendererTestFixture( application );
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
+ // Set the StencilFunction to something other than the default, to confirm it is set as a property,
+ // but NO GL call has been made while the RenderMode is set to not use the stencil buffer.
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::NONE );
ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
- // Set the StencilFunction to something other than the default, to confirm it is set as a property,
- // but NO GL call has been made while the StencilMode is set to OFF.
renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::NEVER );
DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_FUNCTION ).Get<int>() ), static_cast<int>( StencilFunction::NEVER ), TEST_LOCATION );
- ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+ ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
std::string methodString( "StencilFunc" );
DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
- // Now set the StencilMode to ON and check the StencilFunction has changed.
- renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
+ // Test the other RenderModes that will not enable the stencil buffer.
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::AUTO );
+ ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+ DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
+
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
+ ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+ DALI_TEST_CHECK( !glStencilFunctionStack.FindMethod( methodString ) );
+
+ // Now set the RenderMode to modes that will use the stencil buffer, and check the StencilFunction has changed.
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
+ ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+
+ DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
+ DALI_TEST_CHECK( glStencilFunctionStack.FindMethod( methodString ) );
+
+ // Test the COLOR_STENCIL RenderMode as it also enables the stencil buffer.
+ // First set a mode to turn off the stencil buffer, so the enable is required.
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR );
+ ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::COLOR_STENCIL );
+ // Set a different stencil function as the last one is cached.
+ renderer.SetProperty( Renderer::Property::STENCIL_FUNCTION, StencilFunction::ALWAYS );
ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
DALI_TEST_CHECK( glEnableDisableStack.FindMethodAndParams( "Enable", GetStencilTestString() ) );
END_TEST;
}
+// Helper function for the SetRenderModeToUseColorBuffer test.
+void CheckRenderModeColorMask( TestApplication& application, Renderer& renderer, RenderMode::Type renderMode, bool expectedValue )
+{
+ // Set the RenderMode property to a value that should not allow color buffer writes.
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, renderMode );
+ application.SendNotification();
+ application.Render();
+
+ // Check if ColorMask has been called, and that the values are correct.
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ const TestGlAbstraction::ColorMaskParams& colorMaskParams( glAbstraction.GetColorMaskParams() );
+
+ DALI_TEST_EQUALS<bool>( colorMaskParams.red, expectedValue, TEST_LOCATION );
+ DALI_TEST_EQUALS<bool>( colorMaskParams.green, expectedValue, TEST_LOCATION );
+ DALI_TEST_EQUALS<bool>( colorMaskParams.blue, expectedValue, TEST_LOCATION );
+ DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, expectedValue, TEST_LOCATION );
+}
+
+int UtcDaliRendererSetRenderModeToUseColorBuffer(void)
+{
+ TestApplication application;
+ tet_infoline("Test setting the RenderMode to use the color buffer");
+
+ Renderer renderer = RendererTestFixture( application );
+
+ // Set the RenderMode property to a value that should not allow color buffer writes.
+ // Then check if ColorMask has been called, and that the values are correct.
+ CheckRenderModeColorMask( application, renderer, RenderMode::AUTO, true );
+ CheckRenderModeColorMask( application, renderer, RenderMode::NONE, false );
+ CheckRenderModeColorMask( application, renderer, RenderMode::COLOR, true );
+ CheckRenderModeColorMask( application, renderer, RenderMode::STENCIL, false );
+ CheckRenderModeColorMask( application, renderer, RenderMode::COLOR_STENCIL, true );
+
+ END_TEST;
+}
+
int UtcDaliRendererSetStencilFunction(void)
{
TestApplication application;
TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
- // StencilMode must be ON for StencilFunction to operate.
- renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
+ // RenderMode must use the stencil for StencilFunction to operate.
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
/*
ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+ DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_FUNCTION_REFERENCE ).Get<int>() ), testValueReference, TEST_LOCATION );
+
std::stringstream parameterStream;
parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", 255";
ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+ DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_FUNCTION_MASK ).Get<int>() ), testValueMask, TEST_LOCATION );
+
// Clear the stringstream.
parameterStream.str( std::string() );
parameterStream << StencilFunctionLookupTable[ StencilOperation::DECREMENT_WRAP ] << ", " << testValueReference << ", " << testValueMask;
TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
- // StencilMode must be ON for StencilOperation to operate.
- renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
+ // RenderMode must use the stencil for StencilOperation to operate.
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
/*
* Lookup table for testing StencilOperation.
}; const int StencilOperationLookupTableCount = sizeof( StencilOperationLookupTable ) / sizeof( StencilOperationLookupTable[0] );
// Set all 3 StencilOperation properties to a default.
- renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::ZERO );
+ renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, StencilOperation::KEEP );
renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::ZERO );
renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::ZERO );
* - Checks the correct parameters to "glStencilFunc" were used
* - Checks the above for all 3 parameter placements of StencilOperation ( OnFail, OnZFail, OnPass )
*/
- int stencilOperationPropertyKeys[] = { Renderer::Property::STENCIL_OPERATION_ON_FAIL, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS };
std::string methodString( "StencilOp" );
- for( int parameterIndex = 0; parameterIndex < 3; ++parameterIndex )
+ for( int i = 0; i < StencilOperationLookupTableCount; ++i )
{
- for( int i = 0; i < StencilOperationLookupTableCount; ++i )
+ for( int j = 0; j < StencilOperationLookupTableCount; ++j )
{
- // Set the property (outer loop causes all 3 different properties to be set separately).
- renderer.SetProperty( stencilOperationPropertyKeys[ parameterIndex ], static_cast<Dali::StencilFunction::Type>( i ) );
-
- // Check GetProperty returns the same value.
- DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( stencilOperationPropertyKeys[ parameterIndex ] ).Get<int>() ), i, TEST_LOCATION );
-
- // Reset the trace debug.
- ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
-
- // Check the function is called and the parameters are correct.
- // Set the expected parameter value at its correct index (only)
- parameters[ parameterIndex ] = StencilOperationLookupTable[ i ];
-
- // Build the parameter list.
- std::stringstream parameterStream;
- for( int parameterBuild = 0; parameterBuild < 3; ++parameterBuild )
+ for( int k = 0; k < StencilOperationLookupTableCount; ++k )
{
- parameterStream << parameters[ parameterBuild ];
- // Comma-separate the parameters.
- if( parameterBuild < 2 )
+ // Set the property (outer loop causes all 3 different properties to be set separately).
+ renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL, static_cast<Dali::StencilFunction::Type>( i ) );
+ renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, static_cast<Dali::StencilFunction::Type>( j ) );
+ renderer.SetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, static_cast<Dali::StencilFunction::Type>( k ) );
+
+ // Check GetProperty returns the same value.
+ DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_FAIL ).Get<int>() ), i, TEST_LOCATION );
+ DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL ).Get<int>() ), j, TEST_LOCATION );
+ DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetProperty( Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ).Get<int>() ), k, TEST_LOCATION );
+
+ // Reset the trace debug.
+ ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+
+ // Check the function is called and the parameters are correct.
+ // Set the expected parameter value at its correct index (only)
+ parameters[ 0u ] = StencilOperationLookupTable[ i ];
+ parameters[ 1u ] = StencilOperationLookupTable[ j ];
+ parameters[ 2u ] = StencilOperationLookupTable[ k ];
+
+ // Build the parameter list.
+ std::stringstream parameterStream;
+ for( int parameterBuild = 0; parameterBuild < 3; ++parameterBuild )
{
- parameterStream << ", ";
+ parameterStream << parameters[ parameterBuild ];
+ // Comma-separate the parameters.
+ if( parameterBuild < 2 )
+ {
+ parameterStream << ", ";
+ }
}
- }
- // Check the function was called and the parameters were correct.
- DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
+ // Check the function was called and the parameters were correct.
+ DALI_TEST_CHECK( glStencilFunctionStack.FindMethodAndParams( methodString, parameterStream.str() ) );
+ }
}
}
TraceCallStack& glEnableDisableStack = glAbstraction.GetEnableDisableTrace();
TraceCallStack& glStencilFunctionStack = glAbstraction.GetStencilFunctionTrace();
- // StencilMode must be ON for StencilMask to operate.
- renderer.SetProperty( Renderer::Property::STENCIL_MODE, StencilMode::ON );
+ // RenderMode must use the stencil for StencilMask to operate.
+ renderer.SetProperty( Renderer::Property::RENDER_MODE, RenderMode::STENCIL );
// Set the StencilMask property to a value.
renderer.SetProperty( Renderer::Property::STENCIL_MASK, 0x00 );
ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+ DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0x00, TEST_LOCATION );
+
std::string methodString( "StencilMask" );
std::string parameterString = "0";
ResetDebugAndFlush( application, glEnableDisableStack, glStencilFunctionStack );
+ DALI_TEST_EQUALS<int>( static_cast<int>( renderer.GetCurrentProperty( Renderer::Property::STENCIL_MASK ).Get<int>() ), 0xFF, TEST_LOCATION );
+
parameterString = "255";
// Check the function was called and the parameters were correct.
END_TEST;
}
-int UtcDaliRendererSetWriteToColorBuffer(void)
+int UtcDaliRendererWrongNumberOfTextures(void)
{
TestApplication application;
- tet_infoline("Test setting the WriteToColorBuffer flag");
+ tet_infoline("Test renderer does render even if number of textures is different than active samplers in the shader");
+
+ //Create a TextureSet with 4 textures (One more texture in the texture set than active samplers)
+ //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64u, 64u );
+ TextureSet textureSet = CreateTextureSet();
+ textureSet.SetTexture(0, texture );
+ textureSet.SetTexture(1, texture );
+ textureSet.SetTexture(2, texture );
+ textureSet.SetTexture(3, texture );
+ Shader shader = Shader::New("VertexSource", "FragmentSource");
+ Geometry geometry = CreateQuadGeometry();
+ Renderer renderer = Renderer::New( geometry, shader );
+ renderer.SetTextures( textureSet );
- Renderer renderer = RendererTestFixture( application );
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ Actor actor= Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetPosition(0.0f,0.0f);
+ actor.SetSize(100, 100);
+ Stage::GetCurrent().Add(actor);
- // Set the StencilMask property to a value.
- renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, false );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Reset();
+ drawTrace.Enable(true);
- // Check GetProperty returns the same value.
- DALI_TEST_CHECK( !renderer.GetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER ).Get<bool>() );
+ application.SendNotification();
+ application.Render(0);
+
+ //Test we do the drawcall when TextureSet has more textures than there are active samplers in the shader
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
+
+ //Create a TextureSet with 1 texture (two more active samplers than texture in the texture set)
+ //@note Shaders in the test suit have 3 active samplers. See TestGlAbstraction::GetActiveUniform()
+ textureSet = CreateTextureSet();
+ renderer.SetTextures( textureSet );
+ textureSet.SetTexture(0, texture );
+ drawTrace.Reset();
+ application.SendNotification();
+ application.Render(0);
+
+ //Test we do the drawcall when TextureSet has less textures than there are active samplers in the shader.
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererOpacity(void)
+{
+ TestApplication application;
+
+ tet_infoline( "Test OPACITY property" );
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
+ Renderer renderer = Renderer::New( geometry, shader );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer( renderer );
+ actor.SetSize( 400, 400 );
+ actor.SetColor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
+ Stage::GetCurrent().Add( actor );
+
+ Property::Value value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
+ float opacity;
+ DALI_TEST_CHECK( value.Get( opacity ) );
+ DALI_TEST_EQUALS( opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
application.SendNotification();
application.Render();
- // Check if ColorMask has been called, and that the values are correct.
- const TestGlAbstraction::ColorMaskParams& colorMaskParams( glAbstraction.GetColorMaskParams() );
+ Vector4 actualValue;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ DALI_TEST_CHECK( gl.GetUniformValue< Vector4 >( "uColor", actualValue ) );
+ DALI_TEST_EQUALS( actualValue.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
- DALI_TEST_EQUALS<bool>( colorMaskParams.red, false, TEST_LOCATION );
- DALI_TEST_EQUALS<bool>( colorMaskParams.green, false, TEST_LOCATION );
- DALI_TEST_EQUALS<bool>( colorMaskParams.blue, false, TEST_LOCATION );
- DALI_TEST_EQUALS<bool>( colorMaskParams.alpha, false, TEST_LOCATION );
+ renderer.SetProperty( DevelRenderer::Property::OPACITY, 0.5f );
- // Set the StencilMask property to true.
- renderer.SetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER, true );
+ application.SendNotification();
+ application.Render();
- // Check GetProperty returns the same value.
- DALI_TEST_CHECK( renderer.GetProperty( Renderer::Property::WRITE_TO_COLOR_BUFFER ).Get<bool>() );
+ value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
+ DALI_TEST_CHECK( value.Get( opacity ) );
+ DALI_TEST_EQUALS( opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
+ value = renderer.GetCurrentProperty( DevelRenderer::Property::OPACITY );
+ DALI_TEST_CHECK( value.Get( opacity ) );
+ DALI_TEST_EQUALS( opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
+ DALI_TEST_CHECK( gl.GetUniformValue< Vector4 >( "uColor", actualValue ) );
+ DALI_TEST_EQUALS( actualValue.a, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererOpacityAnimation(void)
+{
+ TestApplication application;
+
+ tet_infoline( "Test OPACITY property animation" );
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
+ Renderer renderer = Renderer::New( geometry, shader );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer( renderer );
+ actor.SetSize( 400, 400 );
+ actor.SetColor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
+ Stage::GetCurrent().Add( actor );
+
+ application.SendNotification();
+ application.Render(0);
+
+ Property::Value value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
+ float opacity;
+ DALI_TEST_CHECK( value.Get( opacity ) );
+ DALI_TEST_EQUALS( opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
+ Animation animation = Animation::New( 1.0f );
+ animation.AnimateTo( Property( renderer, DevelRenderer::Property::OPACITY ), 0.0f );
+ animation.Play();
+
+ application.SendNotification();
+ application.Render( 1000 );
+
+ value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
+ DALI_TEST_CHECK( value.Get( opacity ) );
+ DALI_TEST_EQUALS( opacity, 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
+ renderer.SetProperty( DevelRenderer::Property::OPACITY, 0.1f );
+
+ animation.Clear();
+ animation.AnimateBy( Property( renderer, DevelRenderer::Property::OPACITY ), 0.5f );
+ animation.Play();
+
+ application.SendNotification();
+ application.Render( 1000 );
+
+ value = renderer.GetProperty( DevelRenderer::Property::OPACITY );
+ DALI_TEST_CHECK( value.Get( opacity ) );
+ DALI_TEST_EQUALS( opacity, 0.6f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererInvalidProperty(void)
+{
+ TestApplication application;
+
+ tet_infoline( "Test invalid property" );
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
+ Renderer renderer = Renderer::New( geometry, shader );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer( renderer );
+ actor.SetSize( 400, 400 );
+ Stage::GetCurrent().Add( actor );
+
+ application.SendNotification();
+ application.Render(0);
+
+ Property::Value value = renderer.GetProperty( Renderer::Property::DEPTH_INDEX + 100 );
+ DALI_TEST_CHECK( value.GetType() == Property::Type::NONE );
+
+ value = renderer.GetCurrentProperty( Renderer::Property::DEPTH_INDEX + 100 );
+ DALI_TEST_CHECK( value.GetType() == Property::Type::NONE );
+
+ END_TEST;
+}
+
+int UtcDaliRendererRenderingBehavior(void)
+{
+ TestApplication application;
+
+ tet_infoline( "Test RENDERING_BEHAVIOR property" );
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
+ Renderer renderer = Renderer::New( geometry, shader );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer( renderer );
+ actor.SetSize( 400, 400 );
+ actor.SetColor( Vector4( 1.0f, 0.0f, 1.0f, 1.0f ) );
+ Stage::GetCurrent().Add( actor );
+
+ Property::Value value = renderer.GetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR );
+ int renderingBehavior;
+ DALI_TEST_CHECK( value.Get( renderingBehavior ) );
+ DALI_TEST_EQUALS( static_cast< DevelRenderer::Rendering::Type >( renderingBehavior ), DevelRenderer::Rendering::IF_REQUIRED, TEST_LOCATION );
application.SendNotification();
application.Render();
- // Check if ColorMask has been called, and that the values are correct.
- const TestGlAbstraction::ColorMaskParams& colorMaskParamsChanged( glAbstraction.GetColorMaskParams() );
+ uint32_t updateStatus = application.GetUpdateStatus();
+
+ DALI_TEST_CHECK( !( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ) );
+
+ renderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY );
+
+ value = renderer.GetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR );
+ DALI_TEST_CHECK( value.Get( renderingBehavior ) );
+ DALI_TEST_EQUALS( static_cast< DevelRenderer::Rendering::Type >( renderingBehavior ), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION );
+
+ // Render and check the update status
+ application.SendNotification();
+ application.Render();
+
+ updateStatus = application.GetUpdateStatus();
+
+ DALI_TEST_CHECK( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING );
+
+ value = renderer.GetCurrentProperty( DevelRenderer::Property::RENDERING_BEHAVIOR );
+ DALI_TEST_CHECK( value.Get( renderingBehavior ) );
+ DALI_TEST_EQUALS( static_cast< DevelRenderer::Rendering::Type >( renderingBehavior ), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION );
+
+ // Render again and check the update status
+ application.SendNotification();
+ application.Render();
+
+ updateStatus = application.GetUpdateStatus();
+
+ DALI_TEST_CHECK( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING );
+
+ // Change rendering behavior
+ renderer.SetProperty( DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED );
+
+ // Render and check the update status
+ application.SendNotification();
+ application.Render();
+
+ updateStatus = application.GetUpdateStatus();
- DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.red, true, TEST_LOCATION );
- DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.green, true, TEST_LOCATION );
- DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.blue, true, TEST_LOCATION );
- DALI_TEST_EQUALS<bool>( colorMaskParamsChanged.alpha, true, TEST_LOCATION );
+ DALI_TEST_CHECK( !( updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING ) );
END_TEST;
}