From: Tom Robinson Date: Mon, 11 Jul 2016 13:02:12 +0000 (+0100) Subject: Moved TextureSet::SetImage() to separate devel-api module X-Git-Tag: dali_1.1.43~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F99%2F79499%2F7;p=platform%2Fcore%2Fuifw%2Fdali-core.git Moved TextureSet::SetImage() to separate devel-api module Change-Id: I44a5be3e98c76a73b6672c079e1f1d9084113994 --- diff --git a/automated-tests/src/dali-devel/utc-Dali-Renderer.cpp b/automated-tests/src/dali-devel/utc-Dali-Renderer.cpp index fe9e038..8f20bbe 100644 --- a/automated-tests/src/dali-devel/utc-Dali-Renderer.cpp +++ b/automated-tests/src/dali-devel/utc-Dali-Renderer.cpp @@ -15,15 +15,17 @@ * */ +// EXTERNAL INCLUDES #include -#include - +#include #include -using namespace Dali; - +// INTERNAL INCLUDES +#include #include +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 ); diff --git a/automated-tests/src/dali-devel/utc-Dali-Sampler.cpp b/automated-tests/src/dali-devel/utc-Dali-Sampler.cpp index 0c67242..83dc18d 100644 --- a/automated-tests/src/dali-devel/utc-Dali-Sampler.cpp +++ b/automated-tests/src/dali-devel/utc-Dali-Sampler.cpp @@ -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. @@ -15,14 +15,17 @@ * */ -#include +// EXTERNAL INCLUDES #include +#include +#include + +// INTERNAL INCLUDES #include +#include using namespace Dali; -#include - 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(); diff --git a/automated-tests/src/dali-devel/utc-Dali-TextureSet.cpp b/automated-tests/src/dali-devel/utc-Dali-TextureSet.cpp index 2c5d75d..388fc2a 100644 --- a/automated-tests/src/dali-devel/utc-Dali-TextureSet.cpp +++ b/automated-tests/src/dali-devel/utc-Dali-TextureSet.cpp @@ -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. @@ -15,13 +15,15 @@ * */ +// EXTERNAL INCLUDES #include -#include - -using namespace Dali; +#include +// INTERNAL INCLUDES +#include #include +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( "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( "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() ); diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-FrustumCulling.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-FrustumCulling.cpp index e3f440e..3efd563 100644 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-FrustumCulling.cpp +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-FrustumCulling.cpp @@ -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. @@ -15,17 +15,21 @@ * */ -#include -#include -#include +// EXTERNAL INCLUDES #include -#include #include #include #include #include #include #include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include 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 ); diff --git a/automated-tests/src/dali/dali-test-suite-utils/mesh-builder.cpp b/automated-tests/src/dali/dali-test-suite-utils/mesh-builder.cpp index 978dc74..d94e548 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/mesh-builder.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/mesh-builder.cpp @@ -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. @@ -14,8 +14,13 @@ * limitations under the License. * */ + +// CLASS HEADER #include "mesh-builder.h" +// EXTERNAL INCLUDES +#include + 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; } diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-actor-utils.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-actor-utils.cpp index 9be97bc..083e582 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-actor-utils.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-actor-utils.cpp @@ -15,14 +15,17 @@ * */ -// HEADER +// CLASS HEADER #include "test-actor-utils.h" -#include "mesh-builder.h" // EXTERNAL INCLUDES #include +#include #include +// 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 ); } } } diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index 1ecf8f1..6d18291 100644 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -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 index 0000000..312e98b --- /dev/null +++ b/dali/devel-api/images/texture-set-image.cpp @@ -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 +#include + +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 index 0000000..04bdb48 --- /dev/null +++ b/dali/devel-api/images/texture-set-image.h @@ -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 + +// INTERNAL INCLUDES +#include + +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 diff --git a/dali/devel-api/rendering/texture-set.cpp b/dali/devel-api/rendering/texture-set.cpp index d92bf70..e2ef8a7 100644 --- a/dali/devel-api/rendering/texture-set.cpp +++ b/dali/devel-api/rendering/texture-set.cpp @@ -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 ); diff --git a/dali/devel-api/rendering/texture-set.h b/dali/devel-api/rendering/texture-set.h index 2d3e732..475015e 100644 --- a/dali/devel-api/rendering/texture-set.h +++ b/dali/devel-api/rendering/texture-set.h @@ -22,11 +22,10 @@ #include // std::size_t // INTERNAL INCLUDES -#include // Dali::Image -#include // Dali::Handle +#include // Dali::Handle #include // Dali::Sampler #include // Dali::Texture -#include // Dali::Shader +#include // 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; /**