Moved TextureSet::SetImage() to separate devel-api module 99/79499/7
authorTom Robinson <tom.robinson@samsung.com>
Mon, 11 Jul 2016 13:02:12 +0000 (14:02 +0100)
committerTom Robinson <tom.robinson@samsung.com>
Mon, 11 Jul 2016 17:58:28 +0000 (18:58 +0100)
Change-Id: I44a5be3e98c76a73b6672c079e1f1d9084113994

automated-tests/src/dali-devel/utc-Dali-Renderer.cpp
automated-tests/src/dali-devel/utc-Dali-Sampler.cpp
automated-tests/src/dali-devel/utc-Dali-TextureSet.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/dali-test-suite-utils/test-actor-utils.cpp
dali/devel-api/file.list
dali/devel-api/images/texture-set-image.cpp [new file with mode: 0644]
dali/devel-api/images/texture-set-image.h [new file with mode: 0644]
dali/devel-api/rendering/texture-set.cpp
dali/devel-api/rendering/texture-set.h

index fe9e038..8f20bbe 100644 (file)
  *
  */
 
+// EXTERNAL INCLUDES
 #include <dali/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-
+#include <dali/devel-api/images/texture-set-image.h>
 #include <cstdio>
 
-using namespace Dali;
-
+// INTERNAL INCLUDES
+#include <dali-test-suite-utils.h>
 #include <mesh-builder.h>
 
+using namespace Dali;
+
 namespace // unnamed namespace
 {
 
@@ -808,7 +810,7 @@ int UtcDaliRendererSetBlendColor(void)
   Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
   TextureSet textureSet = TextureSet::New();
   BufferImage image = BufferImage::New( 50, 50, Pixel::RGBA8888 );
-  textureSet.SetImage( 0u, image );
+  TextureSetImage( textureSet, 0u, image );
   Renderer renderer = Renderer::New( geometry, shader );
   renderer.SetTextures( textureSet );
 
index 0c67242..83dc18d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
  *
  */
 
-#include <unistd.h>
+// EXTERNAL INCLUDES
 #include <dali/public-api/dali-core.h>
+#include <dali/devel-api/images/texture-set-image.h>
+#include <unistd.h>
+
+// INTERNAL INCLUDES
 #include <dali-test-suite-utils.h>
+#include <mesh-builder.h>
 
 using namespace Dali;
 
-#include <mesh-builder.h>
-
 void sampler_test_startup(void)
 {
   test_return_value = TET_UNDEF;
@@ -113,7 +116,6 @@ int UtcDaliSamplerAssignmentOperator(void)
   END_TEST;
 }
 
-
 int UtcSamplerSetFilterMode(void)
 {
   TestApplication application;
@@ -122,7 +124,7 @@ int UtcSamplerSetFilterMode(void)
   Sampler sampler = Sampler::New();
 
   TextureSet textureSet = CreateTextureSet();
-  textureSet.SetImage( 0u, image );
+  TextureSetImage( textureSet, 0u, image );
   textureSet.SetSampler( 0u, sampler );
 
   Shader shader = CreateShader();
@@ -253,7 +255,7 @@ int UtcSamplerSetWrapMode(void)
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
   TextureSet textureSet = CreateTextureSet();
   Sampler sampler = Sampler::New();
-  textureSet.SetImage( 0u, image );
+  TextureSetImage( textureSet, 0u, image );
   textureSet.SetSampler( 0u, sampler );
 
   Shader shader = CreateShader();
index 2c5d75d..388fc2a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  */
 
+// EXTERNAL INCLUDES
 #include <dali/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
-
-using namespace Dali;
+#include <dali/devel-api/images/texture-set-image.h>
 
+// INTERNAL INCLUDES
+#include <dali-test-suite-utils.h>
 #include <mesh-builder.h>
 
+using namespace Dali;
 void texture_set_test_startup(void)
 {
   test_return_value = TET_UNDEF;
@@ -56,7 +58,7 @@ int UtcDaliTextureSetCopyConstructor(void)
 
   Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
   TextureSet textureSet = TextureSet::New();
-  textureSet.SetImage( 0u, image );
+  TextureSetImage( textureSet, 0u, image );
 
   TextureSet textureSetCopy(textureSet);
 
@@ -101,97 +103,6 @@ int UtcDaliTextureSetDownCast02(void)
   END_TEST;
 }
 
-int UtcDaliTextureSetSetImage01(void)
-{
-  TestApplication application;
-
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-
-  Shader shader = CreateShader();
-  TextureSet textureSet = CreateTextureSet();
-  textureSet.SetImage( 0u, image );
-
-  Geometry geometry = Geometry::QUAD();
-  Renderer renderer = Renderer::New( geometry, shader );
-  renderer.SetTextures( textureSet );
-
-  Actor actor = Actor::New();
-  actor.AddRenderer(renderer);
-  actor.SetParentOrigin( ParentOrigin::CENTER );
-  actor.SetSize(400, 400);
-
-  Stage::GetCurrent().Add( actor );
-
-  TestGlAbstraction& gl = application.GetGlAbstraction();
-
-  TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
-  texParameterTrace.Reset();
-  texParameterTrace.Enable( true );
-  application.SendNotification();
-  application.Render();
-
-  int textureUnit=-1;
-  DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture", textureUnit ) );
-  DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
-
-  texParameterTrace.Enable( false );
-
-  // Verify gl state
-  // There are three calls to TexParameteri when the texture is first created
-  // as the texture is using default sampling parametrers there shouldn't be any more calls to TexParameteri
-  DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3, TEST_LOCATION);
-
-  END_TEST;
-}
-
-int UtcDaliTextureSetSetImage02(void)
-{
-  TestApplication application;
-
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-
-  Shader shader = CreateShader();
-  TextureSet textureSet = CreateTextureSet();
-
-  Sampler sampler = Sampler::New();
-  sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
-  textureSet.SetImage( 0u, image );
-  textureSet.SetSampler( 0u, sampler );
-
-  Geometry geometry = Geometry::QUAD();
-  Renderer renderer = Renderer::New( geometry, shader );
-  renderer.SetTextures( textureSet );
-
-  Actor actor = Actor::New();
-  actor.AddRenderer(renderer);
-  actor.SetParentOrigin( ParentOrigin::CENTER );
-  actor.SetSize(400, 400);
-
-  Stage::GetCurrent().Add( actor );
-
-  TestGlAbstraction& gl = application.GetGlAbstraction();
-
-  TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
-  texParameterTrace.Reset();
-  texParameterTrace.Enable( true );
-  application.SendNotification();
-  application.Render();
-
-  int textureUnit=-1;
-  DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture", textureUnit ) );
-  DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
-
-  texParameterTrace.Enable( false );
-
-  // Verify gl state
-  // There are three calls to TexParameteri when the texture is first created
-  // Texture minification and magnification filters are now different than default so
-  //there should have been two extra TexParameteri calls to set the new filter mode
-  DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 4, TEST_LOCATION);
-
-  END_TEST;
-}
-
 int UtcDaliTextureSetTexture01(void)
 {
   TestApplication application;
@@ -342,35 +253,6 @@ int UtcDaliTextureSetSetSampler(void)
   END_TEST;
 }
 
-int UtcDaliTextureSetGetImage(void)
-{
-  TestApplication application;
-
-  TextureSet textureSet = CreateTextureSet();
-  DALI_TEST_EQUALS( textureSet.GetImage(0), Image(), TEST_LOCATION );
-  DALI_TEST_EQUALS( textureSet.GetImage(1), Image(), TEST_LOCATION );
-  DALI_TEST_EQUALS( textureSet.GetImage(2), Image(), TEST_LOCATION );
-
-  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  textureSet.SetImage( 0u, image );
-
-  DALI_TEST_EQUALS( textureSet.GetImage(0), image, TEST_LOCATION );
-  DALI_TEST_EQUALS( textureSet.GetImage(1), Image(), TEST_LOCATION );
-  DALI_TEST_EQUALS( textureSet.GetImage(2), Image(), TEST_LOCATION );
-
-  textureSet.SetImage( 2u, image );
-  DALI_TEST_EQUALS( textureSet.GetImage(0), image, TEST_LOCATION );
-  DALI_TEST_EQUALS( textureSet.GetImage(1), Image(), TEST_LOCATION );
-  DALI_TEST_EQUALS( textureSet.GetImage(2), image, TEST_LOCATION );
-
-  textureSet.SetImage( 2u, Image() );
-  DALI_TEST_EQUALS( textureSet.GetImage(0), image, TEST_LOCATION );
-  DALI_TEST_EQUALS( textureSet.GetImage(1), Image(), TEST_LOCATION );
-  DALI_TEST_EQUALS( textureSet.GetImage(2), Image(), TEST_LOCATION );
-
-  END_TEST;
-}
-
 int UtcDaliTextureSetGetTexture(void)
 {
   TestApplication application;
@@ -438,10 +320,10 @@ int UtcDaliTextureSetGetTextureCount(void)
   DALI_TEST_EQUALS( textureSet.GetTextureCount(), 0u, TEST_LOCATION );
 
   Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
-  textureSet.SetImage( 0u, image );
+  TextureSetImage( textureSet, 0u, image );
   DALI_TEST_EQUALS( textureSet.GetTextureCount(), 1u, TEST_LOCATION );
 
-  textureSet.SetImage( 1u, image );
+  TextureSetImage( textureSet, 1u, image );
   DALI_TEST_EQUALS( textureSet.GetTextureCount(), 2u, TEST_LOCATION );
 
   textureSet.SetSampler( 2u, Sampler::New() );
index e3f440e..3efd563 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
  *
  */
 
-#include <iostream>
-#include <algorithm>
-#include <stdlib.h>
+// EXTERNAL INCLUDES
 #include <dali/public-api/dali-core.h>
-#include <dali-test-suite-utils.h>
 #include <dali/devel-api/object/property-buffer.h>
 #include <dali/devel-api/rendering/geometry.h>
 #include <dali/devel-api/rendering/texture-set.h>
 #include <dali/devel-api/rendering/renderer.h>
 #include <dali/devel-api/rendering/sampler.h>
 #include <dali/devel-api/rendering/shader.h>
+#include <dali/devel-api/images/texture-set-image.h>
+#include <iostream>
+#include <algorithm>
+#include <stdlib.h>
+
+// INTERNAL INCLUDES
+#include <dali-test-suite-utils.h>
 
 using namespace Dali;
 
@@ -64,7 +68,7 @@ Actor CreateMeshActorToStage( TestApplication& application, Vector3 parentOrigin
   Geometry geometry = Geometry::QUAD();
   Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER, shaderHints );
   TextureSet textureSet = TextureSet::New();
-  textureSet.SetImage( 0u, image );
+  TextureSetImage( textureSet, 0u, image );
   Renderer renderer = Renderer::New( geometry, shader );
   renderer.SetTextures( textureSet );
 
index 978dc74..d94e548 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
  * limitations under the License.
  *
  */
+
+// CLASS HEADER
 #include "mesh-builder.h"
 
+// EXTERNAL INCLUDES
+#include <dali/devel-api/images/texture-set-image.h>
+
 namespace Dali
 {
 
@@ -28,10 +33,11 @@ TextureSet CreateTextureSet()
 {
   return TextureSet::New();
 }
+
 TextureSet CreateTextureSet( Image image )
 {
   TextureSet textureSet = TextureSet::New();
-  textureSet.SetImage( 0u, image );
+  TextureSetImage( textureSet, 0u, image );
   return textureSet;
 }
 
index 9be97bc..083e582 100644 (file)
  *
  */
 
-// HEADER
+// CLASS HEADER
 #include "test-actor-utils.h"
-#include "mesh-builder.h"
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/dali-core.h>
+#include <dali/devel-api/images/texture-set-image.h>
 #include <dali/devel-api/rendering/renderer.h>
 
+// INTERNAL INCLUDES
+#include "mesh-builder.h"
+
 namespace Dali
 {
 
@@ -81,7 +84,7 @@ Actor CreateRenderableActor( Image texture, const std::string& vertexShader, con
   if( texture )
   {
     TextureSet textureSet = TextureSet::New();
-    textureSet.SetImage( 0u, texture );
+    TextureSetImage( textureSet, 0u, texture );
     renderer.SetTextures( textureSet );
 
     // Set actor to the size of the texture if set
@@ -102,7 +105,7 @@ Image GetTexture( Actor actor )
       TextureSet textureSet = renderer.GetTextures();
       if( textureSet && textureSet.GetTextureCount() )
       {
-        image = textureSet.GetImage( 0u );
+        image = TextureGetImage( textureSet, 0u );
       }
     }
   }
index 1ecf8f1..6d18291 100644 (file)
@@ -8,6 +8,7 @@ devel_api_src_files = \
   $(devel_api_src_dir)/images/atlas.cpp \
   $(devel_api_src_dir)/images/distance-field.cpp \
   $(devel_api_src_dir)/images/pixel-data.cpp \
+  $(devel_api_src_dir)/images/texture-set-image.cpp \
   $(devel_api_src_dir)/object/property-buffer.cpp \
   $(devel_api_src_dir)/object/weak-handle.cpp \
   $(devel_api_src_dir)/rendering/frame-buffer.cpp \
@@ -43,7 +44,8 @@ devel_api_core_images_header_files = \
   $(devel_api_src_dir)/images/atlas.h \
   $(devel_api_src_dir)/images/distance-field.h \
   $(devel_api_src_dir)/images/pixel-data.h \
-  $(devel_api_src_dir)/images/native-image-interface-extension.h
+  $(devel_api_src_dir)/images/native-image-interface-extension.h \
+  $(devel_api_src_dir)/images/texture-set-image.h
 
 devel_api_core_object_header_files = \
   $(devel_api_src_dir)/object/property-buffer.h \
diff --git a/dali/devel-api/images/texture-set-image.cpp b/dali/devel-api/images/texture-set-image.cpp
new file mode 100644 (file)
index 0000000..312e98b
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 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 "texture-set-image.h"
+
+// INTERNAL INCLUDES
+#include <dali/internal/event/rendering/texture-set-impl.h>
+#include <dali/internal/event/images/image-impl.h>
+
+namespace Dali
+{
+
+
+void TextureSetImage( TextureSet textureSet, size_t index, Image image )
+{
+  // Get implementation of the TextureSet to use.
+  Internal::TextureSet& internalTextureSet = GetImplementation( textureSet );
+
+  // Check for valid image.
+  if( image )
+  {
+    // Get image impl and set in TextureSet.
+    Internal::ImagePtr imagePointer( &GetImplementation( image ) );
+    internalTextureSet.SetImage( index, imagePointer );
+  }
+  else
+  {
+    // No valid image, Remove texture at this index.
+    internalTextureSet.SetImage( index, NULL );
+  }
+}
+
+Image TextureGetImage( TextureSet textureSet, size_t index )
+{
+  // Get implementation of the TextureSet to use.
+  Internal::TextureSet& internalTextureSet = GetImplementation( textureSet );
+
+  // Get a pointer to the image implementation.
+  Internal::Image* imagePointer = internalTextureSet.GetImage( index );
+
+  // Return a handle to the image.
+  return Dali::Image( imagePointer );
+}
+
+
+} // namespace Dali
diff --git a/dali/devel-api/images/texture-set-image.h b/dali/devel-api/images/texture-set-image.h
new file mode 100644 (file)
index 0000000..04bdb48
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef DALI_TEXTURE_SET_IMAGE_H
+#define DALI_TEXTURE_SET_IMAGE_H
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <stdlib.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+
+namespace Dali
+{
+
+class Image;
+class TextureSet;
+
+/**
+ * @brief Set the image at the specified position index.
+ * @param[in] textureSet The TextureSet to use
+ * @param[in] index The position in the TextureSet that the image will be set
+ * @param[in] image The image to set
+ */
+DALI_IMPORT_API void TextureSetImage( TextureSet textureSet, size_t index, Image image );
+
+/**
+ * @brief Get the image at the specified position index.
+ * @param[in] textureSet The TextureSet to use
+ * @param[in] index The position in the TextureSet that the image will be set
+ * @return A handle to the image at the the specified position
+ */
+DALI_IMPORT_API Image TextureGetImage( TextureSet textureSet, size_t index );
+
+
+} //namespace Dali
+
+#endif // DALI_TEXTURE_SET_IMAGE_H
index d92bf70..e2ef8a7 100644 (file)
@@ -56,19 +56,6 @@ TextureSet& TextureSet::operator=( const TextureSet& handle )
   return *this;
 }
 
-void TextureSet::SetImage( size_t index, Image image )
-{
-  if( image )
-  {
-    Internal::ImagePtr imagePtr( &GetImplementation( image ) );
-    GetImplementation(*this).SetImage( index, imagePtr );
-  }
-  else
-  {
-    GetImplementation(*this).SetImage( index, NULL );
-  }
-}
-
 void TextureSet::SetTexture( size_t index, Texture texture )
 {
   if( texture )
@@ -82,12 +69,6 @@ void TextureSet::SetTexture( size_t index, Texture texture )
   }
 }
 
-Image TextureSet::GetImage( size_t index ) const
-{
-  Internal::Image* imagePtr = GetImplementation(*this).GetImage( index );
-  return Dali::Image( imagePtr );
-}
-
 Texture TextureSet::GetTexture( size_t index ) const
 {
   Internal::NewTexture* texturePtr = GetImplementation(*this).GetTexture( index );
index 2d3e732..475015e 100644 (file)
 #include <cstddef> // std::size_t
 
 // INTERNAL INCLUDES
-#include <dali/public-api/images/image.h> // Dali::Image
-#include <dali/public-api/object/handle.h> // Dali::Handle
+#include <dali/public-api/object/handle.h>    // Dali::Handle
 #include <dali/devel-api/rendering/sampler.h> // Dali::Sampler
 #include <dali/devel-api/rendering/texture.h> // Dali::Texture
-#include <dali/devel-api/rendering/shader.h> // Dali::Shader
+#include <dali/devel-api/rendering/shader.h>  // Dali::Shader
 
 namespace Dali
 {
@@ -85,13 +84,6 @@ public:
   TextureSet& operator=( const TextureSet& handle );
 
   /**
-   * @brief Set the image at position "index"
-   * @param[in] index The position in the texture set of the image
-   * @param[in] image The image
-   */
-  void SetImage( size_t index, Image image );
-
-  /**
    * @brief Set the texture at position "index"
    * @param[in] index The position in the texture set of the texture
    * @param[in] texture The texture
@@ -103,13 +95,6 @@ public:
    * @param[in] index The position in the texture set of the image
    * @return A handle to the image at the the specified position
    */
-  Image GetImage( size_t index ) const;
-
-  /**
-   * @brief Get the image at position "index"
-   * @param[in] index The position in the texture set of the image
-   * @return A handle to the image at the the specified position
-   */
   Texture GetTexture( size_t index ) const;
 
   /**