Debian Codegraph @

cppcanvas/source/mtfrenderer/cachedprimitivebase.hxx

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