Bump version to 21.06.18.1
[LibreOffice.git] / cppcanvas / source / mtfrenderer / cachedprimitivebase.hxx
blob2f32d887b51596f42e6b7d8bb197097db90857ea
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 #pragma once
22 #include <com/sun/star/uno/Reference.hxx>
23 #include <com/sun/star/rendering/XCachedPrimitive.hpp>
25 #include <basegfx/matrix/b2dhommatrix.hxx>
26 #include <cppcanvas/canvas.hxx>
28 #include <action.hxx>
30 namespace basegfx { class B2DHomMatrix; }
33 /* Definition of internal::CachedPrimitiveBase class */
35 namespace cppcanvas::internal
37 /** Base class providing cached re-rendering, if XCanvas
38 returns XCachedPrimitive
40 Derive from this class and implement private render()
41 method to perform the actual primitive rendering. Return
42 cached primitive into given reference. Next time this
43 class' public render() method gets called, the cached
44 representation is taken.
46 class CachedPrimitiveBase : public Action
48 public:
49 /** Constructor
51 @param rCanvas
52 Canvas on which this primitive is to appear
54 @param bOnlyRedrawWithSameTransform
55 When true, this class only reuses the cached
56 primitive, if the overall transformation stays the
57 same. Otherwise, repaints are always performed via the
58 cached primitive.
60 CachedPrimitiveBase( const CanvasSharedPtr& rCanvas,
61 bool bOnlyRedrawWithSameTransform );
63 CachedPrimitiveBase(const CachedPrimitiveBase&) = delete;
64 const CachedPrimitiveBase& operator=(const CachedPrimitiveBase&) = delete;
66 virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const override;
68 protected:
69 using Action::render;
71 private:
72 virtual bool renderPrimitive( css::uno::Reference< css::rendering::XCachedPrimitive >& rCachedPrimitive,
73 const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
75 CanvasSharedPtr mpCanvas;
76 mutable css::uno::Reference< css::rendering::XCachedPrimitive > mxCachedPrimitive;
77 mutable ::basegfx::B2DHomMatrix maLastTransformation;
78 const bool mbOnlyRedrawWithSameTransform;
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */