Remove Sampler scene object 80/49080/19
authorFerran Sole <ferran.sole@samsung.com>
Tue, 6 Oct 2015 08:02:05 +0000 (09:02 +0100)
committerFerran Sole <ferran.sole@samsung.com>
Tue, 13 Oct 2015 09:43:12 +0000 (02:43 -0700)
* Removed sampler scene object
* Created render thread sampler
* Separated samplers (specify sampling mode) from textures
* Samplers can be reused by multiple textures
* Added support for texture wrapping modes

Change-Id: I530cd6346ae828dabdeeaa2874fa9c4229b4601a

39 files changed:
automated-tests/src/dali-devel/utc-Dali-Material.cpp
automated-tests/src/dali-devel/utc-Dali-Renderer.cpp
automated-tests/src/dali-devel/utc-Dali-Sampler.cpp
automated-tests/src/dali-internal/utc-Dali-Internal-FrustumCulling.cpp
automated-tests/src/dali/dali-test-suite-utils/mesh-builder.cpp
automated-tests/src/dali/utc-Dali-RenderTask.cpp
dali/devel-api/rendering/material.cpp
dali/devel-api/rendering/material.h
dali/devel-api/rendering/sampler.cpp
dali/devel-api/rendering/sampler.h
dali/integration-api/profiling.cpp
dali/internal/common/image-sampler.cpp
dali/internal/common/image-sampler.h
dali/internal/event/rendering/material-impl.cpp
dali/internal/event/rendering/material-impl.h
dali/internal/event/rendering/sampler-impl.cpp
dali/internal/event/rendering/sampler-impl.h
dali/internal/file.list
dali/internal/render/common/render-manager.cpp
dali/internal/render/common/render-manager.h
dali/internal/render/data-providers/render-data-provider.cpp
dali/internal/render/data-providers/render-data-provider.h
dali/internal/render/data-providers/sampler-data-provider.h [deleted file]
dali/internal/render/gl-resources/texture.cpp
dali/internal/render/gl-resources/texture.h
dali/internal/render/renderers/render-new-renderer.cpp
dali/internal/render/renderers/render-new-renderer.h
dali/internal/render/renderers/render-sampler.h [new file with mode: 0644]
dali/internal/render/renderers/render-texture.h [new file with mode: 0644]
dali/internal/update/common/discard-queue.cpp
dali/internal/update/common/discard-queue.h
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h
dali/internal/update/rendering/scene-graph-material.cpp
dali/internal/update/rendering/scene-graph-material.h
dali/internal/update/rendering/scene-graph-renderer.cpp
dali/internal/update/rendering/scene-graph-sampler.cpp [deleted file]
dali/internal/update/rendering/scene-graph-sampler.h [deleted file]
dali/public-api/actors/sampling.h

index 433520f..ee8d42c 100644 (file)
@@ -66,14 +66,12 @@ int UtcDaliMaterialCopyConstructor(void)
 
   Shader shader = Shader::New("vertexSrc", "fragmentSrc");
   Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
-  Sampler sampler = Sampler::New(image, "sTexture");
   Material material = Material::New(shader);
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
 
   Material materialCopy(material);
 
   DALI_TEST_CHECK( materialCopy );
-  DALI_TEST_EQUALS( materialCopy.GetSamplerAt(0), sampler, TEST_LOCATION );
 
   END_TEST;
 }
@@ -84,16 +82,13 @@ int UtcDaliMaterialAssignmentOperator(void)
 
   Shader shader = Shader::New("vertexSrc", "fragmentSrc");
   Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
-  Sampler sampler = Sampler::New(image, "sTexture");
   Material material = Material::New(shader);
-  material.AddSampler( sampler );
 
   Material material2;
   DALI_TEST_CHECK( !material2 );
 
   material2 = material;
   DALI_TEST_CHECK( material2 );
-  DALI_TEST_EQUALS( material2.GetSamplerAt(0), sampler, TEST_LOCATION );
 
   END_TEST;
 }
@@ -194,57 +189,13 @@ int UtcDaliMaterialGetShader(void)
   END_TEST;
 }
 
-int UtcDaliMaterialAddSampler(void)
+int UtcDaliMaterialGetNumberOfTextures(void)
 {
   TestApplication application;
 
-  tet_infoline("Test AddSampler(sampler)");
+  tet_infoline("Test GetNumberOfTextures()");
 
   Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
-  Sampler sampler1 = Sampler::New(image, "sTexture1");
-  Sampler sampler2 = Sampler::New(image, "sTexture2");
-
-  Material material = CreateMaterial(0.5f);
-
-  Geometry geometry = CreateQuadGeometry();
-  Renderer renderer = Renderer::New( geometry, material );
-  Actor actor = Actor::New();
-  actor.AddRenderer(renderer);
-  actor.SetParentOrigin( ParentOrigin::CENTER );
-  actor.SetSize(400, 400);
-  Stage::GetCurrent().Add( actor );
-
-  TestGlAbstraction& gl = application.GetGlAbstraction();
-  int textureUnit=-1;
-
-  material.AddSampler( sampler1 );
-  application.SendNotification();
-  application.Render();
-  DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture1", textureUnit ) );
-  DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
-
-  material.AddSampler( sampler2 );
-  application.SendNotification();
-  application.Render();
-  DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture2", textureUnit ) );
-  DALI_TEST_EQUALS( textureUnit, 1, TEST_LOCATION );
-
-  END_TEST;
-}
-
-int UtcDaliMaterialGetNumberOfSampler(void)
-{
-  TestApplication application;
-
-  tet_infoline("Test GetNumberOfSampler()");
-
-  Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
-  Sampler sampler0 = Sampler::New(image, "sTexture0");
-  Sampler sampler1 = Sampler::New(image, "sTexture1");
-  Sampler sampler2 = Sampler::New(image, "sTexture2");
-  Sampler sampler3 = Sampler::New(image, "sTexture3");
-  Sampler sampler4 = Sampler::New(image, "sTexture4");
-
   Material material = CreateMaterial(0.5f);
 
   Geometry geometry = CreateQuadGeometry();
@@ -255,106 +206,21 @@ int UtcDaliMaterialGetNumberOfSampler(void)
   actor.SetSize(400, 400);
   Stage::GetCurrent().Add( actor );
 
-  material.AddSampler( sampler0 );
-  material.AddSampler( sampler1 );
-  DALI_TEST_EQUALS( material.GetNumberOfSamplers(), 2u, TEST_LOCATION );
+  material.AddTexture( image, "sTexture0" );
+  material.AddTexture( image, "sTexture1" );
+  DALI_TEST_EQUALS( material.GetNumberOfTextures(), 2u, TEST_LOCATION );
 
-  material.AddSampler( sampler2 );
-  material.AddSampler( sampler3 );
-  material.AddSampler( sampler4 );
-  DALI_TEST_EQUALS( material.GetNumberOfSamplers(), 5u, TEST_LOCATION );
+  material.AddTexture( image, "sTexture2" );
+  material.AddTexture( image, "sTexture3" );
+  material.AddTexture( image, "sTexture4" );
+  DALI_TEST_EQUALS( material.GetNumberOfTextures(), 5u, TEST_LOCATION );
 
-  material.RemoveSampler(3); // remove sampler3
-  DALI_TEST_EQUALS( material.GetNumberOfSamplers(), 4u, TEST_LOCATION );
+  material.RemoveTexture(3);
+  DALI_TEST_EQUALS( material.GetNumberOfTextures(), 4u, TEST_LOCATION );
 
-  material.RemoveSampler(3); // remove sampler4
-  material.RemoveSampler(0); // remove sampler0
-  DALI_TEST_EQUALS( material.GetNumberOfSamplers(), 2u, TEST_LOCATION );
-
-  END_TEST;
-}
-
-int UtcDaliMaterialRemoveSampler(void)
-{
-  TestApplication application;
-
-  tet_infoline("Test RemoveSampler(index)");
-  Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
-  Sampler sampler1 = Sampler::New(image, "sTexture1");
-  Sampler sampler2 = Sampler::New(image, "sTexture2");
-
-  Material material = CreateMaterial(0.5f);
-
-  Geometry geometry = CreateQuadGeometry();
-  Renderer renderer = Renderer::New( geometry, material );
-  Actor actor = Actor::New();
-  actor.AddRenderer(renderer);
-  actor.SetParentOrigin( ParentOrigin::CENTER );
-  actor.SetSize(400, 400);
-  Stage::GetCurrent().Add( actor );
-
-  material.AddSampler( sampler1 );
-  material.AddSampler( sampler2 );
-
-  TestGlAbstraction& gl = application.GetGlAbstraction();
-  int textureUnit=-1;
-  application.SendNotification();
-  application.Render();
-  DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture1", textureUnit ) );
-  DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
-  DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture2", textureUnit ) );
-  DALI_TEST_EQUALS( textureUnit, 1, TEST_LOCATION );
-
-  material.RemoveSampler(0); // remove sampler1
-  application.SendNotification();
-  application.Render();
-  // Todo: test the sampler is removed from gl, cannot pass this test with current implementation
-  //DALI_TEST_CHECK( ! gl.GetUniformValue<int>( "sTexture1", textureUnit ) );
-  DALI_TEST_EQUALS( material.GetNumberOfSamplers(), 1u, TEST_LOCATION );
-
-  material.RemoveSampler(0); // remove sampler2
-  application.SendNotification();
-  application.Render();
-  // Todo: test the sampler is removed from gl, cannot pass this test with current implementation
-  //DALI_TEST_CHECK( ! gl.GetUniformValue<int>( "sTexture2", textureUnit ) );
-  DALI_TEST_EQUALS( material.GetNumberOfSamplers(), 0u, TEST_LOCATION );
-
-  END_TEST;
-}
-
-int UtcDaliMaterialGetSamplerAt(void)
-{
-  TestApplication application;
-
-  tet_infoline("Test GetSamplerAt(index)");
-
-  Image image = BufferImage::New(16, 16, Pixel::RGBA8888);
-  Sampler sampler1 = Sampler::New(image, "sTexture1");
-  Sampler sampler2 = Sampler::New(image, "sTexture2");
-  Sampler sampler3 = Sampler::New(image, "sTexture3");
-
-  Material material = CreateMaterial(0.5f);
-  material.AddSampler( sampler1 );
-  material.AddSampler( sampler2 );
-  material.AddSampler( sampler3 );
-
-  Geometry geometry = CreateQuadGeometry();
-  Renderer renderer = Renderer::New( geometry, material );
-  Actor actor = Actor::New();
-  actor.AddRenderer(renderer);
-  actor.SetParentOrigin( ParentOrigin::CENTER );
-  actor.SetSize(400, 400);
-  Stage::GetCurrent().Add( actor );
-
-  application.SendNotification();
-  application.Render();
-
-  DALI_TEST_EQUALS( material.GetSamplerAt( 0 ), sampler1, TEST_LOCATION );
-  DALI_TEST_EQUALS( material.GetSamplerAt( 1 ), sampler2, TEST_LOCATION );
-  DALI_TEST_EQUALS( material.GetSamplerAt( 2 ), sampler3, TEST_LOCATION );
-
-  Sampler sampler = material.GetSamplerAt( 1 );
-  DALI_TEST_EQUALS( sampler.GetImage().GetWidth(), 16u, TEST_LOCATION );
+  material.RemoveTexture(3);
+  material.RemoveTexture(0);
+  DALI_TEST_EQUALS( material.GetNumberOfTextures(), 2u, TEST_LOCATION );
 
   END_TEST;
 }
@@ -851,8 +717,7 @@ int UtcDaliMaterialSetBlendMode08(void)
   Material material = Material::New(shader);
   material.SetProperty(Material::Property::COLOR, Color::WHITE);
   BufferImage image = BufferImage::New( 50, 50, Pixel::RGB888 );
-  Sampler sampler = Sampler::New( image, "sTexture" );
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
   Renderer renderer = Renderer::New( geometry, material );
 
   Actor actor = Actor::New();
@@ -869,9 +734,7 @@ int UtcDaliMaterialSetBlendMode08(void)
   application.Render();
 
   TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
-  std::ostringstream blendStr;
-  blendStr << GL_BLEND;
-  DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+  DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", "GL_BLEND" ) );
 
   END_TEST;
 }
@@ -914,8 +777,7 @@ int UtcDaliMaterialSetBlendColor(void)
   Material material = Material::New(shader);
   material.SetProperty(Material::Property::COLOR, Color::WHITE);
   BufferImage image = BufferImage::New( 50, 50, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New( image, "sTexture" );
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
   Renderer renderer = Renderer::New( geometry, material );
 
   Actor actor = Actor::New();
@@ -1167,3 +1029,115 @@ int UtcDaliMaterialAnimatedProperty02(void)
 
   END_TEST;
 }
+
+
+int UtcDaliMaterialSetTextureUniformName01(void)
+{
+  TestApplication application;
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+
+  Material material = CreateMaterial(1.0f);
+  material.AddTexture( image, "sTexture" );
+  material.SetTextureUniformName( 0, "sEffectTexture" );
+
+  Geometry geometry = CreateQuadGeometry();
+  Renderer renderer = Renderer::New( geometry, material );
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetParentOrigin( ParentOrigin::CENTER );
+  actor.SetSize(400, 400);
+
+  Stage::GetCurrent().Add( actor );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render();
+
+  int textureUnit=-1;
+  DALI_TEST_CHECK( gl.GetUniformValue<int>( "sEffectTexture", textureUnit ) );
+  DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliMaterialSetTextureUniformName02(void)
+{
+  TestApplication application;
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  Image image2 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+
+  Material material = CreateMaterial(1.0f);
+  material.AddTexture( image, "sTexture");
+  material.SetTextureUniformName( 0, "sEffectTexture" );
+  material.AddTexture( image2, "sTexture2");
+
+    Geometry geometry = CreateQuadGeometry();
+  Renderer renderer = Renderer::New( geometry, material );
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetParentOrigin( ParentOrigin::CENTER );
+  actor.SetSize(400, 400);
+
+  Stage::GetCurrent().Add( actor );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render();
+
+  int textureUnit=-1;
+  DALI_TEST_CHECK( gl.GetUniformValue<int>( "sEffectTexture", textureUnit ) );
+  DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+  DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture2", textureUnit ) );
+  DALI_TEST_EQUALS( textureUnit, 1, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliMaterialSetTextureAffectsTransparency(void)
+{
+  TestApplication application;
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+
+  Material material = CreateMaterial(1.0f);
+  material.AddTexture( image, "sTexture" );
+
+  Geometry geometry = CreateQuadGeometry();
+  Renderer renderer = Renderer::New( geometry, material );
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetParentOrigin( ParentOrigin::CENTER );
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add( actor );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  // Test SetAffectsTransparency( false )
+  material.SetTextureAffectsTransparency( 0, false );
+
+  gl.EnableCullFaceCallTrace(true);
+  application.SendNotification();
+  application.Render();
+
+  TraceCallStack& glEnableStack = gl.GetCullFaceTrace();
+  std::ostringstream blendStr;
+  blendStr << GL_BLEND;
+  DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+
+  // Test SetAffectsTransparency( true )
+  material.SetTextureAffectsTransparency( 0, true );
+
+  glEnableStack.Reset();
+  gl.EnableCullFaceCallTrace(true);
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+
+  END_TEST;
+}
index 37d31e0..ee82c5e 100644 (file)
@@ -452,12 +452,10 @@ int UtcDaliRendererUniformMapPrecendence01(void)
   tet_infoline("Test the uniform map precedence is applied properly");
 
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
-  sampler.SetUniformName( "sEffectTexture" );
 
   Shader shader = Shader::New("VertexSource", "FragmentSource");
   Material material = Material::New( shader );
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
   material.SetProperty(Material::Property::COLOR, Color::WHITE);
 
   PropertyBuffer vertexBuffer = CreatePropertyBuffer();
@@ -477,7 +475,6 @@ int UtcDaliRendererUniformMapPrecendence01(void)
 
   Property::Index materialFadeColorIndex = material.RegisterProperty( "uFadeColor", Color::BLUE );
 
-  sampler.RegisterProperty( "uFadeColor", Color::CYAN );
   shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
 
   geometry.RegisterProperty( "uFadeColor", Color::YELLOW );
@@ -523,12 +520,10 @@ int UtcDaliRendererUniformMapPrecendence02(void)
   tet_infoline("Test the uniform map precedence is applied properly");
 
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
-  sampler.SetUniformName( "sEffectTexture" );
 
   Shader shader = Shader::New("VertexSource", "FragmentSource");
   Material material = Material::New( shader );
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
   material.SetProperty(Material::Property::COLOR, Color::WHITE);
 
   PropertyBuffer vertexBuffer = CreatePropertyBuffer();
@@ -548,7 +543,6 @@ int UtcDaliRendererUniformMapPrecendence02(void)
 
   Property::Index materialFadeColorIndex = material.RegisterProperty( "uFadeColor", Color::BLUE );
 
-  sampler.RegisterProperty( "uFadeColor", Color::CYAN );
   shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
 
   geometry.RegisterProperty( "uFadeColor", Color::YELLOW );
@@ -595,12 +589,10 @@ int UtcDaliRendererUniformMapPrecendence03(void)
   tet_infoline("Test the uniform map precedence is applied properly");
 
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
-  sampler.SetUniformName( "sEffectTexture" );
 
   Shader shader = Shader::New("VertexSource", "FragmentSource");
   Material material = Material::New( shader );
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
   material.SetProperty(Material::Property::COLOR, Color::WHITE);
 
   PropertyBuffer vertexBuffer = CreatePropertyBuffer();
@@ -618,7 +610,6 @@ int UtcDaliRendererUniformMapPrecendence03(void)
 
   material.RegisterProperty( "uFadeColor", Color::BLUE );
 
-  sampler.RegisterProperty( "uFadeColor", Color::CYAN );
   shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
 
   Property::Index geometryFadeColorIndex = geometry.RegisterProperty( "uFadeColor", Color::YELLOW );
@@ -665,12 +656,10 @@ int UtcDaliRendererUniformMapPrecendence04(void)
   tet_infoline("Test the uniform map precedence is applied properly");
 
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
-  sampler.SetUniformName( "sEffectTexture" );
 
   Shader shader = Shader::New("VertexSource", "FragmentSource");
   Material material = Material::New( shader );
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
   material.SetProperty(Material::Property::COLOR, Color::WHITE);
 
   PropertyBuffer vertexBuffer = CreatePropertyBuffer();
@@ -685,8 +674,6 @@ int UtcDaliRendererUniformMapPrecendence04(void)
   application.Render(0);
 
   // Don't add property / uniform map to renderer/actor/material
-
-  sampler.RegisterProperty( "uFadeColor", Color::CYAN );
   shader.RegisterProperty( "uFadeColor", Color::MAGENTA );
 
   Property::Index geometryFadeColorIndex = geometry.RegisterProperty( "uFadeColor", Color::YELLOW );
@@ -702,7 +689,7 @@ int UtcDaliRendererUniformMapPrecendence04(void)
   // Expect that the sampler's fade color property is accessed
   Vector4 actualValue(Vector4::ZERO);
   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
-  DALI_TEST_EQUALS( actualValue, Color::CYAN, TEST_LOCATION );
+  DALI_TEST_EQUALS( actualValue, Color::MAGENTA, TEST_LOCATION );
 
   // Animate geometry's fade color property. Should be no change to uniform
   Animation  animation = Animation::New(1.0f);
@@ -716,11 +703,11 @@ int UtcDaliRendererUniformMapPrecendence04(void)
   application.Render(500);
 
   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
-  DALI_TEST_EQUALS( actualValue, Color::CYAN, TEST_LOCATION );
+  DALI_TEST_EQUALS( actualValue, Color::MAGENTA, TEST_LOCATION );
 
   application.Render(500);
   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
-  DALI_TEST_EQUALS( actualValue, Color::CYAN, TEST_LOCATION );
+  DALI_TEST_EQUALS( actualValue, Color::MAGENTA, TEST_LOCATION );
 
   END_TEST;
 }
@@ -732,12 +719,9 @@ int UtcDaliRendererUniformMapPrecendence05(void)
   tet_infoline("Test the uniform map precedence is applied properly");
 
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
-  sampler.SetUniformName( "sEffectTexture" );
 
   Shader shader = Shader::New("VertexSource", "FragmentSource");
   Material material = Material::New( shader );
-  material.AddSampler( sampler );
   material.SetProperty(Material::Property::COLOR, Color::WHITE);
 
   PropertyBuffer vertexBuffer = CreatePropertyBuffer();
@@ -798,12 +782,9 @@ int UtcDaliRendererUniformMapPrecendence06(void)
   tet_infoline("Test the uniform map precedence is applied properly");
 
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
-  sampler.SetUniformName( "sEffectTexture" );
 
   Shader shader = Shader::New("VertexSource", "FragmentSource");
   Material material = Material::New( shader );
-  material.AddSampler( sampler );
   material.SetProperty(Material::Property::COLOR, Color::WHITE);
 
   PropertyBuffer vertexBuffer = CreatePropertyBuffer();
@@ -862,12 +843,9 @@ int UtcDaliRendererUniformMapPrecendence07(void)
   tet_infoline("Test the uniform map precedence is applied properly");
 
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
-  sampler.SetUniformName( "sEffectTexture" );
 
   Shader shader = Shader::New("VertexSource", "FragmentSource");
   Material material = Material::New( shader );
-  material.AddSampler( sampler );
   material.SetProperty(Material::Property::COLOR, Color::WHITE);
 
   PropertyBuffer vertexBuffer = CreatePropertyBuffer();
@@ -924,12 +902,9 @@ int UtcDaliRendererUniformMapMultipleUniforms01(void)
   tet_infoline("Test the uniform maps are collected from all objects (same type)");
 
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
-  sampler.SetUniformName( "sEffectTexture" );
 
   Shader shader = Shader::New("VertexSource", "FragmentSource");
   Material material = Material::New( shader );
-  material.AddSampler( sampler );
   material.SetProperty(Material::Property::COLOR, Color::WHITE);
 
   PropertyBuffer vertexBuffer = CreatePropertyBuffer();
@@ -946,10 +921,9 @@ int UtcDaliRendererUniformMapMultipleUniforms01(void)
   renderer.RegisterProperty( "uUniform1", Color::RED );
   actor.RegisterProperty( "uUniform2", Color::GREEN );
   material.RegisterProperty( "uUniform3", Color::BLUE );
-  sampler.RegisterProperty( "uUniform4", Color::CYAN );
-  shader.RegisterProperty( "uUniform5", Color::MAGENTA );
-  geometry.RegisterProperty( "uUniform6", Color::YELLOW );
-  vertexBuffer.RegisterProperty( "uUniform7", Color::BLACK );
+  shader.RegisterProperty( "uUniform4", Color::MAGENTA );
+  geometry.RegisterProperty( "uUniform5", Color::YELLOW );
+  vertexBuffer.RegisterProperty( "uUniform6", Color::BLACK );
 
 
   TestGlAbstraction& gl = application.GetGlAbstraction();
@@ -970,20 +944,16 @@ int UtcDaliRendererUniformMapMultipleUniforms01(void)
   DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform3", uniform3Value ) );
   DALI_TEST_EQUALS( uniform3Value, Color::BLUE, TEST_LOCATION );
 
-  Vector4 uniform4Value(Vector4::ZERO);
-  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform4", uniform4Value ) );
-  DALI_TEST_EQUALS( uniform4Value, Color::CYAN, TEST_LOCATION );
-
   Vector4 uniform5Value(Vector4::ZERO);
-  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform5", uniform5Value ) );
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform4", uniform5Value ) );
   DALI_TEST_EQUALS( uniform5Value, Color::MAGENTA, TEST_LOCATION );
 
   Vector4 uniform6Value(Vector4::ZERO);
-  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform6", uniform6Value ) );
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform5", uniform6Value ) );
   DALI_TEST_EQUALS( uniform6Value, Color::YELLOW, TEST_LOCATION );
 
   Vector4 uniform7Value(Vector4::ZERO);
-  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform7", uniform7Value ) );
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform6", uniform7Value ) );
   DALI_TEST_EQUALS( uniform7Value, Color::BLACK, TEST_LOCATION );
 
 
@@ -998,12 +968,9 @@ int UtcDaliRendererUniformMapMultipleUniforms02(void)
   tet_infoline("Test the uniform maps are collected from all objects (different types)");
 
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
-  sampler.SetUniformName( "sEffectTexture" );
 
   Shader shader = Shader::New("VertexSource", "FragmentSource");
   Material material = Material::New( shader );
-  material.AddSampler( sampler );
   material.SetProperty(Material::Property::COLOR, Color::WHITE);
 
   PropertyBuffer vertexBuffer = CreatePropertyBuffer();
@@ -1026,9 +993,6 @@ int UtcDaliRendererUniformMapMultipleUniforms02(void)
   Property::Value value3(Vector3(0.5f, 0.5f, 1.0f));
   material.RegisterProperty( "uFadePosition", value3);
 
-  Property::Value value4(Vector2(0.5f, 1.0f));
-  sampler.RegisterProperty( "uFadeUV", value4 );
-
   Property::Value value5(Matrix3::IDENTITY);
   shader.RegisterProperty( "uANormalMatrix", value5 );
 
@@ -1057,10 +1021,6 @@ int UtcDaliRendererUniformMapMultipleUniforms02(void)
   DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "uFadePosition", uniform3Value ) );
   DALI_TEST_EQUALS( uniform3Value, value3.Get<Vector3>(), TEST_LOCATION );
 
