Kaydet (Commit) 7dd6b261 authored tarafından Caolán McNamara's avatar Caolán McNamara

use cairo-compatible top-down direction virtual devices everywhere

that way we can use cairo to text render etc onto our basebmp-backed
headless/gtk3 virtual devices

Change-Id: I91002b610b72a4fe1d2094a57c5cb1b6b5d69cb1
Reviewed-on: https://gerrit.libreoffice.org/19957Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 8569c6d0
...@@ -859,7 +859,7 @@ void doc_paintTile (LibreOfficeKitDocument* pThis, ...@@ -859,7 +859,7 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
pDevice->SetOutputSizePixelScaleOffsetAndBuffer( pDevice->SetOutputSizePixelScaleOffsetAndBuffer(
Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
aBuffer, aAlphaBuffer, true); aBuffer, aAlphaBuffer);
pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight); nTilePosX, nTilePosY, nTileWidth, nTileHeight);
...@@ -881,7 +881,7 @@ void doc_paintTile (LibreOfficeKitDocument* pThis, ...@@ -881,7 +881,7 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
pDevice->SetOutputSizePixelScaleOffsetAndBuffer( pDevice->SetOutputSizePixelScaleOffsetAndBuffer(
Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(), Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
aBuffer, aAlphaBuffer, true ); aBuffer, aAlphaBuffer);
pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight); nTilePosX, nTilePosY, nTileWidth, nTileHeight);
......
...@@ -44,12 +44,10 @@ private: ...@@ -44,12 +44,10 @@ private:
SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData = nullptr ); SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData = nullptr );
SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase, SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pBuffer );
const bool bTopDown );
SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pBuffer,
const basebmp::RawMemorySharedArray &pAlphaBuffer, const basebmp::RawMemorySharedArray &pAlphaBuffer );
const bool bTopDown );
VirtualDevice (const VirtualDevice &) = delete; VirtualDevice (const VirtualDevice &) = delete;
VirtualDevice & operator= (const VirtualDevice &) = delete; VirtualDevice & operator= (const VirtualDevice &) = delete;
...@@ -127,8 +125,8 @@ public: ...@@ -127,8 +125,8 @@ public:
const Fraction& rScale, const Fraction& rScale,
const Point& rNewOffset, const Point& rNewOffset,
const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pBuffer,
const basebmp::RawMemorySharedArray &pAlphaBuffer, const basebmp::RawMemorySharedArray &pAlphaBuffer );
const bool bTopDown = false );
bool SetOutputSize( const Size& rNewSize, bool bErase = true ) bool SetOutputSize( const Size& rNewSize, bool bErase = true )
{ return SetOutputSizePixel( LogicToPixel( rNewSize ), bErase ); } { return SetOutputSizePixel( LogicToPixel( rNewSize ), bErase ); }
......
...@@ -772,7 +772,7 @@ DECLARE_OOXMLIMPORT_TEST(testN777345, "n777345.docx") ...@@ -772,7 +772,7 @@ DECLARE_OOXMLIMPORT_TEST(testN777345, "n777345.docx")
Graphic aGraphic(xGraphic); Graphic aGraphic(xGraphic);
// If this changes later, feel free to update it, but make sure it's not // If this changes later, feel free to update it, but make sure it's not
// the checksum of a white/transparent placeholder rectangle. // the checksum of a white/transparent placeholder rectangle.
CPPUNIT_ASSERT_EQUAL(BitmapChecksum(3652741777587093783), aGraphic.GetChecksum()); CPPUNIT_ASSERT_EQUAL(BitmapChecksum(SAL_CONST_UINT64(16427281842367305761)), aGraphic.GetChecksum());
#endif #endif
} }
......
...@@ -54,7 +54,7 @@ bool SvpSalBitmap::Create( const Size& rSize, ...@@ -54,7 +54,7 @@ bool SvpSalBitmap::Create( const Size& rSize,
aSize.setY( 1 ); aSize.setY( 1 );
sal_Int32 nStride = getBitmapDeviceStrideForWidth(nFormat, aSize.getX()); sal_Int32 nStride = getBitmapDeviceStrideForWidth(nFormat, aSize.getX());
if( nBitCount > 8 ) if( nBitCount > 8 )
m_aBitmap = createBitmapDevice( aSize, false, nFormat, nStride ); m_aBitmap = createBitmapDevice( aSize, true, nFormat, nStride );
else else
{ {
// prepare palette // prepare palette
...@@ -67,7 +67,7 @@ bool SvpSalBitmap::Create( const Size& rSize, ...@@ -67,7 +67,7 @@ bool SvpSalBitmap::Create( const Size& rSize,
const BitmapColor& rCol = rPalette[i]; const BitmapColor& rCol = rPalette[i];
(*pPalette)[i] = basebmp::Color( rCol.GetRed(), rCol.GetGreen(), rCol.GetBlue() ); (*pPalette)[i] = basebmp::Color( rCol.GetRed(), rCol.GetGreen(), rCol.GetBlue() );
} }
m_aBitmap = createBitmapDevice( aSize, false, nFormat, nStride, m_aBitmap = createBitmapDevice( aSize, true, nFormat, nStride,
basebmp::RawMemorySharedArray(), basebmp::RawMemorySharedArray(),
basebmp::PaletteMemorySharedVector( pPalette ) basebmp::PaletteMemorySharedVector( pPalette )
); );
......
...@@ -70,7 +70,6 @@ void SvpSalFrame::enableDamageTracker( bool bOn ) ...@@ -70,7 +70,6 @@ void SvpSalFrame::enableDamageTracker( bool bOn )
SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance, SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance,
SalFrame* pParent, SalFrame* pParent,
SalFrameStyleFlags nSalFrameStyle, SalFrameStyleFlags nSalFrameStyle,
bool bTopDown,
basebmp::Format nScanlineFormat, basebmp::Format nScanlineFormat,
SystemParentData* ) : SystemParentData* ) :
m_pInstance( pInstance ), m_pInstance( pInstance ),
...@@ -78,7 +77,6 @@ SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance, ...@@ -78,7 +77,6 @@ SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance,
m_nStyle( nSalFrameStyle ), m_nStyle( nSalFrameStyle ),
m_bVisible( false ), m_bVisible( false ),
#ifndef IOS #ifndef IOS
m_bTopDown( bTopDown ),
m_bDamageTracking( false ), m_bDamageTracking( false ),
m_nScanlineFormat( nScanlineFormat ), m_nScanlineFormat( nScanlineFormat ),
#endif #endif
...@@ -92,7 +90,6 @@ SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance, ...@@ -92,7 +90,6 @@ SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance,
memset( static_cast<void *>(&m_aSystemChildData), 0, sizeof( SystemEnvData ) ); memset( static_cast<void *>(&m_aSystemChildData), 0, sizeof( SystemEnvData ) );
m_aSystemChildData.nSize = sizeof( SystemEnvData ); m_aSystemChildData.nSize = sizeof( SystemEnvData );
#ifdef IOS #ifdef IOS
(void) bTopDown;
(void) nScanlineFormat; (void) nScanlineFormat;
#elif defined ANDROID #elif defined ANDROID
// Nothing // Nothing
...@@ -295,7 +292,7 @@ void SvpSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u ...@@ -295,7 +292,7 @@ void SvpSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u
if( aFrameSize.getY() == 0 ) if( aFrameSize.getY() == 0 )
aFrameSize.setY( 1 ); aFrameSize.setY( 1 );
sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(m_nScanlineFormat, aFrameSize.getX()); sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(m_nScanlineFormat, aFrameSize.getX());
m_aFrame = createBitmapDevice( aFrameSize, m_bTopDown, m_nScanlineFormat, nStride ); m_aFrame = createBitmapDevice( aFrameSize, true, m_nScanlineFormat, nStride );
if (m_bDamageTracking) if (m_bDamageTracking)
m_aFrame->setDamageTracker( m_aFrame->setDamageTracker(
basebmp::IBitmapDeviceDamageTrackerSharedPtr( new DamageTracker ) ); basebmp::IBitmapDeviceDamageTrackerSharedPtr( new DamageTracker ) );
......
...@@ -200,12 +200,12 @@ bool SvpSalInstance::CheckTimeout( bool bExecuteTimers ) ...@@ -200,12 +200,12 @@ bool SvpSalInstance::CheckTimeout( bool bExecuteTimers )
SalFrame* SvpSalInstance::CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) SalFrame* SvpSalInstance::CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle )
{ {
return new SvpSalFrame( this, nullptr, nStyle, false, SVP_DEFAULT_BITMAP_FORMAT, pParent ); return new SvpSalFrame( this, nullptr, nStyle, SVP_DEFAULT_BITMAP_FORMAT, pParent );
} }
SalFrame* SvpSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) SalFrame* SvpSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
{ {
return new SvpSalFrame( this, pParent, nStyle, false, SVP_DEFAULT_BITMAP_FORMAT ); return new SvpSalFrame( this, pParent, nStyle, SVP_DEFAULT_BITMAP_FORMAT );
} }
void SvpSalInstance::DestroyFrame( SalFrame* pFrame ) void SvpSalInstance::DestroyFrame( SalFrame* pFrame )
......
...@@ -52,12 +52,11 @@ void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics ) ...@@ -52,12 +52,11 @@ void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY ) bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
{ {
return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray(), false ); return SetSizeUsingBuffer(nNewDX, nNewDY, basebmp::RawMemorySharedArray());
} }
bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pBuffer )
const bool bTopDown )
{ {
B2IVector aDevSize( nNewDX, nNewDY ); B2IVector aDevSize( nNewDX, nNewDY );
if( aDevSize.getX() == 0 ) if( aDevSize.getX() == 0 )
...@@ -76,14 +75,14 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, ...@@ -76,14 +75,14 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
std::vector< basebmp::Color > aDevPal(2); std::vector< basebmp::Color > aDevPal(2);
aDevPal[0] = basebmp::Color( 0, 0, 0 ); aDevPal[0] = basebmp::Color( 0, 0, 0 );
aDevPal[1] = basebmp::Color( 0xff, 0xff, 0xff ); aDevPal[1] = basebmp::Color( 0xff, 0xff, 0xff );
m_aDevice = createBitmapDevice( aDevSize, bTopDown, nFormat, nStride, m_aDevice = createBitmapDevice( aDevSize, true, nFormat, nStride,
PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) ); PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
} }
else else
{ {
m_aDevice = pBuffer ? m_aDevice = pBuffer ?
createBitmapDevice( aDevSize, bTopDown, nFormat, nStride, pBuffer, PaletteMemorySharedVector() ) createBitmapDevice( aDevSize, true, nFormat, nStride, pBuffer, PaletteMemorySharedVector() )
: createBitmapDevice( aDevSize, bTopDown, nFormat, nStride ); : createBitmapDevice( aDevSize, true, nFormat, nStride );
} }
// update device in existing graphics // update device in existing graphics
......
...@@ -44,7 +44,6 @@ class VCL_DLLPUBLIC SvpSalFrame : public SalFrame ...@@ -44,7 +44,6 @@ class VCL_DLLPUBLIC SvpSalFrame : public SalFrame
SalFrameStyleFlags m_nStyle; SalFrameStyleFlags m_nStyle;
bool m_bVisible; bool m_bVisible;
#ifndef IOS #ifndef IOS
bool m_bTopDown;
basebmp::BitmapDeviceSharedPtr m_aFrame; basebmp::BitmapDeviceSharedPtr m_aFrame;
bool m_bDamageTracking; bool m_bDamageTracking;
basebmp::Format m_nScanlineFormat; basebmp::Format m_nScanlineFormat;
...@@ -63,7 +62,6 @@ public: ...@@ -63,7 +62,6 @@ public:
SvpSalFrame( SvpSalInstance* pInstance, SvpSalFrame( SvpSalInstance* pInstance,
SalFrame* pParent, SalFrame* pParent,
SalFrameStyleFlags nSalFrameStyle, SalFrameStyleFlags nSalFrameStyle,
bool bTopDown,
basebmp::Format nScanlineFormat, basebmp::Format nScanlineFormat,
SystemParentData* pSystemParent = nullptr ); SystemParentData* pSystemParent = nullptr );
virtual ~SvpSalFrame(); virtual ~SvpSalFrame();
......
...@@ -54,9 +54,9 @@ class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics ...@@ -54,9 +54,9 @@ class VCL_DLLPUBLIC SvpSalGraphics : public SalGraphics
public: public:
static GlyphCache& getPlatformGlyphCache(); static GlyphCache& getPlatformGlyphCache();
void setDevice(basebmp::BitmapDeviceSharedPtr& rDevice);
void BlendTextColor(const basebmp::Color &rTextColor, const basebmp::BitmapDeviceSharedPtr &rAlphaMask, void BlendTextColor(const basebmp::Color &rTextColor, const basebmp::BitmapDeviceSharedPtr &rAlphaMask,
const basegfx::B2IPoint &rDstPoint); const basegfx::B2IPoint &rDstPoint);
void setDevice(basebmp::BitmapDeviceSharedPtr& rDevice);
private: private:
bool m_bClipSetup; bool m_bClipSetup;
......
...@@ -42,8 +42,7 @@ public: ...@@ -42,8 +42,7 @@ public:
virtual bool SetSize( long nNewDX, long nNewDY ) override; virtual bool SetSize( long nNewDX, long nNewDY ) override;
virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY, virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY,
const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pBuffer
const bool bTopDown
) override; ) override;
// SalGeometryProvider // SalGeometryProvider
......
...@@ -47,9 +47,7 @@ public: ...@@ -47,9 +47,7 @@ public:
// Set new size using a buffer at the given address // Set new size using a buffer at the given address
virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY, virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY,
const basebmp::RawMemorySharedArray & /* pBuffer */, const basebmp::RawMemorySharedArray & /* pBuffer */ )
const bool /* bTopDown */
)
{ {
// Only the headless virtual device has an implementation that uses // Only the headless virtual device has an implementation that uses
// pBuffer (and bTopDown). // pBuffer (and bTopDown).
......
...@@ -285,8 +285,7 @@ void VirtualDevice::dispose() ...@@ -285,8 +285,7 @@ void VirtualDevice::dispose()
} }
bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase, bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pBuffer )
const bool bTopDown )
{ {
SAL_INFO( "vcl.gdi", SAL_INFO( "vcl.gdi",
"VirtualDevice::InnerImplSetOutputSizePixel( " << rNewSize.Width() << ", " "VirtualDevice::InnerImplSetOutputSizePixel( " << rNewSize.Width() << ", "
...@@ -315,7 +314,7 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra ...@@ -315,7 +314,7 @@ bool VirtualDevice::InnerImplSetOutputSizePixel( const Size& rNewSize, bool bEra
if ( bErase ) if ( bErase )
{ {
if ( pBuffer ) if ( pBuffer )
bRet = mpVirDev->SetSizeUsingBuffer( nNewWidth, nNewHeight, pBuffer, bTopDown ); bRet = mpVirDev->SetSizeUsingBuffer( nNewWidth, nNewHeight, pBuffer );
else else
bRet = mpVirDev->SetSize( nNewWidth, nNewHeight ); bRet = mpVirDev->SetSize( nNewWidth, nNewHeight );
...@@ -393,10 +392,9 @@ void VirtualDevice::ImplFillOpaqueRectangle( const Rectangle& rRect ) ...@@ -393,10 +392,9 @@ void VirtualDevice::ImplFillOpaqueRectangle( const Rectangle& rRect )
bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pBuffer,
const basebmp::RawMemorySharedArray &pAlphaBuffer, const basebmp::RawMemorySharedArray &pAlphaBuffer )
const bool bTopDown )
{ {
if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer, bTopDown) ) if( InnerImplSetOutputSizePixel(rNewSize, bErase, pBuffer) )
{ {
if( mnAlphaDepth != -1 ) if( mnAlphaDepth != -1 )
{ {
...@@ -410,8 +408,7 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, ...@@ -410,8 +408,7 @@ bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
{ {
mpAlphaVDev = VclPtr<VirtualDevice>::Create( *this, mnAlphaDepth ); mpAlphaVDev = VclPtr<VirtualDevice>::Create( *this, mnAlphaDepth );
mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase, mpAlphaVDev->InnerImplSetOutputSizePixel(rNewSize, bErase,
pAlphaBuffer, pAlphaBuffer);
bTopDown );
} }
// TODO: copy full outdev state to new one, here. Also needed in outdev2.cxx:DrawOutDev // TODO: copy full outdev state to new one, here. Also needed in outdev2.cxx:DrawOutDev
...@@ -444,12 +441,12 @@ void VirtualDevice::EnableRTL( bool bEnable ) ...@@ -444,12 +441,12 @@ void VirtualDevice::EnableRTL( bool bEnable )
bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase ) bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, bool bErase )
{ {
return ImplSetOutputSizePixel( rNewSize, bErase, basebmp::RawMemorySharedArray(), basebmp::RawMemorySharedArray(), false ); return ImplSetOutputSizePixel( rNewSize, bErase, basebmp::RawMemorySharedArray(), basebmp::RawMemorySharedArray());
} }
bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer(
const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset, const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset,
const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pAlphaBuffer, const bool bTopDown ) const basebmp::RawMemorySharedArray &pBuffer, const basebmp::RawMemorySharedArray &pAlphaBuffer )
{ {
if (pAlphaBuffer) if (pAlphaBuffer)
mnAlphaDepth = 8; mnAlphaDepth = 8;
...@@ -461,7 +458,7 @@ bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer( ...@@ -461,7 +458,7 @@ bool VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer(
mm.SetScaleY( rScale ); mm.SetScaleY( rScale );
SetMapMode( mm ); SetMapMode( mm );
} }
return ImplSetOutputSizePixel( rNewSize, true, pBuffer, pAlphaBuffer, bTopDown ); return ImplSetOutputSizePixel( rNewSize, true, pBuffer, pAlphaBuffer );
} }
void VirtualDevice::SetReferenceDevice( RefDevMode i_eRefDevMode ) void VirtualDevice::SetReferenceDevice( RefDevMode i_eRefDevMode )
......
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