basebmp/inc/basebmp/bitmapdevice.hxx | 23 ++-- basebmp/source/bitmapdevice.cxx | 55 ++++++---- ios/experimental/LibreOffice/LibreOffice.xcodeproj/project.pbxproj | 6 - vcl/coretext/salcoretextlayout.cxx | 13 +- vcl/coretext/salgdi.cxx | 26 +++- 5 files changed, 81 insertions(+), 42 deletions(-)
New commits: commit 1a6b1873ce75fa9a37c9e69812d127628e0be379 Author: Tor Lillqvist <[email protected]> Date: Fri Apr 12 02:22:32 2013 +0300 Turn off subpixel positioning for now Change-Id: Id8b9bec79e5673db738e16905eacd8e84cea89e1 diff --git a/vcl/coretext/salcoretextlayout.cxx b/vcl/coretext/salcoretextlayout.cxx index c3110019..e324ef7 100644 --- a/vcl/coretext/salcoretextlayout.cxx +++ b/vcl/coretext/salcoretextlayout.cxx @@ -223,6 +223,7 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const CGContextSetFontSize(gr.mrContext, CTFontGetSize(mpStyle->GetFont())); CGContextSetTextDrawingMode(gr.mrContext, kCGTextFill); CGContextSetShouldAntialias( gr.mrContext, true ); + CGContextSetShouldSubpixelPositionFonts( gr.mrContext, false ); if( mpStyle->GetColor() ) { CGContextSetFillColorWithColor(gr.mrContext, mpStyle->GetColor()); CGContextSetStrokeColorWithColor(gr.mrContext, mpStyle->GetColor()); commit 034d5fe9acb41aa4d71e9507a8488b54ba246ee8 Author: Tor Lillqvist <[email protected]> Date: Fri Apr 12 02:17:09 2013 +0300 Sort source files for clarity Change-Id: Idac1c756faa47236e4ebc3c7400f7e4412f02a44 diff --git a/ios/experimental/LibreOffice/LibreOffice.xcodeproj/project.pbxproj b/ios/experimental/LibreOffice/LibreOffice.xcodeproj/project.pbxproj index 3287eab..2e94d03 100644 --- a/ios/experimental/LibreOffice/LibreOffice.xcodeproj/project.pbxproj +++ b/ios/experimental/LibreOffice/LibreOffice.xcodeproj/project.pbxproj @@ -119,10 +119,11 @@ BE2F0A0D17077A950060FE0D /* vcl */ = { isa = PBXGroup; children = ( - BE4EEE9A16FF80B100D475B2 /* virdev.cxx */, - BEBF3E3D17002D6900C454AC /* window.cxx */, + BE954A2E1704F9500040D517 /* iosinst.cxx */, BEBF3E3A17002D0200C454AC /* svapp.cxx */, BEBF3E3B17002D0200C454AC /* svmain.cxx */, + BE4EEE9A16FF80B100D475B2 /* virdev.cxx */, + BEBF3E3D17002D6900C454AC /* window.cxx */, BEA86899170B3FCB0043E44B /* coretext */, BE2F0A0C17077A2F0060FE0D /* headless */, ); @@ -199,7 +200,6 @@ BE2F0A1017077B560060FE0D /* basebmp */, BE2F0A0B17077A0F0060FE0D /* cppuhelper */, BE2F0A0E17077AC40060FE0D /* framework */, - BE954A2E1704F9500040D517 /* iosinst.cxx */, BE56CD651704A08E00CA5B15 /* lo.h */, BE56CD661704A08E00CA5B15 /* lo.mm */, BE2F0A0F17077B060060FE0D /* sfx2 */, commit 84587bdf9af104d5e416f2a011559f71fe493ae2 Author: Tor Lillqvist <[email protected]> Date: Fri Apr 12 02:14:33 2013 +0300 Use my improved understanding of what a subset BitmapDevice is Need to pass the whole pixel buffer to CGBitmapContextCreate(). Change-Id: Iadac7dc3e63c29e5d0cc328b2e2a1f10824248a6 diff --git a/vcl/coretext/salgdi.cxx b/vcl/coretext/salgdi.cxx index c1ace40..a462c37 100644 --- a/vcl/coretext/salgdi.cxx +++ b/vcl/coretext/salgdi.cxx @@ -283,23 +283,30 @@ void QuartzSalGraphics::SetTextColor( SalColor nSalColor ) bool SvpSalGraphics::CheckContext() { - basegfx::B2IVector size = m_aDevice->getSize(); + const basegfx::B2IVector size = m_aDevice->getSize(); + const basegfx::B2IVector bufferSize = m_aDevice->getBufferSize(); + const sal_Int32 scanlineStride = m_aDevice->getScanlineStride(); basebmp::RawMemorySharedArray pixelBuffer = m_aDevice->getBuffer(); - 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() ); + SAL_INFO( "vcl.ios", + "CheckContext: device=" << m_aDevice.get() << + " size=" << size.getX() << "x" << size.getY() << + (m_aDevice->isTopDown() ? " top-down" : " bottom-up") << + " stride=" << scanlineStride << + " bufferSize=(" << bufferSize.getX() << "," << bufferSize.getY() << ")" ); switch( m_aDevice->getScanlineFormat() ) { case basebmp::Format::EIGHT_BIT_PAL: mrContext = CGBitmapContextCreate(pixelBuffer.get(), - size.getX(), size.getY(), - 8, m_aDevice->getScanlineStride(), + bufferSize.getX(), bufferSize.getY(), + 8, scanlineStride, CGColorSpaceCreateDeviceGray(), kCGImageAlphaNone); break; case basebmp::Format::THIRTYTWO_BIT_TC_MASK_RGBA: mrContext = CGBitmapContextCreate(pixelBuffer.get(), - size.getX(), size.getY(), - 8, m_aDevice->getScanlineStride(), + bufferSize.getX(), bufferSize.getY(), + 8, scanlineStride, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipLast); break; @@ -309,12 +316,17 @@ bool SvpSalGraphics::CheckContext() SAL_WARN_IF( mrContext == NULL, "vcl.ios", "CheckContext() failed" ); + // Should we also clip the context? (Then we need to add a + // getBounds() function to BitmapDevice.) + if( mrContext != NULL && m_aDevice->isTopDown() ) { - CGContextTranslateCTM( mrContext, 0, size.getY() ); + CGContextTranslateCTM( mrContext, 0, bufferSize.getY() ); CGContextScaleCTM( mrContext, 1, -1 ); } + SAL_INFO( "vcl.ios", "CheckContext: context=" << mrContext ); + return ( mrContext != NULL ); } commit d520bd0903ae272cf32db8b3e4f560891df59331 Author: Tor Lillqvist <[email protected]> Date: Fri Apr 12 02:05:36 2013 +0300 A bit more logging in DrawText() Change-Id: I04c715e88ee79aa639c10f2a39d303eecdbd3962 diff --git a/vcl/coretext/salcoretextlayout.cxx b/vcl/coretext/salcoretextlayout.cxx index ddd6928..c3110019 100644 --- a/vcl/coretext/salcoretextlayout.cxx +++ b/vcl/coretext/salcoretextlayout.cxx @@ -213,9 +213,6 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const if( mnCharCount <= 0 || !gr.CheckContext() ) return; - Point pos = GetDrawPosition(Point(0,0)); - SAL_INFO( "vcl.coretext.layout", " at pos (" << pos.X() << "," << pos.Y() <<") ctfont=" << mpStyle->GetFont() ); - CGFontRef cg_font = CTFontCopyGraphicsFont(mpStyle->GetFont(), NULL); if( !cg_font ) { SAL_INFO( "vcl.coretext.layout", "Error cg_font is NULL" ); @@ -236,6 +233,15 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const CFRelease(cg_font); CGContextSetTextMatrix(gr.mrContext, CGAffineTransformMakeScale(1.0, -1.0)); CGContextSetShouldAntialias( gr.mrContext, !gr.mbNonAntialiasedText ); + + Point pos = GetDrawPosition(Point(0,0)); + CGPoint posDev = CGContextConvertPointToDeviceSpace(gr.mrContext, CGPointMake(pos.X(), pos.Y())); + SAL_INFO( "vcl.coretext.layout", + " context=" << gr.mrContext << + " pos=(" << pos.X() << "," << pos.Y() <<")" << + " posDev=" << posDev << + " font=" << mpStyle->GetFont() ); + CGContextTranslateCTM(gr.mrContext, pos.X(), pos.Y()); CGContextShowGlyphsWithAdvances(gr.mrContext, mpGlyphs, mpGlyphAdvances, mnGlyphCount); commit 3f9acb7f9c3b68da11f8263b9103d2700321913b Author: Tor Lillqvist <[email protected]> Date: Fri Apr 12 01:45:20 2013 +0300 Nah, I don't need a getOffset(), but I do need a getBufferSize() To properly handle subsetted BitmapDevices in the iOS vcl backend I seem to need to know what the size of the full BitmapDevice is. I wasted at least one day on desperate hacking and debugging, trying to wrap my head around a misunderstanding of what a subsetted BitmapDevice is. I thought it involved coordinate offsetting... Change-Id: I83bf1a7d75ce192aaf21f1e408008e362fd6c6e6 diff --git a/basebmp/inc/basebmp/bitmapdevice.hxx b/basebmp/inc/basebmp/bitmapdevice.hxx index 71c4a63..941b01c 100644 --- a/basebmp/inc/basebmp/bitmapdevice.hxx +++ b/basebmp/inc/basebmp/bitmapdevice.hxx @@ -79,7 +79,7 @@ class BASEBMP_DLLPUBLIC BitmapDevice : public boost::enable_shared_from_this<Bit private boost::noncopyable { public: - /** Query size of device in pixel + /** Query size of device in pixel columns (X) and rows (Y, "scanlines") */ basegfx::B2IVector getSize() const; @@ -92,12 +92,12 @@ public: */ bool isTopDown() const; - /** Query the offset from the start of the memory buffer + /** Query the size of the whole frame buffer - @ return the offset, which is (0,0) unless this is a subset - device. + @ return the size of the whole frame buffer, the same as + getSize() unless this is a "subset" device. */ - basegfx::B2IVector getOffset() const; + basegfx::B2IVector getBufferSize() const; /** Query type of scanline memory format */ @@ -552,6 +552,7 @@ public: protected: BASEBMP_DLLPRIVATE BitmapDevice( const basegfx::B2IBox& rBounds, + const basegfx::B2IVector& rBufferSize, sal_Int32 nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, @@ -688,10 +689,16 @@ BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC createBitmapDevice( const basegfx::B2IVe /** Function to retrieve a subsetted BitmapDevice to the same memory. + Note that there is no coordinate system translation or offsetting + involved. + This method creates a second bitmap device instance, which renders - to the same memory as the original, but to a limited, rectangular - area. Useful to implement rectangular clips (usually faster than - setting up a 1bpp clip mask). + to the same memory as the original, with the same pixel coordinate + pairs refering to the same pixels in the memory buffer, but with + rendering clipped to a rectangular area. Useful to implement + rectangular clips (usually faster than setting up a 1bpp clip + mask). + */ BitmapDeviceSharedPtr BASEBMP_DLLPUBLIC subsetBitmapDevice( const BitmapDeviceSharedPtr& rProto, const basegfx::B2IBox& rSubset ); diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx index c090b45..d1a19f9 100644 --- a/basebmp/source/bitmapdevice.cxx +++ b/basebmp/source/bitmapdevice.cxx @@ -283,6 +283,7 @@ namespace // ------------------------------------------------------- BitmapRenderer( const basegfx::B2IBox& rBounds, + const basegfx::B2IVector& rBufferSize, sal_Int32 nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, @@ -292,7 +293,7 @@ namespace const RawMemorySharedArray& rMem, const PaletteMemorySharedVector& rPalette, const IBitmapDeviceDamageTrackerSharedPtr& rDamage ) : - BitmapDevice( rBounds, nScanlineFormat, + BitmapDevice( rBounds, rBufferSize, nScanlineFormat, nScanlineStride, pFirstScanline, rMem, rPalette ), maBegin( begin ), maColorLookup(), @@ -1044,6 +1045,9 @@ struct ImplBitmapDevice */ basegfx::B2IBox maBounds; + //// Size of the actual frame buffer + basegfx::B2IVector maBufferSize; + /// Scanline format, as provided at the constructor sal_Int32 mnScanlineFormat; @@ -1072,6 +1076,7 @@ struct ImplBitmapDevice BitmapDevice::BitmapDevice( const basegfx::B2IBox& rBounds, + const basegfx::B2IVector& rBufferSize, sal_Int32 nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, @@ -1082,6 +1087,7 @@ BitmapDevice::BitmapDevice( const basegfx::B2IBox& rBounds, mpImpl->mpMem = rMem; mpImpl->mpPalette = rPalette; mpImpl->maBounds = rBounds; + mpImpl->maBufferSize = rBufferSize; mpImpl->mnScanlineFormat = nScanlineFormat; mpImpl->mnScanlineStride = nScanlineStride; mpImpl->mpFirstScanline = pFirstScanline; @@ -1105,9 +1111,9 @@ bool BitmapDevice::isTopDown() const return mpImpl->mnScanlineStride >= 0; } -basegfx::B2IVector BitmapDevice::getOffset() const +basegfx::B2IVector BitmapDevice::getBufferSize() const { - return basegfx::B2IVector(mpImpl->maBounds.getMinX(), mpImpl->maBounds.getMinY()); + return mpImpl->maBufferSize; } sal_Int32 BitmapDevice::getScanlineFormat() const @@ -1679,6 +1685,7 @@ struct StdMasks template< class FormatTraits, class MaskTraits > BitmapDeviceSharedPtr createRenderer( const basegfx::B2IBox& rBounds, + const basegfx::B2IVector& rBufferSize, sal_Int32 nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, @@ -1693,6 +1700,7 @@ BitmapDeviceSharedPtr createRenderer( template< class FormatTraits, class MaskTraits, class Accessor > BitmapDeviceSharedPtr createRenderer( const basegfx::B2IBox& rBounds, + const basegfx::B2IVector& rBufferSize, sal_Int32 nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, @@ -1712,6 +1720,7 @@ BitmapDeviceSharedPtr createRenderer( return BitmapDeviceSharedPtr( new Renderer( rBounds, + rBufferSize, nScanlineFormat, nScanlineStride, pFirstScanline, @@ -1750,6 +1759,7 @@ PaletteMemorySharedVector createStandardPalette( template< class FormatTraits, class MaskTraits > BitmapDeviceSharedPtr createRenderer( const basegfx::B2IBox& rBounds, + const basegfx::B2IVector& rBufferSize, sal_Int32 nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, @@ -1759,6 +1769,7 @@ BitmapDeviceSharedPtr createRenderer( { return createRenderer<FormatTraits, MaskTraits>(rBounds, + rBufferSize, nScanlineFormat, nScanlineStride, pFirstScanline, @@ -1774,6 +1785,7 @@ BitmapDeviceSharedPtr createRenderer( template< class FormatTraits, class MaskTraits > BitmapDeviceSharedPtr createRenderer( const basegfx::B2IBox& rBounds, + const basegfx::B2IVector& rBufferSize, sal_Int32 nScanlineFormat, sal_Int32 nScanlineStride, sal_uInt8* pFirstScanline, @@ -1788,6 +1800,7 @@ BitmapDeviceSharedPtr createRenderer( OSL_ASSERT(pPal); return createRenderer<FormatTraits, MaskTraits>(rBounds, + rBufferSize, nScanlineFormat, nScanlineStride, pFirstScanline, @@ -1917,23 +1930,23 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& case Format::ONE_BIT_MSB_GREY: return createRenderer<PixelFormatTraits_GREY1_MSB,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, rDamage ); case Format::ONE_BIT_LSB_GREY: return createRenderer<PixelFormatTraits_GREY1_LSB,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, rDamage ); case Format::ONE_BIT_MSB_PAL: return createRenderer<PixelFormatTraits_PAL1_MSB,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat], rDamage ); case Format::ONE_BIT_LSB_PAL: return createRenderer<PixelFormatTraits_PAL1_LSB,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat], rDamage ); @@ -1943,23 +1956,23 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& case Format::FOUR_BIT_MSB_GREY: return createRenderer<PixelFormatTraits_GREY4_MSB,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, rDamage ); case Format::FOUR_BIT_LSB_GREY: return createRenderer<PixelFormatTraits_GREY4_LSB,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, rDamage ); case Format::FOUR_BIT_MSB_PAL: return createRenderer<PixelFormatTraits_PAL4_MSB,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat], rDamage ); case Format::FOUR_BIT_LSB_PAL: return createRenderer<PixelFormatTraits_PAL4_LSB,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat], rDamage ); @@ -1969,12 +1982,12 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& case Format::EIGHT_BIT_GREY: return createRenderer<PixelFormatTraits_GREY8,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, rDamage ); case Format::EIGHT_BIT_PAL: return createRenderer<PixelFormatTraits_PAL8,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, bitsPerPixel[nScanlineFormat], rDamage ); @@ -1984,12 +1997,12 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& case Format::SIXTEEN_BIT_LSB_TC_MASK: return createRenderer<PixelFormatTraits_RGB16_565_LSB,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, rDamage ); case Format::SIXTEEN_BIT_MSB_TC_MASK: return createRenderer<PixelFormatTraits_RGB16_565_MSB,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, rDamage ); @@ -1997,7 +2010,7 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& // twentyfour bit formats case Format::TWENTYFOUR_BIT_TC_MASK: return createRenderer<PixelFormatTraits_BGR24,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, rDamage ); @@ -2006,22 +2019,22 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector& case Format::THIRTYTWO_BIT_TC_MASK_BGRA: return createRenderer<PixelFormatTraits_BGRX32_8888,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, rDamage ); case Format::THIRTYTWO_BIT_TC_MASK_ARGB: return createRenderer<PixelFormatTraits_XRGB32_8888,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, rDamage ); case Format::THIRTYTWO_BIT_TC_MASK_ABGR: return createRenderer<PixelFormatTraits_XBGR32_8888,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, rDamage ); case Format::THIRTYTWO_BIT_TC_MASK_RGBA: return createRenderer<PixelFormatTraits_RGBX32_8888,StdMasks>( - aBounds, nScanlineFormat, nScanlineStride, + aBounds, rSize, nScanlineFormat, nScanlineStride, pFirstScanline, pMem, pPal, rDamage ); } @@ -2043,7 +2056,7 @@ BitmapDeviceSharedPtr createBitmapDeviceImpl( const basegfx::B2IVector& std::ostringstream subset; if (pSubset) - subset << " subset: " << pSubset->getWidth() << "x" << pSubset->getHeight() << "@(" << pSubset->getMinX() << "," << pSubset->getMinY() << ")"; + subset << " subset=" << pSubset->getWidth() << "x" << pSubset->getHeight() << "@(" << pSubset->getMinX() << "," << pSubset->getMinY() << ")"; SAL_INFO( "basebmp.bitmapdevice", "createBitmapDevice: " _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
