From 53eb583fbee4c4a305d6e04b36b16bf173790219 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Thu, 28 Jan 2021 16:22:19 +0000 Subject: [PATCH] (Builder) Added Constants that can be used by Custom shaders Change-Id: I4654fb649a8bd8113219019a501b05fd7a965256 --- dali-toolkit/devel-api/builder/builder.h | 24 ++++++++++++++++++++---- dali-toolkit/internal/builder/builder-impl.cpp | 18 +++++++++++------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/dali-toolkit/devel-api/builder/builder.h b/dali-toolkit/devel-api/builder/builder.h index f10f037..b255c11 100644 --- a/dali-toolkit/devel-api/builder/builder.h +++ b/dali-toolkit/devel-api/builder/builder.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_UIBUILDER_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -163,9 +163,23 @@ public: * @brief Adds user defined constants to all future style template or animation expansions * * e.g. - * Property::Map map; - * map["IMAGE_DIRECTORY"] = "/usr/share/images"; - * builder.AddConstants( map ); + * @code + * Property::Map map; + * map["IMAGE_DIRECTORY"] = "/usr/share/images"; + * builder.AddConstants( map ); + * @endcode + * + * The following shows a list of constants available by default: + * + * Constant | Description + * ----------------------------- | ---------------------------------------------------------------------------------------------------- + * DALI_IMAGE_DIR | The Image Directory used by Toolkit. + * DALI_SOUND_DIR | The Sound Directory used by Toolkit. + * DALI_STYLE_DIR | The Style directory that the Toolkit uses. + * DALI_STYLE_IMAGE_DIR | The directory that stores all the images used by Toolkit's style. + * DALI_SHADER_VERSION_PREFIX | For use in custom shaders to prepend the shader version in use. @ref Shader::GetShaderVersionPrefix + * DALI_VERTEX_SHADER_PREFIX | For use in custom vertex shaders to preprocessor prefix used. @ref Shader::GetVertexShaderPrefix + * DALI_FRAGMENT_SHADER_PREFIX | For use in custom vertex shaders to preprocessor prefix used. @ref Shader::GetFragmentShaderPrefix() * * @pre The Builder has been initialized. * @param map The user defined constants used in template expansions. @@ -180,6 +194,8 @@ public: * builder.AddConstant( "IMAGE_DIRECTORY", "/usr/share/images" ); * @endcode * + * @see AddConstants(const Property::Map&) for builder pre-defined default constants. + * * @pre The Builder has been initialized. * @param key The constant name to add or update * @param value The new value for the constant. diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp index 8bcdff1..88c51b6 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -156,13 +157,16 @@ Builder::Builder() { mParser = Dali::Toolkit::JsonParser::New(); - Property::Map defaultDirs; - defaultDirs[TOKEN_STRING(DALI_IMAGE_DIR)] = AssetManager::GetDaliImagePath(); - defaultDirs[TOKEN_STRING(DALI_SOUND_DIR)] = AssetManager::GetDaliSoundPath(); - defaultDirs[TOKEN_STRING(DALI_STYLE_DIR)] = AssetManager::GetDaliStylePath(); - defaultDirs[TOKEN_STRING(DALI_STYLE_IMAGE_DIR)] = AssetManager::GetDaliStyleImagePath(); + Property::Map defaultConstants; + defaultConstants[TOKEN_STRING(DALI_IMAGE_DIR)] = AssetManager::GetDaliImagePath(); + defaultConstants[TOKEN_STRING(DALI_SOUND_DIR)] = AssetManager::GetDaliSoundPath(); + defaultConstants[TOKEN_STRING(DALI_STYLE_DIR)] = AssetManager::GetDaliStylePath(); + defaultConstants[TOKEN_STRING(DALI_STYLE_IMAGE_DIR)] = AssetManager::GetDaliStyleImagePath(); + defaultConstants[TOKEN_STRING(DALI_SHADER_VERSION_PREFIX)] = Shader::GetShaderVersionPrefix(); + defaultConstants[TOKEN_STRING(DALI_VERTEX_SHADER_PREFIX)] = Shader::GetVertexShaderPrefix(); + defaultConstants[TOKEN_STRING(DALI_FRAGMENT_SHADER_PREFIX)] = Shader::GetFragmentShaderPrefix(); - AddConstants( defaultDirs ); + AddConstants(defaultConstants); } void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::UIFormat format ) -- 2.7.4