From e4c8362431523550a745b190c67c0c8e3f25ac4d Mon Sep 17 00:00:00 2001 From: "huayong.xu" Date: Wed, 15 Feb 2023 16:58:50 +0800 Subject: [PATCH] Replace std::string global variables with C-style string. A std::string global variable would allocate a memory in heap, then copy the string from .text section to the heap. This patch may reduce loading time & memory a little. Change-Id: I2ce22c98695cee6edea088d98b9569e11fc6c837 --- .../public-api/loader/blend-shape-details.cpp | 14 ++++----- .../public-api/loader/blend-shape-details.h | 10 +++---- dali-scene3d/public-api/loader/dli-loader.cpp | 25 ++++++++-------- .../public-api/loader/environment-definition.cpp | 2 +- dali-scene3d/public-api/loader/gltf2-loader.cpp | 14 ++++----- dali-scene3d/public-api/loader/mesh-definition.cpp | 2 +- dali-scene3d/public-api/loader/node-definition.cpp | 2 +- dali-scene3d/public-api/loader/node-definition.h | 2 +- .../public-api/loader/scene-definition.cpp | 4 +-- .../public-api/loader/shader-definition.cpp | 5 ++-- .../public-api/loader/skinning-details.cpp | 3 +- dali-scene3d/public-api/loader/skinning-details.h | 2 +- dali-toolkit/internal/builder/builder-impl.cpp | 33 ++++++++++----------- .../controls/control/control-data-impl.cpp | 12 ++++---- .../controls/scene3d-view/scene3d-view-impl.cpp | 2 +- .../controls/text-controls/text-label-impl.cpp | 16 +++++----- .../text-controls/text-selection-popup-impl.cpp | 10 +++---- .../controller/text-controller-event-handler.cpp | 10 +++---- .../text/controller/text-controller-impl.cpp | 2 +- .../text-controller-input-font-handler.cpp | 2 +- .../text-controller-input-font-handler.h | 2 +- .../text-controller-input-properties.cpp | 10 +++---- .../controller/text-controller-input-properties.h | 8 ++--- .../text-controller-placeholder-handler.cpp | 4 +-- .../text-controller-placeholder-handler.h | 2 +- .../internal/text/controller/text-controller.cpp | 22 +++++++------- .../internal/text/controller/text-controller.h | 20 ++++++------- .../markup-processor-embedded-item.cpp | 3 +- .../markup-processor/markup-processor-font.cpp | 3 -- .../markup-processor-helper-functions.cpp | 34 +++++++++++----------- dali-toolkit/internal/text/text-effects-style.cpp | 21 +++++++------ dali-toolkit/internal/text/text-font-style.cpp | 15 +++++----- 32 files changed, 153 insertions(+), 163 deletions(-) diff --git a/dali-scene3d/public-api/loader/blend-shape-details.cpp b/dali-scene3d/public-api/loader/blend-shape-details.cpp index 01601f9..8e0353c 100644 --- a/dali-scene3d/public-api/loader/blend-shape-details.cpp +++ b/dali-scene3d/public-api/loader/blend-shape-details.cpp @@ -32,13 +32,13 @@ namespace Scene3D { namespace Loader { -const std::string BlendShapes::NUMBER_OF_BLEND_SHAPES("uNumberOfBlendShapes"); -const std::string BlendShapes::UNNORMALIZE_FACTOR("uBlendShapeUnnormalizeFactor"); -const std::string BlendShapes::COMPONENT_SIZE("uBlendShapeComponentSize"); +const char* BlendShapes::NUMBER_OF_BLEND_SHAPES("uNumberOfBlendShapes"); +const char* BlendShapes::UNNORMALIZE_FACTOR("uBlendShapeUnnormalizeFactor"); +const char* BlendShapes::COMPONENT_SIZE("uBlendShapeComponentSize"); -const std::string BlendShapes::COMPONENTS("blendShapeComponents"); +const char* BlendShapes::COMPONENTS("blendShapeComponents"); -const std::string BlendShapes::WEIGHTS_UNIFORM("uBlendShapeWeight"); +const char* BlendShapes::WEIGHTS_UNIFORM("uBlendShapeWeight"); void BlendShapes::ConfigureProperties(const std::pair& mesh, Shader shader, Actor actor) { @@ -46,8 +46,8 @@ void BlendShapes::ConfigureProperties(const std::pair(context, input, output, inputDataBuffer, outputDataBuffer); char weightNameBuffer[32]; - auto prefixSize = snprintf(weightNameBuffer, sizeof(weightNameBuffer), "%s[", BLEND_SHAPE_WEIGHTS_UNIFORM.c_str()); + auto prefixSize = snprintf(weightNameBuffer, sizeof(weightNameBuffer), "%s[", BLEND_SHAPE_WEIGHTS_UNIFORM); char* const pWeightName = weightNameBuffer + prefixSize; const auto remainingSize = sizeof(weightNameBuffer) - prefixSize; for(uint32_t weightIndex = 0u, endWeightIndex = channel.mSampler->mOutput->mCount / channel.mSampler->mInput->mCount; weightIndex < endWeightIndex; ++weightIndex) diff --git a/dali-scene3d/public-api/loader/mesh-definition.cpp b/dali-scene3d/public-api/loader/mesh-definition.cpp index 3beaf83..45ab5ff 100644 --- a/dali-scene3d/public-api/loader/mesh-definition.cpp +++ b/dali-scene3d/public-api/loader/mesh-definition.cpp @@ -65,7 +65,7 @@ private: uint16_t (*mFunc)(uintptr_t&); }; -const std::string QUAD("quad"); +const char* QUAD("quad"); ///@brief Reads a blob from the given stream @a source into @a target, which must have /// at least @a descriptor.length bytes. diff --git a/dali-scene3d/public-api/loader/node-definition.cpp b/dali-scene3d/public-api/loader/node-definition.cpp index b47c203..98405d7 100644 --- a/dali-scene3d/public-api/loader/node-definition.cpp +++ b/dali-scene3d/public-api/loader/node-definition.cpp @@ -61,7 +61,7 @@ void NodeDefinition::Renderable::OnCreate(const NodeDefinition& node, CreatePara actor.AddRenderer(renderer); } -const std::string NodeDefinition::ORIGINAL_MATRIX_PROPERTY_NAME = "originalMatrix"; +const char* NodeDefinition::ORIGINAL_MATRIX_PROPERTY_NAME = "originalMatrix"; Actor NodeDefinition::CreateActor(CreateParams& params) { diff --git a/dali-scene3d/public-api/loader/node-definition.h b/dali-scene3d/public-api/loader/node-definition.h index d713ed5..0e9a5d7 100644 --- a/dali-scene3d/public-api/loader/node-definition.h +++ b/dali-scene3d/public-api/loader/node-definition.h @@ -250,7 +250,7 @@ public: // METHODS static std::string_view GetIblYDirectionUniformName(); public: // DATA - static const std::string ORIGINAL_MATRIX_PROPERTY_NAME; + static const char* ORIGINAL_MATRIX_PROPERTY_NAME; std::string mName; uint32_t mNodeId = INVALID_INDEX; diff --git a/dali-scene3d/public-api/loader/scene-definition.cpp b/dali-scene3d/public-api/loader/scene-definition.cpp index 3241769..f41422e 100644 --- a/dali-scene3d/public-api/loader/scene-definition.cpp +++ b/dali-scene3d/public-api/loader/scene-definition.cpp @@ -45,7 +45,7 @@ namespace Loader { namespace { -const std::string JOINT_MATRIX{"jointMatrix"}; +const char* JOINT_MATRIX{"jointMatrix"}; const std::map sConstraintFactory = { {Property::Type::BOOLEAN, @@ -305,7 +305,7 @@ void ConfigureBoneMatrix(const Matrix& ibm, Actor joint, Shader& shader, Index& { // Register bone transform on shader. char propertyNameBuffer[32]; - snprintf(propertyNameBuffer, sizeof(propertyNameBuffer), "%s[%d]", Skinning::BONE_UNIFORM_NAME.c_str(), boneIdx); + snprintf(propertyNameBuffer, sizeof(propertyNameBuffer), "%s[%d]", Skinning::BONE_UNIFORM_NAME, boneIdx); DALI_ASSERT_DEBUG(shader.GetPropertyIndex(propertyNameBuffer) == Property::INVALID_INDEX); auto propBoneXform = shader.RegisterProperty(propertyNameBuffer, Matrix{false}); diff --git a/dali-scene3d/public-api/loader/shader-definition.cpp b/dali-scene3d/public-api/loader/shader-definition.cpp index 729fa1d..a753155 100644 --- a/dali-scene3d/public-api/loader/shader-definition.cpp +++ b/dali-scene3d/public-api/loader/shader-definition.cpp @@ -28,9 +28,8 @@ namespace Loader { namespace { -const std::string SHADER_HINT_OUTPUT_IS_TRANSPARENT("OUTPUT_IS_TRANSPARENT"); ///< Might generate transparent alpha from opaque inputs. -const std::string SHADER_HINT_MODIFIES_GEOMETRY("MODIFIES_GEOMETRY"); ///< Might change position of vertices, this option disables any culling optimizations. - +const char* SHADER_HINT_OUTPUT_IS_TRANSPARENT("OUTPUT_IS_TRANSPARENT"); ///< Might generate transparent alpha from opaque inputs. +const char* SHADER_HINT_MODIFIES_GEOMETRY("MODIFIES_GEOMETRY"); ///< Might change position of vertices, this option disables any culling optimizations. } // namespace ShaderDefinition::ShaderDefinition(const ShaderDefinition& other) diff --git a/dali-scene3d/public-api/loader/skinning-details.cpp b/dali-scene3d/public-api/loader/skinning-details.cpp index 128a19b..e100151 100644 --- a/dali-scene3d/public-api/loader/skinning-details.cpp +++ b/dali-scene3d/public-api/loader/skinning-details.cpp @@ -27,8 +27,7 @@ namespace Loader { const unsigned int Skinning::MAX_JOINTS = 64; -const std::string Skinning::BONE_UNIFORM_NAME = "uBone"; - +const char* Skinning::BONE_UNIFORM_NAME = "uBone"; } // namespace Loader } // namespace Scene3D } // namespace Dali diff --git a/dali-scene3d/public-api/loader/skinning-details.h b/dali-scene3d/public-api/loader/skinning-details.h index 78ba38c..d754f0c 100644 --- a/dali-scene3d/public-api/loader/skinning-details.h +++ b/dali-scene3d/public-api/loader/skinning-details.h @@ -40,7 +40,7 @@ struct DALI_SCENE3D_API Skinning /* * @brief Name of bone matrix uniform (array). */ - static const std::string BONE_UNIFORM_NAME; + static const char* BONE_UNIFORM_NAME; Skinning() = delete; }; diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp index 517d78f..8b69071 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -70,23 +70,22 @@ namespace { #define TOKEN_STRING(x) #x -const std::string KEYNAME_ACTORS = "actors"; -const std::string KEYNAME_ENTRY_TRANSITION = "entryTransition"; -const std::string KEYNAME_EXIT_TRANSITION = "exitTransition"; -const std::string KEYNAME_INCLUDES = "includes"; -const std::string KEYNAME_INHERIT = "inherit"; -const std::string KEYNAME_MAPPINGS = "mappings"; -const std::string KEYNAME_NAME = "name"; -const std::string KEYNAME_SIGNALS = "signals"; -const std::string KEYNAME_STATES = "states"; -const std::string KEYNAME_STYLES = "styles"; -const std::string KEYNAME_TEMPLATES = "templates"; -const std::string KEYNAME_TRANSITIONS = "transitions"; -const std::string KEYNAME_TYPE = "type"; -const std::string KEYNAME_VISUALS = "visuals"; - -const std::string PROPERTIES = "properties"; -const std::string ANIMATABLE_PROPERTIES = "animatableProperties"; +const char* KEYNAME_ACTORS = "actors"; +const char* KEYNAME_ENTRY_TRANSITION = "entryTransition"; +const char* KEYNAME_EXIT_TRANSITION = "exitTransition"; +const char* KEYNAME_INCLUDES = "includes"; +const char* KEYNAME_INHERIT = "inherit"; +const char* KEYNAME_MAPPINGS = "mappings"; +const char* KEYNAME_SIGNALS = "signals"; +const char* KEYNAME_STATES = "states"; +const char* KEYNAME_STYLES = "styles"; +const char* KEYNAME_TEMPLATES = "templates"; +const char* KEYNAME_TRANSITIONS = "transitions"; +const char* KEYNAME_TYPE = "type"; +const char* KEYNAME_VISUALS = "visuals"; + +const char* PROPERTIES = "properties"; +const char* ANIMATABLE_PROPERTIES = "animatableProperties"; typedef std::vector TreeNodeList; diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index 23f9204..76de885 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -52,12 +52,12 @@ namespace { -const std::string READING_INFO_TYPE_NAME = "name"; -const std::string READING_INFO_TYPE_ROLE = "role"; -const std::string READING_INFO_TYPE_DESCRIPTION = "description"; -const std::string READING_INFO_TYPE_STATE = "state"; -const std::string READING_INFO_TYPE_ATTRIBUTE_NAME = "reading_info_type"; -const std::string READING_INFO_TYPE_SEPARATOR = "|"; +const char* READING_INFO_TYPE_NAME = "name"; +const char* READING_INFO_TYPE_ROLE = "role"; +const char* READING_INFO_TYPE_DESCRIPTION = "description"; +const char* READING_INFO_TYPE_STATE = "state"; +const char* READING_INFO_TYPE_ATTRIBUTE_NAME = "reading_info_type"; +const char* READING_INFO_TYPE_SEPARATOR = "|"; } // namespace namespace Dali diff --git a/dali-toolkit/internal/controls/scene3d-view/scene3d-view-impl.cpp b/dali-toolkit/internal/controls/scene3d-view/scene3d-view-impl.cpp index 77eb533..e93057d 100644 --- a/dali-toolkit/internal/controls/scene3d-view/scene3d-view-impl.cpp +++ b/dali-toolkit/internal/controls/scene3d-view/scene3d-view-impl.cpp @@ -36,7 +36,7 @@ namespace const char* const IMAGE_BRDF_FILE_NAME = "brdfLUT.png"; // glTF file extension -const std::string GLTF_EXT(".gltf"); +const char* GLTF_EXT(".gltf"); /** * cube map face index diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index 8d3c203..14d2de7 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -70,25 +70,25 @@ const unsigned int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::DevelText::DEFAULT * The alignment depends on the alignment value of the text label (Use Text::VerticalAlignment enumerations). */ const float VERTICAL_ALIGNMENT_TABLE[Text::VerticalAlignment::BOTTOM + 1] = - { +{ 0.0f, // VerticalAlignment::TOP 0.5f, // VerticalAlignment::CENTER 1.0f // VerticalAlignment::BOTTOM }; -const std::string TEXT_FIT_ENABLE_KEY("enable"); -const std::string TEXT_FIT_MIN_SIZE_KEY("minSize"); -const std::string TEXT_FIT_MAX_SIZE_KEY("maxSize"); -const std::string TEXT_FIT_STEP_SIZE_KEY("stepSize"); -const std::string TEXT_FIT_FONT_SIZE_KEY("fontSize"); -const std::string TEXT_FIT_FONT_SIZE_TYPE_KEY("fontSizeType"); +const char* TEXT_FIT_ENABLE_KEY("enable"); +const char* TEXT_FIT_MIN_SIZE_KEY("minSize"); +const char* TEXT_FIT_MAX_SIZE_KEY("maxSize"); +const char* TEXT_FIT_STEP_SIZE_KEY("stepSize"); +const char* TEXT_FIT_FONT_SIZE_KEY("fontSize"); +const char* TEXT_FIT_FONT_SIZE_TYPE_KEY("fontSizeType"); #if defined(DEBUG_ENABLED) Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS"); #endif const Scripting::StringEnum AUTO_SCROLL_STOP_MODE_TABLE[] = - { +{ {"IMMEDIATE", Toolkit::TextLabel::AutoScrollStopMode::IMMEDIATE}, {"FINISH_LOOP", Toolkit::TextLabel::AutoScrollStopMode::FINISH_LOOP}, }; diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp index 862a69c..50d7d3d 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp @@ -57,7 +57,7 @@ namespace #define GET_LOCALE_TEXT(string) dgettext("dali-toolkit", string) #endif -const std::string TEXT_SELECTION_POPUP_BUTTON_STYLE_NAME("TextSelectionPopupButton"); +const char* TEXT_SELECTION_POPUP_BUTTON_STYLE_NAME("TextSelectionPopupButton"); const Dali::Vector4 DEFAULT_OPTION_PRESSED_COLOR(Dali::Vector4(0.24f, 0.72f, 0.8f, 1.0f)); const float DEFAULT_OPTION_PRESSED_CORNER_RADIUS = 0.0f; const Dali::Vector4 DEFAULT_LABEL_PADDING(Dali::Vector4(24.0f, 24.0f, 14.0f, 14.0f)); @@ -93,8 +93,8 @@ const char* const OPTION_COPY("optionCopy"); // "Copy" popup opt const char* const OPTION_PASTE("optionPaste"); // "Paste" popup option. const char* const OPTION_CLIPBOARD("optionClipboard"); // "Clipboard" popup option. -const std::string IDS_LTR("IDS_LTR"); -const std::string RTL_DIRECTION("RTL"); +const char* IDS_LTR("IDS_LTR"); +const char* RTL_DIRECTION("RTL"); BaseHandle Create() { @@ -726,10 +726,10 @@ void TextSelectionPopup::AddPopupOptionsToToolbar(bool showIcons, bool showCapti // Whether to mirror the list of buttons (for right to left languages) bool mirror = false; #if defined(__GLIBC__) - char* idsLtr = GET_LOCALE_TEXT(IDS_LTR.c_str()); + char* idsLtr = GET_LOCALE_TEXT(IDS_LTR); if(NULL != idsLtr) { - mirror = (0 == strcmp(idsLtr, RTL_DIRECTION.c_str())); + mirror = (0 == strcmp(idsLtr, RTL_DIRECTION)); if(mirror) { diff --git a/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp index 5323d35..f7bd90a 100644 --- a/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp @@ -39,11 +39,11 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_TEXT_PERFORMANCE_MARKER, false); -const std::string KEY_C_NAME = "c"; -const std::string KEY_V_NAME = "v"; -const std::string KEY_X_NAME = "x"; -const std::string KEY_A_NAME = "a"; -const std::string KEY_INSERT_NAME = "Insert"; +const char* KEY_C_NAME = "c"; +const char* KEY_V_NAME = "v"; +const char* KEY_X_NAME = "x"; +const char* KEY_A_NAME = "a"; +const char* KEY_INSERT_NAME = "Insert"; } // namespace diff --git a/dali-toolkit/internal/text/controller/text-controller-impl.cpp b/dali-toolkit/internal/text/controller/text-controller-impl.cpp index c483114..7752360 100644 --- a/dali-toolkit/internal/text/controller/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl.cpp @@ -51,7 +51,7 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT constexpr float MAX_FLOAT = std::numeric_limits::max(); -const std::string EMPTY_STRING(""); +const char* EMPTY_STRING = ""; } // namespace diff --git a/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp index a1e6214..f2d49d2 100644 --- a/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.cpp @@ -131,7 +131,7 @@ void Controller::InputFontHandler::SetInputFontFamily(Controller& controller, co } } -const std::string& Controller::InputFontHandler::GetInputFontFamily(const Controller& controller) +std::string Controller::InputFontHandler::GetInputFontFamily(const Controller& controller) { if(NULL != controller.mImpl->mEventData) { diff --git a/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h index 2ac7464..bf38a00 100644 --- a/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h +++ b/dali-toolkit/internal/text/controller/text-controller-input-font-handler.h @@ -34,7 +34,7 @@ namespace Text struct Controller::InputFontHandler { static void SetInputFontFamily(Controller& controller, const std::string& fontFamily); - static const std::string& GetInputFontFamily(const Controller& controller); + static std::string GetInputFontFamily(const Controller& controller); static void SetInputFontWeight(const Controller& controller, FontWeight weight); static bool IsInputFontWeightDefined(const Controller& controller); static FontWeight GetInputFontWeight(const Controller& controller); diff --git a/dali-toolkit/internal/text/controller/text-controller-input-properties.cpp b/dali-toolkit/internal/text/controller/text-controller-input-properties.cpp index f410187..7842d05 100644 --- a/dali-toolkit/internal/text/controller/text-controller-input-properties.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-input-properties.cpp @@ -38,7 +38,7 @@ namespace { -const std::string EMPTY_STRING(""); +const char* EMPTY_STRING = ""; } namespace Dali::Toolkit::Text @@ -116,7 +116,7 @@ void Controller::InputProperties::SetInputShadowProperties(Controller& controlle } } -const std::string& Controller::InputProperties::GetInputShadowProperties(const Controller& controller) +std::string Controller::InputProperties::GetInputShadowProperties(const Controller& controller) { return controller.mImpl->mEventData ? controller.mImpl->mEventData->mInputStyle.shadowProperties : EMPTY_STRING; } @@ -129,7 +129,7 @@ void Controller::InputProperties::SetInputUnderlineProperties(Controller& contro } } -const std::string& Controller::InputProperties::GetInputUnderlineProperties(const Controller& controller) +std::string Controller::InputProperties::GetInputUnderlineProperties(const Controller& controller) { return controller.mImpl->mEventData ? controller.mImpl->mEventData->mInputStyle.underlineProperties : EMPTY_STRING; } @@ -142,7 +142,7 @@ void Controller::InputProperties::SetInputEmbossProperties(Controller& controlle } } -const std::string& Controller::InputProperties::GetInputEmbossProperties(const Controller& controller) +std::string Controller::InputProperties::GetInputEmbossProperties(const Controller& controller) { return controller.mImpl->mEventData ? controller.mImpl->mEventData->mInputStyle.embossProperties : controller.GetDefaultEmbossProperties(); } @@ -155,7 +155,7 @@ void Controller::InputProperties::SetInputOutlineProperties(Controller& controll } } -const std::string& Controller::InputProperties::GetInputOutlineProperties(const Controller& controller) +std::string Controller::InputProperties::GetInputOutlineProperties(const Controller& controller) { return controller.mImpl->mEventData ? controller.mImpl->mEventData->mInputStyle.outlineProperties : controller.GetDefaultOutlineProperties(); } diff --git a/dali-toolkit/internal/text/controller/text-controller-input-properties.h b/dali-toolkit/internal/text/controller/text-controller-input-properties.h index b0736f7..9b31d22 100644 --- a/dali-toolkit/internal/text/controller/text-controller-input-properties.h +++ b/dali-toolkit/internal/text/controller/text-controller-input-properties.h @@ -39,19 +39,19 @@ struct Controller::InputProperties static void SetInputShadowProperties(Controller& controller, const std::string& shadowProperties); - static const std::string& GetInputShadowProperties(const Controller& controller); + static std::string GetInputShadowProperties(const Controller& controller); static void SetInputUnderlineProperties(Controller& controller, const std::string& underlineProperties); - static const std::string& GetInputUnderlineProperties(const Controller& controller); + static std::string GetInputUnderlineProperties(const Controller& controller); static void SetInputEmbossProperties(Controller& controller, const std::string& embossProperties); - static const std::string& GetInputEmbossProperties(const Controller& controller); + static std::string GetInputEmbossProperties(const Controller& controller); static void SetInputOutlineProperties(Controller& controller, const std::string& outlineProperties); - static const std::string& GetInputOutlineProperties(const Controller& controller); + static std::string GetInputOutlineProperties(const Controller& controller); static void SetInputModePassword(Controller& controller, bool passwordInput); diff --git a/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.cpp index da15a43..a0f03a6 100644 --- a/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.cpp @@ -33,7 +33,7 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS"); #endif -const std::string EMPTY_STRING(""); +const char* EMPTY_STRING = ""; const char* const PLACEHOLDER_TEXT = "text"; const char* const PLACEHOLDER_TEXT_FOCUSED = "textFocused"; @@ -122,7 +122,7 @@ void Controller::PlaceholderHandler::SetPlaceholderFontFamily(Controller& contro } } -const std::string& Controller::PlaceholderHandler::GetPlaceholderFontFamily(const Controller& controller) +std::string Controller::PlaceholderHandler::GetPlaceholderFontFamily(const Controller& controller) { if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont)) { diff --git a/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h b/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h index c7107c9..3bbf87b 100644 --- a/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h +++ b/dali-toolkit/internal/text/controller/text-controller-placeholder-handler.h @@ -39,7 +39,7 @@ struct Controller::PlaceholderHandler static void SetPlaceholderText(Controller& controller, PlaceholderType type, const std::string& text); static void GetPlaceholderText(const Controller& controller, PlaceholderType type, std::string& text); static void SetPlaceholderFontFamily(Controller& controller, const std::string& placeholderTextFontFamily); - static const std::string& GetPlaceholderFontFamily(const Controller& controller); + static std::string GetPlaceholderFontFamily(const Controller& controller); static void SetPlaceholderTextFontWeight(Controller& controller, FontWeight weight); static bool IsPlaceholderTextFontWeightDefined(const Controller& controller); static FontWeight GetPlaceholderTextFontWeight(const Controller& controller); diff --git a/dali-toolkit/internal/text/controller/text-controller.cpp b/dali-toolkit/internal/text/controller/text-controller.cpp index b66cd3c..810cd1a 100644 --- a/dali-toolkit/internal/text/controller/text-controller.cpp +++ b/dali-toolkit/internal/text/controller/text-controller.cpp @@ -45,7 +45,7 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS"); #endif -const std::string EMPTY_STRING(""); +const char* EMPTY_STRING = ""; template void EnsureCreated(Type*& object) @@ -538,7 +538,7 @@ void Controller::SetDefaultFontFamily(const std::string& defaultFontFamily) } } -const std::string& Controller::GetDefaultFontFamily() const +std::string Controller::GetDefaultFontFamily() const { return mImpl->mFontDefaults ? mImpl->mFontDefaults->mFontDescription.family : EMPTY_STRING; } @@ -548,7 +548,7 @@ void Controller::SetPlaceholderFontFamily(const std::string& placeholderTextFont PlaceholderHandler::SetPlaceholderFontFamily(*this, placeholderTextFontFamily); } -const std::string& Controller::GetPlaceholderFontFamily() const +std::string Controller::GetPlaceholderFontFamily() const { return PlaceholderHandler::GetPlaceholderFontFamily(*this); } @@ -945,7 +945,7 @@ void Controller::SetDefaultEmbossProperties(const std::string& embossProperties) mImpl->mEmbossDefaults->properties = embossProperties; } -const std::string& Controller::GetDefaultEmbossProperties() const +std::string Controller::GetDefaultEmbossProperties() const { return mImpl->mEmbossDefaults ? mImpl->mEmbossDefaults->properties : EMPTY_STRING; } @@ -956,7 +956,7 @@ void Controller::SetDefaultOutlineProperties(const std::string& outlinePropertie mImpl->mOutlineDefaults->properties = outlineProperties; } -const std::string& Controller::GetDefaultOutlineProperties() const +std::string Controller::GetDefaultOutlineProperties() const { return mImpl->mOutlineDefaults ? mImpl->mOutlineDefaults->properties : EMPTY_STRING; } @@ -1006,7 +1006,7 @@ void Controller::SetInputFontFamily(const std::string& fontFamily) InputFontHandler::SetInputFontFamily(*this, fontFamily); } -const std::string& Controller::GetInputFontFamily() const +std::string Controller::GetInputFontFamily() const { return InputFontHandler::GetInputFontFamily(*this); } @@ -1081,7 +1081,7 @@ void Controller::SetInputShadowProperties(const std::string& shadowProperties) InputProperties::SetInputShadowProperties(*this, shadowProperties); } -const std::string& Controller::GetInputShadowProperties() const +std::string Controller::GetInputShadowProperties() const { return InputProperties::GetInputShadowProperties(*this); } @@ -1091,7 +1091,7 @@ void Controller::SetInputUnderlineProperties(const std::string& underlinePropert InputProperties::SetInputUnderlineProperties(*this, underlineProperties); } -const std::string& Controller::GetInputUnderlineProperties() const +std::string Controller::GetInputUnderlineProperties() const { return InputProperties::GetInputUnderlineProperties(*this); } @@ -1101,7 +1101,7 @@ void Controller::SetInputEmbossProperties(const std::string& embossProperties) InputProperties::SetInputEmbossProperties(*this, embossProperties); } -const std::string& Controller::GetInputEmbossProperties() const +std::string Controller::GetInputEmbossProperties() const { return InputProperties::GetInputEmbossProperties(*this); } @@ -1111,7 +1111,7 @@ void Controller::SetInputOutlineProperties(const std::string& outlineProperties) InputProperties::SetInputOutlineProperties(*this, outlineProperties); } -const std::string& Controller::GetInputOutlineProperties() const +std::string Controller::GetInputOutlineProperties() const { return InputProperties::GetInputOutlineProperties(*this); } @@ -1236,7 +1236,7 @@ void Controller::SetInputStrikethroughProperties(const std::string& strikethroug } } -const std::string& Controller::GetInputStrikethroughProperties() const +std::string Controller::GetInputStrikethroughProperties() const { return (NULL != mImpl->mEventData) ? mImpl->mEventData->mInputStyle.strikethroughProperties : EMPTY_STRING; } diff --git a/dali-toolkit/internal/text/controller/text-controller.h b/dali-toolkit/internal/text/controller/text-controller.h index 0a1b057..55953f4 100644 --- a/dali-toolkit/internal/text/controller/text-controller.h +++ b/dali-toolkit/internal/text/controller/text-controller.h @@ -829,7 +829,7 @@ public: // Default style & Input style * * @return The default font family. */ - const std::string& GetDefaultFontFamily() const; + std::string GetDefaultFontFamily() const; /** * @brief Sets the placeholder text font family. @@ -842,7 +842,7 @@ public: // Default style & Input style * * @return The placeholder text font family */ - const std::string& GetPlaceholderFontFamily() const; + std::string GetPlaceholderFontFamily() const; /** * @brief Sets the default font weight. @@ -1258,7 +1258,7 @@ public: // Default style & Input style * * @return The emboss's properties string. */ - const std::string& GetDefaultEmbossProperties() const; + std::string GetDefaultEmbossProperties() const; /** * @brief Sets the outline's properties string. @@ -1274,7 +1274,7 @@ public: // Default style & Input style * * @return The outline's properties string. */ - const std::string& GetDefaultOutlineProperties() const; + std::string GetDefaultOutlineProperties() const; /** * @brief Sets the default line spacing. @@ -1350,7 +1350,7 @@ public: // Default style & Input style * * @return The input text's font family name. */ - const std::string& GetInputFontFamily() const; + std::string GetInputFontFamily() const; /** * @brief Sets the input font's weight. @@ -1451,7 +1451,7 @@ public: // Default style & Input style * * @return The shadow's properties string. */ - const std::string& GetInputShadowProperties() const; + std::string GetInputShadowProperties() const; /** * @brief Sets the input underline's properties string. @@ -1467,7 +1467,7 @@ public: // Default style & Input style * * @return The underline's properties string. */ - const std::string& GetInputUnderlineProperties() const; + std::string GetInputUnderlineProperties() const; /** * @brief Sets the input emboss's properties string. @@ -1483,7 +1483,7 @@ public: // Default style & Input style * * @return The emboss's properties string. */ - const std::string& GetInputEmbossProperties() const; + std::string GetInputEmbossProperties() const; /** * @brief Sets input the outline's properties string. @@ -1499,7 +1499,7 @@ public: // Default style & Input style * * @return The outline's properties string. */ - const std::string& GetInputOutlineProperties() const; + std::string GetInputOutlineProperties() const; /** * @brief Sets the input strikethrough's properties string. @@ -1515,7 +1515,7 @@ public: // Default style & Input style * * @return The strikethrough's properties string. */ - const std::string& GetInputStrikethroughProperties() const; + std::string GetInputStrikethroughProperties() const; /** * @brief Set the control's interface. diff --git a/dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.cpp index 8e9ec06..f39afce 100644 --- a/dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-embedded-item.cpp @@ -35,8 +35,7 @@ namespace Text { namespace { -const std::string NONE("none"); -const std::string MULTIPLY("multiply"); +const char* MULTIPLY = "multiply"; } // namespace void ProcessEmbeddedItem(const Tag& tag, EmbeddedItem& embeddedItem) diff --git a/dali-toolkit/internal/text/markup-processor/markup-processor-font.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-font.cpp index 133d7fa..13afaa0 100644 --- a/dali-toolkit/internal/text/markup-processor/markup-processor-font.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-font.cpp @@ -37,9 +37,6 @@ namespace Text { namespace { -const std::string FONT_PREFIX("font-"); -const unsigned int FONT_PREFIX_LENGTH = 5u; -const unsigned int MIN_FONT_ATTRIBUTE_SIZE = 4u; ///< The minimum length of any of the possible 'weight', 'width' , 'slant' or 'size' values. const unsigned int MAX_FONT_ATTRIBUTE_SIZE = 15u; ///< The maximum length of any of the possible 'weight', 'width' or 'slant' values. const float PIXEL_FORMAT_64_FACTOR = 64.f; ///< 64.f is used to convert from point size to 26.6 pixel format. } // namespace diff --git a/dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.cpp b/dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.cpp index b0ac16b..f7ed507 100644 --- a/dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.cpp +++ b/dali-toolkit/internal/text/markup-processor/markup-processor-helper-functions.cpp @@ -44,23 +44,23 @@ const char WEB_COLOR_TOKEN('#'); const char* const HEX_COLOR_TOKEN("0x"); const char* const ALPHA_ONE("FF"); -const std::string BLACK_COLOR("black"); -const std::string WHITE_COLOR("white"); -const std::string RED_COLOR("red"); -const std::string GREEN_COLOR("green"); -const std::string BLUE_COLOR("blue"); -const std::string YELLOW_COLOR("yellow"); -const std::string MAGENTA_COLOR("magenta"); -const std::string CYAN_COLOR("cyan"); -const std::string TRANSPARENT_COLOR("transparent"); - -const std::string SOLID_UNDERLINE("solid"); -const std::string DASHED_UNDERLINE("dashed"); -const std::string DOUBLE_UNDERLINE("double"); - -const std::string BEGIN_HORIZONTAL_ALIGNMENT("begin"); -const std::string CENTER_HORIZONTAL_ALIGNMENT("center"); -const std::string END_HORIZONTAL_ALIGNMENT("end"); +const char* BLACK_COLOR("black"); +const char* WHITE_COLOR("white"); +const char* RED_COLOR("red"); +const char* GREEN_COLOR("green"); +const char* BLUE_COLOR("blue"); +const char* YELLOW_COLOR("yellow"); +const char* MAGENTA_COLOR("magenta"); +const char* CYAN_COLOR("cyan"); +const char* TRANSPARENT_COLOR("transparent"); + +const char* SOLID_UNDERLINE("solid"); +const char* DASHED_UNDERLINE("dashed"); +const char* DOUBLE_UNDERLINE("double"); + +const char* BEGIN_HORIZONTAL_ALIGNMENT("begin"); +const char* CENTER_HORIZONTAL_ALIGNMENT("center"); +const char* END_HORIZONTAL_ALIGNMENT("end"); } // namespace diff --git a/dali-toolkit/internal/text/text-effects-style.cpp b/dali-toolkit/internal/text/text-effects-style.cpp index 1428b95..2bf1398 100644 --- a/dali-toolkit/internal/text/text-effects-style.cpp +++ b/dali-toolkit/internal/text/text-effects-style.cpp @@ -35,17 +35,16 @@ namespace Text { namespace { -const std::string COLOR_KEY("color"); -const std::string OFFSET_KEY("offset"); -const std::string BLUR_RADIUS_KEY("blurRadius"); -const std::string WIDTH_KEY("width"); -const std::string HEIGHT_KEY("height"); -const std::string ENABLE_KEY("enable"); -const std::string TYPE_KEY("type"); -const std::string DASH_WIDTH_KEY("dashWidth"); -const std::string DASH_GAP_KEY("dashGap"); -const std::string TRUE_TOKEN("true"); -const std::string FALSE_TOKEN("false"); +const char* COLOR_KEY = "color"; +const char* OFFSET_KEY = "offset"; +const char* BLUR_RADIUS_KEY = "blurRadius"; +const char* WIDTH_KEY = "width"; +const char* HEIGHT_KEY = "height"; +const char* ENABLE_KEY = "enable"; +const char* TYPE_KEY = "type"; +const char* DASH_WIDTH_KEY = "dashWidth"; +const char* DASH_GAP_KEY = "dashGap"; +const char* TRUE_TOKEN = "true"; } // namespace bool ParseShadowProperties(const Property::Map& shadowPropertiesMap, diff --git a/dali-toolkit/internal/text/text-font-style.cpp b/dali-toolkit/internal/text/text-font-style.cpp index ce5e860..f087a1e 100644 --- a/dali-toolkit/internal/text/text-font-style.cpp +++ b/dali-toolkit/internal/text/text-font-style.cpp @@ -33,14 +33,13 @@ namespace Text { namespace { -const std::string STYLE_KEY("style"); -const std::string WEIGHT_KEY("weight"); -const std::string WIDTH_KEY("width"); -const std::string SLANT_KEY("slant"); -const std::string FAMILY_KEY("family"); -const std::string TYPE_KEY("type"); - -const std::string SYSTEM_TOKEN("system"); +const char* WEIGHT_KEY = "weight"; +const char* WIDTH_KEY = "width"; +const char* SLANT_KEY = "slant"; +const char* FAMILY_KEY = "family"; +const char* TYPE_KEY = "type"; + +const char* SYSTEM_TOKEN = "system"; } // namespace -- 2.7.4