-  Vector2 uniform4Value(Vector2::ZERO);
-  DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "uFadeUV", uniform4Value ) );
-  DALI_TEST_EQUALS( uniform4Value, value4.Get<Vector2>(), TEST_LOCATION );
-
   Matrix3 uniform5Value;
   DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uANormalMatrix", uniform5Value ) );
   DALI_TEST_EQUALS( uniform5Value, value5.Get<Matrix3>(), TEST_LOCATION );
index 81ae455..41322f6 100644 (file)
@@ -36,9 +36,7 @@ void sampler_test_cleanup(void)
 int UtcDaliSamplerNew01(void)
 {
   TestApplication application;
-
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
+  Sampler sampler = Sampler::New();
 
   DALI_TEST_EQUALS( (bool)sampler, true, TEST_LOCATION );
   END_TEST;
@@ -58,8 +56,7 @@ int UtcDaliSamplerCopyConstructor(void)
   tet_infoline("Testing Dali::Handle::Handle(const Handle&)");
 
   // Initialize an object, ref count == 1
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
+  Sampler sampler = Sampler::New();
 
   DALI_TEST_EQUALS(1, sampler.GetBaseObject().ReferenceCount(), TEST_LOCATION);
 
@@ -78,8 +75,7 @@ int UtcDaliSamplerCopyConstructor(void)
 int UtcDaliSamplerDownCast01(void)
 {
   TestApplication application;
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
+  Sampler sampler = Sampler::New();
 
   BaseHandle handle(sampler);
   Sampler sampler2 = Sampler::DownCast(handle);
@@ -100,9 +96,7 @@ int UtcDaliSamplerDownCast02(void)
 int UtcDaliSamplerAssignmentOperator(void)
 {
   TestApplication application;
-
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler1 = Sampler::New(image, "sTexture");
+  Sampler sampler1 = Sampler::New();
 
   Sampler sampler2;
 
@@ -112,156 +106,23 @@ int UtcDaliSamplerAssignmentOperator(void)
 
   DALI_TEST_CHECK(sampler1 == sampler2);
 
-  sampler2 = Sampler::New(image, "sTexture");
+  sampler2 = Sampler::New();
 
   DALI_TEST_CHECK(!(sampler1 == sampler2));
 
   END_TEST;
 }
 
-int UtcDaliSamplerSetUniformName01(void)
-{
-  TestApplication application;
-
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
-  sampler.SetUniformName( "sEffectTexture" );
-
-  Material material = CreateMaterial(1.0f);
-  material.AddSampler( sampler );
-
-  Geometry geometry = CreateQuadGeometry();
-  Renderer renderer = Renderer::New( geometry, material );
-  Actor actor = Actor::New();
-  actor.AddRenderer(renderer);
-  actor.SetParentOrigin( ParentOrigin::CENTER );
-  actor.SetSize(400, 400);
-
-  Stage::GetCurrent().Add( actor );
-
-  TestGlAbstraction& gl = application.GetGlAbstraction();
-
-  application.SendNotification();
-  application.Render();
-
-  int textureUnit=-1;
-  DALI_TEST_CHECK( gl.GetUniformValue<int>( "sEffectTexture", textureUnit ) );
-  DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
-
-  END_TEST;
-}
-
-int UtcDaliSamplerSetUniformName02(void)
-{
-  TestApplication application;
-
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Image image2 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler1 = Sampler::New(image, "sTexture");
-  sampler1.SetUniformName( "sEffectTexture" );
-
-  Sampler sampler2 = Sampler::New(image2, "sTexture2");
-
-  Material material = CreateMaterial(1.0f);
-  material.AddSampler( sampler1 );
-  material.AddSampler( sampler2 );
-
-  Geometry geometry = CreateQuadGeometry();
-  Renderer renderer = Renderer::New( geometry, material );
-  Actor actor = Actor::New();
-  actor.AddRenderer(renderer);
-  actor.SetParentOrigin( ParentOrigin::CENTER );
-  actor.SetSize(400, 400);
-
-  Stage::GetCurrent().Add( actor );
-
-  TestGlAbstraction& gl = application.GetGlAbstraction();
-
-  application.SendNotification();
-  application.Render();
-
-  int textureUnit=-1;
-  DALI_TEST_CHECK( gl.GetUniformValue<int>( "sEffectTexture", textureUnit ) );
-  DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
-
-  DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture2", textureUnit ) );
-  DALI_TEST_EQUALS( textureUnit, 1, TEST_LOCATION );
-
-  END_TEST;
-}
-
-int UtcDaliSamplerGetUniformName01(void)
-{
-  TestApplication application;
-
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  std::string uniformName = "sTextureTEST";
-  Sampler sampler = Sampler::New(image, uniformName);
-
-  std::string actual = sampler.GetUniformName();
-
-  DALI_TEST_EQUALS( uniformName, actual, TEST_LOCATION );
-
-  END_TEST;
-}
-
-int UtcDaliSamplerGetUniformName02(void)
-{
-  TestApplication application;
-
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTextureFAIL" );
-
-  std::string uniformName = "sTextureTEST";
-  sampler.SetUniformName( uniformName );
-
-  Material material = CreateMaterial(1.0f);
-  material.AddSampler( sampler );
-  Geometry geometry = CreateQuadGeometry();
-  Renderer renderer = Renderer::New( geometry, material );
-  Actor actor = Actor::New();
-  actor.AddRenderer(renderer);
-  actor.SetParentOrigin( ParentOrigin::CENTER );
-  actor.SetSize(400, 400);
-
-  Stage::GetCurrent().Add( actor );
-
-  application.SendNotification();
-  application.Render();
-
-  std::string actual = sampler.GetUniformName();
-
-  DALI_TEST_EQUALS( uniformName, actual, TEST_LOCATION );
-
-  END_TEST;
-}
-
-int UtcDaliSamplerSetGetImage(void)
-{
-  TestApplication application;
-
-  Image image1 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Image image2 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image1, "sTexture");
-
-  DALI_TEST_CHECK(image1 == sampler.GetImage());
-
-  sampler.SetImage( image2 );
-  DALI_TEST_CHECK(!(image1 == sampler.GetImage()));
-  DALI_TEST_CHECK(image2 == sampler.GetImage());
-
-  END_TEST;
-}
 
 int UtcSamplerSetFilterMode(void)
 {
   TestApplication application;
 
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
+  Sampler sampler = Sampler::New();
 
   Material material = CreateMaterial(1.0f);
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture", sampler );
 
   Geometry geometry = CreateQuadGeometry();
   Renderer renderer = Renderer::New( geometry, material );
@@ -271,8 +132,6 @@ int UtcSamplerSetFilterMode(void)
   actor.SetSize(400, 400);
   Stage::GetCurrent().Add( actor );
 
-  float initialValue = 1.0f;
-  sampler.RegisterProperty("uWidthClamp", initialValue );
 
   TestGlAbstraction& gl = application.GetGlAbstraction();
 
@@ -282,7 +141,7 @@ int UtcSamplerSetFilterMode(void)
   texParameterTrace.Reset();
   texParameterTrace.Enable( true );
 
-  sampler.SetFilterMode( Sampler::DEFAULT, Sampler::DEFAULT );
+  sampler.SetFilterMode( FilterMode::DEFAULT, FilterMode::DEFAULT );
   application.SendNotification();
   application.Render();
 
@@ -290,7 +149,7 @@ int UtcSamplerSetFilterMode(void)
 
   // Verify gl state
 
-  // There are two calls to TexParameteri when the texture is first created
+  // There are three 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);
 
@@ -303,7 +162,7 @@ int UtcSamplerSetFilterMode(void)
   texParameterTrace.Reset();
   texParameterTrace.Enable( true );
 
-  sampler.SetFilterMode( Sampler::DEFAULT, Sampler::DEFAULT );
+  sampler.SetFilterMode( FilterMode::DEFAULT, FilterMode::DEFAULT );
 
   // Flush the queue and render once
   application.SendNotification();
@@ -321,7 +180,7 @@ int UtcSamplerSetFilterMode(void)
   texParameterTrace.Reset();
   texParameterTrace.Enable( true );
 
-  sampler.SetFilterMode( Sampler::NEAREST, Sampler::NEAREST );
+  sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
 
   // Flush the queue and render once
   application.SendNotification();
@@ -340,12 +199,13 @@ int UtcSamplerSetFilterMode(void)
   out << GL_TEXTURE_2D << ", " << GL_TEXTURE_MAG_FILTER << ", " << GL_NEAREST;
   DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(1, "TexParameteri", out.str()), true, TEST_LOCATION);
 
+
   /**************************************************************/
   // Nearest/Linear
   texParameterTrace.Reset();
   texParameterTrace.Enable( true );
 
-  sampler.SetFilterMode( Sampler::NEAREST, Sampler::LINEAR );
+  sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::LINEAR );
 
   // Flush the queue and render once
   application.SendNotification();
@@ -365,7 +225,7 @@ int UtcSamplerSetFilterMode(void)
   texParameterTrace.Reset();
   texParameterTrace.Enable( true );
 
-  sampler.SetFilterMode( Sampler::NONE, Sampler::NONE );
+  sampler.SetFilterMode( FilterMode::NONE, FilterMode::NONE );
 
   // Flush the queue and render once
   application.SendNotification();
@@ -388,10 +248,9 @@ int UtcSamplerSetWrapMode(void)
   TestApplication application;
 
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
-
   Material material = CreateMaterial(1.0f);
-  material.AddSampler( sampler );
+  Sampler sampler = Sampler::New();
+  material.AddTexture( image, "sTexture", sampler );
 
   Geometry geometry = CreateQuadGeometry();
   Renderer renderer = Renderer::New( geometry, material );
@@ -416,7 +275,7 @@ int UtcSamplerSetWrapMode(void)
 
   // Verify gl state
 
-  // There are two calls to TexParameteri when the texture is first created
+  // There are three 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);
 
@@ -431,7 +290,7 @@ int UtcSamplerSetWrapMode(void)
   texParameterTrace.Reset();
   texParameterTrace.Enable( true );
 
-  sampler.SetWrapMode( Sampler::CLAMP_TO_EDGE, Sampler::CLAMP_TO_EDGE );
+  sampler.SetWrapMode( WrapMode::CLAMP_TO_EDGE, WrapMode::CLAMP_TO_EDGE );
 
   // Flush the queue and render once
   application.SendNotification();
@@ -448,48 +307,3 @@ int UtcSamplerSetWrapMode(void)
 
   END_TEST;
 }
-
-int UtcSamplerSetAffectsTransparency(void)
-{
-  TestApplication application;
-
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  Sampler sampler = Sampler::New(image, "sTexture");
-
-  Material material = CreateMaterial(1.0f);
-  material.AddSampler( sampler );
-
-  Geometry geometry = CreateQuadGeometry();
-  Renderer renderer = Renderer::New( geometry, material );
-  Actor actor = Actor::New();
-  actor.AddRenderer(renderer);
-  actor.SetParentOrigin( ParentOrigin::CENTER );
-  actor.SetSize(400, 400);
-  Stage::GetCurrent().Add( actor );
-
-  TestGlAbstraction& gl = application.GetGlAbstraction();
-
-  // Test SetAffectsTransparency( false )
-  sampler.SetAffectsTransparency( false );
-
-  gl.EnableCullFaceCallTrace(true);
-  application.SendNotification();
-  application.Render();
-
-  TraceCallStack& glEnableStack = gl.GetCullFaceTrace();
-  std::ostringstream blendStr;
-  blendStr << GL_BLEND;
-  DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
-
-  // Test SetAffectsTransparency( true )
-  sampler.SetAffectsTransparency( true );
-
-  glEnableStack.Reset();
-  gl.EnableCullFaceCallTrace(true);
-  application.SendNotification();
-  application.Render();
-
-  DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
-
-  END_TEST;
-}
index 7a4d674..bccd367 100644 (file)
@@ -95,8 +95,7 @@ Actor CreateMeshActorToStage( TestApplication& application, Vector3 parentOrigin
 
   Geometry geometry = CreateGeometry();
   Material material = Material::New( Shader::New( VERTEX_SHADER, FRAGMENT_SHADER, shaderHints ) );
-  Sampler sampler = Sampler::New( image, "sTexture" );
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
   Renderer renderer = Renderer::New( geometry, material );
 
   Actor meshActor = Actor::New();
index 3fdae8a..51f3e29 100644 (file)
@@ -39,8 +39,7 @@ Material CreateMaterial(float opacity, Image image)
   color.a = opacity;
   material.SetProperty(Material::Property::COLOR, color);
 
-  Sampler sampler = Sampler::New( image, "sTexture" );
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
 
   return material;
 }
index 74bd263..7ae8a9f 100644 (file)
@@ -169,7 +169,7 @@ bool TestScreenToFrameBufferFunction( Vector2& coordinates )
   return true;
 }
 
