[Libreoffice-commits] core.git: 9 commits - sc/source sw/source vcl/coretext vcl/headless vcl/inc vcl/ios vcl/source

Tor Lillqvist tml at iki.fi
Tue Mar 26 10:07:50 PDT 2013


 sc/source/core/data/documen8.cxx   |    4 ++++
 sw/source/core/doc/docnew.cxx      |    4 ++++
 vcl/coretext/salcoretextlayout.cxx |   17 -----------------
 vcl/coretext/salgdi.cxx            |   34 ++++++++++++++++++++++++++++++----
 vcl/headless/svpbmp.cxx            |    1 +
 vcl/headless/svpgdi.cxx            |   24 ++++++++++++++++++++----
 vcl/inc/vcl/sysdata.hxx            |    6 ++++--
 vcl/inc/vcl/virdev.hxx             |   28 +++++++++++++++++++++++-----
 vcl/ios/iosinst.cxx                |   16 ++++++++--------
 vcl/source/gdi/virdev.cxx          |    6 ++++--
 10 files changed, 98 insertions(+), 42 deletions(-)

New commits:
commit 4ac0eff680a9fbf81dfd9e8a5772dee93bd0fb1a
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 18:32:41 2013 +0200

    Re-add change from 304cb6ab8fb159c883c42d2d42e82750fab4e4a7
    
    Was accidentally reverted.
    
    Change-Id: I1d62003cfab222664b7cf2053f640287910b2892

diff --git a/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm b/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm
index 7e7216f..271342b 100644
--- a/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm
+++ b/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm
@@ -26,7 +26,7 @@ static UIWindow *theWindow;
     (void) application;
     (void) launchOptions;
 
-    CGRect bounds = [[UIScreen mainScreen] bounds];
+    CGRect bounds = [[UIScreen mainScreen] applicationFrame];
     self.window = [[LOViewerWindow alloc] initWithFrame:bounds];
 
     theWindow = self.window;
commit 92b973fadcf63409026237884e81a1e3f3e62660
Author: Tor Lillqvist <tml at iki.fi>
Date:   Mon Mar 25 08:04:27 2013 +0200

    Use an 8bpp virtual device (instead of a 1bpp one) in sw and sc for iOS
    
    The reason why a 1bpp virtual device is used in these two places in sc
    and sw is unclear to me. It causes complications on iOS as such a
    bitmap gets passed to CGBitmapContextCreate() which does not accept
    1bpp bitmaps. But let's keep the 1bpp for other platforms.
    
    Change-Id: Ia34927cf728d4be05a31e88b7da78200d0b799ba

diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index f535235..9a6c0fb 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -207,7 +207,11 @@ VirtualDevice* ScDocument::GetVirtualDevice_100th_mm()
 {
     if (!pVirtualDevice_100th_mm)
     {
+#ifdef IOS
+        pVirtualDevice_100th_mm = new VirtualDevice( 8 );
+#else
         pVirtualDevice_100th_mm = new VirtualDevice( 1 );
+#endif
         pVirtualDevice_100th_mm->SetReferenceDevice(VirtualDevice::REFDEV_MODE_MSO1);
         MapMode aMapMode( pVirtualDevice_100th_mm->GetMapMode() );
         aMapMode.SetMapUnit( MAP_100TH_MM );
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 7ffacc3..c978716 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -698,7 +698,11 @@ SwDoc::~SwDoc()
 
 VirtualDevice& SwDoc::CreateVirtualDevice_() const
 {
+#ifdef IOS
+    VirtualDevice* pNewVir = new VirtualDevice( 8 );
+#else
     VirtualDevice* pNewVir = new VirtualDevice( 1 );
+#endif
 
     pNewVir->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
 
diff --git a/vcl/inc/vcl/virdev.hxx b/vcl/inc/vcl/virdev.hxx
index 9c8c4ed..5d8a70e 100644
--- a/vcl/inc/vcl/virdev.hxx
+++ b/vcl/inc/vcl/virdev.hxx
@@ -65,23 +65,41 @@ private:
     SAL_DLLPRIVATE bool ForceZeroExtleadBug() const
         { return ((meRefDevMode & REFDEV_FORCE_ZERO_EXTLEAD) != 0); }
 public:
+    /** Create a virtual device of size 1x1
+
+        @param nBitCount
+        Bit depth of the generated virtual device. Use 0 here, to
+        indicate: take default screen depth. Only 0, 1 and 8
+        are allowed here, with 1 denoting binary mask and 8 a graylevel mask.
+     */
                         VirtualDevice( sal_uInt16 nBitCount = 0 );
+
+    /** Create a virtual device of size 1x1
+
+        @param rCompDev
+        The generated vdev will be compatible to this device.
+
+        @param nBitCount
+        Bit depth of the generated virtual device. Use 0 here, to
+        indicate: take default screen depth. Only 0 and 1
+        are allowed here, with 1 denoting binary mask.
+     */
                         VirtualDevice( const OutputDevice& rCompDev,
                                        sal_uInt16 nBitCount = 0 );
-    /** Create a virtual device with alpha channel
+
+    /** Create a virtual device  of size 1x1 with alpha channel
 
         @param rCompDev
-        The generated vdev will be compatible to this device. By
-        default, Application::GetDefaultDevice() is used here.
+        The generated vdev will be compatible to this device.
 
         @param nBitCount
         Bit depth of the generated virtual device. Use 0 here, to
-        indicate: take default screen depth. Currently, only 0 and 1
+        indicate: take default screen depth. Only 0 and 1
         are allowed here, with 1 denoting binary mask.
 
         @param nAlphaBitCount
         Bit depth of the generated virtual device. Use 0 here, to
-        indicate: take default screen depth. Currently, only 0 and 1
+        indicate: take default screen depth. Only 0 and 1
         are allowed here, with 1 denoting binary mask.
      */
                         VirtualDevice( const OutputDevice& rCompDev,
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index 87a7487..3559550 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -39,6 +39,8 @@ using namespace ::com::sun::star::uno;
 void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev,
                                     long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData )
 {
+    SAL_INFO( "vcl.virdev", "ImplInitVirDev(" << nDX << "," << nDY << "," << nBitCount << ")" );
+
     if ( nDX < 1 )
         nDX = 1;
 
@@ -126,8 +128,8 @@ VirtualDevice::VirtualDevice( sal_uInt16 nBitCount )
 :   mpVirDev( NULL ),
     meRefDevMode( REFDEV_NONE )
 {
-    SAL_WARN_IF( nBitCount > 1, "vcl.gdi",
-                "VirtualDevice::VirtualDevice(): Only 0 or 1 is for BitCount allowed" );
+    SAL_WARN_IF( (nBitCount > 1 && nBitCount != 8), "vcl.gdi",
+                "VirtualDevice::VirtualDevice(): Only 0, 1 or 8 allowed for BitCount" );
     SAL_INFO( "vcl.gdi", "VirtualDevice::VirtualDevice( " << nBitCount << " )" );
 
     ImplInitVirDev( Application::GetDefaultDevice(), 1, 1, nBitCount );
commit 99a6a8d1bddc11097ff1bf386eb31132dbcdf311
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 17:26:57 2013 +0200

    rCGContext is not used for iOS
    
    Change-Id: If853edc8cd15bc61f0bc9d421799ad290a87d298

diff --git a/vcl/inc/vcl/sysdata.hxx b/vcl/inc/vcl/sysdata.hxx
index 6d26bc2..a1db487 100644
--- a/vcl/inc/vcl/sysdata.hxx
+++ b/vcl/inc/vcl/sysdata.hxx
@@ -124,8 +124,9 @@ struct SystemGraphicsData
     unsigned long   nSize;          // size in bytes of this structure
 #if defined( WNT )
     HDC             hDC;            // handle to a device context
-#elif defined( MACOSX ) || defined( IOS )
+#elif defined( MACOSX )
     CGContextRef    rCGContext;     // CoreGraphics graphic context
+#elif defined( IOS )
 #elif defined( UNX )
     void*           pDisplay;       // the relevant display connection
     long            hDrawable;      // a drawable
@@ -139,7 +140,8 @@ struct SystemGraphicsData
         : nSize( sizeof( SystemGraphicsData ) )
 #if defined( WNT )
         , hDC( 0 )
-#elif defined( MACOSX ) || defined( IOS )
+#elif defined( MACOSX )
+#elif defined( IOS )
 #elif defined( UNX )
         , pDisplay( NULL )
         , hDrawable( 0 )
commit f238648cea537e5c40824270df8f91b50af392de
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 17:19:55 2013 +0200

    Ifdef out methods for iOS that are actually in coretext/salgdi.cxx
    
    A bit scary that the linker didn't notice the duplicate symbols, but
    instead apparently just picked the first (or an arbitrary) one. Need
    to look into that. Anyway, now when the correct SetTextColor is linked
    in the coloured text in the demo document shows up in all its glory.
    
    The code that is partially shared between the headless, OS X CoreText
    and iOS backends should to be refactored a bit, I guess.
    
    Change-Id: Id341298f72dc253380d9b2319032e0a9a8bdd0f6

diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index f3abe76..0fc3529 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -358,11 +358,15 @@ void SvpSalGraphics::SetROPFillColor( SalROPColor nROPColor )
     }
 }
 
+#ifndef IOS
+
 void SvpSalGraphics::SetTextColor( SalColor nSalColor )
 {
     m_aTextColor = basebmp::Color( nSalColor );
 }
 
+#endif
+
 void SvpSalGraphics::drawPixel( long nX, long nY )
 {
     if( m_bUseLineColor )
@@ -699,6 +703,8 @@ sal_Bool SvpSalGraphics::drawEPS( long, long, long, long, void*, sal_uLong )
     return sal_False;
 }
 
+#ifndef IOS
+
 SystemFontData SvpSalGraphics::GetSysFontData( int nFallbacklevel ) const
 {
     SystemFontData aSysFontData;
@@ -707,18 +713,16 @@ SystemFontData SvpSalGraphics::GetSysFontData( int nFallbacklevel ) const
     if (nFallbacklevel < 0 ) nFallbacklevel = 0;
 
     aSysFontData.nSize = sizeof( SystemFontData );
-#ifdef IOS
-    aSysFontData.rCTFont = NULL;
-#else
     aSysFontData.nFontId = 0;
     aSysFontData.nFontFlags = 0;
-#endif
     aSysFontData.bFakeBold = false;
     aSysFontData.bFakeItalic = false;
     aSysFontData.bAntialias = true;
     return aSysFontData;
 }
 
+#endif
+
 SystemGraphicsData SvpSalGraphics::GetGraphicsData() const
 {
     return SystemGraphicsData();
commit 91a3723922b5fecf0b18346d7d31a9ee685a0b43
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 17:13:58 2013 +0200

    Remove unnecessary code that was based on a wrong guess
    
    Change-Id: Ia3e12d68c0eef56ba32b2c6062448874a52a8df3

diff --git a/vcl/coretext/salcoretextlayout.cxx b/vcl/coretext/salcoretextlayout.cxx
index d435630..7cadbe7 100644
--- a/vcl/coretext/salcoretextlayout.cxx
+++ b/vcl/coretext/salcoretextlayout.cxx
@@ -621,23 +621,6 @@ bool CoreTextLayout::LayoutText( ImplLayoutArgs& rArgs)
         return false;
     }
 
-#ifdef IOS
-    // This might be a red herring and unnecessary once the CoreText
-    // code actually works;)
-
-    // If the string contains U+FFFD ("REPLACEMENT CHARACTER"), which
-    // happens at least for the ooo80484-1.slk document in
-    // sc_filters_test, the CTTypesetterCreateWithAttributedString()
-    // call below crashes, at least in the iOS simulator. Go figure.
-    // (In that case the string consists of *only* such characters,
-    // but play it safe.)
-    for (int i = 0; i < mnCharCount; i++)
-    {
-        if ( rArgs.mpStr[rArgs.mnMinCharPos+i] == 0xFFFD)
-            return false;
-    }
-#endif
-
     SAL_INFO( "vcl.coretext.layout", "LayoutText() returning,  mnGlyphCount=" << mnGlyphCount );
 
     return true;
commit 708270b616b486869e896d2ace4bc9b4fdbefad3
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 00:27:59 2013 +0200

    Improve the blitting, use memcpy for each row
    
    Change-Id: Idfc5efe8b2326748670fec82a7780f81b243dbc8

diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx
index 8e3137b..71dda58 100644
--- a/vcl/ios/iosinst.cxx
+++ b/vcl/ios/iosinst.cxx
@@ -56,20 +56,20 @@ void IosSalInstance::BlitFrameToBuffer(char *pPixelBuffer,
     const sal_Int32 nStride = aDev->getScanlineStride();
     const unsigned char *pSrc = aSrcData.get();
 
+    if (aDev->getScanlineFormat() != basebmp::Format::THIRTYTWO_BIT_TC_MASK_RGBA)
+    {
+        SAL_INFO( "vcl.ios", "BlitFrameToBuffer: format is not 32bpp RGBA but " << aDev->getScanlineFormat() );
+        return;
+    }
+
     for (unsigned int y = 0; y < (unsigned int)aDevSize.getY(); y++)
     {
-        const unsigned char *sp( pSrc + nStride * y );
+        const unsigned char *sp( pSrc + nStride * (aDevSize.getY() - 1 - y) );
 
         unsigned char *dp( (unsigned char *)pPixelBuffer +
                            nPBWidth * 4 * (y + nDestY) +
                            nDestX * 4 );
-        for (unsigned int x = 0; x < (unsigned int)aDevSize.getX(); x++)
-        {
-            dp[x*4 + 0] = sp[x*4 + 0]; // R
-            dp[x*4 + 1] = sp[x*4 + 1]; // G
-            dp[x*4 + 2] = sp[x*4 + 2]; // B
-            dp[x*4 + 3] = 255; // A
-        }
+        memcpy(dp, sp, aDevSize.getX()*4);
     }
 }
 
commit 40e67e2b5a2c0658633513c3c408cf6ef1441665
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 00:27:03 2013 +0200

    Add a SAL_INFO()
    
    Change-Id: Ieb3ff50a13172fa2c51173697b80ff5a71fbe244

diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index 3b22d1b..0b5eb52 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -39,6 +39,7 @@ bool SvpSalBitmap::Create( const Size& rSize,
                            const BitmapPalette& rPalette )
 {
     sal_uInt32 nFormat = SVP_DEFAULT_BITMAP_FORMAT;
+    SAL_INFO( "vcl.headless", "SvpSalBitmap::Create(" << rSize.Width() << "," << rSize.Height() << "," << nBitCount << ")" );
     switch( nBitCount )
     {
         case 1: nFormat = Format::ONE_BIT_MSB_PAL; break;
commit e642b9d97d8ac56fda6b5c1e0859f99abc5c47e3
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 00:26:30 2013 +0200

    Release style and CGContext resources in dtor
    
    Change-Id: I40fa43aaccda42e276f729cb7948101482c6ce5c

diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 58f496e..f3abe76 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -96,6 +96,18 @@ SvpSalGraphics::SvpSalGraphics() :
 
 SvpSalGraphics::~SvpSalGraphics()
 {
+#ifdef IOS
+    if(m_style)
+    {
+        delete m_style;
+        m_style = NULL;
+    }
+    if(mrContext)
+    {
+        CGContextRelease( mrContext );
+        mrContext = NULL;
+    }
+#endif
 }
 
 void SvpSalGraphics::setDevice( basebmp::BitmapDeviceSharedPtr& rDevice )
commit b2ad5380ad70de51075d67bbd9dd2145d1484b6a
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Mar 26 00:25:34 2013 +0200

    Handle different basebmp scanline formats and flip vertically when needed
    
    Change-Id: Ic0fd7d60ddc66bcd5577988b3a4e5b2185d3ec1f

diff --git a/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm b/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm
index 271342b..7e7216f 100644
--- a/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm
+++ b/ios/experimental/Viewer/Viewer/LOViewerAppDelegate.mm
@@ -26,7 +26,7 @@ static UIWindow *theWindow;
     (void) application;
     (void) launchOptions;
 
-    CGRect bounds = [[UIScreen mainScreen] applicationFrame];
+    CGRect bounds = [[UIScreen mainScreen] bounds];
     self.window = [[LOViewerWindow alloc] initWithFrame:bounds];
 
     theWindow = self.window;
diff --git a/vcl/coretext/salgdi.cxx b/vcl/coretext/salgdi.cxx
index c7db660..7fdd975 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;


More information about the Libreoffice-commits mailing list