diff options
author | Armin Le Grand (Collabora) <Armin.Le.Grand@me.com> | 2024-07-23 13:26:34 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2024-07-23 18:35:26 +0200 |
commit | 462d85709ead9c7cec33ce58fc608997263cb6aa (patch) | |
tree | 3eef2f07a6bef84a3ba02d49c9536ab58d5abfbf /include/drawinglayer/primitive2d | |
parent | 863b90e33c4b9964a697684887aeb42cc538b019 (diff) |
CairoSDPR: Support alpha for BitmapPrimitives
To more directly support an additional alpha channel
for BitmapPrimitive data I have done some deeper
changes to the primitive stack, in a compatible
way. Quite some more graphic types and primitives
now support an additional direct alpha value. All
that is decomposed/created/broken down in a way
that needs no changes for existing renderers, in
already described ways.
The CairoPixelProcessor2D already uses this in the
processFillGraphicPrimitive2D implementation and
thus in the FillGraphicPrimitive2D. This works since
primitive productions now all try to create that
FillGraphicPrimitive2D type including an additional
alpha value - if possible and necessary.
Change-Id: Ib1b16491a2b3aee16f14cc8196e28af30a7cf9be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170900
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Tested-by: Jenkins
Diffstat (limited to 'include/drawinglayer/primitive2d')
3 files changed, 30 insertions, 3 deletions
diff --git a/include/drawinglayer/primitive2d/PolyPolygonGraphicPrimitive2D.hxx b/include/drawinglayer/primitive2d/PolyPolygonGraphicPrimitive2D.hxx index f364ba7f19db..0b0e2ee4dbf2 100644 --- a/include/drawinglayer/primitive2d/PolyPolygonGraphicPrimitive2D.hxx +++ b/include/drawinglayer/primitive2d/PolyPolygonGraphicPrimitive2D.hxx @@ -32,6 +32,10 @@ namespace drawinglayer::primitive2d This primitive defines a tools::PolyPolygon filled with bitmap data (including transparence). The decomosition will create a MaskPrimitive2D containing a FillGraphicPrimitive2D. + + SDPR: support alpha now directly: the decompositon creates + FillGraphicPrimitive2D which also supports alpha directly + now. All direct usages are covered */ class DRAWINGLAYER_DLLPUBLIC PolyPolygonGraphicPrimitive2D final : public BufferedDecompositionPrimitive2D @@ -46,6 +50,9 @@ private: /// the bitmap fill definition (may include tiling) attribute::FillGraphicAttribute maFillGraphic; + /// the transparency in range [0.0 .. 1.0] + double mfTransparency; + /// local decomposition. virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override; @@ -53,12 +60,15 @@ private: public: PolyPolygonGraphicPrimitive2D(basegfx::B2DPolyPolygon aPolyPolygon, const basegfx::B2DRange& rDefinitionRange, - const attribute::FillGraphicAttribute& rFillGraphic); + const attribute::FillGraphicAttribute& rFillGraphic, + double fTransparency = 0.0); /// data read access const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; } const attribute::FillGraphicAttribute& getFillGraphic() const { return maFillGraphic; } + double getTransparency() const { return mfTransparency; } + bool hasTransparency() const { return !basegfx::fTools::equalZero(mfTransparency); } /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; diff --git a/include/drawinglayer/primitive2d/fillgraphicprimitive2d.hxx b/include/drawinglayer/primitive2d/fillgraphicprimitive2d.hxx index d43df3da84e4..784117ae880c 100644 --- a/include/drawinglayer/primitive2d/fillgraphicprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/fillgraphicprimitive2d.hxx @@ -56,6 +56,12 @@ namespace drawinglayer::primitive2d Renderers should handle this primitive; it has a geometrically correct decomposition, but on pixel outputs the areas where the tiled pieces are aligned tend to show up (one overlapping or empty pixel) + + SDPR: support alpha directly now. If a primitive processor + cannot deal with it, use it's decomposition. The decompositon + uses create2DDecompositionOfGraphic, there all paths are now + capable of handling a given alpha, including metafile, SVG and + animated graphics */ class DRAWINGLAYER_DLLPUBLIC FillGraphicPrimitive2D final : public BufferedDecompositionPrimitive2D { @@ -69,6 +75,9 @@ namespace drawinglayer::primitive2d /// the evtl. buffered OffsetXYCreatedBitmap BitmapEx maOffsetXYCreatedBitmap; + /// the transparency in range [0.0 .. 1.0] + double mfTransparency; + /// local decomposition. virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override; @@ -87,12 +96,15 @@ namespace drawinglayer::primitive2d /// constructor FillGraphicPrimitive2D( basegfx::B2DHomMatrix aTransformation, - const attribute::FillGraphicAttribute& rFillGraphic); + const attribute::FillGraphicAttribute& rFillGraphic, + double fTransparency = 0.0); /// data read access const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } const attribute::FillGraphicAttribute& getFillGraphic() const { return maFillGraphic; } const BitmapEx& getOffsetXYCreatedBitmap() const { return maOffsetXYCreatedBitmap; } + double getTransparency() const { return mfTransparency; } + bool hasTransparency() const { return !basegfx::fTools::equalZero(mfTransparency); } /// compare operator virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override; diff --git a/include/drawinglayer/primitive2d/graphicprimitivehelper2d.hxx b/include/drawinglayer/primitive2d/graphicprimitivehelper2d.hxx index 6aa8ef5191ce..024ad3fce28a 100644 --- a/include/drawinglayer/primitive2d/graphicprimitivehelper2d.hxx +++ b/include/drawinglayer/primitive2d/graphicprimitivehelper2d.hxx @@ -33,11 +33,16 @@ namespace drawinglayer::primitive2d and GraphicPrimitive2D at the same time. It is able to handle Bitmaps (with the sub-categories animated bitmap, and SVG), and Metafiles. + + SDPR: create2DDecompositionOfGraphic now supports a given + alpha directly: all paths are now capable of handling a + given alpha, including metafile, SVG and animated graphics */ void DRAWINGLAYER_DLLPUBLIC create2DDecompositionOfGraphic( Primitive2DContainer& rContainer, const Graphic& rGraphic, - const basegfx::B2DHomMatrix& rTransform); + const basegfx::B2DHomMatrix& rTransform, + double fTransparency = 0.0); /** Helper to embed given sequence of primitives to evtl. a stack of ModifiedColorPrimitive2D's to get all the needed modifications |