From: Victor Cebollada Date: Mon, 11 Apr 2016 08:47:10 +0000 (+0100) Subject: TextModel - Conversion from characters to glyphs. X-Git-Tag: dali_1.1.30~4^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=3a14f4cd926da60a41c4dc9ca32ac808c5c7d349 TextModel - Conversion from characters to glyphs. * Pass the glyph index to the methods that calculates the conversion tables. Change-Id: I150e1a747dea196b9b3669d0e8b02d834b41d28f Signed-off-by: Victor Cebollada --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp index fdde254..fe6d4cb 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp @@ -84,10 +84,12 @@ bool SetGlyphsPerCharacterTest( const SetGlyphsPerCharacterData& data ) Vector& charactersToGlyph = visualModel->mCharactersToGlyph; Vector& glyphsPerCharacter = visualModel->mGlyphsPerCharacter; + GlyphIndex startGlyphIndex = 0u; if( 0u != charactersToGlyph.Count() ) { // The number of glyphs to be removed. const Length numberOfGlyphs = charactersToGlyph[data.startIndex + data.numberOfCharacters - 1u] + glyphsPerCharacter[data.startIndex + data.numberOfCharacters - 1u] - charactersToGlyph[data.startIndex]; + startGlyphIndex = charactersToGlyph[data.startIndex]; charactersToGlyph.Erase( charactersToGlyph.Begin() + data.startIndex, charactersToGlyph.Begin() + data.startIndex + data.numberOfCharacters ); @@ -106,6 +108,7 @@ bool SetGlyphsPerCharacterTest( const SetGlyphsPerCharacterData& data ) // 3) Call the CreateGlyphsPerCharacterTable() function visualModel->CreateGlyphsPerCharacterTable( data.startIndex, + startGlyphIndex, data.numberOfCharacters ); // 4) Compare the results. @@ -160,10 +163,12 @@ bool SetCharacterToGlyphTest( const SetCharacterToGlyphData& data ) Vector& charactersToGlyph = visualModel->mCharactersToGlyph; Vector& glyphsPerCharacter = visualModel->mGlyphsPerCharacter; + GlyphIndex startGlyphIndex = 0u; if( 0u != charactersToGlyph.Count() ) { // The number of glyphs to be removed. const Length numberOfGlyphs = charactersToGlyph[data.startIndex + data.numberOfCharacters - 1u] + glyphsPerCharacter[data.startIndex + data.numberOfCharacters - 1u] - charactersToGlyph[data.startIndex]; + startGlyphIndex = charactersToGlyph[data.startIndex]; charactersToGlyph.Erase( charactersToGlyph.Begin() + data.startIndex, charactersToGlyph.Begin() + data.startIndex + data.numberOfCharacters ); @@ -180,6 +185,7 @@ bool SetCharacterToGlyphTest( const SetCharacterToGlyphData& data ) // 3) Call the CreateCharacterToGlyphTable() function visualModel->CreateCharacterToGlyphTable( data.startIndex, + startGlyphIndex, data.numberOfCharacters ); // 4) Compare the results. diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-model.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-model.cpp index f07cfdc..aff7eb7 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-model.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-model.cpp @@ -239,8 +239,8 @@ void CreateTextModel( const std::string& text, newParagraphGlyphs ); // Create the 'number of glyphs' per character and the glyph to character conversion tables. - visualModel->CreateGlyphsPerCharacterTable( 0u, numberOfCharacters ); - visualModel->CreateCharacterToGlyphTable( 0u, numberOfCharacters ); + visualModel->CreateGlyphsPerCharacterTable( 0u, 0u, numberOfCharacters ); + visualModel->CreateCharacterToGlyphTable( 0u, 0u, numberOfCharacters ); const Length numberOfGlyphs = glyphs.Count(); diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 78bd7e9..5571f94 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -477,8 +477,8 @@ void Controller::Impl::UpdateModel( OperationsMask operationsRequired ) newParagraphGlyphs ); // Create the 'number of glyphs' per character and the glyph to character conversion tables. - mVisualModel->CreateGlyphsPerCharacterTable( startIndex, numberOfCharacters ); - mVisualModel->CreateCharacterToGlyphTable( startIndex, numberOfCharacters ); + mVisualModel->CreateGlyphsPerCharacterTable( startIndex, startGlyphIndex, numberOfCharacters ); + mVisualModel->CreateCharacterToGlyphTable( startIndex, startGlyphIndex, numberOfCharacters ); } const Length numberOfGlyphs = glyphs.Count(); diff --git a/dali-toolkit/internal/text/visual-model-impl.cpp b/dali-toolkit/internal/text/visual-model-impl.cpp index 138ce54..c1faee7 100644 --- a/dali-toolkit/internal/text/visual-model-impl.cpp +++ b/dali-toolkit/internal/text/visual-model-impl.cpp @@ -36,6 +36,7 @@ VisualModelPtr VisualModel::New() } void VisualModel::CreateCharacterToGlyphTable( CharacterIndex startIndex, + GlyphIndex startGlyphIndex, Length numberOfCharacters ) { if( 0u == numberOfCharacters ) @@ -72,7 +73,6 @@ void VisualModel::CreateCharacterToGlyphTable( CharacterIndex startIndex, // 2) Traverse the glyphs and set the glyph indices per character. // Index to the glyph. - const GlyphIndex startGlyphIndex = updateCurrentBuffer ? *( mCharactersToGlyph.Begin() + startIndex ) : 0u; GlyphIndex glyphIndex = startGlyphIndex; CharacterIndex characterIndex = startIndex; const CharacterIndex lastCharacterIndexPlusOne = startIndex + numberOfCharacters; @@ -115,6 +115,7 @@ void VisualModel::CreateCharacterToGlyphTable( CharacterIndex startIndex, } void VisualModel::CreateGlyphsPerCharacterTable( CharacterIndex startIndex, + GlyphIndex startGlyphIndex, Length numberOfCharacters ) { if( 0u == numberOfCharacters ) @@ -146,14 +147,12 @@ void VisualModel::CreateGlyphsPerCharacterTable( CharacterIndex startIndex, // 2) Traverse the glyphs and set the number of glyphs per character. - // The glyph index. - const GlyphIndex glyphIndex = updateCurrentBuffer ? *( mCharactersToGlyph.Begin() + startIndex ) : 0u; Length traversedCharacters = 0; // The number of 'characters per glyph' equal to zero. Length zeroCharactersPerGlyph = 0u; - for( Vector::ConstIterator it = mCharactersPerGlyph.Begin() + glyphIndex, + for( Vector::ConstIterator it = mCharactersPerGlyph.Begin() + startGlyphIndex, endIt = mCharactersPerGlyph.End(); ( it != endIt ) && ( traversedCharacters < numberOfCharacters ); ++it ) diff --git a/dali-toolkit/internal/text/visual-model-impl.h b/dali-toolkit/internal/text/visual-model-impl.h index a0339a4..5aa90af 100644 --- a/dali-toolkit/internal/text/visual-model-impl.h +++ b/dali-toolkit/internal/text/visual-model-impl.h @@ -67,18 +67,22 @@ public: * @pre The glyphs per character table needs to be created first. * * @param[in] startIndex The character from where the conversion table is created. + * @param[in] startGlyphIndex The glyph from where the conversion table is created. * @param[in] numberOfCharacters The number of characters. */ void CreateCharacterToGlyphTable( CharacterIndex startIndex, + GlyphIndex startGlyphIndex, Length numberOfCharacters ); /** * @brief Creates an array containing the number of glyphs per character. * * @param[in] startIndex The character from where the table is created. + * @param[in] startGlyphIndex The glyph from where the conversion table is created. * @param[in] numberOfCharacters The number of characters. */ void CreateGlyphsPerCharacterTable( CharacterIndex startIndex, + GlyphIndex startGlyphIndex, Length numberOfCharacters ); /**