Graphics Merge to Tizen.2.2
authorSungyeon Woo <s.woo@samsung.com>
Mon, 3 Jun 2013 05:59:11 +0000 (14:59 +0900)
committerSungyeon Woo <s.woo@samsung.com>
Mon, 3 Jun 2013 05:59:11 +0000 (14:59 +0900)
Change-Id: Ib1b87864e33c2f440220e8ea1079465c44ae879c
Signed-off-by: Sungyeon Woo <s.woo@samsung.com>
src/graphics/FGrp_FontImpl.cpp [changed mode: 0755->0644]
src/graphics/inc/FGrp_TextTextObject.h
src/graphics/text/FGrp_TextTextColumn.cpp
src/graphics/text/FGrp_TextTextColumn.h
src/graphics/text/FGrp_TextTextComposite.cpp
src/graphics/text/FGrp_TextTextComposite.h
src/graphics/text/FGrp_TextTextObject.cpp

old mode 100755 (executable)
new mode 100644 (file)
index fcdaacb..95d8c34
 
 #include <new>
 #include <memory>
+#include <pthread.h>
 
 #include <FGrpFont.h>
-
 #include <FBaseSysLog.h>
+#include <FBaseRtMutex.h>
 
 #include "FGrp_FontImpl.h"
 #include "FGrp_Font.h"
 #include "FGrp_ResUtil.h"
 
 
+using namespace Tizen::Base::Runtime;
+
 #define IF_NOT_INITIALIZED(code) if (this->_pNativeFont == null || this->_pCoordHolder == null) \
        { \
                code; \
        }
 #define IsSucceeded(X) (!IsFailed(X))
 
