*
*/
+// 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
{
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 );
/*
- * 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;
END_TEST;
}
-
int UtcSamplerSetFilterMode(void)
{
TestApplication application;
Sampler sampler = Sampler::New();
TextureSet textureSet = CreateTextureSet();
- textureSet.SetImage( 0u, image );
+ TextureSetImage( textureSet, 0u, image );
textureSet.SetSampler( 0u, sampler );
Shader shader = CreateShader();
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();
/*
- * 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;
Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
TextureSet textureSet = TextureSet::New();
- textureSet.SetImage( 0u, image );
+ TextureSetImage( textureSet, 0u, image );
TextureSet textureSetCopy(textureSet);
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;
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;
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() );
/*
- * 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;
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 );
/*
- * 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
{
{
return TextureSet::New();
}
+
TextureSet CreateTextureSet( Image image )
{
TextureSet textureSet = TextureSet::New();
- textureSet.SetImage( 0u, image );
+ TextureSetImage( textureSet, 0u, image );
return textureSet;
}
*
*/
-// 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
{
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
TextureSet textureSet = renderer.GetTextures();
if( textureSet && textureSet.GetTextureCount() )
{
- image = textureSet.GetImage( 0u );
+ image = TextureGetImage( textureSet, 0u );
}
}
}
$(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 \
$(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 \
--- /dev/null
+/*
+ * 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
--- /dev/null
+#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
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 )
}
}
-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 );
#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
{
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
* @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;
/**