use insert function instead of for loop
[LibreOffice.git] / include / drawinglayer / processor2d / SDPRProcessor2dTools.hxx
blob0dd81f594fa5d978df084b9add1656af47c96888
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 <sal/config.h>
24 namespace drawinglayer::primitive2d
26 class FillGraphicPrimitive2D;
29 namespace drawinglayer::geometry
31 class ViewInformation2D;
34 namespace basegfx
36 class B2DRange;
39 class BitmapEx;
41 namespace drawinglayer::processor2d
43 /** helper to process FillGraphicPrimitive2D:
45 In places that want to implement direct rendering of this primitive
46 e.g. in SDPRs all impls would need to handle the FillGraphicAttribute
47 settings and the type of Graphic. Unify this by this helper in one place
48 since this may get complicated (many cases to cover).
49 It will create and return a BitmapEx when direct tiled rendering is
50 preferable and suggested.
51 Of course every impl may still do what it wants, this is just to make
52 implementations easier.
54 @param rFillGraphicPrimitive2D
55 The primitive to work on
57 @param rViewInformation2D
58 The ViewInformation to work with (from the processor)
60 @param rTarget
61 The prepared PixelData to use for tiled rendering. If this
62 is empty on return this means to evtl. use the decompose.
63 Please hand in an empty one to make this work.
65 @param rFillUnitRange
66 This is a modifiable copy of FillGraphicAttribute.getGraphicRange(). We
67 need a modifiable one since params since OffsetX/OffsetY in
68 FillGraphicAttribute may require to change/adapt this if used
70 @param fBigDiscreteArea
71 Defines starting with which number of square pixels a target is seen
72 to be painted 'big'
74 @return
75 false: rendering is not needed (invalid, outside, ...), done
76 true: rendering is needed
77 -> if rTarget is filled, use for tiled rendering
78 -> if not, use fallback (primitive decomposition)
80 For the various reasons/things that get checked/tested/done, please
81 see the implementation
83 bool prepareBitmapForDirectRender(
84 const drawinglayer::primitive2d::FillGraphicPrimitive2D& rFillGraphicPrimitive2D,
85 const drawinglayer::geometry::ViewInformation2D& rViewInformation2D, BitmapEx& rTarget,
86 basegfx::B2DRange& rFillUnitRange, double fBigDiscreteArea = 300.0 * 300.0);
88 /** helper to react/process if OffsetX/OffsetY of the FillGraphicAttribute is used.
90 This is old but hard to remove stuff that allows hor/ver offset when
91 tiled fill is used. To solve that, create pixel data that doubles
92 resp. in width/height and copies the off-setted version of the bitmap
93 information to the extra space, so rendering does not need to do that.
95 Since this doubles the geometry, an adaption of the used fill range
96 (here rFillUnitRange in unit coordinates) also needs to be adapted,
97 refer to usage.
99 void takeCareOfOffsetXY(
100 const drawinglayer::primitive2d::FillGraphicPrimitive2D& rFillGraphicPrimitive2D,
101 BitmapEx& rTarget, basegfx::B2DRange& rFillUnitRange);
103 /** helper to calculate a discrete visible range based on a given logic range
104 and a current ViewInformation2D. This is used for pixel renderers.
105 It is handy to check for visibility of a primitive, but also to continue
106 working with just the visible discrete part.
108 The result rDiscreteVisibleRange will be reset if rContentRange is empty.
109 Else it will be calculated. If ViewInformation2D does have a valid
110 Viewport (getDiscreteViewport is not empty), it will also be clipped
111 against that to calculate the visible part.
113 @param rDiscreteVisibleRange
114 The logic range in view-coordinates (will be transformed by
115 getObjectToViewTransformation)
117 @param rContentRange
118 The logic input range in view-coordinates (will be transformed by
119 getObjectToViewTransformation)
121 @param rViewInformation2D
122 The ViewInformation to work with (from the processor)
124 void calculateDiscreteVisibleRange(
125 basegfx::B2DRange& rDiscreteVisibleRange, const basegfx::B2DRange& rContentRange,
126 const drawinglayer::geometry::ViewInformation2D& rViewInformation2D);
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */