diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-11-13 15:54:00 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-11-23 14:25:58 +0000 |
commit | b0f5416d7ee7c988d316df7ffa0318fa6514e4de (patch) | |
tree | c196c9966ee53499559806050bb2f01195d91c23 /vcl/headless | |
parent | e34f290eec4f3c8d42724f1602029f5680aecde6 (diff) |
Do all svp text rendering with cairo
enabling us to delete a whole pile of foo
For android we patch cairo, which is internal in that case, to swap the rgb
components so that cairo then matches the OpenGL GL_RGBA format so we can use
it there where we don't have GL_BGRA support.
Change-Id: I25e34889c7b7263438b143dd2a2ad882fb0f190a
Diffstat (limited to 'vcl/headless')
-rw-r--r-- | vcl/headless/svpcairotextrender.cxx | 63 | ||||
-rw-r--r-- | vcl/headless/svpcairotextrender.hxx | 36 | ||||
-rw-r--r-- | vcl/headless/svpgdi.cxx | 31 | ||||
-rw-r--r-- | vcl/headless/svpglyphcache.cxx | 71 | ||||
-rw-r--r-- | vcl/headless/svpinst.cxx | 28 | ||||
-rw-r--r-- | vcl/headless/svptextrender.cxx | 500 | ||||
-rw-r--r-- | vcl/headless/svpvd.cxx | 7 |
7 files changed, 198 insertions, 538 deletions
diff --git a/vcl/headless/svpcairotextrender.cxx b/vcl/headless/svpcairotextrender.cxx new file mode 100644 index 000000000000..06abf0ccc48a --- /dev/null +++ b/vcl/headless/svpcairotextrender.cxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "svpcairotextrender.hxx" +#include "headless/svpgdi.hxx" + +SvpCairoTextRender::SvpCairoTextRender(SvpSalGraphics& rParent) + : mrParent(rParent) +{ +} + +GlyphCache& SvpCairoTextRender::getPlatformGlyphCache() +{ + return SvpSalGraphics::getPlatformGlyphCache(); +} + +cairo_t* SvpCairoTextRender::getCairoContext() +{ + cairo_t* pRet = mrParent.getCairoContext(); + if (!pRet) + { + mxTmpSurface = mrParent.createSimpleMask(); + pRet = SvpSalGraphics::createCairoContext(mxTmpSurface); + } + return pRet; +} + +void SvpCairoTextRender::getSurfaceOffset(double& nDX, double& nDY) +{ + nDX = 0; + nDY = 0; +} + +void SvpCairoTextRender::clipRegion(cairo_t* cr) +{ + mrParent.clipRegion(cr); +} + +basebmp::BitmapDeviceSharedPtr SvpCairoTextRender::createSimpleMask() +{ + return mrParent.createSimpleMask(); +} + +void SvpCairoTextRender::drawSurface(cairo_t*) +{ + //typically we have drawn directly to the real surface, in edge-cases of + //strange surface depths, we'll have drawn into a tmp surface, so flush + //it + if (mxTmpSurface) + { + // blend text color into target using the glyph's mask + mrParent.BlendTextColor(basebmp::Color(GetTextColor()), mxTmpSurface, basegfx::B2IPoint(0, 0)); + mxTmpSurface.reset(); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpcairotextrender.hxx b/vcl/headless/svpcairotextrender.hxx new file mode 100644 index 000000000000..daae42c51842 --- /dev/null +++ b/vcl/headless/svpcairotextrender.hxx @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_UNX_GTK3_GDI_GTK3CAIROTEXTRENDER_HXX +#define INCLUDED_VCL_UNX_GTK3_GDI_GTK3CAIROTEXTRENDER_HXX + +#include "cairotextrender.hxx" + +class SvpSalGraphics; + +class SvpCairoTextRender : public CairoTextRender +{ +protected: + basebmp::BitmapDeviceSharedPtr mxTmpSurface; + SvpSalGraphics& mrParent; + +public: + explicit SvpCairoTextRender(SvpSalGraphics& rParent); + + virtual GlyphCache& getPlatformGlyphCache() override; + virtual cairo_t* getCairoContext() override; + virtual void getSurfaceOffset(double& nDX, double& nDY) override; + virtual void clipRegion(cairo_t* cr) override; + virtual void drawSurface(cairo_t* cr) override; + virtual basebmp::BitmapDeviceSharedPtr createSimpleMask() override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 9ed0870db5a2..05e673cda733 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -20,7 +20,7 @@ #include "headless/svpgdi.hxx" #include "headless/svpbmp.hxx" #ifndef IOS -#include "headless/svptextrender.hxx" +#include "svpcairotextrender.hxx" #endif #include "saldatabasic.hxx" @@ -101,19 +101,33 @@ namespace if (!rBuffer) return false; - if (rBuffer->getScanlineFormat() != basebmp::Format::ThirtyTwoBitTcMaskBGRX) + if (rBuffer->getScanlineFormat() != SVP_CAIRO_FORMAT + && rBuffer->getScanlineFormat() != basebmp::Format::OneBitLsbGrey) return false; #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0) basegfx::B2IVector size = rBuffer->getSize(); sal_Int32 nStride = rBuffer->getScanlineStride(); - return (cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, size.getX()) == nStride); + cairo_format_t nFormat; + if (rBuffer->getScanlineFormat() == SVP_CAIRO_FORMAT) + nFormat = CAIRO_FORMAT_RGB24; + else + nFormat = CAIRO_FORMAT_A1; + return (cairo_format_stride_for_width(nFormat, size.getX()) == nStride); #else return false; #endif } } +#endif + +basebmp::BitmapDeviceSharedPtr SvpSalGraphics::createSimpleMask() const +{ + return basebmp::createBitmapDevice(m_aOrigDevice->getSize(), true, basebmp::Format::OneBitLsbGrey, + cairo_format_stride_for_width(CAIRO_FORMAT_A1, m_aOrigDevice->getSize().getX())); +} + void SvpSalGraphics::clipRegion(cairo_t* cr) { RectangleVector aRectangles; @@ -222,7 +236,7 @@ SvpSalGraphics::SvpSalGraphics() : m_aDrawMode( basebmp::DrawMode::Paint ), m_bClipSetup( false ) { - m_xTextRenderImpl.reset(new SvpTextRender(*this)); + m_xTextRenderImpl.reset(new SvpCairoTextRender(*this)); } SvpSalGraphics::~SvpSalGraphics() @@ -236,8 +250,6 @@ void SvpSalGraphics::setDevice( basebmp::BitmapDeviceSharedPtr& rDevice ) m_xTextRenderImpl->setDevice(rDevice); } -#endif - void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) { rDPIX = rDPIY = 96; @@ -949,9 +961,14 @@ cairo_t* SvpSalGraphics::createCairoContext(const basebmp::BitmapDeviceSharedPtr sal_Int32 nStride = rBuffer->getScanlineStride(); basebmp::RawMemorySharedArray data = rBuffer->getBuffer(); + cairo_format_t nFormat; + if (rBuffer->getScanlineFormat() == SVP_CAIRO_FORMAT) + nFormat = CAIRO_FORMAT_RGB24; + else + nFormat = CAIRO_FORMAT_A1; cairo_surface_t *target = cairo_image_surface_create_for_data(data.get(), - CAIRO_FORMAT_RGB24, + nFormat, size.getX(), size.getY(), nStride); cairo_t* cr = cairo_create(target); diff --git a/vcl/headless/svpglyphcache.cxx b/vcl/headless/svpglyphcache.cxx new file mode 100644 index 000000000000..833e750c66a4 --- /dev/null +++ b/vcl/headless/svpglyphcache.cxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/types.h> + +#include <cassert> + +#include <rtl/instance.hxx> +#include <tools/debug.hxx> + +#include "generic/geninst.h" +#include "generic/glyphcache.hxx" +#include "headless/svpgdi.hxx" + +class SvpGlyphPeer : public GlyphCachePeer +{ +public: + SvpGlyphPeer() {} +}; + +namespace +{ + struct GlyphCacheHolder + { + private: + SvpGlyphPeer* m_pSvpGlyphPeer; + GlyphCache* m_pSvpGlyphCache; + public: + GlyphCacheHolder() + { + m_pSvpGlyphPeer = new SvpGlyphPeer(); + m_pSvpGlyphCache = new GlyphCache( *m_pSvpGlyphPeer ); + } + GlyphCache& getGlyphCache() + { + return *m_pSvpGlyphCache; + } + ~GlyphCacheHolder() + { + delete m_pSvpGlyphCache; + delete m_pSvpGlyphPeer; + } + }; + + struct theGlyphCacheHolder : + public rtl::Static<GlyphCacheHolder, theGlyphCacheHolder> + {}; +} + +GlyphCache& SvpSalGraphics::getPlatformGlyphCache() +{ + return theGlyphCacheHolder::get().getGlyphCache(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 9c941a069f07..fc2420010be3 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -31,12 +31,12 @@ #include "headless/svpdummies.hxx" #include "headless/svpvd.hxx" #ifdef IOS -#include "headless/svpgdi.hxx" #include "quartz/salbmp.h" #include "quartz/salgdi.h" #include "quartz/salvd.h" #endif #include "headless/svpbmp.hxx" +#include "headless/svpgdi.hxx" #include <salframe.hxx> #include <svdata.hxx> @@ -200,12 +200,12 @@ bool SvpSalInstance::CheckTimeout( bool bExecuteTimers ) SalFrame* SvpSalInstance::CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) { - return new SvpSalFrame( this, nullptr, nStyle, SVP_DEFAULT_BITMAP_FORMAT, pParent ); + return new SvpSalFrame( this, nullptr, nStyle, SVP_CAIRO_FORMAT, pParent ); } SalFrame* SvpSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) { - return new SvpSalFrame( this, pParent, nStyle, SVP_DEFAULT_BITMAP_FORMAT ); + return new SvpSalFrame( this, pParent, nStyle, SVP_CAIRO_FORMAT ); } void SvpSalInstance::DestroyFrame( SalFrame* pFrame ) @@ -416,20 +416,8 @@ void SvpSalTimer::Start( sal_uLong nMS ) m_pInstance->StartTimer( nMS ); } -void SvpSalInstance::setBitCountFormatMapping( sal_uInt16 nBitCount, - Format aFormat ) -{ - m_aBitCountFormatMap[nBitCount] = aFormat; -} - Format SvpSalInstance::getFormatForBitCount( sal_uInt16 nBitCount ) { - BitCountFormatMap::iterator aIt; - if ( (aIt = m_aBitCountFormatMap.find( nBitCount )) != m_aBitCountFormatMap.end() ) - { - return aIt->second; - } - switch( nBitCount ) { case 1: @@ -444,18 +432,10 @@ Format SvpSalInstance::getFormatForBitCount( sal_uInt16 nBitCount ) #else return Format::SixteenBitLsbTcMask; #endif - case 24: - return Format::ThirtyTwoBitTcMaskBGRX; case 32: return Format::ThirtyTwoBitTcMaskBGRA; - case 0: -#ifdef ANDROID - return Format::ThirtyTwoBitTcMaskRGBA; -#else - return Format::ThirtyTwoBitTcMaskBGRX; -#endif default: - return SVP_DEFAULT_BITMAP_FORMAT; + return SVP_CAIRO_FORMAT; } } diff --git a/vcl/headless/svptextrender.cxx b/vcl/headless/svptextrender.cxx deleted file mode 100644 index c4bc49e827ab..000000000000 --- a/vcl/headless/svptextrender.cxx +++ /dev/null @@ -1,500 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sal/types.h> - -#include <cassert> - -#include <basebmp/scanlineformats.hxx> -#include <basegfx/polygon/b2dpolypolygon.hxx> -#include <basegfx/range/b2drange.hxx> -#include <basegfx/range/b2ibox.hxx> -#include <rtl/instance.hxx> -#include <tools/debug.hxx> -#include <vcl/sysdata.hxx> -#include <config_cairo_canvas.h> - -#include "generic/geninst.h" -#include "generic/genpspgraphics.h" -#include "generic/glyphcache.hxx" -#include "headless/svpbmp.hxx" -#include "headless/svpgdi.hxx" -#include "headless/svptextrender.hxx" -#include "impfont.hxx" -#include "outfont.hxx" -#include "PhysicalFontFace.hxx" - -class PhysicalFontCollection; - -using namespace basegfx; -using namespace basebmp; - -class SvpGlyphPeer : public GlyphCachePeer -{ -public: - SvpGlyphPeer() {} - - BitmapDeviceSharedPtr GetGlyphBmp( ServerFont&, sal_GlyphId, - basebmp::Format nBmpFormat, B2IPoint& rTargetPos ); - -protected: - virtual void RemovingFont( ServerFont& ) override; - virtual void RemovingGlyph( GlyphData& ) override; - -}; - -class SvpGcpHelper -{ -public: - RawBitmap maRawBitmap; - BitmapDeviceSharedPtr maBitmapDev; -}; - -class SvpGlyphCache : public GlyphCache -{ -public: - explicit SvpGlyphCache( SvpGlyphPeer& rPeer ) : GlyphCache( rPeer) {} - SvpGlyphPeer& GetPeer() { return reinterpret_cast<SvpGlyphPeer&>( mrPeer ); } - static SvpGlyphCache& GetInstance(); -}; - -namespace -{ - struct GlyphCacheHolder - { - private: - SvpGlyphPeer* m_pSvpGlyphPeer; - SvpGlyphCache* m_pSvpGlyphCache; - public: - GlyphCacheHolder() - { - m_pSvpGlyphPeer = new SvpGlyphPeer(); - m_pSvpGlyphCache = new SvpGlyphCache( *m_pSvpGlyphPeer ); - } - SvpGlyphCache& getGlyphCache() - { - return *m_pSvpGlyphCache; - } - ~GlyphCacheHolder() - { - delete m_pSvpGlyphCache; - delete m_pSvpGlyphPeer; - } - }; - - struct theGlyphCacheHolder : - public rtl::Static<GlyphCacheHolder, theGlyphCacheHolder> - {}; -} - -SvpGlyphCache& SvpGlyphCache::GetInstance() -{ - return theGlyphCacheHolder::get().getGlyphCache(); -} - -BitmapDeviceSharedPtr SvpGlyphPeer::GetGlyphBmp( ServerFont& rServerFont, - sal_GlyphId aGlyphId, basebmp::Format nBmpFormat, B2IPoint& rTargetPos ) -{ - GlyphData& rGlyphData = rServerFont.GetGlyphData( aGlyphId ); - - if( rGlyphData.ExtDataRef().meInfo != nBmpFormat ) - { - SvpGcpHelper* pGcpHelper = rGlyphData.ExtDataRef().mpData; - bool bNew = pGcpHelper == nullptr; - if( bNew ) - pGcpHelper = new SvpGcpHelper; - - // get glyph bitmap in matching format - bool bFound = false; - switch( nBmpFormat ) - { - case Format::OneBitLsbGrey: - bFound = rServerFont.GetGlyphBitmap1( aGlyphId, pGcpHelper->maRawBitmap ); - break; - case Format::EightBitGrey: - bFound = rServerFont.GetGlyphBitmap8( aGlyphId, pGcpHelper->maRawBitmap ); - break; - default: - OSL_FAIL( "SVP GCP::GetGlyphBmp(): illegal scanline format"); - // fall back to black&white mask - nBmpFormat = Format::OneBitLsbGrey; - bFound = false; - break; - } - - // return .notdef glyph if needed - if( !bFound && (aGlyphId != 0) ) - { - if( bNew ) - delete pGcpHelper; - return GetGlyphBmp( rServerFont, 0, nBmpFormat, rTargetPos ); - } - - // construct alpha mask from raw bitmap - if (pGcpHelper->maRawBitmap.mnScanlineSize && pGcpHelper->maRawBitmap.mnHeight) - { - const B2IVector aSize( - pGcpHelper->maRawBitmap.mnScanlineSize, - pGcpHelper->maRawBitmap.mnHeight ); - static PaletteMemorySharedVector aDummyPAL; - pGcpHelper->maBitmapDev = createBitmapDevice( aSize, true, nBmpFormat, aSize.getX(), pGcpHelper->maRawBitmap.mpBits, aDummyPAL ); - } - - rGlyphData.ExtDataRef().meInfo = nBmpFormat; - rGlyphData.ExtDataRef().mpData = pGcpHelper; - } - - SvpGcpHelper* pGcpHelper = static_cast<SvpGcpHelper*>( - rGlyphData.ExtDataRef().mpData); - assert(pGcpHelper != nullptr); - rTargetPos += B2IPoint( pGcpHelper->maRawBitmap.mnXOffset, pGcpHelper->maRawBitmap.mnYOffset ); - return pGcpHelper->maBitmapDev; -} - -void SvpGlyphPeer::RemovingFont( ServerFont& ) -{ - // nothing to do: no font resources held in SvpGlyphPeer -} - -void SvpGlyphPeer::RemovingGlyph( GlyphData& rGlyphData ) -{ - SvpGcpHelper* pGcpHelper = rGlyphData.ExtDataRef().mpData; - rGlyphData.ExtDataRef().meInfo = basebmp::Format::NONE; - rGlyphData.ExtDataRef().mpData = nullptr; - delete pGcpHelper; -} - -SvpTextRender::SvpTextRender(SvpSalGraphics& rParent) - : m_rParent(rParent) - , m_aTextColor(COL_BLACK) - , m_eTextFmt(basebmp::Format::EightBitGrey) -{ - for( int i = 0; i < MAX_FALLBACK; ++i ) - m_pServerFont[i] = nullptr; -} - -sal_uInt16 SvpTextRender::SetFont( FontSelectPattern* pIFSD, int nFallbackLevel ) -{ - // release all no longer needed font resources - for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i ) - { - if( m_pServerFont[i] != nullptr ) - { - // old server side font is no longer referenced - SvpGlyphCache::GetInstance().UncacheFont( *m_pServerFont[i] ); - m_pServerFont[i] = nullptr; - } - } - - // return early if there is no new font - if( !pIFSD ) - return 0; - - // handle the request for a non-native X11-font => use the GlyphCache - ServerFont* pServerFont = SvpGlyphCache::GetInstance().CacheFont( *pIFSD ); - if( !pServerFont ) - return SAL_SETFONT_BADFONT; - - // check selected font - if( !pServerFont->TestFont() ) - { - SvpGlyphCache::GetInstance().UncacheFont( *pServerFont ); - return SAL_SETFONT_BADFONT; - } - - // update SalGraphics font settings - m_pServerFont[ nFallbackLevel ] = pServerFont; - return SAL_SETFONT_USEDRAWTEXTARRAY; -} - -void SvpTextRender::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackLevel ) -{ - if( nFallbackLevel >= MAX_FALLBACK ) - return; - - if( m_pServerFont[nFallbackLevel] != nullptr ) - { - long rDummyFactor; - m_pServerFont[nFallbackLevel]->FetchFontMetric( *pMetric, rDummyFactor ); - } -} - -const FontCharMapPtr SvpTextRender::GetFontCharMap() const -{ - if( !m_pServerFont[0] ) - return nullptr; - - const FontCharMapPtr pFCMap = m_pServerFont[0]->GetFontCharMap(); - return pFCMap; -} - -bool SvpTextRender::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const -{ - if (!m_pServerFont[0]) - return false; - - return m_pServerFont[0]->GetFontCapabilities(rFontCapabilities); -} - -void SvpTextRender::GetDevFontList( PhysicalFontCollection* pFontCollection ) -{ - GlyphCache& rGC = SvpGlyphCache::GetInstance(); - - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - psp::FastPrintFontInfo aInfo; - ::std::list< psp::fontID > aList; - rMgr.getFontList( aList ); - ::std::list< psp::fontID >::iterator it; - for( it = aList.begin(); it != aList.end(); ++it ) - { - if( !rMgr.getFontFastInfo( *it, aInfo ) ) - continue; - - // normalize face number to the GlyphCache - int nFaceNum = rMgr.getFontFaceNumber( aInfo.m_nID ); - - // inform GlyphCache about this font provided by the PsPrint subsystem - ImplDevFontAttributes aDFA = GenPspGraphics::Info2DevFontAttributes( aInfo ); - aDFA.mnQuality += 4096; - const OString& rFileName = rMgr.getFontFileSysPath( aInfo.m_nID ); - rGC.AddFontFile( rFileName, nFaceNum, aInfo.m_nID, aDFA ); - } - - // announce glyphcache fonts - rGC.AnnounceFonts( pFontCollection ); - - // register platform specific font substitutions if available - SalGenericInstance::RegisterFontSubstitutors( pFontCollection ); - - ImplGetSVData()->maGDIData.mbNativeFontConfig = true; -} - -void SvpTextRender::ClearDevFontCache() -{ - GlyphCache& rGC = SvpGlyphCache::GetInstance(); - rGC.ClearFontCache(); -} - -bool SvpTextRender::AddTempDevFont( PhysicalFontCollection* pFontCollection, - const OUString& rFileURL, - const OUString& rFontName ) -{ - return GenPspGraphics::AddTempDevFontHelper( pFontCollection, rFileURL, rFontName, SvpGlyphCache::GetInstance() ); -} - -bool SvpTextRender::CreateFontSubset( - const OUString& rToFile, - const PhysicalFontFace* pFont, - const sal_GlyphId* pGlyphIds, - const sal_uInt8* pEncoding, - sal_Int32* pWidths, - int nGlyphCount, - FontSubsetInfo& rInfo - ) -{ - // in this context the pFont->GetFontId() is a valid PSP - // font since they are the only ones left after the PDF - // export has filtered its list of subsettable fonts (for - // which this method was created). The correct way would - // be to have the GlyphCache search for the PhysicalFontFace pFont - psp::fontID aFont = pFont->GetFontId(); - - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - bool bSuccess = rMgr.createFontSubset( rInfo, - aFont, - rToFile, - pGlyphIds, - pEncoding, - pWidths, - nGlyphCount ); - return bSuccess; -} - -const Ucs2SIntMap* SvpTextRender::GetFontEncodingVector( const PhysicalFontFace* pFont, const Ucs2OStrMap** pNonEncoded, std::set<sal_Unicode> const** ppPriority) -{ - // in this context the pFont->GetFontId() is a valid PSP - // font since they are the only ones left after the PDF - // export has filtered its list of subsettable fonts (for - // which this method was created). The correct way would - // be to have the GlyphCache search for the PhysicalFontFace pFont - psp::fontID aFont = pFont->GetFontId(); - return GenPspGraphics::DoGetFontEncodingVector(aFont, pNonEncoded, ppPriority); -} - -const void* SvpTextRender::GetEmbedFontData( - const PhysicalFontFace* pFont, - const sal_Ucs* pUnicodes, - sal_Int32* pWidths, - size_t nLen, - FontSubsetInfo& rInfo, - long* pDataLen - ) -{ - // in this context the pFont->GetFontId() is a valid PSP - // font since they are the only ones left after the PDF - // export has filtered its list of subsettable fonts (for - // which this method was created). The correct way would - // be to have the GlyphCache search for the PhysicalFontFace pFont - psp::fontID aFont = pFont->GetFontId(); - return GenPspGraphics::DoGetEmbedFontData( aFont, pUnicodes, pWidths, nLen, rInfo, pDataLen ); -} - -void SvpTextRender::FreeEmbedFontData( const void* pData, long nLen ) -{ - GenPspGraphics::DoFreeEmbedFontData( pData, nLen ); -} - -void SvpTextRender::GetGlyphWidths( const PhysicalFontFace* pFont, - bool bVertical, - Int32Vector& rWidths, - Ucs2UIntMap& rUnicodeEnc ) -{ - // in this context the pFont->GetFontId() is a valid PSP - // font since they are the only ones left after the PDF - // export has filtered its list of subsettable fonts (for - // which this method was created). The correct way would - // be to have the GlyphCache search for the PhysicalFontFace pFont - psp::fontID aFont = pFont->GetFontId(); - GenPspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); -} - -bool SvpTextRender::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect ) -{ - const int nLevel = aGlyphId >> GF_FONTSHIFT; - if( nLevel >= MAX_FALLBACK ) - return false; - - ServerFont* pSF = m_pServerFont[ nLevel ]; - if( !pSF ) - return false; - - aGlyphId &= GF_IDXMASK; - const GlyphMetric& rGM = pSF->GetGlyphMetric( aGlyphId ); - rRect = Rectangle( rGM.GetOffset(), rGM.GetSize() ); - return true; -} - -bool SvpTextRender::GetGlyphOutline( sal_GlyphId aGlyphId, B2DPolyPolygon& rPolyPoly ) -{ - const int nLevel = aGlyphId >> GF_FONTSHIFT; - if( nLevel >= MAX_FALLBACK ) - return false; - - const ServerFont* pSF = m_pServerFont[ nLevel ]; - if( !pSF ) - return false; - - aGlyphId &= GF_IDXMASK; - if( pSF->GetGlyphOutline( aGlyphId, rPolyPoly ) ) - return true; - - return false; -} - -SalLayout* SvpTextRender::GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) -{ - GenericSalLayout* pLayout = nullptr; - - if( m_pServerFont[ nFallbackLevel ] ) - pLayout = new ServerFontLayout( *m_pServerFont[ nFallbackLevel ] ); - - return pLayout; -} - -void SvpTextRender::DrawServerFontLayout( const ServerFontLayout& rSalLayout ) -{ - // iterate over all glyphs in the layout - Point aPos; - sal_GlyphId aGlyphId; - SvpGlyphPeer& rGlyphPeer = SvpGlyphCache::GetInstance().GetPeer(); - for( int nStart = 0; rSalLayout.GetNextGlyphs( 1, &aGlyphId, aPos, nStart ); ) - { - ServerFont& rFont = rSalLayout.GetServerFont(); - // get the glyph's alpha mask and adjust the drawing position - aGlyphId &= GF_IDXMASK; - B2IPoint aDstPoint( aPos.X(), aPos.Y() ); - BitmapDeviceSharedPtr aAlphaMask - = rGlyphPeer.GetGlyphBmp(rFont, aGlyphId, m_eTextFmt, aDstPoint); - if( !aAlphaMask ) // ignore empty glyphs - continue; - - // blend text color into target using the glyph's mask - m_rParent.BlendTextColor(m_aTextColor, aAlphaMask, aDstPoint); - } -} - -void SvpTextRender::SetTextColor( SalColor nSalColor ) -{ - m_aTextColor = basebmp::Color( nSalColor ); -} - -#if ENABLE_CAIRO_CANVAS - -SystemFontData SvpTextRender::GetSysFontData( int nFallbackLevel ) const -{ - SystemFontData aSysFontData; - - if (nFallbackLevel >= MAX_FALLBACK) nFallbackLevel = MAX_FALLBACK - 1; - if (nFallbackLevel < 0 ) nFallbackLevel = 0; - - if (m_pServerFont[nFallbackLevel] != nullptr) - { - ServerFont* rFont = m_pServerFont[nFallbackLevel]; - aSysFontData.nFontId = rFont->GetFtFace(); - aSysFontData.nFontFlags = rFont->GetLoadFlags(); - aSysFontData.bFakeBold = rFont->NeedsArtificialBold(); - aSysFontData.bFakeItalic = rFont->NeedsArtificialItalic(); - aSysFontData.bAntialias = rFont->GetAntialiasAdvice(); - aSysFontData.bVerticalCharacterType = rFont->GetFontSelData().mbVertical; - } - - return aSysFontData; -} - -#endif // ENABLE_CAIRO_CANVAS - -void SvpTextRender::setDevice( basebmp::BitmapDeviceSharedPtr& rDevice ) -{ - // determine matching bitmap format for masks - basebmp::Format nDeviceFmt = rDevice ? rDevice->getScanlineFormat() : basebmp::Format::EightBitGrey; - switch( nDeviceFmt ) - { - case basebmp::Format::EightBitGrey: - case basebmp::Format::SixteenBitLsbTcMask: - case basebmp::Format::SixteenBitMsbTcMask: - case basebmp::Format::TwentyFourBitTcMask: - case basebmp::Format::ThirtyTwoBitTcMaskBGRX: - case basebmp::Format::ThirtyTwoBitTcMaskBGRA: - case basebmp::Format::ThirtyTwoBitTcMaskARGB: - case basebmp::Format::ThirtyTwoBitTcMaskABGR: - case basebmp::Format::ThirtyTwoBitTcMaskRGBA: - m_eTextFmt = basebmp::Format::EightBitGrey; - break; - default: - m_eTextFmt = basebmp::Format::OneBitLsbGrey; - break; - } -} - -GlyphCache& SvpSalGraphics::getPlatformGlyphCache() -{ - return SvpGlyphCache::GetInstance(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx index fab2c153fa49..f861ac76a9d5 100644 --- a/vcl/headless/svpvd.cxx +++ b/vcl/headless/svpvd.cxx @@ -94,13 +94,6 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, return true; } -void InitSvpForLibreOfficeKit() -{ - ImplSVData* pSVData = ImplGetSVData(); - SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst); - pSalInstance->setBitCountFormatMapping( 32, ::basebmp::Format::ThirtyTwoBitTcMaskRGBA ); -} - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |