Line data Source code
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 :
21 : #include <canvas/debug.hxx>
22 : #include <canvas/base/cachedprimitivebase.hxx>
23 :
24 : #include <com/sun/star/rendering/RepaintResult.hpp>
25 : #include <cppuhelper/supportsservice.hxx>
26 :
27 : #include <basegfx/matrix/b2dhommatrix.hxx>
28 : #include <basegfx/tools/canvastools.hxx>
29 :
30 : using namespace ::com::sun::star;
31 :
32 : namespace canvas
33 : {
34 0 : CachedPrimitiveBase::CachedPrimitiveBase( const rendering::ViewState& rUsedViewState,
35 : const uno::Reference< rendering::XCanvas >& rTarget,
36 : bool bFailForChangedViewTransform ) :
37 : CachedPrimitiveBase_Base( m_aMutex ),
38 : maUsedViewState( rUsedViewState ),
39 : mxTarget( rTarget ),
40 0 : mbFailForChangedViewTransform( bFailForChangedViewTransform )
41 : {
42 0 : }
43 :
44 0 : CachedPrimitiveBase::~CachedPrimitiveBase()
45 : {
46 0 : }
47 :
48 0 : void SAL_CALL CachedPrimitiveBase::disposing()
49 : {
50 0 : ::osl::MutexGuard aGuard( m_aMutex );
51 :
52 0 : maUsedViewState.Clip.clear();
53 0 : mxTarget.clear();
54 0 : }
55 :
56 0 : sal_Int8 SAL_CALL CachedPrimitiveBase::redraw( const rendering::ViewState& aState ) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
57 : {
58 0 : ::basegfx::B2DHomMatrix aUsedTransformation;
59 0 : ::basegfx::B2DHomMatrix aNewTransformation;
60 :
61 : ::basegfx::unotools::homMatrixFromAffineMatrix( aUsedTransformation,
62 0 : maUsedViewState.AffineTransform );
63 : ::basegfx::unotools::homMatrixFromAffineMatrix( aNewTransformation,
64 0 : aState.AffineTransform );
65 :
66 0 : const bool bSameViewTransforms( aUsedTransformation == aNewTransformation );
67 :
68 0 : if( mbFailForChangedViewTransform &&
69 0 : !bSameViewTransforms )
70 : {
71 : // differing transformations, don't try to draft the
72 : // output, just plain fail here.
73 0 : return rendering::RepaintResult::FAILED;
74 : }
75 :
76 : return doRedraw( aState,
77 : maUsedViewState,
78 : mxTarget,
79 0 : bSameViewTransforms );
80 : }
81 :
82 0 : OUString SAL_CALL CachedPrimitiveBase::getImplementationName( ) throw (uno::RuntimeException, std::exception)
83 : {
84 0 : return OUString("canvas::CachedPrimitiveBase");
85 : }
86 :
87 0 : sal_Bool SAL_CALL CachedPrimitiveBase::supportsService( const OUString& ServiceName ) throw (uno::RuntimeException, std::exception)
88 : {
89 0 : return cppu::supportsService(this, ServiceName);
90 : }
91 :
92 0 : uno::Sequence< OUString > SAL_CALL CachedPrimitiveBase::getSupportedServiceNames( ) throw (uno::RuntimeException, std::exception)
93 : {
94 0 : uno::Sequence< OUString > aRet(1);
95 0 : aRet[0] = "com.sun.star.rendering.CachedBitmap";
96 :
97 0 : return aRet;
98 : }
99 : }
100 :
101 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|