diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-11-22 15:35:16 +0000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2016-11-23 22:40:58 +0000 |
commit | d9a6e0023c9a192850b9db00f8120fbcc4256ec9 (patch) | |
tree | 41e3ea0e81c4f0bc1581e61919ef3d0db6711c42 /vcl/headless | |
parent | d689ad29c28ad7f077c2239a8fa4c2b6307a6aa1 (diff) |
Resolves: tdf#99508 ensure sufficient size for hidpi backing surface
and match virtual device scale with widget device scale
Change-Id: I1f35dcbaec94be12758ad6e4276bfd6bda4b1e88
Reviewed-on: https://gerrit.libreoffice.org/31080
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Jenkins <ci@libreoffice.org>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/headless')
-rw-r--r-- | vcl/headless/svpgdi.cxx | 11 | ||||
-rw-r--r-- | vcl/headless/svpinst.cxx | 2 | ||||
-rw-r--r-- | vcl/headless/svpvd.cxx | 31 |
3 files changed, 24 insertions, 20 deletions
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 1f861e7d8651..46d8a8a8dbda 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -374,6 +374,7 @@ bool SvpSalGraphics::drawAlphaRect(long nX, long nY, long nWidth, long nHeight, SvpSalGraphics::SvpSalGraphics() : m_pSurface(nullptr) + , m_fScale(1.0) , m_aLineColor(MAKE_SALCOLOR(0x00, 0x00, 0x00)) , m_aFillColor(MAKE_SALCOLOR(0xFF, 0xFF, 0XFF)) , m_ePaintMode(OVERPAINT) @@ -388,6 +389,7 @@ SvpSalGraphics::~SvpSalGraphics() void SvpSalGraphics::setSurface(cairo_surface_t* pSurface) { m_pSurface = pSurface; + cairo_surface_get_device_scale(pSurface, &m_fScale, nullptr); ResetClipRegion(); } @@ -981,14 +983,15 @@ void SvpSalGraphics::copyBits( const SalTwoRect& rTR, #if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 12, 0) pCopy = cairo_surface_create_similar(source, cairo_surface_get_content(m_pSurface), - aTR.mnSrcWidth, - aTR.mnSrcHeight); + aTR.mnSrcWidth * m_fScale, + aTR.mnSrcHeight * m_fScale); #else pCopy = cairo_surface_create_similar_image(source, cairo_image_surface_get_format(m_pSurface), - aTR.mnSrcWidth, - aTR.mnSrcHeight); + aTR.mnSrcWidth * m_fScale, + aTR.mnSrcHeight * m_fScale); #endif + cairo_surface_set_device_scale(pCopy, m_fScale, m_fScale); cairo_t* cr = cairo_create(pCopy); cairo_set_source_surface(cr, source, -aTR.mnSrcX, -aTR.mnSrcY); diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 53072d6a3061..39ad72737a33 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -281,7 +281,7 @@ SalVirtualDevice* SvpSalInstance::CreateVirtualDevice( SalGraphics* /* pGraphics DeviceFormat eFormat, const SystemGraphicsData* /* pData */ ) { - SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice(eFormat); + SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice(eFormat, 1); pNew->SetSize( nDX, nDY ); return pNew; } diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx index f356d7dfbb3e..f0d31f84b069 100644 --- a/vcl/headless/svpvd.cxx +++ b/vcl/headless/svpvd.cxx @@ -57,14 +57,16 @@ bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY ) bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, sal_uInt8 *const pBuffer) { - B2IVector aDevSize( nNewDX, nNewDY ); - if( aDevSize.getX() == 0 ) - aDevSize.setX( 1 ); - if( aDevSize.getY() == 0 ) - aDevSize.setY( 1 ); - - if (!m_pSurface || cairo_image_surface_get_width(m_pSurface) != aDevSize.getX() || - cairo_image_surface_get_height(m_pSurface) != aDevSize.getY() ) + if (nNewDX == 0) + nNewDX = 1; + if (nNewDY == 0) + nNewDY = 1; + + nNewDX *= m_fScale; + nNewDY *= m_fScale; + + if (!m_pSurface || cairo_image_surface_get_width(m_pSurface) != nNewDX || + cairo_image_surface_get_height(m_pSurface) != nNewDY ) { if (m_pSurface) { @@ -74,22 +76,21 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, if (m_eFormat == DeviceFormat::BITMASK) { m_pSurface = cairo_image_surface_create(CAIRO_FORMAT_A1, - aDevSize.getX(), - aDevSize.getY()); + nNewDX, nNewDY); } else { m_pSurface = pBuffer ? cairo_image_surface_create_for_data(pBuffer, CAIRO_FORMAT_ARGB32, - aDevSize.getX(), - aDevSize.getY(), - cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, aDevSize.getX())) + nNewDX, nNewDY, + cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, nNewDX)) : cairo_image_surface_create(CAIRO_FORMAT_ARGB32, - aDevSize.getX(), - aDevSize.getY()); + nNewDX, nNewDY); } + cairo_surface_set_device_scale(m_pSurface, m_fScale, m_fScale); + // update device in existing graphics for( std::list< SvpSalGraphics* >::iterator it = m_aGraphics.begin(); it != m_aGraphics.end(); ++it ) |