TextModel - Conversion from characters to glyphs. 96/65496/1
authorVictor Cebollada <v.cebollada@samsung.com>
Mon, 11 Apr 2016 08:47:10 +0000 (09:47 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Mon, 11 Apr 2016 09:26:50 +0000 (10:26 +0100)
* Pass the glyph index to the methods that calculates the conversion tables.

Change-Id: I150e1a747dea196b9b3669d0e8b02d834b41d28f
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-text-model.cpp
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/visual-model-impl.cpp
dali-toolkit/internal/text/visual-model-impl.h

index fdde254..fe6d4cb 100644 (file)
@@ -84,10 +84,12 @@ bool SetGlyphsPerCharacterTest( const SetGlyphsPerCharacterData& data )
   Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
   Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter;
 
   Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
   Vector<Length>& 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];
   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 );
 
     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,
 
   // 3) Call the CreateGlyphsPerCharacterTable() function
   visualModel->CreateGlyphsPerCharacterTable( data.startIndex,
+                                              startGlyphIndex,
                                               data.numberOfCharacters );
 
   // 4) Compare the results.
                                               data.numberOfCharacters );
 
   // 4) Compare the results.
@@ -160,10 +163,12 @@ bool SetCharacterToGlyphTest( const SetCharacterToGlyphData& data )
   Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
   Vector<Length>& glyphsPerCharacter = visualModel->mGlyphsPerCharacter;
 
   Vector<GlyphIndex>& charactersToGlyph = visualModel->mCharactersToGlyph;
   Vector<Length>& 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];
   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 );
 
     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,
 
   // 3) Call the CreateCharacterToGlyphTable() function
   visualModel->CreateCharacterToGlyphTable( data.startIndex,
+                                            startGlyphIndex,
                                             data.numberOfCharacters );
 
   // 4) Compare the results.
                                             data.numberOfCharacters );
 
   // 4) Compare the results.
index f07cfdc..aff7eb7 100644 (file)
@@ -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.
              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();
 
 
   const Length numberOfGlyphs = glyphs.Count();
 
index 78bd7e9..5571f94 100644 (file)
@@ -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.
                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();
   }
 
   const Length numberOfGlyphs = glyphs.Count();
index 138ce54..c1faee7 100644 (file)
@@ -36,6 +36,7 @@ VisualModelPtr VisualModel::New()
 }
 
 void VisualModel::CreateCharacterToGlyphTable( CharacterIndex startIndex,
 }
 
 void VisualModel::CreateCharacterToGlyphTable( CharacterIndex startIndex,
+                                               GlyphIndex startGlyphIndex,
                                                Length numberOfCharacters )
 {
   if( 0u == numberOfCharacters )
                                                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.
   // 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;
   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,
 }
 
 void VisualModel::CreateGlyphsPerCharacterTable( CharacterIndex startIndex,
+                                                 GlyphIndex startGlyphIndex,
                                                  Length numberOfCharacters )
 {
   if( 0u == numberOfCharacters )
                                                  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.
 
 
   // 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;
 
   Length traversedCharacters = 0;
 
   // The number of 'characters per glyph' equal to zero.
   Length zeroCharactersPerGlyph = 0u;
 
-  for( Vector<Length>::ConstIterator it = mCharactersPerGlyph.Begin() + glyphIndex,
+  for( Vector<Length>::ConstIterator it = mCharactersPerGlyph.Begin() + startGlyphIndex,
          endIt = mCharactersPerGlyph.End();
        ( it != endIt ) && ( traversedCharacters < numberOfCharacters );
        ++it )
          endIt = mCharactersPerGlyph.End();
        ( it != endIt ) && ( traversedCharacters < numberOfCharacters );
        ++it )
index a0339a4..5aa90af 100644 (file)
@@ -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.
    * @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,
    * @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.
                                     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,
    * @param[in] numberOfCharacters The number of characters.
    */
   void CreateGlyphsPerCharacterTable( CharacterIndex startIndex,
+                                      GlyphIndex startGlyphIndex,
                                       Length numberOfCharacters );
 
   /**
                                       Length numberOfCharacters );
 
   /**