#include <mesh-builder.h>
using namespace Dali;
+
+namespace
+{
+
+enum SetSampler
+{
+ SET_SAMPLER,
+ DONT_SET_SAMPLER
+};
+
+Actor CreateActor( SetSampler setSamplerOption )
+{
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64 );
+
+ Shader shader = CreateShader();
+ TextureSet textureSet = CreateTextureSet();
+
+ Sampler sampler = Sampler::New();
+ sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
+ textureSet.SetTexture( 0u, texture );
+ if( setSamplerOption == SET_SAMPLER )
+ {
+ textureSet.SetSampler( 0u, sampler );
+ }
+
+ Geometry geometry = CreateQuadGeometry();
+ Renderer renderer = Renderer::New( geometry, shader );
+ renderer.SetTextures( textureSet );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetParentOrigin( ParentOrigin::CENTER );
+ actor.SetSize(400, 400);
+
+ return actor;
+}
+
+} // namespace
+
+
void texture_set_test_startup(void)
{
test_return_value = TET_UNDEF;
{
TestApplication application;
- Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64 );
-
- Shader shader = CreateShader();
- TextureSet textureSet = CreateTextureSet();
- textureSet.SetTexture( 0u, texture );
-
- Geometry geometry = CreateQuadGeometry();
- Renderer renderer = Renderer::New( geometry, shader );
- renderer.SetTextures( textureSet );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetParentOrigin( ParentOrigin::CENTER );
- actor.SetSize(400, 400);
+ Actor actor = CreateActor( DONT_SET_SAMPLER );
Stage::GetCurrent().Add( actor );
{
TestApplication application;
- Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64 );
+ Actor actor = CreateActor(SET_SAMPLER);
- Shader shader = CreateShader();
- TextureSet textureSet = CreateTextureSet();
+ Stage::GetCurrent().Add( actor );
- Sampler sampler = Sampler::New();
- sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
- textureSet.SetTexture( 0u, texture );
- textureSet.SetSampler( 0u, sampler );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
- Geometry geometry = CreateQuadGeometry();
- Renderer renderer = Renderer::New( geometry, shader );
- renderer.SetTextures( textureSet );
+ TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
+ texParameterTrace.Reset();
+ texParameterTrace.Enable( true );
+ application.SendNotification();
+ application.Render();
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetParentOrigin( ParentOrigin::CENTER );
- actor.SetSize(400, 400);
+ int textureUnit=-1;
+ DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
- Stage::GetCurrent().Add( actor );
+ texParameterTrace.Enable( false );
+
+ // Verify gl state
+ // There are four calls to TexParameteri when the texture is first created
+ // Texture minification and magnification filters are now different than default so
+ //there should have been two extra TexParameteri calls to set the new filter mode
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 6, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliTextureSetMultiple(void)
+{
+ TestApplication application;
+
+ Actor actor1 = CreateActor(SET_SAMPLER);
+ Actor actor2 = CreateActor(SET_SAMPLER);
+
+ Stage::GetCurrent().Add( actor1 );
+ Stage::GetCurrent().Add( actor2 );
TestGlAbstraction& gl = application.GetGlAbstraction();
texParameterTrace.Enable( false );
// Verify gl state
- // There are four calls to TexParameteri when the texture is first created
+ // For each actor there are four calls to TexParameteri when the texture is first created
// Texture minification and magnification filters are now different than default so
//there should have been two extra TexParameteri calls to set the new filter mode
- DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 6, TEST_LOCATION);
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 2 * 6, TEST_LOCATION);
END_TEST;
}
+
int UtcDaliTextureSetSetSampler(void)
{
TestApplication application;
// Verify gl state
// There are 4 calls to TexParameteri when the texture is first created
// as the texture is using default sampling parametrers there shouldn't be any more calls to TexParameteri
- DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3, TEST_LOCATION);
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 4, TEST_LOCATION);
texParameterTrace.Reset();
texParameterTrace.Enable( true );
END_TEST;
}
-int UtcDaliTextureGetTextureCount0(void)
+int UtcDaliTextureSetGetTextureCount0(void)
{
TestApplication application;
TextureSetImage( textureSet, 1u, image );
DALI_TEST_EQUALS( textureSet.GetTextureCount(), 2u, TEST_LOCATION );
- textureSet.SetSampler( 2u, Sampler::New() );
+ Sampler sampler = Sampler::New();
+ sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
+ textureSet.SetSampler( 2u, sampler );
+ DALI_TEST_EQUALS( textureSet.GetTextureCount(), 2u, TEST_LOCATION );
+
+ TextureSetImage( textureSet, 2u, image );
DALI_TEST_EQUALS( textureSet.GetTextureCount(), 3u, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetSampler(2u), sampler, TEST_LOCATION );
END_TEST;
}
-int UtcDaliTextureGetTextureCount1(void)
+int UtcDaliTextureSetGetTextureCount1(void)
{
TestApplication application;
textureSet.SetTexture( 1u, texture );
DALI_TEST_EQUALS( textureSet.GetTextureCount(), 2u, TEST_LOCATION );
- textureSet.SetSampler( 2u, Sampler::New() );
+ Sampler sampler = Sampler::New();
+ sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
+ textureSet.SetSampler( 2u, sampler );
+ DALI_TEST_EQUALS( textureSet.GetTextureCount(), 2u, TEST_LOCATION );
+
+ textureSet.SetTexture( 2u, texture );
DALI_TEST_EQUALS( textureSet.GetTextureCount(), 3u, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetSampler(2u), sampler, TEST_LOCATION );
+
END_TEST;
}