+
+#if 1
+#define CRITICAL_SECTION _MutexGuard __mutexGuard__
+#else
+#define CRITICAL_SECTION
+#endif
+
+
 namespace Tizen { namespace Graphics
 {
 
+class _MutexGuard
+{
+public:
+       _MutexGuard()
+       {
+               Mutex* pMutex = GetMutexInstance();
+               pMutex->Acquire();
+       }
+
+       ~_MutexGuard()
+       {
+               Mutex* pMutex = GetMutexInstance();
+               pMutex->Release();
+       }
+
+private:
+       static void __InitCreateMutex(void)
+       {
+               static Mutex mutex;
+               mutex.Create();
+               _MutexGuard::pMutexInstance = &mutex;
+       }
+
+       static Mutex* GetMutexInstance(void)
+       {
+               static pthread_once_t once_block = PTHREAD_ONCE_INIT;
+
+               if (_MutexGuard::pMutexInstance == null)
+               {
+                       pthread_once(&once_block, __InitCreateMutex);
+               }
+
+               return _MutexGuard::pMutexInstance;
+       }
+
+public:
+       static Mutex* pMutexInstance;
+};
+
+Mutex* _MutexGuard::pMutexInstance = null;
+
+
 struct _FontCoordHolder
 {
        _ResUtil::CoordHolder <int> size;
@@ -130,6 +183,7 @@ _FontImpl::~_FontImpl()
 result
 _FontImpl::Construct(int style, int vcSize)
 {
+       CRITICAL_SECTION;
        IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
 
        // convert VC -> PC
@@ -151,6 +205,7 @@ _FontImpl::Construct(int style, int vcSize)
 result
 _FontImpl::Construct(const Tizen::Base::String& fontName, int style, int vcSize, bool isPathEnabled)
 {
+       CRITICAL_SECTION;
        IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
 
        // convert VC -> PC
@@ -172,6 +227,7 @@ _FontImpl::Construct(const Tizen::Base::String& fontName, int style, int vcSize,
 result
 _FontImpl::Construct(const Tizen::Base::ByteBuffer& fontData, int style, int vcSize)
 {
+       CRITICAL_SECTION;
        IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
 
        // convert VC -> PC
@@ -193,6 +249,7 @@ _FontImpl::Construct(const Tizen::Base::ByteBuffer& fontData, int style, int vcS
 result
 _FontImpl::Construct(int style, float vcSize)
 {
+       CRITICAL_SECTION;
        IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
 
        // convert VC -> PC
@@ -214,6 +271,7 @@ _FontImpl::Construct(int style, float vcSize)
 result
 _FontImpl::Construct(const Tizen::Base::String& fontName, int style, float vcSize, bool isPathEnabled)
 {
+       CRITICAL_SECTION;
        IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
 
        // convert VC -> PC
@@ -235,6 +293,7 @@ _FontImpl::Construct(const Tizen::Base::String& fontName, int style, float vcSiz
 result
 _FontImpl::Construct(const Tizen::Base::ByteBuffer& fontData, int style, float vcSize)
 {
+       CRITICAL_SECTION;
        IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
 
        // convert VC -> PC
@@ -256,6 +315,7 @@ _FontImpl::Construct(const Tizen::Base::ByteBuffer& fontData, int style, float v
 bool
 _FontImpl::IsConstructed(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return false);
 
        return true;
@@ -264,6 +324,7 @@ _FontImpl::IsConstructed(void) const
 int
 _FontImpl::GetMaxHeight(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return -1);
 
        int pcMaxHeight = _DoubleToIntForPos(ceil(_pNativeFont->GetMaxHeight().ToDouble()));
@@ -285,6 +346,7 @@ _FontImpl::GetMaxHeight(void) const
 float
 _FontImpl::GetMaxHeightF(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return -1.0f);
 
        float pcMaxHeight = float(ceil(_pNativeFont->GetMaxHeight().ToDouble()));
@@ -296,6 +358,7 @@ _FontImpl::GetMaxHeightF(void) const
 int
 _FontImpl::GetMaxWidth(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return -1);
 
        int pcMaxWidth = _pNativeFont->GetMaxWidth().ToInt();
@@ -307,6 +370,7 @@ _FontImpl::GetMaxWidth(void) const
 float
 _FontImpl::GetMaxWidthF(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return -1.0f);
 
        float pcMaxWidth = _pNativeFont->GetMaxWidth().ToFloat();
@@ -318,9 +382,20 @@ _FontImpl::GetMaxWidthF(void) const
 int
 _FontImpl::GetAscender(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return -1);
 
-       int pcAscender = _pNativeFont->GetAscender().ToInt();
+       int pcAscender = _DoubleToIntForPos(ceil(_pNativeFont->GetAscender().ToDouble()));
+
+       for (int i = pcAscender; i < INT_MAX; i++)
+       {
+               if (_ResUtil::ConvertToPhyCoord(_ResUtil::ConvertToVirCoordY(i)) >= pcAscender)
+               {
+                       pcAscender = i;
+                       break;
+               }
+       }
+
        int vcAscender = _ResUtil::ConvertToVirCoordY(pcAscender);
 
        return vcAscender;
@@ -329,9 +404,10 @@ _FontImpl::GetAscender(void) const
 float
 _FontImpl::GetAscenderF(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return -1.0f);
 
-       float pcAscender = _pNativeFont->GetAscender().ToFloat();
+       float pcAscender = float(ceil(_pNativeFont->GetAscender().ToDouble()));
        float vcAscender = _ResUtil::ConvertToVirCoordY(pcAscender);
 
        return vcAscender;
@@ -340,25 +416,37 @@ _FontImpl::GetAscenderF(void) const
 int
 _FontImpl::GetDescender(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return -1);
 
-       int pcDescender = _pNativeFont->GetDescender().ToInt();
-       int vcDescender = _ResUtil::ConvertToVirCoordY(pcDescender);
+       int pcDescender = _DoubleToIntForPos(ceil(_pNativeFont->GetDescender().ToDouble()));
 
-       if (vcDescender < 0)
+       if (pcDescender < 0)
        {
-               vcDescender *= -1;
+               pcDescender *= -1;
+       }
+
+       for (int i = pcDescender; i < INT_MAX; i++)
+       {
+               if (_ResUtil::ConvertToPhyCoord(_ResUtil::ConvertToVirCoordY(i)) >= pcDescender)
+               {
+                       pcDescender = i;
+                       break;
+               }
        }
 
+       int vcDescender = _ResUtil::ConvertToVirCoordY(pcDescender);
+
        return vcDescender;
 }
 
 float
 _FontImpl::GetDescenderF(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return -1.0f);
 
-       float pcDescender = _pNativeFont->GetDescender().ToFloat();
+       float pcDescender = float(ceil(_pNativeFont->GetDescender().ToDouble()));
        float vcDescender = _ResUtil::ConvertToVirCoordY(pcDescender);
 
        if (vcDescender < 0.0f)
@@ -372,6 +460,7 @@ _FontImpl::GetDescenderF(void) const
 result
 _FontImpl::GetLeftBear(wchar_t character, int& vcLeftBear) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
 
        _Util::FixedPoint22_10 pcLeftBear(0);
@@ -389,6 +478,7 @@ _FontImpl::GetLeftBear(wchar_t character, int& vcLeftBear) const
 result
 _FontImpl::GetLeftBear(wchar_t character, float& vcLeftBear) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
 
        _Util::FixedPoint22_10 pcLeftBear(0);
@@ -405,6 +495,7 @@ _FontImpl::GetLeftBear(wchar_t character, float& vcLeftBear) const
 result
 _FontImpl::GetRightBear(wchar_t character, int& vcRightBear) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
 
        _Util::FixedPoint22_10 pcRightBear(0);
@@ -422,6 +513,7 @@ _FontImpl::GetRightBear(wchar_t character, int& vcRightBear) const
 result
 _FontImpl::GetRightBear(wchar_t character, float& vcRightBear) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
 
        _Util::FixedPoint22_10 pcRightBear(0);
@@ -438,6 +530,7 @@ _FontImpl::GetRightBear(wchar_t character, float& vcRightBear) const
 result
 _FontImpl::GetTextExtent(const Tizen::Base::String& text, int length, Dimension& vcDim, bool outline) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
 
        int dummyCount = 0 ;
@@ -463,6 +556,7 @@ _FontImpl::GetTextExtent(const Tizen::Base::String& text, int length, Dimension&
 result
 _FontImpl::GetTextExtent(const Tizen::Base::String& text, int length, FloatDimension& vcDim, bool outline) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
 
        int dummyCount = 0;
@@ -482,6 +576,7 @@ _FontImpl::GetTextExtent(const Tizen::Base::String& text, int length, FloatDimen
 bool
 _FontImpl::IsBold(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return false);
 
        return _pNativeFont->IsBold();
@@ -490,6 +585,7 @@ _FontImpl::IsBold(void) const
 bool
 _FontImpl::IsItalic(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return false);
 
        return _pNativeFont->IsItalic();
@@ -498,6 +594,7 @@ _FontImpl::IsItalic(void) const
 bool
 _FontImpl::IsPlain(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return false);
 
        return _pNativeFont->IsPlain();
@@ -506,6 +603,7 @@ _FontImpl::IsPlain(void) const
 bool
 _FontImpl::IsStrikeOut(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return false);
 
        return _pNativeFont->IsStrikeOut();
@@ -514,6 +612,7 @@ _FontImpl::IsStrikeOut(void) const
 bool
 _FontImpl::IsUnderlined(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return false);
 
        return _pNativeFont->IsUnderlined();
@@ -522,6 +621,7 @@ _FontImpl::IsUnderlined(void) const
 int
 _FontImpl::GetSize(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return -1);
 
        return _pCoordHolder->size.required;
@@ -530,6 +630,7 @@ _FontImpl::GetSize(void) const
 float
 _FontImpl::GetSizeF(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return -1.0f);
 
        return _pCoordHolder->sizeF.required;
@@ -538,6 +639,7 @@ _FontImpl::GetSizeF(void) const
 void
 _FontImpl::SetStrikeOut(bool strikeOut)
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return);
 
        _pNativeFont->SetStrikeOut(strikeOut);
@@ -548,6 +650,7 @@ _FontImpl::SetStrikeOut(bool strikeOut)
 void
 _FontImpl::SetUnderline(bool underline)
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return);
 
        _pNativeFont->SetUnderline(underline);
@@ -558,6 +661,7 @@ _FontImpl::SetUnderline(bool underline)
 void
 _FontImpl::SetCharSpace(int vcSpace)
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return);
 
        // save it
@@ -574,6 +678,7 @@ _FontImpl::SetCharSpace(int vcSpace)
 void
 _FontImpl::SetCharSpace(float vcSpace)
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return);
 
        // save it
@@ -590,6 +695,7 @@ _FontImpl::SetCharSpace(float vcSpace)
 int
 _FontImpl::GetCharSpace(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return 0);
 
        return _pCoordHolder->charSpace.required;
@@ -598,6 +704,7 @@ _FontImpl::GetCharSpace(void) const
 float
 _FontImpl::GetCharSpaceF(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return 0.0f);
 
        return _pCoordHolder->charSpaceF.required;
@@ -606,6 +713,7 @@ _FontImpl::GetCharSpaceF(void) const
 Tizen::Base::String
 _FontImpl::GetFaceName(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return "");
 
        return _pNativeFont->GetFaceName();
@@ -614,18 +722,21 @@ _FontImpl::GetFaceName(void) const
 Tizen::Base::Collection::IList*
 _FontImpl::GetSystemFontListN(void)
 {
+       CRITICAL_SECTION;
        return _Font::GetSystemFontListN();
 }
 
 Tizen::Base::String
 _FontImpl::GetFaceName(const Tizen::Base::String& filePath)
 {
+       CRITICAL_SECTION;
        return _Font::GetFaceName(filePath);
 }
 
 _FontImpl*
 _FontImpl::CloneN(void)
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return null);
 
        std::auto_ptr<_FontImpl> pFontImpl(new (std::nothrow) _FontImpl(*this));
@@ -639,6 +750,8 @@ _FontImpl::CloneN(void)
 Font*
 _FontImpl::CloneN(const Font& font)
 {
+       CRITICAL_SECTION;
+
        // check the validation of input param
        SysTryReturn(NID_GRP, font.__pImpl && font.__pImpl->IsConstructed(), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input param given");
 
@@ -653,6 +766,7 @@ _FontImpl::CloneN(const Font& font)
 result
 _FontImpl::GetTextExtent(int vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, int& count, Dimension& vcDim) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
 
        SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE,
@@ -680,6 +794,7 @@ _FontImpl::GetTextExtent(int vcWidth, const Tizen::Base::String& text, int start
 result
 _FontImpl::GetTextExtent(int vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, Dimension& vcDim) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
 
        SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE,
@@ -707,6 +822,7 @@ _FontImpl::GetTextExtent(int vcWidth, const Tizen::Base::String& text, int start
 result
 _FontImpl::GetTextExtent(float vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, int& count, FloatDimension& vcDim) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
 
        SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE,
@@ -728,6 +844,7 @@ _FontImpl::GetTextExtent(float vcWidth, const Tizen::Base::String& text, int sta
 result
 _FontImpl::GetTextExtent(float vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, FloatDimension& vcDim) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
 
        SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE,
@@ -749,6 +866,7 @@ _FontImpl::GetTextExtent(float vcWidth, const Tizen::Base::String& text, int sta
 result
 _FontImpl::SetSize(int vcSize)
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
        SysTryReturnResult(NID_GRP, vcSize > 0, E_INVALID_ARG, "Font size should be greater than 0");
 
@@ -774,6 +892,7 @@ _FontImpl::SetSize(int vcSize)
 result
 _FontImpl::SetSize(float vcSize)
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
        SysTryReturnResult(NID_GRP, vcSize > 0.0f, E_INVALID_ARG, "Font size should be greater than 0");
 
@@ -799,6 +918,7 @@ _FontImpl::SetSize(float vcSize)
 result
 _FontImpl::SetStyle(int style)
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
        SysTryReturnResult(NID_GRP, style > FONT_STYLE_MIN && style <= (FONT_STYLE_PLAIN | FONT_STYLE_BOLD | FONT_STYLE_ITALIC), E_INVALID_ARG,
                "Style(%d) is invalid", style);
@@ -812,6 +932,7 @@ _FontImpl::SetStyle(int style)
 int
 _FontImpl::GetStyle(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return FONT_STYLE_PLAIN);
 
        return _pNativeFont->GetStyle();
@@ -820,6 +941,7 @@ _FontImpl::GetStyle(void) const
 int
 _FontImpl::GetLeading(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return -1);
 
        int pcLeading = _DoubleToIntForPos(ceil(_pNativeFont->GetLeading().ToDouble()));
@@ -841,6 +963,7 @@ _FontImpl::GetLeading(void) const
 float
 _FontImpl::GetLeadingF(void) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return -1.0f);
 
        float pcLeading = float(ceil(_pNativeFont->GetLeading().ToDouble()));
@@ -852,24 +975,28 @@ _FontImpl::GetLeadingF(void) const
 _FontImpl*
 _FontImpl::GetInstance(Font& font)
 {
+       CRITICAL_SECTION;
        return (&font != null) ? font.__pImpl : null;
 }
 
 const _FontImpl*
 _FontImpl::GetInstance(const Font& font)
 {
+       CRITICAL_SECTION;
        return (&font != null) ? font.__pImpl : null;
 }
 
 bool
 _FontImpl::UpdateDefaultFont(const Tizen::Base::String& key)
 {
+       CRITICAL_SECTION;
        return _Font::UpdateDefaultFont(key);
 }
 
 result
 _FontImpl::GetTextExtentList(const Tizen::Base::String& string, int startIndex, int length, Tizen::Base::Collection::ArrayListT<_FloatPair>& outList) const
 {
+       CRITICAL_SECTION;
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
 
        SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < string.GetLength(), E_OUT_OF_RANGE,
index dfba180..6cb39c7 100644 (file)
@@ -357,13 +357,9 @@ public:
 
        TextBidiHint GetTextBidiHint(void) const;
 
-       result SetFirstDisplayPositionX(int x);
+       result SetDisplayBoundsExpandEnabled(bool enable);
 
-       result SetFirstDisplayPositionX(float x);
-
-       int GetFirstDisplayPositionX(void) const;
-
-       float GetFirstDisplayPositionXF(void) const;
+       bool IsDisplayBoundsExpandEnabled(void) const;
 
 private:
        result DrawByLine(_CanvasImpl& canvasImpl, const Rectangle& displayRect);
@@ -431,6 +427,7 @@ private:
        bool __isActionOn;
        bool __isChanged;
        bool __isAlternateLookEnabled;
+       bool __isDisplayBoundsExpandEnabled;
        Font* __pDefaultFont;
        Color __defaultForegroundColor;
        Color __defaultBackgroundColor;
index dfb7948..c2e2991 100644 (file)
@@ -51,7 +51,6 @@ TextColumn::TextColumn(TextComposite* pCompositeText)
        __displayLineCount = 0;
        __firstDisplayLineIndex = 0;
        __firstDisplayPositionY = -1;
-       __firstDisplayPositionX = -1;
        __displayHeight = -1;
        __slidingPosition = 0;
        __pCompositeText = pCompositeText;
@@ -199,11 +198,6 @@ TextColumn::Draw(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int start
                __displayHeight -= __firstDisplayPositionY - lineBounds.y;
        }
 
-       if (__firstDisplayPositionX > 0)
-       {
-               displayRect.x -= __firstDisplayPositionX;
-       }
-
        while (pTextLineNode != null && 0 <= displayRect.height)
        {
                if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
@@ -224,11 +218,6 @@ TextColumn::Draw(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int start
                                {
                                        lineAction = TEXT_OBJECT_ACTION_TYPE_ABBREV;
                                }
-
-                               if (displayRect.width < lineBounds.width)
-                               {
-                                       lineAction = TEXT_OBJECT_ACTION_TYPE_ABBREV;
-                               }
                        }
                        else
                        {
@@ -1680,18 +1669,6 @@ TextColumn::GetFirstDisplayPositionYF(void) const
 }
 
 void
-TextColumn::SetFirstDisplayPositionX(float x)
-{
-       __firstDisplayPositionX = x;
-}
-
-float
-TextColumn::GetFirstDisplayPositionX(void) const
-{
-       return __firstDisplayPositionX;
-}
-
-void
 TextColumn::SetDisplayHeight(int height)
 {
        __displayHeight = _CoordinateSystemUtils::ConvertToFloat(height);
index 1b08256..2606bb3 100644 (file)
@@ -143,10 +143,6 @@ public:
 
        float GetFirstDisplayPositionYF(void) const;
 
-       void SetFirstDisplayPositionX(float x);
-
-       float GetFirstDisplayPositionX(void) const;
-
        int GetTextLengthAt(int lineIndex) const;
 
        int GetFirstTextIndexAt(int lineIndex) const;
@@ -246,7 +242,6 @@ private:
        int __totalLineCount;
        int __firstDisplayLineIndex;
        float __firstDisplayPositionY;
-       float __firstDisplayPositionX;
        int __displayLineCount;
        float __displayHeight;
        Tizen::Graphics::FloatDimension __slidingDimension;
index 7ddb9d4..d872047 100644 (file)
@@ -1872,6 +1872,7 @@ TextComposite::DrawLine(_CanvasImpl& canvasImpl, TextLine* pTextLine, const Floa
        pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
 
        adjustedRect = displayRect;
+       adjustedRect.width = lineBounds.width;
        adjustedRect.height = lineBounds.height;
 
        if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
@@ -3951,30 +3952,201 @@ TextComposite::ComposeInNoneWrap(FloatRectangle& rect, NoneWrapComposeInfo* pNon
 {
        SysTryReturn(NID_GRP, __pCurrentTextColumn, -1, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet.");
 
-       TextLine* pTextLine = new (std::nothrow)TextLine(this);
-       SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
+       TextLine* pTextLine = null;
        FloatRectangle lineBounds;
-       FloatDimension lineTextSize;
-       int lineLength = __length;
+       FloatDimension textSize;
+       int lineOffset = 0;
+       int lineLength = 0;
+       int endType = TEXT_RETBY_NORMAL;
+       bool isChanged = false;
        float baseline = 0;
+       int textIndex = 0;
+
+       textIndex = (__workStart < 0) ? 0 : __workStart;
+       textIndex = (textIndex > __length) ? __length : textIndex;
+       bool forwardSearch = (textIndex == __length) ? false : true;
+
+       if (__pCurrentTextColumn->GetTotalLineCount() > 0)
+       {
+               pTextLine = __pCurrentTextColumn->GetTextLine(0);
+               SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
+
+               lineBounds = pTextLine->GetBoundsF();
+               endType = pTextLine->GetEndType();
+
+               if (lineBounds.width != rect.width)
+               {
+                       isChanged = true;
+               }
+
+               lineOffset = pTextLine->GetTextOffset();
+               lineLength = pTextLine->GetTextLength();
+
+               if (lineOffset <= textIndex && textIndex < lineOffset + lineLength)
+               {
+                       isChanged = true;
+               }
+       }
+       else
+       {
+               pTextLine = new (std::nothrow)TextLine(this);
+               SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+
+               if (forwardSearch)
+               {
+                       if (pNoneWrapComposeInfo != null)
+                       {
+                               lineOffset = pNoneWrapComposeInfo->prevTextOffset;
+                       }
+                       else
+                       {
+                               lineOffset = 0;
+                       }
+               }
+               else
+               {
+                       lineOffset = __length - 1;
+               }
+
+               lineLength = 0;
+               lineBounds.width = rect.width;
+               lineBounds.x = 0;
+               lineBounds.y = 0;
+               lineBounds.height = 0;
+
+               __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
+
+               isChanged = true;
+       }
+
+       if (isChanged)
+       {
+               lineBounds.width = rect.width;
+               lineBounds.x = 0;
+               lineBounds.y = 0;
+
+               if (forwardSearch)
+               {
+                       endType = ForwardAnalyzeWithBaseline(lineOffset, __length - lineOffset, lineBounds.width, __wrap,
+                                                                         lineLength, textSize.width, textSize.height, baseline);
+
+                       lineBounds.height = textSize.height;
+                       pTextLine->SetBounds(lineBounds);
+                       pTextLine->SetTextOffset(lineOffset);
+                       pTextLine->SetTextLength(lineLength);
+                       pTextLine->SetRegion(textSize.width, textSize.height);
+                       pTextLine->SetEndType(endType);
+                       pTextLine->SetBaseline(baseline);
+                       GetTextExtentList(pTextLine);
+               }
+               else
+               {
+                       int textCount = 0;
 
-       GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
+                       BackwardAnalyze(lineOffset, lineBounds.width, &textCount, &textSize.width, &textSize.height);
 
-       lineBounds.width = (rect.width < lineTextSize.width) ? lineTextSize.width :rect.width;
-       lineBounds.height = lineTextSize.height;
-       baseline = lineBounds.height / 3.0f;
+                       lineBounds.height = textSize.height;
+                       lineOffset -= (textCount - 1);
+                       lineLength = textCount;
+                       endType = (lineOffset == 0) ? TEXT_RETBY_NORMAL : TEXT_RETBY_LIMITWIDTH;
+
+                       pTextLine->SetBounds(lineBounds);
+                       pTextLine->SetTextOffset(lineOffset);
+                       pTextLine->SetTextLength(lineLength);
+                       pTextLine->SetRegion(textSize.width, textSize.height);
+                       pTextLine->SetEndType(endType);
+                       pTextLine->SetBaseline(baseline);
+                       GetTextExtentList(pTextLine);
+               }
+       }
+
+       if (__length == 0)
+       {
+               pTextLine->SetEndType(TEXT_RETBY_NORMAL);
+               return 1;
+       }
+
+       rect.height = lineBounds.height;
+
+       if (textIndex < lineOffset)
+       {
+               lineOffset = textIndex;
+               endType = ForwardAnalyze(lineOffset, __length - lineOffset, lineBounds.width, __wrap,
+                                                                 lineLength, textSize.width, textSize.height);
+
+               lineBounds.height = textSize.height;
+       }
+       else if (forwardSearch && textIndex >= lineOffset + lineLength)
+       {
+               FloatDimension needDim;
+               GetRegion(lineOffset + lineLength, textIndex - (lineOffset + lineLength) + 1, needDim.width, needDim.height);
+
+               int index = 0;
+               float remainingWidth = needDim.width - (lineBounds.width - textSize.width);
+
+               FloatDimension charDim;
+               textSize.width += needDim.width;
+               lineLength += textIndex - (lineOffset + lineLength) + 1;
+
+               while (1)
+               {
+                       GetRegion(lineOffset, 1, charDim.width, charDim.height);
+                       lineOffset++;
+                       index++;
+                       remainingWidth -= charDim.width;
+                       textSize.width -= charDim.width;
+
+                       if (remainingWidth <= 0)
+                       {
+                               break;
+                       }
+               }
+
+               lineLength -= index;
+       }
+       else if (endType != TEXT_RETBY_LIMITWIDTH && lineLength != __length)
+       {
+               if (lineOffset > 0)
+               {
+                       FloatDimension lineTextSize;
+                       int textCount = 0;
+                       float remainingWidth = 0;
+
+                       pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
+                       remainingWidth = lineBounds.width - lineTextSize.width;
+                       BackwardAnalyze(lineOffset - 1, remainingWidth, &textCount, &textSize.width, &textSize.height);
+
+                       if (textSize.width > 0)
+                       {
+                               lineOffset -= textCount;
+                               lineLength += textCount;
+                               textSize.width += lineTextSize.width;
+                               lineBounds.height = textSize.height;
+                               endType = TEXT_RETBY_LIMITLENGTH;
+                       }
+                       else
+                       {
+                               return 1;
+                       }
+               }
+               else
+               {
+                       return 1;
+               }
+       }
+       else
+       {
+               return 1;
+       }
 
        pTextLine->SetBounds(lineBounds);
-       pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
-       pTextLine->SetTextOffset(0);
+       pTextLine->SetRegion(textSize.width, textSize.height);
        pTextLine->SetTextLength(lineLength);
-       pTextLine->SetEndType(TEXT_RETBY_NORMAL);
+       pTextLine->SetTextOffset(lineOffset);
+       pTextLine->SetEndType(endType);
        pTextLine->SetBaseline(baseline);
        GetTextExtentList(pTextLine);
 
-       __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
-
        return 1;
 }
 
@@ -4791,7 +4963,8 @@ TextComposite::ComposeInNoneWrapMiddleEllipsis(FloatRectangle& rect)
 
        maxHeight = textSize.height;
 
-       BackwardAnalyze(__length - 1, lineBounds.width - __middleEllipsisWidth - __middleEllipsisHeadWidth, length, textSize.width, textSize.height);
+       ForwardAnalyze(__middleEllipsisTextLengthInHead, __length - __middleEllipsisTextLengthInHead, lineBounds.width - __middleEllipsisWidth -
+                                  __middleEllipsisHeadWidth, __wrap, length, textSize.width, textSize.height);
 
        __middleEllipsisTextLengthInTail = length;
        maxHeight = (maxHeight < textSize.height) ? textSize.height : maxHeight;
@@ -4859,8 +5032,7 @@ TextComposite::ComposeInNoneWrapHeadEllipsis(FloatRectangle& rect)
        __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height);
        __headEllipsisWidth = abbrevTextDim.width;
 
-       BackwardAnalyze(__length - 1, lineBounds.width - abbrevTextDim.width, __headEllipsisTextLength, textSize.width, textSize.height);
-
+       BackwardAnalyze(__length - 1, lineBounds.width - abbrevTextDim.width, &__headEllipsisTextLength, &textSize.width, &textSize.height);
        maxHeight = textSize.height;
 
        TextLine* pTextLine = new (std::nothrow)TextLine(this);
@@ -4938,15 +5110,15 @@ TextComposite::GetValue(int textIndex, TextComponentInfoValueType type, unsigned
 }
 
 bool
-TextComposite::BackwardAnalyze(int startTextIndex, float maxWidth, int& actualLength, float& width, float& height)
+TextComposite::BackwardAnalyze(int startTextIndex, float maxWidth, int* actualLength, float* width, float* height)
 {
        float remainingWidth = 0;
        int length = 0;
        FloatDimension textSize;
 
-       actualLength = 0;
-       width = 0;
-       height = 0;
+       *actualLength = 0;
+       *width = 0;
+       *height = 0;
 
        remainingWidth = maxWidth;
        length = 1;
@@ -4957,9 +5129,9 @@ TextComposite::BackwardAnalyze(int startTextIndex, float maxWidth, int& actualLe
 
                if (textSize.width <= remainingWidth)
                {
-                       actualLength = length;
-                       width = textSize.width;
-                       height = textSize.height;
+                       *actualLength = length;
+                       *width = textSize.width;
+                       *height = textSize.height;
                }
 
                startTextIndex--;
index af6f58c..562f37f 100644 (file)
@@ -301,7 +301,7 @@ private:
 
        int ComposeInPartialMode(FloatRectangle& rect);
 
-       bool BackwardAnalyze(int startTextIndex, float maxWidth, int& actualLength, float& width, float& height);
+       bool BackwardAnalyze(int startTextIndex, float maxWidth, int* actualLength, float* width, float* height);
 
        result DrawAbbrevInMiddleEllipsis(_CanvasImpl& canvasImpl, const FloatRectangle& displayRect, const TextObjectAlignment alignment);
 
index c921346..df0175c 100644 (file)
@@ -98,6 +98,7 @@ TextObject::TextObject(void)
        __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_NORMAL] = Color::GetColor(COLOR_ID_BLUE);
        __linkColor[TEXT_OBJECT_LINK_COLOR_TYPE_PHONE_NUMBER_SELECT] = Color::GetColor(COLOR_ID_BLUE);
        __bidiHint = TEXT_BIDI_HINT_NONE;
+       __isDisplayBoundsExpandEnabled = false;
 
        __sweepInfo.isValid = false;
        __sweepInfo.sweepType = TEXT_OBJECT_SWEEP_TYPE_NONE;
@@ -426,10 +427,16 @@ CONTINUE_PROC:
        FloatRectangle finalClipRect;
        clipRect = canvasImpl.GetClipBoundsF();
 
-       finalClipRect.x = (clipRect.x > targetBounds.x) ? clipRect.x : targetBounds.x;
-       finalClipRect.y = (clipRect.y > targetBounds.y) ? clipRect.y: targetBounds.y;
-       finalClipRect.width = (clipRect.x + clipRect.width > targetBounds.x + targetBounds.width) ? (targetBounds.x + targetBounds.width) - finalClipRect.x : (clipRect.x + clipRect.width) - finalClipRect.x;
-       finalClipRect.height = (clipRect.y + clipRect.height > targetBounds.y + targetBounds.height) ? (targetBounds.y + targetBounds.height) - finalClipRect.y : (clipRect.y + clipRect.height) - finalClipRect.y;
+       finalClipRect.x = (clipRect.x > __rect.x) ? clipRect.x : __rect.x;
+       finalClipRect.y = (clipRect.y > __rect.y) ? clipRect.y: __rect.y;
+       finalClipRect.width = (clipRect.x + clipRect.width > __rect.x + __rect.width) ? (__rect.x + __rect.width) - finalClipRect.x : (clipRect.x + clipRect.width) - finalClipRect.x;
+       finalClipRect.height = (clipRect.y + clipRect.height > __rect.y + __rect.height) ? (__rect.y + __rect.height) - finalClipRect.y : (clipRect.y + clipRect.height) - finalClipRect.y;
+
+       if (__isDisplayBoundsExpandEnabled == true)
+       {
+               finalClipRect.y = clipRect.y;
+               finalClipRect.height = clipRect.height;
+       }
 
        SysTryReturn(NID_GRP, 0.0f <= finalClipRect.width && 0.0f <= finalClipRect.height, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get clip rectangle.");
 
@@ -730,7 +737,6 @@ TextObject::Compose(void)
                __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_UNKONWN, 0, 0);
                __pTextColumn->SetFirstDisplayLineIndex(0);
                __pTextColumn->SetFirstDisplayPositionY(0.0f);
-               __pTextColumn->SetFirstDisplayPositionX(0.0f);
        }
 
        ResetSweepInfo();
@@ -743,11 +749,10 @@ TextObject::Compose(void)
                TextLine* pTextLine = __pTextColumn->GetTextLine(0);
                if (pTextLine != null)
                {
-                       FloatRectangle lineBounds = pTextLine->GetBoundsF();
                        int lineLength = pTextLine->GetTextLength();
                        int totalLength = __pCompositeText->GetTextLength();
 
-                       if (lineLength < totalLength || __rect.width < lineBounds.width)
+                       if (lineLength < totalLength)
                        {
                                __isActionOn = true;
                                __pTextColumn->SetSlidingPosition(0.0f);
@@ -862,6 +867,11 @@ TextObject::SetFirstDisplayLineIndex(int lineIndex)
 {
        IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
 
+       if (lineIndex == 0 && __pTextColumn->GetTotalLineCount() == 0)
+       {
+               return E_SUCCESS;
+       }
+
        result r = E_SUCCESS;
        FloatRectangle lineBounds;
        TextLine* pTextLine = null;
@@ -892,53 +902,6 @@ CATCH:
 }
 
 result
-TextObject::SetFirstDisplayPositionX(int x)
-{
-       return SetFirstDisplayPositionX(_CoordinateSystemUtils::ConvertToFloat(x));
-}
-
-result
-TextObject::SetFirstDisplayPositionX(float x)
-{
-       IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
-       SysTryReturn(NID_GRP, __wrap == TEXT_OBJECT_WRAP_TYPE_NONE
-               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The argument is invalid.");
-
-       TextLine* pTextLine = __pTextColumn->GetTextLine(0);
-       SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
-
-       FloatRectangle lineBounds = pTextLine->GetBoundsF();
-
-       if (x < 0)
-       {
-               x = 0;
-       }
-
-       if (lineBounds.width - __rect.width < x)
-       {
-               x = lineBounds.width - __rect.width;
-       }
-
-       __pTextColumn->SetFirstDisplayPositionX(x);
-
-       return E_SUCCESS;
-}
-
-int
-TextObject::GetFirstDisplayPositionX(void) const
-{
-       return _CoordinateSystemUtils::ConvertToInteger(GetFirstDisplayPositionXF());
-}
-
-float
-TextObject::GetFirstDisplayPositionXF(void) const
-{
-       IF_NOT_CONSTRUCTED(return -1);
-
-       return __pTextColumn->GetFirstDisplayPositionX();
-}
-
-result
 TextObject::SetFirstDisplayPositionY(int y)
 {
        return SetFirstDisplayPositionY(_CoordinateSystemUtils::ConvertToFloat(y));
@@ -3421,7 +3384,6 @@ TextObject::GetTextPositionInfoInNoneWrapAt(int textIndex, float& width, float&
        SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
 
        int lineLength = pTextLine->GetTextLength();
-       float firstDisplayPositionX = __pTextColumn->GetFirstDisplayPositionX();
        float posX = 0.0f;
        float posY = 0.0f;
 
@@ -3499,7 +3461,7 @@ TextObject::GetTextPositionInfoInNoneWrapAt(int textIndex, float& width, float&
                break;
        }
 
-       absX = posX + textExtent.x - firstDisplayPositionX;
+       absX = posX + textExtent.x;
        logicalX = (absX >= 0.0f) ? absX + __rect.x : absX;
        absY = posY;
        logicalY = absY + __rect.y;
@@ -4227,4 +4189,22 @@ TextObject::GetTextBidiHint(void) const
        return __bidiHint;
 }
 
+result
+TextObject::SetDisplayBoundsExpandEnabled(bool enable)
+{
+       IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
+
+       __isDisplayBoundsExpandEnabled = enable;
+
+       return E_SUCCESS;
+}
+
+bool
+TextObject::IsDisplayBoundsExpandEnabled(void) const
+{
+       IF_NOT_CONSTRUCTED(return false);
+
+       return __isDisplayBoundsExpandEnabled;
+}
+
 }}} // Tizen::Graphics::_Text