| 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 <sal/config.h> |
| 23 |
|
| 24 |
namespace drawinglayer::primitive2d |
| 25 |
{ |
| 26 |
class FillGraphicPrimitive2D; |
| 27 |
} |
| 28 |
|
| 29 |
namespace drawinglayer::geometry |
| 30 |
{ |
| 31 |
class ViewInformation2D; |
| 32 |
} |
| 33 |
|
| 34 |
namespace basegfx |
| 35 |
{ |
| 36 |
class B2DRange; |
| 37 |
} |
| 38 |
|
| 39 |
class Bitmap; |
| 40 |
|
| 41 |
namespace drawinglayer::processor2d |
| 42 |
{ |
| 43 |
/** helper to process FillGraphicPrimitive2D: |
| 44 |
|
| 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 Bitmap 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. |
| 53 |
|
| 54 |
@param rFillGraphicPrimitive2D |
| 55 |
The primitive to work on |
| 56 |
|
| 57 |
@param rViewInformation2D |
| 58 |
The ViewInformation to work with (from the processor) |
| 59 |
|
| 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. |
| 64 |
|
| 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 |
| 69 |
|
| 70 |
@param fBigDiscreteArea |
| 71 |
Defines starting with which number of square pixels a target is seen |
| 72 |
to be painted 'big' |
| 73 |
|
| 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) |
| 79 |
|
| 80 |
For the various reasons/things that get checked/tested/done, please |
| 81 |
see the implementation |
| 82 |
*/ |
| 83 |
bool prepareBitmapForDirectRender( |
| 84 |
const drawinglayer::primitive2d::FillGraphicPrimitive2D& rFillGraphicPrimitive2D, |
| 85 |
const drawinglayer::geometry::ViewInformation2D& rViewInformation2D, Bitmap& rTarget, |
| 86 |
basegfx::B2DRange& rFillUnitRange, double fBigDiscreteArea = 300.0 * 300.0); |
| 87 |
|
| 88 |
/** helper to react/process if OffsetX/OffsetY of the FillGraphicAttribute is used. |
| 89 |
|
| 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. |
| 94 |
|
| 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. |
| 98 |
*/ |
| 99 |
void takeCareOfOffsetXY( |
| 100 |
const drawinglayer::primitive2d::FillGraphicPrimitive2D& rFillGraphicPrimitive2D, |
| 101 |
Bitmap& rTarget, basegfx::B2DRange& rFillUnitRange); |
| 102 |
|
| 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. |
| 107 |
|
| 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. |
| 112 |
|
| 113 |
@param rDiscreteVisibleRange |
| 114 |
The logic range in view-coordinates (will be transformed by |
| 115 |
getObjectToViewTransformation) |
| 116 |
|
| 117 |
@param rContentRange |
| 118 |
The logic input range in view-coordinates (will be transformed by |
| 119 |
getObjectToViewTransformation) |
| 120 |
|
| 121 |
@param rViewInformation2D |
| 122 |
The ViewInformation to work with (from the processor) |
| 123 |
*/ |
| 124 |
void calculateDiscreteVisibleRange( |
| 125 |
basegfx::B2DRange& rDiscreteVisibleRange, const basegfx::B2DRange& rContentRange, |
| 126 |
const drawinglayer::geometry::ViewInformation2D& rViewInformation2D); |
| 127 |
} |
| 128 |
|
| 129 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |