X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-run-container.h;h=3b54d5c803cc47ea8c358a71283a90e0c16f182e;hp=67d03738ad6db0b51074f71b0bb0deb89381451d;hb=528aa3699cd51dab5115bca1aaebb65d4bc67c15;hpb=b899c4999231a14190e804e13b941527c3c437a1 diff --git a/dali-toolkit/internal/text/text-run-container.h b/dali-toolkit/internal/text/text-run-container.h index 67d0373..3b54d5c 100644 --- a/dali-toolkit/internal/text/text-run-container.h +++ b/dali-toolkit/internal/text/text-run-container.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_TEXT_STYLE_RUN_CONTAINER_H__ -#define __DALI_TOOLKIT_TEXT_STYLE_RUN_CONTAINER_H__ +#ifndef DALI_TOOLKIT_TEXT_RUN_CONTAINER_H +#define DALI_TOOLKIT_TEXT_RUN_CONTAINER_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,12 +47,12 @@ void ClearCharacterRuns( CharacterIndex startIndex, uint32_t& endRemoveIndex ) { T* runsBuffer = runs.Begin(); + T* run = runsBuffer; const Length length = runs.Count(); - for( Length index = 0u; index < length; ++index ) + Length index = 0u; + for( index = 0u; index < length; ++index ) { - T* run = ( runsBuffer + index ); - if( ( run->characterRun.characterIndex <= endIndex ) && ( startIndex < run->characterRun.characterIndex + run->characterRun.numberOfCharacters ) ) { @@ -62,37 +62,36 @@ void ClearCharacterRuns( CharacterIndex startIndex, startRemoveIndex = index; break; } + + ++run; } - for( Length index = startRemoveIndex; index < length; ++index ) + run = ( runsBuffer + startRemoveIndex ); + for( index = startRemoveIndex; index < length; ++index ) { - T* run = ( runsBuffer + index ); - - if( ( run->characterRun.characterIndex <= endIndex ) && - ( startIndex < run->characterRun.characterIndex + run->characterRun.numberOfCharacters ) ) - { - // Update the index to the last run to be removed. - endRemoveIndex = index + 1u; - } - else + if( ( run->characterRun.characterIndex > endIndex ) || + ( startIndex >= run->characterRun.characterIndex + run->characterRun.numberOfCharacters ) ) { // Run found. Nothing else to do. break; } + ++run; } + endRemoveIndex = index; // The number of characters to remove. const Length numberOfCharactersRemoved = 1u + endIndex - startIndex; // Update the character index of the next runs. + run = runsBuffer; for( Length index = 0u; index < length; ++index ) { - T* run = ( runsBuffer + index ); - if( run->characterRun.characterIndex > startIndex ) { run->characterRun.characterIndex -= numberOfCharactersRemoved; } + + ++run; } } @@ -259,10 +258,99 @@ void UpdateCharacterRuns( CharacterIndex index, } } +/** + * @brief Clears the runs starting from the given glyph index. + * + * @param[in] startIndex The starting glyph index used to remove runs. + * @param[in] endIndex The ending glyph index used to remove runs. + * @param[in,out] runs The text's runs. + * @param[out] startRemoveIndex The index to the first run to be removed. + * @param[out] endRemoveIndex The index to the last run to be removed. + */ +template< typename T > +void ClearGlyphRuns( GlyphIndex startIndex, + GlyphIndex endIndex, + Vector& runs, + uint32_t& startRemoveIndex, + uint32_t& endRemoveIndex ) +{ + T* runsBuffer = runs.Begin(); + T* run = runsBuffer; + + const Length length = runs.Count(); + Length index = 0u; + for( index = 0u; index < length; ++index ) + { + if( ( run->glyphRun.glyphIndex <= endIndex ) && + ( startIndex < run->glyphRun.glyphIndex + run->glyphRun.numberOfGlyphs ) ) + { + // Run found. + + // Set the index to the first run to be removed. + startRemoveIndex = index; + break; + } + ++run; + } + + run = ( runsBuffer + startRemoveIndex ); + for( index = startRemoveIndex; index < length; ++index ) + { + if( ( run->glyphRun.glyphIndex > endIndex ) || + ( startIndex >= run->glyphRun.glyphIndex + run->glyphRun.numberOfGlyphs ) ) + { + // Run found. Nothing else to do. + break; + } + + ++run; + } + endRemoveIndex = index; + + // The number of glyphs to remove. + const Length numberOfGlyphsRemoved = 1u + endIndex - startIndex; + + // Update the glyph index of the next runs. + run = runsBuffer; + for( Length index = 0u; index < length; ++index ) + { + + if( run->glyphRun.glyphIndex > startIndex ) + { + run->glyphRun.glyphIndex -= numberOfGlyphsRemoved; + } + } +} + +/** + * @brief Clears the runs starting from the given glyph index. + * + * @param[in] startIndex The starting glyph index used to remove runs. + * @param[in] endIndex The ending glyph index used to remove runs. + * @param[in,out] runs The text's runs. + */ +template< typename T > +void ClearGlyphRuns( GlyphIndex startIndex, + GlyphIndex endIndex, + Vector& runs ) +{ + uint32_t startRemoveIndex = runs.Count(); + uint32_t endRemoveIndex = startRemoveIndex; + ClearGlyphRuns( startIndex, + endIndex, + runs, + startRemoveIndex, + endRemoveIndex ); + + // Remove all remaining runs. + T* runBuffer = runs.Begin(); + runs.Erase( runBuffer + startRemoveIndex, runBuffer + endRemoveIndex ); +} + } // namespace Text } // namespace Toolkit } // namespace Dali -#endif // __DALI_TOOLKIT_TEXT_STYLE_RUN_CONTAINER_H__ +#endif // DALI_TOOLKIT_TEXT_RUN_CONTAINER_H