diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2024-07-10 13:16:20 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2024-07-11 10:58:24 +0200 |
commit | 27829e4a6c5a4a1162599550c46b5e7f974aba91 (patch) | |
tree | 408844c4e976b7e8ca1624ed38cb2555b2ddd2eb /drawinglayer/source/primitive2d | |
parent | c92e4d1a944019dd5b14cdce3d85213d2a8d9e92 (diff) |
CairoSDPR: Improve BColorModified Bitmaps
There is the complete BColorModifierStack support for
primitives for Bitmaps, e.g. hue/saturation, etc, but
it was slow due to not being buffered, so had to be
re-created often. I changed this to use the common
buffering mechanism to improve this.
Up to now a fallback to use the old Graphic
manipulators for that purpose was in place since this
was faster, but had to be done every time. I have now
changed the priority to using the primitive way to
handle things, but kept the fallback code - just in
case.
Note that the new stuff is faster, but even much faster
when the bitmap is copied and appears multiple times ->
the same buffered instance is used, and SDPRs then use
the system-dependent data buffered at that prepared
data.
Also note that this change does not only speedup
CairoSDPR, but all PrimitiveRenderers, including the
VCL and Metafile ones. In principle everything that
uses BitmapEx::ModifyBitmapEx.
Had a 2nd thought: Only the content Bitmap gets changed,
so for this case we do not need AssociatedAlpha and
watch for it to not have changed. Removed that.
Change-Id: I2ee36cc84bdc1c723aa01f872edbfd1f51e11c2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170305
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'drawinglayer/source/primitive2d')
-rw-r--r-- | drawinglayer/source/primitive2d/graphicprimitive2d.cxx | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx index 0f228c528a0e..2c97c809f4ff 100644 --- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx @@ -75,28 +75,41 @@ GraphicPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D&) co const GraphicObject& rGraphicObject = getGraphicObject(); Graphic aTransformedGraphic(rGraphicObject.GetGraphic()); - const bool isBitmap(GraphicType::Bitmap == aTransformedGraphic.GetType() - && !aTransformedGraphic.getVectorGraphicData()); const bool isAdjusted(getGraphicAttr().IsAdjusted()); const bool isDrawMode(GraphicDrawMode::Standard != getGraphicAttr().GetDrawMode()); - if (isBitmap && (isAdjusted || isDrawMode)) + // I have now added buffering BColorModifierStack-adapted Bitmaps, + // see BitmapEx::ModifyBitmapEx, thus the primitive case is fast now. + // It buffers the adapted bitmap and at that the SDPRs can then buffer + // the system-dependent represetation. + // I keep the code below (adding a static switch). It modifies the + // Graphic and is a reliable fallback - just in case. Remember that + // it does *not* buffer and has to modify again at each re-use... + static bool bUseOldModification(false); + + if (bUseOldModification) { - // the pure primitive solution with the color modifiers works well, too, but when - // it is a bitmap graphic the old modification currently is faster; so use it here - // instead of creating all as in create2DColorModifierEmbeddingsAsNeeded (see below). - // Still, crop, rotation, mirroring and transparency is handled by primitives already - // (see above). - // This could even be done when vector graphic, but we explicitly want to have the - // pure primitive solution for this; this will allow vector graphics to stay vector - // graphics, independent from the color filtering stuff. This will enhance e.g. - // SVG and print quality while reducing data size at the same time. - // The other way around the old modifications when only used on already bitmap objects - // will not lose any quality. - aTransformedGraphic = rGraphicObject.GetTransformedGraphic(&aSuppressGraphicAttr); - - // reset GraphicAttr after use to not apply double - aSuppressGraphicAttr = GraphicAttr(); + const bool isBitmap(GraphicType::Bitmap == aTransformedGraphic.GetType() + && !aTransformedGraphic.getVectorGraphicData()); + + if (isBitmap && (isAdjusted || isDrawMode)) + { + // the pure primitive solution with the color modifiers works well, too, but when + // it is a bitmap graphic the old modification currently is faster; so use it here + // instead of creating all as in create2DColorModifierEmbeddingsAsNeeded (see below). + // Still, crop, rotation, mirroring and transparency is handled by primitives already + // (see above). + // This could even be done when vector graphic, but we explicitly want to have the + // pure primitive solution for this; this will allow vector graphics to stay vector + // graphics, independent from the color filtering stuff. This will enhance e.g. + // SVG and print quality while reducing data size at the same time. + // The other way around the old modifications when only used on already bitmap objects + // will not lose any quality. + aTransformedGraphic = rGraphicObject.GetTransformedGraphic(&aSuppressGraphicAttr); + + // reset GraphicAttr after use to not apply double + aSuppressGraphicAttr = GraphicAttr(); + } } // create sub-content; helper takes care of correct handling of |