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=57290a10848fc80a4bdf667e4116b39d56cceb57;hp=4220b00a35794e16856ba45667ea9ebc3d8a7c76;hb=c93f6281a8bafc5b7ba5f0dcdad0eb675b8e3436;hpb=3c90f2e19f0526a936f5664dc446addbaa25ade8 diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.cpp b/dali-toolkit/internal/visuals/visual-factory-impl.cpp index 4220b00..57290a1 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) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -77,6 +78,7 @@ const char* const BROKEN_IMAGE_FILE_NAME = "broken.png"; ///< The file name of t VisualFactory::VisualFactory(bool debugEnabled) : mFactoryCache(), mImageVisualShaderFactory(), + mTextVisualShaderFactory(), mSlotDelegate(this), mDebugEnabled(debugEnabled), mPreMultiplyOnLoad(true) @@ -178,7 +180,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual(const Property::Map& propertyM else { Property::Array* array = imageURLValue->GetArray(); - if(array) + if(array && array->Count() > 0) { visualPtr = AnimatedImageVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), *array, propertyMap); } @@ -207,7 +209,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual(const Property::Map& propertyM case Toolkit::Visual::TEXT: { - visualPtr = TextVisual::New(GetFactoryCache(), propertyMap); + visualPtr = TextVisual::New(GetFactoryCache(), GetTextVisualShaderFactory(), propertyMap); break; } @@ -217,7 +219,10 @@ Toolkit::Visual::Base VisualFactory::CreateVisual(const Property::Map& propertyM std::string imageUrl; if(imageURLValue && imageURLValue->Get(imageUrl)) { - visualPtr = NPatchVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), imageUrl, propertyMap); + if(!imageUrl.empty()) + { + visualPtr = NPatchVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), imageUrl, propertyMap); + } } break; } @@ -228,7 +233,10 @@ Toolkit::Visual::Base VisualFactory::CreateVisual(const Property::Map& propertyM std::string imageUrl; if(imageURLValue && imageURLValue->Get(imageUrl)) { - visualPtr = SvgVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), imageUrl, propertyMap); + if(!imageUrl.empty()) + { + visualPtr = SvgVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), imageUrl, propertyMap); + } } break; } @@ -241,12 +249,15 @@ Toolkit::Visual::Base VisualFactory::CreateVisual(const Property::Map& propertyM { if(imageURLValue->Get(imageUrl)) { - visualPtr = AnimatedImageVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), imageUrl, propertyMap); + if(!imageUrl.empty()) + { + visualPtr = AnimatedImageVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), imageUrl, propertyMap); + } } else { Property::Array* array = imageURLValue->GetArray(); - if(array) + if(array && array->Count() > 0) { visualPtr = AnimatedImageVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), *array, propertyMap); } @@ -267,7 +278,10 @@ Toolkit::Visual::Base VisualFactory::CreateVisual(const Property::Map& propertyM std::string imageUrl; if(imageURLValue && imageURLValue->Get(imageUrl)) { - visualPtr = AnimatedVectorImageVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), imageUrl, propertyMap); + if(!imageUrl.empty()) + { + visualPtr = AnimatedVectorImageVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), imageUrl, propertyMap); + } } break; } @@ -370,15 +384,19 @@ Internal::TextureManager& VisualFactory::GetTextureManager() void VisualFactory::SetBrokenImageUrl(Toolkit::StyleManager& styleManager) { - const std::string imageDirPath = AssetManager::GetDaliImagePath(); - std::string brokenImageUrl = imageDirPath + BROKEN_IMAGE_FILE_NAME; + const std::string imageDirPath = AssetManager::GetDaliImagePath(); + std::string brokenImageUrl = imageDirPath + BROKEN_IMAGE_FILE_NAME; std::vector customBrokenImageUrlList; if(styleManager) { - customBrokenImageUrlList = Toolkit::DevelStyleManager::GetBrokenImageUrlList(styleManager); - Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager); - config["brokenImageUrl"].Get(brokenImageUrl); + customBrokenImageUrlList = Toolkit::DevelStyleManager::GetBrokenImageUrlList(styleManager); + const Property::Map& config = Toolkit::DevelStyleManager::GetConfigurations(styleManager); + const auto brokenImageUrlValue = config.Find("brokenImageUrl", Property::Type::STRING); + if(brokenImageUrlValue) + { + brokenImageUrlValue->Get(brokenImageUrl); + } } // Add default image @@ -389,7 +407,7 @@ Internal::VisualFactoryCache& VisualFactory::GetFactoryCache() { if(!mFactoryCache) { - mFactoryCache = std::unique_ptr(new VisualFactoryCache(mPreMultiplyOnLoad)); + mFactoryCache = std::unique_ptr(new VisualFactoryCache(mPreMultiplyOnLoad)); Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get(); if(styleManager) { @@ -410,6 +428,15 @@ ImageVisualShaderFactory& VisualFactory::GetImageVisualShaderFactory() return *mImageVisualShaderFactory; } +TextVisualShaderFactory& VisualFactory::GetTextVisualShaderFactory() +{ + if(!mTextVisualShaderFactory) + { + mTextVisualShaderFactory = std::unique_ptr(new TextVisualShaderFactory()); + } + return *mTextVisualShaderFactory; +} + } // namespace Internal } // namespace Toolkit