From 6c456bd91c102985503b651e4734c5d82221c941 Mon Sep 17 00:00:00 2001 From: "Jinho, Lee" Date: Thu, 16 Nov 2017 03:11:18 +0900 Subject: [PATCH] Outline effect has been fixed to be not front cropped. Change-Id: Icdb5ed12ddc9deb59f291c20b051fd99a7884888 --- .../dali-toolkit-test-utils/toolkit-text-utils.cpp | 5 +++-- .../src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp | 8 ++++++-- dali-toolkit/internal/text/layouts/layout-engine.cpp | 8 ++++++-- dali-toolkit/internal/text/layouts/layout-parameters.h | 7 +++++-- dali-toolkit/internal/text/text-controller.cpp | 4 +++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp index 1c844c5..9248151 100644 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp @@ -269,7 +269,7 @@ void CreateTextModel( const std::string& text, // Set the layout parameters. const Vector& charactersToGlyph = visualModel->mCharactersToGlyph; const Vector& glyphsPerCharacter = visualModel->mGlyphsPerCharacter; - + float outlineWidth = visualModel->GetOutlineWidth(); Layout::Parameters layoutParameters( textArea, utf32Characters.Begin(), lineBreakInfo.Begin(), @@ -282,7 +282,8 @@ void CreateTextModel( const std::string& text, glyphsPerCharacter.Begin(), numberOfGlyphs, Text::HorizontalAlignment::BEGIN, - Text::LineWrap::WORD ); + Text::LineWrap::WORD, + outlineWidth ); Vector& lines = visualModel->mLines; diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp index f6c58db..b521976 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp @@ -157,6 +157,7 @@ bool LayoutTextTest( const LayoutTextData& data ) engine.SetLayout( data.layout ); const Length totalNumberOfGlyphs = visualModel->mGlyphs.Count(); + float outlineWidth = visualModel->GetOutlineWidth(); Layout::Parameters layoutParameters( data.textArea, logicalModel->mText.Begin(), @@ -170,7 +171,8 @@ bool LayoutTextTest( const LayoutTextData& data ) visualModel->mGlyphsPerCharacter.Begin(), totalNumberOfGlyphs, Text::HorizontalAlignment::BEGIN, - Text::LineWrap::WORD ); + Text::LineWrap::WORD, + outlineWidth ); layoutParameters.isLastNewParagraph = isLastNewParagraph; @@ -374,6 +376,7 @@ bool ReLayoutRightToLeftLinesTest( const ReLayoutRightToLeftLinesData& data ) Layout::Engine engine; engine.SetMetrics( metrics ); + float outlineWidth = visualModel->GetOutlineWidth(); Layout::Parameters layoutParameters( data.textArea, logicalModel->mText.Begin(), logicalModel->mLineBreakInfo.Begin(), @@ -386,7 +389,8 @@ bool ReLayoutRightToLeftLinesTest( const ReLayoutRightToLeftLinesData& data ) visualModel->mGlyphsPerCharacter.Begin(), visualModel->mGlyphs.Count(), Text::HorizontalAlignment::BEGIN, - Text::LineWrap::WORD ); + Text::LineWrap::WORD, + outlineWidth ); layoutParameters.numberOfBidirectionalInfoRuns = logicalModel->mBidirectionalLineInfo.Count(); layoutParameters.lineBidirectionalInfoRunsBuffer = logicalModel->mBidirectionalLineInfo.Begin(); diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index 3e633ba..ccd42ae 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -470,6 +470,7 @@ struct Engine::Impl void SetGlyphPositions( const GlyphInfo* const glyphsBuffer, Length numberOfGlyphs, + float outlineWidth, Vector2* glyphPositionsBuffer ) { // Traverse the glyphs and set the positions. @@ -479,7 +480,8 @@ struct Engine::Impl // so the penX position needs to be moved to the right. const GlyphInfo& glyph = *glyphsBuffer; - float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing : 0.f; + float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing + outlineWidth : outlineWidth; + for( GlyphIndex i = 0u; i < numberOfGlyphs; ++i ) { @@ -604,6 +606,7 @@ struct Engine::Impl SetGlyphPositions( layoutParameters.glyphsBuffer + lineRun->glyphRun.glyphIndex, ellipsisLayout.numberOfGlyphs, + layoutParameters.outlineWidth, glyphPositionsBuffer + lineRun->glyphRun.glyphIndex - layoutParameters.startGlyphIndex ); } @@ -963,6 +966,7 @@ struct Engine::Impl // Sets the positions of the glyphs. SetGlyphPositions( layoutParameters.glyphsBuffer + index, layout.numberOfGlyphs, + layoutParameters.outlineWidth, glyphPositionsBuffer + index - layoutParameters.startGlyphIndex ); // Updates the vertical pen's position. @@ -1043,7 +1047,7 @@ struct Engine::Impl const CharacterIndex characterVisualIndex = bidiLine.characterRun.characterIndex + *bidiLine.visualToLogicalMap; const GlyphInfo& glyph = *( layoutParameters.glyphsBuffer + *( layoutParameters.charactersToGlyphsBuffer + characterVisualIndex ) ); - float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing : 0.f; + float penX = ( 0.f > glyph.xBearing ) ? -glyph.xBearing - layoutParameters.outlineWidth : -layoutParameters.outlineWidth; Vector2* glyphPositionsBuffer = glyphPositions.Begin(); diff --git a/dali-toolkit/internal/text/layouts/layout-parameters.h b/dali-toolkit/internal/text/layouts/layout-parameters.h index 47aed0e..7f3e169 100644 --- a/dali-toolkit/internal/text/layouts/layout-parameters.h +++ b/dali-toolkit/internal/text/layouts/layout-parameters.h @@ -73,7 +73,8 @@ struct Parameters const Length* const glyphsPerCharacterBuffer, Length totalNumberOfGlyphs, Text::HorizontalAlignment::Type horizontalAlignment, - Text::LineWrap::Mode lineWrapMode ) + Text::LineWrap::Mode lineWrapMode, + float outlineWidth ) : boundingBox( boundingBox ), textBuffer( textBuffer ), lineBreakInfoBuffer( lineBreakInfoBuffer ), @@ -93,7 +94,8 @@ struct Parameters startLineIndex( 0u ), estimatedNumberOfLines( 0u ), lineWrapMode( lineWrapMode ), - isLastNewParagraph( false ) + isLastNewParagraph( false ), + outlineWidth( outlineWidth ) {} Vector2 boundingBox; ///< The size of the box containing the text. @@ -116,6 +118,7 @@ struct Parameters Length estimatedNumberOfLines; ///< The estimated number of lines. Text::LineWrap::Mode lineWrapMode; ///< The line wrap mode for moving to next line. bool isLastNewParagraph; ///< Whether the last character is a new paragraph character. + float outlineWidth; ///< The outline width. }; } // namespace Layout diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 552be56..7847fb9 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -3319,6 +3319,7 @@ bool Controller::DoRelayout( const Size& size, const Vector& glyphsToCharactersMap = mImpl->mModel->mVisualModel->mGlyphsToCharacters; const Vector& charactersPerGlyph = mImpl->mModel->mVisualModel->mCharactersPerGlyph; const Character* const textBuffer = mImpl->mModel->mLogicalModel->mText.Begin(); + float outlineWidth = mImpl->mModel->GetOutlineWidth(); // Set the layout parameters. Layout::Parameters layoutParameters( size, @@ -3333,7 +3334,8 @@ bool Controller::DoRelayout( const Size& size, glyphsPerCharacterBuffer, totalNumberOfGlyphs, mImpl->mModel->mHorizontalAlignment, - mImpl->mModel->mLineWrapMode ); + mImpl->mModel->mLineWrapMode, + outlineWidth ); // Resize the vector of positions to have the same size than the vector of glyphs. Vector& glyphPositions = mImpl->mModel->mVisualModel->mGlyphPositions; -- 2.7.4