Merge "Remove @ref tag in front of namespace" into devel/master
authorDavid Steele <david.steele@samsung.com>
Fri, 20 Apr 2018 15:10:53 +0000 (15:10 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Fri, 20 Apr 2018 15:10:53 +0000 (15:10 +0000)
17 files changed:
automated-tests/src/dali-toolkit-styling/default-theme.json
automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp
dali-toolkit/internal/builder/builder-impl.cpp
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/npatch/npatch-visual.cpp
dali-toolkit/internal/visuals/texture-manager-impl.cpp
dali-toolkit/internal/visuals/texture-manager-impl.h
dali-toolkit/internal/visuals/visual-factory-cache.cpp
dali-toolkit/internal/visuals/visual-factory-cache.h
dali-toolkit/internal/visuals/visual-factory-impl.cpp
dali-toolkit/internal/visuals/visual-factory-impl.h
dali-toolkit/public-api/dali-toolkit-version.cpp
dali-toolkit/styles/1920x1080/dali-toolkit-default-theme.json
dali-toolkit/styles/480x800/dali-toolkit-default-theme.json
dali-toolkit/styles/720x1280/dali-toolkit-default-theme.json
packaging/dali-toolkit.spec

index 30edbfd..7630242 100644 (file)
@@ -2,7 +2,8 @@
   "config":
   {
     "alwaysShowFocus":false,
-    "clearFocusOnEscape":true
+    "clearFocusOnEscape":true,
+    "brokenImageUrl":"{DALI_IMAGE_DIR}broken.png"
   },
   "constants":
   {
index 07d657f..5ec1f9f 100644 (file)
@@ -238,6 +238,12 @@ int UtcDaliStyleManagerApplyTheme(void)
 
   styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
 
+  // To ensure we make VisualFactory
+  VisualFactory factory = VisualFactory::Get();
+  Property::Map propertyMap;
+  propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
+  Visual::Base textVisual = factory.CreateVisual( propertyMap );
+
   // Render and notify
   application.SendNotification();
   application.Render();
@@ -1306,8 +1312,13 @@ int UtcDaliStyleManagerConfigSectionTest(void)
 
   const char* defaultTheme =
     "{\n"
+    "  \"constants\":\n"
+    "  {\n"
+    "    \"TEST\":\"broken\"\n"
+    "  },\n"
     "  \"config\":\n"
     "  {\n"
+    "    \"brokenImageUrl\":\"{TEST}|{TEST}|{TEST|TEST.png\",\n"
     "    \"alwaysShowFocus\":false,\n"
     "    \"clearFocusOnEscape\":false\n"
     "  },\n"
@@ -1327,6 +1338,8 @@ int UtcDaliStyleManagerConfigSectionTest(void)
   DALI_TEST_CHECK( !alwaysShowFocus );
   bool clearFocusOnEscape = config["clearFocusOnEscape"].Get<bool>();
   DALI_TEST_CHECK( !clearFocusOnEscape );
+  std::string brokenImageUrl = config["brokenImageUrl"].Get<std::string>();
+  DALI_TEST_CHECK( brokenImageUrl.compare( "broken|broken|{TEST|TEST.png" ) == 0 );
 
   // For coverage
   Toolkit::TextEditor editor = Toolkit::TextEditor::New();
index c17872b..a15a793 100644 (file)
 namespace
 {
 const char* DEFAULT_THEME=
-  "{\"styles\":{\n"
+  "{\n"
+  "  \"config\":\n"
+  "  {\n"
+  "    \"brokenImageUrl\":\"{DALI_IMAGE_DIR}broken.png\"\n"
+  "  },\n"
+  "  \"styles\":\n"
+  "  {\n"
   "  \"textlabel\":\n"
   "    {\n"
   "      \"fontStyle\":{\"weight\":\"normal\"},\n"
index 7f1b441..e5da81e 100644 (file)
@@ -179,10 +179,10 @@ void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::U
   }
   else
   {
-    // load configuration map
-    LoadConfiguration( *parser.GetRoot(), mConfigurationMap );
     // load constant map (allows the user to override the constants in the json after loading)
     LoadConstants( *parser.GetRoot(), mReplacementMap );
+    // load configuration map
+    LoadConfiguration( *parser.GetRoot(), mConfigurationMap );
     // merge includes
     if( OptionalChild includes = IsChild(*parser.GetRoot(), KEYNAME_INCLUDES) )
     {
@@ -797,6 +797,61 @@ void Builder::LoadConfiguration( const TreeNode& root, Property::Map& intoMap )
       if( (*iter).second.GetName() )
       {
         DeterminePropertyFromNode( (*iter).second, property, replacer );
+
+        // If config is string, find constant and replace it to original value.
+        if( (*iter).second.GetType() == TreeNode::STRING )
+        {
+          std::string stringConfigValue;
+          if( property.Get( stringConfigValue ) )
+          {
+            std::size_t pos = 0;
+
+            while( pos < stringConfigValue.size() )
+            {
+              // If we can't find "{","}" pair in stringConfigValue, will out loop.
+              std::size_t leftPos = stringConfigValue.find( "{", pos );
+              if( leftPos != std::string::npos )
+              {
+                std::size_t rightPos = stringConfigValue.find( "}", pos+1 );
+
+                if( rightPos != std::string::npos )
+                {
+                  // If we find "{","}" pair but can't find matched constant
+                  // try to find other "{","}" pair after current left position.
+                  pos = leftPos+1;
+
+                  for( unsigned int i = 0; i < mReplacementMap.Count() ; i++ )
+                  {
+                    std::string constant = mReplacementMap.GetKey(i);
+
+                    // Compare string which is between "{" and "}" with constant string
+                    // If they are same, change string in stringConfigValue to mapped constant value.
+                    if ( stringConfigValue.compare( leftPos+1, rightPos-leftPos-1,constant) == 0 )
+                    {
+                      std::string replaceString;
+                      mReplacementMap.GetValue(i).Get( replaceString );
+
+                      stringConfigValue.replace( leftPos, rightPos-leftPos+1, replaceString );
+                      pos = leftPos + replaceString.size();
+                      break;
+                    }
+                  }
+                }
+                else
+                {
+                  // If we cannot find constant in const value, will out loop.
+                  pos = stringConfigValue.size();
+                }
+              }
+              else
+              {
+                // If we cannot find constant in const value, will out loop.
+                pos = stringConfigValue.size();
+              }
+            }
+            property = Property::Value( stringConfigValue );
+          }
+        }
         intoMap[ (*iter).second.GetName() ] = property;
       }
     }
index 6aaa271..0e4f018 100644 (file)
@@ -623,7 +623,7 @@ void ImageVisual::GetNaturalSize( Vector2& naturalSize )
       }
       else
       {
-        Image brokenImage = VisualFactoryCache::GetBrokenVisualImage();
+        Image brokenImage = mFactoryCache.GetBrokenVisualImage();
 
         naturalSize.x = brokenImage.GetWidth();
         naturalSize.y = brokenImage.GetWidth();
@@ -1097,7 +1097,7 @@ void ImageVisual::UploadComplete( bool loadingSuccess, int32_t textureId, Textur
       }
       else
       {
-        Image brokenImage = VisualFactoryCache::GetBrokenVisualImage();
+        Image brokenImage = mFactoryCache.GetBrokenVisualImage();
 
         textureSet = TextureSet::New();
         mImpl->mRenderer.SetTextures( textureSet );
index 971c73d..618c466 100755 (executable)
@@ -584,7 +584,7 @@ void NPatchVisual::ApplyTextureAndUniforms()
     DALI_LOG_ERROR("The N patch image '%s' is not a valid N patch image\n", mImageUrl.GetUrl().c_str() );
     textureSet = TextureSet::New();
 
-    Image croppedImage = VisualFactoryCache::GetBrokenVisualImage();
+    Image croppedImage = mFactoryCache.GetBrokenVisualImage();
     TextureSetImage( textureSet, 0u, croppedImage );
     mImpl->mRenderer.RegisterProperty( "uFixed[0]", Vector2::ZERO );
     mImpl->mRenderer.RegisterProperty( "uFixed[1]", Vector2::ZERO );
index 1ec606c..39e180b 100644 (file)
@@ -83,7 +83,6 @@ Debug::Filter* gTextureManagerLogFilter = Debug::Filter::New( Debug::NoLogging,
 
 const uint32_t      DEFAULT_ATLAS_SIZE( 1024u );                     ///< This size can fit 8 by 8 images of average size 128 * 128
 const Vector4       FULL_ATLAS_RECT( 0.0f, 0.0f, 1.0f, 1.0f );       ///< UV Rectangle that covers the full Texture
-const char * const  BROKEN_IMAGE_URL( DALI_IMAGE_DIR "broken.png" ); ///< URL For the broken image placeholder
 const int           INVALID_INDEX( -1 );                             ///< Invalid index used to represent a non-existant TextureInfo struct
 const int           INVALID_CACHE_INDEX( -1 ); ///< Invalid Cache index
 
@@ -116,6 +115,7 @@ TextureManager::MaskingData::MaskingData()
 TextureManager::TextureManager()
 : mAsyncLocalLoaders( GetNumberOfLocalLoaderThreads(), [&]() { return AsyncLoadingHelper(*this); } ),
   mAsyncRemoteLoaders( GetNumberOfRemoteLoaderThreads(), [&]() { return AsyncLoadingHelper(*this); } ),
+  mBrokenImageUrl(""),
   mCurrentTextureId( 0 )
 {
 }
@@ -176,7 +176,7 @@ TextureSet TextureManager::LoadTexture(
     {
       // use broken image
       textureSet = TextureSet::New();
-      Devel::PixelBuffer pixelBuffer = LoadImageFromFile( BROKEN_IMAGE_URL );
+      Devel::PixelBuffer pixelBuffer = LoadImageFromFile( mBrokenImageUrl );
       if( pixelBuffer )
       {
         PreMultiply( pixelBuffer, preMultiplyOnLoad );
@@ -1065,6 +1065,11 @@ void TextureManager::AsyncLoadingHelper::AsyncLoadComplete(uint32_t           id
   mTextureManager.AsyncLoadComplete(mLoadingInfoContainer, id, pixelBuffer);
 }
 
+void TextureManager::SetBrokenImageUrl(const std::string& brokenImageUrl)
+{
+  mBrokenImageUrl = brokenImageUrl;
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index b8c6ab8..e56fec4 100644 (file)
@@ -355,6 +355,12 @@ public:
    */
   void RemoveObserver( TextureManager::LifecycleObserver& observer );
 
+  /**
+   * @brief Set an image to be used when a visual has failed to correctly render
+   * @param[in] brokenImageUrl The broken image url.
+   */
+  void SetBrokenImageUrl(const std::string& brokenImageUrl);
+
 private:
 
   /**
@@ -737,6 +743,7 @@ private:  // Member Variables:
   RoundRobinContainerView< AsyncLoadingHelper > mAsyncRemoteLoaders;   ///< The Asynchronous image loaders used to provide all remote async loads
   std::vector< ExternalTextureInfo >            mExternalTextures;     ///< Externally provided textures
   Dali::Vector<LifecycleObserver*>              mLifecycleObservers;   ///< Lifecycle observers of texture manager
+  std::string                                   mBrokenImageUrl;       ///< Broken image url
   TextureId                                     mCurrentTextureId;     ///< The current value used for the unique Texture Id generation
 };
 
index 307791b..101e696 100644 (file)
@@ -26,6 +26,7 @@
 #include <dali-toolkit/internal/visuals/svg/svg-visual.h>
 #include <dali-toolkit/internal/visuals/image-atlas-manager.h>
 
+
 namespace
 {
 const char * const BROKEN_VISUAL_IMAGE_URL( DALI_IMAGE_DIR "broken.png");
@@ -42,6 +43,7 @@ namespace Internal
 
 VisualFactoryCache::VisualFactoryCache( bool preMultiplyOnLoad )
 : mSvgRasterizeThread( NULL ),
+  mBrokenImageUrl(""),
   mPreMultiplyOnLoad( preMultiplyOnLoad )
 {
 }
@@ -107,7 +109,7 @@ ImageAtlasManagerPtr VisualFactoryCache::GetAtlasManager()
   if( !mAtlasManager )
   {
     mAtlasManager = new ImageAtlasManager();
-    mAtlasManager->SetBrokenImage( BROKEN_VISUAL_IMAGE_URL );
+    mAtlasManager->SetBrokenImage( mBrokenImageUrl );
   }
 
   return mAtlasManager;
@@ -212,7 +214,7 @@ Geometry VisualFactoryCache::CreateGridGeometry( Uint16Pair gridSize )
 
 Image VisualFactoryCache::GetBrokenVisualImage()
 {
-  return ResourceImage::New( BROKEN_VISUAL_IMAGE_URL );
+  return ResourceImage::New( mBrokenImageUrl );
 }
 
 void VisualFactoryCache::SetPreMultiplyOnLoad( bool preMultiply )
@@ -225,6 +227,19 @@ bool VisualFactoryCache::GetPreMultiplyOnLoad()
   return mPreMultiplyOnLoad;
 }
 
+void VisualFactoryCache::SetBrokenImageUrl(const std::string& brokenImageUrl)
+{
+  mBrokenImageUrl = brokenImageUrl;
+
+  if( !mAtlasManager )
+  {
+    mAtlasManager = new ImageAtlasManager();
+  }
+
+  mAtlasManager->SetBrokenImage( mBrokenImageUrl );
+  mTextureManager.SetBrokenImageUrl( mBrokenImageUrl );
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index bb4744c..a62dfb4 100644 (file)
@@ -161,7 +161,7 @@ public:
    * @brief Returns an image to be used when a visual has failed to correctly render
    * @return The broken image handle.
    */
-  static Image GetBrokenVisualImage();
+  Image GetBrokenVisualImage();
 
   /**
    * @copydoc Toolkit::VisualFactory::SetPreMultiplyOnLoad()
@@ -173,6 +173,12 @@ public:
    */
   bool GetPreMultiplyOnLoad();
 
+  /**
+   * @brief Set an image to be used when a visual has failed to correctly render
+   * @param[in] brokenImageUrl The broken image url.
+   */
+  void SetBrokenImageUrl(const std::string& brokenImageUrl);
+
 public:
   /**
    * Get the image atlas manager.
@@ -225,6 +231,7 @@ private:
   TextureManager       mTextureManager;
   NPatchLoader         mNPatchLoader;
   SvgRasterizeThread*  mSvgRasterizeThread;
+  std::string          mBrokenImageUrl;
   bool                 mPreMultiplyOnLoad;
 };
 
index 4803e07..e762b3e 100644 (file)
@@ -67,11 +67,13 @@ BaseHandle Create()
 
 DALI_TYPE_REGISTRATION_BEGIN_CREATE( Toolkit::VisualFactory, Dali::BaseHandle, Create, true )
 DALI_TYPE_REGISTRATION_END()
+const char * const  BROKEN_IMAGE_URL( DALI_IMAGE_DIR "broken.png" ); ///< URL For the broken image
 
 } // namespace
 
 VisualFactory::VisualFactory( bool debugEnabled )
 : mFactoryCache(),
+  mSlotDelegate(this),
   mDebugEnabled( debugEnabled ),
   mPreMultiplyOnLoad( true )
 {
@@ -81,6 +83,22 @@ VisualFactory::~VisualFactory()
 {
 }
 
+void VisualFactory::OnStyleChangedSignal( Toolkit::StyleManager styleManager, StyleChange::Type type)
+{
+  if( type == StyleChange::THEME_CHANGE )
+  {
+    std::string brokenImageUrl(BROKEN_IMAGE_URL);
+
+    Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager );
+    config["brokenImageUrl"].Get( brokenImageUrl );
+
+    if( mFactoryCache )
+    {
+      mFactoryCache->SetBrokenImageUrl(brokenImageUrl);
+    }
+  }
+}
+
 Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& propertyMap )
 {
   Visual::BasePtr visualPtr;
@@ -342,6 +360,17 @@ Internal::VisualFactoryCache& VisualFactory::GetFactoryCache()
   if( !mFactoryCache )
   {
     mFactoryCache = std::unique_ptr<VisualFactoryCache>( new VisualFactoryCache( mPreMultiplyOnLoad ) );
+
+    std::string brokenImageUrl(BROKEN_IMAGE_URL);
+    Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+    if( styleManager )
+    {
+      Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager );
+      config["brokenImageUrl"].Get( brokenImageUrl );
+      styleManager.StyleChangedSignal().Connect( mSlotDelegate, &VisualFactory::OnStyleChangedSignal );
+    }
+
+    mFactoryCache->SetBrokenImageUrl(brokenImageUrl);
   }
   return *mFactoryCache;
 }
index 999a0c4..a9a6563 100644 (file)
@@ -24,6 +24,8 @@
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
 
 namespace Dali
 {
@@ -51,6 +53,14 @@ public:
   VisualFactory( bool debugEnabled );
 
   /**
+   * @brief StyleChanged callback
+   *
+   * @param[in] styleManager Handle for style manager.
+   * @param[in] type Style change type.
+   */
+  void OnStyleChangedSignal( Toolkit::StyleManager styleManager, StyleChange::Type type );
+
+  /**
    * @copydoc Toolkit::VisualFactory::CreateVisual( const Property::Map& )
    */
   Toolkit::Visual::Base CreateVisual( const Property::Map& propertyMap );
@@ -99,6 +109,7 @@ private:
 
 private:
   std::unique_ptr<VisualFactoryCache> mFactoryCache;
+  SlotDelegate< VisualFactory >       mSlotDelegate;
   bool                                mDebugEnabled:1;
   bool                                mPreMultiplyOnLoad:1; ///< Local store for this flag
 };
index fb07b2a..78cefb1 100644 (file)
@@ -31,7 +31,7 @@ namespace Toolkit
 
 const unsigned int TOOLKIT_MAJOR_VERSION = 1;
 const unsigned int TOOLKIT_MINOR_VERSION = 3;
-const unsigned int TOOLKIT_MICRO_VERSION = 20;
+const unsigned int TOOLKIT_MICRO_VERSION = 21;
 const char * const TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 50f9529..fa8c6f8 100644 (file)
@@ -28,6 +28,7 @@
 {
   "config":
   {
+    "brokenImageUrl":"{DALI_IMAGE_DIR}broken.png",
     "alwaysShowFocus":true,
     "clearFocusOnEscape":false
   },
index 460d0f8..f35f988 100644 (file)
@@ -28,6 +28,7 @@
 {
   "config":
   {
+    "brokenImageUrl":"{DALI_IMAGE_DIR}broken.png",
     "alwaysShowFocus":false,
     "clearFocusOnEscape":true
   },
index 9390546..1a9d7ab 100644 (file)
@@ -28,6 +28,7 @@
 {
   "config":
   {
+    "brokenImageUrl":"{DALI_IMAGE_DIR}broken.png",
     "alwaysShowFocus":false,
     "clearFocusOnEscape":true
   },
index 94149ef..186f8e5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-toolkit
 Summary:    Dali 3D engine Toolkit
-Version:    1.3.20
+Version:    1.3.21
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT