diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-03-20 12:09:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-03-21 10:30:07 +0100 |
commit | ad38105f45b517e09bf65a76e66517ece41fb62e (patch) | |
tree | c22546143d65369aa50fabba41112b84e50809a4 /drawinglayer/inc | |
parent | c663d0bcc93b278f50c8f6802928a7a6154207f2 (diff) |
move headers inside modules
Change-Id: Iad5c414861eb807e6246b8a988b94d66ef5f687d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90776
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'drawinglayer/inc')
22 files changed, 2332 insertions, 10 deletions
diff --git a/drawinglayer/inc/pch/precompiled_drawinglayer.hxx b/drawinglayer/inc/pch/precompiled_drawinglayer.hxx index c07ffd345150..b5fb42d97e6e 100644 --- a/drawinglayer/inc/pch/precompiled_drawinglayer.hxx +++ b/drawinglayer/inc/pch/precompiled_drawinglayer.hxx @@ -13,7 +13,7 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2020-01-22 15:57:44 using: + Generated on 2020-03-20 13:37:39 using: ./bin/update_pch drawinglayer drawinglayer --cutoff=4 --exclude:system --exclude:module --exclude:local If after updating build fails, use the following command to locate conflicting headers: @@ -57,6 +57,7 @@ #include <sal/detail/log.h> #include <sal/log.hxx> #include <sal/types.h> +#include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> #include <vcl/canvastools.hxx> #include <vcl/dllapi.h> @@ -143,10 +144,8 @@ #include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> -#include <drawinglayer/primitive2d/epsprimitive2d.hxx> #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx> #include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx> -#include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx> #include <drawinglayer/primitive2d/groupprimitive2d.hxx> #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx> #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx> @@ -155,10 +154,8 @@ #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx> #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx> -#include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> -#include <drawinglayer/primitive2d/primitivetools2d.hxx> #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx> #include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx> #include <drawinglayer/primitive2d/textlayoutdevice.hxx> @@ -168,18 +165,13 @@ #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> #include <drawinglayer/primitive3d/baseprimitive3d.hxx> #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx> -#include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx> #include <drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx> #include <drawinglayer/primitive3d/polygonprimitive3d.hxx> #include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx> -#include <drawinglayer/primitive3d/sdrdecompositiontools3d.hxx> #include <drawinglayer/primitive3d/sdrextrudelathetools3d.hxx> #include <drawinglayer/primitive3d/sdrprimitive3d.hxx> -#include <drawinglayer/primitive3d/textureprimitive3d.hxx> #include <drawinglayer/primitive3d/transformprimitive3d.hxx> #include <drawinglayer/processor2d/baseprocessor2d.hxx> -#include <drawinglayer/processor3d/baseprocessor3d.hxx> -#include <drawinglayer/texture/texture.hxx> #endif // PCH_LEVEL >= 4 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/cropprimitive2d.hxx b/drawinglayer/inc/primitive2d/cropprimitive2d.hxx new file mode 100644 index 000000000000..ba427eb6fba6 --- /dev/null +++ b/drawinglayer/inc/primitive2d/cropprimitive2d.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + + +namespace drawinglayer +{ + namespace primitive2d + { + /** CropPrimitive2D class + + Caution: Due to old constraints (old core definitions) the + crop distances describe how the uncropped content is defined + relative to the current object size. This means that maTransformation + describes the current object size (the part of the object visible + with the crop applied). To get the original size and orientation + of the uncropped content it is necessary to calc back from the + current situation (maTransformation) using the crop values + to get to the uncropped original content. + + Thus a transformation has to be calculated which will be applied + to the already existing content to get it to the uncropped state + and then this is masked with the current state (mask polygon + created from unit polygon and maTransformation). + + At least in this primitive the units of the crop values are + already in the local coordinate system; in the core these distances + are defined relative to the object content size (PrefMapMode + and PrefSize of the content)... + + Of course this is a primitive, so feel free to just ignore all that + stuff and use the automatically generated decomposition. Sigh. + */ + class CropPrimitive2D final : public GroupPrimitive2D + { + private: + // the transformation already applied to the child geometry + basegfx::B2DHomMatrix maTransformation; + + // the crop offsets relative to the range of the unrotated content + double mfCropLeft; + double mfCropTop; + double mfCropRight; + double mfCropBottom; + + public: + /// constructor + CropPrimitive2D( + const Primitive2DContainer& rChildren, + const basegfx::B2DHomMatrix& rTransformation, + double fCropLeft, + double fCropTop, + double fCropRight, + double fCropBottom); + + /// data read access + const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } + double getCropLeft() const { return mfCropLeft; } + double getCropTop() const { return mfCropTop; } + double getCropRight() const { return mfCropRight; } + double getCropBottom() const { return mfCropBottom; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// local decomposition + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/epsprimitive2d.hxx b/drawinglayer/inc/primitive2d/epsprimitive2d.hxx new file mode 100644 index 000000000000..eb4a38678af6 --- /dev/null +++ b/drawinglayer/inc/primitive2d/epsprimitive2d.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <vcl/gfxlink.hxx> +#include <vcl/gdimtf.hxx> + +namespace drawinglayer +{ + namespace primitive2d + { + /** EpsPrimitive2D class */ + class EpsPrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// the geometry definition + basegfx::B2DHomMatrix maEpsTransform; + + /// the Eps content definition + GfxLink maGfxLink; + + /// the replacement content definition + GDIMetaFile maMetaFile; + + /// create local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + EpsPrimitive2D( + const basegfx::B2DHomMatrix& rEpsTransform, + const GfxLink& rGfxLink, + const GDIMetaFile& rMetaFile); + + /// data read access + const basegfx::B2DHomMatrix& getEpsTransform() const { return maEpsTransform; } + const GfxLink& getGfxLink() const { return maGfxLink; } + const GDIMetaFile& getMetaFile() const { return maMetaFile; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get B2Drange + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/fillhatchprimitive2d.hxx b/drawinglayer/inc/primitive2d/fillhatchprimitive2d.hxx new file mode 100644 index 000000000000..4b741cef44d6 --- /dev/null +++ b/drawinglayer/inc/primitive2d/fillhatchprimitive2d.hxx @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <drawinglayer/primitive2d/primitivetools2d.hxx> +#include <drawinglayer/attribute/fillhatchattribute.hxx> +#include <basegfx/color/bcolor.hxx> + + +// FillHatchPrimitive2D class + +namespace drawinglayer +{ + namespace primitive2d + { + /** FillHatchPrimitive2D class + + This class defines a hatch filling for a rectangular area. The + Range is defined by the Transformation, the hatch by the FillHatchAttribute. + If the background is to be filled, a flag in FillHatchAttribute is set and + the BColor defines the background color. + + #i120230# This primitive is now evtl. metric dependent due to the value + MinimalDiscreteDistance in the FillHatchAttribute if the value is not zero. + This is used for a more appealing, VCL-like visualisation by not letting the + distances get too small between lines. + + The decomposition will deliver the hatch lines. + */ + class FillHatchPrimitive2D final : public DiscreteMetricDependentPrimitive2D + { + private: + /// the geometrically visible area + basegfx::B2DRange maOutputRange; + + /// the area the gradient definition is based on + /// in the simplest case identical to OutputRange + basegfx::B2DRange maDefinitionRange; + + /// the hatch definition + attribute::FillHatchAttribute maFillHatch; + + /// hatch background color (if used) + basegfx::BColor maBColor; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructors. The one without definition range will use output range as definition range + FillHatchPrimitive2D( + const basegfx::B2DRange& rOutputRange, + const basegfx::BColor& rBColor, + const attribute::FillHatchAttribute& rFillHatch); + FillHatchPrimitive2D( + const basegfx::B2DRange& rOutputRange, + const basegfx::B2DRange& rDefinitionRange, + const basegfx::BColor& rBColor, + const attribute::FillHatchAttribute& rFillHatch); + + /// data read access + const basegfx::B2DRange& getOutputRange() const { return maOutputRange; } + const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; } + const attribute::FillHatchAttribute& getFillHatch() const { return maFillHatch; } + const basegfx::BColor& getBColor() const { return maBColor; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// Override standard getDecomposition to be view-dependent here + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/graphicprimitivehelper2d.hxx b/drawinglayer/inc/primitive2d/graphicprimitivehelper2d.hxx new file mode 100644 index 000000000000..cd1cc99ebf51 --- /dev/null +++ b/drawinglayer/inc/primitive2d/graphicprimitivehelper2d.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <vcl/GraphicObject.hxx> + + +// predefines + +class Graphic; + + +namespace drawinglayer +{ + namespace primitive2d + { + /** Helper method with supports decomposing a Graphic with all + possible contents to lower level primitives. + + #i121194# Unified to use this helper for FillGraphicPrimitive2D + and GraphicPrimitive2D at the same time. It is able to handle + Bitmaps (with the sub-categories animated bitmap, and SVG), + and Metafiles. + */ + void create2DDecompositionOfGraphic( + Primitive2DContainer& rContainer, + const Graphic& rGraphic, + const basegfx::B2DHomMatrix& rTransform); + + /** Helper to embed given sequence of primitives to evtl. a stack + of ModifiedColorPrimitive2D's to get all the needed modifications + applied. + */ + Primitive2DContainer create2DColorModifierEmbeddingsAsNeeded( + const Primitive2DContainer& rChildren, + GraphicDrawMode aGraphicDrawMode, + double fLuminance = 0.0, // [-1.0 .. 1.0] + double fContrast = 0.0, // [-1.0 .. 1.0] + double fRed = 0.0, // [-1.0 .. 1.0] + double fGreen = 0.0, // [-1.0 .. 1.0] + double fBlue = 0.0, // [-1.0 .. 1.0] + double fGamma = 1.0, // ]0.0 .. 10.0] + bool bInvert = false); + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/pointarrayprimitive2d.hxx b/drawinglayer/inc/primitive2d/pointarrayprimitive2d.hxx new file mode 100644 index 000000000000..e83220df1726 --- /dev/null +++ b/drawinglayer/inc/primitive2d/pointarrayprimitive2d.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/color/bcolor.hxx> + + +// PointArrayPrimitive2D class + +namespace drawinglayer +{ + namespace primitive2d + { + /** PointArrayPrimitive2D class + + This primitive defines single,discrete 'pixels' for the given + positions in the given color. This makes it view-dependent since + the logic size of a 'pixel' depends on the view transformation. + + This is one of the non-decomposable primitives, so a renderer + should process it (Currently it is only used for grid visualisation, + but this may change). + */ + class PointArrayPrimitive2D final : public BasePrimitive2D + { + private: + /// the array of positions + std::vector< basegfx::B2DPoint > maPositions; + + /// the color to use + basegfx::BColor maRGBColor; + + /// #i96669# add simple range buffering for this primitive + basegfx::B2DRange maB2DRange; + + public: + /// constructor + PointArrayPrimitive2D( + const std::vector< basegfx::B2DPoint >& rPositions, + const basegfx::BColor& rRGBColor); + + /// data read access + const std::vector< basegfx::B2DPoint >& getPositions() const { return maPositions; } + const basegfx::BColor& getRGBColor() const { return maRGBColor; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/texteffectprimitive2d.hxx b/drawinglayer/inc/primitive2d/texteffectprimitive2d.hxx new file mode 100644 index 000000000000..a39256453f17 --- /dev/null +++ b/drawinglayer/inc/primitive2d/texteffectprimitive2d.hxx @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + + +namespace drawinglayer +{ + namespace primitive2d + { + /** TextEffectStyle2D definition */ + enum class TextEffectStyle2D + { + ReliefEmbossedDefault, + ReliefEngravedDefault, + ReliefEmbossed, + ReliefEngraved, + Outline + }; + + /** TextEffectPrimitive2D class + + This primitive embeds text primitives (normally, as can be seen can + also be used for any other primitives) which have some TextEffect applied + and create the needed geometry and embedding on decomposition. + */ + class TextEffectPrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// the text (or other) content + Primitive2DContainer maTextContent; + + /// the style to apply, the direction and the rotation center + const basegfx::B2DPoint maRotationCenter; + double mfDirection; + TextEffectStyle2D meTextEffectStyle2D; + + /** the last used object to view transformtion used from getDecomposition + for decide buffering + */ + basegfx::B2DHomMatrix maLastObjectToViewTransformation; + + /// create local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + TextEffectPrimitive2D( + const Primitive2DContainer& rTextContent, + const basegfx::B2DPoint& rRotationCenter, + double fDirection, + TextEffectStyle2D eTextEffectStyle2D); + + /// data read access + const Primitive2DContainer& getTextContent() const { return maTextContent; } + const basegfx::B2DPoint& getRotationCenter() const { return maRotationCenter; } + double getDirection() const { return mfDirection; } + TextEffectStyle2D getTextEffectStyle2D() const { return meTextEffectStyle2D; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /** own get range implementation to solve more effective. Content is by definition displaced + by a fixed discrete unit, thus the contained geometry needs only once be asked for its + own basegfx::B2DRange + */ + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + + /// Override standard getDecomposition to be view-dependent here + virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/textlineprimitive2d.hxx b/drawinglayer/inc/primitive2d/textlineprimitive2d.hxx new file mode 100644 index 000000000000..059c69bd7ca3 --- /dev/null +++ b/drawinglayer/inc/primitive2d/textlineprimitive2d.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolor.hxx> + + +namespace drawinglayer +{ + namespace primitive2d + { + class TextLinePrimitive2D final : public BufferedDecompositionPrimitive2D + { + private: + /// geometric definitions + basegfx::B2DHomMatrix maObjectTransformation; + double mfWidth; + double mfOffset; + double mfHeight; + + /// decoration definitions + TextLine meTextLine; + basegfx::BColor maLineColor; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + TextLinePrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + double fOffset, + double fHeight, + TextLine eTextLine, + const basegfx::BColor& rLineColor); + + /// data read access + const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + double getWidth() const { return mfWidth; } + double getOffset() const { return mfOffset; } + double getHeight() const { return mfHeight; } + TextLine getTextLine() const { return meTextLine; } + const basegfx::BColor& getLineColor() const { return maLineColor; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/textstrikeoutprimitive2d.hxx b/drawinglayer/inc/primitive2d/textstrikeoutprimitive2d.hxx new file mode 100644 index 000000000000..1e1e75f7ced1 --- /dev/null +++ b/drawinglayer/inc/primitive2d/textstrikeoutprimitive2d.hxx @@ -0,0 +1,143 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolor.hxx> +#include <drawinglayer/attribute/fontattribute.hxx> +#include <com/sun/star/lang/Locale.hpp> + + +namespace drawinglayer +{ + namespace primitive2d + { + class BaseTextStrikeoutPrimitive2D : public BufferedDecompositionPrimitive2D + { + private: + /// geometric definitions + basegfx::B2DHomMatrix maObjectTransformation; + double mfWidth; + + /// decoration definitions + basegfx::BColor maFontColor; + + public: + /// constructor + BaseTextStrikeoutPrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + const basegfx::BColor& rFontColor); + + /// data read access + const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + double getWidth() const { return mfWidth; } + const basegfx::BColor& getFontColor() const { return maFontColor; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace primitive2d + { + class TextCharacterStrikeoutPrimitive2D final : public BaseTextStrikeoutPrimitive2D + { + private: + sal_Unicode maStrikeoutChar; + attribute::FontAttribute maFontAttribute; + css::lang::Locale maLocale; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + TextCharacterStrikeoutPrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + const basegfx::BColor& rFontColor, + sal_Unicode aStrikeoutChar, + const attribute::FontAttribute& rFontAttribute, + const css::lang::Locale& rLocale); + + /// data read access + sal_Unicode getStrikeoutChar() const { return maStrikeoutChar; } + const attribute::FontAttribute& getFontAttribute() const { return maFontAttribute; } + const css::lang::Locale& getLocale() const { return maLocale; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace primitive2d + { + class TextGeometryStrikeoutPrimitive2D final : public BaseTextStrikeoutPrimitive2D + { + private: + double mfHeight; + double mfOffset; + TextStrikeout meTextStrikeout; + + /// local decomposition. + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + TextGeometryStrikeoutPrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + const basegfx::BColor& rFontColor, + double fHeight, + double fOffset, + TextStrikeout eTextStrikeout); + + /// data read access + double getHeight() const { return mfHeight; } + double getOffset() const { return mfOffset; } + TextStrikeout getTextStrikeout() const { return meTextStrikeout; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive2d/wallpaperprimitive2d.hxx b/drawinglayer/inc/primitive2d/wallpaperprimitive2d.hxx new file mode 100644 index 000000000000..a8e4b158f30e --- /dev/null +++ b/drawinglayer/inc/primitive2d/wallpaperprimitive2d.hxx @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/primitivetools2d.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/wall.hxx> + + +namespace drawinglayer +{ + namespace primitive2d + { + /** WallpaperBitmapPrimitive2D class + + This is a specialized primitive for the Wallpaper definitions included in + VCL and Metafiles. The extraordinary about the bitmap definition part of + the Wallpaper is that it uses PIXEL size of the given Bitmap and not + the logic and/or discrete size derived by PrefMapMode/PrefSize methods. + To emulate this, a ViewTransformation dependent primitive is needed which + takes over the correct scaling(s). + + Since a specialized primitive is needed anyways, i opted to also add the + layouting which is dependent from WallpaperStyle; thus it does not need + to be handled anywhere else in the future. + */ + class WallpaperBitmapPrimitive2D final : public ViewTransformationDependentPrimitive2D + { + private: + basegfx::B2DRange maObjectRange; + BitmapEx maBitmapEx; + WallpaperStyle meWallpaperStyle; + + /// create local decomposition + virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; + + public: + /// constructor + WallpaperBitmapPrimitive2D( + const basegfx::B2DRange& rObjectRange, + const BitmapEx& rBitmapEx, + WallpaperStyle eWallpaperStyle); + + /// data read access + const basegfx::B2DRange& getLocalObjectRange() const { return maObjectRange; } + const BitmapEx& getBitmapEx() const { return maBitmapEx ; } + WallpaperStyle getWallpaperStyle() const { return meWallpaperStyle; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; + + /// get B2Drange + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive3d/hatchtextureprimitive3d.hxx b/drawinglayer/inc/primitive3d/hatchtextureprimitive3d.hxx new file mode 100644 index 000000000000..1329bf70647f --- /dev/null +++ b/drawinglayer/inc/primitive3d/hatchtextureprimitive3d.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <primitive3d/textureprimitive3d.hxx> +#include <drawinglayer/attribute/fillhatchattribute.hxx> + + +namespace drawinglayer +{ + namespace primitive3d + { + /** HatchTexturePrimitive3D class + + HatchTexturePrimitive3D is derived from GroupPrimitive3D, but implements + a decomposition which is complicated enough for buffering. Since the group + primitive has no default buffering, it is necessary here to add a local + buffering mechanism for the decomposition + */ + class HatchTexturePrimitive3D final : public TexturePrimitive3D + { + /// the hatch definition + attribute::FillHatchAttribute maHatch; + + /// the buffered decomposed hatch + Primitive3DContainer maBuffered3DDecomposition; + + /// helper: local decomposition + Primitive3DContainer impCreate3DDecomposition() const; + + /// local access methods to maBufferedDecomposition + const Primitive3DContainer& getBuffered3DDecomposition() const { return maBuffered3DDecomposition; } + + public: + /// constructor + HatchTexturePrimitive3D( + const attribute::FillHatchAttribute& rHatch, + const Primitive3DContainer& rChildren, + const basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + + /// data read access + const attribute::FillHatchAttribute& getHatch() const { return maHatch; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const override; + + /// local decomposition. + virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive3d/hiddengeometryprimitive3d.hxx b/drawinglayer/inc/primitive3d/hiddengeometryprimitive3d.hxx new file mode 100644 index 000000000000..246abe38a664 --- /dev/null +++ b/drawinglayer/inc/primitive3d/hiddengeometryprimitive3d.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/groupprimitive3d.hxx> + + +namespace drawinglayer +{ + namespace primitive3d + { + // This primitive is used to represent geometry for non-visible objects, + // e.g. a 3D cube without fill attributes. To still be able to use + // primitives for HitTest functionality, the 3d decompositions produce + // an as much as possible simplified fill geometry encapsulated in this + // primitive when there is no fill geometry. Currently, the 3d hit test + // uses only areas, so maybe in a further enhanced version this will change + // to 'if neither filled nor lines' creation criteria. The whole primitive + // decomposes to nothing, so no one not knowing it will be influenced. Only + // helper processors for hit test (and maybe BoundRect extractors) will + // use it and its children subcontent. + class HiddenGeometryPrimitive3D final : public GroupPrimitive3D + { + public: + explicit HiddenGeometryPrimitive3D(const Primitive3DContainer& rChildren); + + // despite returning an empty decomposition since it's no visualisation data, + // range calculation is intended to use hidden geometry, so + // the local implementation will return the children's range + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const override; + + /// The default implementation returns an empty sequence + virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const override; + + // provide unique ID + DeclPrimitive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive3d/polygontubeprimitive3d.hxx b/drawinglayer/inc/primitive3d/polygontubeprimitive3d.hxx new file mode 100644 index 000000000000..e27201ad6a12 --- /dev/null +++ b/drawinglayer/inc/primitive3d/polygontubeprimitive3d.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/polygonprimitive3d.hxx> + + +namespace drawinglayer +{ + namespace primitive3d + { + /** PolygonStrokePrimitive3D class + + This 3D primitive extends a 3D hairline to a 3D tube which is + e.g. used for fat lines in 3D. It's decomposition will create all + 3D objects needed for the line tubes and the edge roundings + in full 3D. + */ + class PolygonTubePrimitive3D final : public PolygonHairlinePrimitive3D + { + /// hold the last decomposition since it's expensive + Primitive3DContainer maLast3DDecomposition; + + /// visualisation parameters + double mfRadius; + double mfDegreeStepWidth; + double mfMiterMinimumAngle; + basegfx::B2DLineJoin maLineJoin; + css::drawing::LineCap maLineCap; + + /** access methods to maLast3DDecomposition. The usage of this methods may allow + later thread-safe stuff to be added if needed. Only to be used by getDecomposition() + implementations for buffering the last decomposition. + */ + const Primitive3DContainer& getLast3DDecomposition() const { return maLast3DDecomposition; } + + /// local decomposition. + Primitive3DContainer impCreate3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + public: + /// constructor + PolygonTubePrimitive3D( + const basegfx::B3DPolygon& rPolygon, + const basegfx::BColor& rBColor, + double fRadius, + basegfx::B2DLineJoin aLineJoin, + css::drawing::LineCap aLineCap, + double fDegreeStepWidth = basegfx::deg2rad(10.0), + double fMiterMinimumAngle = basegfx::deg2rad(15.0)); + + /// data read access + double getRadius() const { return mfRadius; } + double getDegreeStepWidth() const { return mfDegreeStepWidth; } + double getMiterMinimumAngle() const { return mfMiterMinimumAngle; } + basegfx::B2DLineJoin getLineJoin() const { return maLineJoin; } + css::drawing::LineCap getLineCap() const { return maLineCap; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const override; + + /** local decomposition. Use own buffering since we are not derived from + BufferedDecompositionPrimitive3D + */ + virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive3d/sdrdecompositiontools3d.hxx b/drawinglayer/inc/primitive3d/sdrdecompositiontools3d.hxx new file mode 100644 index 000000000000..c2057db81f11 --- /dev/null +++ b/drawinglayer/inc/primitive3d/sdrdecompositiontools3d.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/baseprimitive3d.hxx> +#include <com/sun/star/drawing/TextureProjectionMode.hpp> +#include <vector> + + +// predefines + +namespace basegfx { + class B3DPolyPolygon; + class B3DHomMatrix; + class B2DVector; +} + +namespace drawinglayer { namespace attribute { + class SdrLineAttribute; + class SdrFillAttribute; + class Sdr3DObjectAttribute; + class FillGradientAttribute; + class SdrShadowAttribute; +}} + + +namespace drawinglayer +{ + namespace primitive3d + { + // #i98295# + basegfx::B3DRange getRangeFrom3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill); + void applyNormalsKindSphereTo3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill, const basegfx::B3DRange& rRange); + void applyNormalsKindFlatTo3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill); + void applyNormalsInvertTo3DGeometry(::std::vector< basegfx::B3DPolyPolygon >& rFill); + + // #i98314# + void applyTextureTo3DGeometry( + css::drawing::TextureProjectionMode eModeX, + css::drawing::TextureProjectionMode eModeY, + ::std::vector< basegfx::B3DPolyPolygon >& rFill, + const basegfx::B3DRange& rRange, + const basegfx::B2DVector& rTextureSize); + + Primitive3DContainer create3DPolyPolygonLinePrimitives( + const basegfx::B3DPolyPolygon& rUnitPolyPolygon, + const basegfx::B3DHomMatrix& rObjectTransform, + const attribute::SdrLineAttribute& rLine); + + Primitive3DContainer create3DPolyPolygonFillPrimitives( + const ::std::vector< basegfx::B3DPolyPolygon >& r3DPolyPolygonVector, + const basegfx::B3DHomMatrix& rObjectTransform, + const basegfx::B2DVector& rTextureSize, + const attribute::Sdr3DObjectAttribute& aSdr3DObjectAttribute, + const attribute::SdrFillAttribute& rFill, + const attribute::FillGradientAttribute& rFillGradient); + + Primitive3DContainer createShadowPrimitive3D( + const Primitive3DContainer& rSource, + const attribute::SdrShadowAttribute& rShadow, + bool bShadow3D); + + Primitive3DContainer createHiddenGeometryPrimitives3D( + const ::std::vector< basegfx::B3DPolyPolygon >& r3DPolyPolygonVector, + const basegfx::B3DHomMatrix& rObjectTransform, + const basegfx::B2DVector& rTextureSize, + const attribute::Sdr3DObjectAttribute& aSdr3DObjectAttribute); + + } // end of namespace primitive3d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive3d/shadowprimitive3d.hxx b/drawinglayer/inc/primitive3d/shadowprimitive3d.hxx new file mode 100644 index 000000000000..60ec61fe7dff --- /dev/null +++ b/drawinglayer/inc/primitive3d/shadowprimitive3d.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/groupprimitive3d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolor.hxx> + + +namespace drawinglayer +{ + namespace primitive3d + { + /** ShadowPrimitive3D class + + This 3D grouping primitive is used to define a shadow for + 3d geometry by embedding it. The shadow of 3D objects are + 2D polygons, so the shadow transformation is a 2D transformation. + + If the Shadow3D flag is set, the shadow definition has to be + combined with the scene and camera definition to create the correct + projected shadow 2D-Polygons. + */ + class ShadowPrimitive3D final : public GroupPrimitive3D + { + /// 2D shadow definition + basegfx::B2DHomMatrix maShadowTransform; + basegfx::BColor maShadowColor; + double mfShadowTransparence; + + bool mbShadow3D : 1; + + public: + /// constructor + ShadowPrimitive3D( + const basegfx::B2DHomMatrix& rShadowTransform, + const basegfx::BColor& rShadowColor, + double fShadowTransparence, + bool bShadow3D, + const Primitive3DContainer& rChildren); + + /// data read access + const basegfx::B2DHomMatrix& getShadowTransform() const { return maShadowTransform; } + const basegfx::BColor& getShadowColor() const { return maShadowColor; } + double getShadowTransparence() const { return mfShadowTransparence; } + bool getShadow3D() const { return mbShadow3D; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/primitive3d/textureprimitive3d.hxx b/drawinglayer/inc/primitive3d/textureprimitive3d.hxx new file mode 100644 index 000000000000..0dc3ed4d3b19 --- /dev/null +++ b/drawinglayer/inc/primitive3d/textureprimitive3d.hxx @@ -0,0 +1,219 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive3d/groupprimitive3d.hxx> +#include <drawinglayer/attribute/fillgraphicattribute.hxx> +#include <basegfx/vector/b2dvector.hxx> +#include <drawinglayer/attribute/fillgradientattribute.hxx> + + +namespace drawinglayer +{ + namespace primitive3d + { + /** TexturePrimitive3D class + + This 3D grouping primitive is used to define a texture for + 3d geometry by embedding it. It is used as base class for + extended texture definitions + */ + class TexturePrimitive3D : public GroupPrimitive3D + { + private: + /// texture geometry definition + basegfx::B2DVector maTextureSize; + + /// flag if texture shall be modulated with white interpolated color + bool mbModulate : 1; + + /// flag if texture shall be filtered + bool mbFilter : 1; + + public: + /// constructor + TexturePrimitive3D( + const Primitive3DContainer& rChildren, + const basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + + /// data read access + const basegfx::B2DVector& getTextureSize() const { return maTextureSize; } + bool getModulate() const { return mbModulate; } + bool getFilter() const { return mbFilter; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const override; + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace primitive3d + { + /** UnifiedTransparenceTexturePrimitive3D class + + This 3D primitive expands TexturePrimitive3D to a unified + transparence texture definition. All 3D primitives + embedded here will be shown with the given transparency. + */ + class UnifiedTransparenceTexturePrimitive3D final : public TexturePrimitive3D + { + private: + /// transparency definition + double mfTransparence; + + public: + /// constructor + UnifiedTransparenceTexturePrimitive3D( + double fTransparence, + const Primitive3DContainer& rChildren); + + /// data read access + double getTransparence() const { return mfTransparence; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const override; + + /// own getB3DRange implementation to include transparent geometries to BoundRect calculations + virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const override; + + /// local decomposition. + virtual Primitive3DContainer get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace primitive3d + { + /** GradientTexturePrimitive3D class + + This 3D primitive expands TexturePrimitive3D to a gradient texture + definition. All 3D primitives embedded here will be shown with the + defined gradient. + */ + class GradientTexturePrimitive3D : public TexturePrimitive3D + { + private: + /// the gradient definition + attribute::FillGradientAttribute maGradient; + + public: + /// constructor + GradientTexturePrimitive3D( + const attribute::FillGradientAttribute& rGradient, + const Primitive3DContainer& rChildren, + const basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + + /// data read access + const attribute::FillGradientAttribute& getGradient() const { return maGradient; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace primitive3d + { + /** BitmapTexturePrimitive3D class + + This 3D primitive expands TexturePrimitive3D to a bitmap texture + definition. All 3D primitives embedded here will be shown with the + defined bitmap (maybe tiled if defined). + */ + class BitmapTexturePrimitive3D final : public TexturePrimitive3D + { + private: + /// bitmap fill attribute + attribute::FillGraphicAttribute maFillGraphicAttribute; + + public: + /// constructor + BitmapTexturePrimitive3D( + const attribute::FillGraphicAttribute& rFillGraphicAttribute, + const Primitive3DContainer& rChildren, + const basegfx::B2DVector& rTextureSize, + bool bModulate, + bool bFilter); + + /// data read access + const attribute::FillGraphicAttribute& getFillGraphicAttribute() const { return maFillGraphicAttribute; } + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace primitive3d + { + /** TransparenceTexturePrimitive3D class + + This 3D primitive expands TexturePrimitive3D to a transparence texture + definition. For transparence definition, a gradient is used. The values in + that gradient will be interpreted as luminance Transparence-Values. All 3D + primitives embedded here will be shown with the defined transparence. + */ + class TransparenceTexturePrimitive3D final : public GradientTexturePrimitive3D + { + public: + /// constructor + TransparenceTexturePrimitive3D( + const attribute::FillGradientAttribute& rGradient, + const Primitive3DContainer& rChildren, + const basegfx::B2DVector& rTextureSize); + + /// compare operator + virtual bool operator==(const BasePrimitive3D& rPrimitive) const override; + + /// provide unique ID + DeclPrimitive3DIDBlock() + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/processor3d/defaultprocessor3d.hxx b/drawinglayer/inc/processor3d/defaultprocessor3d.hxx new file mode 100644 index 000000000000..2a8b179a1ba7 --- /dev/null +++ b/drawinglayer/inc/processor3d/defaultprocessor3d.hxx @@ -0,0 +1,146 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/processor3d/baseprocessor3d.hxx> +#include <basegfx/range/b2drange.hxx> +#include <basegfx/color/bcolormodifier.hxx> +#include <svtools/optionsdrawinglayer.hxx> + +// predefines + +namespace basegfx { + class B3DPolygon; + class B3DPolyPolygon; +} + +namespace drawinglayer { namespace attribute { + class SdrSceneAttribute; + class SdrLightingAttribute; + class MaterialAttribute3D; +}} + +namespace drawinglayer { namespace primitive3d { + class PolygonHairlinePrimitive3D; + class PolyPolygonMaterialPrimitive3D; + class GradientTexturePrimitive3D; + class HatchTexturePrimitive3D; + class BitmapTexturePrimitive3D; + class TransformPrimitive3D; + class ModifiedColorPrimitive3D; +}} + +namespace drawinglayer { namespace texture { + class GeoTexSvx; +}} + + +namespace drawinglayer +{ + namespace processor3d + { + /** DefaultProcessor3D class + + This processor renders all fed primitives to a 2D raster where for all + primitives the two basic methods rasterconvertB3DPolygon for hairlines and + rasterconvertB3DPolyPolygon for filled geometry is called. It is a baseclass to + e.g. base a Z-Buffer supported renderer on the 3D primitive processing. + */ + class DefaultProcessor3D : public BaseProcessor3D + { + protected: + /// read-only scene infos (normal handling, etc...) + const attribute::SdrSceneAttribute& mrSdrSceneAttribute; + + /// read-only light infos (lights, etc...) + const attribute::SdrLightingAttribute& mrSdrLightingAttribute; + + /// renderer range. Need to be correctly set by the derived implementations + /// normally the (0, 0, W, H) range from mpBZPixelRaster + basegfx::B2DRange maRasterRange; + + /// the modifiedColorPrimitive stack + basegfx::BColorModifierStack maBColorModifierStack; + + /// the current active texture + std::shared_ptr< texture::GeoTexSvx > mpGeoTexSvx; + + /// the current active transparence texture + std::shared_ptr< texture::GeoTexSvx > mpTransparenceGeoTexSvx; + + /// SvtOptionsDrawinglayer incarnation to react on diverse settings + const SvtOptionsDrawinglayer maDrawinglayerOpt; + + /// counter for entered transparence textures + sal_uInt32 mnTransparenceCounter; + + bool mbModulate : 1; + bool mbFilter : 1; + bool mbSimpleTextureActive : 1; + + + // rendering support + + void impRenderGradientTexturePrimitive3D(const primitive3d::GradientTexturePrimitive3D& rPrimitive, bool bTransparence); + void impRenderHatchTexturePrimitive3D(const primitive3d::HatchTexturePrimitive3D& rPrimitive); + void impRenderBitmapTexturePrimitive3D(const primitive3d::BitmapTexturePrimitive3D& rPrimitive); + void impRenderModifiedColorPrimitive3D(const primitive3d::ModifiedColorPrimitive3D& rModifiedCandidate); + void impRenderPolygonHairlinePrimitive3D(const primitive3d::PolygonHairlinePrimitive3D& rPrimitive) const; + void impRenderPolyPolygonMaterialPrimitive3D(const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive) const; + void impRenderTransformPrimitive3D(const primitive3d::TransformPrimitive3D& rTransformCandidate); + + + // rasterconversions for filled and non-filled polygons. These NEED to be + // implemented from derivations + + virtual void rasterconvertB3DPolygon(const attribute::MaterialAttribute3D& rMaterial, const basegfx::B3DPolygon& rHairline) const = 0; + virtual void rasterconvertB3DPolyPolygon(const attribute::MaterialAttribute3D& rMaterial, const basegfx::B3DPolyPolygon& rFill) const = 0; + + // the processing method for a single, known primitive + virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D& rBasePrimitive) override; + + public: + DefaultProcessor3D( + const geometry::ViewInformation3D& rViewInformation, + const attribute::SdrSceneAttribute& rSdrSceneAttribute, + const attribute::SdrLightingAttribute& rSdrLightingAttribute); + virtual ~DefaultProcessor3D() override; + + /// data read access + const attribute::SdrSceneAttribute& getSdrSceneAttribute() const { return mrSdrSceneAttribute; } + const attribute::SdrLightingAttribute& getSdrLightingAttribute() const { return mrSdrLightingAttribute; } + + /// data read access renderer stuff + const basegfx::BColorModifierStack& getBColorModifierStack() const { return maBColorModifierStack; } + const std::shared_ptr< texture::GeoTexSvx >& getGeoTexSvx() const { return mpGeoTexSvx; } + const std::shared_ptr< texture::GeoTexSvx >& getTransparenceGeoTexSvx() const { return mpTransparenceGeoTexSvx; } + sal_uInt32 getTransparenceCounter() const { return mnTransparenceCounter; } + bool getModulate() const { return mbModulate; } + bool getFilter() const { return mbFilter; } + bool getSimpleTextureActive() const { return mbSimpleTextureActive; } + + /// access to Drawinglayer configuration options + const SvtOptionsDrawinglayer& getOptionsDrawinglayer() const { return maDrawinglayerOpt; } + }; + } // end of namespace processor3d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/processor3d/geometry2dextractor.hxx b/drawinglayer/inc/processor3d/geometry2dextractor.hxx new file mode 100644 index 000000000000..ae3050fb2850 --- /dev/null +++ b/drawinglayer/inc/processor3d/geometry2dextractor.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/processor3d/baseprocessor3d.hxx> +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolormodifier.hxx> + + +namespace drawinglayer +{ + namespace processor3d + { + /** Geometry2DExtractingProcessor class + + This processor extracts the 2D geometry (projected geometry) of all fed primitives. + It is e.g. used as sub-processor for contour extraction where 3D geometry is only + useful as 2D projected geometry. + */ + class Geometry2DExtractingProcessor final : public BaseProcessor3D + { + private: + /// result holding vector (2D) + primitive2d::Primitive2DContainer maPrimitive2DSequence; + + /// object transformation for scene for 2d definition + basegfx::B2DHomMatrix maObjectTransformation; + + /// the modifiedColorPrimitive stack + basegfx::BColorModifierStack maBColorModifierStack; + + /* as tooling, the process() implementation takes over API handling and calls this + virtual render method when the primitive implementation is BasePrimitive3D-based. + */ + virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate) override; + + public: + Geometry2DExtractingProcessor( + const geometry::ViewInformation3D& rViewInformation, + const basegfx::B2DHomMatrix& rObjectTransformation); + + // data read access + const primitive2d::Primitive2DContainer& getPrimitive2DSequence() const { return maPrimitive2DSequence; } + const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + }; + } // end of namespace processor3d +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/processor3d/shadow3dextractor.hxx b/drawinglayer/inc/processor3d/shadow3dextractor.hxx new file mode 100644 index 000000000000..37c1c0f0e6fc --- /dev/null +++ b/drawinglayer/inc/processor3d/shadow3dextractor.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/processor3d/baseprocessor3d.hxx> +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/matrix/b3dhommatrix.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + +namespace basegfx { class B3DPolyPolygon; } +namespace basegfx { class B3DPolygon; } + + +namespace drawinglayer +{ + namespace processor3d + { + /** Shadow3DExtractingProcessor class + + This processor extracts the 2D shadow geometry (projected geometry) of all fed primitives. + It is used to create the shadow of 3D objects which consists of 2D geometry. It needs quite + some data to do so since we do not only offer flat projected 2D shadow, but also projections + dependent on the light source + */ + class Shadow3DExtractingProcessor final : public BaseProcessor3D + { + private: + /// result holding vector (2D) and target vector for stacking (inited to &maPrimitive2DSequence) + primitive2d::Primitive2DContainer maPrimitive2DSequence; + primitive2d::Primitive2DContainer* mpPrimitive2DSequence; + + /// object transformation for scene for 2d definition + basegfx::B2DHomMatrix maObjectTransformation; + + /// prepared data (transformations) for 2D/3D shadow calculations + basegfx::B3DHomMatrix maWorldToEye; + basegfx::B3DHomMatrix maEyeToView; + basegfx::B3DVector maLightNormal; + basegfx::B3DVector maShadowPlaneNormal; + basegfx::B3DPoint maPlanePoint; + double mfLightPlaneScalar; + + /// flag if shadow plane projection preparation led to valid results + bool mbShadowProjectionIsValid : 1; + + /// flag if conversion is switched on + bool mbConvert : 1; + + /// flag if conversion shall use projection + bool mbUseProjection : 1; + + /// local helpers + basegfx::B2DPolygon impDoShadowProjection(const basegfx::B3DPolygon& rSource); + basegfx::B2DPolyPolygon impDoShadowProjection(const basegfx::B3DPolyPolygon& rSource); + + /* as tooling, the process() implementation takes over API handling and calls this + virtual render method when the primitive implementation is BasePrimitive3D-based. + */ + virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate) override; + + public: + Shadow3DExtractingProcessor( + const geometry::ViewInformation3D& rViewInformation, + const basegfx::B2DHomMatrix& rObjectTransformation, + const basegfx::B3DVector& rLightNormal, + double fShadowSlant, + const basegfx::B3DRange& rContained3DRange); + virtual ~Shadow3DExtractingProcessor() override; + + /// data read access + const primitive2d::Primitive2DContainer& getPrimitive2DSequence() const; + const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + const basegfx::B3DHomMatrix& getWorldToEye() const { return maWorldToEye; } + }; + } // end of namespace processor3d +} // end of namespace drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/processor3d/zbufferprocessor3d.hxx b/drawinglayer/inc/processor3d/zbufferprocessor3d.hxx new file mode 100644 index 000000000000..9a0b422ac380 --- /dev/null +++ b/drawinglayer/inc/processor3d/zbufferprocessor3d.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <processor3d/defaultprocessor3d.hxx> +#include <basegfx/matrix/b3dhommatrix.hxx> +#include <memory> + +namespace basegfx { + class BZPixelRaster; +} + +namespace drawinglayer { + namespace attribute { + class SdrSceneAttribute; + class SdrLightingAttribute; + class MaterialAttribute3D; + } +} + +class ZBufferRasterConverter3D; +class RasterPrimitive3D; + +namespace drawinglayer +{ + namespace processor3d + { + /** + This 3D renderer derived from DefaultProcessor3D renders all fed primitives to a 2D + raster bitmap using a Z-Buffer based approach. It is able to supersample and to handle + transparent content. + */ + class ZBufferProcessor3D final : public DefaultProcessor3D + { + private: + /// inverse of EyeToView for rasterconversion with evtl. Phong shading + basegfx::B3DHomMatrix maInvEyeToView; + + /// The raster converter for Z-Buffer + std::unique_ptr<ZBufferRasterConverter3D> mpZBufferRasterConverter3D; + + /* AA value. Defines how many oversamples will be used in X and Y. Values 0, 1 + will switch it off while e.g. 2 will use 2x2 pixels for each pixel to create + */ + sal_uInt16 mnAntiAlialize; + + /* remembered RasterPrimitive3D's which need to be painted back to front + for transparent 3D parts + */ + std::unique_ptr<std::vector< RasterPrimitive3D >> mpRasterPrimitive3Ds; + + sal_uInt32 mnStartLine; + sal_uInt32 mnStopLine; + + // rasterconversions for filled and non-filled polygons + + virtual void rasterconvertB3DPolygon(const attribute::MaterialAttribute3D& rMaterial, const basegfx::B3DPolygon& rHairline) const override; + virtual void rasterconvertB3DPolyPolygon(const attribute::MaterialAttribute3D& rMaterial, const basegfx::B3DPolyPolygon& rFill) const override; + + public: + ZBufferProcessor3D( + const geometry::ViewInformation3D& rViewInformation3D, + const attribute::SdrSceneAttribute& rSdrSceneAttribute, + const attribute::SdrLightingAttribute& rSdrLightingAttribute, + const basegfx::B2DRange& rVisiblePart, + sal_uInt16 nAntiAlialize, + double fFullViewSizeX, + double fFullViewSizeY, + basegfx::BZPixelRaster& rBZPixelRaster, + sal_uInt32 nStartLine, + sal_uInt32 nStopLine); + virtual ~ZBufferProcessor3D() override; + + void finish(); + }; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/texture/texture.hxx b/drawinglayer/inc/texture/texture.hxx new file mode 100644 index 000000000000..c61d8d2b1674 --- /dev/null +++ b/drawinglayer/inc/texture/texture.hxx @@ -0,0 +1,339 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/range/b2drange.hxx> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/utils/gradienttools.hxx> +#include <vector> + + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvx + { + public: + GeoTexSvx(); + virtual ~GeoTexSvx(); + + // compare operator + virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const; + bool operator!=(const GeoTexSvx& rGeoTexSvx) const { return !operator==(rGeoTexSvx); } + + // virtual base methods + virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; + virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const; + }; + } // end of namespace texture +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace texture + { + /// helper class for processing equal number of matrices and colors + /// for texture processing + struct B2DHomMatrixAndBColor + { + basegfx::B2DHomMatrix maB2DHomMatrix; + basegfx::BColor maBColor; + }; + } // end of namespace texture +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvxGradient : public GeoTexSvx + { + protected: + basegfx::ODFGradientInfo maGradientInfo; + basegfx::B2DRange maDefinitionRange; + basegfx::BColor maStart; + basegfx::BColor maEnd; + double mfBorder; + + public: + GeoTexSvxGradient( + const basegfx::B2DRange& rDefinitionRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + double fBorder); + virtual ~GeoTexSvxGradient() override; + + // compare operator + virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const override; + + // virtual base methods + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOuterColor) = 0; + }; + } // end of namespace texture +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvxGradientLinear final : public GeoTexSvxGradient + { + double mfUnitMinX; + double mfUnitWidth; + double mfUnitMaxY; + + public: + GeoTexSvxGradientLinear( + const basegfx::B2DRange& rDefinitionRange, + const basegfx::B2DRange& rOutputRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fAngle); + virtual ~GeoTexSvxGradientLinear() override; + + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOuterColor) override; + virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; + }; + } // end of namespace texture +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvxGradientAxial final : public GeoTexSvxGradient + { + double mfUnitMinX; + double mfUnitWidth; + + public: + GeoTexSvxGradientAxial( + const basegfx::B2DRange& rDefinitionRange, + const basegfx::B2DRange& rOutputRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fAngle); + virtual ~GeoTexSvxGradientAxial() override; + + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOuterColor) override; + virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; + }; + } // end of namespace texture +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvxGradientRadial final : public GeoTexSvxGradient + { + public: + GeoTexSvxGradientRadial( + const basegfx::B2DRange& rDefinitionRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fOffsetX, + double fOffsetY); + virtual ~GeoTexSvxGradientRadial() override; + + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOuterColor) override; + virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; + }; + } // end of namespace texture +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvxGradientElliptical final : public GeoTexSvxGradient + { + public: + GeoTexSvxGradientElliptical( + const basegfx::B2DRange& rDefinitionRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fOffsetX, + double fOffsetY, + double fAngle); + virtual ~GeoTexSvxGradientElliptical() override; + + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOuterColor) override; + virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; + }; + } // end of namespace texture +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvxGradientSquare final : public GeoTexSvxGradient + { + public: + GeoTexSvxGradientSquare( + const basegfx::B2DRange& rDefinitionRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fOffsetX, + double fOffsetY, + double fAngle); + virtual ~GeoTexSvxGradientSquare() override; + + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOuterColor) override; + virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; + }; + } // end of namespace texture +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvxGradientRect final : public GeoTexSvxGradient + { + public: + GeoTexSvxGradientRect( + const basegfx::B2DRange& rDefinitionRange, + const basegfx::BColor& rStart, + const basegfx::BColor& rEnd, + sal_uInt32 nSteps, + double fBorder, + double fOffsetX, + double fOffsetY, + double fAngle); + virtual ~GeoTexSvxGradientRect() override; + + virtual void appendTransformationsAndColors( + std::vector< B2DHomMatrixAndBColor >& rEntries, + basegfx::BColor& rOuterColor) override; + virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; + }; + } // end of namespace texture +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvxHatch final : public GeoTexSvx + { + basegfx::B2DRange maOutputRange; + basegfx::B2DHomMatrix maTextureTransform; + basegfx::B2DHomMatrix maBackTextureTransform; + double mfDistance; + double mfAngle; + sal_uInt32 mnSteps; + + bool mbDefinitionRangeEqualsOutputRange : 1; + + public: + GeoTexSvxHatch( + const basegfx::B2DRange& rDefinitionRange, + const basegfx::B2DRange& rOutputRange, + double fDistance, + double fAngle); + virtual ~GeoTexSvxHatch() override; + + // compare operator + virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const override; + + void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices); + double getDistanceToHatch(const basegfx::B2DPoint& rUV) const; + const basegfx::B2DHomMatrix& getBackTextureTransform() const; + }; + } // end of namespace texture +} // end of namespace drawinglayer + + +namespace drawinglayer +{ + namespace texture + { + // This class applies a tiling to the unit range. The given range + // will be repeated inside the unit range in X and Y and for each + // tile a matrix will be created (by appendTransformations) that + // represents the needed transformation to map a filling in unit + // coordinates to that tile. + // When offsetX is given, every 2nd line will be offsetted by the + // given percentage value (offsetX has to be 0.0 <= offsetX <= 1.0). + // Accordingly to offsetY. If both are given, offsetX is preferred + // and offsetY is ignored. + class GeoTexSvxTiled final : public GeoTexSvx + { + basegfx::B2DRange maRange; + double mfOffsetX; + double mfOffsetY; + + sal_Int32 iterateTiles(::std::vector< basegfx::B2DHomMatrix >* pMatrices) const; + + public: + GeoTexSvxTiled( + const basegfx::B2DRange& rRange, + double fOffsetX = 0.0, + double fOffsetY = 0.0); + virtual ~GeoTexSvxTiled() override; + + // compare operator + virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const override; + + void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) const; + sal_uInt32 getNumberOfTiles() const; + }; + } // end of namespace texture +} // end of namespace drawinglayer + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/texture/texture3d.hxx b/drawinglayer/inc/texture/texture3d.hxx new file mode 100644 index 000000000000..b5ac6e514f04 --- /dev/null +++ b/drawinglayer/inc/texture/texture3d.hxx @@ -0,0 +1,143 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <texture/texture.hxx> +#include <vcl/bitmapex.hxx> + +namespace drawinglayer { namespace primitive3d { + class HatchTexturePrimitive3D; +}} + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvxMono final : public GeoTexSvx + { + basegfx::BColor maSingleColor; + double mfOpacity; + + public: + GeoTexSvxMono( + const basegfx::BColor& rSingleColor, + double fOpacity); + + // compare operator + virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const override; + virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; + virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const override; + }; + } // end of namespace texture +} // end of namespace drawinglayer + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvxBitmapEx : public GeoTexSvx + { + protected: + BitmapEx maBitmapEx; + Bitmap maBitmap; // Bitmap held within maBitmapEx, to exist during mpReadBitmap scope + Bitmap::ScopedReadAccess mpReadBitmap; + Bitmap maTransparence; + Bitmap::ScopedReadAccess mpReadTransparence; + basegfx::B2DPoint maTopLeft; + basegfx::B2DVector maSize; + double mfMulX; + double mfMulY; + + bool mbIsAlpha : 1; + bool mbIsTransparent : 1; + + // helpers + bool impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const; + sal_uInt8 impGetTransparence(sal_Int32 rX, sal_Int32 rY) const; + + public: + GeoTexSvxBitmapEx( + const BitmapEx& rBitmapEx, + const basegfx::B2DRange& rRange); + virtual ~GeoTexSvxBitmapEx() override; + + virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; + virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const override; + }; + } // end of namespace texture +} // end of namespace drawinglayer + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvxBitmapExTiled final : public GeoTexSvxBitmapEx + { + double mfOffsetX; + double mfOffsetY; + + bool mbUseOffsetX : 1; + bool mbUseOffsetY : 1; + + // helpers + basegfx::B2DPoint impGetCorrected(const basegfx::B2DPoint& rUV) const; + + public: + GeoTexSvxBitmapExTiled( + const BitmapEx& rBitmapEx, + const basegfx::B2DRange& rRange, + double fOffsetX, + double fOffsetY); + + virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; + virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const override; + }; + } // end of namespace texture +} // end of namespace drawinglayer + +namespace drawinglayer +{ + namespace texture + { + class GeoTexSvxMultiHatch final : public GeoTexSvx + { + basegfx::BColor maColor; + double mfLogicPixelSize; + std::unique_ptr<GeoTexSvxHatch> mp0; + std::unique_ptr<GeoTexSvxHatch> mp1; + std::unique_ptr<GeoTexSvxHatch> mp2; + + bool mbFillBackground : 1; + + // helpers + bool impIsOnHatch(const basegfx::B2DPoint& rUV) const; + + public: + GeoTexSvxMultiHatch(const primitive3d::HatchTexturePrimitive3D& rPrimitive, double fLogicPixelSize); + virtual ~GeoTexSvxMultiHatch() override; + virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const override; + virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const override; + }; + } // end of namespace texture +} // end of namespace drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |