From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- drawinglayer/inc/emfplushelper.hxx | 52 ++++ drawinglayer/inc/pch/precompiled_drawinglayer.cxx | 12 + drawinglayer/inc/pch/precompiled_drawinglayer.hxx | 195 +++++++++++++++ .../inc/pch/precompiled_drawinglayercore.cxx | 12 + .../inc/pch/precompiled_drawinglayercore.hxx | 52 ++++ drawinglayer/inc/primitive2d/cropprimitive2d.hxx | 93 ++++++++ .../inc/primitive2d/graphicprimitivehelper2d.hxx | 59 +++++ .../inc/primitive2d/texteffectprimitive2d.hxx | 97 ++++++++ .../inc/primitive2d/textlineprimitive2d.hxx | 74 ++++++ .../inc/primitive2d/textstrikeoutprimitive2d.hxx | 135 +++++++++++ .../inc/primitive2d/wallpaperprimitive2d.hxx | 76 ++++++ .../inc/primitive3d/hatchtextureprimitive3d.hxx | 74 ++++++ .../inc/primitive3d/hiddengeometryprimitive3d.hxx | 57 +++++ .../inc/primitive3d/polygontubeprimitive3d.hxx | 88 +++++++ .../inc/primitive3d/sdrdecompositiontools3d.hxx | 87 +++++++ drawinglayer/inc/primitive3d/shadowprimitive3d.hxx | 73 ++++++ .../inc/primitive3d/textureprimitive3d.hxx | 207 ++++++++++++++++ .../inc/processor3d/defaultprocessor3d.hxx | 137 +++++++++++ .../inc/processor3d/geometry2dextractor.hxx | 66 +++++ drawinglayer/inc/processor3d/shadow3dextractor.hxx | 95 ++++++++ .../inc/processor3d/zbufferprocessor3d.hxx | 93 ++++++++ drawinglayer/inc/texture/texture.hxx | 265 +++++++++++++++++++++ drawinglayer/inc/texture/texture3d.hxx | 132 ++++++++++ drawinglayer/inc/wmfemfhelper.hxx | 218 +++++++++++++++++ 24 files changed, 2449 insertions(+) create mode 100644 drawinglayer/inc/emfplushelper.hxx create mode 100644 drawinglayer/inc/pch/precompiled_drawinglayer.cxx create mode 100644 drawinglayer/inc/pch/precompiled_drawinglayer.hxx create mode 100644 drawinglayer/inc/pch/precompiled_drawinglayercore.cxx create mode 100644 drawinglayer/inc/pch/precompiled_drawinglayercore.hxx create mode 100644 drawinglayer/inc/primitive2d/cropprimitive2d.hxx create mode 100644 drawinglayer/inc/primitive2d/graphicprimitivehelper2d.hxx create mode 100644 drawinglayer/inc/primitive2d/texteffectprimitive2d.hxx create mode 100644 drawinglayer/inc/primitive2d/textlineprimitive2d.hxx create mode 100644 drawinglayer/inc/primitive2d/textstrikeoutprimitive2d.hxx create mode 100644 drawinglayer/inc/primitive2d/wallpaperprimitive2d.hxx create mode 100644 drawinglayer/inc/primitive3d/hatchtextureprimitive3d.hxx create mode 100644 drawinglayer/inc/primitive3d/hiddengeometryprimitive3d.hxx create mode 100644 drawinglayer/inc/primitive3d/polygontubeprimitive3d.hxx create mode 100644 drawinglayer/inc/primitive3d/sdrdecompositiontools3d.hxx create mode 100644 drawinglayer/inc/primitive3d/shadowprimitive3d.hxx create mode 100644 drawinglayer/inc/primitive3d/textureprimitive3d.hxx create mode 100644 drawinglayer/inc/processor3d/defaultprocessor3d.hxx create mode 100644 drawinglayer/inc/processor3d/geometry2dextractor.hxx create mode 100644 drawinglayer/inc/processor3d/shadow3dextractor.hxx create mode 100644 drawinglayer/inc/processor3d/zbufferprocessor3d.hxx create mode 100644 drawinglayer/inc/texture/texture.hxx create mode 100644 drawinglayer/inc/texture/texture3d.hxx create mode 100644 drawinglayer/inc/wmfemfhelper.hxx (limited to 'drawinglayer/inc') diff --git a/drawinglayer/inc/emfplushelper.hxx b/drawinglayer/inc/emfplushelper.hxx new file mode 100644 index 000000000..22b9acb60 --- /dev/null +++ b/drawinglayer/inc/emfplushelper.hxx @@ -0,0 +1,52 @@ +/* -*- 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 +#include +#include "wmfemfhelper.hxx" + +namespace emfplushelper { struct EmfPlusHelperData; } +namespace wmfemfhelper { class TargetHolders; } +namespace drawinglayer::geometry { class ViewInformation2D; } +class SvMemoryStream; + +namespace emfplushelper +{ + /// EMF+ data holder + class EmfPlusHelper + { + private: + const std::unique_ptr mpD; + + public: + EmfPlusHelper( + SvMemoryStream& rMemoryStream, + wmfemfhelper::TargetHolders& rTargetHolders, + wmfemfhelper::PropertyHolders& rPropertyHolders); + ~EmfPlusHelper(); + + void processEmfPlusData( + SvMemoryStream& rMemoryStream, + const drawinglayer::geometry::ViewInformation2D& rViewInformation); + }; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/pch/precompiled_drawinglayer.cxx b/drawinglayer/inc/pch/precompiled_drawinglayer.cxx new file mode 100644 index 000000000..fc906a313 --- /dev/null +++ b/drawinglayer/inc/pch/precompiled_drawinglayer.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "precompiled_drawinglayer.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/pch/precompiled_drawinglayer.hxx b/drawinglayer/inc/pch/precompiled_drawinglayer.hxx new file mode 100644 index 000000000..fc6371906 --- /dev/null +++ b/drawinglayer/inc/pch/precompiled_drawinglayer.hxx @@ -0,0 +1,195 @@ +/* -*- 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 has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + 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 2021-12-23 08:55:28 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: + ./bin/update_pch_bisect ./drawinglayer/inc/pch/precompiled_drawinglayer.hxx "make drawinglayer.build" --find-conflicts +*/ + +#include +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/pch/precompiled_drawinglayercore.cxx b/drawinglayer/inc/pch/precompiled_drawinglayercore.cxx new file mode 100644 index 000000000..4a8c23ea8 --- /dev/null +++ b/drawinglayer/inc/pch/precompiled_drawinglayercore.cxx @@ -0,0 +1,12 @@ +/* -*- 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/. + */ + +#include "precompiled_drawinglayercore.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/pch/precompiled_drawinglayercore.hxx b/drawinglayer/inc/pch/precompiled_drawinglayercore.hxx new file mode 100644 index 000000000..9912df042 --- /dev/null +++ b/drawinglayer/inc/pch/precompiled_drawinglayercore.hxx @@ -0,0 +1,52 @@ +/* -*- 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 has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + 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 2021-12-23 08:57:20 using: + ./bin/update_pch drawinglayer drawinglayercore --cutoff=3 --exclude:system --exclude:module --exclude:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./drawinglayer/inc/pch/precompiled_drawinglayercore.hxx "make drawinglayer.build" --find-conflicts +*/ + +#include +#if PCH_LEVEL >= 1 +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#include +#include +#include +#include +#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 000000000..3bed0638f --- /dev/null +++ b/drawinglayer/inc/primitive2d/cropprimitive2d.hxx @@ -0,0 +1,93 @@ +/* -*- 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 +#include + + +namespace drawinglayer::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( + Primitive2DContainer&& aChildren, + 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 drawinglayer::primitive2d + +/* 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 000000000..cecb1d8f1 --- /dev/null +++ b/drawinglayer/inc/primitive2d/graphicprimitivehelper2d.hxx @@ -0,0 +1,59 @@ +/* -*- 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 +#include + +class Graphic; + +namespace drawinglayer::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( + 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 drawinglayer::primitive2d + +/* 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 000000000..c586c6f23 --- /dev/null +++ b/drawinglayer/inc/primitive2d/texteffectprimitive2d.hxx @@ -0,0 +1,97 @@ +/* -*- 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 +#include + +namespace drawinglayer::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(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::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 000000000..423be7995 --- /dev/null +++ b/drawinglayer/inc/primitive2d/textlineprimitive2d.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 +#include +#include +#include + + +namespace drawinglayer::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 drawinglayer::primitive2d + + +/* 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 000000000..9b93e28db --- /dev/null +++ b/drawinglayer/inc/primitive2d/textstrikeoutprimitive2d.hxx @@ -0,0 +1,135 @@ +/* -*- 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 +#include +#include +#include +#include +#include + + +namespace drawinglayer::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 drawinglayer::primitive2d + + +namespace drawinglayer::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 drawinglayer::primitive2d + + +namespace drawinglayer::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 drawinglayer::primitive2d + + +/* 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 000000000..c92006b36 --- /dev/null +++ b/drawinglayer/inc/primitive2d/wallpaperprimitive2d.hxx @@ -0,0 +1,76 @@ +/* -*- 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 +#include +#include + + +namespace drawinglayer::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 drawinglayer::primitive2d + +/* 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 000000000..151fa67ea --- /dev/null +++ b/drawinglayer/inc/primitive3d/hatchtextureprimitive3d.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 +#include + + +namespace drawinglayer::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 drawinglayer::primitive3d + + +/* 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 000000000..45de83380 --- /dev/null +++ b/drawinglayer/inc/primitive3d/hiddengeometryprimitive3d.hxx @@ -0,0 +1,57 @@ +/* -*- 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 + + +namespace drawinglayer::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 drawinglayer::primitive3d + + +/* 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 000000000..38372977e --- /dev/null +++ b/drawinglayer/inc/primitive3d/polygontubeprimitive3d.hxx @@ -0,0 +1,88 @@ +/* -*- 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 + + +namespace drawinglayer::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 drawinglayer::primitive3d + + +/* 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 000000000..6e549289b --- /dev/null +++ b/drawinglayer/inc/primitive3d/sdrdecompositiontools3d.hxx @@ -0,0 +1,87 @@ +/* -*- 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 +#include +#include + + +// predefines + +namespace basegfx { + class B3DPolyPolygon; + class B3DHomMatrix; + class B2DVector; +} + +namespace drawinglayer::attribute { + class SdrLineAttribute; + class SdrFillAttribute; + class Sdr3DObjectAttribute; + class FillGradientAttribute; + class SdrShadowAttribute; +} + + +namespace drawinglayer::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 drawinglayer::primitive3d + + +/* 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 000000000..627d2b8c1 --- /dev/null +++ b/drawinglayer/inc/primitive3d/shadowprimitive3d.hxx @@ -0,0 +1,73 @@ +/* -*- 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 +#include +#include + + +namespace drawinglayer::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 drawinglayer::primitive3d + + +/* 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 000000000..855ee3436 --- /dev/null +++ b/drawinglayer/inc/primitive3d/textureprimitive3d.hxx @@ -0,0 +1,207 @@ +/* -*- 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 +#include +#include +#include + + +namespace drawinglayer::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 drawinglayer::primitive3d + + +namespace drawinglayer::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 drawinglayer::primitive3d + + +namespace drawinglayer::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 drawinglayer::primitive3d + + +namespace drawinglayer::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 drawinglayer::primitive3d + + +namespace drawinglayer::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 drawinglayer::primitive3d + + +/* 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 000000000..aace2ef87 --- /dev/null +++ b/drawinglayer/inc/processor3d/defaultprocessor3d.hxx @@ -0,0 +1,137 @@ +/* -*- 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 +#include +#include + +// predefines + +namespace basegfx { + class B3DPolygon; + class B3DPolyPolygon; +} + +namespace drawinglayer::attribute { + class SdrSceneAttribute; + class SdrLightingAttribute; + class MaterialAttribute3D; +} + +namespace drawinglayer::primitive3d { + class PolygonHairlinePrimitive3D; + class PolyPolygonMaterialPrimitive3D; + class GradientTexturePrimitive3D; + class HatchTexturePrimitive3D; + class BitmapTexturePrimitive3D; + class TransformPrimitive3D; + class ModifiedColorPrimitive3D; +} + +namespace drawinglayer::texture { + class GeoTexSvx; +} + + +namespace drawinglayer::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; + + /// 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; } + }; + +} // end of namespace drawinglayer::processor3d + + +/* 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 000000000..e490ecfc5 --- /dev/null +++ b/drawinglayer/inc/processor3d/geometry2dextractor.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 +#include +#include +#include + + +namespace drawinglayer::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 drawinglayer::processor3d + + +/* 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 000000000..9fa877fec --- /dev/null +++ b/drawinglayer/inc/processor3d/shadow3dextractor.hxx @@ -0,0 +1,95 @@ +/* -*- 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 +#include +#include +#include +#include +#include + +namespace basegfx { class B3DPolyPolygon; } +namespace basegfx { class B3DPolygon; } + + +namespace drawinglayer::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 drawinglayer::processor3d + +/* 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 000000000..4207a6fcd --- /dev/null +++ b/drawinglayer/inc/processor3d/zbufferprocessor3d.hxx @@ -0,0 +1,93 @@ +/* -*- 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 +#include +#include + +namespace basegfx { + class BZPixelRaster; +} + +namespace drawinglayer::attribute { + class SdrSceneAttribute; + class SdrLightingAttribute; + class MaterialAttribute3D; +} + + +class ZBufferRasterConverter3D; +class RasterPrimitive3D; + +namespace drawinglayer::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 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 + */ + mutable std::vector< RasterPrimitive3D > maRasterPrimitive3Ds; + + 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 000000000..9cfb2d6d5 --- /dev/null +++ b/drawinglayer/inc/texture/texture.hxx @@ -0,0 +1,265 @@ +/* -*- 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 +#include +#include +#include +#include +#include + +namespace drawinglayer::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; + }; + + /// helper class for processing equal number of matrices and colors + /// for texture processing + struct B2DHomMatrixAndBColor + { + basegfx::B2DHomMatrix maB2DHomMatrix; + basegfx::BColor maBColor; + }; + + 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; + }; + + 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; + }; + + 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; + }; + + 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; + }; + + 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; + }; + + 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; + }; + + 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; + }; + + 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; + }; + + // 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; + + 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; + + // Iterate over created tiles with callback provided. + void iterateTiles(std::function aFunc) const; + + void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices) const; + sal_uInt32 getNumberOfTiles() const; + }; +} // end of namespace drawinglayer::texture + + +/* 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 000000000..88d13ed03 --- /dev/null +++ b/drawinglayer/inc/texture/texture3d.hxx @@ -0,0 +1,132 @@ +/* -*- 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 +#include + +namespace drawinglayer::primitive3d { + class HatchTexturePrimitive3D; +} + +namespace drawinglayer::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 drawinglayer::texture + +namespace drawinglayer::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; + + // 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 drawinglayer::texture + +namespace drawinglayer::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 drawinglayer::texture + +namespace drawinglayer::texture + { + class GeoTexSvxMultiHatch final : public GeoTexSvx + { + basegfx::BColor maColor; + double mfLogicPixelSize; + std::unique_ptr mp0; + std::unique_ptr mp1; + std::unique_ptr 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 drawinglayer::texture + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/wmfemfhelper.hxx b/drawinglayer/inc/wmfemfhelper.hxx new file mode 100644 index 000000000..f085065c1 --- /dev/null +++ b/drawinglayer/inc/wmfemfhelper.hxx @@ -0,0 +1,218 @@ +/* -*- 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 +#include +#include +#include +#include +#include +#include + +// predefines +namespace drawinglayer::geometry { class ViewInformation2D; } +class GDIMetaFile; +namespace wmfemfhelper { class PropertyHolder; } + +namespace wmfemfhelper +{ + /** Helper class to buffer and hold a Primitive target vector. It + encapsulates the new/delete functionality and allows to work + on pointers of the implementation classes. All data will + be converted to uno sequences of uno references when accessing the + data. + */ + class TargetHolder + { + private: + drawinglayer::primitive2d::Primitive2DContainer aTargets; + + public: + TargetHolder(); + ~TargetHolder(); + sal_uInt32 size() const; + void append(const rtl::Reference & pCandidate) + { + append(pCandidate.get()); + } + void append(drawinglayer::primitive2d::Primitive2DContainer xCandidate) + { + aTargets.append(std::move(xCandidate)); + } + void append(drawinglayer::primitive2d::BasePrimitive2D* pCandidate); + drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequence(const PropertyHolder& rPropertyHolder); + }; + + /** Helper class which builds a stack on the TargetHolder class */ + class TargetHolders + { + private: + std::vector< TargetHolder* > maTargetHolders; + + public: + TargetHolders(); + sal_uInt32 size() const; + void Push(); + void Pop(); + TargetHolder& Current(); + ~TargetHolders(); + }; + + /** helper class for graphic context + + This class allows to hold a complete representation of classic + VCL OutputDevice state. This data is needed for correct + interpretation of the MetaFile action flow. + */ + class PropertyHolder + { + private: + /// current transformation (aka MapMode) + basegfx::B2DHomMatrix maTransformation; + MapUnit maMapUnit; + + /// current colors + basegfx::BColor maLineColor; + basegfx::BColor maFillColor; + basegfx::BColor maTextColor; + basegfx::BColor maTextFillColor; + basegfx::BColor maTextLineColor; + basegfx::BColor maOverlineColor; + + /// clipping + basegfx::B2DPolyPolygon maClipPolyPolygon; + + /// font, etc. + vcl::Font maFont; + RasterOp maRasterOp; + vcl::text::ComplexTextLayoutFlags mnLayoutMode; + LanguageType maLanguageType; + vcl::PushFlags mnPushFlags; + + /// contains all active markers + bool mbLineColor : 1; + bool mbFillColor : 1; + bool mbTextColor : 1; + bool mbTextFillColor : 1; + bool mbTextLineColor : 1; + bool mbOverlineColor : 1; + bool mbClipPolyPolygonActive : 1; + + public: + PropertyHolder(); + + /// read/write accesses + const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } + void setTransformation(const basegfx::B2DHomMatrix& rNew) { if (rNew != maTransformation) maTransformation = rNew; } + + MapUnit getMapUnit() const { return maMapUnit; } + void setMapUnit(MapUnit eNew) { if (eNew != maMapUnit) maMapUnit = eNew; } + + const basegfx::BColor& getLineColor() const { return maLineColor; } + void setLineColor(const basegfx::BColor& rNew) { if (rNew != maLineColor) maLineColor = rNew; } + bool getLineColorActive() const { return mbLineColor; } + void setLineColorActive(bool bNew) { if (bNew != mbLineColor) mbLineColor = bNew; } + + const basegfx::BColor& getFillColor() const { return maFillColor; } + void setFillColor(const basegfx::BColor& rNew) { if (rNew != maFillColor) maFillColor = rNew; } + bool getFillColorActive() const { return mbFillColor; } + void setFillColorActive(bool bNew) { if (bNew != mbFillColor) mbFillColor = bNew; } + + const basegfx::BColor& getTextColor() const { return maTextColor; } + void setTextColor(const basegfx::BColor& rNew) { if (rNew != maTextColor) maTextColor = rNew; } + bool getTextColorActive() const { return mbTextColor; } + void setTextColorActive(bool bNew) { if (bNew != mbTextColor) mbTextColor = bNew; } + + const basegfx::BColor& getTextFillColor() const { return maTextFillColor; } + void setTextFillColor(const basegfx::BColor& rNew) { if (rNew != maTextFillColor) maTextFillColor = rNew; } + bool getTextFillColorActive() const { return mbTextFillColor; } + void setTextFillColorActive(bool bNew) { if (bNew != mbTextFillColor) mbTextFillColor = bNew; } + + const basegfx::BColor& getTextLineColor() const { return maTextLineColor; } + void setTextLineColor(const basegfx::BColor& rNew) { if (rNew != maTextLineColor) maTextLineColor = rNew; } + bool getTextLineColorActive() const { return mbTextLineColor; } + void setTextLineColorActive(bool bNew) { if (bNew != mbTextLineColor) mbTextLineColor = bNew; } + + const basegfx::BColor& getOverlineColor() const { return maOverlineColor; } + void setOverlineColor(const basegfx::BColor& rNew) { if (rNew != maOverlineColor) maOverlineColor = rNew; } + bool getOverlineColorActive() const { return mbOverlineColor; } + void setOverlineColorActive(bool bNew) { if (bNew != mbOverlineColor) mbOverlineColor = bNew; } + + const basegfx::B2DPolyPolygon& getClipPolyPolygon() const { return maClipPolyPolygon; } + void setClipPolyPolygon(const basegfx::B2DPolyPolygon& rNew) { if (rNew != maClipPolyPolygon) maClipPolyPolygon = rNew; } + bool getClipPolyPolygonActive() const { return mbClipPolyPolygonActive; } + void setClipPolyPolygonActive(bool bNew) { if (bNew != mbClipPolyPolygonActive) mbClipPolyPolygonActive = bNew; } + + const vcl::Font& getFont() const { return maFont; } + void setFont(const vcl::Font& rFont) { if (rFont != maFont) maFont = rFont; } + + const RasterOp& getRasterOp() const { return maRasterOp; } + void setRasterOp(const RasterOp& rRasterOp) { if (rRasterOp != maRasterOp) maRasterOp = rRasterOp; } + bool isRasterOpInvert() const { return (RasterOp::Xor == maRasterOp || RasterOp::Invert == maRasterOp); } + bool isRasterOpForceBlack() const { return RasterOp::N0 == maRasterOp; } + bool isRasterOpActive() const { return isRasterOpInvert() || isRasterOpForceBlack(); } + + vcl::text::ComplexTextLayoutFlags getLayoutMode() const { return mnLayoutMode; } + void setLayoutMode(vcl::text::ComplexTextLayoutFlags nNew) { if (nNew != mnLayoutMode) mnLayoutMode = nNew; } + + LanguageType getLanguageType() const { return maLanguageType; } + void setLanguageType(LanguageType aNew) { if (aNew != maLanguageType) maLanguageType = aNew; } + + vcl::PushFlags getPushFlags() const { return mnPushFlags; } + void setPushFlags(vcl::PushFlags nNew) { if (nNew != mnPushFlags) mnPushFlags = nNew; } + + bool getLineOrFillActive() const { return (mbLineColor || mbFillColor); } + }; + + /** stack for properties + + This class builds a stack based on the PropertyHolder + class. It encapsulates the pointer/new/delete usage to + make it safe and implements the push/pop as needed by a + VCL Metafile interpreter. The critical part here are the + flag values VCL OutputDevice uses here; not all stuff is + pushed and thus needs to be copied at pop. + */ + class PropertyHolders + { + private: + std::vector< PropertyHolder* > maPropertyHolders; + + public: + PropertyHolders(); + void PushDefault(); + void Push(vcl::PushFlags nPushFlags); + void Pop(); + PropertyHolder& Current(); + ~PropertyHolders(); + }; + + drawinglayer::primitive2d::Primitive2DContainer interpretMetafile( + const GDIMetaFile& rMetaFile, + const drawinglayer::geometry::ViewInformation2D& rViewInformation); + + void HandleNewClipRegion( + const basegfx::B2DPolyPolygon& rClipPolyPolygon, + TargetHolders& rTargetHolders, + PropertyHolders& rPropertyHolders); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3