From: adam.b Date: Thu, 4 Aug 2016 13:46:21 +0000 (+0100) Subject: Batching clean-up X-Git-Tag: dali_1.2.0~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=afe38927f068846eaa02c374430da05f6209a6f9 Batching clean-up BatchImageVisual has been made more like Svg/NpatchVisual. It's "less" public now. Change-Id: I7c57768db634e1859d4752f3745ce905a8a99cfd --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index ef801bb..ef9dab8 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -190,8 +190,9 @@ int UtcDaliVisualSize(void) // Batch Image visual propertyMap.Clear(); - propertyMap.Insert( Visual::Property::TYPE, Visual::BATCH_IMAGE ); - propertyMap.Insert( BatchImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true ); Visual::Base batchImageVisual = factory.CreateVisual( propertyMap ); batchImageVisual.SetSize( visualSize ); DALI_TEST_EQUALS( batchImageVisual.GetSize(), visualSize, TEST_LOCATION ); @@ -796,10 +797,11 @@ int UtcDaliVisualGetPropertyMapBatchImageVisual(void) VisualFactory factory = VisualFactory::Get(); Property::Map propertyMap; - propertyMap.Insert( Visual::Property::TYPE, Visual::BATCH_IMAGE ); - propertyMap.Insert( BatchImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); - propertyMap.Insert( BatchImageVisual::Property::DESIRED_WIDTH, 20 ); - propertyMap.Insert( BatchImageVisual::Property::DESIRED_HEIGHT, 30 ); + 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 ); @@ -810,17 +812,17 @@ int UtcDaliVisualGetPropertyMapBatchImageVisual(void) // 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::BATCH_IMAGE ); + DALI_TEST_CHECK( value->Get() == Visual::IMAGE ); - value = resultMap.Find( BatchImageVisual::Property::URL, Property::STRING ); + value = resultMap.Find( ImageVisual::Property::URL, Property::STRING ); DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == TEST_IMAGE_FILE_NAME ); - value = resultMap.Find( BatchImageVisual::Property::DESIRED_WIDTH, Property::INTEGER ); + value = resultMap.Find( ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER ); DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == 20 ); - value = resultMap.Find( BatchImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER ); + value = resultMap.Find( ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER ); DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == 30 ); @@ -834,12 +836,13 @@ int UtcDaliVisualGetPropertyMapBatchImageVisualNoAtlas(void) VisualFactory factory = VisualFactory::Get(); Property::Map propertyMap; - propertyMap.Insert( Visual::Property::TYPE, Visual::BATCH_IMAGE ); - propertyMap.Insert( BatchImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + 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( BatchImageVisual::Property::DESIRED_WIDTH, 2048 ); - propertyMap.Insert( BatchImageVisual::Property::DESIRED_HEIGHT, 2048 ); + propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 2048 ); + propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 2048 ); // Create the visual. Visual::Base batchImageVisual = factory.CreateVisual( propertyMap ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp index 4a32341..76d6aac 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp @@ -1521,8 +1521,9 @@ int UtcDaliVisualFactoryGetBatchImageVisual1(void) DALI_TEST_CHECK( factory ); Property::Map propertyMap; - propertyMap.Insert( Visual::Property::TYPE, Visual::BATCH_IMAGE ); - propertyMap.Insert( BatchImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + 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 ); @@ -1559,10 +1560,10 @@ int UtcDaliVisualFactoryGetBatchImageVisual2(void) // 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( Visual::Property::BATCHING_ENABLED, true ); + propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true ); // Properties for the Batch-Image Visual. - propertyMap.Insert( BatchImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); Visual::Base visual = factory.CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); @@ -1573,7 +1574,7 @@ int UtcDaliVisualFactoryGetBatchImageVisual2(void) Property::Value* value = resultMap.Find( Visual::Property::TYPE, Property::INTEGER ); DALI_TEST_CHECK( value ); - DALI_TEST_EQUALS( value->Get(), (int)Visual::BATCH_IMAGE, TEST_LOCATION ); + DALI_TEST_EQUALS( value->Get(), (int)Visual::IMAGE, TEST_LOCATION ); Actor actor = Actor::New(); @@ -1605,8 +1606,8 @@ int UtcDaliVisualFactoryGetBatchImageVisual3(void) // Create a property-map that enables batching. Property::Map propertyMap; - propertyMap.Insert( Dali::Toolkit::BatchImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); - propertyMap.Insert( Visual::Property::BATCHING_ENABLED, true ); + propertyMap.Insert( Dali::Toolkit::ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true ); // Create an ImageView, passing the property-map in to instruct it to use batching. Toolkit::ImageView imageView = Toolkit::ImageView::New(); diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h index 4c641ae..2c5fe2a 100644 --- a/dali-toolkit/dali-toolkit.h +++ b/dali-toolkit/dali-toolkit.h @@ -61,7 +61,6 @@ #include -#include #include #include #include diff --git a/dali-toolkit/internal/visuals/image/batch-image-visual.cpp b/dali-toolkit/internal/visuals/image/batch-image-visual.cpp index 8eca47e..12bfdad 100644 --- a/dali-toolkit/internal/visuals/image/batch-image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/batch-image-visual.cpp @@ -31,7 +31,6 @@ #include // INTERNAL HEADER -#include #include #include #include @@ -103,21 +102,21 @@ BatchImageVisual::~BatchImageVisual() void BatchImageVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap ) { std::string oldImageUrl = mImageUrl; - Property::Value* imageURLValue = propertyMap.Find( Dali::Toolkit::BatchImageVisual::Property::URL, Dali::Toolkit::Internal::IMAGE_URL_NAME ); + Property::Value* imageURLValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::URL, Dali::Toolkit::Internal::IMAGE_URL_NAME ); if( imageURLValue ) { imageURLValue->Get( mImageUrl ); int desiredWidth = 0; - Property::Value* desiredWidthValue = propertyMap.Find( Dali::Toolkit::BatchImageVisual::Property::DESIRED_WIDTH, DESIRED_WIDTH ); + Property::Value* desiredWidthValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH, DESIRED_WIDTH ); if( desiredWidthValue ) { desiredWidthValue->Get( desiredWidth ); } int desiredHeight = 0; - Property::Value* desiredHeightValue = propertyMap.Find( Dali::Toolkit::BatchImageVisual::Property::DESIRED_HEIGHT, DESIRED_HEIGHT ); + Property::Value* desiredHeightValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT, DESIRED_HEIGHT ); if( desiredHeightValue ) { desiredHeightValue->Get( desiredHeight ); @@ -254,13 +253,14 @@ void BatchImageVisual::DoSetOffStage( Actor& actor ) void BatchImageVisual::DoCreatePropertyMap( Property::Map& map ) const { map.Clear(); - map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::BATCH_IMAGE ); + map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE ); if( !mImageUrl.empty() ) { - map.Insert( Toolkit::BatchImageVisual::Property::URL, mImageUrl ); - map.Insert( Toolkit::BatchImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth() ); - map.Insert( Toolkit::BatchImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight() ); + 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() ); } } diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index e7ad66e..9125acd 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -58,6 +58,7 @@ 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/visual-factory-impl.cpp b/dali-toolkit/internal/visuals/visual-factory-impl.cpp index f4677a7..530feb9 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-impl.cpp @@ -68,12 +68,10 @@ DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, IMAGE ) DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, MESH ) DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, PRIMITIVE ) DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, DEBUG ) -DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, BATCH_IMAGE ) DALI_ENUM_TO_STRING_TABLE_END( VISUAL_TYPE ) const char * const VISUAL_TYPE( "visualType" ); const char * const BATCHING_ENABLED( "batchingEnabled" ); - BaseHandle Create() { BaseHandle handle = Toolkit::VisualFactory::Get(); @@ -118,21 +116,6 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property Scripting::GetEnumerationProperty( *typeValue, VISUAL_TYPE_TABLE, VISUAL_TYPE_TABLE_COUNT, visualType ); } - // If the type is IMAGE, either from a default or the TYPE value in the property-map, change it to a BatchImage if required. - if( visualType == Toolkit::Visual::IMAGE ) - { - bool batchingEnabled( false ); - Property::Value* value = propertyMap.Find( Toolkit::Visual::Property::BATCHING_ENABLED, BATCHING_ENABLED ); - if( value ) - { - value->Get( batchingEnabled ); - if( batchingEnabled ) - { - visualType = Toolkit::Visual::BATCH_IMAGE; - } - } - } - switch( visualType ) { case Toolkit::Visual::BORDER: @@ -160,7 +143,19 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property std::string imageUrl; if( imageURLValue && imageURLValue->Get( imageUrl ) ) { - if( NinePatchImage::IsNinePatchUrl( imageUrl ) ) + Property::Value* batchingEnabledValue = propertyMap.Find( Toolkit::ImageVisual::Property::BATCHING_ENABLED, BATCHING_ENABLED ); + if( batchingEnabledValue ) + { + bool batchingEnabled( false ); + batchingEnabledValue->Get( batchingEnabled ); + if( batchingEnabled ) + { + CreateAtlasManager(); + visualPtr = new BatchImageVisual( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) ); + break; + } + } + else if( NinePatchImage::IsNinePatchUrl( imageUrl ) ) { visualPtr = new NPatchVisual( *( mFactoryCache.Get() ) ); } @@ -206,12 +201,6 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property break; } - case Toolkit::Visual::BATCH_IMAGE: - { - CreateAtlasManager(); - visualPtr = new BatchImageVisual( *( mFactoryCache.Get() ), *( mAtlasManager.Get() ) ); - break; - } } if( visualPtr ) diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list index 205dca8..7eb3cfc 100755 --- a/dali-toolkit/public-api/file.list +++ b/dali-toolkit/public-api/file.list @@ -124,7 +124,6 @@ public_api_video_view_header_files = \ $(public_api_src_dir)/controls/video-view/video-view.h public_api_visuals_header_files = \ - $(public_api_src_dir)/visuals/batch-image-visual-properties.h \ $(public_api_src_dir)/visuals/border-visual-properties.h \ $(public_api_src_dir)/visuals/color-visual-properties.h \ $(public_api_src_dir)/visuals/gradient-visual-properties.h \ diff --git a/dali-toolkit/public-api/visuals/batch-image-visual-properties.h b/dali-toolkit/public-api/visuals/batch-image-visual-properties.h deleted file mode 100644 index 25def11..0000000 --- a/dali-toolkit/public-api/visuals/batch-image-visual-properties.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef DALI_TOOLKIT_BATCH_IMAGE_VISUAL_PROPERTIES_H -#define DALI_TOOLKIT_BATCH_IMAGE_VISUAL_PROPERTIES_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. - * - */ - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Toolkit -{ - -namespace BatchImageVisual -{ - -namespace Property -{ - -enum -{ - /** - * @brief The URL of the image. - * @details Name "url", type Property::STRING. - * @SINCE_1_1.46 - * @note Mandatory. - */ - URL = VISUAL_PROPERTY_START_INDEX, - - /** - * @brief The image width. - * @details Name "desiredWidth", type Property::INTEGER. - * @SINCE_1_1.46 - * @note Optional. If not specified, the actual image width is used. - */ - DESIRED_WIDTH, - - /** - * @brief The image height. - * @details Name "desiredHeight", type Property::INTEGER. - * @SINCE_1_1.46 - * @note Optional. If not specified, the actual image height is used. - */ - DESIRED_HEIGHT, -}; - -} // namespace Property - -} // namespace BatchImageVisual - -} // namespace Toolkit - -} // namespace Dali - -#endif // DALI_TOOLKIT_BATCH_IMAGE_VISUAL_PROPERTIES_H diff --git a/dali-toolkit/public-api/visuals/image-visual-properties.h b/dali-toolkit/public-api/visuals/image-visual-properties.h index 619a8f1..b008dad 100644 --- a/dali-toolkit/public-api/visuals/image-visual-properties.h +++ b/dali-toolkit/public-api/visuals/image-visual-properties.h @@ -98,6 +98,14 @@ enum * @note For N-Patch images only. */ BORDER_ONLY, + + /** + * @brief This enables Image visuals to automatically be converted to Batch-Image visuals. + * @details Name "batchingEnabled", type Property::BOOLEAN. + * @SINCE_1_1.46 + * @note Optional. For Image visuals only. Not to be used with NPatch or SVG images. + */ + BATCHING_ENABLED, }; } // namespace Property diff --git a/dali-toolkit/public-api/visuals/visual-properties.h b/dali-toolkit/public-api/visuals/visual-properties.h index f8d4b70..4c1ff57 100644 --- a/dali-toolkit/public-api/visuals/visual-properties.h +++ b/dali-toolkit/public-api/visuals/visual-properties.h @@ -43,7 +43,6 @@ enum Type MESH, ///< Renders a mesh using an "obj" file, optionally with textures provided by an "mtl" file. @SINCE_1_1.45 PRIMITIVE, ///< Renders a simple 3D shape, such as a cube or sphere. @SINCE_1_1.45 DEBUG, ///< Renders a simple wire-frame outlining a quad. @SINCE_1_1.45 - BATCH_IMAGE, ///< Renders an image in the geometry batching mode @SINCE_1_1.46 }; namespace Property @@ -69,14 +68,6 @@ enum * @see Shader::Property */ SHADER, - - /** - * @brief This enables Image visuals to automatically be converted to Batch-Image visuals. - * @details Name "batchingEnabled", type Boolean. - * @SINCE_1_1.46 - * @note Optional. - */ - BATCHING_ENABLED, }; } // namespace Property