1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #include <sal/config.h> 21 22 #include <basegfx/matrix/b2dhommatrix.hxx> 23 #include <basegfx/utils/canvastools.hxx> 24 #include <com/sun/star/rendering/RepaintResult.hpp> 25 #include <cppuhelper/supportsservice.hxx> 26 27 #include <base/cachedprimitivebase.hxx> 28 29 30 using namespace ::com::sun::star; 31 32 namespace canvas 33 { CachedPrimitiveBase(const rendering::ViewState & rUsedViewState,const uno::Reference<rendering::XCanvas> & rTarget)34 CachedPrimitiveBase::CachedPrimitiveBase( const rendering::ViewState& rUsedViewState, 35 const uno::Reference< rendering::XCanvas >& rTarget ) : 36 CachedPrimitiveBase_Base( m_aMutex ), 37 maUsedViewState( rUsedViewState ), 38 mxTarget( rTarget ) 39 { 40 } 41 ~CachedPrimitiveBase()42 CachedPrimitiveBase::~CachedPrimitiveBase() 43 { 44 } 45 disposing()46 void SAL_CALL CachedPrimitiveBase::disposing() 47 { 48 ::osl::MutexGuard aGuard( m_aMutex ); 49 50 maUsedViewState.Clip.clear(); 51 mxTarget.clear(); 52 } 53 redraw(const rendering::ViewState & aState)54 sal_Int8 SAL_CALL CachedPrimitiveBase::redraw( const rendering::ViewState& aState ) 55 { 56 ::basegfx::B2DHomMatrix aUsedTransformation; 57 ::basegfx::B2DHomMatrix aNewTransformation; 58 59 ::basegfx::unotools::homMatrixFromAffineMatrix( aUsedTransformation, 60 maUsedViewState.AffineTransform ); 61 ::basegfx::unotools::homMatrixFromAffineMatrix( aNewTransformation, 62 aState.AffineTransform ); 63 64 const bool bSameViewTransforms( aUsedTransformation == aNewTransformation ); 65 66 if( !bSameViewTransforms ) 67 { 68 // differing transformations, don't try to draft the 69 // output, just plain fail here. 70 return rendering::RepaintResult::FAILED; 71 } 72 73 return doRedraw( aState, 74 maUsedViewState, 75 mxTarget, 76 bSameViewTransforms ); 77 } 78 getImplementationName()79 OUString SAL_CALL CachedPrimitiveBase::getImplementationName( ) 80 { 81 return "canvas::CachedPrimitiveBase"; 82 } 83 supportsService(const OUString & ServiceName)84 sal_Bool SAL_CALL CachedPrimitiveBase::supportsService( const OUString& ServiceName ) 85 { 86 return cppu::supportsService(this, ServiceName); 87 } 88 getSupportedServiceNames()89 uno::Sequence< OUString > SAL_CALL CachedPrimitiveBase::getSupportedServiceNames( ) 90 { 91 return { "com.sun.star.rendering.CachedBitmap" }; 92 } 93 } 94 95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 96