Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / cppcanvas / source / mtfrenderer / cachedprimitivebase.hxx
blob5fc7e0aeb0b31823a3ece5f2a1fa7ee6e8c202b3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_CACHEDPRIMITIVEBASE_HXX
21 #define INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_CACHEDPRIMITIVEBASE_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <com/sun/star/rendering/XCanvas.hpp>
26 #include <cppcanvas/canvas.hxx>
28 #include "action.hxx"
30 namespace basegfx { class B2DHomMatrix; }
33 /* Definition of internal::CachedPrimitiveBase class */
35 namespace cppcanvas
37 namespace internal
39 /** Base class providing cached re-rendering, if XCanvas
40 returns XCachedPrimitive
42 Derive from this class and implement private render()
43 method to perform the actual primitive rendering. Return
44 cached primitive into given reference. Next time this
45 class' public render() method gets called, the cached
46 representation is taken.
48 class CachedPrimitiveBase : public Action
50 public:
51 /** Constructor
53 @param rCanvas
54 Canvas on which this primitive is to appear
56 @param bOnlyRedrawWithSameTransform
57 When true, this class only reuses the cached
58 primitive, if the overall transformation stays the
59 same. Otherwise, repaints are always performed via the
60 cached primitive.
62 CachedPrimitiveBase( const CanvasSharedPtr& rCanvas,
63 bool bOnlyRedrawWithSameTransform );
64 virtual ~CachedPrimitiveBase() {}
66 CachedPrimitiveBase(const CachedPrimitiveBase&) = delete;
67 const CachedPrimitiveBase& operator=(const CachedPrimitiveBase&) = delete;
69 virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const override;
71 protected:
72 using Action::render;
74 private:
75 virtual bool renderPrimitive( css::uno::Reference< css::rendering::XCachedPrimitive >& rCachedPrimitive,
76 const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
78 CanvasSharedPtr mpCanvas;
79 mutable css::uno::Reference< css::rendering::XCachedPrimitive > mxCachedPrimitive;
80 mutable ::basegfx::B2DHomMatrix maLastTransformation;
81 const bool mbOnlyRedrawWithSameTransform;
86 #endif // INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_CACHEDPRIMITIVEBASE_HXX
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */