[Libreoffice-commits] core.git: Branch 'distro/suse/suse-4.0' - 4 commits - canvas/source oox/inc oox/source vcl/inc vcl/source vcl/unx
Radek Doulik
rodo at novell.com
Wed Apr 3 09:56:01 PDT 2013
canvas/source/cairo/cairo_canvasbitmap.cxx | 30 ++++-
canvas/source/cairo/cairo_canvasbitmap.hxx | 4
canvas/source/cairo/cairo_xlib_cairo.cxx | 7 +
canvas/source/cairo/cairo_xlib_cairo.hxx | 1
oox/inc/oox/drawingml/theme.hxx | 3
oox/source/drawingml/fillproperties.cxx | 3
oox/source/drawingml/graphicshapecontext.cxx | 3
oox/source/drawingml/shape.cxx | 18 +--
oox/source/drawingml/theme.cxx | 5
oox/source/drawingml/themeelementscontext.cxx | 12 +-
vcl/inc/salbmp.hxx | 2
vcl/inc/unx/salbmp.h | 7 +
vcl/inc/unx/salgdi.h | 5
vcl/inc/vcl/bitmap.hxx | 3
vcl/source/gdi/bitmap.cxx | 13 ++
vcl/source/gdi/gdimtf.cxx | 10 -
vcl/source/helper/canvastools.cxx | 25 ++++
vcl/unx/generic/gdi/salbmp.cxx | 18 ++-
vcl/unx/generic/gdi/salgdi2.cxx | 151 ++++++++++++++------------
19 files changed, 225 insertions(+), 95 deletions(-)
New commits:
commit 6b8e311ddc633bb13053d13c5d0f29240039846b
Author: Radek Doulik <rodo at novell.com>
Date: Thu Mar 14 09:36:43 2013 +0100
pass argb32 pixmaps from vcl to canvas, avoiding costly x11 roundtrips
- fixes also problem with emf+ rendering for slideshow
Change-Id: Icb894d3f37b29f23d3f267c944d827eefbf47fda
diff --git a/canvas/source/cairo/cairo_canvasbitmap.cxx b/canvas/source/cairo/cairo_canvasbitmap.cxx
index 91f6194..c0759c0 100644
--- a/canvas/source/cairo/cairo_canvasbitmap.cxx
+++ b/canvas/source/cairo/cairo_canvasbitmap.cxx
@@ -134,6 +134,30 @@ namespace cairocanvas
return maCanvasHelper.repaint( pSurface, viewState, renderState );
}
+ void SAL_CALL CanvasBitmap::setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rAny ) throw (uno::RuntimeException)
+ {
+ sal_Int64 nPointer;
+
+ if ( nHandle == 0 )
+ {
+ rAny >>= nPointer;
+
+ if ( nPointer )
+ {
+ ::Bitmap *pBitmap = reinterpret_cast< ::Bitmap* >( nPointer );
+
+ mpBufferSurface = createSurface( *pBitmap );
+ mpBufferCairo = mpBufferSurface->getCairo();
+
+ ::Size aSize( pBitmap->GetSizePixel() );
+ maSize = ::basegfx::B2ISize( aSize.getWidth(), aSize.getHeight() );
+
+ maCanvasHelper.setSize( maSize );
+ maCanvasHelper.setSurface( mpBufferSurface, mbHasAlpha );
+ }
+ }
+ }
+
uno::Any SAL_CALL CanvasBitmap::getFastPropertyValue( sal_Int32 nHandle ) throw (uno::RuntimeException)
{
uno::Any aRV( sal_Int32(0) );
@@ -152,10 +176,11 @@ namespace cairocanvas
#ifdef CAIRO_HAS_XLIB_SURFACE
X11Surface* pXlibSurface=dynamic_cast<X11Surface*>(mpBufferSurface.get());
OSL_ASSERT(pXlibSurface);
- uno::Sequence< uno::Any > args( 3 );
+ uno::Sequence< uno::Any > args( 4 );
args[0] = uno::Any( false ); // do not call XFreePixmap on it
args[1] = uno::Any( pXlibSurface->getPixmap()->mhDrawable );
args[2] = uno::Any( sal_Int32( pXlibSurface->getDepth() ) );
+ args[3] = uno::Any( sal_Int64( pXlibSurface->getVisual () ) );
aRV = uno::Any( args );
#elif defined CAIRO_HAS_QUARTZ_SURFACE
@@ -180,7 +205,7 @@ namespace cairocanvas
case 2:
{
#ifdef CAIRO_HAS_XLIB_SURFACE
- uno::Sequence< uno::Any > args( 3 );
+ uno::Sequence< uno::Any > args( 4 );
SurfaceSharedPtr pAlphaSurface = mpSurfaceProvider->createSurface( maSize, CAIRO_CONTENT_COLOR );
CairoSharedPtr pAlphaCairo = pAlphaSurface->getCairo();
X11Surface* pXlibSurface=dynamic_cast<X11Surface*>(pAlphaSurface.get());
@@ -199,6 +224,7 @@ namespace cairocanvas
args[0] = uno::Any( true );
args[1] = ::com::sun::star::uno::Any( pPixmap->mhDrawable );
args[2] = ::com::sun::star::uno::Any( sal_Int32( pXlibSurface->getDepth () ) );
+ args[3] = ::com::sun::star::uno::Any( sal_Int64( pXlibSurface->getVisual () ) );
pPixmap->clear(); // caller takes ownership of pixmap
// return pixmap and alphachannel pixmap - it will be used in BitmapEx
diff --git a/canvas/source/cairo/cairo_canvasbitmap.hxx b/canvas/source/cairo/cairo_canvasbitmap.hxx
index b1d669e..bef03f5 100644
--- a/canvas/source/cairo/cairo_canvasbitmap.hxx
+++ b/canvas/source/cairo/cairo_canvasbitmap.hxx
@@ -115,14 +115,14 @@ namespace cairocanvas
// 2nd the pixmap handle
// 3rd the pixmap depth
virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&) throw (::com::sun::star::uno::RuntimeException) {}
+ virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&) throw (::com::sun::star::uno::RuntimeException);
private:
SurfaceProviderRef mpSurfaceProvider;
::cairo::SurfaceSharedPtr mpBufferSurface;
::cairo::CairoSharedPtr mpBufferCairo;
- const ::basegfx::B2ISize maSize;
+ ::basegfx::B2ISize maSize;
const bool mbHasAlpha;
};
}
diff --git a/canvas/source/cairo/cairo_xlib_cairo.cxx b/canvas/source/cairo/cairo_xlib_cairo.cxx
index cd13ea1..3086fd5 100644
--- a/canvas/source/cairo/cairo_xlib_cairo.cxx
+++ b/canvas/source/cairo/cairo_xlib_cairo.cxx
@@ -187,7 +187,7 @@ namespace cairo
mpSurface(
cairo_xlib_surface_create( (Display*)rSysData.pDisplay,
(Drawable)rData.aPixmap,
- (Visual*) rSysData.pVisual,
+ (Visual*) (rData.aVisual ? rData.aVisual : rSysData.pVisual),
rData.mnWidth, rData.mnHeight ),
&cairo_surface_destroy)
{
@@ -312,6 +312,11 @@ namespace cairo
return -1;
}
+ void* X11Surface::getVisual() const
+ {
+ return cairo_xlib_surface_get_visual( mpSurface.get() );
+ }
+
SurfaceSharedPtr createSurface( const CairoSurfaceSharedPtr& rSurface )
{
return SurfaceSharedPtr(new X11Surface(rSurface));
diff --git a/canvas/source/cairo/cairo_xlib_cairo.hxx b/canvas/source/cairo/cairo_xlib_cairo.hxx
index 105c570..080258b 100644
--- a/canvas/source/cairo/cairo_xlib_cairo.hxx
+++ b/canvas/source/cairo/cairo_xlib_cairo.hxx
@@ -92,6 +92,7 @@ namespace cairo {
X11PixmapSharedPtr getPixmap() const { return mpPixmap; }
void* getRenderFormat() const { return maSysData.pRenderFormat; }
long getDrawable() const { return mpPixmap ? mpPixmap->mhDrawable : maSysData.hDrawable; }
+ void* getVisual() const;
};
}
diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h
index 6973507..70307a1 100644
--- a/vcl/inc/unx/salbmp.h
+++ b/vcl/inc/unx/salbmp.h
@@ -80,6 +80,7 @@ public:
SAL_DLLPRIVATE bool ImplCreateFromDrawable(
Drawable aDrawable,
+ void* pVisual,
SalX11Screen nXScreen,
long nDrawableDepth,
long nX,
@@ -162,6 +163,7 @@ class ImplSalDDB
private:
Pixmap maPixmap;
+ void* mpVisual;
SalTwoRect maTwoRect;
long mnDepth;
SalX11Screen mnXScreen;
@@ -193,6 +195,7 @@ public:
ImplSalDDB(
Drawable aDrawable,
+ void *pVisual,
SalX11Screen nXScreen,
long nDrawableDepth,
long nX,
@@ -204,6 +207,7 @@ public:
~ImplSalDDB();
Pixmap ImplGetPixmap() const { return maPixmap; }
+ void* ImplGetVisual() const { return mpVisual; }
long ImplGetWidth() const { return maTwoRect.mnDestWidth; }
long ImplGetHeight() const { return maTwoRect.mnDestHeight; }
long ImplGetDepth() const { return mnDepth; }
diff --git a/vcl/inc/vcl/bitmap.hxx b/vcl/inc/vcl/bitmap.hxx
index ea52068..df42f93 100644
--- a/vcl/inc/vcl/bitmap.hxx
+++ b/vcl/inc/vcl/bitmap.hxx
@@ -325,6 +325,7 @@ struct BitmapSystemData
void* rImageContext; //Image context (CGContextRef)
#else
void* aPixmap;
+ void* aVisual;
#endif
int mnWidth;
int mnHeight;
@@ -846,6 +847,8 @@ public:
const BmpFilterParam* pFilterParam = NULL,
const Link* pProgress = NULL );
+ bool HasAlpha();
+
public:
BitmapReadAccess* AcquireReadAccess();
BitmapWriteAccess* AcquireWriteAccess();
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index 436092a..98de0a4 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -1901,4 +1901,17 @@ bool Bitmap::GetSystemData( BitmapSystemData& rData ) const
return bRet;
}
+bool Bitmap::HasAlpha()
+{
+ bool bRet = false;
+ if( mpImpBmp )
+ {
+ SalBitmap* pSalBitmap = mpImpBmp->ImplGetSalBitmap();
+ if( pSalBitmap )
+ bRet = pSalBitmap->HasAlpha();
+ }
+
+ return bRet;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/helper/canvastools.cxx b/vcl/source/helper/canvastools.cxx
index 75ad872..d05f7e7 100644
--- a/vcl/source/helper/canvastools.cxx
+++ b/vcl/source/helper/canvastools.cxx
@@ -21,6 +21,8 @@
#include <rtl/logfile.hxx>
#include <cppuhelper/compbase1.hxx>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+
#include <com/sun/star/geometry/RealSize2D.hpp>
#include <com/sun/star/geometry/RealPoint2D.hpp>
#include <com/sun/star/geometry/RealRectangle2D.hpp>
@@ -70,11 +72,32 @@ namespace vcl
{
namespace unotools
{
- uno::Reference< rendering::XBitmap > xBitmapFromBitmapEx( const uno::Reference< rendering::XGraphicDevice >& /*xGraphicDevice*/,
+ uno::Reference< rendering::XBitmap > xBitmapFromBitmapEx( const uno::Reference< rendering::XGraphicDevice >& xGraphicDevice,
const ::BitmapEx& inputBitmap )
{
RTL_LOGFILE_CONTEXT( aLog, "::vcl::unotools::xBitmapFromBitmapEx()" );
+ if ( inputBitmap.GetBitmap().HasAlpha() )
+ {
+ geometry::IntegerSize2D aSize;
+
+ aSize.Width = aSize.Height = 1;
+
+ uno::Reference< rendering::XBitmap > xBitmap = xGraphicDevice->createCompatibleAlphaBitmap( aSize );
+
+ uno::Reference< beans::XFastPropertySet > rPropSet( xBitmap, uno::UNO_QUERY );
+ if ( rPropSet.is() )
+ {
+ Bitmap aBitmap = inputBitmap.GetBitmap();
+ rPropSet->setFastPropertyValue( 0, uno::Any( sal_Int64( &aBitmap )));
+
+ aSize = xBitmap->getSize();
+
+ if ( aSize.Width != 1 || aSize.Height != 1 )
+ return xBitmap;
+ }
+ }
+
return new vcl::unotools::VclCanvasBitmap( inputBitmap );
}
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index faa04c7..bf9a703 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -566,6 +566,7 @@ XImage* X11SalBitmap::ImplCreateXImage(
// -----------------------------------------------------------------------------
bool X11SalBitmap::ImplCreateFromDrawable(
Drawable aDrawable,
+ void *pVisual,
SalX11Screen nScreen,
long nDrawableDepth,
long nX,
@@ -576,7 +577,7 @@ bool X11SalBitmap::ImplCreateFromDrawable(
Destroy();
if( aDrawable && nWidth && nHeight && nDrawableDepth )
- mpDDB = new ImplSalDDB( aDrawable, nScreen, nDrawableDepth, nX, nY, nWidth, nHeight );
+ mpDDB = new ImplSalDDB( aDrawable, pVisual, nScreen, nDrawableDepth, nX, nY, nWidth, nHeight );
return( mpDDB != NULL );
}
@@ -736,7 +737,8 @@ bool X11SalBitmap::Create( const SalBitmap& rSSalBmp )
}
else if( rSalBmp.mpDDB )
ImplCreateFromDrawable( rSalBmp.mpDDB->ImplGetPixmap(),
- rSalBmp.mpDDB->ImplGetScreen(),
+ rSalBmp.mpDDB->ImplGetVisual(),
+ rSalBmp.mpDDB->ImplGetScreen(),
rSalBmp.mpDDB->ImplGetDepth(),
0, 0, rSalBmp.mpDDB->ImplGetWidth(), rSalBmp.mpDDB->ImplGetHeight() );
@@ -775,11 +777,13 @@ bool X11SalBitmap::Create(
if( xFastPropertySet->getFastPropertyValue(bMask ? 2 : 1) >>= args ) {
long pixmapHandle;
- if( ( args[1] >>= pixmapHandle ) && ( args[2] >>= depth ) ) {
+ sal_Int64 nVisualPtr;
+ if( args.getLength() >= 4 && ( args[1] >>= pixmapHandle ) && ( args[2] >>= depth ) && ( args[3] >>= nVisualPtr ) ) {
mbGrey = bMask;
bool bSuccess = ImplCreateFromDrawable(
pixmapHandle,
+ reinterpret_cast<void*>(nVisualPtr),
// FIXME: this seems multi-screen broken to me
SalX11Screen( 0 ),
depth,
@@ -891,6 +895,7 @@ bool X11SalBitmap::GetSystemData( BitmapSystemData& rData )
// prolly not a good idea, since it's accessed from
// non-platform aware code in vcl/bitmap.hxx)
rData.aPixmap = (void*)mpDDB->ImplGetPixmap();
+ rData.aVisual = mpDDB->ImplGetVisual ();
rData.mnWidth = mpDDB->ImplGetWidth ();
rData.mnHeight = mpDDB->ImplGetHeight ();
return true;
@@ -906,6 +911,7 @@ bool X11SalBitmap::GetSystemData( BitmapSystemData& rData )
ImplSalDDB::ImplSalDDB( XImage* pImage, Drawable aDrawable,
SalX11Screen nXScreen, const SalTwoRect& rTwoRect )
: maPixmap ( 0 )
+ , mpVisual ( NULL )
, maTwoRect ( rTwoRect )
, mnDepth ( pImage->depth )
, mnXScreen ( nXScreen )
@@ -937,13 +943,15 @@ ImplSalDDB::ImplSalDDB( XImage* pImage, Drawable aDrawable,
ImplSalDDB::ImplSalDDB(
Drawable aDrawable,
+ void *pVisual,
SalX11Screen nXScreen,
long nDrawableDepth,
long nX,
long nY,
long nWidth,
long nHeight
-) : mnDepth( nDrawableDepth )
+) : mpVisual ( pVisual )
+ , mnDepth( nDrawableDepth )
, mnXScreen( nXScreen )
{
SalDisplay* pSalDisp = GetGenericData()->GetSalDisplay();
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index 4684842..bbc9c6b 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -90,7 +90,7 @@ void X11SalGraphics::CopyScreenArea( Display* pDisplay,
else
{
X11SalBitmap aBM;
- aBM.ImplCreateFromDrawable( aSrc, nXScreenSrc, nSrcDepth, src_x, src_y, w, h );
+ aBM.ImplCreateFromDrawable( aSrc, NULL, nXScreenSrc, nSrcDepth, src_x, src_y, w, h );
SalTwoRect aTwoRect;
aTwoRect.mnSrcX = aTwoRect.mnSrcY = 0;
aTwoRect.mnSrcWidth = aTwoRect.mnDestWidth = w;
@@ -658,8 +658,8 @@ bool X11SalGraphics::drawAlphaBitmapOpt( const SalTwoRect& rTR,
const SalVisual& rSalVis = pSalDisp->GetVisual( m_nXScreen );
Display* pXDisplay = pSalDisp->GetDisplay();
- Picture aAlphaPic;
- Pixmap aAlphaPM;
+ Picture aAlphaPic = 0;
+ Pixmap aAlphaPM = 0;
// create source Picture
int nDepth = m_pVDev ? m_pVDev->GetDepth() : rSalVis.GetDepth();
const X11SalBitmap& rSrcX11Bmp = static_cast<const X11SalBitmap&>( rSrcBitmap );
@@ -911,7 +911,7 @@ SalBitmap *X11SalGraphics::getBitmap( long nX, long nY, long nDX, long nDY )
nBitCount = 1;
if( ! bFakeWindowBG )
- pSalBitmap->ImplCreateFromDrawable( GetDrawable(), m_nXScreen, nBitCount, nX, nY, nDX, nDY );
+ pSalBitmap->ImplCreateFromDrawable( GetDrawable(), NULL, m_nXScreen, nBitCount, nX, nY, nDX, nDY );
else
pSalBitmap->Create( Size( nDX, nDY ), (nBitCount > 8) ? 24 : nBitCount, BitmapPalette( nBitCount > 8 ? nBitCount : 0 ) );
commit 1a977c09ec478b58eaa49a2372ca8696c4fbe336
Author: Radek Doulik <rodo at novell.com>
Date: Thu Mar 7 13:31:34 2013 +0100
fix canvas bitmap rendering (argb32 pixmaps) fixes color issue in n#780830
Change-Id: I5242bbb171ba21da43e535255b7e9dd73c1d4930
diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx
index 99b5e6a..03f9af9 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -47,6 +47,8 @@ public:
virtual bool Create( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > xBitmapCanvas,
Size& rSize,
bool bMask = false ) = 0;
+ virtual bool HasAlpha() const { return false; }
+ virtual void SetHasAlpha( bool ) { }
virtual void Destroy() = 0;
virtual Size GetSize() const = 0;
virtual sal_uInt16 GetBitCount() const = 0;
diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h
index 866412d..6973507 100644
--- a/vcl/inc/unx/salbmp.h
+++ b/vcl/inc/unx/salbmp.h
@@ -74,6 +74,7 @@ private:
BitmapBuffer* mpDIB;
ImplSalDDB* mpDDB;
bool mbGrey;
+ bool mbHasAlpha;
public:
@@ -148,6 +149,8 @@ public:
virtual BitmapBuffer* AcquireBuffer( bool bReadOnly );
virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly );
virtual bool GetSystemData( BitmapSystemData& rData );
+ virtual bool HasAlpha() const { return mbHasAlpha; }
+ virtual void SetHasAlpha( bool bHasAlpha ) { mbHasAlpha = bHasAlpha; }
};
// --------------
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index f1039e9..3684dd0 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -324,6 +324,11 @@ public:
const SalBitmap& rSourceBitmap,
const SalBitmap& rAlphaBitmap );
+ bool drawAlphaBitmapOpt( const SalTwoRect&,
+ const SalBitmap& rSourceBitmap,
+ const SalBitmap& rAlphaBitmap,
+ bool bUseAlphaBitmap = true );
+
virtual bool drawAlphaRect( long nX, long nY, long nWidth,
long nHeight, sal_uInt8 nTransparency );
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 42ed63c..3fbb01c 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -492,20 +492,16 @@ bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, S
}
SalBitmap* pSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
- SalBitmap* pSalMask = ImplGetSVData()->mpDefInst->CreateSalBitmap();
+ pSalBmp->SetHasAlpha( true );
- if( pSalBmp->Create( xBitmapCanvas, aSize ) && pSalMask->Create( xBitmapCanvas, aSize, true ) )
+ if( pSalBmp->Create( xBitmapCanvas, aSize ) )
{
Bitmap aBitmap( pSalBmp );
- Bitmap aMask( pSalMask );
- AlphaMask aAlphaMask( aMask );
- BitmapEx aBitmapEx( aBitmap, aAlphaMask );
- pOut->DrawBitmapEx( rPos, aBitmapEx );
+ pOut->DrawBitmap( rPos, aBitmap );
return true;
}
delete pSalBmp;
- delete pSalMask;
}
}
}
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index aee24dd..faa04c7 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -42,6 +42,7 @@
#include <unx/salbmp.h>
#include <unx/salinst.h>
#include <unx/x11/xlimits.hxx>
+#include "xrender_peer.hxx"
#if defined HAVE_VALGRIND_HEADERS
#include <valgrind/memcheck.h>
@@ -65,6 +66,7 @@ X11SalBitmap::X11SalBitmap()
: mpDIB( NULL )
, mpDDB( NULL )
, mbGrey( false )
+ , mbHasAlpha( false )
{
}
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index 97d1924..4684842 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -495,7 +495,10 @@ void X11SalGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSa
XChangeGC( pXDisp, aGC, nValues, &aNewVal );
}
- static_cast<const X11SalBitmap&>(rSalBitmap).ImplDraw( aDrawable, m_nXScreen, nDepth, *pPosAry, aGC );
+ if ( rSalBitmap.GetBitCount() == 32 && rSalBitmap.HasAlpha() )
+ drawAlphaBitmapOpt( *pPosAry, rSalBitmap, rSalBitmap, false );
+ else
+ static_cast<const X11SalBitmap&>(rSalBitmap).ImplDraw( aDrawable, m_nXScreen, nDepth, *pPosAry, aGC );
if( rSalBitmap.GetBitCount() == 1 )
XChangeGC( pXDisp, aGC, nValues, &aOldVal );
@@ -623,10 +626,17 @@ void X11SalGraphics::drawMaskedBitmap( const SalTwoRect* pPosAry,
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
- const SalBitmap& rSrcBitmap, const SalBitmap& rAlphaBmp )
+ const SalBitmap& rSrcBitmap, const SalBitmap& rAlphaBmp )
+{
+ return drawAlphaBitmapOpt( rTR, rSrcBitmap, rAlphaBmp );
+}
+
+// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+bool X11SalGraphics::drawAlphaBitmapOpt( const SalTwoRect& rTR,
+ const SalBitmap& rSrcBitmap, const SalBitmap& rAlphaBmp, bool bUseAlphaBitmap )
{
// non 8-bit alpha not implemented yet
- if( rAlphaBmp.GetBitCount() != 8 )
+ if( bUseAlphaBitmap && rAlphaBmp.GetBitCount() != 8 )
return false;
// horizontal mirroring not implemented yet
@@ -648,10 +658,12 @@ bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
const SalVisual& rSalVis = pSalDisp->GetVisual( m_nXScreen );
Display* pXDisplay = pSalDisp->GetDisplay();
+ Picture aAlphaPic;
+ Pixmap aAlphaPM;
// create source Picture
int nDepth = m_pVDev ? m_pVDev->GetDepth() : rSalVis.GetDepth();
const X11SalBitmap& rSrcX11Bmp = static_cast<const X11SalBitmap&>( rSrcBitmap );
- ImplSalDDB* pSrcDDB = rSrcX11Bmp.ImplGetDDB( hDrawable_, m_nXScreen, nDepth, rTR );
+ ImplSalDDB* pSrcDDB = rSrcX11Bmp.ImplGetDDB( hDrawable_, m_nXScreen, bUseAlphaBitmap ? nDepth : 32, rTR );
if( !pSrcDDB )
return false;
@@ -659,7 +671,7 @@ bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
// we requested. E.g. mask pixmaps are always compatible with the drawable
// TODO: find an appropriate picture format for these cases
// then remove the workaround below and the one for #i75531#
- if( nDepth != pSrcDDB->ImplGetDepth() )
+ if( bUseAlphaBitmap && nDepth != pSrcDDB->ImplGetDepth() )
return false;
Pixmap aSrcPM = pSrcDDB->ImplGetPixmap();
@@ -670,81 +682,86 @@ bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
// TODO: use scoped picture
Visual* pSrcXVisual = rSalVis.GetVisual();
XRenderPeer& rPeer = XRenderPeer::GetInstance();
- XRenderPictFormat* pSrcVisFmt = rPeer.FindVisualFormat( pSrcXVisual );
+ XRenderPictFormat* pSrcVisFmt = bUseAlphaBitmap ? rPeer.FindVisualFormat( pSrcXVisual ) : rPeer.FindStandardFormat( PictStandardARGB32 );
if( !pSrcVisFmt )
return false;
Picture aSrcPic = rPeer.CreatePicture( aSrcPM, pSrcVisFmt, 0, NULL );
if( !aSrcPic )
return false;
- // create alpha Picture
+ if ( bUseAlphaBitmap ) {
+ // create alpha Picture
- // TODO: use SalX11Bitmap functionality and caching for the Alpha Pixmap
- // problem is that they don't provide an 8bit Pixmap on a non-8bit display
- BitmapBuffer* pAlphaBuffer = const_cast<SalBitmap&>(rAlphaBmp).AcquireBuffer( sal_True );
+ // TODO: use SalX11Bitmap functionality and caching for the Alpha Pixmap
+ // problem is that they don't provide an 8bit Pixmap on a non-8bit display
+ BitmapBuffer* pAlphaBuffer = const_cast<SalBitmap&>(rAlphaBmp).AcquireBuffer( sal_True );
- // an XImage needs its data top_down
- // TODO: avoid wrongly oriented images in upper layers!
- const int nImageSize = pAlphaBuffer->mnHeight * pAlphaBuffer->mnScanlineSize;
- const char* pSrcBits = (char*)pAlphaBuffer->mpBits;
- char* pAlphaBits = new char[ nImageSize ];
- if( BMP_SCANLINE_ADJUSTMENT( pAlphaBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN )
- memcpy( pAlphaBits, pSrcBits, nImageSize );
- else
- {
- char* pDstBits = pAlphaBits + nImageSize;
- const int nLineSize = pAlphaBuffer->mnScanlineSize;
- for(; (pDstBits -= nLineSize) >= pAlphaBits; pSrcBits += nLineSize )
- memcpy( pDstBits, pSrcBits, nLineSize );
- }
-
- // the alpha values need to be inverted for XRender
- // TODO: make upper layers use standard alpha
- long* pLDst = (long*)pAlphaBits;
- for( int i = nImageSize/sizeof(long); --i >= 0; ++pLDst )
- *pLDst = ~*pLDst;
-
- char* pCDst = (char*)pLDst;
- for( int i = nImageSize & (sizeof(long)-1); --i >= 0; ++pCDst )
- *pCDst = ~*pCDst;
-
- const XRenderPictFormat* pAlphaFormat = rPeer.GetStandardFormatA8();
- XImage* pAlphaImg = XCreateImage( pXDisplay, pSrcXVisual, 8, ZPixmap, 0,
- pAlphaBits, pAlphaBuffer->mnWidth, pAlphaBuffer->mnHeight,
- pAlphaFormat->depth, pAlphaBuffer->mnScanlineSize );
-
- Pixmap aAlphaPM = limitXCreatePixmap( pXDisplay, hDrawable_,
- rTR.mnDestWidth, rTR.mnDestHeight, 8 );
-
- XGCValues aAlphaGCV;
- aAlphaGCV.function = GXcopy;
- GC aAlphaGC = XCreateGC( pXDisplay, aAlphaPM, GCFunction, &aAlphaGCV );
- XPutImage( pXDisplay, aAlphaPM, aAlphaGC, pAlphaImg,
- rTR.mnSrcX, rTR.mnSrcY, 0, 0, rTR.mnDestWidth, rTR.mnDestHeight );
- XFreeGC( pXDisplay, aAlphaGC );
- XFree( pAlphaImg );
- if( pAlphaBits != (char*)pAlphaBuffer->mpBits )
- delete[] pAlphaBits;
-
- const_cast<SalBitmap&>(rAlphaBmp).ReleaseBuffer( pAlphaBuffer, sal_True );
-
- XRenderPictureAttributes aAttr;
- aAttr.repeat = true;
- Picture aAlphaPic = rPeer.CreatePicture( aAlphaPM, pAlphaFormat, CPRepeat, &aAttr );
- if( !aAlphaPic )
- return false;
+ // an XImage needs its data top_down
+ // TODO: avoid wrongly oriented images in upper layers!
+ const int nImageSize = pAlphaBuffer->mnHeight * pAlphaBuffer->mnScanlineSize;
+ const char* pSrcBits = (char*)pAlphaBuffer->mpBits;
+ char* pAlphaBits = new char[ nImageSize ];
+ if( BMP_SCANLINE_ADJUSTMENT( pAlphaBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN )
+ memcpy( pAlphaBits, pSrcBits, nImageSize );
+ else
+ {
+ char* pDstBits = pAlphaBits + nImageSize;
+ const int nLineSize = pAlphaBuffer->mnScanlineSize;
+ for(; (pDstBits -= nLineSize) >= pAlphaBits; pSrcBits += nLineSize )
+ memcpy( pDstBits, pSrcBits, nLineSize );
+ }
+
+ // the alpha values need to be inverted for XRender
+ // TODO: make upper layers use standard alpha
+ long* pLDst = (long*)pAlphaBits;
+ for( int i = nImageSize/sizeof(long); --i >= 0; ++pLDst )
+ *pLDst = ~*pLDst;
+
+ char* pCDst = (char*)pLDst;
+ for( int i = nImageSize & (sizeof(long)-1); --i >= 0; ++pCDst )
+ *pCDst = ~*pCDst;
+
+ const XRenderPictFormat* pAlphaFormat = rPeer.GetStandardFormatA8();
+ XImage* pAlphaImg = XCreateImage( pXDisplay, pSrcXVisual, 8, ZPixmap, 0,
+ pAlphaBits, pAlphaBuffer->mnWidth, pAlphaBuffer->mnHeight,
+ pAlphaFormat->depth, pAlphaBuffer->mnScanlineSize );
+
+ aAlphaPM = limitXCreatePixmap( pXDisplay, hDrawable_,
+ rTR.mnDestWidth, rTR.mnDestHeight, 8 );
+
+ XGCValues aAlphaGCV;
+ aAlphaGCV.function = GXcopy;
+ GC aAlphaGC = XCreateGC( pXDisplay, aAlphaPM, GCFunction, &aAlphaGCV );
+ XPutImage( pXDisplay, aAlphaPM, aAlphaGC, pAlphaImg,
+ rTR.mnSrcX, rTR.mnSrcY, 0, 0, rTR.mnDestWidth, rTR.mnDestHeight );
+ XFreeGC( pXDisplay, aAlphaGC );
+ XFree( pAlphaImg );
+ if( pAlphaBits != (char*)pAlphaBuffer->mpBits )
+ delete[] pAlphaBits;
+
+ const_cast<SalBitmap&>(rAlphaBmp).ReleaseBuffer( pAlphaBuffer, sal_True );
+
+ XRenderPictureAttributes aAttr;
+ aAttr.repeat = true;
+ aAlphaPic = rPeer.CreatePicture( aAlphaPM, pAlphaFormat, CPRepeat, &aAttr );
+ if( !aAlphaPic )
+ return false;
+ }
// set clipping
if( mpClipRegion && !XEmptyRegion( mpClipRegion ) )
rPeer.SetPictureClipRegion( aDstPic, mpClipRegion );
// paint source * mask over destination picture
- rPeer.CompositePicture( PictOpOver, aSrcPic, aAlphaPic, aDstPic,
- rTR.mnSrcX, rTR.mnSrcY, 0, 0,
- rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight );
+ rPeer.CompositePicture( PictOpOver, aSrcPic, bUseAlphaBitmap ? aAlphaPic : None, aDstPic,
+ rTR.mnSrcX, rTR.mnSrcY, 0, 0,
+ rTR.mnDestX, rTR.mnDestY, rTR.mnDestWidth, rTR.mnDestHeight );
- rPeer.FreePicture( aAlphaPic );
- XFreePixmap(pXDisplay, aAlphaPM);
+ if ( bUseAlphaBitmap )
+ {
+ rPeer.FreePicture( aAlphaPic );
+ XFreePixmap( pXDisplay, aAlphaPM);
+ }
rPeer.FreePicture( aSrcPic );
return true;
}
commit 8c7100d05aa90c8567e22f83f3cec8b5ac4c9ca3
Author: Radek Doulik <rodo at novell.com>
Date: Tue Jan 29 10:42:46 2013 +0100
use ole obj preview image
Change-Id: I7e88ca553fcb8449a337af36554dd1996bc6dd7d
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index a400cce..5caeb55 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -396,6 +396,9 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe
}
}
+ rPropMap[ PROP_Graphic ] <<= xGraphic;
+
+ // do we still need to set GraphicURL as well? (TODO)
OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic );
if( !aGraphicUrl.isEmpty() )
rPropMap[ PROP_GraphicURL ] <<= aGraphicUrl;
diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx
index 1b13420..377b8c5 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -214,6 +214,9 @@ Reference< XFastContextHandler > OleObjectGraphicDataContext::createFastChildCon
OSL_ENSURE( mrOleObjectInfo.mbLinked, "OleObjectGraphicDataContext::createFastChildContext - unexpected child element" );
mrOleObjectInfo.mbAutoUpdate = aAttribs.getBool( XML_updateAutomatic, false );
break;
+ case PPT_TOKEN( pic ):
+ xRet.set( new GraphicShapeContext( *this, mpMasterShapePtr, mpShapePtr ) );
+ break;
}
return xRet;
}
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 9e0b232..8a4cdca 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -540,7 +540,7 @@ Reference< XShape > Shape::createAndInsert(
// applying properties
aShapeProps.assignUsed( getShapeProperties() );
aShapeProps.assignUsed( maDefaultShapeProperties );
- if ( bIsEmbMedia || aServiceName == "com.sun.star.drawing.GraphicObjectShape" )
+ if ( bIsEmbMedia || aServiceName == "com.sun.star.drawing.GraphicObjectShape" || aServiceName == "com.sun.star.drawing.OLE2Shape" )
mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper );
if ( mpTablePropertiesPtr.get() && aServiceName == "com.sun.star.drawing.TableShape" )
mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
commit ccab75a6b86072a28f943f14cef55b5f5fca3400
Author: Radek Doulik <rodo at novell.com>
Date: Tue Dec 11 15:35:43 2012 +0100
use effect references
Change-Id: Ie0d295cd7db695f777071edcd9b792056ac783ef
diff --git a/oox/inc/oox/drawingml/theme.hxx b/oox/inc/oox/drawingml/theme.hxx
index e7b1030..12bb62b 100644
--- a/oox/inc/oox/drawingml/theme.hxx
+++ b/oox/inc/oox/drawingml/theme.hxx
@@ -37,7 +37,7 @@ const sal_Int32 THEMED_STYLE_INTENSE = 3;
typedef RefVector< FillProperties > FillStyleList;
typedef RefVector< LineProperties > LineStyleList;
-typedef RefVector< PropertyMap > EffectStyleList;
+typedef RefVector< EffectProperties > EffectStyleList;
typedef RefMap< sal_Int32, TextCharacterProperties > FontScheme;
// ============================================================================
@@ -68,6 +68,7 @@ public:
inline EffectStyleList& getEffectStyleList() { return maEffectStyleList; }
inline const EffectStyleList& getEffectStyleList() const { return maEffectStyleList; }
+ const EffectProperties* getEffectStyle( sal_Int32 nIndex ) const;
inline FontScheme& getFontScheme() { return maFontScheme; }
inline const FontScheme& getFontScheme() const { return maFontScheme; }
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 9200fa2..9e0b232 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -493,6 +493,8 @@ Reference< XShape > Shape::createAndInsert(
aFillProperties.moFillType = XML_noFill;
sal_Int32 nFillPhClr = -1;
EffectProperties aEffectProperties;
+ // TODO: use ph color when applying effect properties
+ //sal_Int32 nEffectPhClr = -1;
if( pTheme )
{
@@ -508,12 +510,13 @@ Reference< XShape > Shape::createAndInsert(
aFillProperties.assignUsed( *pFillProps );
nFillPhClr = pFillRef->maPhClr.getColor( rGraphicHelper );
}
-// if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_fillRef ) )
-// {
-// if( const EffectProperties* pEffectProps = pTheme->getEffectStyle( pEffectRef->mnThemedIdx ) )
-// aEffectProperties.assignUsed( *pEffectProps );
-// nEffectPhClr = pEffectRef->maPhClr.getColor( rGraphicHelper );
-// }
+ if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) )
+ {
+ if( const EffectProperties* pEffectProps = pTheme->getEffectStyle( pEffectRef->mnThemedIdx ) )
+ aEffectProperties.assignUsed( *pEffectProps );
+ // TODO: use ph color when applying effect properties
+ // nEffectPhClr = pEffectRef->maPhClr.getColor( rGraphicHelper );
+ }
}
aLineProperties.assignUsed( getLineProperties() );
@@ -543,6 +546,7 @@ Reference< XShape > Shape::createAndInsert(
mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, mbFlipH, mbFlipV );
aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr );
+ // TODO: use ph color when applying effect properties
aEffectProperties.pushToPropMap( aShapeProps, rGraphicHelper );
// applying autogrowheight property before setting shape size, because
diff --git a/oox/source/drawingml/theme.cxx b/oox/source/drawingml/theme.cxx
index ef426fa..03f3f0c 100644
--- a/oox/source/drawingml/theme.cxx
+++ b/oox/source/drawingml/theme.cxx
@@ -57,6 +57,11 @@ const LineProperties* Theme::getLineStyle( sal_Int32 nIndex ) const
return lclGetStyleElement( maLineStyleList, nIndex );
}
+const EffectProperties* Theme::getEffectStyle( sal_Int32 nIndex ) const
+{
+ return lclGetStyleElement( maEffectStyleList, nIndex );
+}
+
const TextCharacterProperties* Theme::getFontStyle( sal_Int32 nSchemeType ) const
{
return maFontScheme.get( nSchemeType ).get();
diff --git a/oox/source/drawingml/themeelementscontext.cxx b/oox/source/drawingml/themeelementscontext.cxx
index 16817ca1..805a080 100644
--- a/oox/source/drawingml/themeelementscontext.cxx
+++ b/oox/source/drawingml/themeelementscontext.cxx
@@ -21,6 +21,8 @@
#include "oox/drawingml/clrschemecontext.hxx"
#include "oox/drawingml/lineproperties.hxx"
#include "oox/drawingml/linepropertiescontext.hxx"
+#include "oox/drawingml/effectproperties.hxx"
+#include "oox/drawingml/effectpropertiescontext.hxx"
#include "oox/drawingml/fillproperties.hxx"
#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
#include "oox/drawingml/theme.hxx"
@@ -122,9 +124,13 @@ Reference< XFastContextHandler > EffectStyleListContext::createFastChildContext(
switch( nElement )
{
case A_TOKEN( effectStyle ):
- mrEffectStyleList.push_back( EffectStyleList::value_type( new PropertyMap ) );
- // TODO: import effect styles
- return 0;
+ mrEffectStyleList.push_back( EffectPropertiesPtr( new EffectProperties ) );
+ return this;
+
+ case A_TOKEN( effectLst ): // CT_EffectList
+ if( mrEffectStyleList.back() )
+ return new EffectPropertiesContext( *this, *mrEffectStyleList.back() );
+ break;
}
return 0;
}
More information about the Libreoffice-commits
mailing list