1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <drawinglayer/drawinglayerdllapi.h>
23 #include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
24 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
26 namespace drawinglayer::geometry
28 class ViewInformation2D
;
31 namespace drawinglayer::primitive2d
33 /** BufferedDecompositionPrimitive2D class
35 Baseclass for all C++ implementations of css::graphic::XPrimitive2D
36 which want to buffer the decomposition result
38 Buffering the decomposition is the most-used buffering and is thus used my most
39 primitive implementations which support a decomposition as base class.
41 The buffering is done by holding the last decomposition in the local parameter
42 maBuffered2DDecomposition. The default implementation of get2DDecomposition checks
43 if maBuffered2DDecomposition is empty. If yes, it uses create2DDecomposition
44 to create the content. In all cases, maBuffered2DDecomposition is returned.
46 For view-dependent primitives derived from Primitive2DBufferDecomposition more needs
47 to be done when the decomposition depends on parts of the parameter ViewInformation2D.
48 This defines a standard method for processing these:
50 Implement a view-dependent get2DDecomposition doing the following steps:
51 (a) Locally extract needed parameters from ViewInformation2D to new, local parameters
52 (this may be a complete local copy of ViewInformation2D)
53 (b) If a buffered decomposition exists, ckeck if one of the new local parameters
54 differs from the corresponding locally remembered (as member) ones. If yes,
55 clear maBuffered2DDecomposition
56 (d) call baseclass::get2DDecomposition which will use create2DDecomposition
57 to fill maBuffered2DDecomposition if it's empty
58 (e) copy the new local parameters to the corresponding locally remembered ones
59 to identify if a new decomposition is needed at the next call
60 (f) return maBuffered2DDecomposition
62 class DRAWINGLAYERCORE_DLLPUBLIC BufferedDecompositionPrimitive2D
: public BasePrimitive2D
65 /// a sequence used for buffering the last create2DDecomposition() result
66 Primitive2DContainer maBuffered2DDecomposition
;
68 /// When a shadow wraps a list of primitives, this primitive wants to influence the transparency
70 sal_uInt16 mnTransparenceForShadow
= 0;
73 /** access methods to maBuffered2DDecomposition. The usage of this methods may allow
74 later thread-safe stuff to be added if needed. Only to be used by getDecomposition()
75 implementations for buffering the last decomposition.
77 const Primitive2DContainer
& getBuffered2DDecomposition() const
79 return maBuffered2DDecomposition
;
81 void setBuffered2DDecomposition(Primitive2DContainer
&& rNew
)
83 maBuffered2DDecomposition
= std::move(rNew
);
86 /** method which is to be used to implement the local decomposition of a 2D primitive. */
88 create2DDecomposition(Primitive2DContainer
& rContainer
,
89 const geometry::ViewInformation2D
& rViewInformation
) const = 0;
92 // constructor/destructor
93 BufferedDecompositionPrimitive2D();
95 /** The getDecomposition default implementation will on demand use create2DDecomposition() if
96 maBuffered2DDecomposition is empty. It will set maBuffered2DDecomposition to this obtained decomposition
97 to buffer it. If the decomposition is also ViewInformation2D-dependent, this method needs to be
98 overridden and the ViewInformation2D for the last decomposition need to be remembered, too, and
99 be used in the next call to decide if the buffered decomposition may be reused or not.
102 get2DDecomposition(Primitive2DDecompositionVisitor
& rVisitor
,
103 const geometry::ViewInformation2D
& rViewInformation
) const override
;
105 void setTransparenceForShadow(sal_uInt16 nTransparenceForShadow
)
107 mnTransparenceForShadow
= nTransparenceForShadow
;
110 sal_uInt16
getTransparenceForShadow() const { return mnTransparenceForShadow
; }
113 } // end of namespace drawinglayer::primitive2d
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */