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 ) :
37 maUsedViewState(std::move( aUsedViewState )),
38 mxTarget(std::move( xTarget ))
39 {
40 }
41
42 CachedPrimitiveBase::~CachedPrimitiveBase()
43 {
44 }
45
46 void CachedPrimitiveBase::disposing(std::unique_lock<std::mutex>& /*rGuard*/)
47 {
48 maUsedViewState.Clip.clear();
49 mxTarget.clear();
50 }
51
52 sal_Int8 SAL_CALL CachedPrimitiveBase::redraw( const rendering::ViewState& aState )
53 {
54 ::basegfx::B2DHomMatrix aUsedTransformation;
55 ::basegfx::B2DHomMatrix aNewTransformation;
56
57 ::basegfx::unotools::homMatrixFromAffineMatrix( aUsedTransformation,
58 maUsedViewState.AffineTransform );
59 ::basegfx::unotools::homMatrixFromAffineMatrix( aNewTransformation,
60 aState.AffineTransform );
61
62 const bool bSameViewTransforms( aUsedTransformation == aNewTransformation );
63
64 if( !bSameViewTransforms )
65 {
66 // differing transformations, don't try to draft the
67 // output, just plain fail here.
68 return rendering::RepaintResult::FAILED;
69 }
70
71 return doRedraw( aState,
72 maUsedViewState,
73 mxTarget,
74 bSameViewTransforms );
75 }
76
77 OUString SAL_CALL CachedPrimitiveBase::getImplementationName( )
78 {
79 return "canvas::CachedPrimitiveBase";
80 }
81
82 sal_Bool SAL_CALL CachedPrimitiveBase::supportsService( const OUString& ServiceName )
83 {
85 }
86
87 uno::Sequence< OUString > SAL_CALL CachedPrimitiveBase::getSupportedServiceNames( )
88 {
89 return { "com.sun.star.rendering.CachedBitmap" };
90 }
91}
92
93/* 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
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool
signed char sal_Int8