Kaydet (Commit) f6db8af1 authored tarafından Akash Jain's avatar Akash Jain Kaydeden (comit) Khaled Hosny

GSoC: Integrate new CommonSalLayout in win/ code

Change-Id: Ifeb2fa7ca9e2cd0da1c504d4e770aa0bb1b0b0de
üst 828b8cf4
......@@ -57,7 +57,12 @@ static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pU
hb_blob_t* pBlob = nullptr;
if (pBuffer != nullptr)
#if defined(_WIN32)
pBlob = hb_blob_create(reinterpret_cast<const char*>(pBuffer), nLength, HB_MEMORY_MODE_READONLY,
const_cast<unsigned char*>(pBuffer), [](void* data){ delete[] reinterpret_cast<unsigned char*>(data); });
#else
pBlob = hb_blob_create(reinterpret_cast<const char*>(pBuffer), nLength, HB_MEMORY_MODE_READONLY, nullptr, nullptr);
#endif
return pBlob;
}
......@@ -74,12 +79,18 @@ static hb_unicode_funcs_t* getUnicodeFuncs()
#if defined(_WIN32)
CommonSalLayout::CommonSalLayout(HDC hDC, WinFontInstance& rWinFontInstance)
: mhDC(hDC),
mhFont((HFONT)GetCurrentObject(hDC, OBJ_FONT)),
mpHbFace(nullptr),
maFontSelData(rWinFontInstance.maFontSelData)
{
mpHbFace = hb_face_create_for_tables(getFontTable, &hDC, nullptr);
}
void CommonSalLayout::InitFont() const
{
SelectObject(mhDC, mhFont);
}
#elif defined(MACOSX) || defined(IOS)
CommonSalLayout::CommonSalLayout(const CoreTextStyle& rCoreTextStyle)
: mpHbFace(nullptr),
......
......@@ -2454,7 +2454,4 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
}
}
void WinSalGraphics::DrawSalLayout( const CommonSalLayout& )
{}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -34,6 +34,7 @@
#include "sft.hxx"
#include "sallayout.hxx"
#include "CommonSalLayout.hxx"
#include <cstdio>
#include <cstdlib>
......@@ -67,7 +68,7 @@ public:
virtual ~TextOutRenderer() = default;
virtual bool operator ()(WinLayout const &rLayout, HDC hDC,
virtual bool operator ()(SalLayout const &rLayout, HDC hDC,
const Rectangle* pRectToErase,
Point* pPos, int* pGetNextGlypInfo) = 0;
};
......@@ -81,7 +82,7 @@ public:
explicit ExTextOutRenderer() = default;
virtual ~ExTextOutRenderer() override = default;
bool operator ()(WinLayout const &rLayout, HDC hDC,
bool operator ()(SalLayout const &rLayout, HDC hDC,
const Rectangle* pRectToErase,
Point* pPos, int* pGetNextGlypInfo) override;
};
......@@ -106,7 +107,7 @@ public:
explicit D2DWriteTextOutRenderer();
virtual ~D2DWriteTextOutRenderer() override;
bool operator ()(WinLayout const &rLayout, HDC hDC,
bool operator ()(SalLayout const &rLayout, HDC hDC,
const Rectangle* pRectToErase,
Point* pPos, int* pGetNextGlypInfo) override;
......@@ -138,7 +139,7 @@ private:
D2DWriteTextOutRenderer & operator = (const D2DWriteTextOutRenderer &) = delete;
bool GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** ppFontFace, float * lfSize) const;
bool GetDWriteInkBox(IDWriteFontFace & rFontFace, WinLayout const &rLayout, float const lfEmHeight, Rectangle &) const;
bool GetDWriteInkBox(IDWriteFontFace & rFontFace, SalLayout const &rLayout, float const lfEmHeight, Rectangle &) const;
ID2D1Factory * mpD2DFactory;
IDWriteFactory * mpDWriteFactory;
......@@ -3483,7 +3484,7 @@ TextOutRenderer & TextOutRenderer::get()
}
bool ExTextOutRenderer::operator ()(WinLayout const &rLayout, HDC hDC,
bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC,
const Rectangle* pRectToErase,
Point* pPos, int* pGetNextGlypInfo)
{
......@@ -3542,7 +3543,7 @@ D2DWriteTextOutRenderer::~D2DWriteTextOutRenderer()
CleanupModules();
}
bool D2DWriteTextOutRenderer::operator ()(WinLayout const &rLayout, HDC hDC,
bool D2DWriteTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC,
const Rectangle* pRectToErase,
Point* pPos, int* pGetNextGlypInfo)
{
......@@ -3708,7 +3709,7 @@ bool D2DWriteTextOutRenderer::GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** p
return succeeded;
}
bool D2DWriteTextOutRenderer::GetDWriteInkBox(IDWriteFontFace & rFontFace, WinLayout const &rLayout, float const /*lfEmHeight*/, Rectangle & rOut) const
bool D2DWriteTextOutRenderer::GetDWriteInkBox(IDWriteFontFace & rFontFace, SalLayout const &rLayout, float const /*lfEmHeight*/, Rectangle & rOut) const
{
rOut.SetEmpty();
......@@ -3903,66 +3904,73 @@ SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe
const WinFontFace& rFontFace = *mpWinFontData[ nFallbackLevel ];
WinFontInstance& rFontInstance = *mpWinFontEntry[ nFallbackLevel ];
bool bUseOpenGL = OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter;
if (!bUspInited)
InitUSP();
if( !(rArgs.mnFlags & SalLayoutFlags::ComplexDisabled) )
if (getenv("SAL_USE_COMMON_LAYOUT"))
{
#if ENABLE_GRAPHITE
if (rFontFace.SupportsGraphite())
{
pWinLayout = new GraphiteWinLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL);
}
else
#endif // ENABLE_GRAPHITE
{
// script complexity is determined in upper layers
pWinLayout = new UniscribeLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL);
// NOTE: it must be guaranteed that the WinSalGraphics lives longer than
// the created UniscribeLayout, otherwise the data passed into the
// constructor might become invalid too early
}
return new CommonSalLayout(getHDC(), rFontInstance);
}
else
{
#if ENABLE_GRAPHITE
if (rFontFace.SupportsGraphite())
{
pWinLayout = new GraphiteWinLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL);
}
else
#endif // ENABLE_GRAPHITE
{
static bool bAvoidSimpleWinLayout = (std::getenv("VCL_NO_SIMPLEWINLAYOUT") != nullptr);
bool bUseOpenGL = OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter;
if (!bAvoidSimpleWinLayout)
{
if( (rArgs.mnFlags & SalLayoutFlags::KerningPairs) && !rFontInstance.HasKernData() )
{
// TODO: directly cache kerning info in the rFontInstance
// TODO: get rid of kerning methods+data in WinSalGraphics object
GetKernPairs();
rFontInstance.SetKernData( mnFontKernPairCount, mpFontKernPairs );
}
if (!bUspInited)
InitUSP();
pWinLayout = new SimpleWinLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL);
if( !(rArgs.mnFlags & SalLayoutFlags::ComplexDisabled) )
{
#if ENABLE_GRAPHITE
if (rFontFace.SupportsGraphite())
{
pWinLayout = new GraphiteWinLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL);
}
else
#endif // ENABLE_GRAPHITE
{
// script complexity is determined in upper layers
pWinLayout = new UniscribeLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL);
// NOTE: it must be guaranteed that the WinSalGraphics lives longer than
// the created UniscribeLayout, otherwise the data passed into the
// constructor might become invalid too early
}
}
}
else
{
#if ENABLE_GRAPHITE
if (rFontFace.SupportsGraphite())
{
pWinLayout = new GraphiteWinLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL);
}
else
#endif // ENABLE_GRAPHITE
{
static bool bAvoidSimpleWinLayout = (std::getenv("VCL_NO_SIMPLEWINLAYOUT") != nullptr);
if( mfFontScale[nFallbackLevel] != 1.0 )
pWinLayout->SetFontScale( mfFontScale[nFallbackLevel] );
if (!bAvoidSimpleWinLayout)
{
if( (rArgs.mnFlags & SalLayoutFlags::KerningPairs) && !rFontInstance.HasKernData() )
{
// TODO: directly cache kerning info in the rFontInstance
// TODO: get rid of kerning methods+data in WinSalGraphics object
GetKernPairs();
rFontInstance.SetKernData( mnFontKernPairCount, mpFontKernPairs );
}
return pWinLayout;
pWinLayout = new SimpleWinLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL);
}
else
{
pWinLayout = new UniscribeLayout(getHDC(), rFontFace, rFontInstance, bUseOpenGL);
// NOTE: it must be guaranteed that the WinSalGraphics lives longer than
// the created UniscribeLayout, otherwise the data passed into the
// constructor might become invalid too early
}
}
}
if( mfFontScale[nFallbackLevel] != 1.0 )
pWinLayout->SetFontScale( mfFontScale[nFallbackLevel] );
return pWinLayout;
}
}
int WinSalGraphics::GetMinKashidaWidth()
......@@ -4071,4 +4079,32 @@ LogicalFontInstance* WinFontFace::CreateFontInstance( FontSelectPattern& rFSD )
return pFontInstance;
}
void WinSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
{
HDC hDC = getHDC();
if (getenv("SAL_DWRITE_COMMON_LAYOUT"))
{
Point aPos(0, 0);
int nGlyphCount(0);
TextOutRenderer &render = TextOutRenderer::get();
bool result = render(rLayout, hDC, nullptr, &aPos, &nGlyphCount);
assert(!result);
}
else
{
Point aPos;
sal_GlyphId aGlyphId;
int nFetchedGlyphs = 0;
UINT oldTa = GetTextAlign(hDC);
SetTextAlign(hDC, (oldTa & ~TA_NOUPDATECP));
while (rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nFetchedGlyphs))
{
ExtTextOutW(hDC, aPos.X(), aPos.Y(), ETO_GLYPH_INDEX, nullptr, reinterpret_cast<LPCWSTR>(&aGlyphId),
1, nullptr);
}
SetTextAlign(hDC, oldTa);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment