1*25ea7f45SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*25ea7f45SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*25ea7f45SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*25ea7f45SAndrew Rist * distributed with this work for additional information 6*25ea7f45SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*25ea7f45SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*25ea7f45SAndrew Rist * "License"); you may not use this file except in compliance 9*25ea7f45SAndrew Rist * with the License. You may obtain a copy of the License at 10*25ea7f45SAndrew Rist * 11*25ea7f45SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*25ea7f45SAndrew Rist * 13*25ea7f45SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*25ea7f45SAndrew Rist * software distributed under the License is distributed on an 15*25ea7f45SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*25ea7f45SAndrew Rist * KIND, either express or implied. See the License for the 17*25ea7f45SAndrew Rist * specific language governing permissions and limitations 18*25ea7f45SAndrew Rist * under the License. 19*25ea7f45SAndrew Rist * 20*25ea7f45SAndrew Rist *************************************************************/ 21*25ea7f45SAndrew Rist 22*25ea7f45SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_canvas.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <ctype.h> // don't ask. msdev breaks otherwise... 28cdf0e10cSrcweir #include <canvas/debug.hxx> 29cdf0e10cSrcweir #include <canvas/verbosetrace.hxx> 30cdf0e10cSrcweir #include <tools/diagnose_ex.h> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <rtl/logfile.hxx> 33cdf0e10cSrcweir #include <rtl/math.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <canvas/canvastools.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 38cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include "dx_canvascustomsprite.hxx" 41cdf0e10cSrcweir #include "dx_spritecanvas.hxx" 42cdf0e10cSrcweir #include "dx_impltools.hxx" 43cdf0e10cSrcweir 44cdf0e10cSrcweir using namespace ::com::sun::star; 45cdf0e10cSrcweir 46cdf0e10cSrcweir namespace dxcanvas 47cdf0e10cSrcweir { 48cdf0e10cSrcweir CanvasCustomSprite::CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize, 49cdf0e10cSrcweir const SpriteCanvasRef& rRefDevice, 50cdf0e10cSrcweir const IDXRenderModuleSharedPtr& rRenderModule, 51cdf0e10cSrcweir const ::canvas::ISurfaceProxyManagerSharedPtr& rSurfaceProxy, 52cdf0e10cSrcweir bool bShowSpriteBounds ) : 53cdf0e10cSrcweir mpSpriteCanvas( rRefDevice ), 54cdf0e10cSrcweir mpSurface() 55cdf0e10cSrcweir { 56cdf0e10cSrcweir ENSURE_OR_THROW( rRefDevice.get(), 57cdf0e10cSrcweir "CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" ); 58cdf0e10cSrcweir 59cdf0e10cSrcweir mpSurface.reset( 60cdf0e10cSrcweir new DXSurfaceBitmap( 61cdf0e10cSrcweir ::basegfx::B2IVector( 62cdf0e10cSrcweir ::canvas::tools::roundUp( rSpriteSize.Width ), 63cdf0e10cSrcweir ::canvas::tools::roundUp( rSpriteSize.Height )), 64cdf0e10cSrcweir rSurfaceProxy, 65cdf0e10cSrcweir rRenderModule, 66cdf0e10cSrcweir true)); 67cdf0e10cSrcweir 68cdf0e10cSrcweir maCanvasHelper.setDevice( *rRefDevice.get() ); 69cdf0e10cSrcweir maCanvasHelper.setTarget( mpSurface ); 70cdf0e10cSrcweir 71cdf0e10cSrcweir maSpriteHelper.init( rSpriteSize, 72cdf0e10cSrcweir rRefDevice, 73cdf0e10cSrcweir rRenderModule, 74cdf0e10cSrcweir mpSurface, 75cdf0e10cSrcweir bShowSpriteBounds ); 76cdf0e10cSrcweir 77cdf0e10cSrcweir // clear sprite to 100% transparent 78cdf0e10cSrcweir maCanvasHelper.clear(); 79cdf0e10cSrcweir } 80cdf0e10cSrcweir 81cdf0e10cSrcweir void SAL_CALL CanvasCustomSprite::disposing() 82cdf0e10cSrcweir { 83cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 84cdf0e10cSrcweir 85cdf0e10cSrcweir mpSurface.reset(); 86cdf0e10cSrcweir mpSpriteCanvas.clear(); 87cdf0e10cSrcweir 88cdf0e10cSrcweir // forward to parent 89cdf0e10cSrcweir CanvasCustomSpriteBaseT::disposing(); 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir #define IMPLEMENTATION_NAME "DXCanvas.CanvasCustomSprite" 93cdf0e10cSrcweir #define SERVICE_NAME "com.sun.star.rendering.CanvasCustomSprite" 94cdf0e10cSrcweir 95cdf0e10cSrcweir ::rtl::OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException ) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir sal_Bool SAL_CALL CanvasCustomSprite::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException ) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) ); 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames() throw( uno::RuntimeException ) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aRet(1); 108cdf0e10cSrcweir aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); 109cdf0e10cSrcweir 110cdf0e10cSrcweir return aRet; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir void CanvasCustomSprite::redraw() const 114cdf0e10cSrcweir { 115cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 116cdf0e10cSrcweir 117cdf0e10cSrcweir maSpriteHelper.redraw( mbSurfaceDirty ); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir } 120