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