diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2023-03-23 16:13:26 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2023-03-23 17:14:04 +0000 |
commit | 462ebbd10bd537f42104fe991a0aeebcd563f178 (patch) | |
tree | 77ad4e2aa83424efa458f99a6e5deee5d321dfa0 /include/drawinglayer | |
parent | 7ecc9925f3b0d1cea4ee7201473dd6fbbb95c271 (diff) |
MCGR: Speedup Gradient Paint for VCLPixelProcessor
To do this, I re-organized FillGradientPrimitive2D and
how it creates it's decompose. This provides the needed
tooling to also do a more direct rendering in primitive
processors if needed.
The decompose no longer collects the matrices & colors
as a 1st step in a helper data struecture (so I removed
B2DHomMatrixAndBColor). It now uses a lambda function
callback that hands over the matrix & color for each
created step, so you can process it directly, in this
case to create the needed primitives.
NOTE: The decompositions are both tested. There was
createNonOverlappingFill, but also createOverlappingFill
that I am not sure is still used - and if in re-creating
an old, strange XOR-using gradient paint mechanism in
old metafiles (encapsulated with gradient info anyways),
but I converted that and made sure it works.
To do so I forced it to be used in paint. This is not
really usable in paint since we need to paint using AA
(else we would get staircase effects, esp. in new 'hard'
color changes in multi-color gradients) and - as should
be known - same edges painted in AA do *not* add up to
full opacity, but leave behind awful 'jaggies' (e.g.
opacity 0.5 and 0.5 create 0.75 and *not* 1.0). Still
important to have the working geometry creation for this
case.
This already makes the decompose faster, but the main
purpose is to use it as tooling for painting in own
primitive renderers.
Thus processFillGradientPrimitive2D now uses that
instead of using the decomposition by default.
This avoids one level of primitive creation, use
that new FillGradientPrimitive2D tooling to directly
create needed geoemtry & color for getting better
performance (to partially compensate for potentially
more expensive multi color gradients). It then paints
directly using OutputDevice calls.
NOTE: This can also be used in SDPRs as a 1st step
to just directly and rapidly render filled single-
color polygons, but of course there an implementation
using the back-transformations (which are also
adapted for MCGRs aleady and work) will be superior.
Change-Id: I5079f76d6d8fe86007a098614c276447f2bfebce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149456
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'include/drawinglayer')
-rw-r--r-- | include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx b/include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx index 43a3179cbe4e..ffdf874fa975 100644 --- a/include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/fillgradientprimitive2d.hxx @@ -28,7 +28,6 @@ // predefines namespace basegfx { class B2DPolygon; } -namespace drawinglayer::texture { struct B2DHomMatrixAndBColor; } // FillGradientPrimitive2D class @@ -62,20 +61,6 @@ namespace drawinglayer::primitive2d /// the gradient definition attribute::FillGradientAttribute maFillGradient; - /// local helpers - void generateMatricesAndColors( - std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, - basegfx::BColor& rOuterColor) const; - void createOverlappingFill( - Primitive2DContainer& rContainer, - const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, - const basegfx::BColor& rOuterColor, - const basegfx::B2DPolygon& rUnitPolygon) const; - void createNonOverlappingFill( - Primitive2DContainer& rContainer, - const std::vector< drawinglayer::texture::B2DHomMatrixAndBColor >& rEntries, - const basegfx::BColor& rOuterColor, - const basegfx::B2DPolygon& rUnitPolygon) const; protected: /// local helper @@ -85,6 +70,12 @@ namespace drawinglayer::primitive2d virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; public: + /// helpers that support e.g. direct paint/geometry creation + basegfx::B2DPolygon getUnitPolygon() const; + basegfx::BColor getOuterColor() const; + void generateMatricesAndColors( + std::function<void(const basegfx::B2DHomMatrix& rMatrix, const basegfx::BColor& rColor)> aCallback) const; + /// constructors. The one without definition range will use output range as definition range FillGradientPrimitive2D( const basegfx::B2DRange& rOutputRange, |