From 0a98cc9159a2b5868987ec7f0b31b76f3dc10259 Mon Sep 17 00:00:00 2001 From: Francisco Santos Date: Thu, 9 Feb 2017 09:59:23 +0000 Subject: [PATCH] Remove batching. Change-Id: I53705f72cfef810eb14fdbb9af2c5448712ee496 NOTE: Public API is not being changed. The batching option in image-visual-properties.h should have not been there. Please refer to the DALi API Publishing Rules an see rule 1c. --- .../src/dali-toolkit/utc-Dali-Visual.cpp | 82 ------ .../src/dali-toolkit/utc-Dali-VisualFactory.cpp | 136 --------- dali-toolkit/internal/file.list | 1 - .../internal/visuals/image/batch-image-visual.cpp | 320 --------------------- .../internal/visuals/image/batch-image-visual.h | 138 --------- .../internal/visuals/image/image-visual.cpp | 1 - dali-toolkit/internal/visuals/text/text-visual.h | 1 - .../internal/visuals/visual-factory-cache.cpp | 43 --- .../internal/visuals/visual-factory-cache.h | 8 - .../internal/visuals/visual-factory-impl.cpp | 18 +- .../public-api/visuals/image-visual-properties.h | 9 - 11 files changed, 1 insertion(+), 756 deletions(-) delete mode 100644 dali-toolkit/internal/visuals/image/batch-image-visual.cpp delete mode 100644 dali-toolkit/internal/visuals/image/batch-image-visual.h diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index f0175c4..f399d4d 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -286,19 +286,6 @@ int UtcDaliVisualSize(void) svgVisual2.GetNaturalSize(naturalSize); DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); // Natural size should still be 100, 100 - // Batch Image visual - TestPlatformAbstraction& platform = application.GetPlatform(); - Vector2 testSize(80.f, 160.f); - platform.SetClosestImageSize(testSize); - propertyMap.Clear(); - propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); - propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); - propertyMap.Insert( "batchingEnabled", true ); - Visual::Base batchImageVisual = factory.CreateVisual( propertyMap ); - batchImageVisual.SetTransformAndSize(DefaultTransform(), controlSize ); - batchImageVisual.GetNaturalSize( naturalSize ); - DALI_TEST_EQUALS( naturalSize, Vector2( 80.0f, 160.0f ), TEST_LOCATION ); - // Text visual. // Load some fonts to get the same metrics on different platforms. @@ -957,45 +944,6 @@ int UtcDaliVisualGetPropertyMap9(void) END_TEST; } -int UtcDaliVisualGetPropertyMapBatchImageVisual(void) -{ - ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualGetPropertyMapBatchImageVisual:" ); - - VisualFactory factory = VisualFactory::Get(); - Property::Map propertyMap; - propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); - propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true ); - propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); - propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 ); - propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 ); - - Visual::Base batchImageVisual = factory.CreateVisual( propertyMap ); - DALI_TEST_CHECK( batchImageVisual ); - - Property::Map resultMap; - batchImageVisual.CreatePropertyMap( resultMap ); - - // Check the property values from the returned map from visual - Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER ); - DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == Visual::IMAGE ); - - value = resultMap.Find( ImageVisual::Property::URL, Property::STRING ); - DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == TEST_IMAGE_FILE_NAME ); - - value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER ); - DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == 20 ); - - value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER ); - DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( value->Get() == 30 ); - - END_TEST; -} - //Text shape visual int UtcDaliVisualGetPropertyMap10(void) { @@ -1117,36 +1065,6 @@ int UtcDaliVisualGetPropertyMap11(void) END_TEST; } -int UtcDaliVisualGetPropertyMapBatchImageVisualNoAtlas(void) -{ - ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualGetPropertyMapBatchImageVisualNoAtlas:" ); - - VisualFactory factory = VisualFactory::Get(); - Property::Map propertyMap; - propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); - propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true ); - propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); - - // Set the desired size to be larger than the atlas limit of 1024x1024. - propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 2048 ); - propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 2048 ); - - // Create the visual. - Visual::Base batchImageVisual = factory.CreateVisual( propertyMap ); - - DALI_TEST_CHECK( batchImageVisual ); - - DummyControl dummyControl = DummyControl::New(true); - Impl::DummyControl& dummyImpl = static_cast(dummyControl.GetImplementation()); - dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, batchImageVisual ); - Stage::GetCurrent().Add( dummyControl ); - - DALI_TEST_CHECK( dummyControl.GetRendererCount() == 1u ); - - END_TEST; -} - int UtcDaliVisualAnimateBorderVisual01(void) { ToolkitTestApplication application; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp index 48de1ca..2eb6262 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp @@ -1976,142 +1976,6 @@ int UtcDaliVisualFactoryGetPrimitiveVisualN1(void) END_TEST; } -int UtcDaliVisualFactoryGetBatchImageVisual1(void) -{ - ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual1: Request a Batch Image visual with a Property::Map" ); - - VisualFactory factory = VisualFactory::Get(); - DALI_TEST_CHECK( factory ); - - Property::Map propertyMap; - propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); - propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true ); - propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); - - Visual::Base visual = factory.CreateVisual( propertyMap ); - DALI_TEST_CHECK( visual ); - - DummyControl actor = DummyControl::New(); - DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); - dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); - - actor.SetSize( 200.0f, 200.0f ); - Stage::GetCurrent().Add( actor ); - visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.0f, 200.0f ) ); - - // Test SetOnStage(). - DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); - - application.SendNotification(); - application.Render(); - - // Test SetOffStage(). - actor.Unparent(); - DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); - - END_TEST; -} - -int UtcDaliVisualFactoryGetBatchImageVisual2(void) -{ - ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual2: Request Batch Image visual from an Image Visual with batchingEnabled set" ); - - VisualFactory factory = VisualFactory::Get(); - DALI_TEST_CHECK( factory ); - - Property::Map propertyMap; - // Create a normal Image Visual. - propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); - // Instruct the factory to change Image Visuals to Batch-Image Visuals. - propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true ); - - // Properties for the Batch-Image Visual. - propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); - - Visual::Base visual = factory.CreateVisual( propertyMap ); - DALI_TEST_CHECK( visual ); - - // Check that a Batch-Image visual was created instead of an Image visual. - Property::Map resultMap; - visual.CreatePropertyMap( resultMap ); - - Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER ); - DALI_TEST_CHECK( value ); - DALI_TEST_EQUALS( value->Get(), (int)Visual::IMAGE, TEST_LOCATION ); - - DummyControl actor = DummyControl::New(); - DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); - dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); - - actor.SetSize( 200.0f, 200.0f ); - Stage::GetCurrent().Add( actor ); - visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.0f, 200.0f ) ); - - // Test SetOnStage(). - DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); - - application.SendNotification(); - application.Render(); - - // Test SetOffStage(). - actor.Unparent(); - DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); - - END_TEST; -} - -int UtcDaliVisualFactoryGetBatchImageVisual3(void) -{ - ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual3: Create an ImageView that uses a batched visual internally" ); - - VisualFactory factory = VisualFactory::Get(); - DALI_TEST_CHECK( factory ); - - // Create a property-map that enables batching. - Property::Map propertyMap; - propertyMap[ Dali::Toolkit::ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME ; - propertyMap[ "desiredHeight" ] = 200; - propertyMap[ "desiredWidth" ] = 200; - propertyMap[ "batchingEnabled" ] = true; - - // Create an ImageView, passing the property-map in to instruct it to use batching. - Toolkit::ImageView imageView = Toolkit::ImageView::New(); - imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, propertyMap ); - - imageView.SetSize( 200.0f, 200.0f ); - Stage::GetCurrent().Add( imageView ); - - END_TEST; -} - -int UtcDaliVisualFactoryGetBatchImageVisual4N(void) -{ - ToolkitTestApplication application; - tet_infoline( "UtcDaliVisualFactoryGetBatchImageVisual4: Create an ImageView that uses a batched visual, with desired properties of the wrong type" ); - - VisualFactory factory = VisualFactory::Get(); - DALI_TEST_CHECK( factory ); - - // Create a property-map that enables batching. - Property::Map propertyMap; - propertyMap[ Dali::Toolkit::ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME ; - propertyMap[ "desiredHeight" ] = Vector2(100, 100); - propertyMap[ "desiredWidth" ] = Vector3(1, 1, 1); - propertyMap[ "batchingEnabled" ] = true; - - // Create an ImageView, passing the property-map in to instruct it to use batching. - Toolkit::ImageView imageView = Toolkit::ImageView::New(); - imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, propertyMap ); - - imageView.SetSize( 200.0f, 200.0f ); - Stage::GetCurrent().Add( imageView ); - - END_TEST; -} - int UtcDaliVisualFactoryGetAnimatedImageVisual1(void) { ToolkitTestApplication application; diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index 84f3214..2fcc669 100755 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -24,7 +24,6 @@ toolkit_src_files = \ $(toolkit_src_dir)/visuals/gradient/linear-gradient.cpp \ $(toolkit_src_dir)/visuals/gradient/radial-gradient.cpp \ $(toolkit_src_dir)/visuals/gradient/gradient-visual.cpp \ - $(toolkit_src_dir)/visuals/image/batch-image-visual.cpp \ $(toolkit_src_dir)/visuals/image/image-visual.cpp \ $(toolkit_src_dir)/visuals/mesh/mesh-visual.cpp \ $(toolkit_src_dir)/visuals/npatch/npatch-visual.cpp \ diff --git a/dali-toolkit/internal/visuals/image/batch-image-visual.cpp b/dali-toolkit/internal/visuals/image/batch-image-visual.cpp deleted file mode 100644 index 47f0316..0000000 --- a/dali-toolkit/internal/visuals/image/batch-image-visual.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/* - * 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 "batch-image-visual.h" - -// EXTERNAL HEADER -#include // for strncasecmp -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// INTERNAL HEADER -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace Internal -{ - -namespace -{ -const char HTTP_URL[] = "http://"; -const char HTTPS_URL[] = "https://"; - -// Properties: -const char * const DESIRED_WIDTH( "desiredWidth" ); -const char * const DESIRED_HEIGHT( "desiredHeight" ); - -const Vector4 FULL_TEXTURE_RECT( 0.f, 0.f, 1.f, 1.f ); - -// The shader used for batched rendering. It uses interleaved data for -// attributes. Limitation is that all batched renderers will share same set of uniforms. -const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( - attribute mediump vec2 aPosition;\n - attribute mediump vec2 aTexCoord;\n - uniform mediump mat4 uMvpMatrix;\n - varying mediump vec2 vTexCoord;\n - \n - void main()\n - {\n - vTexCoord = aTexCoord;\n - gl_Position = uMvpMatrix * vec4( aPosition, 0.0, 1.0 );\n - }\n -); - -const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( - varying mediump vec2 vTexCoord;\n - uniform sampler2D sTexture;\n - uniform lowp vec4 uColor;\n - uniform lowp vec4 mixColor;\n - uniform lowp float preMultipliedAlpha;\n - lowp vec4 visualMixColor()\n - {\n - return vec4( mixColor.rgb * mix( 1.0, mixColor.a, preMultipliedAlpha ), mixColor.a );\n - }\n - \n - void main()\n - {\n - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * visualMixColor(); - }\n -); - -} // unnamed namespace - -BatchImageVisualPtr BatchImageVisual::New( VisualFactoryCache& factoryCache, const std::string& url, const Property::Map& properties ) -{ - BatchImageVisualPtr visual = new BatchImageVisual( factoryCache ); - visual->mImageUrl = url; - visual->SetProperties( properties ); - - return visual; -} - -BatchImageVisual::BatchImageVisual( VisualFactoryCache& factoryCache ) -: Visual::Base( factoryCache ), - mImageUrl(""), - mDesiredSize() -{ -} - -BatchImageVisual::~BatchImageVisual() -{ -} - -void BatchImageVisual::DoSetProperties( const Property::Map& propertyMap ) -{ - // url already passed in constructor - - for( Property::Map::SizeType iter = 0; iter < propertyMap.Count(); ++iter ) - { - KeyValuePair keyValue = propertyMap.GetKeyValue( iter ); - if( keyValue.first.type == Property::Key::INDEX ) - { - DoSetProperty( keyValue.first.indexKey, keyValue.second ); - } - else - { - if( keyValue.first == DESIRED_WIDTH ) - { - DoSetProperty( Toolkit::ImageVisual::Property::DESIRED_WIDTH, keyValue.second ); - } - else if( keyValue.first == DESIRED_HEIGHT ) - { - DoSetProperty( Toolkit::ImageVisual::Property::DESIRED_HEIGHT, keyValue.second ); - } - } - } -} - -void BatchImageVisual::DoSetProperty( Property::Index index, const Property::Value& value ) -{ - switch( index ) - { - case Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH: - { - int width; - if( value.Get( width ) ) - { - mDesiredSize.SetWidth( width ); - } - else - { - DALI_LOG_ERROR("BatchImageVisual: width property has incorrect type\n"); - } - break; - } - case Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT: - { - int height; - if( value.Get( height ) ) - { - mDesiredSize.SetHeight( height ); - } - else - { - DALI_LOG_ERROR("BatchImageVisual: height property has incorrect type\n"); - } - break; - } - } -} - -void BatchImageVisual::GetNaturalSize( Vector2& naturalSize ) -{ - if( mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0 ) - { - naturalSize.x = mDesiredSize.GetWidth(); - naturalSize.y = mDesiredSize.GetHeight(); - return; - } - else if( !mImageUrl.empty() ) - { - ImageDimensions dimentions = ResourceImage::GetImageSize( mImageUrl ); - naturalSize.x = dimentions.GetWidth(); - naturalSize.y = dimentions.GetHeight(); - return; - } - - naturalSize = Vector2::ZERO; -} - -void BatchImageVisual::InitializeRenderer( const std::string& imageUrl ) -{ - if( imageUrl.empty() ) - { - return; - } - - mImageUrl = imageUrl; - mImpl->mRenderer.Reset(); - mAtlasRect = FULL_TEXTURE_RECT; - - if( !mImpl->mCustomShader && - ( strncasecmp( imageUrl.c_str(),HTTP_URL, sizeof( HTTP_URL ) -1 ) != 0 ) && // Ignore remote images - ( strncasecmp( imageUrl.c_str(), HTTPS_URL, sizeof( HTTPS_URL ) -1 ) != 0 ) ) - { - if( !mImpl->mRenderer ) - { - TextureSet textureSet = mFactoryCache.GetAtlasManager()->Add( - mAtlasRect, - imageUrl, - mDesiredSize ); - - // If image doesn't fit the atlas, create new texture set with texture that - // is used as whole. - if( !textureSet ) - { - BitmapLoader loader = BitmapLoader::New( imageUrl, mDesiredSize ); - loader.Load(); - Dali::PixelData pixelData = loader.GetPixelData(); - Texture texture = Texture::New( TextureType::TEXTURE_2D, - pixelData.GetPixelFormat(), - pixelData.GetWidth(), - pixelData.GetHeight() ); - texture.Upload( pixelData ); - textureSet = TextureSet::New(); - textureSet.SetTexture( 0, texture ); - mAtlasRect = FULL_TEXTURE_RECT; - } - - Geometry geometry = mFactoryCache.CreateBatchQuadGeometry( mAtlasRect ); - Shader shader( GetBatchShader( mFactoryCache ) ); - mImpl->mRenderer = Renderer::New( geometry, shader ); - mImpl->mRenderer.SetTextures( textureSet ); - - // Turn batching on, to send message it must be on stage. - mImpl->mRenderer.SetProperty( Dali::DevelRenderer::Property::BATCHING_ENABLED, true ); - } - mImpl->mFlags |= Impl::IS_FROM_CACHE; - } -} - -void BatchImageVisual::DoSetOnStage( Actor& actor ) -{ - if( !mImageUrl.empty() ) - { - InitializeRenderer( mImageUrl ); - } - // Turn batching on, to send message it must be on stage - mImpl->mRenderer.SetProperty( Dali::DevelRenderer::Property::BATCHING_ENABLED, true ); - - actor.AddRenderer( mImpl->mRenderer ); -} - -void BatchImageVisual::DoSetOffStage( Actor& actor ) -{ - actor.RemoveRenderer( mImpl->mRenderer ); - - // If we own the image then make sure we release it when we go off stage - if( !mImageUrl.empty() ) - { - CleanCache( mImageUrl ); - } - else - { - mImpl->mRenderer.Reset(); - } -} - -void BatchImageVisual::DoCreatePropertyMap( Property::Map& map ) const -{ - map.Clear(); - map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::IMAGE ); - - if( !mImageUrl.empty() ) - { - map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl ); - map.Insert( Toolkit::ImageVisual::Property::BATCHING_ENABLED, true ); - map.Insert( Toolkit::ImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth() ); - map.Insert( Toolkit::ImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight() ); - } -} - -Shader BatchImageVisual::GetBatchShader( VisualFactoryCache& factoryCache ) -{ - Shader shader = factoryCache.GetShader( VisualFactoryCache::BATCH_IMAGE_SHADER ); - if( !shader ) - { - shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); - factoryCache.SaveShader( VisualFactoryCache::BATCH_IMAGE_SHADER, shader ); - } - return shader; -} - -void BatchImageVisual::CleanCache(const std::string& url) -{ - TextureSet textureSet = mImpl->mRenderer.GetTextures(); - mImpl->mRenderer.Reset(); - if( mFactoryCache.CleanRendererCache( url ) ) - { - mFactoryCache.GetAtlasManager()->Remove( textureSet, mAtlasRect ); - } -} - -void BatchImageVisual::OnSetTransform() -{ - if( mImpl->mRenderer ) - { - //Register transform properties - mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT ); - } -} - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/internal/visuals/image/batch-image-visual.h b/dali-toolkit/internal/visuals/image/batch-image-visual.h deleted file mode 100644 index 1f81195..0000000 --- a/dali-toolkit/internal/visuals/image/batch-image-visual.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_H -#define DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_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 HEADER -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -class BatchImageVisual; -typedef IntrusivePtr< BatchImageVisual > BatchImageVisualPtr; - -class BatchImageVisual: public Visual::Base, public ConnectionTracker -{ -public: - - /** - * @brief Create a new batch-image visual. - * - * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object - * @param[in] url The URL of the image to use - * @param[in] properties A Property::Map containing settings for this visual - * @return A smart-pointer to the newly allocated visual. - */ - static BatchImageVisualPtr New( VisualFactoryCache& factoryCache, const std::string& url, const Property::Map& properties = Property::Map() ); - -public: // from Visual - - /** - * @copydoc Visual::Base::GetNaturalSize - */ - virtual void GetNaturalSize( Vector2& naturalSize ); - - /** - * @copydoc Visual::Base::CreatePropertyMap - */ - virtual void DoCreatePropertyMap( Property::Map& map ) const; - -protected: - - /** - * @brief Constructor. - * - * @param[in] factoryCache The VisualFactoryCache object - */ - BatchImageVisual( VisualFactoryCache& factoryCache ); - - /** - * @brief A reference counted object may only be deleted by calling Unreference(). - */ - ~BatchImageVisual(); - - /** - * @copydoc Visua::Base::DoSetProperties - */ - virtual void DoSetProperties( const Property::Map& propertyMap ); - - /** - * @copydoc Visual::Base::DoSetOnStage - */ - virtual void DoSetOnStage( Actor& actor ); - - /** - * @copydoc Visual::Base::DoSetOffStage - */ - virtual void DoSetOffStage( Actor& actor ); - - /** - * @copydoc Visual::Base::OnSetTransform - */ - virtual void OnSetTransform(); - -private: - - /** - * Get the batch image rendering shader. - * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object - */ - static Shader GetBatchShader( VisualFactoryCache& factoryCache ); - - /** - * @brief Initializes the Dali::Renderer from an image url string - * - * @param[in] imageUrl The image url string to intialize this ImageVisual from - */ - void InitializeRenderer( const std::string& imageUrl ); - - /** - * Clean the Visual from cache, and remove the image from atlas if it is not used anymore - */ - void CleanCache( const std::string& url ); - - /** - * Helper method to set individual values by index key. - * @param[in] index The index key of the value - * @param[in] value The value - */ - void DoSetProperty( Property::Index index, const Property::Value& value ); - -private: - - Vector4 mAtlasRect; - std::string mImageUrl; - Dali::ImageDimensions mDesiredSize; -}; - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_BATCH_IMAGE_VISUAL_H diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index ec03c7f..a0197cd 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -58,7 +58,6 @@ const char * const IMAGE_SAMPLING_MODE( "samplingMode" ); const char * const IMAGE_DESIRED_WIDTH( "desiredWidth" ); const char * const IMAGE_DESIRED_HEIGHT( "desiredHeight" ); const char * const SYNCHRONOUS_LOADING( "synchronousLoading" ); -const char * const BATCHING_ENABLED( "batchingEnabled" ); // fitting modes DALI_ENUM_TO_STRING_TABLE_BEGIN( FITTING_MODE ) diff --git a/dali-toolkit/internal/visuals/text/text-visual.h b/dali-toolkit/internal/visuals/text/text-visual.h index 9edf08c..b0bf8c3 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.h +++ b/dali-toolkit/internal/visuals/text/text-visual.h @@ -60,7 +60,6 @@ typedef IntrusivePtr< TextVisual > TextVisualPtr; * | underline | STRING | * | shadow | STRING | * | outline | STRING | - * | batchingEnabled | BOOLEAN | * */ class TextVisual : public Visual::Base diff --git a/dali-toolkit/internal/visuals/visual-factory-cache.cpp b/dali-toolkit/internal/visuals/visual-factory-cache.cpp index 05e32ff..03f31de 100644 --- a/dali-toolkit/internal/visuals/visual-factory-cache.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-cache.cpp @@ -284,49 +284,6 @@ Geometry VisualFactoryCache::CreateGridGeometry( Uint16Pair gridSize ) return geometry; } -Geometry VisualFactoryCache::CreateBatchQuadGeometry( Vector4 texCoords ) -{ - const float halfWidth = 0.5f; - const float halfHeight = 0.5f; - struct QuadVertex { - QuadVertex( const Vector2& vertexPosition, const Vector2& vertexTexCoords ) - : position( vertexPosition ), - texCoords( vertexTexCoords ) - {} - Vector2 position; - Vector2 texCoords; - }; - - // special case, when texture takes whole space - if( texCoords == Vector4::ZERO ) - { - texCoords = Vector4(0.0f, 0.0f, 1.0f, 1.0f); - } - - QuadVertex quadVertexData[6] = - { - QuadVertex( Vector2(-halfWidth, -halfHeight ), Vector2(texCoords.x, texCoords.y) ), - QuadVertex( Vector2( halfWidth, -halfHeight ), Vector2(texCoords.z, texCoords.y) ), - QuadVertex( Vector2(-halfWidth, halfHeight ), Vector2(texCoords.x, texCoords.w) ), - QuadVertex( Vector2( halfWidth, -halfHeight ), Vector2(texCoords.z, texCoords.y) ), - QuadVertex( Vector2(-halfWidth, halfHeight ), Vector2(texCoords.x, texCoords.w) ), - QuadVertex( Vector2( halfWidth, halfHeight ), Vector2(texCoords.z, texCoords.w) ), - }; - - Property::Map vertexFormat; - vertexFormat[ "aPosition" ] = Property::VECTOR2; - vertexFormat[ "aTexCoord" ] = Property::VECTOR2; - PropertyBuffer vertexBuffer = PropertyBuffer::New( vertexFormat ); - vertexBuffer.SetData( quadVertexData, 6 ); - - // create geometry as normal, single quad - Geometry geometry = Geometry::New(); - geometry.AddVertexBuffer( vertexBuffer ); - geometry.SetType( Geometry::TRIANGLES ); - - return geometry; -} - Image VisualFactoryCache::GetBrokenVisualImage() { return ResourceImage::New( BROKEN_VISUAL_IMAGE_URL ); diff --git a/dali-toolkit/internal/visuals/visual-factory-cache.h b/dali-toolkit/internal/visuals/visual-factory-cache.h index 641c013..c674aac 100644 --- a/dali-toolkit/internal/visuals/visual-factory-cache.h +++ b/dali-toolkit/internal/visuals/visual-factory-cache.h @@ -64,7 +64,6 @@ public: GRADIENT_SHADER_RADIAL_USER_SPACE, GRADIENT_SHADER_RADIAL_BOUNDING_BOX, IMAGE_SHADER, - BATCH_IMAGE_SHADER, IMAGE_SHADER_ATLAS_DEFAULT_WRAP, IMAGE_SHADER_ATLAS_CUSTOM_WRAP, NINE_PATCH_SHADER, @@ -134,13 +133,6 @@ public: static Geometry CreateGridGeometry( Uint16Pair gridSize ); /** - * Create the batchable geometry - * @param[in] texCoords The texture atlas rect coordinates - * @return The created batchable geometry - */ - static Geometry CreateBatchQuadGeometry( Vector4 texCoords ); - - /** * @brief Returns an image to be used when a visual has failed to correctly render * @return The broken image handle. */ diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.cpp b/dali-toolkit/internal/visuals/visual-factory-impl.cpp index 2410f0a..909cfcc 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-impl.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -57,7 +56,6 @@ namespace Internal namespace { -const char * const BATCHING_ENABLED( "batchingEnabled" ); BaseHandle Create() { BaseHandle handle = Toolkit::VisualFactory::Get(); @@ -138,21 +136,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property } else // Regular image { - bool batchingEnabled( false ); - Property::Value* batchingEnabledValue = propertyMap.Find( Toolkit::ImageVisual::Property::BATCHING_ENABLED, BATCHING_ENABLED ); - if( batchingEnabledValue ) - { - batchingEnabledValue->Get( batchingEnabled ); - } - - if( batchingEnabled ) - { - visualPtr = BatchImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); - } - else - { - visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); - } + visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); } } diff --git a/dali-toolkit/public-api/visuals/image-visual-properties.h b/dali-toolkit/public-api/visuals/image-visual-properties.h index c1b0bfa..fd08176 100644 --- a/dali-toolkit/public-api/visuals/image-visual-properties.h +++ b/dali-toolkit/public-api/visuals/image-visual-properties.h @@ -105,15 +105,6 @@ enum BORDER_ONLY, /** - * @brief This enables Image visuals to automatically be converted to Batch-Image visuals. - * @details Name "batchingEnabled", type Property::BOOLEAN. - * @SINCE_1_2.0 - * @note Optional. If not specified, the default is false. - * @note For Image visuals only. Not to be used with NPatch or SVG images. - */ - BATCHING_ENABLED, - - /** * @brief The image area to be displayed. * @details Name "pixelArea", type Property::VECTOR4. * It is a rectangular area. -- 2.7.4