diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-01-10 14:08:36 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-01-11 08:47:43 +0000 |
commit | f4b8dbe9c2d54494f2666df7eaeae19198158b9c (patch) | |
tree | 79d610bd80fbad617cca026602406b5d2a115fab /vcl/unx/generic/gdi | |
parent | 95756934cf56e4a9ff58464bc0ed6881c15fe411 (diff) |
reuse CairoCommon copyArea from X11CairoSalGraphicsImpl
Change-Id: I7a238add5daac622219fdfce253d97f30a844e9f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145267
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx/generic/gdi')
-rw-r--r-- | vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx | 28 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx | 12 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/gdiimpl.cxx | 111 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/gdiimpl.hxx | 11 |
4 files changed, 38 insertions, 124 deletions
diff --git a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx index c6c4af83039b..cdcaa291cfcf 100644 --- a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx +++ b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx @@ -131,4 +131,32 @@ bool X11CairoSalGraphicsImpl::supportsOperation(OutDevSupportType eType) const return CairoCommon::supportsOperation(eType); } +void X11CairoSalGraphicsImpl::copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, + tools::Long nSrcY, tools::Long nSrcWidth, + tools::Long nSrcHeight, bool /*bWindowInvalidate*/) +{ + SalTwoRect aTR(nSrcX, nSrcY, nSrcWidth, nSrcHeight, nDestX, nDestY, nSrcWidth, nSrcHeight); + + cairo_surface_t* source = mrCairoCommon.m_pSurface; + mrCairoCommon.copyBitsCairo(aTR, source, getAntiAlias()); +} + +void X11CairoSalGraphicsImpl::copyBits(const SalTwoRect& rTR, SalGraphics* pSrcGraphics) +{ + cairo_surface_t* source = nullptr; + + if (pSrcGraphics) + { + X11CairoSalGraphicsImpl* pSrc + = static_cast<X11CairoSalGraphicsImpl*>(pSrcGraphics->GetImpl()); + source = pSrc->mrCairoCommon.m_pSurface; + } + else + { + source = mrCairoCommon.m_pSurface; + } + + mrCairoCommon.copyBitsCairo(rTR, source, getAntiAlias()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx index 08704a642659..8bf49ec423de 100644 --- a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx +++ b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.hxx @@ -132,9 +132,17 @@ public: void invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags) override; - virtual bool hasFastDrawTransformedBitmap() const override; + // CopyArea --> No RasterOp, but ClipRegion + void copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, tools::Long nSrcY, + tools::Long nSrcWidth, tools::Long nSrcHeight, bool bWindowInvalidate) override; - virtual bool supportsOperation(OutDevSupportType eType) const override; + // CopyBits and DrawBitmap --> RasterOp and ClipRegion + // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics + void copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) override; + + bool hasFastDrawTransformedBitmap() const override; + + bool supportsOperation(OutDevSupportType eType) const override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx index 3e4256184674..bfe8995c025f 100644 --- a/vcl/unx/generic/gdi/gdiimpl.cxx +++ b/vcl/unx/generic/gdi/gdiimpl.cxx @@ -305,117 +305,6 @@ GC X11SalGraphicsImpl::SelectPen() return mpPenGC; } -void X11SalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, - SalGraphics *pSSrcGraphics ) -{ - X11SalGraphics* pSrcGraphics = pSSrcGraphics - ? static_cast<X11SalGraphics*>(pSSrcGraphics) - : &mrParent; - - if( rPosAry.mnSrcWidth <= 0 - || rPosAry.mnSrcHeight <= 0 - || rPosAry.mnDestWidth <= 0 - || rPosAry.mnDestHeight <= 0 ) - { - return; - } - - int n; - if( pSrcGraphics == &mrParent ) - { - n = 2; - } - else if( pSrcGraphics->bWindow_ ) - { - // window or compatible virtual device - if( pSrcGraphics->GetDisplay() == mrParent.GetDisplay() && - pSrcGraphics->m_nXScreen == mrParent.m_nXScreen && - pSrcGraphics->GetVisual().GetDepth() == mrParent.GetVisual().GetDepth() - ) - n = 2; // same Display - else - n = 1; // printer or other display - } - else if( pSrcGraphics->bVirDev_ ) - { - n = 1; // window or compatible virtual device - } - else - n = 0; - - if( n == 2 - && rPosAry.mnSrcWidth == rPosAry.mnDestWidth - && rPosAry.mnSrcHeight == rPosAry.mnDestHeight - ) - { - // #i60699# Need to generate graphics exposures (to repaint - // obscured areas beneath overlapping windows), src and dest - // are the same window. - const bool bNeedGraphicsExposures( pSrcGraphics == &mrParent && - !mrParent.bVirDev_ && - pSrcGraphics->bWindow_ ); - - GC pCopyGC = GetCopyGC(); - - if( bNeedGraphicsExposures ) - XSetGraphicsExposures( mrParent.GetXDisplay(), - pCopyGC, - True ); - - XCopyArea( mrParent.GetXDisplay(), - pSrcGraphics->GetDrawable(), // source - mrParent.GetDrawable(), // destination - pCopyGC, // destination clipping - rPosAry.mnSrcX, rPosAry.mnSrcY, - rPosAry.mnSrcWidth, rPosAry.mnSrcHeight, - rPosAry.mnDestX, rPosAry.mnDestY ); - - if( bNeedGraphicsExposures ) - { - mrParent.YieldGraphicsExpose(); - - if( pCopyGC ) - XSetGraphicsExposures( mrParent.GetXDisplay(), - pCopyGC, - False ); - } - } - else if( n ) - { - // #i60699# No chance to handle graphics exposures - we copy - // to a temp bitmap first, into which no repaints are - // technically possible. - std::shared_ptr<SalBitmap> xDDB(pSrcGraphics->getBitmap( rPosAry.mnSrcX, - rPosAry.mnSrcY, - rPosAry.mnSrcWidth, - rPosAry.mnSrcHeight )); - - if( !xDDB ) - { - SAL_WARN( "vcl", "SalGraphics::CopyBits !pSrcGraphics->GetBitmap()" ); - return; - } - - SalTwoRect aPosAry( rPosAry ); - - aPosAry.mnSrcX = 0; - aPosAry.mnSrcY = 0; - drawBitmap( aPosAry, *xDDB ); - } - else { - SAL_WARN( "vcl", "X11SalGraphicsImpl::CopyBits from Printer not yet implemented" ); - } -} - -void X11SalGraphicsImpl::copyArea ( tools::Long nDestX, tools::Long nDestY, - tools::Long nSrcX, tools::Long nSrcY, - tools::Long nSrcWidth, tools::Long nSrcHeight, - bool /*bWindowInvalidate*/) -{ - SalTwoRect aPosAry(nSrcX, nSrcY, nSrcWidth, nSrcHeight, nDestX, nDestY, nSrcWidth, nSrcHeight); - copyBits(aPosAry, nullptr); -} - void X11SalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) { const SalDisplay* pSalDisp = mrParent.GetDisplay(); diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx index 73bf4813ee42..974a7d168423 100644 --- a/vcl/unx/generic/gdi/gdiimpl.hxx +++ b/vcl/unx/generic/gdi/gdiimpl.hxx @@ -145,17 +145,6 @@ public: const Point* const* pPtAry, const PolyFlags* const* pFlgAry ) override; - // 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 ) override; - - // CopyBits and DrawBitmap --> RasterOp and ClipRegion - // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics - virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) override; - virtual void drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) override; virtual void drawBitmap( |