RenderableActor renderableActor = RenderableActor::DownCast( child );
DALI_TEST_CHECK( renderableActor );
- renderableActor = NULL;
+ renderableActor.Reset();
DALI_TEST_CHECK( !renderableActor );
renderableActor = DownCast< RenderableActor >( child );
delete ractor;
END_TEST;
}
+
+int UtcDaliRenderableActorSetGetFilterModes(void)
+{
+ TestApplication application;
+
+ tet_infoline("Testing Dali::RenderableActor::SetFilterMode() / Dali::RenderableActor::GetFilterMode()");
+
+ TextActor actor = TextActor::New(TestTextHelloWorld);
+
+ FilterMode::Type minifyFilter = FilterMode::NEAREST;
+ FilterMode::Type magnifyFilter = FilterMode::NEAREST;
+
+ // Default test
+ actor.GetFilterMode( minifyFilter, magnifyFilter );
+ DALI_TEST_CHECK( FilterMode::DEFAULT == minifyFilter );
+ DALI_TEST_CHECK( FilterMode::DEFAULT == magnifyFilter );
+
+ // Default/Default
+ actor.SetFilterMode( FilterMode::DEFAULT, FilterMode::DEFAULT );
+ actor.GetFilterMode( minifyFilter, magnifyFilter );
+ DALI_TEST_CHECK( FilterMode::DEFAULT == minifyFilter );
+ DALI_TEST_CHECK( FilterMode::DEFAULT == magnifyFilter );
+
+ // Nearest/Nearest
+ actor.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
+ actor.GetFilterMode( minifyFilter, magnifyFilter );
+ DALI_TEST_CHECK( FilterMode::NEAREST == minifyFilter );
+ DALI_TEST_CHECK( FilterMode::NEAREST == magnifyFilter );
+
+ // Linear/Linear
+ actor.SetFilterMode( FilterMode::LINEAR, FilterMode::LINEAR );
+ actor.GetFilterMode( minifyFilter, magnifyFilter );
+ DALI_TEST_CHECK( FilterMode::LINEAR == minifyFilter );
+ DALI_TEST_CHECK( FilterMode::LINEAR == magnifyFilter );
+
+ // Nearest/Linear
+ actor.SetFilterMode( FilterMode::NEAREST, FilterMode::LINEAR );
+ actor.GetFilterMode( minifyFilter, magnifyFilter );
+ DALI_TEST_CHECK( FilterMode::NEAREST == minifyFilter );
+ DALI_TEST_CHECK( FilterMode::LINEAR == magnifyFilter );
+
+ // Linear/Nearest
+ actor.SetFilterMode( FilterMode::LINEAR, FilterMode::NEAREST );
+ actor.GetFilterMode( minifyFilter, magnifyFilter );
+ DALI_TEST_CHECK( FilterMode::LINEAR == minifyFilter );
+ DALI_TEST_CHECK( FilterMode::NEAREST == magnifyFilter );
+
+ END_TEST;
+}
+
+int UtcDaliRenderableActorSetFilterMode(void)
+{
+ TestApplication application;
+
+ tet_infoline("Testing Dali::RenderableActor::SetFilterMode()");
+
+ BitmapImage img = BitmapImage::New( 1,1 );
+ ImageActor actor = ImageActor::New( img );
+
+ actor.SetSize(100.0f, 100.0f);
+ actor.SetParentOrigin(ParentOrigin::CENTER);
+ actor.SetAnchorPoint(AnchorPoint::CENTER);
+
+ Stage::GetCurrent().Add(actor);
+
+ /**************************************************************/
+
+ // Default/Default
+ TraceCallStack& texParameterTrace = application.GetGlAbstraction().GetTexParameterTrace();
+ texParameterTrace.Reset();
+ texParameterTrace.Enable( true );
+
+ actor.SetFilterMode( FilterMode::DEFAULT, FilterMode::DEFAULT );
+
+ // Flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ texParameterTrace.Enable( false );
+
+ std::stringstream out;
+
+ // Verify actor gl state
+
+ // There are two calls to TexParameteri when the texture is first created
+ // Texture mag filter is not called as the first time set it uses the system default
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3, TEST_LOCATION);
+
+ out.str("");
+ out << GL_TEXTURE_2D << ", " << GL_TEXTURE_MIN_FILTER << ", " << GL_LINEAR;
+ DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(2, "TexParameteri", out.str()), true, TEST_LOCATION);
+
+ /**************************************************************/
+
+ // Default/Default
+ texParameterTrace = application.GetGlAbstraction().GetTexParameterTrace();
+ texParameterTrace.Reset();
+ texParameterTrace.Enable( true );
+
+ actor.SetFilterMode( FilterMode::DEFAULT, FilterMode::DEFAULT );
+
+ // Flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ texParameterTrace.Enable( false );
+
+ // Verify actor gl state
+
+ // Should not make any calls when settings are the same
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 0, TEST_LOCATION);
+
+ /**************************************************************/
+
+ // Nearest/Nearest
+ texParameterTrace.Reset();
+ texParameterTrace.Enable( true );
+
+ actor.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
+
+ // Flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ texParameterTrace.Enable( false );
+
+ // Verify actor gl state
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 2, TEST_LOCATION);
+
+ out.str("");
+ out << GL_TEXTURE_2D << ", " << GL_TEXTURE_MIN_FILTER << ", " << GL_NEAREST;
+ DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(0, "TexParameteri", out.str()), true, TEST_LOCATION);
+
+ out.str("");
+ out << GL_TEXTURE_2D << ", " << GL_TEXTURE_MAG_FILTER << ", " << GL_NEAREST;
+ DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(1, "TexParameteri", out.str()), true, TEST_LOCATION);
+
+ /**************************************************************/
+
+ // Linear/Linear
+ texParameterTrace.Reset();
+ texParameterTrace.Enable( true );
+
+ actor.SetFilterMode( FilterMode::LINEAR, FilterMode::LINEAR );
+
+ // Flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ texParameterTrace.Enable( false );
+
+ // Verify actor gl state
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 2, TEST_LOCATION);
+
+ out.str("");
+ out << GL_TEXTURE_2D << ", " << GL_TEXTURE_MIN_FILTER << ", " << GL_LINEAR;
+ DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(0, "TexParameteri", out.str()), true, TEST_LOCATION);
+
+ out.str("");
+ out << GL_TEXTURE_2D << ", " << GL_TEXTURE_MAG_FILTER << ", " << GL_LINEAR;
+ DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(1, "TexParameteri", out.str()), true, TEST_LOCATION);
+
+
+ /**************************************************************/
+
+ // Nearest/Linear
+ texParameterTrace.Reset();
+ texParameterTrace.Enable( true );
+
+ actor.SetFilterMode( FilterMode::NEAREST, FilterMode::LINEAR );
+
+ // Flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ texParameterTrace.Enable( false );
+
+ // Verify actor gl state
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 1, TEST_LOCATION);
+
+ out.str("");
+ out << GL_TEXTURE_2D << ", " << GL_TEXTURE_MIN_FILTER << ", " << GL_NEAREST;
+ DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(0, "TexParameteri", out.str()), true, TEST_LOCATION);
+
+ /**************************************************************/
+
+ // Default/Default
+ texParameterTrace.Reset();
+ texParameterTrace.Enable( true );
+
+ actor.SetFilterMode( FilterMode::DEFAULT, FilterMode::DEFAULT );
+
+ // Flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ texParameterTrace.Enable( false );
+
+ // Verify actor gl state
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 1, TEST_LOCATION);
+
+ out.str("");
+ out << GL_TEXTURE_2D << ", " << GL_TEXTURE_MIN_FILTER << ", " << GL_LINEAR;
+ DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(0, "TexParameteri", out.str()), true, TEST_LOCATION);
+
+ /**************************************************************/
+
+ // None/None
+ texParameterTrace.Reset();
+ texParameterTrace.Enable( true );
+
+ actor.SetFilterMode( FilterMode::NONE, FilterMode::NONE );
+
+ // Flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ texParameterTrace.Enable( false );
+
+ // Verify actor gl state
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 1, TEST_LOCATION);
+
+ out.str("");
+ out << GL_TEXTURE_2D << ", " << GL_TEXTURE_MIN_FILTER << ", " << GL_NEAREST_MIPMAP_LINEAR;
+ DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(0, "TexParameteri", out.str()), true, TEST_LOCATION);
+
+ /**************************************************************/
+
+ Stage::GetCurrent().Remove(actor);
+
+ END_TEST;
+}
+
+int UtcDaliRenderableActorSetShaderEffect(void)
+{
+ TestApplication application;
+ BitmapImage img = BitmapImage::New( 1,1 );
+ ImageActor actor = ImageActor::New( img );
+ Stage::GetCurrent().Add( actor );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ GLuint lastShaderCompiledBefore = application.GetGlAbstraction().GetLastShaderCompiled();
+
+ application.GetGlAbstraction().EnableShaderCallTrace( true );
+
+ const std::string vertexShader = "UtcDaliRenderableActorSetShaderEffect-VertexSource";
+ const std::string fragmentShader = "UtcDaliRenderableActorSetShaderEffect-FragmentSource";
+ ShaderEffect effect = ShaderEffect::New(vertexShader, fragmentShader );
+ DALI_TEST_CHECK( effect != actor.GetShaderEffect() );
+
+ actor.SetShaderEffect( effect );
+ DALI_TEST_CHECK( effect == actor.GetShaderEffect() );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ GLuint lastShaderCompiledAfter = application.GetGlAbstraction().GetLastShaderCompiled();
+ DALI_TEST_EQUALS( lastShaderCompiledAfter, lastShaderCompiledBefore + 2, TEST_LOCATION );
+
+ std::string actualVertexShader = application.GetGlAbstraction().GetShaderSource( lastShaderCompiledBefore + 1 );
+ DALI_TEST_EQUALS( vertexShader,
+ actualVertexShader.substr( actualVertexShader.length() - vertexShader.length() ), TEST_LOCATION );
+ std::string actualFragmentShader = application.GetGlAbstraction().GetShaderSource( lastShaderCompiledBefore + 2 );
+ DALI_TEST_EQUALS( fragmentShader,
+ actualFragmentShader.substr( actualFragmentShader.length() - fragmentShader.length() ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRenderableActorGetShaderEffect(void)
+{
+ TestApplication application;
+ TextActor actor = TextActor::New();
+
+ ShaderEffect effect = ShaderEffect::New("UtcDaliRenderableActorGetShaderEffect-VertexSource", "UtcDaliRenderableActorGetShaderEffect-FragmentSource" );
+ actor.SetShaderEffect(effect);
+
+ DALI_TEST_CHECK(effect == actor.GetShaderEffect());
+ END_TEST;
+}
+
+int UtcDaliRenderableActorRemoveShaderEffect01(void)
+{
+ TestApplication application;
+ TextActor actor = TextActor::New();
+
+ ShaderEffect defaultEffect = actor.GetShaderEffect();
+
+ ShaderEffect effect = ShaderEffect::New("UtcDaliRenderableActorRemoveShaderEffect-VertexSource", "UtcDaliRenderableActorRemoveShaderEffect-FragmentSource" );
+ actor.SetShaderEffect(effect);
+
+ DALI_TEST_CHECK(effect == actor.GetShaderEffect());
+
+ actor.RemoveShaderEffect();
+
+ DALI_TEST_CHECK(defaultEffect == actor.GetShaderEffect());
+ END_TEST;
+}
+
+int UtcDaliRenderableActorRemoveShaderEffect02(void)
+{
+ TestApplication application;
+ TextActor actor = TextActor::New();
+
+ ShaderEffect defaultEffect = actor.GetShaderEffect();
+
+ actor.RemoveShaderEffect();
+
+ DALI_TEST_CHECK(defaultEffect == actor.GetShaderEffect());
+ END_TEST;
+}
+
+int UtcDaliSetShaderEffectRecursively(void)
+{
+ TestApplication application;
+ /**
+ * create a tree
+ * actor1
+ * actor2 actor4
+ * actor3 textactor
+ * imageactor
+ */
+ BitmapImage img = BitmapImage::New( 1,1 );
+ ImageActor actor1 = ImageActor::New( img );
+ Actor actor2 = Actor::New();
+ actor1.Add( actor2 );
+ Actor actor3 = Actor::New();
+ actor2.Add( actor3 );
+ TextActor textactor = TextActor::New( "Foo" );
+ actor2.Add( textactor );
+ ImageActor imageactor = ImageActor::New( img );
+ actor3.Add( imageactor );
+ Actor actor4 = Actor::New();
+ actor1.Add( actor4 );
+ Stage::GetCurrent().Add( actor1 );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ GLuint lastShaderCompiledBefore = application.GetGlAbstraction().GetLastShaderCompiled();
+
+ application.GetGlAbstraction().EnableShaderCallTrace( true );
+
+ const std::string vertexShader = "UtcDaliRenderableActorSetShaderEffect-VertexSource";
+ const std::string fragmentShader = "UtcDaliRenderableActorSetShaderEffect-FragmentSource";
+ // test with empty effect
+ ShaderEffect effect;
+ SetShaderEffectRecursively( actor1, effect );
+
+ effect = ShaderEffect::New(vertexShader, fragmentShader );
+
+ DALI_TEST_CHECK( effect != actor1.GetShaderEffect() );
+ DALI_TEST_CHECK( effect != textactor.GetShaderEffect() );
+ DALI_TEST_CHECK( effect != imageactor.GetShaderEffect() );
+
+ SetShaderEffectRecursively( actor1, effect );
+ DALI_TEST_CHECK( effect == textactor.GetShaderEffect() );
+ DALI_TEST_CHECK( effect == imageactor.GetShaderEffect() );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ GLuint lastShaderCompiledAfter = application.GetGlAbstraction().GetLastShaderCompiled();
+ DALI_TEST_EQUALS( lastShaderCompiledAfter, lastShaderCompiledBefore + 2, TEST_LOCATION );
+
+ std::string actualVertexShader = application.GetGlAbstraction().GetShaderSource( lastShaderCompiledBefore + 1 );
+ DALI_TEST_EQUALS( vertexShader,
+ actualVertexShader.substr( actualVertexShader.length() - vertexShader.length() ), TEST_LOCATION );
+ std::string actualFragmentShader = application.GetGlAbstraction().GetShaderSource( lastShaderCompiledBefore + 2 );
+ DALI_TEST_EQUALS( fragmentShader,
+ actualFragmentShader.substr( actualFragmentShader.length() - fragmentShader.length() ), TEST_LOCATION );
+
+ // remove from one that does not have shader
+ RemoveShaderEffectRecursively( actor4 );
+
+ // remove partially
+ RemoveShaderEffectRecursively( actor3 );
+ DALI_TEST_CHECK( effect == textactor.GetShaderEffect() );
+ DALI_TEST_CHECK( effect != imageactor.GetShaderEffect() );
+
+ // test with empty actor just to check it does not crash
+ Actor empty;
+ SetShaderEffectRecursively( empty, effect );
+ RemoveShaderEffectRecursively( empty );
+
+ // test with actor with no children just to check it does not crash
+ Actor loner = Actor::New();
+ Stage::GetCurrent().Add( loner );
+ SetShaderEffectRecursively( loner, effect );
+ RemoveShaderEffectRecursively( loner );
+
+ END_TEST;
+}
+