LibreOffice Module canvas (master) 1
cachedprimitivebase.cxx
Go to the documentation of this file.
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
24#include <com/sun/star/rendering/RepaintResult.hpp>
26
28#include <utility>
29
30
31using namespace ::com::sun::star;
32
33namespace canvas
34{
35 CachedPrimitiveBase::CachedPrimitiveBase( rendering::ViewState aUsedViewState,
36 uno::Reference< rendering::XCanvas > xTarget ) :
38 maUsedViewState(std::move( aUsedViewState )),
39 mxTarget(std::move( xTarget ))
40 {
41 }
42
43 CachedPrimitiveBase::~CachedPrimitiveBase()
44 {
45 }
46
47 void SAL_CALL CachedPrimitiveBase::disposing()
48 {
49 ::osl::MutexGuard aGuard( m_aMutex );
50
51 maUsedViewState.Clip.clear();
52 mxTarget.clear();
53 }
54
55 sal_Int8 SAL_CALL CachedPrimitiveBase::redraw( const rendering::ViewState& aState )
56 {
57 ::basegfx::B2DHomMatrix aUsedTransformation;
58 ::basegfx::B2DHomMatrix aNewTransformation;
59
60 ::basegfx::unotools::homMatrixFromAffineMatrix( aUsedTransformation,
61 maUsedViewState.AffineTransform );
62 ::basegfx::unotools::homMatrixFromAffineMatrix( aNewTransformation,
63 aState.AffineTransform );
64
65 const bool bSameViewTransforms( aUsedTransformation == aNewTransformation );
66
67 if( !bSameViewTransforms )
68 {
69 // differing transformations, don't try to draft the
70 // output, just plain fail here.
71 return rendering::RepaintResult::FAILED;
72 }
73
74 return doRedraw( aState,
75 maUsedViewState,
76 mxTarget,
77 bSameViewTransforms );
78 }
79
80 OUString SAL_CALL CachedPrimitiveBase::getImplementationName( )
81 {
82 return "canvas::CachedPrimitiveBase";
83 }
84
85 sal_Bool SAL_CALL CachedPrimitiveBase::supportsService( const OUString& ServiceName )
86 {
88 }
89
90 uno::Sequence< OUString > SAL_CALL CachedPrimitiveBase::getSupportedServiceNames( )
91 {
92 return { "com.sun.star.rendering.CachedBitmap" };
93 }
94}
95
96/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
CachedPrimitiveBase(css::rendering::ViewState rUsedViewState, css::uno::Reference< css::rendering::XCanvas > xTarget)
Create an XCachedPrimitive for given target canvas.
Reference< XInterface > xTarget
std::mutex m_aMutex
cppu::WeakComponentImplHelper< css::rendering::XCachedPrimitive, css::lang::XServiceInfo > CachedPrimitiveBase_Base
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool
signed char sal_Int8