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