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=c368580ae44e9652759353e81bfebb101258e39f;hp=8a5d24554913e9379874ebe1ee102918d7639cb8;hb=339af74b081016140d2d5e25dc8609913aabaa31;hpb=ddef399f249128bef52cbb79eb321b0bfdaa0ced diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.cpp b/dali-toolkit/internal/visuals/visual-factory-impl.cpp index 8a5d245..c368580 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. @@ -26,13 +26,14 @@ #include // INTERNAL INCLUDES -#include -#include -#include #include +#include +#include +#include #include #include #include +#include #include #include #include @@ -88,7 +89,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property Visual::BasePtr visualPtr; - Property::Value* typeValue = propertyMap.Find( Toolkit::DevelVisual::Property::TYPE, VISUAL_TYPE ); + Property::Value* typeValue = propertyMap.Find( Toolkit::Visual::Property::TYPE, VISUAL_TYPE ); Toolkit::DevelVisual::Type visualType = Toolkit::DevelVisual::IMAGE; // Default to IMAGE type. if( typeValue ) { @@ -119,31 +120,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 ) { - VisualUrl visualUrl( imageUrl ); - - switch( visualUrl.GetType() ) + if( imageURLValue->Get( imageUrl ) ) { - case VisualUrl::N_PATCH: + if( !imageUrl.empty() ) { - visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), visualUrl, propertyMap ); - break; + VisualUrl visualUrl( imageUrl ); + + switch( visualUrl.GetType() ) + { + 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; + } + } } - 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: + } + else + { + Property::Array* array = imageURLValue->GetArray(); + if( array ) { - visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), visualUrl, propertyMap ); - break; + visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), *array, propertyMap ); } } } @@ -168,13 +183,13 @@ 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::DevelVisual::N_PATCH: + case Toolkit::Visual::N_PATCH: { Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); std::string imageUrl; @@ -185,7 +200,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property break; } - case Toolkit::DevelVisual::SVG: + case Toolkit::Visual::SVG: { Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); std::string imageUrl; @@ -196,16 +211,33 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property break; } - case Toolkit::DevelVisual::ANIMATED_IMAGE: + case Toolkit::Visual::ANIMATED_IMAGE: { Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); std::string imageUrl; - if( imageURLValue && imageURLValue->Get( imageUrl ) ) + if( imageURLValue ) { - visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), imageUrl, propertyMap ); + 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; } + + case Toolkit::DevelVisual::ANIMATED_GRADIENT: + { + visualPtr = AnimatedGradientVisual::New( *( mFactoryCache.Get() ), propertyMap ); + break; + } } if( !visualPtr ) @@ -231,14 +263,17 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Image& image ) Visual::BasePtr visualPtr; - NinePatchImage npatchImage = NinePatchImage::DownCast( image ); - if( npatchImage ) - { - visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), npatchImage ); - } - else + if( image ) { - visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), image ); + NinePatchImage npatchImage = NinePatchImage::DownCast( image ); + if( npatchImage ) + { + visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), npatchImage ); + } + else + { + visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), image ); + } } if( mDebugEnabled ) @@ -259,29 +294,32 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const std::string& url, Image Visual::BasePtr visualPtr; - // first resolve url type to know which visual to create - VisualUrl visualUrl( url ); - switch( visualUrl.GetType() ) + if( !url.empty() ) { - case VisualUrl::N_PATCH: - { - visualPtr = NPatchVisual::New( *( mFactoryCache.Get() ), visualUrl ); - break; - } - case VisualUrl::SVG: - { - visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), visualUrl ); - break; - } - case VisualUrl::GIF: + // first resolve url type to know which visual to create + VisualUrl visualUrl( url ); + switch( visualUrl.GetType() ) { - visualPtr = AnimatedImageVisual::New( *( mFactoryCache.Get() ), visualUrl ); - break; - } - case VisualUrl::REGULAR_IMAGE: - { - visualPtr = ImageVisual::New( *( mFactoryCache.Get() ), visualUrl, size ); - break; + 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; + } } } @@ -294,6 +332,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