1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dx_canvascustomsprite.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_canvas.hxx"
34 #include <ctype.h> // don't ask. msdev breaks otherwise...
35 #include <canvas/debug.hxx>
36 #include <canvas/verbosetrace.hxx>
37 #include <tools/diagnose_ex.h>
39 #include <rtl/logfile.hxx>
40 #include <rtl/math.hxx>
42 #include <canvas/canvastools.hxx>
44 #include <basegfx/matrix/b2dhommatrix.hxx>
45 #include <basegfx/point/b2dpoint.hxx>
47 #include "dx_canvascustomsprite.hxx"
48 #include "dx_spritecanvas.hxx"
49 #include "dx_impltools.hxx"
51 using namespace ::com::sun::star
;
55 CanvasCustomSprite::CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D
& rSpriteSize
,
56 const SpriteCanvasRef
& rRefDevice
,
57 const IDXRenderModuleSharedPtr
& rRenderModule
,
58 const ::canvas::ISurfaceProxyManagerSharedPtr
& rSurfaceProxy
,
59 bool bShowSpriteBounds
) :
60 mpSpriteCanvas( rRefDevice
),
63 ENSURE_OR_THROW( rRefDevice
.get(),
64 "CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" );
69 ::canvas::tools::roundUp( rSpriteSize
.Width
),
70 ::canvas::tools::roundUp( rSpriteSize
.Height
)),
75 maCanvasHelper
.setDevice( *rRefDevice
.get() );
76 maCanvasHelper
.setTarget( mpSurface
);
78 maSpriteHelper
.init( rSpriteSize
,
84 // clear sprite to 100% transparent
85 maCanvasHelper
.clear();
88 void SAL_CALL
CanvasCustomSprite::disposing()
90 ::osl::MutexGuard
aGuard( m_aMutex
);
93 mpSpriteCanvas
.clear();
96 CanvasCustomSpriteBaseT::disposing();
99 #define IMPLEMENTATION_NAME "DXCanvas.CanvasCustomSprite"
100 #define SERVICE_NAME "com.sun.star.rendering.CanvasCustomSprite"
102 ::rtl::OUString SAL_CALL
CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException
)
104 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME
) );
107 sal_Bool SAL_CALL
CanvasCustomSprite::supportsService( const ::rtl::OUString
& ServiceName
) throw( uno::RuntimeException
)
109 return ServiceName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME
) );
112 uno::Sequence
< ::rtl::OUString
> SAL_CALL
CanvasCustomSprite::getSupportedServiceNames() throw( uno::RuntimeException
)
114 uno::Sequence
< ::rtl::OUString
> aRet(1);
115 aRet
[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME
) );
120 void CanvasCustomSprite::redraw() const
122 ::osl::MutexGuard
aGuard( m_aMutex
);
124 maSpriteHelper
.redraw( mbSurfaceDirty
);