From 0f62149a3887e236f7c3b90f4485c4091544ae0d Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Wed, 9 Jul 2014 11:10:57 +0100 Subject: [PATCH] Replaces TextArray type definition. TextArray is now a Dali::Vector instead a std::vector. Change-Id: Iafebb20da91c8f557d0b6162bb84901dadb1cd1b Signed-off-by: Victor Cebollada --- .../dali-internal/utc-Dali-Internal-Text.cpp | 2 +- .../test-platform-abstraction.cpp | 4 +- .../test-platform-abstraction.h | 4 +- .../dali-test-suite-utils.h | 9 ++- .../test-platform-abstraction.cpp | 4 +- .../test-platform-abstraction.h | 4 +- automated-tests/src/dali/utc-Dali-Text.cpp | 6 +- dali/integration-api/file.list | 3 +- dali/integration-api/platform-abstraction.h | 8 +-- .../common => integration-api}/text-array.h | 8 +-- .../text-attachment-impl.cpp | 10 +-- .../actor-attachments/text-attachment-impl.h | 10 +-- .../internal/event/actors/text-actor-impl.cpp | 13 ++-- dali/internal/event/actors/text-actor-impl.h | 6 +- .../event/text/atlas/atlas-rank-generator.cpp | 4 +- .../event/text/atlas/atlas-rank-generator.h | 2 +- .../atlas/glyph-atlas-manager-interface.h | 14 ++-- .../event/text/atlas/glyph-atlas-manager.cpp | 17 +++-- .../event/text/atlas/glyph-atlas-manager.h | 9 ++- .../internal/event/text/atlas/glyph-atlas.cpp | 32 ++++----- dali/internal/event/text/atlas/glyph-atlas.h | 16 ++--- dali/internal/event/text/font-factory.h | 1 - dali/internal/event/text/font-impl.cpp | 26 +++---- dali/internal/event/text/font-impl.h | 19 +++--- .../event/text/font-metrics-interface.h | 4 +- dali/internal/event/text/font-metrics.cpp | 35 +++++----- dali/internal/event/text/font-metrics.h | 10 +-- .../text/generator/text-vertex-generator.cpp | 6 +- .../text/generator/text-vertex-generator.h | 4 +- .../glyph-status/glyph-status-container.cpp | 30 ++++----- .../glyph-status/glyph-status-container.h | 8 +-- dali/internal/event/text/text-impl.cpp | 67 ++++++++++--------- dali/internal/event/text/text-impl.h | 12 ++-- .../event/text/text-request-helper.cpp | 12 ++-- .../internal/event/text/text-request-helper.h | 8 +-- dali/internal/event/text/utf8-impl.cpp | 6 +- dali/internal/event/text/utf8-impl.h | 4 +- dali/public-api/actors/text-actor.cpp | 2 +- 38 files changed, 218 insertions(+), 221 deletions(-) rename dali/{internal/common => integration-api}/text-array.h (86%) diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Text.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Text.cpp index 04de70587..f482755e2 100644 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-Text.cpp +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-Text.cpp @@ -107,7 +107,7 @@ int UtcDaliTextGetTextArray(void) Text text( std::string( "Hello world" ) ); - DALI_TEST_EQUALS( text.GetImplementation().GetTextArray().size(), 11u, TEST_LOCATION ); + DALI_TEST_EQUALS( text.GetImplementation().GetTextArray().Count(), 11u, TEST_LOCATION ); END_TEST; } diff --git a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.cpp b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.cpp index 744647541..22b046692 100644 --- a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.cpp +++ b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.cpp @@ -312,7 +312,7 @@ void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int d /** * @copydoc PlatformAbstraction::GetFontFamilyForChars() */ -const std::string& TestPlatformAbstraction::GetFontFamilyForChars(const TextArray& charsRequested) const +const std::string& TestPlatformAbstraction::GetFontFamilyForChars(const Integration::TextArray& charsRequested) const { mTrace.PushCall("GetFontFamilyForChars", ""); return mGetDefaultFontFamilyResult; @@ -321,7 +321,7 @@ const std::string& TestPlatformAbstraction::GetFontFamilyForChars(const TextArra /** * @copydoc PlatformAbstraction::AllGlyphsSupported() */ -bool TestPlatformAbstraction::AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const TextArray& text) const +bool TestPlatformAbstraction::AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const { mTrace.PushCall("AllGlyphsSupported", ""); return true; diff --git a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.h b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.h index 571d3c968..6ecfe0781 100644 --- a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.h +++ b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.h @@ -182,12 +182,12 @@ public: /** * @copydoc PlatformAbstraction::GetFontFamilyForChars() */ - virtual const std::string& GetFontFamilyForChars(const TextArray& charsRequested) const; + virtual const std::string& GetFontFamilyForChars(const Integration::TextArray& charsRequested) const; /** * @copydoc PlatformAbstraction::AllGlyphsSupported() */ - virtual bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const TextArray& text) const; + virtual bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const; /** * @copydoc PlatformAbstraction::ValidateFontFamilyName() diff --git a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h index de7790365..375fb9008 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h +++ b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h @@ -295,7 +295,6 @@ void DALI_TEST_EQUALS( const std::string &str1, const char* str2, const char* lo */ void DALI_TEST_EQUALS( const char* str1, const std::string &str2, const char* location); - /** * Test whether two UTF32 strings are equal. * @param[in] str1 The first string @@ -303,20 +302,20 @@ void DALI_TEST_EQUALS( const char* str1, const std::string &str2, const char* lo * @param[in] location The TEST_LOCATION macro should be used here */ template<> -inline void DALI_TEST_EQUALS( const TextArray& str1, const TextArray& str2, const char* location) +inline void DALI_TEST_EQUALS( const Integration::TextArray& str1, const Integration::TextArray& str2, const char* location) { - if (!std::equal(str1.begin(), str1.end(), str2.begin())) + if( !std::equal( str1.Begin(), str1.End(), str2.Begin() ) ) { fprintf(stderr, "%s, checking '", location); - for( unsigned int i = 0; i < str1.size(); ++i) + for( unsigned int i = 0; i < str1.Count(); ++i ) { fprintf(stderr, "%c", str1[i]); } fprintf(stderr, "' == '"); - for( unsigned int i = 0; i < str2.size(); ++i) + for( unsigned int i = 0; i < str2.Count(); ++i ) { fprintf(stderr, "%c", str2[i]); } diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp index 4f749ce22..ef3eb772e 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp @@ -322,7 +322,7 @@ void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int d /** * @copydoc PlatformAbstraction::GetFontFamilyForChars() */ -const std::string& TestPlatformAbstraction::GetFontFamilyForChars(const TextArray& charsRequested) const +const std::string& TestPlatformAbstraction::GetFontFamilyForChars(const Integration::TextArray& charsRequested) const { mTrace.PushCall("GetFontFamilyForChars", ""); return mGetDefaultFontFamilyResult; @@ -331,7 +331,7 @@ const std::string& TestPlatformAbstraction::GetFontFamilyForChars(const TextArra /** * @copydoc PlatformAbstraction::AllGlyphsSupported() */ -bool TestPlatformAbstraction::AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const TextArray& text) const +bool TestPlatformAbstraction::AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const { mTrace.PushCall("AllGlyphsSupported", ""); return true; diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h index 4723d9025..2d4c38c9d 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h @@ -185,12 +185,12 @@ public: /** * @copydoc PlatformAbstraction::GetFontFamilyForChars() */ - virtual const std::string& GetFontFamilyForChars(const TextArray& charsRequested) const; + virtual const std::string& GetFontFamilyForChars(const Integration::TextArray& charsRequested) const; /** * @copydoc PlatformAbstraction::AllGlyphsSupported() */ - virtual bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const TextArray& text) const; + virtual bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const; /** * @copydoc PlatformAbstraction::ValidateFontFamilyName() diff --git a/automated-tests/src/dali/utc-Dali-Text.cpp b/automated-tests/src/dali/utc-Dali-Text.cpp index b1c418a79..e9ebb978a 100644 --- a/automated-tests/src/dali/utc-Dali-Text.cpp +++ b/automated-tests/src/dali/utc-Dali-Text.cpp @@ -180,7 +180,7 @@ int UtcDaliTextAccessOperator01(void) catch( DaliException& e ) { tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "position < mString.size() && \"Text::operator[]: Character position is out of bounds\"", TEST_LOCATION ); + DALI_TEST_EQUALS( e.mCondition, "position < mString.Count() && \"Text::operator[]: Character position is out of bounds\"", TEST_LOCATION ); assert2 = true; } @@ -296,7 +296,7 @@ int UtcDaliTextRemove01(void) catch( DaliException& e ) { tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "position < mString.size() && \"Text::Remove: Character position is out of bounds\"", TEST_LOCATION ); + DALI_TEST_EQUALS( e.mCondition, "position < mString.Count() && \"Text::Remove: Character position is out of bounds\"", TEST_LOCATION ); assert1 = true; } @@ -307,7 +307,7 @@ int UtcDaliTextRemove01(void) catch( DaliException& e ) { tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "position + numberOfCharacters <= mString.size() && \"Text::Remove: Character position + numberOfCharacters is out of bounds\"", TEST_LOCATION ); + DALI_TEST_EQUALS( e.mCondition, "position + numberOfCharacters <= mString.Count() && \"Text::Remove: Character position + numberOfCharacters is out of bounds\"", TEST_LOCATION ); assert2 = true; } diff --git a/dali/integration-api/file.list b/dali/integration-api/file.list index d1d1eb45a..5620eddf7 100644 --- a/dali/integration-api/file.list +++ b/dali/integration-api/file.list @@ -42,7 +42,8 @@ platform_abstraction_header_files = \ $(platform_abstraction_src_dir)/platform-abstraction.h \ $(platform_abstraction_src_dir)/shader-data.h \ $(platform_abstraction_src_dir)/system-overlay.h \ - $(platform_abstraction_src_dir)/common/lockless-buffer.h + $(platform_abstraction_src_dir)/common/lockless-buffer.h \ + $(platform_abstraction_src_dir)/text-array.h platform_abstraction_dynamics_header_files = \ $(platform_abstraction_src_dir)/dynamics/dynamics-body-intf.h \ diff --git a/dali/integration-api/platform-abstraction.h b/dali/integration-api/platform-abstraction.h index f0f8af437..4fb4352a5 100644 --- a/dali/integration-api/platform-abstraction.h +++ b/dali/integration-api/platform-abstraction.h @@ -18,18 +18,14 @@ * */ -// EXTERNAL INCLUDES -#include - // INTERNAL INCLUDES -#include #include +#include +#include namespace Dali { -typedef std::vector TextArray; - namespace Integration { diff --git a/dali/internal/common/text-array.h b/dali/integration-api/text-array.h similarity index 86% rename from dali/internal/common/text-array.h rename to dali/integration-api/text-array.h index ed9fcdadb..70d78efba 100644 --- a/dali/internal/common/text-array.h +++ b/dali/integration-api/text-array.h @@ -22,20 +22,20 @@ #include // INTERNAL INCLUDES -#include +#include namespace Dali { -namespace Internal +namespace Integration { /** * array of UTF-32 codes. */ -typedef std::vector TextArray; +typedef Vector TextArray; -} // namespace Internal +} // namespace Integration } // namespace Dali diff --git a/dali/internal/event/actor-attachments/text-attachment-impl.cpp b/dali/internal/event/actor-attachments/text-attachment-impl.cpp index 475919143..454bfee64 100644 --- a/dali/internal/event/actor-attachments/text-attachment-impl.cpp +++ b/dali/internal/event/actor-attachments/text-attachment-impl.cpp @@ -31,7 +31,7 @@ namespace Dali namespace Internal { -TextAttachmentPtr TextAttachment::New( const SceneGraph::Node& parentNode, const TextArray& text, FontPointer font ) +TextAttachmentPtr TextAttachment::New( const SceneGraph::Node& parentNode, const Integration::TextArray& text, FontPointer font ) { StagePtr stage = Stage::GetCurrent(); @@ -74,11 +74,11 @@ TextAttachment::~TextAttachment() delete mTextColor; } -void TextAttachment::SetText(const TextArray& text) +void TextAttachment::SetText( const Integration::TextArray& text ) { // return if the text hasn't changed - if( (text.size() == mText.size() ) && - std::equal(mText.begin(), mText.end(), text.begin ()) ) + if( ( text.Count() == mText.Count() ) && + std::equal( mText.Begin(), mText.End(), text.Begin () ) ) { return; } @@ -468,7 +468,7 @@ Vector3 TextAttachment::MeasureText() const void TextAttachment::TextChanged() { - DALI_LOG_INFO(Debug::Filter::gResource, Debug::Verbose, "TextAttachment::TextChanged() TextModified:%s TextEmpty:%s\n", IsTextModified()?"Y":"N", mText.empty()?"Y":"N"); + DALI_LOG_INFO(Debug::Filter::gResource, Debug::Verbose, "TextAttachment::TextChanged() TextModified:%s TextEmpty:%s\n", IsTextModified()?"Y":"N", ( 0u == mText.Count() )?"Y":"N"); if( !IsTextModified() ) { diff --git a/dali/internal/event/actor-attachments/text-attachment-impl.h b/dali/internal/event/actor-attachments/text-attachment-impl.h index 083e97c03..de16ee812 100644 --- a/dali/internal/event/actor-attachments/text-attachment-impl.h +++ b/dali/internal/event/actor-attachments/text-attachment-impl.h @@ -26,10 +26,10 @@ #include #include #include -#include #include #include #include +#include namespace Dali { @@ -59,19 +59,19 @@ public: * @param [in] font The font which will be used for the text. * @return A smart-pointer to the newly allocated TextAttachment. */ - static TextAttachmentPtr New( const SceneGraph::Node& parentNode, const TextArray& text, FontPointer font ); + static TextAttachmentPtr New( const SceneGraph::Node& parentNode, const Integration::TextArray& text, FontPointer font ); /** * Set the text label displayed by the attachment * @param [in] text The new text label */ - void SetText(const TextArray& text); + void SetText(const Integration::TextArray& text); /** * Get the text label displayed by the attachment * @return The text label */ - const TextArray& GetText() const + const Integration::TextArray& GetText() const { // This is not animatable; the cached value is up-to-date. return mText; @@ -389,7 +389,7 @@ private: ///< Font parameters are stored in the FontPointer member. Inside the TextStyle, font parameters and color are allocated in the same struct, ///< so store the text color in the style will allocate space for the font parameters as well, wasting space. // Cached values for public getters - TextArray mText; + Integration::TextArray mText; bool mTextChanged:1; ///< whether the text has changed bool mFontChanged:1; ///< whether the font has changed diff --git a/dali/internal/event/actors/text-actor-impl.cpp b/dali/internal/event/actors/text-actor-impl.cpp index c568f88b0..5ae192125 100644 --- a/dali/internal/event/actors/text-actor-impl.cpp +++ b/dali/internal/event/actors/text-actor-impl.cpp @@ -133,7 +133,7 @@ SignalConnectorType s1( mType, Dali::TextActor::SIGNAL_TEXT_LOADING_FINISHED, &T } -TextActorPtr TextActor::New( const TextArray& utfCodes, const TextActorParameters& parameters ) +TextActorPtr TextActor::New( const Integration::TextArray& utfCodes, const TextActorParameters& parameters ) { // first stage construction TextActorPtr actor ( new TextActor( parameters.IsAutomaticFontDetectionEnabled() ) ); @@ -146,7 +146,7 @@ TextActorPtr TextActor::New( const TextArray& utfCodes, const TextActorParameter actor->Initialize(); //create the attachment - actor->mTextAttachment = TextAttachment::New( *actor->mNode, TextArray(), fontPtr ); + actor->mTextAttachment = TextAttachment::New( *actor->mNode, Integration::TextArray(), fontPtr ); // Note: SetTextStyle() MUST be called before SetText(), to ensure // that a single ResourceRequest for the glyphs is made. Calling @@ -189,14 +189,15 @@ TextActor::~TextActor() const std::string TextActor::GetText() const { - const TextArray& utfCodes = mTextAttachment->GetText(); + const Integration::TextArray& utfCodes = mTextAttachment->GetText(); std::string text; + const std::size_t length = utfCodes.Count(); // minimize allocations for ascii strings - text.reserve(utfCodes.size()); + text.reserve( length ); - for (unsigned int i = 0; i < utfCodes.size(); ++i) + for (unsigned int i = 0; i < length; ++i) { unsigned char utf8Data[4]; unsigned int utf8Length; @@ -239,7 +240,7 @@ void TextActor::StartObservingTextLoads() } } -void TextActor::SetText(const TextArray& utfCodes) +void TextActor::SetText(const Integration::TextArray& utfCodes) { StopObservingTextLoads(); diff --git a/dali/internal/event/actors/text-actor-impl.h b/dali/internal/event/actors/text-actor-impl.h index 28fa08b9b..08494cddb 100644 --- a/dali/internal/event/actors/text-actor-impl.h +++ b/dali/internal/event/actors/text-actor-impl.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include namespace Dali @@ -57,7 +57,7 @@ public: * @see Dali::TextActor::New( const Text& text, const TextActorParameters& parameters ) * @return A pointer to a new TextActor. */ - static TextActorPtr New( const TextArray& utfCodes, const TextActorParameters& parameters ); + static TextActorPtr New( const Integration::TextArray& utfCodes, const TextActorParameters& parameters ); /** * @copydoc Dali::Internal::Actor::OnInitialize @@ -73,7 +73,7 @@ public: * @copybrief Dali::TextActor::SetText(const std::string&) * @param[in] utfCodes An std::vector containing the UTF-32 codes */ - void SetText(const TextArray& utfCodes); + void SetText(const Integration::TextArray& utfCodes); /** * @copydoc Dali::TextActor::SetToNaturalSize() diff --git a/dali/internal/event/text/atlas/atlas-rank-generator.cpp b/dali/internal/event/text/atlas/atlas-rank-generator.cpp index da3255364..90e524157 100644 --- a/dali/internal/event/text/atlas/atlas-rank-generator.cpp +++ b/dali/internal/event/text/atlas/atlas-rank-generator.cpp @@ -74,7 +74,7 @@ AtlasRanking::SpaceStatus GetAtlasSpaceStatus( bool canFit, bool atlasResizable } // un-named namespace -AtlasRanking GetAtlasRanking( const TextArray& text, +AtlasRanking GetAtlasRanking( const Integration::TextArray& text, FontId fontId, const GlyphStatusContainer& container, bool atlasResizable) @@ -85,7 +85,7 @@ AtlasRanking GetAtlasRanking( const TextArray& text, // find if the text will fit or not, and how many characters are missing container.GetTextStatus( text, fontId, charsNotLoaded, canFit); - AtlasRanking::CharacterMatch charMatchStatus = GetTextMatchStatus( text.size(), charsNotLoaded ); + AtlasRanking::CharacterMatch charMatchStatus = GetTextMatchStatus( text.Count(), charsNotLoaded ); AtlasRanking::SpaceStatus spaceStatus = GetAtlasSpaceStatus( canFit, atlasResizable); diff --git a/dali/internal/event/text/atlas/atlas-rank-generator.h b/dali/internal/event/text/atlas/atlas-rank-generator.h index d2e70674d..a59a97aae 100644 --- a/dali/internal/event/text/atlas/atlas-rank-generator.h +++ b/dali/internal/event/text/atlas/atlas-rank-generator.h @@ -38,7 +38,7 @@ namespace Internal * @param[in] atlasResizable whether the atlas is resizable * @return atlas ranking */ - AtlasRanking GetAtlasRanking( const TextArray& text, + AtlasRanking GetAtlasRanking( const Integration::TextArray& text, FontId fontId, const GlyphStatusContainer& container, bool atlasResizable); diff --git a/dali/internal/event/text/atlas/glyph-atlas-manager-interface.h b/dali/internal/event/text/atlas/glyph-atlas-manager-interface.h index 4556b36be..8e0959703 100644 --- a/dali/internal/event/text/atlas/glyph-atlas-manager-interface.h +++ b/dali/internal/event/text/atlas/glyph-atlas-manager-interface.h @@ -19,12 +19,12 @@ */ // INTERNAL INCLUDES -#include #include #include #include #include #include +#include namespace Dali { @@ -50,7 +50,7 @@ public: * @param[in] metric interface to get metric information for the text * @return text vertex buffer */ - virtual TextVertexBuffer* TextRequired( const TextArray& text, + virtual TextVertexBuffer* TextRequired( const Integration::TextArray& text, const TextFormat& format, FontMetricsInterface& metrics ) = 0; @@ -62,7 +62,7 @@ public: * @param[in] fontId font id * @param[in] textureId texture id (each atlas has a single texture) */ - virtual void TextNotRequired( const TextArray& text, + virtual void TextNotRequired( const Integration::TextArray& text, const TextFormat& format, FontId fontId, unsigned int textureId ) = 0; @@ -75,10 +75,10 @@ public: * @param[in] textureId texture id (each atlas has a single texture) * @return true if all characters are available, false if not */ - virtual bool IsTextLoaded( const TextArray& text, - const TextFormat& format, - FontId fontId, - unsigned int textureId) const = 0; + virtual bool IsTextLoaded( const Integration::TextArray& text, + const TextFormat& format, + FontId fontId, + unsigned int textureId) const = 0; /** diff --git a/dali/internal/event/text/atlas/glyph-atlas-manager.cpp b/dali/internal/event/text/atlas/glyph-atlas-manager.cpp index 3feab73ec..eabda3141 100644 --- a/dali/internal/event/text/atlas/glyph-atlas-manager.cpp +++ b/dali/internal/event/text/atlas/glyph-atlas-manager.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include namespace Dali @@ -43,14 +42,14 @@ GlyphAtlasManager::~GlyphAtlasManager() // Atlases automatically get destroyed. } -TextVertexBuffer* GlyphAtlasManager::TextRequired( const TextArray& text , +TextVertexBuffer* GlyphAtlasManager::TextRequired( const Integration::TextArray& text , const TextFormat& format, FontMetricsInterface& metrics ) { // get the font id FontId fontId = metrics.GetFontId(); - AtlasRanking bestRank( text.size() ); + AtlasRanking bestRank( text.Count() ); // find the atlas which is best suited to displaying the text string GlyphAtlas* atlas = FindAtlas( text, format, fontId, bestRank); @@ -67,7 +66,7 @@ TextVertexBuffer* GlyphAtlasManager::TextRequired( const TextArray& text , return atlas->AssignText( text, format, fontId, metrics ); } -void GlyphAtlasManager::TextNotRequired( const TextArray& text, +void GlyphAtlasManager::TextNotRequired( const Integration::TextArray& text, const TextFormat& format, FontId fontId, unsigned int textureId ) @@ -78,7 +77,7 @@ void GlyphAtlasManager::TextNotRequired( const TextArray& text, } -bool GlyphAtlasManager::IsTextLoaded( const TextArray& text, +bool GlyphAtlasManager::IsTextLoaded( const Integration::TextArray& text, const TextFormat& format, FontId fontId, unsigned int textureId ) const @@ -153,22 +152,22 @@ GlyphAtlas* GlyphAtlasManager::CreateAtlas( unsigned int size ) return atlas; } -GlyphAtlas* GlyphAtlasManager::FindAtlas( const TextArray& text, +GlyphAtlas* GlyphAtlasManager::FindAtlas( const Integration::TextArray& text, const TextFormat& format, FontId fontId, AtlasRanking &bestRank ) { // if the text is underlined, add the underline character to the text string - TextArray searchText( text ); + Integration::TextArray searchText( text ); if( format.IsUnderLined() ) { - searchText.push_back( format.GetUnderLineCharacter() ); + searchText.PushBack( format.GetUnderLineCharacter() ); } if( mAtlasList.Count() == 0 ) { // make sure the initial atlas size holds the requested text. - unsigned int size = GlyphAtlasSize::GetInitialSize( searchText.size() ); + unsigned int size = GlyphAtlasSize::GetInitialSize( searchText.Count() ); return CreateAtlas( size ); } diff --git a/dali/internal/event/text/atlas/glyph-atlas-manager.h b/dali/internal/event/text/atlas/glyph-atlas-manager.h index 6260f2a6b..958d66b54 100644 --- a/dali/internal/event/text/atlas/glyph-atlas-manager.h +++ b/dali/internal/event/text/atlas/glyph-atlas-manager.h @@ -19,7 +19,6 @@ */ // INTERNAL INCLUDES -#include #include #include #include @@ -67,14 +66,14 @@ public: // for GlyphAtlasManagerInterface /** * @copydoc GlyphAtlasManagerInterface::TextRequired() */ - virtual TextVertexBuffer* TextRequired( const TextArray& text, + virtual TextVertexBuffer* TextRequired( const Integration::TextArray& text, const TextFormat& format, FontMetricsInterface& metrics ); /** * @copydoc GlyphAtlasManagerInterface::TextNotRequired() */ - virtual void TextNotRequired( const TextArray& text, + virtual void TextNotRequired( const Integration::TextArray& text, const TextFormat& format, FontId font, unsigned int textureId ); @@ -82,7 +81,7 @@ public: // for GlyphAtlasManagerInterface /** * @copydoc GlyphAtlasManagerInterface::IsTextLoaded() */ - virtual bool IsTextLoaded( const TextArray& text, + virtual bool IsTextLoaded( const Integration::TextArray& text, const TextFormat& format, FontId fontId, unsigned int textureId) const; @@ -142,7 +141,7 @@ private: * @param[in,out] the ranking for the atlas that is found * @return atlas */ - GlyphAtlas* FindAtlas( const TextArray& text , + GlyphAtlas* FindAtlas( const Integration::TextArray& text , const TextFormat& format, FontId fontId, AtlasRanking& bestRank); diff --git a/dali/internal/event/text/atlas/glyph-atlas.cpp b/dali/internal/event/text/atlas/glyph-atlas.cpp index 6c24d09e0..cf00962b8 100644 --- a/dali/internal/event/text/atlas/glyph-atlas.cpp +++ b/dali/internal/event/text/atlas/glyph-atlas.cpp @@ -42,7 +42,7 @@ GlyphAtlas::~GlyphAtlas() { } -TextVertexBuffer* GlyphAtlas::AssignText( const TextArray& text, +TextVertexBuffer* GlyphAtlas::AssignText( const Integration::TextArray& text, const TextFormat &format, FontId fontId, FontMetricsInterface& metrics ) @@ -60,12 +60,12 @@ TextVertexBuffer* GlyphAtlas::AssignText( const TextArray& text, return textBuffer; } -void GlyphAtlas::TextNoLongerUsed( const TextArray& text, const TextFormat &format, FontId fontId ) +void GlyphAtlas::TextNoLongerUsed( const Integration::TextArray& text, const TextFormat &format, FontId fontId ) { // go through each character un-referencing it - for( std::size_t i = 0, size = text.size(); i < size; ++i) + for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) { - mGlyphContainer.DecreaseRefCount( text[i], fontId ); + mGlyphContainer.DecreaseRefCount( *it, fontId ); } if( format.IsUnderLined() ) @@ -74,7 +74,7 @@ void GlyphAtlas::TextNoLongerUsed( const TextArray& text, const TextFormat &form } } -AtlasRanking GlyphAtlas::GetRanking( const TextArray& text , FontId fontId ) const +AtlasRanking GlyphAtlas::GetRanking( const Integration::TextArray& text , FontId fontId ) const { return GetAtlasRanking( text, fontId, mGlyphContainer, Resizable() ); } @@ -104,13 +104,13 @@ void GlyphAtlas::ClearRequestLists() mRequestList.clear(); } -bool GlyphAtlas::IsTextLoaded( const TextArray& text, const TextFormat &format, FontId fontId) const +bool GlyphAtlas::IsTextLoaded( const Integration::TextArray& text, const TextFormat &format, FontId fontId) const { // check the underline character is needed / loaded first if( format.IsUnderLined() ) { - TextArray tempText; - tempText.push_back( format.GetUnderLineCharacter() ); + Integration::TextArray tempText; + tempText.PushBack( format.GetUnderLineCharacter() ); bool loaded = mGlyphContainer.IsTextLoaded( tempText, fontId ); if( !loaded ) @@ -168,12 +168,12 @@ void GlyphAtlas::ClearDeadCharacters() // but have a reference count of zero. // go through each dead character, marking them as de-allocated in the atlas - std::vector< unsigned int > deadCharacters; + Integration::TextArray deadCharacters; mGlyphContainer.GetDeadCharacters( deadCharacters ); - for( std::size_t i = 0; i < deadCharacters.size() ; ++i ) + for( Integration::TextArray::ConstIterator it = deadCharacters.Begin(), endIt = deadCharacters.End(); it != endIt; ++it ) { - mAtlas.Remove( deadCharacters[i]); + mAtlas.Remove( *it ); } // clear the dead characters from the glyph container @@ -278,16 +278,16 @@ void GlyphAtlas::GetNewTextureId( std::vector& oldTextureIds , uns mTextureIdOfReplacedAtlases.clear(); } -void GlyphAtlas::ReferenceText( const TextArray& text, - const TextFormat &format, - FontId fontId) +void GlyphAtlas::ReferenceText( const Integration::TextArray& text, + const TextFormat &format, + FontId fontId) { // go through each character, if it exists increase it's ref count. - for( std::size_t i = 0, size = text.size(); i < size; ++i) + for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) { // this will automatically load the character if it doesn't exist - IncreaseGlyphRefCount( text[i], fontId ); + IncreaseGlyphRefCount( *it, fontId ); } if( format.IsUnderLined() ) diff --git a/dali/internal/event/text/atlas/glyph-atlas.h b/dali/internal/event/text/atlas/glyph-atlas.h index de6639a7e..f804d7a43 100644 --- a/dali/internal/event/text/atlas/glyph-atlas.h +++ b/dali/internal/event/text/atlas/glyph-atlas.h @@ -21,12 +21,12 @@ // INTERNAL INCLUDES #include #include -#include #include #include #include #include #include +#include namespace Dali { @@ -87,7 +87,7 @@ public: * @param[in] fontId the font id * @param[in] metrics font metrics interface */ - TextVertexBuffer* AssignText( const TextArray& text, const TextFormat &format, FontId fontId, FontMetricsInterface& metrics ); + TextVertexBuffer* AssignText( const Integration::TextArray& text, const TextFormat &format, FontId fontId, FontMetricsInterface& metrics ); /** * Inform the atlas that text is no longer used @@ -95,7 +95,7 @@ public: * @param[in] format the text format * @param[in] fontId the font id */ - void TextNoLongerUsed( const TextArray& text, const TextFormat &format, FontId fontId ); + void TextNoLongerUsed( const Integration::TextArray& text, const TextFormat &format, FontId fontId ); /** * Given a text string, returns an atlas ranking. @@ -104,7 +104,7 @@ public: * @param[in] fontId the font id * @return atlas ranking */ - AtlasRanking GetRanking( const TextArray& text , FontId fontId ) const; + AtlasRanking GetRanking( const Integration::TextArray& text , FontId fontId ) const; /** * Get the atlas size @@ -142,7 +142,7 @@ public: * @param[in] fontId the font id * @return true if the text is loaded */ - bool IsTextLoaded( const TextArray& text, const TextFormat &format, FontId fontId) const; + bool IsTextLoaded( const Integration::TextArray& text, const TextFormat &format, FontId fontId) const; /** * Clone the contents of the atlas into this atlas @@ -208,9 +208,9 @@ private: * @param[in] format the text format * @param[in] fontId font id */ - void ReferenceText( const TextArray& text, - const TextFormat &format, - FontId fontId); + void ReferenceText( const Integration::TextArray& text, + const TextFormat &format, + FontId fontId); /** * Increase glyph reference count. diff --git a/dali/internal/event/text/font-factory.h b/dali/internal/event/text/font-factory.h index ffbd0ff84..3974b6fe9 100644 --- a/dali/internal/event/text/font-factory.h +++ b/dali/internal/event/text/font-factory.h @@ -22,7 +22,6 @@ #include #include #include -#include namespace Dali { diff --git a/dali/internal/event/text/font-impl.cpp b/dali/internal/event/text/font-impl.cpp index dbf770892..c510a19ad 100644 --- a/dali/internal/event/text/font-impl.cpp +++ b/dali/internal/event/text/font-impl.cpp @@ -79,11 +79,11 @@ bool Font::operator==( const Font& font ) const return ( font.GetResourceId() == GetResourceId() ) && ( fabsf( font.GetPointSize() - GetPointSize() ) < Math::MACHINE_EPSILON_1000 ); } -const std::string Font::GetFamilyForText(const TextArray& text) +const std::string Font::GetFamilyForText(const Integration::TextArray& text) { Integration::PlatformAbstraction& platform = ThreadLocalStorage::Get().GetPlatformAbstraction(); // this is a synchronous request - return platform.GetFontFamilyForChars(text); + return platform.GetFontFamilyForChars( text ); } PixelSize Font::GetLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, const CapsHeight& capsHeight) @@ -133,7 +133,7 @@ void Font::GetInstalledFonts( Dali::Font::FontListMode mode, std::vectorGetFontId(); } -float Font::MeasureTextWidth(const TextArray& text, float textHeightPx) const +float Font::MeasureTextWidth(const Integration::TextArray& text, float textHeightPx) const { Vector3 size = MeasureText(text); @@ -159,7 +159,7 @@ float Font::MeasureTextWidth(const TextArray& text, float textHeightPx) const return width; } -float Font::MeasureTextHeight(const TextArray& text, float textWidthPx) const +float Font::MeasureTextHeight(const Integration::TextArray& text, float textWidthPx) const { Vector3 size = MeasureText(text); @@ -174,7 +174,7 @@ float Font::MeasureTextHeight(const TextArray& text, float textWidthPx) const return height; } -Vector3 Font::MeasureText(const TextArray& text) const +Vector3 Font::MeasureText(const Integration::TextArray& text) const { if (mMetrics) { @@ -246,8 +246,8 @@ float Font::GetUnitsToPixels() const void Font::GetMetrics(const Dali::Character& character, Dali::Font::Metrics::Impl& metricsImpl) const { - TextArray text; - text.push_back( character.GetImplementation().GetCharacter() ); + Integration::TextArray text; + text.PushBack( character.GetImplementation().GetCharacter() ); mMetrics->GetMetrics( character, metricsImpl ); @@ -324,13 +324,13 @@ void Font::RemoveObserver(TextObserver& observer) mAtlasManager.RemoveTextObserver(observer); } -TextVertexBuffer* Font::TextRequired( const TextArray& text, const TextFormat& format) +TextVertexBuffer* Font::TextRequired( const Integration::TextArray& text, const TextFormat& format) { // make sure the metrics are loaded for the text string, along with underline character if required if( format.IsUnderLined() ) { - TextArray underline; - underline.push_back( SpecialCharacters::UNDERLINE_CHARACTER ); + Integration::TextArray underline; + underline.PushBack( SpecialCharacters::UNDERLINE_CHARACTER ); mMetrics->LoadMetricsSynchronously( underline ); } @@ -341,7 +341,7 @@ TextVertexBuffer* Font::TextRequired( const TextArray& text, const TextFormat& f return mAtlasManager.TextRequired(text, format, *(mMetrics.Get())); } -void Font::TextNotRequired( const TextArray& text, const TextFormat& format, unsigned int mTextureId ) +void Font::TextNotRequired( const Integration::TextArray& text, const TextFormat& format, unsigned int mTextureId ) { // let the atlas manager we no longer need the text mAtlasManager.TextNotRequired( text, format, mMetrics->GetFontId(), mTextureId ); @@ -357,7 +357,7 @@ void Font::RemoveTextureObserver(GlyphTextureObserver& observer ) mAtlasManager.RemoveTextureObserver( observer ); } -bool Font::IsTextLoaded( const TextArray& text, const TextFormat& format, unsigned int textureId ) const +bool Font::IsTextLoaded( const Integration::TextArray& text, const TextFormat& format, unsigned int textureId ) const { return mAtlasManager.IsTextLoaded( text, format, mMetrics->GetFontId(), textureId ); } diff --git a/dali/internal/event/text/font-impl.h b/dali/internal/event/text/font-impl.h index 7c9438620..7645f8a5e 100644 --- a/dali/internal/event/text/font-impl.h +++ b/dali/internal/event/text/font-impl.h @@ -26,13 +26,12 @@ #include #include #include -#include #include #include #include #include - #include +#include namespace Dali { @@ -83,7 +82,7 @@ public: /** * @copydoc Dali::Font::GetFamilyForText() */ - static const std::string GetFamilyForText(const TextArray& text); + static const std::string GetFamilyForText(const Integration::TextArray& text); /** * @copydoc Dali::Font::GetLineHeightFromCapsHeight() @@ -98,7 +97,7 @@ public: /** * @copydoc Dali::Font::AllGlyphsSupported() */ - bool AllGlyphsSupported(const TextArray& text) const; + bool AllGlyphsSupported(const Integration::TextArray& text) const; /** * returns the Id used for lookups @@ -109,17 +108,17 @@ public: /** * @copydoc Dali::Font::MeasureTextWidth() */ - float MeasureTextWidth(const TextArray& text, float textHeightPx) const; + float MeasureTextWidth(const Integration::TextArray& text, float textHeightPx) const; /** * @copydoc Dali::Font::MeasureTextHeight() */ - float MeasureTextHeight(const TextArray& text, float textWidthPx) const; + float MeasureTextHeight(const Integration::TextArray& text, float textWidthPx) const; /** * @copydoc Dali::Font::MeasureText(const Text& text) const */ - Vector3 MeasureText(const TextArray& text) const; + Vector3 MeasureText(const Integration::TextArray& text) const; /** * @copydoc Dali::Font::IsDefaultSystemFont() @@ -223,12 +222,12 @@ public: /** * @copydoc GlyphAtlasManagerInterface::TextRequired() */ - TextVertexBuffer* TextRequired( const TextArray& text, const TextFormat& format ); + TextVertexBuffer* TextRequired( const Integration::TextArray& text, const TextFormat& format ); /** * @copydoc GlyphAtlasManagerInterface::TextNotRequired() */ - void TextNotRequired( const TextArray& text, const TextFormat& format, unsigned int textureId ); + void TextNotRequired( const Integration::TextArray& text, const TextFormat& format, unsigned int textureId ); /** * Add a glyph texture observer @@ -249,7 +248,7 @@ public: * @param[in] textureId texture ID of the atlas * @return true if all characters are available, false if not */ - bool IsTextLoaded( const TextArray& text, const TextFormat& format, unsigned int textureId ) const; + bool IsTextLoaded( const Integration::TextArray& text, const TextFormat& format, unsigned int textureId ) const; private: diff --git a/dali/internal/event/text/font-metrics-interface.h b/dali/internal/event/text/font-metrics-interface.h index c690b934f..336278879 100644 --- a/dali/internal/event/text/font-metrics-interface.h +++ b/dali/internal/event/text/font-metrics-interface.h @@ -21,7 +21,7 @@ // INTERNAL INCLUDES #include #include -#include +#include // EXTERNAL INCLUDES #include @@ -46,7 +46,7 @@ public: * Ensures the metrics for each character in the text are loaded and cached. * @param[in] text The text string to load the metrics for. */ - virtual void LoadMetricsSynchronously( const TextArray& text ) = 0; + virtual void LoadMetricsSynchronously( const Integration::TextArray& text ) = 0; /** * Gets the metrics for a single character. diff --git a/dali/internal/event/text/font-metrics.cpp b/dali/internal/event/text/font-metrics.cpp index 7541eb0b3..f656d8343 100644 --- a/dali/internal/event/text/font-metrics.cpp +++ b/dali/internal/event/text/font-metrics.cpp @@ -46,12 +46,12 @@ const uint32_t FIRST_NON_CONTROL_CHAR( 0x20 ); // 0x20 is the white space which const uint32_t LINE_SEPARATOR( '\n' ); -TextArray GetUniqueCharacters( const TextArray &text ) +Integration::TextArray GetUniqueCharacters( const Integration::TextArray& text ) { - TextArray utfCodes(text.begin(), text.end()); - std::sort( utfCodes.begin(), utfCodes.end() ); - TextArray::iterator it = std::unique( utfCodes.begin(), utfCodes.end() ); - utfCodes.resize(it - utfCodes.begin()); + Integration::TextArray utfCodes = text; + std::sort( utfCodes.Begin(), utfCodes.End() ); + Integration::TextArray::Iterator it = std::unique( utfCodes.Begin(), utfCodes.End() ); + utfCodes.Resize( it - utfCodes.Begin() ); return utfCodes; } @@ -88,13 +88,14 @@ void FontMetrics::LoadGlobalMetrics() } } -Vector3 FontMetrics::MeasureText( const TextArray& text ) +Vector3 FontMetrics::MeasureText( const Integration::TextArray& text ) { - if( text.empty() ) + if( 0u == text.Count() ) { return Vector3::ZERO; } - TextArray utfCodes = GetUniqueCharacters( text ); + + Integration::TextArray utfCodes = GetUniqueCharacters( text ); // ensure all the metrics are loaded for the characters LoadMetricsSynchronously( utfCodes ); @@ -106,7 +107,7 @@ Vector3 FontMetrics::MeasureText( const TextArray& text ) float xPos = 0.0f; - for( TextArray::const_iterator it = text.begin(), endIt = text.end(); it != endIt; ++it ) + for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) { const uint32_t utfCode( *it ); @@ -132,11 +133,11 @@ Vector3 FontMetrics::MeasureText( const TextArray& text ) return measurement; } -bool FontMetrics::TextAvailable( const TextArray& text ) const +bool FontMetrics::TextAvailable( const Integration::TextArray& text ) const { TCharMap::const_iterator endIter = mCharMap.end(); - for( TextArray::const_iterator it = text.begin(), endIt = text.end(); it != endIt; ++it ) + for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) { const uint32_t utfCode( *it ); @@ -150,14 +151,14 @@ bool FontMetrics::TextAvailable( const TextArray& text ) const return true; } -unsigned int FontMetrics::GetMissingText( const TextArray& text, CharacterList& missingText ) const +unsigned int FontMetrics::GetMissingText( const Integration::TextArray& text, CharacterList& missingText ) const { // sort and remove duplicate character codes - TextArray utfCodes( GetUniqueCharacters(text) ); + Integration::TextArray utfCodes( GetUniqueCharacters(text) ); // scan through the metrics cache, making a list of characters that are missing TCharMap::const_iterator endIter = mCharMap.end(); - for( TextArray::const_iterator it = utfCodes.begin(), endIt = utfCodes.end(); it != endIt; ++it ) + for( Integration::TextArray::ConstIterator it = utfCodes.Begin(), endIt = utfCodes.End(); it != endIt; ++it ) { const uint32_t utfCode( *it ); @@ -170,7 +171,7 @@ unsigned int FontMetrics::GetMissingText( const TextArray& text, CharacterList& return missingText.size(); } -void FontMetrics::LoadMetricsSynchronously( const TextArray& text ) +void FontMetrics::LoadMetricsSynchronously( const Integration::TextArray& text ) { // check to make sure the metrics cache has loaded CheckMetricsLoaded(); @@ -300,8 +301,8 @@ float FontMetrics::GetPadAdjustY() const void FontMetrics::GetMetrics( const Dali::Character& character, Dali::Font::Metrics::Impl& metrics ) { - TextArray utfCodes; - utfCodes.push_back( character.GetImplementation().GetCharacter() ); + Integration::TextArray utfCodes; + utfCodes.PushBack( character.GetImplementation().GetCharacter() ); LoadMetricsSynchronously( utfCodes ); diff --git a/dali/internal/event/text/font-metrics.h b/dali/internal/event/text/font-metrics.h index 253af01b2..b3e28e51f 100644 --- a/dali/internal/event/text/font-metrics.h +++ b/dali/internal/event/text/font-metrics.h @@ -27,11 +27,11 @@ #include #include #include -#include #include #include #include #include +#include namespace Dali { @@ -110,14 +110,14 @@ public: * @param[in] text The text string to measure. * @return The natural size of the text. */ - Vector3 MeasureText(const TextArray& text); + Vector3 MeasureText(const Integration::TextArray& text); /** * Check if all characters in a string are currently in the font * @param[in] text The string to check * @return true if all characters are currently in the font */ - bool TextAvailable (const TextArray& text) const; + bool TextAvailable (const Integration::TextArray& text) const; /** * Given a text array, checks which characters have their metrics loaded. @@ -126,14 +126,14 @@ public: * @param[out] missingText Characters from text not contained in this font. * @return number of characters that have not had their metrics loaded */ - unsigned int GetMissingText(const TextArray& text, CharacterList& missingText ) const; + unsigned int GetMissingText(const Integration::TextArray& text, CharacterList& missingText ) const; public: // for FontMetricsInterface /** * @copydoc FontMetricsInterface::LoadMetricsSynchronously */ - virtual void LoadMetricsSynchronously( const TextArray& text ); + virtual void LoadMetricsSynchronously( const Integration::TextArray& text ); /** * @copydoc FontMetricsInterface::GetGlyph() diff --git a/dali/internal/event/text/generator/text-vertex-generator.cpp b/dali/internal/event/text/generator/text-vertex-generator.cpp index 05f287225..1498c46f8 100644 --- a/dali/internal/event/text/generator/text-vertex-generator.cpp +++ b/dali/internal/event/text/generator/text-vertex-generator.cpp @@ -298,7 +298,7 @@ void DebugVertexBuffer( VertexBuffer& buffer ) } // unnamed namespace -TextVertexBuffer* TextVertexGenerator::Generate( const TextArray& text, +TextVertexBuffer* TextVertexGenerator::Generate( const Integration::TextArray& text, const TextFormat& format, const FontMetricsInterface& metrics, const AtlasUvInterface& uvInterface, @@ -332,7 +332,7 @@ TextVertexBuffer* TextVertexGenerator::Generate( const TextArray& text, const float tileWidth( metrics.GetMaxWidth() * scalar ); const float tileHeight( metrics.GetMaxHeight() * scalar ); - for( TextArray::const_iterator it = text.begin(), endIt = text.end(); it != endIt; ++it ) + for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) { const uint32_t charIndex = *it; @@ -416,7 +416,7 @@ TextVertexBuffer* TextVertexGenerator::Generate( const TextArray& text, #endif DALI_LOG_INFO(gTextVertsLogFilter, Debug::General, "TextVertexBuffer for %c%c%c...: Calculated Extents:(%5.2f, %5.2f)\n Geometry Extents:(%5.2f, %5.2f )\n", - text.size()>0?(char)text[0]:' ', text.size()>1?(char)text[1]:' ', text.size()>2?(char)text[2]:' ', + text.Count()>0?(char)text[0]:' ', text.Count()>1?(char)text[1]:' ', text.Count()>2?(char)text[2]:' ', textVertexBuffer->mVertexMax.x,textVertexBuffer->mVertexMax.y, textVertexBuffer->mGeometryExtent.width,textVertexBuffer->mGeometryExtent.height); diff --git a/dali/internal/event/text/generator/text-vertex-generator.h b/dali/internal/event/text/generator/text-vertex-generator.h index cbe26d245..97c611db3 100644 --- a/dali/internal/event/text/generator/text-vertex-generator.h +++ b/dali/internal/event/text/generator/text-vertex-generator.h @@ -21,12 +21,12 @@ // EXTERNAL INCLUDES // INTERNAL INCLUDES -#include #include #include #include #include #include +#include namespace Dali { @@ -52,7 +52,7 @@ namespace TextVertexGenerator * @param[in] fontId the font id * @return text vertex buffer */ - TextVertexBuffer* Generate(const TextArray& text, + TextVertexBuffer* Generate(const Integration::TextArray& text, const TextFormat& format, const FontMetricsInterface& metrics, const AtlasUvInterface& uvInterface, diff --git a/dali/internal/event/text/glyph-status/glyph-status-container.cpp b/dali/internal/event/text/glyph-status/glyph-status-container.cpp index 2ee41aca4..eae2d2b2e 100644 --- a/dali/internal/event/text/glyph-status/glyph-status-container.cpp +++ b/dali/internal/event/text/glyph-status/glyph-status-container.cpp @@ -38,13 +38,13 @@ namespace // un-named namespace /** * @return the unique characters in a text array */ -TextArray GetUniqueCharacters( const TextArray &text ) +Integration::TextArray GetUniqueCharacters( const Integration::TextArray &text ) { - TextArray utfCodes( text ); + Integration::TextArray utfCodes( text ); - std::sort( utfCodes.begin(), utfCodes.end() ); - TextArray::iterator it = std::unique( utfCodes.begin(), utfCodes.end() ); - utfCodes.resize(it - utfCodes.begin()); + std::sort( utfCodes.Begin(), utfCodes.End() ); + Integration::TextArray::Iterator it = std::unique( utfCodes.Begin(), utfCodes.End() ); + utfCodes.Resize(it - utfCodes.Begin()); return utfCodes; } @@ -191,11 +191,11 @@ const GlyphStatusContainer::StatusSet& GlyphStatusContainer::GetStatusSet() cons return mCharacterLookup; } -bool GlyphStatusContainer::IsTextLoaded( const TextArray& text, FontId fontId) const +bool GlyphStatusContainer::IsTextLoaded( const Integration::TextArray& text, FontId fontId ) const { - for( std::size_t n = 0, size = text.size(); n < size; ++n) + for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) { - uint32_t charCode = text[n]; + const uint32_t charCode = *it; // ignore invisible characters if( charCode < SpecialCharacters::FIRST_VISIBLE_CHAR ) @@ -212,7 +212,7 @@ bool GlyphStatusContainer::IsTextLoaded( const TextArray& text, FontId fontId) c return true; } -void GlyphStatusContainer::GetTextStatus( const TextArray& text, +void GlyphStatusContainer::GetTextStatus( const Integration::TextArray& text, FontId fontId, unsigned int& charsNotLoaded, bool& fitsInContainer ) const @@ -220,11 +220,11 @@ void GlyphStatusContainer::GetTextStatus( const TextArray& text, charsNotLoaded = 0; fitsInContainer = false; - TextArray uniqueText = GetUniqueCharacters( text ); + Integration::TextArray uniqueText = GetUniqueCharacters( text ); - for( std::size_t n = 0, size = uniqueText.size(); n < size; ++n) + for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) { - uint32_t charCode = uniqueText[n]; + const uint32_t charCode = *it; // ignore invisible characters if( charCode < SpecialCharacters::FIRST_VISIBLE_CHAR ) @@ -270,9 +270,9 @@ void GlyphStatusContainer::CloneContents( const GlyphStatusContainer& clone ) } -void GlyphStatusContainer::GetDeadCharacters( std::vector< unsigned int >& deadList ) +void GlyphStatusContainer::GetDeadCharacters( Integration::TextArray& deadList ) { - deadList.reserve( mDeadCharacters.size() ); + deadList.Reserve( mDeadCharacters.size() ); // iterate through the dead character list @@ -280,7 +280,7 @@ void GlyphStatusContainer::GetDeadCharacters( std::vector< unsigned int >& deadL for( StatusPointerSet::iterator iter = mDeadCharacters.begin(); iter != endIter; ++iter ) { const GlyphStatus* glyphStatus(*iter); - deadList.push_back( glyphStatus->GetUniqueId()); + deadList.PushBack( glyphStatus->GetUniqueId()); } } diff --git a/dali/internal/event/text/glyph-status/glyph-status-container.h b/dali/internal/event/text/glyph-status/glyph-status-container.h index a665b3e80..76537e30a 100644 --- a/dali/internal/event/text/glyph-status/glyph-status-container.h +++ b/dali/internal/event/text/glyph-status/glyph-status-container.h @@ -21,7 +21,7 @@ // INTERNAL INCLUDES #include #include -#include +#include namespace Dali { @@ -129,7 +129,7 @@ public: * @param[in] fontId font id * @return true if all characters are loaded false if not */ - bool IsTextLoaded( const TextArray& text, FontId fontId) const; + bool IsTextLoaded( const Integration::TextArray& text, FontId fontId) const; /** * Given a text array, find how many character are loaded and @@ -139,7 +139,7 @@ public: * @param[out] charsNotLoaded how many characters are not loaded * @param[out] fitsInContainer whether the text fits in the container */ - void GetTextStatus( const TextArray& text, + void GetTextStatus( const Integration::TextArray& text, FontId fontId, unsigned int& charsNotLoaded, bool& fitsInContainer ) const; @@ -154,7 +154,7 @@ public: * Get the list of dead characters * @param[out] deadList to be filled with a list of dead characters */ - void GetDeadCharacters( std::vector< unsigned int >& deadList ); + void GetDeadCharacters( Integration::TextArray& deadList ); /** * Clear dead characters. diff --git a/dali/internal/event/text/text-impl.cpp b/dali/internal/event/text/text-impl.cpp index b42b224a0..7b2650a6d 100644 --- a/dali/internal/event/text/text-impl.cpp +++ b/dali/internal/event/text/text-impl.cpp @@ -19,11 +19,12 @@ #include // INTERNAL INCLUDES - -#include #include #include +// EXTERNAL INCLUDES +#include + namespace Dali { @@ -32,7 +33,7 @@ namespace Internal namespace { -static const TextArray VOID_TEXT_ARRAY; ///< A void text array to be used in the helper Internal::GetTextArray() function. +static const Integration::TextArray VOID_TEXT_ARRAY; ///< A void text array to be used in the helper Internal::GetTextArray() function. } // namespace Text::Text() @@ -43,17 +44,19 @@ Text::Text() Text::Text( const std::string& text ) : mString() { + const std::size_t length = text.size(); + // minimize allocations for ascii strings - mString.reserve( text.size() ); + mString.Reserve( length ); // break string into UTF-8 tokens - UTF8Tokenize( reinterpret_cast( text.c_str() ), text.size(), mString ); + UTF8Tokenize( reinterpret_cast( text.c_str() ), length, mString ); } Text::Text( const Character& character ) : mString() { - mString.push_back( character.GetCharacter() ); + mString.PushBack( character.GetCharacter() ); } Text::Text( const Text& text ) @@ -64,9 +67,9 @@ Text::Text( const Text& text ) void Text::GetText( std::string& text ) const { // minimize allocations for ascii strings - text.reserve( mString.size() ); + text.reserve( mString.Count() ); - for( TextArray::const_iterator it = mString.begin(), endIt = mString.end(); it != endIt; ++it ) + for( Integration::TextArray::ConstIterator it = mString.Begin(), endIt = mString.End(); it != endIt; ++it ) { unsigned char utf8Data[4]; unsigned int utf8Length; @@ -87,18 +90,19 @@ Text& Text::operator=( const Text& text ) Text::~Text() { Clear(); + mString.Release(); } void Text::Clear() { - mString.clear(); + mString.Clear(); } Dali::Character Text::operator[]( size_t position ) const { - DALI_ASSERT_ALWAYS( position < mString.size() && "Text::operator[]: Character position is out of bounds" ); + DALI_ASSERT_ALWAYS( position < mString.Count() && "Text::operator[]: Character position is out of bounds" ); - const uint32_t c = *( mString.begin() + position ); + const uint32_t c = *( mString.Begin() + position ); Dali::Character character( new Character( c ) ); @@ -107,34 +111,34 @@ Dali::Character Text::operator[]( size_t position ) const bool Text::IsEmpty() const { - return mString.empty(); + return 0u == mString.Count(); } size_t Text::GetLength() const { - return mString.size(); + return mString.Count(); } void Text::Append( const Dali::Text& text ) { - const TextArray& utfCodes = text.GetImplementation().GetTextArray(); + const Integration::TextArray& utfCodes = text.GetImplementation().GetTextArray(); - mString.insert( mString.end(), utfCodes.begin(), utfCodes.end() ); + mString.Insert( mString.End(), utfCodes.Begin(), utfCodes.End() ); } void Text::Remove( size_t position, size_t numberOfCharacters ) { - DALI_ASSERT_ALWAYS( position < mString.size() && "Text::Remove: Character position is out of bounds" ); - DALI_ASSERT_ALWAYS( position + numberOfCharacters <= mString.size() && "Text::Remove: Character position + numberOfCharacters is out of bounds" ); + DALI_ASSERT_ALWAYS( position < mString.Count() && "Text::Remove: Character position is out of bounds" ); + DALI_ASSERT_ALWAYS( position + numberOfCharacters <= mString.Count() && "Text::Remove: Character position + numberOfCharacters is out of bounds" ); - mString.erase( mString.begin() + position, mString.begin() + position + numberOfCharacters ); + mString.Erase( mString.Begin() + position, mString.Begin() + position + numberOfCharacters ); } void Text::Find( uint32_t character, std::size_t from, std::size_t to, Vector& positions ) const { std::size_t position = from; - for( TextArray::const_iterator it = mString.begin() + from, endIt = mString.begin() + to + 1u; it != endIt; ++position, ++it ) + for( Integration::TextArray::ConstIterator it = mString.Begin() + from, endIt = mString.Begin() + to + 1u; it != endIt; ++position, ++it ) { if( *it == character ) { @@ -147,7 +151,7 @@ void Text::FindWhiteSpace( std::size_t from, std::size_t to, Vector { std::size_t position = from; - for( TextArray::const_iterator it = mString.begin() + from, endIt = mString.begin() + to + 1u; it != endIt; ++position, ++it ) + for( Integration::TextArray::ConstIterator it = mString.Begin() + from, endIt = mString.Begin() + to + 1u; it != endIt; ++position, ++it ) { if( Character::IsWhiteSpace( *it ) ) { @@ -160,7 +164,7 @@ void Text::FindNewLine( std::size_t from, std::size_t to, Vector& p { std::size_t position = from; - for( TextArray::const_iterator it = mString.begin() + from, endIt = mString.begin() + to + 1u; it != endIt; ++position, ++it ) + for( Integration::TextArray::ConstIterator it = mString.Begin() + from, endIt = mString.Begin() + to + 1u; it != endIt; ++position, ++it ) { if( Character::IsNewLine( *it ) ) { @@ -173,22 +177,21 @@ void Text::GetSubText( std::size_t from, std::size_t to, Text* subText ) const { if( to < from ) { - const std::size_t length = mString.size(); - const std::size_t rfrom = length - ( from + 1u ); - const std::size_t rto = length - to; - subText->mString.insert( subText->mString.end(), mString.rbegin() + rfrom, mString.rbegin() + rto ); + std::swap( from, to ); + subText->mString.Insert( subText->mString.End(), mString.Begin() + from, mString.Begin() + to + 1u ); + std::reverse( subText->mString.Begin(), subText->mString.End() ); } else { - subText->mString.insert( subText->mString.end(), mString.begin() + from, mString.begin() + to + 1u ); + subText->mString.Insert( subText->mString.End(), mString.Begin() + from, mString.Begin() + to + 1u ); } } bool Text::IsWhiteSpace( std::size_t index ) const { - if( index < mString.size() ) + if( index < mString.Count() ) { - return Character::IsWhiteSpace( *( mString.begin() + index ) ); + return Character::IsWhiteSpace( *( mString.Begin() + index ) ); } return false; @@ -196,20 +199,20 @@ bool Text::IsWhiteSpace( std::size_t index ) const bool Text::IsNewLine( std::size_t index ) const { - if( index < mString.size() ) + if( index < mString.Count() ) { - return Character::IsNewLine( *( mString.begin() + index ) ); + return Character::IsNewLine( *( mString.Begin() + index ) ); } return false; } -const TextArray& Text::GetTextArray() const +const Integration::TextArray& Text::GetTextArray() const { return mString; } -const TextArray& GetTextArray( const Dali::Text& text ) +const Integration::TextArray& GetTextArray( const Dali::Text& text ) { if( text.IsEmpty() ) { diff --git a/dali/internal/event/text/text-impl.h b/dali/internal/event/text/text-impl.h index 475e3250b..96157cf34 100644 --- a/dali/internal/event/text/text-impl.h +++ b/dali/internal/event/text/text-impl.h @@ -23,7 +23,7 @@ // INTERNAL INCLUDES #include -#include +#include namespace Dali { @@ -139,21 +139,21 @@ public: * Retrieves a reference to the UTF-32 encoded string. * @return A reference to the UTF-32 encoded string. */ - const TextArray& GetTextArray() const; + const Integration::TextArray& GetTextArray() const; private: - TextArray mString; ///< Stores an array of unicodes. + Integration::TextArray mString; ///< Stores an array of unicodes. }; /** - * @brief Helper function to get the TextArray from a Dali::Text. + * @brief Helper function to get the Integration::TextArray from a Dali::Text. * * @param[in] text A Dali::Text. * - * @return The Text's TextArray. + * @return The Text's Integration::TextArray. */ - const TextArray& GetTextArray( const Dali::Text& text ); + const Integration::TextArray& GetTextArray( const Dali::Text& text ); } // namespace Internal diff --git a/dali/internal/event/text/text-request-helper.cpp b/dali/internal/event/text/text-request-helper.cpp index 30f4a2f2f..e0de39d1d 100644 --- a/dali/internal/event/text/text-request-helper.cpp +++ b/dali/internal/event/text/text-request-helper.cpp @@ -44,7 +44,7 @@ TextRequestHelper::~TextRequestHelper() } } -TextVertexBuffer* TextRequestHelper::SetText(const TextArray& text, const TextFormat& format) +TextVertexBuffer* TextRequestHelper::SetText(const Integration::TextArray& text, const TextFormat& format) { // current text no longer required. TextNotRequired(); @@ -65,7 +65,7 @@ TextVertexBuffer* TextRequestHelper::SetFont( const FontPointer& font, const Tex return TextRequired( format ); } -TextVertexBuffer* TextRequestHelper::SetTextAndFont( const TextArray& text, +TextVertexBuffer* TextRequestHelper::SetTextAndFont( const Integration::TextArray& text, const FontPointer& font, const TextFormat& format ) { @@ -82,7 +82,7 @@ TextVertexBuffer* TextRequestHelper::SetTextAndFont( const TextArray& text, void TextRequestHelper::TextNotRequired() { - if( mFont && !mText.empty() ) + if( mFont && ( 0u < mText.Count() ) ) { mFont->TextNotRequired( mText, mFormat, mTextureId ); } @@ -92,7 +92,7 @@ TextVertexBuffer* TextRequestHelper::TextRequired( const TextFormat& format ) { mFormat = format; - if( mFont && !mText.empty() ) + if( mFont && ( 0u < mText.Count() ) ) { // watch out for texture resizes / splits AddTextureObserver(); @@ -105,7 +105,7 @@ TextVertexBuffer* TextRequestHelper::TextRequired( const TextFormat& format ) return buffer; } - else if( mText.empty() ) + else if( 0u == mText.Count() ) { // create an empty vertex buffer TextVertexBuffer* buffer = new TextVertexBuffer; @@ -125,7 +125,7 @@ void TextRequestHelper::TextureChanged( unsigned int oldTextureId, unsigned int bool TextRequestHelper::IsTextLoaded() const { - if( mTextureId == 0 || (!mFont) || mText.empty() ) + if( mTextureId == 0 || (!mFont) || ( 0u == mText.Count() ) ) { return false; } diff --git a/dali/internal/event/text/text-request-helper.h b/dali/internal/event/text/text-request-helper.h index 65b58ace0..01572b9d9 100644 --- a/dali/internal/event/text/text-request-helper.h +++ b/dali/internal/event/text/text-request-helper.h @@ -20,11 +20,11 @@ // INTERNAL INCLUDES #include -#include #include #include #include #include +#include namespace Dali { @@ -61,7 +61,7 @@ public: * @param [in] format text format * @return the vertex data required to draw the text */ - TextVertexBuffer* SetText(const TextArray& text, const TextFormat& format ); + TextVertexBuffer* SetText(const Integration::TextArray& text, const TextFormat& format ); /** * Set the font @@ -78,7 +78,7 @@ public: * @param [in] format text format * @return the vertex data required to draw the text */ - TextVertexBuffer* SetTextAndFont(const TextArray& text, const FontPointer& font, const TextFormat& format ); + TextVertexBuffer* SetTextAndFont(const Integration::TextArray& text, const FontPointer& font, const TextFormat& format ); /** * Called when the texture id has changed @@ -113,7 +113,7 @@ private: void AddTextureObserver(); unsigned int mTextureId; ///< the texture id of the glyph atlas being used - TextArray mText; ///< text string + Integration::TextArray mText; ///< text string TextFormat mFormat; ///< text format FontPointer mFont; ///< the font bool mTextureObserverInstalled:1; ///< whether texture observer is installed diff --git a/dali/internal/event/text/utf8-impl.cpp b/dali/internal/event/text/utf8-impl.cpp index 1888ce999..5fa4e41ef 100644 --- a/dali/internal/event/text/utf8-impl.cpp +++ b/dali/internal/event/text/utf8-impl.cpp @@ -124,7 +124,7 @@ size_t UTF8Write(const uint32_t code, unsigned char* utf8Data) return sequenceLength; } -size_t UTF8Tokenize(const unsigned char* utf8Data, const size_t utf8DataLength, TextArray& tokens) +size_t UTF8Tokenize(const unsigned char* utf8Data, const size_t utf8DataLength, Integration::TextArray& tokens) { size_t dataLength = utf8DataLength; @@ -145,12 +145,12 @@ size_t UTF8Tokenize(const unsigned char* utf8Data, const size_t utf8DataLength, } code = UTF8Read(utf8Data, sequenceLength); - tokens.push_back(code); + tokens.PushBack(code); utf8Data += sequenceLength; dataLength -= sequenceLength; } - return tokens.size(); + return tokens.Count(); } } // namespace Internal diff --git a/dali/internal/event/text/utf8-impl.h b/dali/internal/event/text/utf8-impl.h index 4f029f755..2c2818188 100644 --- a/dali/internal/event/text/utf8-impl.h +++ b/dali/internal/event/text/utf8-impl.h @@ -19,7 +19,7 @@ */ // INTERNAL INCLUDES -#include +#include namespace Dali { @@ -57,7 +57,7 @@ size_t UTF8Write(const uint32_t code, unsigned char* utf8Data); * @param[out] tokens A vector which will receive the converted UTF-32 codes * @return The number of UTF-32 codes. */ -size_t UTF8Tokenize(const unsigned char* utf8Data, const size_t utf8DataLength, TextArray& tokens); +size_t UTF8Tokenize(const unsigned char* utf8Data, const size_t utf8DataLength, Integration::TextArray& tokens); } // namespace Internal diff --git a/dali/public-api/actors/text-actor.cpp b/dali/public-api/actors/text-actor.cpp index eb4f1913c..6ba09edd2 100644 --- a/dali/public-api/actors/text-actor.cpp +++ b/dali/public-api/actors/text-actor.cpp @@ -38,7 +38,7 @@ TextActor::TextActor() TextActor TextActor::New() { TextActorParameters parameters; - Internal::TextActorPtr internal = Internal::TextActor::New( Internal::TextArray(), parameters ); + Internal::TextActorPtr internal = Internal::TextActor::New( Integration::TextArray(), parameters ); return TextActor( internal.Get() ); } -- 2.34.1