vcl/inc/salgdi.hxx | 7 ++++++- vcl/inc/salgdiimpl.hxx | 37 +++++++++++++++---------------------- vcl/source/outdev/bitmapex.cxx | 6 +++--- 3 files changed, 24 insertions(+), 26 deletions(-)
New commits: commit b9e1d9fac994754e775899889cf601d303dba688 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Wed Dec 8 09:43:13 2021 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Sat Dec 11 10:14:53 2021 +0100 explain the intent of HasDrawTransformedBitmap() better Change-Id: I32d6cfb7358dae25109de4db3332797763abc7d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126506 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index 716c9aa934a6..db3ed6806f7e 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -600,7 +600,12 @@ protected: const SalBitmap* pAlphaBitmap, double fAlpha) = 0; - /// Used e.g. by canvas to know whether to cache the drawing. + /// Returns true if the drawTransformedBitmap() call is fast, and so it should + /// be used directly without trying to optimize some calls e.g. by calling drawBitmap() + /// instead (which is faster for most VCL backends). These optimizations are not + /// done unconditionally because they may be counter-productive for some fast VCL backends + /// (for example, some OutputDevice optimizations could try access the pixels, which + /// would make performance worse for GPU-backed backends). /// See also tdf#138068. virtual bool hasFastDrawTransformedBitmap() const = 0; diff --git a/vcl/source/outdev/bitmapex.cxx b/vcl/source/outdev/bitmapex.cxx index 7855d1ae5613..55a166c6e5ba 100644 --- a/vcl/source/outdev/bitmapex.cxx +++ b/vcl/source/outdev/bitmapex.cxx @@ -525,6 +525,8 @@ void OutputDevice::DrawTransformedBitmapEx( if(rtl::math::approxEqual( fAlpha, 1.0 )) fAlpha = 1.0; // avoid the need for approxEqual in backends + // If the backend's implementation is known to not need any optimizations here, pass to it directly. + // With most backends it's more performant to try to simplify to DrawBitmapEx() first. if(bTryDirectPaint && mpGraphics->HasFastDrawTransformedBitmap() && DrawTransformBitmapExDirect(aFullTransform, bitmapEx)) return; @@ -562,11 +564,9 @@ void OutputDevice::DrawTransformedBitmapEx( return; } + // Try the backend's implementation before resorting to the slower fallback here. if(bTryDirectPaint && DrawTransformBitmapExDirect(aFullTransform, bitmapEx)) - { - // we are done return; - } // take the fallback when no rotate and shear, but mirror (else we would have done this above) if(!bRotated && !bSheared) commit 68ad2dd46dd42d81b576b3e61659c39f381790b6 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Wed Dec 8 09:34:07 2021 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Sat Dec 11 10:14:39 2021 +0100 don't duplicate SalGraphics docs in SalGraphicsImpl It's incomplete anyway, and it's annoying to do it twice. Simply refer to SalGraphics. Change-Id: I6a28709e2e68ba565176ea3ddf67bd17ecf3d1e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126505 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx index cb4bc35bd942..55f7544587ed 100644 --- a/vcl/inc/salgdiimpl.hxx +++ b/vcl/inc/salgdiimpl.hxx @@ -38,6 +38,15 @@ class Gradient; class SalVirtualDevice; struct SalGradient; +/** +Implementation class for SalGraphics. + +This class allows having an implementation of drawing calls that is separate from SalGraphics, +and SalGraphics can forward all such calls to SalGraphicsImpl. For example X11SalGraphics +may internally use either Xlib-based X11SalGraphicsImpl or Skia-based SkiaSalGraphicsImpl, +and the latter may be used also by other SalGraphics implementations. All the functions +here should be implementations of the relevant SalGraphics functions. +*/ class VCL_PLUGIN_PUBLIC SalGraphicsImpl { bool m_bAntiAlias; @@ -59,6 +68,10 @@ public: virtual ~SalGraphicsImpl(); + // All the functions are implementations of functions from the SalGraphics class, + // so see the SalGraphics class for documentation (both uppercase and lowercase + // function variants). + virtual void Init() = 0; virtual void DeInit() {} @@ -68,40 +81,27 @@ public: virtual OUString getRenderBackendName() const = 0; virtual bool setClipRegion( const vcl::Region& ) = 0; - // - // get the depth of the device + virtual sal_uInt16 GetBitCount() const = 0; - // get the width of the device virtual tools::Long GetGraphicsWidth() const = 0; - // set the clip region to empty virtual void ResetClipRegion() = 0; - // set the line color to transparent (= don't draw lines) - virtual void SetLineColor() = 0; - // set the line color to a specific color virtual void SetLineColor( Color nColor ) = 0; - // set the fill color to transparent (= don't fill) virtual void SetFillColor() = 0; - // set the fill color to a specific color, shapes will be - // filled accordingly virtual void SetFillColor( Color nColor ) = 0; - // enable/disable XOR drawing virtual void SetXORMode( bool bSet, bool bInvertOnly ) = 0; - // set line color for raster operations virtual void SetROPLineColor( SalROPColor nROPColor ) = 0; - // set fill color for raster operations virtual void SetROPFillColor( SalROPColor nROPColor ) = 0; - // draw --> LineColor and FillColor and RasterOp and ClipRegion virtual void drawPixel( tools::Long nX, tools::Long nY ) = 0; virtual void drawPixel( tools::Long nX, tools::Long nY, Color nColor ) = 0; @@ -125,7 +125,7 @@ public: const basegfx::B2DPolygon&, double fTransparency, double fLineWidth, - const std::vector< double >* pStroke, // MM01 + const std::vector< double >* pStroke, basegfx::B2DLineJoin, css::drawing::LineCap, double fMiterMinimumAngle, @@ -147,15 +147,12 @@ public: const Point* const* pPtAry, const PolyFlags* const* pFlgAry ) = 0; - // CopyArea --> No RasterOp, but ClipRegion virtual void copyArea( tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, tools::Long nSrcY, tools::Long nSrcWidth, tools::Long nSrcHeight, bool bWindowInvalidate ) = 0; - // CopyBits and DrawBitmap --> RasterOp and ClipRegion - // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) = 0; virtual void drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) = 0; @@ -174,7 +171,6 @@ public: virtual Color getPixel( tools::Long nX, tools::Long nY ) = 0; - // invert --> ClipRegion (only Windows or VirDevs) virtual void invert( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, @@ -203,7 +199,6 @@ public: const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap ) = 0; - /** draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system */ virtual bool drawTransformedBitmap( const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX, @@ -212,8 +207,6 @@ public: const SalBitmap* pAlphaBitmap, double fAlpha) = 0; - /// Used e.g. by canvas to know whether to cache the drawing. - /// See also tdf#138068. virtual bool hasFastDrawTransformedBitmap() const = 0; virtual bool drawAlphaRect(