X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-factory-impl.cpp;h=365c6149a82fa8782247791ffc2291ec9d1150bc;hp=2410f0aa58ddc3d7a6e2327810915da16d7d2afd;hb=ca4209fb071e5c353a7e528098a2e497765118d8;hpb=8baeadfe23cbb78ccc879aec3350edde7bf8424a diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.cpp b/dali-toolkit/internal/visuals/visual-factory-impl.cpp index 2410f0a..365c614 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -27,12 +27,11 @@ // INTERNAL INCLUDES #include -#include -#include +#include +#include #include #include #include -#include #include #include #include @@ -42,7 +41,7 @@ #include #include #include -#include +#include #include namespace Dali @@ -57,7 +56,6 @@ namespace Internal namespace { -const char * const BATCHING_ENABLED( "batchingEnabled" ); BaseHandle Create() { BaseHandle handle = Toolkit::VisualFactory::Get(); @@ -89,8 +87,8 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property Visual::BasePtr visualPtr; - Property::Value* typeValue = propertyMap.Find( Toolkit::DevelVisual::Property::TYPE, VISUAL_TYPE ); - Toolkit::DevelVisual::Type visualType = Toolkit::DevelVisual::IMAGE; // Default to IMAGE type. + Property::Value* typeValue = propertyMap.Find( Toolkit::Visual::Property::TYPE, VISUAL_TYPE ); + Toolkit::Visual::Type visualType = Toolkit::Visual::IMAGE; // Default to IMAGE type. if( typeValue ) { Scripting::GetEnumerationProperty( *typeValue, VISUAL_TYPE_TABLE, VISUAL_TYPE_TABLE_COUNT, visualType ); @@ -120,42 +118,45 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property { Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); std::string imageUrl; - if( imageURLValue && imageURLValue->Get( imageUrl ) ) + if( imageURLValue ) { - // first resolve url type to know which visual to create - UrlType::Type type = ResolveUrlType( imageUrl ); - if( UrlType::N_PATCH == type ) - { - visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); - } - else if( UrlType::SVG == type ) - { - visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); - } - else if( UrlType::GIF == type ) + if( imageURLValue->Get( imageUrl ) ) { - visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); - } - else // Regular image - { - bool batchingEnabled( false ); - Property::Value* batchingEnabledValue = propertyMap.Find( Toolkit::ImageVisual::Property::BATCHING_ENABLED, BATCHING_ENABLED ); - if( batchingEnabledValue ) - { - batchingEnabledValue->Get( batchingEnabled ); - } + VisualUrl visualUrl( imageUrl ); - if( batchingEnabled ) + switch( visualUrl.GetType() ) { - visualPtr = BatchImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); + case VisualUrl::N_PATCH: + { + visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), visualUrl, propertyMap ); + break; + } + case VisualUrl::SVG: + { + visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), visualUrl, propertyMap ); + break; + } + case VisualUrl::GIF: + { + visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), visualUrl, propertyMap ); + break; + } + case VisualUrl::REGULAR_IMAGE: + { + visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), visualUrl, propertyMap ); + break; + } } - else + } + else + { + Property::Array* array = imageURLValue->GetArray(); + if( array ) { - visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); + visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), *array, propertyMap ); } } } - break; } @@ -177,11 +178,55 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property break; } - case Toolkit::DevelVisual::TEXT: + case Toolkit::Visual::TEXT: { visualPtr = TextVisual::New( *( mFactoryCache.Get() ), propertyMap ); break; } + + case Toolkit::Visual::N_PATCH: + { + Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); + std::string imageUrl; + if( imageURLValue && imageURLValue->Get( imageUrl ) ) + { + visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); + } + break; + } + + case Toolkit::Visual::SVG: + { + Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); + std::string imageUrl; + if( imageURLValue && imageURLValue->Get( imageUrl ) ) + { + visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); + } + break; + } + + case Toolkit::Visual::ANIMATED_IMAGE: + { + Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); + std::string imageUrl; + if( imageURLValue ) + { + if( imageURLValue->Get( imageUrl ) ) + { + visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); + } + else + { + Property::Array* array = imageURLValue->GetArray(); + if( array ) + { + visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), *array, propertyMap ); + } + } + } + break; + } } if( !visualPtr ) @@ -189,7 +234,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property DALI_LOG_ERROR( "Renderer type unknown\n" ); } - if( mDebugEnabled && visualType != Toolkit::DevelVisual::WIREFRAME ) + if( mDebugEnabled && visualType != Toolkit::Visual::WIREFRAME ) { //Create a WireframeVisual if we have debug enabled visualPtr = WireframeVisual::New( *( mFactoryCache.Get() ), visualPtr, propertyMap ); @@ -236,22 +281,29 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const std::string& url, Image Visual::BasePtr visualPtr; // first resolve url type to know which visual to create - UrlType::Type type = ResolveUrlType( url ); - if( UrlType::N_PATCH == type ) - { - visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), url ); - } - else if( UrlType::SVG == type ) - { - visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), url ); - } - else if( UrlType::GIF == type ) + VisualUrl visualUrl( url ); + switch( visualUrl.GetType() ) { - visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), url ); - } - else // Regular image - { - visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), url, size ); + case VisualUrl::N_PATCH: + { + visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), visualUrl ); + break; + } + case VisualUrl::SVG: + { + visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), visualUrl ); + break; + } + case VisualUrl::GIF: + { + visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), visualUrl ); + break; + } + case VisualUrl::REGULAR_IMAGE: + { + visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), visualUrl, size ); + break; + } } if( mDebugEnabled ) @@ -263,6 +315,15 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const std::string& url, Image return Toolkit::Visual::Base( visualPtr.Get() ); } +Internal::TextureManager& VisualFactory::GetTextureManager() +{ + if( !mFactoryCache ) + { + mFactoryCache = new VisualFactoryCache(); + } + return mFactoryCache->GetTextureManager(); +} + } // namespace Internal } // namespace Toolkit