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