diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-03-26 00:25:34 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-03-26 19:05:34 +0200 |
commit | b2ad5380ad70de51075d67bbd9dd2145d1484b6a (patch) | |
tree | 0b42759eb9c297762d7f9987a3edfb31f502622e /vcl | |
parent | Use the applicationFrame and not whole screen size (diff) | |
download | core-b2ad5380ad70de51075d67bbd9dd2145d1484b6a.tar.gz core-b2ad5380ad70de51075d67bbd9dd2145d1484b6a.zip |
Handle different basebmp scanline formats and flip vertically when needed
Change-Id: Ic0fd7d60ddc66bcd5577988b3a4e5b2185d3ec1f
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/coretext/salgdi.cxx | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/vcl/coretext/salgdi.cxx b/vcl/coretext/salgdi.cxx index c7db660ce834..7fdd97532176 100644 --- a/vcl/coretext/salgdi.cxx +++ b/vcl/coretext/salgdi.cxx @@ -30,6 +30,8 @@ #include <UIKit/UIKit.h> #include <postmac.h> +#include <basebmp/scanlineformats.hxx> + #include "saldatabasic.hxx" #include "headless/svpframe.hxx" #include "headless/svpgdi.hxx" @@ -284,17 +286,41 @@ bool SvpSalGraphics::CheckContext() basegfx::B2IVector size = m_aDevice->getSize(); basebmp::RawMemorySharedArray pixelBuffer = m_aDevice->getBuffer(); - mrContext = CGBitmapContextCreate(pixelBuffer.get(), size.getX(), size.getY(), 8, m_aDevice->getScanlineStride(), - CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipLast); + SAL_INFO( "vcl.ios", "CheckContext: device=" << m_aDevice.get() << " size=" << size.getX() << "x" << size.getY() << (m_aDevice->isTopDown() ? " top-down" : " bottom-up") << " stride=" << m_aDevice->getScanlineStride() ); + + switch( m_aDevice->getScanlineFormat() ) { + case basebmp::Format::EIGHT_BIT_PAL: + mrContext = CGBitmapContextCreate(pixelBuffer.get(), + size.getX(), size.getY(), + 8, m_aDevice->getScanlineStride(), + CGColorSpaceCreateDeviceGray(), + kCGImageAlphaNone); + break; + case basebmp::Format::THIRTYTWO_BIT_TC_MASK_RGBA: + mrContext = CGBitmapContextCreate(pixelBuffer.get(), + size.getX(), size.getY(), + 8, m_aDevice->getScanlineStride(), + CGColorSpaceCreateDeviceRGB(), + kCGImageAlphaNoneSkipLast); + break; + default: + SAL_INFO( "vcl.ios", "CheckContext: unsupported color format " << basebmp::Format::formatName( m_aDevice->getScanlineFormat() ) ); + } SAL_WARN_IF( mrContext == NULL, "vcl.ios", "CheckContext() failed" ); - return (mrContext != NULL); + if( mrContext != NULL && m_aDevice->isTopDown() ) + { + CGContextTranslateCTM( mrContext, 0, size.getY() ); + CGContextScaleCTM( mrContext, 1, -1 ); + } + + return ( mrContext != NULL ); } CGContextRef SvpSalGraphics::GetContext() { - if (!mrContext) + if ( !mrContext ) CheckContext(); return mrContext; |