-ImageActor CreateLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
+ImageActor CreateLoadingImageActor(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
 {
   Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
   DALI_TEST_CHECK( image );
@@ -183,7 +183,7 @@ ImageActor CreateLoadingImage(TestApplication& application, std::string filename
   return actor;
 }
 
-Sampler CreateSamplerWithLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
+Image CreateLoadingImage(TestApplication& application, std::string filename, ResourceImage::LoadPolicy loadPolicy, Image::ReleasePolicy releasePolicy)
 {
   Image image = ResourceImage::New(filename, loadPolicy, releasePolicy);
   DALI_TEST_CHECK( image );
@@ -191,10 +191,7 @@ Sampler CreateSamplerWithLoadingImage(TestApplication& application, std::string
   application.Render(16);
   DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
 
-  Sampler sampler = Sampler::New( image, "sTexture" );
-  application.SendNotification();
-  application.Render(16);
-  return sampler;
+  return image;
 }
 
 void CompleteImageLoad(TestApplication& application, Integration::ResourceId resourceId, Integration::ResourceTypeId requestType)
@@ -1826,7 +1823,7 @@ int UtcDaliRenderTaskContinuous01(void)
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
 
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -1869,7 +1866,7 @@ int UtcDaliRenderTaskContinuous02(void)
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
 
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -1911,7 +1908,7 @@ int UtcDaliRenderTaskContinuous03(void)
   Stage::GetCurrent().Add( rootActor );
 
   CameraActor offscreenCameraActor = CameraActor::New();
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -1954,7 +1951,7 @@ int UtcDaliRenderTaskContinuous04(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -1995,11 +1992,11 @@ int UtcDaliRenderTaskContinous05(void)
   Stage::GetCurrent().Add( offscreenCameraActor );
 
   Material material = CreateMaterial(1.0f);
-  Sampler sampler = CreateSamplerWithLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
 
   Geometry geometry = CreateQuadGeometry();
   Renderer renderer = Renderer::New(geometry, material);
@@ -2043,7 +2040,7 @@ int UtcDaliRenderTaskOnce01(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -2100,11 +2097,11 @@ int UtcDaliRenderTaskOnce02(void)
   Stage::GetCurrent().Add( offscreenCameraActor );
 
   Material material = CreateMaterial(1.0f);
-  Sampler sampler = CreateSamplerWithLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
 
   Geometry geometry = CreateQuadGeometry();
   Renderer renderer = Renderer::New(geometry, material);
@@ -2157,7 +2154,7 @@ int UtcDaliRenderTaskOnce03(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -2217,11 +2214,11 @@ int UtcDaliRenderTaskOnce04(void)
   Stage::GetCurrent().Add( offscreenCameraActor );
 
   Material material = CreateMaterial(1.0f);
-  Sampler sampler = CreateSamplerWithLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
 
   Geometry geometry = CreateQuadGeometry();
   Renderer renderer = Renderer::New(geometry, material);
@@ -2282,7 +2279,7 @@ int UtcDaliRenderTaskOnce05(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -2348,7 +2345,7 @@ int UtcDaliRenderTaskOnce05(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -2422,7 +2419,7 @@ int UtcDaliRenderTaskOnce07(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -2489,7 +2486,7 @@ int UtcDaliRenderTaskOnce08(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -2564,7 +2561,7 @@ int UtcDaliRenderTaskOnce09(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -2625,7 +2622,7 @@ int UtcDaliRenderTaskOnce10(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Stage::GetCurrent().Add(secondRootActor);
@@ -2683,7 +2680,7 @@ int UtcDaliRenderTaskOnceNoSync01(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -2726,11 +2723,11 @@ int UtcDaliRenderTaskOnceNoSync02(void)
   Stage::GetCurrent().Add( offscreenCameraActor );
 
   Material material = CreateMaterial(1.0f);
-  Sampler sampler = CreateSamplerWithLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
-  material.AddSampler( sampler );
+  material.AddTexture(image, "sTexture" );
 
   Geometry geometry = CreateQuadGeometry();
   Renderer renderer = Renderer::New(geometry, material);
@@ -2776,7 +2773,7 @@ int UtcDaliRenderTaskOnceNoSync03(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -2825,11 +2822,11 @@ int UtcDaliRenderTaskOnceNoSync04(void)
   Stage::GetCurrent().Add( offscreenCameraActor );
 
   Material material = CreateMaterial(1.0f);
-  Sampler sampler = CreateSamplerWithLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
-  material.AddSampler( sampler );
+  material.AddTexture( image, "sTexture" );
 
   Geometry geometry = CreateQuadGeometry();
   Renderer renderer = Renderer::New(geometry, material);
@@ -2880,7 +2877,7 @@ int UtcDaliRenderTaskOnceNoSync05(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -2930,7 +2927,7 @@ int UtcDaliRenderTaskOnceNoSync05(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -2992,7 +2989,7 @@ int UtcDaliRenderTaskOnceNoSync07(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -3045,7 +3042,7 @@ int UtcDaliRenderTaskOnceNoSync08(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -3104,7 +3101,7 @@ int UtcDaliRenderTaskOnceNoSync09(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
@@ -3155,7 +3152,7 @@ int UtcDaliRenderTaskOnceNoSync10(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor secondRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor secondRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Stage::GetCurrent().Add(secondRootActor);
@@ -3205,7 +3202,7 @@ int UtcDaliRenderTaskOnceChain01(void)
 
   CameraActor offscreenCameraActor = CameraActor::New();
   Stage::GetCurrent().Add( offscreenCameraActor );
-  ImageActor firstRootActor = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
+  ImageActor firstRootActor = CreateLoadingImageActor(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
   Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
   Integration::ResourceId imageRequestId = imageRequest->GetId();
   Integration::ResourceTypeId imageType  = imageRequest->GetType()->id;
index af2fd92..aeb7885 100644 (file)
@@ -71,28 +71,75 @@ Shader Material::GetShader() const
   return Dali::Shader( shaderPtr );
 }
 
-void Material::AddSampler( Sampler& sampler )
+int Material::AddTexture( Image image, const std::string& uniformName, Sampler sampler)
 {
-  DALI_ASSERT_ALWAYS( sampler && "Sampler handle is uninitialized" );
-  GetImplementation(*this).AddSampler( GetImplementation( sampler ) );
+  int index( -1 );
+  if( image )
+  {
+    Internal::ImagePtr imagePtr(&GetImplementation( image ));
+    Internal::SamplerPtr samplerPtr(0);
+    if( sampler )
+    {
+      samplerPtr = &GetImplementation( sampler );
+    }
+
+    index = GetImplementation(*this).AddTexture( imagePtr, uniformName, samplerPtr );
+  }
+  else
+  {
+    DALI_LOG_ERROR("Error adding invalid texture %s to material", uniformName.c_str() );
+  }
+  return index;
+}
+
+void Material::RemoveTexture( size_t index )
+{
+  GetImplementation(*this).RemoveTexture( index );
+}
+
+void Material::SetTextureImage( size_t index, Image image )
+{
+  Internal::Image* imagePtr(0);
+  if( image )
+  {
+    imagePtr = &GetImplementation( image );
+  }
+
+  GetImplementation(*this).SetTextureImage( index, imagePtr );
 }
 
-std::size_t Material::GetNumberOfSamplers() const
+void Material::SetTextureSampler( size_t index, Sampler sampler )
 {
-  return GetImplementation(*this).GetNumberOfSamplers();
+  Internal::Sampler* samplerPtr(0);
+  if( sampler )
+  {
+    samplerPtr = &GetImplementation( sampler );
+  }
+
+  GetImplementation(*this).SetTextureSampler( index, samplerPtr );
+}
+
+void Material::SetTextureUniformName( size_t index, const std::string& uniformName )
+{
+  GetImplementation(*this).SetTextureUniformName( index, uniformName );
 }
 
-void Material::RemoveSampler( std::size_t index )
+int Material::GetTextureIndex( const std::string& uniformName )
 {
-  GetImplementation(*this).RemoveSampler( index );
+  return GetImplementation(*this).GetTextureIndex( uniformName );
 }
 
-Sampler Material::GetSamplerAt( unsigned int index ) const
+void Material::SetTextureAffectsTransparency( size_t index, bool affectsTransparency )
 {
-  Internal::Sampler* samplerPtr( GetImplementation(*this).GetSamplerAt(index) );
-  return Dali::Sampler( samplerPtr );
+  GetImplementation(*this).SetTextureAffectsTransparency( index, affectsTransparency );
 }
 
+std::size_t Material::GetNumberOfTextures() const
+{
+  return GetImplementation(*this).GetNumberOfTextures();
+}
+
+
 void Material::SetFaceCullingMode( FaceCullingMode cullingMode )
 {
   GetImplementation(*this).SetFaceCullingMode( cullingMode );
index 5751fff..9943ffa 100644 (file)
@@ -139,37 +139,66 @@ public:
   Shader GetShader() const;
 
   /**
-   * @brief Add a sampler to this material
+   * @brief Add a new texture to be used by the material
    *
-   * param[in] sampler The sampler to add to this material
+   * @param[in] image The image used by the texture
+   * @param[in] uniformName The uniform name of the texture
+   * @param[in] sampler Sampling parameters. If not provided the default sampling parameters will be used
+   * @return The index of the texture in the array of textures or -1 if texture can not be added
    */
-  void AddSampler( Sampler& sampler );
+  int AddTexture( Image image, const std::string& uniformName, Sampler sampler = Sampler() );
 
   /**
-   * @brief Get the number of samplers
+   * @brief Removes a texture from the material
    *
-   * @return The number of samplers
+   * @param[in] index The index of the texture in the array of textures
    */
-  std::size_t GetNumberOfSamplers() const;
+  void RemoveTexture( size_t  index );
 
   /**
-   * @brief Remove a sampler
+   * @brief Sets the image to be used by a given texture
    *
-   * The index must be between 0 and GetNumberOfSamplers()-1
+   * @param[in] index The index of the texture in the array of textures
+   * @param[in] image The new image
+   */
+  void SetTextureImage( size_t index, Image image );
+
+  /**
+   * @brief Set the sampler used by a given texture
+   *
+   * @param[in] index The index of the texture in the array of textures
+   * @param[in] sampler The new sampler
+   */
+  void SetTextureSampler( size_t index, Sampler sampler );
+
+  /**
+   * @brief Set the uniform name of a given texture
    *
-   * @param[in] index The index of the sampler to remove
+   * @param[in] index The index of the texture in the array of textures
+   * @param[in] uniformName The new uniform name
    */
-  void RemoveSampler( std::size_t index );
+  void SetTextureUniformName( size_t index, const std::string& uniformName );
 
   /**
-   * @brief Get the sampler at the given index for this material
+   * @brief Establish if a given texture will affect the transparency of the material ( true by default )
    *
-   * The index must be between 0 and GetNumberOfSamplers()-1
+   * @param[in] index The index of the texture in the array of textures
+   * @param[in] affectsTransparency True if the texture affects transparency, false otherwise
+   */
+  void SetTextureAffectsTransparency( size_t index, bool affectsTransparency );
+
+  /*
+   * @brief Retrive the index of a texture given its uniform name
    *
-   * @param[in] index The index of the sampler
-   * @return The sampler at that index
+   * @param[in] uniformName the uniform name
+   * @returns The index in the array of textures or -1 if the texture is not found
+   */
+  int GetTextureIndex( const std::string& uniformName );
+
+  /**
+   * @brief Retrieve the number of textures used by the material
    */
-  Sampler GetSamplerAt( unsigned int index ) const;
+  std::size_t GetNumberOfTextures() const;
 
   /**
    * @brief Set the culling mode for this material
index 2b2ab5e..7c38729 100644 (file)
 namespace Dali
 {
 
-Sampler Sampler::New( Image& image, const std::string& textureUnitUniformName )
+Sampler Sampler::New()
 {
-  Internal::SamplerPtr sampler = Internal::Sampler::New(textureUnitUniformName);
-  Internal::ImagePtr imagePtr = &GetImplementation( image );
-  sampler->SetImage( imagePtr );
+  Internal::SamplerPtr sampler = Internal::Sampler::New();
   return Sampler( sampler.Get() );
 }
 
@@ -41,7 +39,7 @@ Sampler::~Sampler()
 }
 
 Sampler::Sampler( const Sampler& handle )
-: Handle( handle )
+: BaseHandle( handle )
 {
 }
 
@@ -56,45 +54,19 @@ Sampler& Sampler::operator=( const Sampler& handle )
   return *this;
 }
 
-void Sampler::SetUniformName( const std::string& name )
-{
-  GetImplementation(*this).SetTextureUnitUniformName( name );
-}
-
-const std::string& Sampler::GetUniformName() const
-{
-  return GetImplementation(*this).GetTextureUnitUniformName();
-}
-
-void Sampler::SetImage( Image& image )
-{
-  Internal::ImagePtr imagePtr = &GetImplementation( image );
-  GetImplementation(*this).SetImage( imagePtr );
-}
-
-Image Sampler::GetImage() const
-{
-  Internal::ImagePtr imagePtr( GetImplementation(*this).GetImage() );
-  return Dali::Image( imagePtr.Get() );
-}
 
-void Sampler::SetFilterMode( FilterMode minFilter, FilterMode magFilter )
+void Sampler::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter )
 {
   GetImplementation(*this).SetFilterMode( minFilter, magFilter );
 }
 
-void Sampler::SetWrapMode( WrapMode uWrap, WrapMode vWrap )
+void Sampler::SetWrapMode( WrapMode::Type uWrap, WrapMode::Type vWrap )
 {
   GetImplementation(*this).SetWrapMode( uWrap, vWrap );
 }
 
-void Sampler::SetAffectsTransparency( bool affectsTransparency )
-{
-  GetImplementation(*this).SetAffectsTransparency( affectsTransparency );
-}
-
 Sampler::Sampler(Internal::Sampler* pointer)
-: Handle( pointer )
+: BaseHandle( pointer )
 {
 }
 
index 4d1b80d..424ab87 100644 (file)
  *
  */
 
-// EXTERNAL INCLUDES
-#include <cstddef> // std::size_t
-#include <string> // std::string
-
 // INTERNAL INCLUDES
 #include <dali/public-api/object/handle.h> // Dali::Handle
-#include <dali/public-api/images/image.h> // Dali::Image
-#include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
+#include <dali/public-api/actors/sampling.h>
 
 namespace Dali
 {
@@ -36,56 +31,19 @@ class Sampler;
 }
 
 /**
- * @brief Sampler is a handle to an object that can be used to provide an image to a material.
+ * @brief Sampler is a handle to an object that can be used to provide the sampling parameters to sample textures
  */
-class DALI_IMPORT_API Sampler : public Handle
+class DALI_IMPORT_API Sampler : public BaseHandle
 {
 public:
 
   /**
-   * @brief Texture filter mode.
-   */
-  enum FilterMode
-  {
-    NONE,     ///< Use GL system defaults (minification NEAREST_MIPMAP_LINEAR, magnification LINEAR)
-    DEFAULT,  ///< Use dali defaults (minification LINEAR, magnification LINEAR)
-    NEAREST,  ///< Filter nearest
-    LINEAR    ///< Filter linear
-  };
-
-  /**
-   * @brief Texture wrap mode.
-   */
-  enum WrapMode
-  {
-    CLAMP_TO_EDGE,    ///< The texture coordinates get clamped to the range [0, 1]
-    REPEAT,           ///< Only the fractional part of the texture coordinates is used
-    MIRRORED_REPEAT,  ///< If the integer part of the texture coordinate is odd then it uses
-                      ///< the fractional part, if it's even it uses 1 - the fractional part
-  };
-
-  /**
-   * @brief An enumeration of properties belonging to the Sampler class.
-   */
-  struct Property
-  {
-    enum
-    {
-      MINIFICATION_FILTER = DEFAULT_OBJECT_PROPERTY_START_INDEX,  ///< name "minification-filter",  type STRING
-      MAGNIGICATION_FILTER,                                       ///< name "magnification-filter", type STRING
-      U_WRAP,                                                     ///< name "u-wrap",               type STRING
-      V_WRAP,                                                     ///< name "v-wrap",               type STRING
-      AFFECTS_TRANSPARENCY,                                       ///< name "affects-transparency", type BOOLEAN
-    };
-  };
-
-  /**
    * @brief Creates a new Sampler object
    *
    * @param[in] image Image used by this sampler
    * @param[in] uniformName String with the name of the uniform
    */
-  static Sampler New( Image& image, const std::string& uniformName );
+  static Sampler New();
 
   /**
    * @brief Default constructor, creates an empty handle
@@ -121,34 +79,6 @@ public:
    */
   Sampler& operator=( const Sampler& handle );
 
-  /**
-   * @brief Sets the name of the shader uniform that will use this sampler
-   *
-   * @param[in] name String with the name of the uniform
-   */
-  void SetUniformName( const std::string& name );
-
-  /**
-   * @brief Gets the name of the shader uniform that this sampler uses
-   *
-   * @return Returns the name of the uniform
-   */
-  const std::string& GetUniformName() const;
-
-  /**
-   * @brief Set the image used by this sampler
-   *
-   * @param[in] image Image used by this sampler
-   */
-  void SetImage( Image& image );
-
-  /**
-   * @brief Retrieve the image used by this sampler
-   *
-   * If no image is assigned, an empty handle is returned
-   * @return The image.
-   */
-  Image GetImage() const;
 
   /**
    * @brief Set the filter modes for this sampler
@@ -159,7 +89,7 @@ public:
    * @param[in] minFilter The minification filter that will be used
    * @param[in] magFilter The magnification filter that will be used
    */
-  void SetFilterMode( FilterMode minFilter, FilterMode magFilter );
+  void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter );
 
   /**
    * @brief Set the wrap modes for this sampler
@@ -169,16 +99,7 @@ public:
    * param[in] uWrap Wrap mode for u coordinates
    * param[in] vWrap Wrap mode for v coordinates
    */
-  void SetWrapMode( WrapMode uWrap, WrapMode vWrap );
-
-  /**
-   * @brief Set if this sampler should be considered for opacity hinting
-   *
-   * Calling this function sets the property AFFECTS_TRANSPARENCY
-   *
-   * param[in] affectsTransparency Specifies if this sampler should be considered for opacity hinting
-   */
-  void SetAffectsTransparency( bool affectsTransparency );
+  void SetWrapMode( WrapMode::Type uWrap, WrapMode::Type vWrap );
 
 public:
   /**
index 2332be9..5158f74 100644 (file)
@@ -62,6 +62,7 @@
 #include <dali/internal/render/renderers/render-image-renderer.h>
 #include <dali/internal/render/renderers/render-new-renderer.h>
 #include <dali/internal/render/renderers/render-renderer.h>
+#include <dali/internal/render/renderers/render-sampler.h>
 
 using Dali::Internal::GestureEventProcessor;
 using Dali::Internal::ThreadLocalStorage;
@@ -145,7 +146,7 @@ const int MATERIAL_MEMORY_SIZE(
   sizeof( Internal::SceneGraph::Material ) );
 const int SAMPLER_MEMORY_SIZE(
   sizeof( Internal::Sampler ) +
-  sizeof( Internal::SceneGraph::Sampler ) );
+  sizeof( Internal::Render::Sampler ) );
 const int SHADER_MEMORY_SIZE(
   sizeof( Internal::Shader ) +
   sizeof( Internal::SceneGraph::Shader ) );
index 036a69a..f008580 100644 (file)
@@ -38,51 +38,27 @@ namespace
 // Adjust these shift sizes if the FilterMode enum grows
 const int MINIFY_BIT_SHIFT  = 0;    // Room for 16
 const int MAGNIFY_BIT_SHIFT = 4;
+const int UWRAP_BIT_SHIFT   = 8;
+const int VWRAP_BIT_SHIFT   = 12;
 
 const int MASK_MINIFY_FILTER    = 0x0000000F;
 const int MASK_MAGNIFY_FILTER   = 0x000000F0;
-
-const unsigned int FILTER_MODE_COUNT = 4;
-
-FilterMode::Type FILTER_MODE_OPTIONS[ FILTER_MODE_COUNT ] =
-  { FilterMode::NONE,
-    FilterMode::DEFAULT,
-    FilterMode::NEAREST,
-    FilterMode::LINEAR };
+const int MASK_UWRAP_MODE       = 0x00000F00;
+const int MASK_VWRAP_MODE       = 0x0000F000;
 
 } // namespace
 
 /**
- * Utility to store one of the FilterMode values.
+ * Utility to store one of the sampling parameters values.
  * @param[out] options A bitmask used to store the FilterMode values.
  * @param[in] factor The FilterMode value.
  * @param[in] bitshift Used to shift to the correct part of options.
  */
-void StoreFilterMode( unsigned int& options, FilterMode::Type mode, int bitShift )
+void StoreSamplingParameter( unsigned int& options, unsigned int mode, int bitShift )
 {
-  // Start shifting from 1 as 0 is the unassigned state
-  switch ( mode )
+  if( mode != 0 )
   {
-    case FilterMode::NONE:
-    {
-      // Nothing to do
-      break;
-    }
-    case FilterMode::DEFAULT:
-    {
-      options |= ( 1u << bitShift );
-      break;
-    }
-    case FilterMode::NEAREST:
-    {
-      options |= ( 2u << bitShift );
-      break;
-    }
-    case FilterMode::LINEAR:
-    {
-      options |= ( 3u << bitShift );
-      break;
-    }
+    options |= ( mode << bitShift );
   }
 }
 
@@ -93,33 +69,42 @@ void StoreFilterMode( unsigned int& options, FilterMode::Type mode, int bitShift
  * @param[in] bitshift Used to shift to the correct part of options.
  * @return Return the filter mode.
  */
-FilterMode::Type RetrieveFilterMode( unsigned int options, int mask, int bitShift )
+unsigned int RetrieveSamplingParameter( unsigned int options, int mask, int bitShift )
 {
   unsigned int index = options & mask;
 
   index = ( index >> bitShift );    // Zero based index for array
-
-  DALI_ASSERT_DEBUG( index < FILTER_MODE_COUNT );
-
-  return FILTER_MODE_OPTIONS[ index ];
+  return index;
 }
 
-unsigned int PackBitfield( FilterMode::Type minify, FilterMode::Type magnify )
+unsigned int PackBitfield( FilterMode::Type minify, FilterMode::Type magnify, WrapMode::Type uWrap, WrapMode::Type vWrap )
 {
   unsigned int bitfield = 0;
-  StoreFilterMode( bitfield, minify, MINIFY_BIT_SHIFT );
-  StoreFilterMode( bitfield, magnify, MAGNIFY_BIT_SHIFT );
+  StoreSamplingParameter( bitfield, minify, MINIFY_BIT_SHIFT );
+  StoreSamplingParameter( bitfield, magnify, MAGNIFY_BIT_SHIFT );
+  StoreSamplingParameter( bitfield, uWrap, UWRAP_BIT_SHIFT );
+  StoreSamplingParameter( bitfield, vWrap, VWRAP_BIT_SHIFT );
   return bitfield;
 }
 
 FilterMode::Type GetMinifyFilterMode( unsigned int bitfield )
 {
-  return RetrieveFilterMode( bitfield, MASK_MINIFY_FILTER, MINIFY_BIT_SHIFT );
+  return static_cast<FilterMode::Type>( RetrieveSamplingParameter( bitfield, MASK_MINIFY_FILTER, MINIFY_BIT_SHIFT ) );
 }
 
 FilterMode::Type GetMagnifyFilterMode( unsigned int bitfield )
 {
-  return RetrieveFilterMode( bitfield, MASK_MAGNIFY_FILTER, MAGNIFY_BIT_SHIFT );
+  return static_cast<FilterMode::Type>( RetrieveSamplingParameter( bitfield, MASK_MAGNIFY_FILTER, MAGNIFY_BIT_SHIFT ) );
+}
+
+WrapMode::Type GetUWrapMode( unsigned int bitfield )
+{
+  return static_cast<WrapMode::Type>( RetrieveSamplingParameter( bitfield, MASK_UWRAP_MODE, UWRAP_BIT_SHIFT ) );
+}
+
+WrapMode::Type GetVWrapMode( unsigned int bitfield )
+{
+  return static_cast<WrapMode::Type>( RetrieveSamplingParameter( bitfield, MASK_VWRAP_MODE, VWRAP_BIT_SHIFT ) );
 }
 
 } // namespace ImageSampler
index 2ebd5a4..53c3f0b 100644 (file)
@@ -39,7 +39,7 @@ namespace ImageSampler
    * @param[in] magnify The magnification filter.
    * @return Return the packed bitfield.
    */
-   unsigned int PackBitfield( FilterMode::Type minify, FilterMode::Type magnify );
+   unsigned int PackBitfield( FilterMode::Type minify, FilterMode::Type magnify, WrapMode::Type uWrap = WrapMode::DEFAULT, WrapMode::Type vWrap = WrapMode::DEFAULT );
 
    /**
    * @brief Return the minification filter from a packed bitfield.
@@ -55,6 +55,20 @@ namespace ImageSampler
    */
    FilterMode::Type GetMagnifyFilterMode( unsigned int bitfield );
 
+   /**
+    * @brief Return the wrap mode in x direction from a packed bitfield.
+    *
+    * @return Return the wrap mode.
+    */
+   WrapMode::Type GetUWrapMode( unsigned int bitfield );
+
+   /**
+    * @brief Return the wrap mode in y direction from a packed bitfield.
+    *
+    * @return Return the wrap mode.
+    */
+   WrapMode::Type GetVWrapMode( unsigned int bitfield );
+
 } // namespace ImageSampler
 
 } // namespace Internal
index b243f8d..e3d5d2b 100644 (file)
 #include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
 #include <dali/internal/update/manager/update-manager.h>
 #include <dali/internal/update/rendering/scene-graph-material.h>
-#include <dali/internal/update/rendering/scene-graph-sampler.h>
+//#include <dali/internal/update/rendering/scene-graph-sampler.h>
+
+//EXTERNAL INCLUDES
+#include <string>
 
 namespace Dali
 {
@@ -83,35 +86,98 @@ Shader* Material::GetShader() const
   return mShader.Get();
 }
 
-void Material::AddSampler( Sampler& sampler )
+size_t Material::AddTexture( ImagePtr image, const std::string& uniformName, SamplerPtr sampler )
+{
+  size_t index = mTextures.size();
+  mTextures.push_back( Texture( uniformName, image, sampler ) );
+
+  Render::Sampler* renderSampler(0);
+  if( sampler )
+  {
+    renderSampler = sampler->GetSamplerRenderObject();
+  }
+
+  if( mOnStage )
+  {
+    image->Connect();
+  }
+
+  SceneGraph::AddTextureMessage( GetEventThreadServices(), *mSceneObject, uniformName, image->GetResourceId(), renderSampler );
+  return index;
+}
+
+void Material::RemoveTexture( size_t index )
+{
+  if( index < GetNumberOfTextures() )
+  {
+    mTextures.erase( mTextures.begin() + index );
+    SceneGraph::RemoveTextureMessage( GetEventThreadServices(), *mSceneObject, index );
+  }
+}
+
+void Material::SetTextureImage( size_t index, Image* image )
+{
+  if( index < GetNumberOfTextures() )
+  {
+    if( mTextures[index].mImage && mOnStage )
+    {
+      mTextures[index].mImage->Disconnect();
+      image->Connect();
+    }
+
+    mTextures[index].mImage.Reset(image);
+    SceneGraph::SetTextureImageMessage( GetEventThreadServices(), *mSceneObject, index, mTextures[index].mImage.Get()->GetResourceId() );
+  }
+}
+
+void Material::SetTextureSampler( size_t index, Sampler* sampler )
 {
-  SamplerConnector connector;
-  connector.Set( sampler, OnStage() );
-  mSamplerConnectors.push_back( connector );
+  if( index < GetNumberOfTextures() )
+  {
+    mTextures[index].mSampler.Reset(sampler);
+
+    Render::Sampler* renderSampler(0);
+    if( sampler )
+    {
+      renderSampler = sampler->GetSamplerRenderObject();
+    }
+    SceneGraph::SetTextureSamplerMessage( GetEventThreadServices(), *mSceneObject, index,  renderSampler );
+  }
+}
 
-  SceneGraph::Sampler& sceneGraphSampler = *sampler.GetSamplerSceneObject();
-  SceneGraph::AddSamplerMessage( GetEventThreadServices(), *mSceneObject, sceneGraphSampler );
+void Material::SetTextureUniformName( size_t index, const std::string& uniformName )
+{
+  if( index < GetNumberOfTextures() )
+  {
+    SceneGraph::SetTextureUniformNameMessage( GetEventThreadServices(), *mSceneObject, index,  uniformName );
+  }
 }
 
-std::size_t Material::GetNumberOfSamplers() const
+int Material::GetTextureIndex( const std::string& uniformName )
 {
-  return mSamplerConnectors.size();
+  size_t textureCount(GetNumberOfTextures());
+  for( size_t i(0); i<textureCount; ++i )
+  {
+    if( uniformName.compare( mTextures[i].mUniformName ) == 0 )
+    {
+      return i;
+    }
+  }
+
+  return -1;
 }
 
-void Material::RemoveSampler( std::size_t index )
+void Material::SetTextureAffectsTransparency( size_t index, bool affectsTransparency )
 {
-  if( index < mSamplerConnectors.size() )
+  if( index < GetNumberOfTextures() )
   {
-    SamplerConnectorContainer::iterator iter = mSamplerConnectors.begin() + index;
-    SceneGraph::Sampler& sceneGraphSampler = *iter->Get()->GetSamplerSceneObject();
-    SceneGraph::RemoveSamplerMessage( GetEventThreadServices(), *mSceneObject, sceneGraphSampler );
-    mSamplerConnectors.erase( iter );
+    SceneGraph::SetTextureAffectsTransparencyMessage( GetEventThreadServices(), *mSceneObject, index,  affectsTransparency );
   }
 }
 
-Sampler* Material::GetSamplerAt( unsigned int index ) const
+size_t Material::GetNumberOfTextures() const
 {
-  return mSamplerConnectors[index].Get().Get();
+  return mTextures.size();
 }
 
 void Material::SetFaceCullingMode( Dali::Material::FaceCullingMode cullingMode )
@@ -547,26 +613,30 @@ void Material::Connect()
 {
   mOnStage = true;
 
-  SamplerConnectorContainer::const_iterator end = mSamplerConnectors.end();
-  for( SamplerConnectorContainer::iterator it = mSamplerConnectors.begin();
-       it < end;
-       ++it )
+  for( size_t i(0); i<mTextures.size(); ++i )
   {
-    it->OnStageConnect();
+    if( mTextures[i].mImage )
+    {
+      mTextures[i].mImage->Connect();
+      if( mTextures[i].mImage->GetResourceId() != 0 )
+      {
+        SceneGraph::SetTextureImageMessage( GetEventThreadServices(), *mSceneObject, i, mTextures[i].mImage->GetResourceId() );
+      }
+    }
   }
 }
 
 void Material::Disconnect()
 {
-  mOnStage = false;
-
-  SamplerConnectorContainer::const_iterator end = mSamplerConnectors.end();
-  for( SamplerConnectorContainer::iterator it = mSamplerConnectors.begin();
-       it < end;
-       ++it )
+  for( size_t i(0); i<mTextures.size(); ++i )
   {
-    it->OnStageDisconnect();
+    if( mTextures[i].mImage )
+    {
+      mTextures[i].mImage->Disconnect();
+    }
   }
+
+  mOnStage = false;
 }
 
 Material::Material()
index 9c4f54e..5b36fe7 100644 (file)
@@ -70,26 +70,45 @@ public:
   Shader* GetShader() const;
 
   /**
-   * @copydoc Dali::Material::AddSampler()
+   * @copydoc Dali::Material::AddTexture()
    */
-  void AddSampler( Sampler& sampler );
+  size_t AddTexture( ImagePtr image, const std::string& uniformName, SamplerPtr sampler );
 
   /**
-   * @copydoc Dali::Material::GetNumberOfSamplers()
+   * @copydoc Dali::Material::RemoveTexture()
    */
-  std::size_t GetNumberOfSamplers() const;
+  void RemoveTexture( size_t index );
 
   /**
-   * @copydoc Dali::Material::RemoveSampler()
+   * @copydoc Dali::Material::SetTextureImage()
    */
-  void RemoveSampler( std::size_t index );
+  void SetTextureImage( size_t index, Image* image );
 
   /**
-   * @copydoc Dali::Material::GetSamplerAt()
+   * @copydoc Dali::Material::SetTextureSampler()
    */
-  Sampler* GetSamplerAt( unsigned int index ) const;
+  void SetTextureSampler( size_t index, Sampler* sampler );
 
   /**
+   * @copydoc Dali::Material::SetTextureUniformName()
+   */
+  void SetTextureUniformName( size_t index, const std::string& uniformName );
+
+  /**
+   * @copydoc Dali::Material::GetTextureIndex()
+   */
+  int GetTextureIndex( const std::string& uniformName );
+
+  /**
+   * @copydoc Dali::Material::SetTextureAffectsTransparency()
+   */
+  void SetTextureAffectsTransparency( size_t index, bool affectsTransparency );
+
+  /**
+   * @copydoc Dali::Material::GetNumberOfTextures()
+   */
+  size_t GetNumberOfTextures() const;
+  /**
    * @copydoc Dali::Material::SetFaceCullingMode()
    */
   void SetFaceCullingMode( Dali::Material::FaceCullingMode cullingMode );
@@ -252,6 +271,26 @@ public: // Functions from Connectable
   virtual void Disconnect();
 
 private: // implementation
+
+  struct Texture
+  {
+    Texture()
+    :mUniformName(""),
+     mImage(NULL),
+     mSampler( NULL )
+    {}
+
+    Texture( const std::string& name, ImagePtr image, SamplerPtr sampler )
+    :mUniformName(name),
+     mImage( image ),
+     mSampler( sampler )
+    {}
+
+    std::string mUniformName;
+    ImagePtr    mImage;
+    SamplerPtr  mSampler;
+  };
+
   Material();
 
   /**
@@ -271,16 +310,13 @@ private: // unimplemented methods
 
 private: //data
   IntrusivePtr<Shader> mShader; ///< Connector that holds the shader used by this material
-
-  typedef ObjectConnector<Sampler> SamplerConnector;
-  typedef std::vector< SamplerConnector > SamplerConnectorContainer;
-  SamplerConnectorContainer mSamplerConnectors; ///< Vector of connectors that hold the samplers used by this material
-
+  std::vector<Material::Texture> mTextures; ///<Vector of textures used by this material
   SceneGraph::Material* mSceneObject;
 
   BlendingMode::Type mBlendingMode; ///< Local store
   BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask
   bool mOnStage;
+
 };
 
 } // namespace Internal
index 616e4b5..de2e75e 100644 (file)
 #include <dali/internal/event/rendering/sampler-impl.h> // Dali::Internal::Sampler
 
 // INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
 #include <dali/devel-api/rendering/sampler.h> // Dali::Internal::Sampler
-#include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
-#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
-#include <dali/internal/update/rendering/scene-graph-sampler.h> // Dali::Internal::SceneGraph::Sampler
+#include <dali/internal/event/common/stage-impl.h>
 #include <dali/internal/update/manager/update-manager.h>
+#include <dali/internal/render/renderers/render-sampler.h>
 
 namespace Dali
 {
 namespace Internal
 {
 
-namespace
-{
-
-/**
- *            |name                    |type     |writable|animatable|constraint-input|enum for index-checking|
- */
-DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "minification-filter",   INTEGER,   true, false,  true, Dali::Sampler::Property::MINIFICATION_FILTER )
-DALI_PROPERTY( "magnification-filter",  INTEGER,   true, false,  true, Dali::Sampler::Property::MAGNIGICATION_FILTER )
-DALI_PROPERTY( "u-wrap",                INTEGER,   true, false,  true, Dali::Sampler::Property::U_WRAP )
-DALI_PROPERTY( "v-wrap",                INTEGER,   true, false,  true, Dali::Sampler::Property::V_WRAP )
-DALI_PROPERTY( "affects-transparency",  BOOLEAN,  true, false,  true, Dali::Sampler::Property::AFFECTS_TRANSPARENCY )
-DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
-
-const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> SAMPLER_IMPL = { DEFAULT_PROPERTY_DETAILS };
-
-BaseHandle Create()
-{
-  return Dali::BaseHandle();
-}
-
-TypeRegistration mType( typeid( Dali::Sampler ), typeid( Dali::Handle ), Create );
-
-} // unnamed namespace
-
-SamplerPtr Sampler::New( const std::string& textureUnitUniformName )
+SamplerPtr Sampler::New( )
 {
   SamplerPtr sampler( new Sampler() );
-  sampler->Initialize( textureUnitUniformName );
+  sampler->Initialize();
   return sampler;
 }
 
-void Sampler::SetTextureUnitUniformName( const std::string& name )
-{
-  SetTextureUnitUniformNameMessage( GetEventThreadServices(), *mSceneObject, name);
-}
-
-const std::string& Sampler::GetTextureUnitUniformName() const
-{
-  return mSceneObject->GetTextureUnitUniformName();
-}
-
-void Sampler::SetImage( ImagePtr& image )
-{
-  // Keep a reference to the image object
-  mImageConnector.Set( image, OnStage() );
-
-  // sceneObject is being used in a separate thread; queue a message to set
-  if( mOnStage )
-  {
-    unsigned int resourceId = image->GetResourceId();
-    if( resourceId != 0 )
-    {
-      SetTextureMessage( GetEventThreadServices(), *mSceneObject, resourceId );
-    }
-  }
-}
-
-ImagePtr Sampler::GetImage() const
-{
-  return mImageConnector.Get();
-}
-
-void Sampler::SetFilterMode( Dali::Sampler::FilterMode minFilter, Dali::Sampler::FilterMode magFilter )
-{
-  if( NULL != mSceneObject )
-  {
-    SetFilterModeMessage( GetEventThreadServices(), *mSceneObject, minFilter, magFilter );
-  }
-}
-
-void Sampler::SetWrapMode( Dali::Sampler::WrapMode uWrap, Dali::Sampler::WrapMode vWrap )
-{
-  if( NULL != mSceneObject )
-  {
-    SetWrapModeMessage( GetEventThreadServices(), *mSceneObject, uWrap, vWrap );
-  }
-}
-
-void Sampler::SetAffectsTransparency( bool affectsTransparency )
-{
-  if( NULL != mSceneObject )
-  {
-    SceneGraph::DoubleBufferedPropertyMessage<bool>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mAffectsTransparency, &SceneGraph::DoubleBufferedProperty<bool>::Set, affectsTransparency );
-  }
-}
-
-const SceneGraph::Sampler* Sampler::GetSamplerSceneObject() const
-{
-  return mSceneObject;
-}
-
-SceneGraph::Sampler* Sampler::GetSamplerSceneObject()
-{
-  return mSceneObject;
-}
-
-unsigned int Sampler::GetDefaultPropertyCount() const
-{
-  return SAMPLER_IMPL.GetDefaultPropertyCount();
-}
-
-void Sampler::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
-  SAMPLER_IMPL.GetDefaultPropertyIndices( indices );
-}
-
-const char* Sampler::GetDefaultPropertyName(Property::Index index) const
-{
-  return SAMPLER_IMPL.GetDefaultPropertyName( index );
-}
-
-Property::Index Sampler::GetDefaultPropertyIndex( const std::string& name ) const
+void Sampler::SetFilterMode( Dali::FilterMode::Type minFilter, Dali::FilterMode::Type magFilter )
 {
-  return SAMPLER_IMPL.GetDefaultPropertyIndex( name );
-}
-
-bool Sampler::IsDefaultPropertyWritable( Property::Index index ) const
-{
-  return SAMPLER_IMPL.IsDefaultPropertyWritable( index );
-}
-
-bool Sampler::IsDefaultPropertyAnimatable( Property::Index index ) const
-{
-  return SAMPLER_IMPL.IsDefaultPropertyAnimatable( index );
-}
-
-bool Sampler::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
-  return SAMPLER_IMPL.IsDefaultPropertyAConstraintInput( index );
-}
-
-Property::Type Sampler::GetDefaultPropertyType( Property::Index index ) const
-{
-  return SAMPLER_IMPL.GetDefaultPropertyType( index );
-}
-
-void Sampler::SetDefaultProperty( Property::Index index,
-                                  const Property::Value& propertyValue )
-{
-  switch( index )
+  if( NULL != mRenderObject )
   {
-    case Dali::Sampler::Property::MINIFICATION_FILTER:
-    {
-      SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mMinFilter, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
-      break;
-    }
-    case Dali::Sampler::Property::MAGNIGICATION_FILTER:
-    {
-      SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mMagFilter, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
-      break;
-    }
-    case Dali::Sampler::Property::U_WRAP:
-    {
-      SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mUWrapMode, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
-      break;
-    }
-    case Dali::Sampler::Property::V_WRAP:
-    {
-      SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mVWrapMode, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
-      break;
-    }
-    case Dali::Sampler::Property::AFFECTS_TRANSPARENCY:
-    {
-      SceneGraph::DoubleBufferedPropertyMessage<bool>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mAffectsTransparency, &SceneGraph::DoubleBufferedProperty<bool>::Set, propertyValue.Get<bool>() );
-      break;
-    }
+    SetFilterModeMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, (unsigned int)minFilter, (unsigned int)magFilter );
   }
 }
 
-void Sampler::SetSceneGraphProperty( Property::Index index,
-                                     const PropertyMetadata& entry,
-                                     const Property::Value& value )
-{
-  SAMPLER_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
-  OnPropertySet(index, value);
-}
-
-Property::Value Sampler::GetDefaultProperty( Property::Index index ) const
+void Sampler::SetWrapMode( Dali::WrapMode::Type uWrap, Dali::WrapMode::Type vWrap )
 {
-  BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
-  Property::Value value;
-
-  switch( index )
+  if( NULL != mRenderObject )
   {
-    case Dali::Sampler::Property::MINIFICATION_FILTER:
-    {
-      value = mSceneObject->mMinFilter[bufferIndex];
-      break;
-    }
-    case Dali::Sampler::Property::MAGNIGICATION_FILTER:
-    {
-      value = mSceneObject->mMagFilter[bufferIndex];
-      break;
-    }
-    case Dali::Sampler::Property::U_WRAP:
-    {
-      value = mSceneObject->mUWrapMode[bufferIndex];
-      break;
-    }
-    case Dali::Sampler::Property::V_WRAP:
-    {
-      value = mSceneObject->mVWrapMode[bufferIndex];
-      break;
-    }
-    case Dali::Sampler::Property::AFFECTS_TRANSPARENCY:
-    {
-      value = mSceneObject->mAffectsTransparency[bufferIndex];
-      break;
-    }
+    SetWrapModeMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, (unsigned int)uWrap, (unsigned int)vWrap );
   }
-  return value;
-}
-
-const SceneGraph::PropertyOwner* Sampler::GetPropertyOwner() const
-{
-  return mSceneObject;
 }
 
-const SceneGraph::PropertyOwner* Sampler::GetSceneObject() const
+Render::Sampler* Sampler::GetSamplerRenderObject()
 {
-  return mSceneObject;
+  return mRenderObject;
 }
 
-const SceneGraph::PropertyBase* Sampler::GetSceneObjectAnimatableProperty( Property::Index index ) const
-{
-  DALI_ASSERT_ALWAYS( IsPropertyAnimatable( index ) && "Property is not animatable" );
-
-  const SceneGraph::PropertyBase* property = NULL;
-
-  if( OnStage() )
-  {
-    property = SAMPLER_IMPL.GetRegisteredSceneGraphProperty( this,
-                                                             &Sampler::FindAnimatableProperty,
-                                                             &Sampler::FindCustomProperty,
-                                                             index );
-
-    if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
-    {
-      // No animatable default props
-      DALI_ASSERT_ALWAYS( 0 && "Property is not animatable" );
-    }
-  }
-
-  return property;
-}
-
-const PropertyInputImpl* Sampler::GetSceneObjectInputProperty( Property::Index index ) const
-{
-  const PropertyInputImpl* property = NULL;
-
-  if( OnStage() )
-  {
-    const SceneGraph::PropertyBase* baseProperty =
-      SAMPLER_IMPL.GetRegisteredSceneGraphProperty( this,
-                                                    &Sampler::FindAnimatableProperty,
-                                                    &Sampler::FindCustomProperty,
-                                                    index );
-    property = static_cast<const PropertyInputImpl*>( baseProperty );
-
-    if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
-    {
-      switch( index )
-      {
-        case Dali::Sampler::Property::MINIFICATION_FILTER:
-        {
-          property = &mSceneObject->mMinFilter;
-          break;
-        }
-        case Dali::Sampler::Property::MAGNIGICATION_FILTER:
-        {
-          property = &mSceneObject->mMagFilter;
-          break;
-        }
-        case Dali::Sampler::Property::U_WRAP:
-        {
-          property = &mSceneObject->mUWrapMode;
-          break;
-        }
-        case Dali::Sampler::Property::V_WRAP:
-        {
-          property = &mSceneObject->mVWrapMode;
-          break;
-        }
-        case Dali::Sampler::Property::AFFECTS_TRANSPARENCY:
-        {
-          property = &mSceneObject->mAffectsTransparency;
-          break;
-        }
-      }
-    }
-  }
-
-  return property;
-}
-
-int Sampler::GetPropertyComponentIndex( Property::Index index ) const
-{
-  return Property::INVALID_COMPONENT_INDEX;
-}
-
-bool Sampler::OnStage() const
-{
-  return mOnStage;
-}
-
-void Sampler::Connect()
-{
-  mOnStage = true;
-
-  mImageConnector.OnStageConnect();
-
-  // sceneObject is being used in a separate thread; queue a message to set
-  unsigned int resourceId = mImageConnector.Get()->GetResourceId();
-  SetTextureMessage( GetEventThreadServices(), *mSceneObject, resourceId );
-}
-
-void Sampler::Disconnect()
-{
-  mOnStage = false;
-
-  mImageConnector.OnStageDisconnect();
-}
 
 Sampler::Sampler()
-: mSceneObject( NULL ),
 mOnStage( false )
+:mEventThreadServices( *Stage::GetCurrent() ),
mRenderObject( NULL )
 {
 }
 
-void Sampler::Initialize( const std::string& textureUnitUniformName )
+void Sampler::Initialize()
 {
-  EventThreadServices& eventThreadServices = GetEventThreadServices();
-  SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
-
-  mSceneObject = new SceneGraph::Sampler( textureUnitUniformName );
-  AddMessage( updateManager, updateManager.GetSamplerOwner(), *mSceneObject );
+  SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
 
-  eventThreadServices.RegisterObject( this );
+  mRenderObject = new Render::Sampler();
+  AddSamplerMessage( updateManager, *mRenderObject );
 }
 
 Sampler::~Sampler()
 {
-  if( EventThreadServices::IsCoreRunning() )
+  if( EventThreadServices::IsCoreRunning() && mRenderObject )
   {
-    EventThreadServices& eventThreadServices = GetEventThreadServices();
-    SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
-    RemoveMessage( updateManager, updateManager.GetSamplerOwner(), *mSceneObject );
-
-    eventThreadServices.UnregisterObject( this );
+    SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager();
+    RemoveSamplerMessage( updateManager, *mRenderObject );
   }
 }
 
index 1cfbea3..387147f 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 // INTERNAL INCLUDES
+#include <dali/public-api/actors/sampling.h>
 #include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
 #include <dali/devel-api/rendering/sampler.h> // Dali::Sampler
@@ -31,7 +32,7 @@ namespace Dali
 {
 namespace Internal
 {
-namespace SceneGraph
+namespace Render
 {
 class Sampler;
 }
@@ -43,7 +44,7 @@ typedef IntrusivePtr<Sampler> SamplerPtr;
  * Sampler is an object that contains an array of structures of values that
  * can be accessed as properties.
  */
-class Sampler : public Object, public Connectable
+class Sampler : public BaseObject
 {
 public:
 
@@ -51,153 +52,24 @@ public:
    * Create a new Sampler.
    * @return A smart-pointer to the newly allocated Sampler.
    */
-  static SamplerPtr New( const std::string& textureUnitUniformName );
-
-  /**
-   * @copydoc Dali::Sampler::SetUniformName()
-   */
-  void SetTextureUnitUniformName( const std::string& name );
-
-  /**
-   * @copydoc Dali::Sampler::GetUniformName()
-   */
-  const std::string& GetTextureUnitUniformName() const;
-
-  /**
-   * @copydoc Dali::Sampler::SetImage()
-   */
-  void SetImage( ImagePtr& image );
-
-  /**
-   * @copydoc Dali::Sampler::GetImage()
-   */
-  ImagePtr GetImage() const;
+  static SamplerPtr New( );
 
   /**
    * @copydoc Dali::Sampler::SetFilterMode()
    */
-  void SetFilterMode( Dali::Sampler::FilterMode minFilter, Dali::Sampler::FilterMode magFilter );
+  void SetFilterMode( Dali::FilterMode::Type minFilter, Dali::FilterMode::Type magFilter );
 
   /**
    * @copydoc Dali::Sampler::SetWrapMode()
    */
-  void SetWrapMode( Dali::Sampler::WrapMode uWrap, Dali::Sampler::WrapMode vWrap );
-
-  /**
-   * @copydoc Dali::Sampler::SetAffectsTransparency()
-   */
-  void SetAffectsTransparency( bool affectsTransparency );
+  void SetWrapMode( Dali::WrapMode::Type uWrap, Dali::WrapMode::Type vWrap );
 
   /**
-   * @brief Get the sampler scene object
+   * Get the render thread sampler
    *
-   * @return the sampler scene object
+   * @return The render thread sampler
    */
-  const SceneGraph::Sampler* GetSamplerSceneObject() const;
-
-  /**
-   * Retrieve the scene-graph sampler added by this object.
-   * @return A pointer to the sampler, or NULL if no sampler has been added to the scene-graph.
-   */
-  SceneGraph::Sampler* GetSamplerSceneObject();
-
-public: // Default property extensions from Object
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
-   */
-  virtual unsigned int GetDefaultPropertyCount() const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
-   */
-  virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
-   */
-  virtual const char* GetDefaultPropertyName(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
-   */
-  virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
-   */
-  virtual bool IsDefaultPropertyWritable(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
-   */
-  virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
-   */
-  virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
-   */
-  virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::SetDefaultProperty()
-   */
-  virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
-
-  /**
-   * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
-   */
-  virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
-
-  /**
-   * @copydoc Dali::Internal::Object::GetDefaultProperty()
-   */
-  virtual Property::Value GetDefaultProperty( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetPropertyOwner()
-   */
-  virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetSceneObject()
-   */
-  virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
-   */
-  virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
-   */
-  virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
-
-  /**
-   * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
-   */
-  virtual int GetPropertyComponentIndex( Property::Index index ) const;
-
-public: // Functions from Connectable
-  /**
-   * @copydoc Dali::Internal::Connectable::OnStage()
-   */
-  virtual bool OnStage() const;
-
-  /**
-   * @copydoc Dali::Internal::Connectable::Connect()
-   */
-  virtual void Connect();
-
-  /**
-   * @copydoc Dali::Internal::Connectable::Disconnect()
-   */
-  virtual void Disconnect();
+  Render::Sampler* GetSamplerRenderObject();
 
 private:
   Sampler();
@@ -205,7 +77,7 @@ private:
   /**
    * Second stage initialization
    */
-  void Initialize( const std::string& textureUnitUniformName );
+  void Initialize( );
 
 protected:
   /**
@@ -214,10 +86,9 @@ protected:
   virtual ~Sampler();
 
 private: // data
-  //TODO: MESH_REWORK : change to ObjectConnector
-  ImageConnector mImageConnector;
-  SceneGraph::Sampler* mSceneObject;
-  bool mOnStage;
+  EventThreadServices& mEventThreadServices;    ///<Used to send messages to the render thread via the update thread
+  Render::Sampler* mRenderObject;               ///<Render thread sampler for this sampler
+
 };
 
 } // namespace Internal
index 55f82f4..48e2c43 100644 (file)
@@ -164,7 +164,6 @@ internal_src_files = \
   $(internal_src_dir)/update/rendering/scene-graph-geometry.cpp \
   $(internal_src_dir)/update/rendering/scene-graph-material.cpp \
   $(internal_src_dir)/update/rendering/scene-graph-renderer.cpp \
-  $(internal_src_dir)/update/rendering/scene-graph-sampler.cpp \
   $(internal_src_dir)/update/resources/bitmap-metadata.cpp \
   $(internal_src_dir)/update/resources/resource-manager.cpp \
   $(internal_src_dir)/update/resources/resource-tracker.cpp \
index fcaf135..dd6a9c6 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali/internal/render/common/render-manager.h>
 
 // INTERNAL INCLUDES
+#include <dali/public-api/actors/sampling.h>
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/common/stage.h>
 #include <dali/public-api/render-tasks/render-task.h>
@@ -36,6 +37,7 @@
 #include <dali/internal/render/gl-resources/texture-cache.h>
 #include <dali/internal/render/renderers/render-renderer.h>
 #include <dali/internal/render/renderers/render-geometry.h>
+#include <dali/internal/render/renderers/render-sampler.h>
 #include <dali/internal/render/shaders/program-controller.h>
 
 // Uncomment the next line to enable frame snapshot logging
@@ -73,6 +75,9 @@ typedef RendererOwnerContainer::Iterator       RendererOwnerIter;
 typedef OwnerContainer< RenderGeometry* >      RenderGeometryOwnerContainer;
 typedef RenderGeometryOwnerContainer::Iterator RenderGeometryOwnerIter;
 
+typedef OwnerContainer< Render::Sampler* >    SamplerOwnerContainer;
+typedef SamplerOwnerContainer::Iterator       SamplerOwnerIter;
+
 typedef OwnerContainer< RenderTracker* >       RenderTrackerContainer;
 typedef RenderTrackerContainer::Iterator       RenderTrackerIter;
 typedef RenderTrackerContainer::ConstIterator  RenderTrackerConstIter;
@@ -97,6 +102,7 @@ struct RenderManager::Impl
     renderBufferIndex( SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX ),
     defaultSurfaceRect(),
     rendererContainer(),
+    samplerContainer(),
     renderersAdded( false ),
     firstRenderCompleted( false ),
     defaultShader( NULL ),
@@ -157,6 +163,7 @@ struct RenderManager::Impl
   Rect<int>                     defaultSurfaceRect;       ///< Rectangle for the default surface we are rendering to
 
   RendererOwnerContainer        rendererContainer;        ///< List of owned renderers
+  SamplerOwnerContainer         samplerContainer;         ///< List of owned samplers
   RenderGeometryOwnerContainer  renderGeometryContainer;  ///< List of owned RenderGeometries
 
   bool                          renderersAdded;
@@ -285,6 +292,38 @@ void RenderManager::RemoveRenderer( Render::Renderer* renderer )
   }
 }
 
+void RenderManager::AddSampler( Render::Sampler* sampler )
+{
+  mImpl->samplerContainer.PushBack( sampler );
+}
+
+void RenderManager::RemoveSampler( Render::Sampler* sampler )
+{
+  DALI_ASSERT_DEBUG( NULL != sampler );
+
+  SamplerOwnerContainer& samplers = mImpl->samplerContainer;
+
+  // Find the sampler
+  for ( SamplerOwnerIter iter = samplers.Begin(); iter != samplers.End(); ++iter )
+  {
+    if ( *iter == sampler )
+    {
+      samplers.Erase( iter ); // Sampler found; now destroy it
+      break;
+    }
+  }
+}
+
+void RenderManager::SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode )
+{
+  sampler->SetFilterMode( (Dali::FilterMode::Type)minFilterMode, (Dali::FilterMode::Type)magFilterMode );
+}
+
+void RenderManager::SetWrapMode( Render::Sampler* sampler, unsigned int uWrapMode, unsigned int vWrapMode )
+{
+  sampler->SetWrapMode( (Dali::WrapMode::Type)uWrapMode, (Dali::WrapMode::Type)vWrapMode );
+}
+
 void RenderManager::AddGeometry( RenderGeometry* renderGeometry )
 {
   mImpl->renderGeometryContainer.PushBack( renderGeometry );
@@ -296,7 +335,7 @@ void RenderManager::RemoveGeometry( RenderGeometry* renderGeometry )
 
   RenderGeometryOwnerContainer& geometries = mImpl->renderGeometryContainer;
 
-  // Find the renderer
+  // Find the geometry
   for ( RenderGeometryOwnerIter iter = geometries.Begin(); iter != geometries.End(); ++iter )
   {
     if ( *iter == renderGeometry )
index 04aecdc..62f1986 100644 (file)
@@ -45,6 +45,7 @@ class ShaderSaver;
 namespace Render
 {
 class Renderer;
+class Sampler;
 }
 
 namespace SceneGraph
@@ -156,6 +157,34 @@ public:
   void RemoveRenderer( Render::Renderer* renderer );
 
   /**
+   * Add a sampler to the render manager.
+   * @param[in] sampler The sampler to add.
+   * @post sampler is owned by RenderManager
+   */
+  void AddSampler( Render::Sampler* sampler );
+
+  /**
+   * Remove a sampler from the render manager.
+   * @param[in] sampler The sampler to remove.
+   * @post sampler is destroyed.
+   */
+  void RemoveSampler( Render::Sampler* sampler );
+
+  /**
+   * Set minification and magnification filter modes for a sampler
+   * @param[in] minFilterMode Filter mode to use when the texture is minificated
+   * @param[in] magFilterMode Filter mode to use when the texture is magnified
+   */
+  void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
+
+  /**
+   * Set wrapping mode for a sampler
+   * @param[in] uWrapMode Wrap mode in the x direction
+   * @param[in] vWrapMode Wrap mode in the y direction
+   */
+  void SetWrapMode( Render::Sampler* sampler, unsigned int uWrapMode, unsigned int vWrapMode );
+
+  /**
    * Add a geometry to the render manager.
    * @param[in] geometry The geometry to add.
    * @post geometry is owned by RenderManager
index 16555cc..31dad41 100644 (file)
@@ -65,14 +65,9 @@ Shader& RenderDataProvider::GetShader() const
   return *mShader;
 }
 
-void RenderDataProvider::SetSamplers( const RenderDataProvider::Samplers& samplers )
+const RenderDataProvider::Textures& RenderDataProvider::GetTextures() const
 {
-  mSamplers = samplers;
-}
-
-const RenderDataProvider::Samplers& RenderDataProvider::GetSamplers() const
-{
-  return mSamplers;
+  return mTextures;
 }
 
 } // SceneGraph
index 512e0c7..6b60e04 100644 (file)
 #include <dali/internal/render/data-providers/geometry-data-provider.h>
 #include <dali/internal/render/data-providers/material-data-provider.h>
 #include <dali/internal/render/data-providers/node-data-provider.h>
-#include <dali/internal/render/data-providers/sampler-data-provider.h>
 #include <dali/internal/render/data-providers/property-buffer-data-provider.h>
 #include <dali/internal/render/data-providers/uniform-map-data-provider.h>
-
+#include <dali/internal/render/renderers/render-texture.h>
 namespace Dali
 {
 namespace Internal
@@ -47,7 +46,7 @@ class RenderDataProvider
 {
 public:
   typedef Dali::Vector< const PropertyBufferDataProvider* > VertexBuffers;
-  typedef Dali::Vector< const SamplerDataProvider* > Samplers;
+  typedef std::vector< Render::Texture > Textures;
 
   /**
    * Constructor.
@@ -99,22 +98,16 @@ public:
   Shader& GetShader() const;
 
   /**
-   * Set the sampler data providers
-   * @param[in] samplers The sampler data providers
-   */
-  void SetSamplers( const Samplers& samplers );
-
-  /**
-   * Returns the list of sampler data providers
-   * @return The list of samplers
+   * Returns the list of textures
+   * @return The list of textures
    */
-  const Samplers& GetSamplers() const;
+  const Textures& GetTextures() const;
 
 private:
   const MaterialDataProvider*   mMaterialDataProvider;
   const UniformMapDataProvider* mUniformMapDataProvider;
   Shader*                       mShader;
-  Samplers                      mSamplers;
+  Textures                      mTextures;
 
 // Give Renderer access to our private data to reduce copying vectors on construction.
   friend class Renderer;
diff --git a/dali/internal/render/data-providers/sampler-data-provider.h b/dali/internal/render/data-providers/sampler-data-provider.h
deleted file mode 100644 (file)
index ba00955..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-#ifndef DALI_INTERNAL_SCENE_GRAPH_SAMPLER_DATA_PROVIDER_H
-#define DALI_INTERNAL_SCENE_GRAPH_SAMPLER_DATA_PROVIDER_H
-
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <dali/devel-api/rendering/sampler.h>
-#include <dali/integration-api/resource-declarations.h>
-#include <dali/internal/common/buffer-index.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-
-class SamplerDataProvider
-{
-public:
-  typedef Dali::Sampler::FilterMode FilterMode;
-  typedef Dali::Sampler::WrapMode   WrapMode;
-  typedef Dali::Integration::ResourceId ResourceId;
-
-  /**
-   * Constructor
-   */
-  SamplerDataProvider()
-  {
-  }
-
-  /**
-   * Get the sampler's texture unit uniform name
-   * @return The texture unit uniform name
-   */
-  virtual const std::string& GetTextureUnitUniformName() const = 0;
-
-  /**
-   * Get the texture identity associated with the sampler
-   * @return The texture identity
-   */
-  virtual ResourceId GetTextureId( BufferIndex bufferIndex ) const = 0;
-
-  /**
-   * Get the filter mode
-   * @param[in] bufferIndex The buffer index to use
-   * @return The minify filter mode
-   */
-  virtual FilterMode GetMinifyFilterMode( BufferIndex bufferIndex ) const = 0;
-
-  /**
-   * Get the filter mode
-   * @param[in] bufferIndex The buffer index to use
-   * @return The magnify filter mode
-   */
-  virtual FilterMode GetMagnifyFilterMode( BufferIndex bufferIndex ) const = 0;
-
-  /**
-   * Get the horizontal wrap mode
-   * @param[in] bufferIndex The buffer index to use
-   * @return The horizontal wrap mode
-   */
-  virtual WrapMode GetUWrapMode( BufferIndex bufferIndex ) const = 0;
-
-  /**
-   * Get the vertical wrap mode
-   * @param[in] bufferIndex The buffer index to use
-   * @return The vertical wrap mode
-   */
-  virtual WrapMode GetVWrapMode( BufferIndex bufferIndex ) const = 0;
-
-protected:
-  /**
-   * No deletion through this interface
-   */
-  virtual ~SamplerDataProvider()
-  {
-  }
-};
-
-} // namespace SceneGraph
-} // namespace Internal
-} // namespace Dali
-
-#endif // DALI_INTERNAL_SCENE_GRAPH_SAMPLER_DATA_PROVIDER_H
index 22ce859..8a30fb2 100644 (file)
@@ -40,6 +40,7 @@ namespace
 // These match the GL specification
 const GLint SYSTEM_MINIFY_DEFAULT  = GL_NEAREST_MIPMAP_LINEAR;
 const GLint SYSTEM_MAGNIFY_DEFAULT = GL_LINEAR;
+const GLint SYSTEM_WRAP_DEFAULT  = GL_CLAMP_TO_EDGE;
 
 // These are the Dali defaults
 const GLint DALI_MINIFY_DEFAULT  = GL_LINEAR;
@@ -80,6 +81,31 @@ GLint FilterModeToGL( FilterMode::Type filterMode, GLint defaultfilterMode, GLin
   return GL_LINEAR;
 }
 
+GLint WrapModeToGL( WrapMode::Type wrapMode, GLint defaultWrapMode )
+{
+  switch( wrapMode )
+  {
+    case WrapMode::DEFAULT:
+    {
+      return defaultWrapMode;
+    }
+    case WrapMode::CLAMP_TO_EDGE:
+    {
+      return GL_CLAMP_TO_EDGE;
+    }
+    case WrapMode::REPEAT:
+    {
+      return GL_REPEAT;
+    }
+    case WrapMode::MIRRORED_REPEAT:
+    {
+      return GL_MIRRORED_REPEAT;
+    }
+  }
+
+  return defaultWrapMode;
+}
+
 using Dali::Internal::Vertex2D;
 using Dali::Internal::Vertex3D;
 
@@ -266,7 +292,7 @@ void Texture::GetDefaultTextureCoordinates(UvRect& uv) const
 
 }
 
-void Texture::ApplyTextureParameter( TextureUnit unit, GLint filterType, FilterMode::Type currentFilterMode, FilterMode::Type newFilterMode, GLint daliDefault, GLint systemDefault )
+void Texture::ApplyFilterModeParameter( TextureUnit unit, GLint filterType, FilterMode::Type currentFilterMode, FilterMode::Type newFilterMode, GLint daliDefault, GLint systemDefault )
 {
   GLint newFilterModeGL = FilterModeToGL( newFilterMode, daliDefault, systemDefault );
   GLint currentFilterModeGL = FilterModeToGL( currentFilterMode, daliDefault, systemDefault );
@@ -278,23 +304,47 @@ void Texture::ApplyTextureParameter( TextureUnit unit, GLint filterType, FilterM
   }
 }
 
+void Texture::ApplyWrapModeParameter( TextureUnit unit, GLint wrapType, WrapMode::Type currentWrapMode, WrapMode::Type newWrapMode )
+{
+  GLint newWrapModeGL = WrapModeToGL( newWrapMode, SYSTEM_WRAP_DEFAULT );
+  GLint currentWrapModeGL = WrapModeToGL( currentWrapMode, SYSTEM_WRAP_DEFAULT );
+
+  if( newWrapModeGL != currentWrapModeGL )
+  {
+    mContext.ActiveTexture( unit );
+    mContext.TexParameteri( GL_TEXTURE_2D, wrapType, newWrapModeGL );
+  }
+}
+
 void Texture::ApplySampler( TextureUnit unit, unsigned int samplerBitfield )
 {
   if( mSamplerBitfield != samplerBitfield && mId != 0 )
   {
-    ApplyTextureParameter( unit,
+    ApplyFilterModeParameter( unit,
                            GL_TEXTURE_MIN_FILTER,
                            ImageSampler::GetMinifyFilterMode( mSamplerBitfield ),
                            ImageSampler::GetMinifyFilterMode( samplerBitfield ),
                            DALI_MINIFY_DEFAULT,
                            SYSTEM_MINIFY_DEFAULT );
 
-    ApplyTextureParameter( unit,
-                           GL_TEXTURE_MAG_FILTER,
-                           ImageSampler::GetMagnifyFilterMode( mSamplerBitfield ),
-                           ImageSampler::GetMagnifyFilterMode( samplerBitfield ),
-                           DALI_MAGNIFY_DEFAULT,
-                           SYSTEM_MAGNIFY_DEFAULT );
+    ApplyFilterModeParameter( unit,
+                              GL_TEXTURE_MAG_FILTER,
+                              ImageSampler::GetMagnifyFilterMode( mSamplerBitfield ),
+                              ImageSampler::GetMagnifyFilterMode( samplerBitfield ),
+                              DALI_MAGNIFY_DEFAULT,
+                              SYSTEM_MAGNIFY_DEFAULT );
+
+    ApplyWrapModeParameter( unit,
+                            GL_TEXTURE_WRAP_S,
+                            ImageSampler::GetUWrapMode( mSamplerBitfield ),
+                            ImageSampler::GetUWrapMode( samplerBitfield ));
+
+    ApplyWrapModeParameter( unit,
+                            GL_TEXTURE_WRAP_T,
+                            ImageSampler::GetVWrapMode( mSamplerBitfield ),
+                            ImageSampler::GetVWrapMode( samplerBitfield ));
+
+
 
     mSamplerBitfield = samplerBitfield;
   }
index 8fc163b..4e9c56a 100644 (file)
@@ -249,7 +249,7 @@ private:
   void GetDefaultTextureCoordinates(UvRect& uv) const;
 
   /**
-   * @brief Apply the given texture parameters.
+   * @brief Apply the given texture filtering parameters.
    *
    * @param[in] texture unit to use
    * @param[in] filterType Minification or magnification.
@@ -258,7 +258,17 @@ private:
    * @param[in] daliDefault The default dali filter mode for the given filterType.
    * @param[in] systemDefault The default system filter mode for the given filterType.
    */
-  void ApplyTextureParameter( TextureUnit unit, GLint filterType, FilterMode::Type currentFilterMode, FilterMode::Type newFilterMode, GLint daliDefault, GLint systemDefault );
+  void ApplyFilterModeParameter( TextureUnit unit, GLint filterType, FilterMode::Type currentFilterMode, FilterMode::Type newFilterMode, GLint daliDefault, GLint systemDefault );
+
+  /**
+   * @brief Apply the given texture wrap mode.
+   *
+   * @param[in] texture unit to use
+   * @param[in] wrapType UWrap or VWrap
+   * @param[in] currentWrapMode The current wrap mode.
+   * @param[in] newWrapMode The new wrap mode.
+   */
+  void ApplyWrapModeParameter( TextureUnit unit, GLint wrapType, WrapMode::Type currentWrapMode, WrapMode::Type newWrapMode );
 
 protected:
 
index dfbf212..ded4957 100644 (file)
  */
 
 #include "render-new-renderer.h"
-
+#include <dali/devel-api/common/hash.h>
 #include <dali/internal/common/image-sampler.h>
 #include <dali/internal/event/common/property-input-impl.h>
 #include <dali/internal/update/common/uniform-map.h>
 #include <dali/internal/render/data-providers/render-data-provider.h>
 #include <dali/internal/render/gl-resources/texture.h>
 #include <dali/internal/render/gl-resources/texture-cache.h>
+#include <dali/internal/render/renderers/render-sampler.h>
 #include <dali/internal/render/shaders/program.h>
 
+
 namespace Dali
 {
 namespace Internal
@@ -119,7 +121,7 @@ void NewRenderer::DoSetBlending( Context& context, BufferIndex bufferIndex, bool
 
 void NewRenderer::DoRender( Context& context, SceneGraph::TextureCache& textureCache, const SceneGraph::NodeDataProvider& node, BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix )
 {
-  BindTextures( textureCache, bufferIndex, program, mRenderDataProvider->GetSamplers() );
+  BindTextures( textureCache, program );
 
   SetUniforms( bufferIndex, node, program );
 
@@ -156,6 +158,7 @@ void NewRenderer::SetUniforms( BufferIndex bufferIndex, const SceneGraph::NodeDa
 
     unsigned int maxMaps = uniformMap.Count() + uniformMapNode.Count();
     mUniformIndexMap.Clear(); // Clear contents, but keep memory if we don't change size
+    mTextureIndexMap.Clear();
     mUniformIndexMap.Resize( maxMaps );
 
     unsigned int mapIndex(0);
@@ -279,104 +282,77 @@ void NewRenderer::SetUniformFromProperty( BufferIndex bufferIndex, Program& prog
 }
 
 void NewRenderer::BindTextures(
-    SceneGraph::TextureCache& textureCache,
-  BufferIndex bufferIndex,
-  Program& program,
-  const SceneGraph::RenderDataProvider::Samplers& samplers )
+  SceneGraph::TextureCache& textureCache,
+  Program& program )
 {
   // @todo MESH_REWORK Write a cache of texture units to commonly used sampler textures
-  unsigned int textureUnit = 0;
+  int textureUnit = 0;
 
-  for( SceneGraph::RenderDataProvider::Samplers::Iterator iter = samplers.Begin();
-       iter != samplers.End();
-       ++iter )
+  const std::vector<Render::Texture>& textures( mRenderDataProvider->GetTextures());
+  for( size_t i(0); i<textures.size(); ++i )
   {
-    const SceneGraph::SamplerDataProvider* sampler = *iter;
-    ResourceId textureId = sampler->GetTextureId(bufferIndex);
-    Texture* texture = textureCache.GetTexture( textureId );
-    if( texture != NULL )
+    ResourceId textureId = textures[i].GetTextureId();
+    Internal::Texture* texture = textureCache.GetTexture( textureId );
+    if( texture )
     {
-      unsigned int textureUnitUniformIndex = GetTextureUnitUniformIndex( program, *sampler );
-      TextureUnit theTextureUnit = static_cast<TextureUnit>(textureUnit);
-      BindTexture( textureCache, program, textureId, texture, theTextureUnit, textureUnitUniformIndex );
-      ApplySampler( bufferIndex, texture, theTextureUnit, *sampler );
-    }
+      textureCache.BindTexture( texture, textureId, GL_TEXTURE_2D, (TextureUnit)textureUnit );
 
-    ++textureUnit;
-  }
-}
+      // Set sampler uniform location for the texture
+      unsigned int uniformIndex = GetTextureUniformIndex( program, textures[i].GetUniformName() );
+      GLint uniformLocation = program.GetUniformLocation( uniformIndex );
+      if( Program::UNIFORM_UNKNOWN != uniformLocation )
+      {
+        program.SetUniform1i( uniformLocation, textureUnit );
+      }
 
-void NewRenderer::BindTexture(
-  SceneGraph::TextureCache& textureCache,
-  Program& program,
-  ResourceId id,
-  Texture* texture,
-  TextureUnit textureUnit,
-  unsigned int textureUnitUniformIndex )
-{
-  if( texture != NULL )
-  {
-    textureCache.BindTexture( texture, id, GL_TEXTURE_2D, textureUnit );
+      unsigned int samplerBitfield(0);
+      const Render::Sampler* sampler( textures[i].GetSampler() );
+      if( sampler )
+      {
+        samplerBitfield = ImageSampler::PackBitfield(
+          static_cast< FilterMode::Type >(sampler->GetMinifyFilterMode()),
+          static_cast< FilterMode::Type >(sampler->GetMagnifyFilterMode()),
+          static_cast< WrapMode::Type >(sampler->GetUWrapMode()),
+          static_cast< WrapMode::Type >(sampler->GetVWrapMode())
+          );
+      }
+      else
+      {
+        samplerBitfield = ImageSampler::PackBitfield(FilterMode::DEFAULT, FilterMode::DEFAULT, WrapMode::DEFAULT, WrapMode::DEFAULT);
+      }
 
-    // Set sampler uniform location for the texture
-    GLint textureUnitLoc = program.GetUniformLocation( textureUnitUniformIndex );
-    if( Program::UNIFORM_UNKNOWN != textureUnitLoc )
-    {
-      program.SetUniform1i( textureUnitLoc, textureUnit );
+      texture->ApplySampler( (TextureUnit)textureUnit, samplerBitfield );
+
+      ++textureUnit;
     }
   }
 }
 
-void NewRenderer::ApplySampler(
-  BufferIndex bufferIndex,
-  Texture*    texture,
-  TextureUnit textureUnit,
-  const SceneGraph::SamplerDataProvider& sampler )
-{
-  unsigned int samplerBitfield = ImageSampler::PackBitfield(
-    static_cast< FilterMode::Type >(sampler.GetMinifyFilterMode(bufferIndex)),
-    static_cast< FilterMode::Type >(sampler.GetMagnifyFilterMode(bufferIndex)) );
-
-  texture->ApplySampler( textureUnit, samplerBitfield );
-
-  // @todo MESH_REWORK add support for wrap modes
-}
-
-unsigned int NewRenderer::GetTextureUnitUniformIndex(
-  Program& program,
-  const SceneGraph::SamplerDataProvider& sampler )
+unsigned int NewRenderer::GetTextureUniformIndex( Program& program, std::string uniformName )
 {
-  // Find sampler in mSamplerNameCache
-  // If it doesn't exist,
-  //   get the index by calling program.RegisterUniform and store it
-  // If it exists, it's index should be set.
-  // @todo Cache should be reset on scene change
-
   unsigned int uniformIndex = 0;
   bool found = false;
 
-  for( unsigned int i=0; i< mTextureUnitUniforms.Count(); ++i )
+  size_t uniformNameHash = Dali::CalculateHash( uniformName );
+  for( unsigned int i=0; i< mTextureIndexMap.Count(); ++i )
   {
-    if( mTextureUnitUniforms[i].sampler == &sampler )
+    if( mTextureIndexMap[i].uniformNameHash == uniformNameHash )
     {
-      uniformIndex = mTextureUnitUniforms[i].index;
+      uniformIndex = mTextureIndexMap[i].uniformIndex;
       found = true;
     }
   }
 
   if( ! found )
   {
-    TextureUnitUniformIndex textureUnitUniformIndex;
-    textureUnitUniformIndex.sampler = &sampler;
-    textureUnitUniformIndex.index = program.RegisterUniform( sampler.GetTextureUnitUniformName() );
-    mTextureUnitUniforms.PushBack( textureUnitUniformIndex );
-    uniformIndex = textureUnitUniformIndex.index;
+    uniformIndex = program.RegisterUniform( uniformName );
+    TextureUniformIndexMap textureUniformIndexMap = {uniformNameHash,uniformIndex};
+    mTextureIndexMap.PushBack( textureUniformIndexMap );
   }
 
   return uniformIndex;
 }
 
-
 } // SceneGraph
 } // Internal
 } // Dali
index 995f515..d5e6061 100644 (file)
@@ -82,9 +82,16 @@ public:
   void SetSortAttributes( BufferIndex bufferIndex, SceneGraph::RendererWithSortAttributes& sortAttributes ) const
   {
     sortAttributes.shader = &( mRenderDataProvider->GetShader() );
-    const SceneGraph::RenderDataProvider::Samplers& samplers = mRenderDataProvider->GetSamplers();
+    const std::vector<Render::Texture>& textures( mRenderDataProvider->GetTextures() );
+    if( !textures.empty() )
+    {
+      sortAttributes.textureResourceId = textures[0].GetTextureId();
+    }
+    else
+    {
+      sortAttributes.textureResourceId = Integration::InvalidResourceId;
+    }
 
-    sortAttributes.textureResourceId = samplers.Empty() ? Integration::InvalidResourceId : samplers[ 0 ]->GetTextureId( bufferIndex );
     sortAttributes.geometry = mRenderGeometry;
   }
 
@@ -161,43 +168,9 @@ private:
   /**
    * Bind the material textures in the samplers and setup the samplers
    * @param[in] textureCache The texture cache
-   * @param[in] bufferIndex The buffer index
    * @param[in] program The shader program
-   * @param[in] samplers The samplers to bind
-   */
-  void BindTextures( SceneGraph::TextureCache& textureCache,
-                     BufferIndex bufferIndex,
-                     Program& program,
-                     const SceneGraph::RenderDataProvider::Samplers& samplers );
-
-  /**
-   * Bind a material texture to a texture unit, and set the sampler's texture uniform
-   * to that texture unit.
-   * @param[in] textureCache The texture cache
-   * @param[in] program The shader program
-   * @param[in] id The resource id of the texture to bind
-   * @param[in] texture The texture to bind
-   * @param[in] textureUnit The texture unit index to use
-   * @param[in] nameIndex The index of the texture uniform in the program
-   */
-  void BindTexture( SceneGraph::TextureCache& textureCache,
-                    Program& program,
-                    ResourceId id,
-                    Texture* texture,
-                    TextureUnit textureUnit,
-                    unsigned int nameIndex );
-
-  /**
-   * Apply the sampler modes to the texture.
-   * @param[in] bufferIndex The current buffer index
-   * @param[in] texture The texture to which to apply the sampler modes
-   * @param[in] textureUnit The texture unit of the texture
-   * @param[in] sampler The sampler from which to get the modes.
    */
-  void ApplySampler( BufferIndex bufferIndex,
-                     Texture* texture,
-                     TextureUnit textureUnit,
-                     const SceneGraph::SamplerDataProvider& sampler );
+  void BindTextures( SceneGraph::TextureCache& textureCache, Program& program );
 
   /**
    * Get the texture uniform index of the name sampler in the program.
@@ -206,9 +179,7 @@ private:
    * @param[in] sampler The sampler holding a texture unit uniform name to search for
    * @return The texture uniform index in the program
    */
-  unsigned int GetTextureUnitUniformIndex( Program& program,
-                                           const SceneGraph::SamplerDataProvider& sampler );
-
+  unsigned int GetTextureUniformIndex( Program& program, std::string uniformName );
 
 
 public: //@todo MESH_REWORK make private after merge with SceneGraph::Renderer
@@ -217,15 +188,6 @@ public: //@todo MESH_REWORK make private after merge with SceneGraph::Renderer
 private:
   SceneGraph::RenderGeometry* mRenderGeometry;
 
-  struct TextureUnitUniformIndex
-  {
-    const SceneGraph::SamplerDataProvider* sampler;
-    unsigned int index;
-  };
-
-  typedef Dali::Vector< TextureUnitUniformIndex > TextureUnitUniforms;
-  TextureUnitUniforms mTextureUnitUniforms;
-
   struct UniformIndexMap
   {
     unsigned int uniformIndex; // The index of the cached location in the Program
@@ -235,6 +197,15 @@ private:
   typedef Dali::Vector< UniformIndexMap > UniformIndexMappings;
   UniformIndexMappings mUniformIndexMap;
 
+  struct TextureUniformIndexMap
+  {
+    size_t       uniformNameHash;
+    unsigned int uniformIndex;    // The index of the cached location in the Program
+  };
+
+  typedef Dali::Vector< TextureUniformIndexMap > TextureUniformIndexMappings;
+  TextureUniformIndexMappings mTextureIndexMap;
+
   Vector<GLint> mAttributesLocation;
   bool mUpdateAttributesLocation;
 
diff --git a/dali/internal/render/renderers/render-sampler.h b/dali/internal/render/renderers/render-sampler.h
new file mode 100644 (file)
index 0000000..f28d855
--- /dev/null
@@ -0,0 +1,126 @@
+#ifndef DALI_INTERNAL_RENDER_SAMPLER_H
+#define DALI_INTERNAL_RENDER_SAMPLER_H
+
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali/public-api/actors/sampling.h>
+#include <dali/devel-api/rendering/sampler.h>
+#include <dali/internal/render/renderers/render-sampler.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Render
+{
+class Sampler
+{
+public:
+  typedef Dali::FilterMode::Type FilterMode;
+  typedef Dali::WrapMode::Type   WrapMode;
+
+  /**
+   * Constructor
+   */
+  Sampler()
+  : mMinFilter( Dali::FilterMode::DEFAULT),
+    mMagFilter( Dali::FilterMode::DEFAULT ),
+    mUWrapMode( Dali::WrapMode::DEFAULT ),
+    mVWrapMode( Dali::WrapMode::DEFAULT )
+  {}
+
+  /**
+   * Destructor
+   */
+  virtual ~Sampler(){}
+
+  /**
+   * Set the filter modes for minify and magnify filters
+   * @param[in] bufferIndex The buffer index to use
+   * @param[in] minFilter The minify filter
+   * @param[in] magFilter The magnify filter
+   */
+  void SetFilterMode(FilterMode minFilter, FilterMode magFilter )
+  {
+    mMinFilter = minFilter;
+    mMagFilter = magFilter;
+  }
+
+  /**
+   * @param[in] bufferIndex The buffer index to use
+   */
+  void SetWrapMode(WrapMode uWrap, WrapMode vWrap )
+  {
+    mUWrapMode = uWrap;
+    mVWrapMode = vWrap;
+  }
+
+public:
+
+  /**
+   * Get the filter mode
+   * @return The minify filter mode
+   */
+  virtual FilterMode GetMinifyFilterMode() const
+  {
+    return mMinFilter;
+  }
+
+  /**
+   * Get the filter mode
+   * @return The magnify filter mode
+   */
+  virtual FilterMode GetMagnifyFilterMode() const
+  {
+    return mMagFilter;
+  }
+
+  /**
+   * Get the horizontal wrap mode
+   * @return The horizontal wrap mode
+   */
+  virtual WrapMode GetUWrapMode() const
+  {
+    return mUWrapMode;
+  }
+
+  /**
+   * Get the vertical wrap mode
+   * @return The vertical wrap mode
+   */
+  virtual WrapMode GetVWrapMode() const
+  {
+    return mVWrapMode;
+  }
+
+public:
+
+  FilterMode  mMinFilter;    ///< The minify filter
+  FilterMode  mMagFilter;    ///< The magnify filter
+  WrapMode  mUWrapMode;    ///< The horizontal wrap mode
+  WrapMode  mVWrapMode;    ///< The vertical wrap mode
+};
+
+} // namespace Render
+
+
+
+} // namespace Internal
+} // namespace Dali
+
+
+#endif //  DALI_INTERNAL_RENDER_SAMPLER_H
diff --git a/dali/internal/render/renderers/render-texture.h b/dali/internal/render/renderers/render-texture.h
new file mode 100644 (file)
index 0000000..83c82f8
--- /dev/null
@@ -0,0 +1,101 @@
+#ifndef DALI_INTERNAL_RENDER_TEXTURE_H
+#define DALI_INTERNAL_RENDER_TEXTURE_H
+
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali/devel-api/rendering/sampler.h>
+#include <dali/integration-api/resource-declarations.h>
+#include <string>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Render
+{
+class Sampler;
+
+class Texture
+{
+public:
+
+  /**
+   * Constructor
+   */
+  Texture()
+  :mUniformName(""),
+   mTextureId(Integration::InvalidResourceId),
+   mSampler(0)
+  {}
+
+  /**
+   * Constructor
+   */
+  Texture( const char* samplerName, Integration::ResourceId textureId, Render::Sampler* sampler )
+  :mUniformName(samplerName),
+   mTextureId( textureId),
+   mSampler(sampler)
+  {}
+
+  /**
+   * Destructor
+   */
+  ~Texture()
+  {}
+
+  /*
+   * Get the Render::Sampler used by the texture
+   * @Return The Render::Sampler being used or 0 if using the default
+   */
+  inline const Render::Sampler* GetSampler() const
+  {
+    return mSampler;
+  }
+
+public: // SamplerDataProvider interface - called from RenderThread
+  /**
+   * Get the texture unit uniform name
+   * @return the name of the texture unit uniform
+   */
+  inline const char* GetUniformName() const
+  {
+    return mUniformName.c_str();
+  }
+
+  /**
+   * Get the texture ID
+   * @param[in] bufferIndex The buffer index to use
+   * @return the identity of the associated texture
+   */
+  inline Integration::ResourceId GetTextureId() const
+  {
+    return mTextureId;
+  }
+
+private:
+  std::string               mUniformName;
+  Integration::ResourceId   mTextureId;
+  Render::Sampler*          mSampler;
+};
+
+} // namespace SceneGraph
+
+} // namespace Internal
+} // namespace Dali
+
+
+#endif //  DALI_INTERNAL_RENDER_TEXTURE_H
index 04883ba..bec6936 100644 (file)
@@ -150,20 +150,6 @@ void DiscardQueue::Add( BufferIndex updateBufferIndex, Shader* shader )
   }
 }
 
-void DiscardQueue::Add( BufferIndex updateBufferIndex, Sampler* sampler )
-{
-  DALI_ASSERT_DEBUG( NULL != sampler );
-
-  if ( 0u == updateBufferIndex )
-  {
-    mSamplerQueue0.PushBack( sampler );
-  }
-  else
-  {
-    mSamplerQueue1.PushBack( sampler );
-  }
-}
-
 void DiscardQueue::Add( BufferIndex updateBufferIndex, PropertyBuffer* propertyBuffer )
 {
   DALI_ASSERT_DEBUG( NULL != propertyBuffer );
@@ -189,7 +175,6 @@ void DiscardQueue::Clear( BufferIndex updateBufferIndex )
     mShaderQueue0.Clear();
     mGeometryQueue0.Clear();
     mMaterialQueue0.Clear();
-    mSamplerQueue0.Clear();
     mPropertyBufferQueue0.Clear();
     mRendererQueue0.Clear();
   }
@@ -200,7 +185,6 @@ void DiscardQueue::Clear( BufferIndex updateBufferIndex )
     mShaderQueue1.Clear();
     mGeometryQueue1.Clear();
     mMaterialQueue1.Clear();
-    mSamplerQueue1.Clear();
     mPropertyBufferQueue1.Clear();
     mRendererQueue1.Clear();
   }
index 09c07b0..96c4dbc 100644 (file)
@@ -27,7 +27,6 @@
 #include <dali/internal/update/common/scene-graph-property-buffer.h>
 #include <dali/internal/update/rendering/scene-graph-geometry.h>
 #include <dali/internal/update/rendering/scene-graph-material.h>
-#include <dali/internal/update/rendering/scene-graph-sampler.h>
 #include <dali/internal/update/rendering/scene-graph-renderer.h>
 
 namespace Dali
@@ -60,7 +59,6 @@ public:
   typedef OwnerContainer< Shader* > ShaderQueue;
   typedef OwnerContainer< Geometry* > GeometryQueue;
   typedef OwnerContainer< Material* > MaterialQueue;
-  typedef OwnerContainer< Sampler* > SamplerQueue;
   typedef OwnerContainer< PropertyBuffer* > PropertyBufferQueue;
   typedef OwnerContainer< Renderer* > RendererQueue;
 
@@ -112,12 +110,6 @@ public:
   void Add( BufferIndex updateBufferIndex, Material* material );
 
   /**
-   * Adds an unwanted material to the discard queue.
-   * A message will be sent to clean up GL resources in the next Render.
-   */
-  void Add( BufferIndex updateBufferIndex, Sampler* material );
-
-  /**
    * Adds an unwanted shader to the discard queue.
    * A message will be sent to clean-up GL resources in the next Render.
    * @pre This method is not thread-safe, and should only be called from the update-thread.
@@ -159,7 +151,6 @@ private:
   ShaderQueue                  mShaderQueue0;
   GeometryQueue                mGeometryQueue0;
   MaterialQueue                mMaterialQueue0;
-  SamplerQueue                 mSamplerQueue0;
   PropertyBufferQueue          mPropertyBufferQueue0;
   RendererQueue                mRendererQueue0;
 
@@ -169,7 +160,6 @@ private:
   ShaderQueue                  mShaderQueue1;
   GeometryQueue                mGeometryQueue1;
   MaterialQueue                mMaterialQueue1;
-  SamplerQueue                 mSamplerQueue1;
   PropertyBufferQueue          mPropertyBufferQueue1;
   RendererQueue                mRendererQueue1;
 };
index 7d64ce7..31425a1 100644 (file)
@@ -59,7 +59,6 @@
 #include <dali/internal/update/render-tasks/scene-graph-render-task.h>
 #include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
 #include <dali/internal/update/rendering/scene-graph-material.h>
-#include <dali/internal/update/rendering/scene-graph-sampler.h>
 #include <dali/internal/update/rendering/scene-graph-geometry.h>
 #include <dali/internal/update/resources/resource-manager.h>
 #include <dali/internal/update/resources/complete-status-manager.h>
@@ -71,6 +70,7 @@
 #include <dali/internal/render/common/performance-monitor.h>
 #include <dali/internal/render/gl-resources/texture-cache.h>
 #include <dali/internal/render/shaders/scene-graph-shader.h>
+#include <dali/internal/render/renderers/render-sampler.h>
 
 // Un-comment to enable node tree debug logging
 //#define NODE_TREE_LOGGING 1
@@ -178,7 +178,6 @@ struct UpdateManager::Impl
     renderers( sceneGraphBuffers, discardQueue ),
     geometries( sceneGraphBuffers, discardQueue ),
     materials( sceneGraphBuffers, discardQueue ),
-    samplers( sceneGraphBuffers, discardQueue ),
     propertyBuffers( sceneGraphBuffers, discardQueue ),
     messageQueue( renderController, sceneGraphBuffers ),
     keepRenderingSeconds( 0.0f ),
@@ -195,7 +194,6 @@ struct UpdateManager::Impl
     geometries.SetSceneController( *sceneController );
     materials.SetSceneController( *sceneController );
     propertyBuffers.SetSceneController( *sceneController );
-    samplers.SetSceneController( *sceneController );
   }
 
   ~Impl()
@@ -277,7 +275,6 @@ struct UpdateManager::Impl
   ObjectOwnerContainer<Renderer>      renderers;
   ObjectOwnerContainer<Geometry>      geometries;                    ///< A container of geometries
   ObjectOwnerContainer<Material>      materials;                     ///< A container of materials
-  ObjectOwnerContainer<Sampler>       samplers;                      ///< A container of samplers
   ObjectOwnerContainer<PropertyBuffer> propertyBuffers;              ///< A container of property buffers
 
   ShaderContainer                     shaders;                       ///< A container of owned shaders
@@ -555,11 +552,6 @@ ObjectOwnerContainer<Material>& UpdateManager::GetMaterialOwner()
   return mImpl->materials;
 }
 
-ObjectOwnerContainer<Sampler>& UpdateManager::GetSamplerOwner()
-{
-  return mImpl->samplers;
-}
-
 ObjectOwnerContainer<PropertyBuffer>& UpdateManager::GetPropertyBufferOwner()
 {
   return mImpl->propertyBuffers;
@@ -757,7 +749,6 @@ void UpdateManager::ResetProperties( BufferIndex bufferIndex )
   mImpl->materials.ResetToBaseValues( bufferIndex );
   mImpl->geometries.ResetToBaseValues( bufferIndex );
   mImpl->propertyBuffers.ResetToBaseValues( bufferIndex );
-  mImpl->samplers.ResetToBaseValues( bufferIndex );
   mImpl->renderers.ResetToBaseValues( bufferIndex );
 
 
@@ -875,7 +866,6 @@ void UpdateManager::ApplyConstraints( BufferIndex bufferIndex )
   // Constrain Materials and geometries
   mImpl->materials.ConstrainObjects( bufferIndex );
   mImpl->geometries.ConstrainObjects( bufferIndex );
-  mImpl->samplers.ConstrainObjects( bufferIndex );
   mImpl->propertyBuffers.ConstrainObjects( bufferIndex );
   mImpl->renderers.ConstrainObjects( bufferIndex );
 
@@ -1227,6 +1217,50 @@ void UpdateManager::SetShaderSaver( ShaderSaver& upstream )
   mImpl->shaderSaver = &upstream;
 }
 
+void UpdateManager::AddSampler( Render::Sampler* sampler )
+{
+  typedef MessageValue1< RenderManager, Render::Sampler* > DerivedType;
+
+  // Reserve some memory inside the render queue
+  unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+
+  // Construct message in the render queue memory; note that delete should not be called on the return value
+  new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::AddSampler, sampler );
+}
+
+void UpdateManager::RemoveSampler( Render::Sampler* sampler )
+{
+  typedef MessageValue1< RenderManager, Render::Sampler* > DerivedType;
+
+  // Reserve some memory inside the render queue
+  unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+
+  // Construct message in the render queue memory; note that delete should not be called on the return value
+  new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::RemoveSampler, sampler );
+}
+
+void UpdateManager::SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode )
+{
+  typedef MessageValue3< RenderManager, Render::Sampler*, unsigned int, unsigned int > DerivedType;
+
+  // Reserve some memory inside the render queue
+  unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+
+  // Construct message in the render queue memory; note that delete should not be called on the return value
+  new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::SetFilterMode, sampler, minFilterMode, magFilterMode );
+}
+
+void UpdateManager::SetWrapMode( Render::Sampler* sampler, unsigned int uWrapMode, unsigned int vWrapMode )
+{
+  typedef MessageValue3< RenderManager, Render::Sampler*, unsigned int, unsigned int > DerivedType;
+
+  // Reserve some memory inside the render queue
+  unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+
+  // Construct message in the render queue memory; note that delete should not be called on the return value
+  new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::SetWrapMode, sampler, uWrapMode, vWrapMode );
+}
+
 } // namespace SceneGraph
 
 } // namespace Internal
index 7471980..f1cb9ae 100644 (file)
@@ -57,6 +57,10 @@ class CompleteNotificationInterface;
 class ResourceManager;
 class TouchResampler;
 
+namespace Render
+{
+class Sampler;
+}
 // value types used by messages
 template <> struct ParameterType< PropertyNotification::NotifyMode >
 : public BasicType< PropertyNotification::NotifyMode > {};
@@ -74,7 +78,6 @@ class TextureCache;
 class Geometry;
 class PropertyBuffer;
 class Material;
-class Sampler;
 
 /**
  * UpdateManager maintains a scene graph i.e. a tree of nodes and attachments and
@@ -265,13 +268,6 @@ public:
   ObjectOwnerContainer< Material >& GetMaterialOwner();
 
   /**
-   * @brief Get the sampler owner
-   *
-   * @return The sampler owner
-   */
-  ObjectOwnerContainer< Sampler >& GetSamplerOwner();
-
-  /**
    * @brief Get the property buffer owner
    *
    * @return The property buffer owner
@@ -370,6 +366,37 @@ public:
    */
   bool FlushQueue();
 
+  /**
+   * Add a new sampler to RenderManager
+   * @param[in] sampler The sampler to add
+   * @post Sends a message to RenderManager to add the sampler.
+   * The sampler will be owned by RenderManager
+   */
+  void AddSampler( Render::Sampler* sampler );
+
+  /**
+   * Removes an existing sampler from RenderManager
+   * @param[in] sampler The sampler to remove
+   * @post The sampler will be destroyed in the render thread
+   */
+  void RemoveSampler( Render::Sampler* sampler );
+
+  /**
+   * Sets the filter modes for an existing sampler
+   * @param[in] sampler The sampler
+   * @param[in] minFilterMode The filter to use under minification
+   * @param[in] magFilterMode The filter to use under magnification
+   */
+  void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode );
+
+  /**
+   * Sets the wrap mode for an existing sampler
+   * @param[in] sampler The sampler
+   * @param[in] uWrapMode Wrapping mode in x direction
+   * @param[in] vWrapMode Wrapping mode in y direction
+   */
+  void SetWrapMode( Render::Sampler* sampler, unsigned int uWrapMode, unsigned int vWrapMode );
+
 public:
 
   /**
@@ -817,6 +844,51 @@ inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer<T>& owne
   new (slot) LocalType( &owner, &ObjectOwnerContainer<T>::Remove, &object );
 }
 
+inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
+{
+  typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &manager, &UpdateManager::AddSampler, &sampler );
+}
+
+inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler )
+{
+  typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &manager, &UpdateManager::RemoveSampler, &sampler );
+}
+
+inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode )
+{
+  typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
+}
+
+inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int uWrapMode, unsigned int vWrapMode )
+{
+  typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int  > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, uWrapMode, vWrapMode );
+}
+
+
 } // namespace SceneGraph
 
 } // namespace Internal
index 4993522..ffea32c 100644 (file)
@@ -22,8 +22,6 @@
 #include <dali/public-api/shader-effects/shader-effect.h>
 #include <dali/devel-api/rendering/material.h>
 #include <dali/internal/common/internal-constants.h>
-#include <dali/internal/update/rendering/scene-graph-sampler.h>
-#include <dali/internal/render/data-providers/sampler-data-provider.h>
 #include <dali/internal/render/shaders/scene-graph-shader.h>
 
 namespace Dali
@@ -72,34 +70,6 @@ Shader* Material::GetShader() const
   return mShader;
 }
 
-void Material::AddSampler( Sampler* sampler )
-{
-  mSamplers.PushBack( sampler );
-
-  sampler->AddConnectionObserver( *this );
-  sampler->AddUniformMapObserver( *this );
-
-  mConnectionObservers.ConnectionsChanged(*this);
-}
-
-void Material::RemoveSampler( Sampler* sampler )
-{
-  Vector<Sampler*>::Iterator match = std::find( mSamplers.Begin(), mSamplers.End(), sampler );
-
-  DALI_ASSERT_DEBUG( mSamplers.End() != match );
-  if( mSamplers.End() != match )
-  {
-    sampler->RemoveConnectionObserver( *this );
-    sampler->RemoveUniformMapObserver( *this );
-    mSamplers.Erase( match );
-    mConnectionObservers.ConnectionsChanged(*this);
-  }
-  else
-  {
-    DALI_ASSERT_DEBUG( 0 && "Sampler not found" );
-  }
-}
-
 void Material::PrepareRender( BufferIndex bufferIndex )
 {
   mBlendPolicy = OPAQUE;
@@ -140,23 +110,17 @@ void Material::PrepareRender( BufferIndex bufferIndex )
 
       if( opaque )
       {
-        // Require that all affecting samplers are opaque
         unsigned int opaqueCount=0;
         unsigned int affectingCount=0;
-
-        for( Vector<Sampler*>::ConstIterator iter = mSamplers.Begin();
-             iter != mSamplers.End(); ++iter )
+        size_t textureCount( GetTextureCount() );
+        for( unsigned int i(0); i<textureCount; ++i )
         {
-          const Sampler* sampler = *iter;
-          if( sampler != NULL )
+          if( mAffectsTransparency[i] )
           {
-            if( sampler->AffectsTransparency( bufferIndex ) )
+            ++affectingCount;
+            if( mIsFullyOpaque[i] )
             {
-              affectingCount++;
-              if( sampler->IsFullyOpaque( bufferIndex ) )
-              {
-                opaqueCount++;
-              }
+              ++opaqueCount;
             }
           }
         }
@@ -168,10 +132,6 @@ void Material::PrepareRender( BufferIndex bufferIndex )
   }
 }
 
-Vector<Sampler*>& Material::GetSamplers()
-{
-  return mSamplers;
-}
 
 Material::BlendPolicy Material::GetBlendPolicy() const
 {
@@ -230,6 +190,45 @@ BlendingEquation::Type Material::GetBlendEquationAlpha( BufferIndex bufferIndex
   return blendingOptions.GetBlendEquationAlpha();
 }
 
+void Material::AddTexture( const std::string& name, ResourceId id, Render::Sampler* sampler )
+{
+  mTextureId.PushBack( id );
+  mUniformName.push_back( name );
+  mSamplers.PushBack( sampler );
+  mIsFullyOpaque.PushBack( false );
+  mAffectsTransparency.PushBack( true );
+
+  mConnectionObservers.ConnectionsChanged(*this);
+}
+
+void Material::RemoveTexture( size_t index )
+{
+  mTextureId.Erase( mTextureId.Begin()+index );
+  mUniformName.erase( mUniformName.begin() + index );
+  mSamplers.Erase( mSamplers.Begin()+index );
+  mIsFullyOpaque.Erase( mIsFullyOpaque.Begin()+index );
+  mAffectsTransparency.Erase( mAffectsTransparency.Begin()+index );
+  mConnectionObservers.ConnectionsChanged( *this );
+}
+
+void Material::SetTextureImage( size_t index, ResourceId id )
+{
+  mTextureId[index] = id;
+  mConnectionObservers.ConnectionsChanged(*this);
+}
+
+void Material::SetTextureSampler( size_t index, Render::Sampler* sampler)
+{
+  mSamplers[index] = sampler;
+  mConnectionObservers.ConnectionsChanged(*this);
+}
+
+void Material::SetTextureUniformName( size_t index, const std::string& uniformName)
+{
+  mUniformName[index] = uniformName;
+  mConnectionObservers.ConnectionsChanged(*this);
+}
+
 void Material::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
 {
 }
index 8d78a03..e4a7bc2 100644 (file)
 #include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
 #include <dali/internal/update/common/uniform-map.h>
 #include <dali/internal/render/data-providers/material-data-provider.h>
+#include <dali/internal/update/resources/resource-manager-declarations.h>
 
 namespace Dali
 {
 namespace Internal
 {
+namespace Render
+{
+class Sampler;
+}
 namespace SceneGraph
 {
 class Sampler;
@@ -69,18 +74,6 @@ public:
   void SetShader( Shader* shader );
 
   /**
-   * Add a sampler (image + sampler modes) to the material
-   * @param[in] sampler A sampler to add
-   */
-  void AddSampler( Sampler* sampler );
-
-  /**
-   * Remove a sampler (image + sampler modes) from the material
-   * @param[in] sampler A sampler to remove
-   */
-  void RemoveSampler( Sampler* sampler );
-
-  /**
    * Prepare the material for rendering.
    *
    * Determine whether blending is enabled for this material, and store the result.
@@ -102,6 +95,52 @@ public:
    */
   void SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options );
 
+  /**
+   * Adds a new texture to be used by the material
+   * @param[in] image The image used by the texture
+   * @param[in] uniformName The uniform name of the texture
+   * @param[in] sampler Sampling parameters. If not provided the default sampling parameters will be used
+   */
+  void AddTexture( const std::string& name, ResourceId id, Render::Sampler* sampler );
+
+  /**
+   * Removes a texture from the material
+   * @param[in] index The index of the texture in the array of textures
+   */
+  void RemoveTexture( size_t index );
+
+  /**
+   * Sets the image to be used by a given texture
+   * @param[in] index The index of the texture in the array of textures
+   * @param[in] image The new image
+   */
+  void SetTextureImage( size_t index, ResourceId id );
+
+  /**
+   * Set the sampler used by a given texture
+   * @param[in] index The index of the texture in the array of textures
+   * @param[in] sampler The new sampler
+   */
+  void SetTextureSampler( size_t index, Render::Sampler* sampler);
+
+  /**
+   * Set the uniform name of a given texture
+   * @param[in] index The index of the texture in the array of textures
+   * @param[in] uniformName The new uniform name
+   */
+  void SetTextureUniformName( size_t index, const std::string& uniformName);
+
+  /**
+   * Establish if a given texture will affect the transparency of the object ( true by default )
+   * @param[in] index The index of the texture in the array of textures
+   * @param[in] affectsTransparency True if the texture affects transparency, false otherwise
+   */
+  void SetAffectsTransparency( size_t index, bool affectsTransparency )
+  {
+    mAffectsTransparency[index] = affectsTransparency;
+    mConnectionObservers.ConnectionsChanged(*this);
+  }
+
 public: // Implementation of MaterialDataProvider
 
   /**
@@ -174,10 +213,43 @@ public:
   Shader* GetShader() const;
 
   /**
-   * Get the samplers this material uses.
-   * @return the samplers
+   * Get the ResourceId of a texture used by the material
+   * @param[in] index The index of the texture in the textures array
+   * @return the ResourceId
+   */
+  ResourceId GetTextureId( size_t index )
+  {
+    return mTextureId[index];
+  }
+
+  /**
+   * Get the uniform name of a texture used by the material
+   * @param[in] index The index of the texture in the textures array
+   * @return the uniform name
+   */
+  const char* GetTextureUniformName( size_t index )
+  {
+    return mUniformName[index].c_str();
+  }
+
+  /**
+   * Get the sampler of a texture used by the material
+   * @param[in] index The index of the texture in the textures array
+   * @return the sampler used by the texture
+   */
+  Render::Sampler* GetTextureSampler( size_t index )
+  {
+    return mSamplers[index];
+  }
+
+  /**
+   * Get the number of textures used by the material
+   * @return The number of textures
    */
-  Vector<Sampler*>& GetSamplers();
+  size_t GetTextureCount()
+  {
+    return mTextureId.Size();
+  }
 
 public: // UniformMap::Observer
   /**
@@ -203,6 +275,11 @@ public: // PropertyOwner implementation
    */
   virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
 
+  void SetIsFullyOpaque( size_t index, bool isFullyOpaque )
+  {
+    mIsFullyOpaque[index] = isFullyOpaque;
+  }
+
 public: // Property data
   AnimatableProperty<Vector4> mColor;
   AnimatableProperty<Vector4> mBlendColor;
@@ -212,7 +289,11 @@ public: // Property data
 
 private:
   Shader* mShader;
-  Vector<Sampler*> mSamplers; // Not owned
+  Vector<Render::Sampler*> mSamplers; // Not owned
+  Vector<ResourceId>  mTextureId;
+  std::vector<std::string> mUniformName;
+  Vector<bool>        mIsFullyOpaque;
+  Vector<bool>        mAffectsTransparency;
   ConnectionChangePropagator mConnectionObservers;
   BlendPolicy mBlendPolicy; ///< The blend policy as determined by PrepareRender
 };
@@ -228,38 +309,81 @@ inline void SetShaderMessage( EventThreadServices& eventThreadServices, const Ma
   new (slot) LocalType( &material, &Material::SetShader, &shader );
 }
 
-inline void AddSamplerMessage( EventThreadServices& eventThreadServices, const Material& material, Sampler& sampler )
+inline void SetBlendingOptionsMessage( EventThreadServices& eventThreadServices, const Material& material, unsigned int options )
+{
+  typedef MessageDoubleBuffered1< Material, unsigned int > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+  new (slot) LocalType( &material, &Material::SetBlendingOptions, options );
+}
+
+inline void AddTextureMessage( EventThreadServices& eventThreadServices, const Material& material, const std::string& uniformName, ResourceId id, Render::Sampler* sampler )
 {
-  typedef MessageValue1< Material, Sampler* > LocalType;
+  typedef MessageValue3< Material, std::string, ResourceId, Render::Sampler* > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &material, &Material::AddSampler, &sampler );
+  new (slot) LocalType( &material, &Material::AddTexture, uniformName, id, sampler );
 }
 
-inline void RemoveSamplerMessage( EventThreadServices& eventThreadServices, const Material& material, Sampler& sampler )
+inline void RemoveTextureMessage( EventThreadServices& eventThreadServices, const Material& material, size_t index )
 {
-  typedef MessageValue1< Material, Sampler* > LocalType;
+  typedef MessageValue1< Material, size_t > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &material, &Material::RemoveSampler, &sampler );
+  new (slot) LocalType( &material, &Material::RemoveTexture, index );
 }
 
-inline void SetBlendingOptionsMessage( EventThreadServices& eventThreadServices, const Material& material, unsigned int options )
+inline void SetTextureImageMessage( EventThreadServices& eventThreadServices, const Material& material, size_t index, ResourceId id )
 {
-  typedef MessageDoubleBuffered1< Material, unsigned int > LocalType;
+  typedef MessageValue2< Material, size_t, ResourceId > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
-  new (slot) LocalType( &material, &Material::SetBlendingOptions, options );
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &material, &Material::SetTextureImage, index, id );
+}
+
+inline void SetTextureSamplerMessage( EventThreadServices& eventThreadServices, const Material& material, size_t index, Render::Sampler* sampler )
+{
+  typedef MessageValue2< Material, size_t, Render::Sampler* > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &material, &Material::SetTextureSampler, index, sampler );
+}
+
+inline void SetTextureUniformNameMessage( EventThreadServices& eventThreadServices, const Material& material, size_t index, const std::string& uniformName )
+{
+  typedef MessageValue2< Material, size_t, std::string > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &material, &Material::SetTextureUniformName, index, uniformName );
 }
 
+inline void SetTextureAffectsTransparencyMessage( EventThreadServices& eventThreadServices, const Material& material, size_t index, bool affectsTransparency )
+{
+  typedef MessageValue2< Material, size_t, bool > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &material, &Material::SetAffectsTransparency, index, affectsTransparency );
+}
 
 } // namespace SceneGraph
 } // namespace Internal
index 4fdad97..4815c67 100644 (file)
@@ -23,7 +23,7 @@
 #include <dali/internal/update/controllers/render-message-dispatcher.h>
 #include <dali/internal/update/rendering/scene-graph-geometry.h>
 #include <dali/internal/update/rendering/scene-graph-material.h>
-#include <dali/internal/update/rendering/scene-graph-sampler.h>
+//#include <dali/internal/update/rendering/scene-graph-sampler.h>
 #include <dali/internal/render/shaders/scene-graph-shader.h>
 #include <dali/internal/render/renderers/render-new-renderer.h>
 #include <dali/internal/render/data-providers/node-data-provider.h>
@@ -148,13 +148,6 @@ void Renderer::PrepareRender( BufferIndex updateBufferIndex )
       AddMappings( localMap, rendererUniformMap );
 
       AddMappings( localMap, mMaterial->GetUniformMap() );
-      Vector<Sampler*>& samplers = mMaterial->GetSamplers();
-      unsigned int samplerCount( samplers.Size() );
-      for( unsigned int i(0); i<samplerCount; ++i )
-      {
-        AddMappings( localMap, samplers[i]->GetUniformMap() );
-      }
-
       AddMappings( localMap, mMaterial->GetShader()->GetUniformMap() );
       AddMappings( localMap, mGeometry->GetUniformMap() );
 
@@ -306,12 +299,13 @@ RenderDataProvider* Renderer::NewRenderDataProvider()
   dataProvider->mUniformMapDataProvider = this;
   dataProvider->mShader = mMaterial->GetShader();
 
-  Vector<Sampler*>& samplers = mMaterial->GetSamplers();
-  unsigned int sampleCount( samplers.Count() );
-  dataProvider->mSamplers.Resize( sampleCount );
-  for( unsigned int i(0); i<sampleCount; ++i )
+  size_t textureCount( mMaterial->GetTextureCount() );
+  dataProvider->mTextures.resize( textureCount );
+  for( unsigned int i(0); i<textureCount; ++i )
   {
-    dataProvider->mSamplers[i] = samplers[i]; // Convert from derived type to base type
+    dataProvider->mTextures[i] = Render::Texture( mMaterial->GetTextureUniformName(i),
+                                                  mMaterial->GetTextureId(i),
+                                                  mMaterial->GetTextureSampler(i));
   }
 
   return dataProvider;
@@ -348,14 +342,13 @@ void Renderer::PrepareResources( BufferIndex updateBufferIndex, ResourceManager&
     unsigned int neverCount = 0;
     unsigned int frameBufferCount = 0;
 
-    Vector<Sampler*>& samplers = mMaterial->GetSamplers();
-    unsigned int samplerCount( samplers.Size() );
-    for( unsigned int i(0); i<samplerCount; ++i )
+    size_t textureCount( mMaterial->GetTextureCount() );
+    for( unsigned int i(0); i<textureCount; ++i )
     {
-      ResourceId textureId = samplers[i]->GetTextureId( updateBufferIndex );
+      ResourceId textureId = mMaterial->GetTextureId(i);
       BitmapMetadata metaData = resourceManager.GetBitmapMetadata( textureId );
 
-      samplers[i]->SetFullyOpaque( metaData.IsFullyOpaque() );
+      mMaterial->SetIsFullyOpaque( i, metaData.IsFullyOpaque() );
 
       switch( completeStatusManager.GetStatus( textureId ) )
       {
@@ -405,8 +398,8 @@ void Renderer::PrepareResources( BufferIndex updateBufferIndex, ResourceManager&
 
     // We are ready if all samplers are complete, or those that aren't are framebuffers
     // We are complete if all samplers are either complete or will nmResendGeometryever complete
-    mResourcesReady = ( completeCount + frameBufferCount >= samplers.Count() ) ;
-    mFinishedResourceAcquisition = ( completeCount + neverCount >= samplers.Count() );
+    mResourcesReady = ( completeCount + frameBufferCount >= textureCount ) ;
+    mFinishedResourceAcquisition = ( completeCount + neverCount >= textureCount );
   }
 }
 
diff --git a/dali/internal/update/rendering/scene-graph-sampler.cpp b/dali/internal/update/rendering/scene-graph-sampler.cpp
deleted file mode 100644 (file)
index 4c99c8d..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// CLASS HEADER
-#include "scene-graph-sampler.h"
-
-// EXTERNAL HEADERS
-
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-
-Sampler::Sampler( const std::string& textureUnitUniformName )
-: mMinFilter( Dali::Sampler::DEFAULT ),
-  mMagFilter( Dali::Sampler::DEFAULT ),
-  mUWrapMode( Dali::Sampler::CLAMP_TO_EDGE ),
-  mVWrapMode( Dali::Sampler::CLAMP_TO_EDGE ),
-  mAffectsTransparency( true ),
-  mTextureUnitUniformName( textureUnitUniformName ),
-  mFullyOpaque(true)
-{
-  mTextureId[ 0 ] = mTextureId[ 1 ] = 0u;
-}
-
-Sampler::~Sampler()
-{
-}
-
-void Sampler::SetTextureUnitUniformName( const std::string& textureUnitUniformName )
-{
-  mTextureUnitUniformName = textureUnitUniformName;
-}
-
-void Sampler::SetTexture( BufferIndex bufferIndex, Integration::ResourceId textureId )
-{
-  if( mTextureId[bufferIndex] != textureId )
-  {
-    mTextureId[ bufferIndex ] = textureId;
-    mConnectionObservers.ConnectionsChanged(*this);
-  }
-}
-
-void Sampler::SetFilterMode( BufferIndex bufferIndex, FilterMode minFilter, FilterMode magFilter )
-{
-  mMinFilter.Set(bufferIndex, minFilter);
-  mMagFilter.Set(bufferIndex, magFilter);
-}
-
-void Sampler::SetWrapMode( BufferIndex bufferIndex, WrapMode uWrap, WrapMode vWrap )
-{
-}
-
-const std::string& Sampler::GetTextureUnitUniformName() const
-{
-  return mTextureUnitUniformName;
-}
-
-Integration::ResourceId Sampler::GetTextureId( BufferIndex bufferIndex ) const
-{
-  return mTextureId[bufferIndex];
-}
-
-Sampler::FilterMode Sampler::GetMinifyFilterMode( BufferIndex bufferIndex ) const
-{
-  return static_cast<Sampler::FilterMode>(mMinFilter[bufferIndex]);
-}
-
-Sampler::FilterMode Sampler::GetMagnifyFilterMode( BufferIndex bufferIndex ) const
-{
-  return static_cast<Sampler::FilterMode>(mMagFilter[bufferIndex]);
-}
-
-Sampler::WrapMode Sampler::GetUWrapMode( BufferIndex bufferIndex ) const
-{
-  return static_cast<Sampler::WrapMode>(mUWrapMode[bufferIndex]);
-}
-
-Sampler::WrapMode Sampler::GetVWrapMode( BufferIndex bufferIndex ) const
-{
-  return static_cast<Sampler::WrapMode>(mVWrapMode[bufferIndex]);
-}
-
-bool Sampler::AffectsTransparency( BufferIndex bufferIndex ) const
-{
-  return mAffectsTransparency[bufferIndex] ;
-}
-
-void Sampler::SetFullyOpaque( bool fullyOpaque )
-{
-  mFullyOpaque = fullyOpaque;
-}
-
-bool Sampler::IsFullyOpaque( BufferIndex bufferIndex ) const
-{
-  return mFullyOpaque;
-}
-
-void Sampler::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
-{
-}
-
-void Sampler::DisconnectFromSceneGraph(SceneController& sceneController, BufferIndex bufferIndex)
-{
-}
-
-void Sampler::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
-{
-  mConnectionObservers.Add(observer);
-}
-
-void Sampler::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
-{
-  mConnectionObservers.Remove(observer);
-}
-
-void Sampler::ResetDefaultProperties( BufferIndex bufferIndex )
-{
-  mTextureId[ bufferIndex ] = mTextureId[ 1 - bufferIndex ];
-  mMinFilter.CopyPrevious( bufferIndex );
-  mMagFilter.CopyPrevious( bufferIndex );
-  mUWrapMode.CopyPrevious( bufferIndex );
-  mVWrapMode.CopyPrevious( bufferIndex );
-  mAffectsTransparency.CopyPrevious( bufferIndex );
-}
-
-} // namespace SceneGraph
-} // namespace Internal
-} // namespace Dali
diff --git a/dali/internal/update/rendering/scene-graph-sampler.h b/dali/internal/update/rendering/scene-graph-sampler.h
deleted file mode 100644 (file)
index f3d0cd7..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-#ifndef DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H
-#define DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H
-
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <dali/devel-api/rendering/sampler.h>
-#include <dali/integration-api/resource-declarations.h>
-#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/update/common/double-buffered.h>
-#include <dali/internal/update/common/double-buffered-property.h>
-#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
-#include <dali/internal/update/resources/bitmap-metadata.h>
-#include <dali/internal/render/data-providers/sampler-data-provider.h>
-
-#include <string>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace SceneGraph
-{
-class SceneController;
-
-class Sampler : public PropertyOwner, public SamplerDataProvider
-{
-public:
-  typedef Dali::Sampler::FilterMode FilterMode;
-  typedef Dali::Sampler::WrapMode   WrapMode;
-
-  /**
-   * Constructor
-   */
-  Sampler( const std::string& samplerName );
-
-  /**
-   * Destructor
-   */
-  virtual ~Sampler();
-
-  /**
-   * Set the uniform name of this sampler. This allows the shader to find the
-   * GL index of this sampler.
-   */
-  void SetTextureUnitUniformName( const std::string& textureUnitUniformName );
-
-  /**
-   * Set the texture identity of this sampler (needs to double buffer this value because
-   * it can be read through the data provider interface in the render thread )
-   * @param[in] bufferIndex The buffer index to use
-   * @param[in] textureId The identity of the texture
-   */
-  void SetTexture( BufferIndex bufferIndex, Integration::ResourceId textureId );
-
-  /**
-   * Set the filter modes for minify and magnify filters
-   * @param[in] bufferIndex The buffer index to use
-   * @param[in] minFilter The minify filter
-   * @param[in] magFilter The magnify filter
-   */
-  void SetFilterMode( BufferIndex bufferIndex, FilterMode minFilter, FilterMode magFilter );
-
-  /**
-   * @param[in] bufferIndex The buffer index to use
-   */
-  void SetWrapMode( BufferIndex bufferIndex, WrapMode uWrap, WrapMode vWrap );
-
-  /**
-   * @param[in] bufferIndex The buffer index to use
-   * @return true if this sampler affects transparency of the material
-   * @note this should only be called from Update thread
-   */
-  bool AffectsTransparency( BufferIndex bufferIndex ) const;
-
-  /**
-   * Sets whether the associated texture is fully opaque or not.
-   * @param[in] fullyOpaque true if it's fully opaque
-   */
-  void SetFullyOpaque( bool fullyOpaque );
-
-  /**
-   * @param[in] bufferIndex The buffer index to use
-   * @return true if the texture is fully opaque
-   * @note this should only be called from Update thread
-   */
-  bool IsFullyOpaque( BufferIndex bufferIndex ) const;
-
-
-public: // SamplerDataProvider interface - called from RenderThread
-  /**
-   * Get the texture unit uniform name
-   * @return the name of the texture unit uniform
-   */
-  virtual const std::string& GetTextureUnitUniformName() const;
-
-  /**
-   * Get the texture ID
-   * @param[in] bufferIndex The buffer index to use
-   * @return the identity of the associated texture
-   */
-  virtual Integration::ResourceId GetTextureId(BufferIndex buffer) const;
-
-  /**
-   * Get the filter mode
-   * @param[in] bufferIndex The buffer index to use
-   * @return The minify filter mode
-   */
-  virtual FilterMode GetMinifyFilterMode( BufferIndex bufferIndex ) const;
-
-  /**
-   * Get the filter mode
-   * @param[in] bufferIndex The buffer index to use
-   * @return The magnify filter mode
-   */
-  virtual FilterMode GetMagnifyFilterMode( BufferIndex bufferIndex ) const;
-
-  /**
-   * Get the horizontal wrap mode
-   * @param[in] bufferIndex The buffer index to use
-   * @return The horizontal wrap mode
-   */
-  virtual WrapMode GetUWrapMode( BufferIndex bufferIndex ) const;
-
-  /**
-   * Get the vertical wrap mode
-   * @param[in] bufferIndex The buffer index to use
-   * @return The vertical wrap mode
-   */
-  virtual WrapMode GetVWrapMode( BufferIndex bufferIndex ) const;
-
-  /**
-   * Connect the object to the scene graph
-   *
-   * @param[in] sceneController The scene controller - used for sending messages to render thread
-   * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
-   */
-  void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
-
-  /**
-   * Disconnect the object from the scene graph
-   * @param[in] sceneController The scene controller - used for sending messages to render thread
-   * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
-   */
-  void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
-
-  /**
-   * @copydoc ConnectionChangePropagator::AddObserver
-   */
-  void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
-
-  /**
-   * @copydoc ConnectionChangePropagator::RemoveObserver
-   */
-  void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
-
-public: // PropertyOwner implementation
-  /**
-   * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
-   */
-  virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
-
-public: // Properties
-  DoubleBufferedProperty<int>  mMinFilter;    ///< The minify filter
-  DoubleBufferedProperty<int>  mMagFilter;    ///< The magnify filter
-  DoubleBufferedProperty<int>  mUWrapMode;    ///< The horizontal wrap mode
-  DoubleBufferedProperty<int>  mVWrapMode;    ///< The vertical wrap mode
-  DoubleBufferedProperty<bool> mAffectsTransparency; ///< If this sampler affects renderer transparency
-
-private:
-  std::string mTextureUnitUniformName; ///< The name of the uniform of the texture unit
-  Integration::ResourceId mTextureId[ 2 ]; //< double buffered
-  ConnectionChangePropagator mConnectionObservers; ///< Connection observers that will be informed when textures change.
-  bool mFullyOpaque; // Update only flag - no need for double buffering
-};
-
-} // namespace SceneGraph
-
-inline void SetTextureUnitUniformNameMessage( EventThreadServices& eventThreadServices, const SceneGraph::Sampler& sampler, const std::string& name )
-{
-  typedef MessageValue1< SceneGraph::Sampler, std::string > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &sampler, &SceneGraph::Sampler::SetTextureUnitUniformName, name );
-}
-
-
-inline void SetTextureMessage( EventThreadServices& eventThreadServices, const SceneGraph::Sampler& sampler, unsigned int resourceId )
-{
-  typedef MessageDoubleBuffered1< SceneGraph::Sampler, unsigned int > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &sampler, &SceneGraph::Sampler::SetTexture, resourceId );
-}
-
-// Declare enum as a message parameter type outside the SceneGraph namespace
-template <> struct ParameterType< SceneGraph::Sampler::FilterMode > : public BasicType< SceneGraph::Sampler::FilterMode > {};
-
-
-inline void SetFilterModeMessage( EventThreadServices& eventThreadServices, const SceneGraph::Sampler& sampler, SceneGraph::Sampler::FilterMode minFilter, SceneGraph::Sampler::FilterMode magFilter )
-{
-  typedef MessageDoubleBuffered2< SceneGraph::Sampler, SceneGraph::Sampler::FilterMode, SceneGraph::Sampler::FilterMode > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &sampler, &SceneGraph::Sampler::SetFilterMode, minFilter, magFilter );
-}
-
-// Declare enum as a message parameter type
-template <> struct ParameterType< SceneGraph::Sampler::WrapMode > : public BasicType< SceneGraph::Sampler::WrapMode > {};
-
-
-inline void SetWrapModeMessage( EventThreadServices& eventThreadServices, const SceneGraph::Sampler& sampler, SceneGraph::Sampler::WrapMode horizontalWrap, SceneGraph::Sampler::WrapMode verticalWrap )
-{
-  typedef MessageDoubleBuffered2< SceneGraph::Sampler, SceneGraph::Sampler::WrapMode, SceneGraph::Sampler::WrapMode > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &sampler, &SceneGraph::Sampler::SetWrapMode, horizontalWrap, verticalWrap );
-}
-
-} // namespace Internal
-} // namespace Dali
-
-
-#endif //  DALI_INTERNAL_SCENE_GRAPH_SAMPLER_H
index 775c294..4cf7a48 100644 (file)
@@ -36,7 +36,7 @@ namespace FilterMode
  */
 enum Type
 {
-  NONE,       ///< Use GL system defaults (minification NEAREST_MIPMAP_LINEAR, magnification LINEAR)
+  NONE = 0,       ///< Use GL system defaults (minification NEAREST_MIPMAP_LINEAR, magnification LINEAR)
   DEFAULT,    ///< Use dali defaults (minification LINEAR, magnification LINEAR)
   NEAREST,    ///< Filter nearest
   LINEAR      ///< Filter linear
@@ -44,6 +44,19 @@ enum Type
 
 } //namespace FilterMode
 
+namespace WrapMode
+{
+
+enum Type
+{
+  DEFAULT = 0,    ///< Clamp to edge
+  CLAMP_TO_EDGE,
+  REPEAT,
+  MIRRORED_REPEAT
+};
+
+} //namespace WrapMode
+
 /**
  * @}
  */