diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2016-11-23 14:00:20 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2016-11-26 05:12:16 +0000 |
commit | 67936ee7ed717eb385b608d7eedcefa61fe13295 (patch) | |
tree | b1698e1dbb3cb2877b437901a8da3710ccc59347 /vcl/win/gdi | |
parent | aabc5aab5af27e929a81a6036d2f470ab1f5ac4d (diff) |
Kill old Graphite layout engines
Change-Id: Ia19d4d0a3a33694b6edfff62e6b40028dac19677
Reviewed-on: https://gerrit.libreoffice.org/31212
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
Diffstat (limited to 'vcl/win/gdi')
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 141 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 176 |
2 files changed, 1 insertions, 316 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index d2d964d47f4b..1c2cfe4289da 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -642,107 +642,11 @@ void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, Font& rFont ) } } -#if ENABLE_GRAPHITE - -#ifdef DEBUG -static FILE * grLogFile = NULL; -static FILE * grLog() -{ - std::string logFileName(getenv("TEMP")); - logFileName.append("\\grface.log"); - if (grLogFile == NULL) grLogFile = fopen(logFileName.c_str(),"w"); - else fflush(grLogFile); - return grLogFile; -} -#endif - -const void * getGrTable(const void* appFaceHandle, unsigned int name, size_t *len) -{ - const GrFontData * fontTables = static_cast<const GrFontData*>(appFaceHandle); - return fontTables->getTable(name, len); -} - -GrFontData::GrFontData(HDC hDC) : - mhDC(hDC), mpFace(nullptr), mnRefCount(1) -{ - // The face options ensure that the tables are all read at construction - // time so there is no need to keep the hDC uptodate - static const char* pGraphiteCacheStr = getenv( "SAL_GRAPHITE_CACHE_SIZE" ); - unsigned long graphiteSegCacheSize = pGraphiteCacheStr ? (atoi(pGraphiteCacheStr)) : 0; - if (graphiteSegCacheSize > 500) - mpFace = gr_make_face_with_seg_cache(this, getGrTable, - graphiteSegCacheSize, gr_face_preloadGlyphs | gr_face_cacheCmap); - else - mpFace = gr_make_face(this, getGrTable, - gr_face_preloadGlyphs | gr_face_cacheCmap); -#ifdef DEBUG - fprintf(grLog(), "gr_make_face %lx for WinFontData %lx\n", (unsigned long)mpFace, - (unsigned long)this); -#endif - mhDC = nullptr; -} - -GrFontData::~GrFontData() -{ - if (mpFace) - { -#ifdef DEBUG - fprintf(grLog(), "gr_face_destroy %lx for WinFontData %lx\n", (unsigned long)mpFace, - (unsigned long)this); -#endif - gr_face_destroy(mpFace); - mpFace = nullptr; - } - std::vector<RawFontData*>::iterator i = mvData.begin(); - while (i != mvData.end()) - { - delete *i; - ++i; - } - mvData.clear(); -} - -const void * GrFontData::getTable(unsigned int name, size_t *len) const -{ - assert(mhDC); - // swap the bytes - union TtfTag { - unsigned int i; - unsigned char c[4]; - }; - TtfTag littleEndianTag; - littleEndianTag.i = name; - TtfTag bigEndianTag; - bigEndianTag.c[0] = littleEndianTag.c[3]; - bigEndianTag.c[1] = littleEndianTag.c[2]; - bigEndianTag.c[2] = littleEndianTag.c[1]; - bigEndianTag.c[3] = littleEndianTag.c[0]; - mvData.push_back(new RawFontData(mhDC, bigEndianTag.i)); - const RawFontData * data = mvData[mvData.size()-1]; - if (data && (data->size() > 0)) - { - if (len) - *len = data->size(); - return static_cast<const void *>(data->get()); - } - else - { - if (len) - *len = 0; - return nullptr; - } -} -#endif - WinFontFace::WinFontFace( const FontAttributes& rDFS, int nHeight, BYTE eWinCharSet, BYTE nPitchAndFamily ) : PhysicalFontFace( rDFS ), mnId( 0 ), mbHasCJKSupport( false ), -#if ENABLE_GRAPHITE - mpGraphiteData(nullptr), - mbHasGraphiteSupport( false ), -#endif mbHasArabicSupport ( false ), mbFontCapabilitiesRead( false ), mxUnicodeMap( nullptr ), @@ -785,13 +689,7 @@ WinFontFace::~WinFontFace() { if( mxUnicodeMap.Is() ) mxUnicodeMap = nullptr; -#if ENABLE_GRAPHITE - if (mpGraphiteData) - mpGraphiteData->DeReference(); -#ifdef DEBUG - fprintf(grLog(), "WinFontFace::~WinFontFace %lx\n", (unsigned long)this); -#endif -#endif // ENABLE_GRAPHITE + delete mpEncodingVector; if( mpHbFont ) @@ -814,45 +712,8 @@ void WinFontFace::UpdateFromHDC( HDC hDC ) const ReadCmapTable( hDC ); GetFontCapabilities( hDC ); -#if ENABLE_GRAPHITE - static const char* pDisableGraphiteText = getenv( "SAL_DISABLE_GRAPHITE" ); - if( !pDisableGraphiteText || (pDisableGraphiteText[0] == '0') ) - { - const DWORD nSilfTag = CalcTag("Silf"); - const RawFontData aRawFontData( hDC, nSilfTag ); - mbHasGraphiteSupport = (aRawFontData.size() > 0); - if (mbHasGraphiteSupport) - { -#ifdef DEBUG - fprintf(grLog(), "WinFontFace::UpdateFromHDC %lx\n", - (unsigned long)this); -#endif - if (mpGraphiteData == nullptr) - { - mpGraphiteData = new GrFontData(hDC); - if (!mpGraphiteData->getFace()) - { - mbHasGraphiteSupport = false; - delete mpGraphiteData; - mpGraphiteData = nullptr; - } - } - } - } -#endif } -#if ENABLE_GRAPHITE -const gr_face* WinFontFace::GraphiteFace() const -{ -#ifdef DEBUG - fprintf(grLog(), "WinFontFace::GraphiteFace %lx has face %lx\n", - (unsigned long)this, mpGraphiteData? mpGraphiteData->getFace(): 0); -#endif - return (mpGraphiteData)? mpGraphiteData->getFace() : nullptr; -} -#endif - bool WinFontFace::HasGSUBstitutions( HDC hDC ) const { if( !mbGsubRead ) diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index 4941ac7cad3a..1cb227bc85d4 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -3430,164 +3430,6 @@ bool D2DWriteTextOutRenderer::GetDWriteInkBox(SalLayout const &rLayout, Rectangl return true; } -#if ENABLE_GRAPHITE - -sal_GlyphId GraphiteLayoutWinImpl::getKashidaGlyph(int & rWidth) -{ - rWidth = mrFont.GetMinKashidaWidth(); - return mrFont.GetMinKashidaGlyph(); -} - -float gr_fontAdvance(const void* appFontHandle, gr_uint16 glyphId) -{ - HDC hDC = static_cast<HDC>(const_cast<void*>(appFontHandle)); - GLYPHMETRICS gm; - const MAT2 mat2 = {{0,1}, {0,0}, {0,0}, {0,1}}; - if (GDI_ERROR == GetGlyphOutlineW(hDC, glyphId, GGO_GLYPH_INDEX | GGO_METRICS, - &gm, 0, nullptr, &mat2)) - { - return .0f; - } - return gm.gmCellIncX; -} - -GraphiteWinLayout::GraphiteWinLayout(HDC hDC, const WinFontFace& rWFD, WinFontInstance& rWFE, bool bUseOpenGL) throw() - : WinLayout(hDC, rWFD, rWFE, bUseOpenGL), mpFont(nullptr), - maImpl(rWFD.GraphiteFace(), rWFE) -{ - // the log font size may differ from the font entry size if scaling is used for large fonts - LOGFONTW aLogFont; - GetObjectW( mhFont, sizeof(LOGFONTW), &aLogFont); - mpFont = gr_make_font_with_advance_fn(static_cast<float>(-aLogFont.lfHeight), - hDC, gr_fontAdvance, rWFD.GraphiteFace()); - maImpl.SetFont(mpFont); - const OString aLang = OUStringToOString( LanguageTag::convertToBcp47( rWFE.maFontSelData.meLanguage ), - RTL_TEXTENCODING_ASCII_US); - OString name = OUStringToOString( - rWFE.maFontSelData.maTargetName, RTL_TEXTENCODING_UTF8 ); - sal_Int32 nFeat = name.indexOf(FontSelectPatternAttributes::FEAT_PREFIX) + 1; - if (nFeat > 0) - { - OString aFeat = name.copy(nFeat, name.getLength() - nFeat); - mpFeatures = new grutils::GrFeatureParser(rWFD.GraphiteFace(), aFeat.getStr(), aLang.getStr()); - } - else - { - mpFeatures = new grutils::GrFeatureParser(rWFD.GraphiteFace(), aLang.getStr()); - } - maImpl.SetFeatures(mpFeatures); -} - -GraphiteWinLayout::~GraphiteWinLayout() -{ - delete mpFeatures; - gr_font_destroy(maImpl.GetFont()); -} - -bool GraphiteWinLayout::LayoutText(ImplLayoutArgs & args) -{ - HFONT hUnRotatedFont = nullptr; - if (args.mnOrientation) - { - // Graphite gets very confused if the font is rotated - LOGFONTW aLogFont; - GetObjectW( mhFont, sizeof(LOGFONTW), &aLogFont); - aLogFont.lfEscapement = 0; - aLogFont.lfOrientation = 0; - hUnRotatedFont = CreateFontIndirectW( &aLogFont); - SelectFont(mhDC, hUnRotatedFont); - } - WinLayout::AdjustLayout(args); - maImpl.SetFontScale(WinLayout::mfFontScale); - bool bSucceeded = maImpl.LayoutText(args); - if (args.mnOrientation) - { - // restore the rotated font - SelectFont(mhDC, mhFont); - DeleteObject(hUnRotatedFont); - } - return bSucceeded; -} - -void GraphiteWinLayout::AdjustLayout(ImplLayoutArgs& rArgs) -{ - WinLayout::AdjustLayout(rArgs); - maImpl.DrawBase() = WinLayout::maDrawBase; - maImpl.DrawOffset() = WinLayout::maDrawOffset; - if ( (rArgs.mnFlags & SalLayoutFlags::BiDiRtl) && rArgs.mpDXArray) - { - mrWinFontEntry.InitKashidaHandling(mhDC); - } - maImpl.AdjustLayout(rArgs); -} - -bool GraphiteWinLayout::DrawTextImpl(HDC hDC, - const Rectangle* pRectToErase, - Point* pPos, - int* pGetNextGlypInfo) const -{ - HFONT hOrigFont = DisableFontScaling(); - maImpl.DrawBase() = WinLayout::maDrawBase; - maImpl.DrawOffset() = WinLayout::maDrawOffset; - - TextOutRenderer & render = TextOutRenderer::get(true); - bool const ok = render(*this, hDC, pRectToErase, pPos, pGetNextGlypInfo); - if( hOrigFont ) - DeleteFont(SelectFont(hDC, hOrigFont)); - return ok; -} - -bool GraphiteWinLayout::CacheGlyphs(SalGraphics& /*rGraphics*/) const -{ - return false; -} - -bool GraphiteWinLayout::DrawCachedGlyphs(SalGraphics& /*rGraphics*/) const -{ - return false; -} - -sal_Int32 GraphiteWinLayout::GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const -{ - sal_Int32 nBreak = maImpl.GetTextBreak(nMaxWidth, nCharExtra, nFactor); - return nBreak; -} - -DeviceCoordinate GraphiteWinLayout::FillDXArray( DeviceCoordinate* pDXArray ) const -{ - return maImpl.FillDXArray(pDXArray); -} - -void GraphiteWinLayout::GetCaretPositions( int nArraySize, long* pCaretXArray ) const -{ - maImpl.GetCaretPositions(nArraySize, pCaretXArray); -} - -int GraphiteWinLayout::GetNextGlyphs( int length, sal_GlyphId* glyph_out, - Point& pos_out, int& glyph_slot, DeviceCoordinate* glyph_adv, int* char_index, - const PhysicalFontFace** pFallbackFonts ) const -{ - maImpl.DrawBase() = WinLayout::maDrawBase; - maImpl.DrawOffset() = WinLayout::maDrawOffset; - return maImpl.GetNextGlyphs(length, glyph_out, pos_out, glyph_slot, glyph_adv, char_index, pFallbackFonts); -} - -void GraphiteWinLayout::MoveGlyph( int glyph_idx, long new_x_pos ) -{ - maImpl.MoveGlyph(glyph_idx, new_x_pos); -} - -void GraphiteWinLayout::DropGlyph( int glyph_idx ) -{ - maImpl.DropGlyph(glyph_idx); -} - -void GraphiteWinLayout::Simplify( bool is_base ) -{ - maImpl.Simplify(is_base); -} -#endif // ENABLE_GRAPHITE - SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel ) { if (!mpWinFontEntry[nFallbackLevel]) return nullptr; @@ -3612,13 +3454,6 @@ SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe 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); @@ -3629,13 +3464,6 @@ SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe } 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); @@ -3756,10 +3584,6 @@ bool WinFontInstance::InitKashidaHandling( HDC hDC ) PhysicalFontFace* WinFontFace::Clone() const { -#if ENABLE_GRAPHITE - if ( mpGraphiteData ) - mpGraphiteData->AddReference(); -#endif if( mpHbFont ) hb_font_reference( mpHbFont ); |