include/vcl/outdev.hxx | 2 include/vcl/window.hxx | 8 - include/vcl_canvas/spritecanvas.hxx | 1 sd/source/ui/slideshow/slideshowviewimpl.hxx | 5 slideshow/Library_slideshow.mk | 2 slideshow/source/engine/shapes/backgroundshape.cxx | 38 +++++ slideshow/source/engine/shapes/viewbackgroundshape.cxx | 19 ++ slideshow/source/engine/shapes/viewbackgroundshape.hxx | 4 slideshow/source/engine/shapes/viewshape.cxx | 119 ++++++++++------- slideshow/source/engine/shapes/viewshape.hxx | 6 slideshow/source/engine/slide/layermanager.cxx | 8 + slideshow/source/engine/slide/slideimpl.cxx | 12 + slideshow/source/engine/slideview.cxx | 24 +++ slideshow/source/inc/viewlayer.hxx | 2 vcl/canvas_inc/base/bufferedgraphicdevicebase.hxx | 61 +++++++- vcl/canvas_inc/cairo_spritecanvas.hxx | 8 - vcl/source/canvas/cairo/cairo_spritecanvashelper.cxx | 2 vcl/source/window/window.cxx | 28 ++-- 18 files changed, 253 insertions(+), 96 deletions(-)
New commits: commit f0b8a037d7db80db86eb444534a4768c5d4b68a1 Author: Shardul Vikram Singh <[email protected]> AuthorDate: Mon Aug 11 02:03:54 2025 +0530 Commit: Shardul Vikram Singh <[email protected]> CommitDate: Mon Aug 11 02:03:54 2025 +0530 Add primitives based rendering to BackgroundShape Fix SlideView::clear and SlideView::clearAll Change-Id: I6b98fe3b8f3082f7348281db1d9317a6a091fb5c diff --git a/slideshow/Library_slideshow.mk b/slideshow/Library_slideshow.mk index 155b8c791b78..accd9a5ca0b5 100644 --- a/slideshow/Library_slideshow.mk +++ b/slideshow/Library_slideshow.mk @@ -48,6 +48,7 @@ $(eval $(call gb_Library_use_libraries,slideshow,\ cppuhelper \ drawinglayer \ drawinglayercore \ + editeng \ sal \ salhelper \ svl \ diff --git a/slideshow/source/engine/shapes/backgroundshape.cxx b/slideshow/source/engine/shapes/backgroundshape.cxx index 33c5b89bcb0a..190e0f07f139 100644 --- a/slideshow/source/engine/shapes/backgroundshape.cxx +++ b/slideshow/source/engine/shapes/backgroundshape.cxx @@ -29,8 +29,19 @@ #include "backgroundshape.hxx" #include <slideshowexceptions.hxx> #include <slideshowcontext.hxx> +#include "basegfx/color/bcolor.hxx" +#include "com/sun/star/graphic/XPrimitiveFactory2D.hdl" +#include "drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx" +#include "drawinglayer/primitive2d/Primitive2DContainer.hxx" #include "gdimtftools.hxx" #include <shape.hxx> +#include "svx/sdr/contact/viewcontact.hxx" +#include "svx/svdmodel.hxx" +#include "svx/svdorect.hxx" +#include "svx/svdoutl.hxx" +#include "svx/svdpage.hxx" +#include "svx/unopage.hxx" +#include "svx/xlineit0.hxx" #include "viewbackgroundshape.hxx" @@ -106,6 +117,7 @@ namespace slideshow::internal /// the list of active view shapes (one for each registered view layer) typedef ::std::vector< ViewBackgroundShapeSharedPtr > ViewBackgroundShapeVector; ViewBackgroundShapeVector maViewShapes; + mutable drawinglayer::primitive2d::Primitive2DContainer mxPrimitive2DContainer; }; } @@ -147,6 +159,28 @@ namespace slideshow::internal mpMtf = std::move(xMtf); maBounds = ::basegfx::B2DRectangle( 0,0,nDocWidth, nDocHeight ); + + SvxDrawPage* pUnoPage = comphelper::getFromUnoTunnel<SvxDrawPage>(xDrawPage); + SdrModel* pDoc = &pUnoPage->GetSdrPage()->getSdrModelFromSdrPage(); + SdrPage* pPage = pUnoPage->GetSdrPage(); + const SdrPageProperties* pCorrectProperties = pPage->getCorrectSdrPageProperties(); + rtl::Reference<SdrObject> pTempBackgroundShape; + if(pCorrectProperties) + { + pTempBackgroundShape = new SdrRectObj( + *pDoc, + tools::Rectangle(Point(0,0), pPage->GetSize())); + pTempBackgroundShape->SetMergedItemSet(pCorrectProperties->GetItemSet()); + pTempBackgroundShape->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE)); + pTempBackgroundShape->NbcSetStyleSheet(pCorrectProperties->GetStyleSheet(), true); + } + if (pTempBackgroundShape.is()) + { + const sdr::contact::ViewContact& rSource(pTempBackgroundShape->GetViewContact()); + drawinglayer::primitive2d::Primitive2DContainer aSourceVal; + rSource.getViewIndependentPrimitive2DContainer(aSourceVal); + mxPrimitive2DContainer = aSourceVal.toSequence(); + } } uno::Reference< drawing::XShape > BackgroundShape::getXShape() const @@ -174,7 +208,7 @@ namespace slideshow::internal // render the Shape on the newly added ViewLayer if( bRedrawLayer ) - maViewShapes.back()->render( mpMtf ); + maViewShapes.back()->render( mpMtf, mxPrimitive2DContainer ); } bool BackgroundShape::removeViewLayer( const ViewLayerSharedPtr& rLayer ) @@ -272,7 +306,7 @@ namespace slideshow::internal if( o3tl::make_unsigned(::std::count_if( maViewShapes.begin(), maViewShapes.end(), [this]( const ViewBackgroundShapeSharedPtr& pBgShape ) - { return pBgShape->render( this->mpMtf ); } )) + { return pBgShape->render( this->mpMtf, this->mxPrimitive2DContainer ); } )) != maViewShapes.size() ) { // at least one of the ViewBackgroundShape::render() calls did return diff --git a/slideshow/source/engine/shapes/viewbackgroundshape.cxx b/slideshow/source/engine/shapes/viewbackgroundshape.cxx index 978ade81db84..fd74b7dc3467 100644 --- a/slideshow/source/engine/shapes/viewbackgroundshape.cxx +++ b/slideshow/source/engine/shapes/viewbackgroundshape.cxx @@ -23,6 +23,8 @@ #include <sal/log.hxx> #include "viewbackgroundshape.hxx" +#include "cairo_spritecanvas.hxx" +#include "drawinglayer/processor2d/cairopixelprocessor2d.hxx" #include <tools.hxx> #include <basegfx/numeric/ftools.hxx> @@ -139,7 +141,9 @@ namespace slideshow::internal return mpViewLayer; } - bool ViewBackgroundShape::render( const GDIMetaFileSharedPtr& rMtf ) const + bool ViewBackgroundShape::render( + const GDIMetaFileSharedPtr& rMtf, + drawinglayer::primitive2d::Primitive2DContainer& rContainer) const { SAL_INFO( "slideshow", "::presentation::internal::ViewBackgroundShape::draw()" ); @@ -179,7 +183,18 @@ namespace slideshow::internal TOOLS_WARN_EXCEPTION( "slideshow", "" ); return false; } - + cairo::SurfaceSharedPtr pSurface; + vcl_canvas::SpriteCanvasSharedPtr pSpriteCanvasAbstract + = mpViewLayer->getSpriteCanvas(); + std::shared_ptr<::vcl_cairocanvas::SpriteCanvas> pSpriteCanvas + = std::static_pointer_cast<::vcl_cairocanvas::SpriteCanvas>(pSpriteCanvasAbstract); + pSurface = pSpriteCanvas->getSurface(); + basegfx::B2DHomMatrix aMatrix(mpViewLayer->getTransformation()); + drawinglayer::geometry::ViewInformation2D aViewInormation; + aViewInormation.setViewTransformation(aMatrix); + drawinglayer::processor2d::CairoPixelProcessor2D aProcessor( + aViewInormation, pSurface->getCairoSurface().get()); + aProcessor.process(rContainer); return true; } diff --git a/slideshow/source/engine/shapes/viewbackgroundshape.hxx b/slideshow/source/engine/shapes/viewbackgroundshape.hxx index 50d8339c7882..1f7beacbf4f1 100644 --- a/slideshow/source/engine/shapes/viewbackgroundshape.hxx +++ b/slideshow/source/engine/shapes/viewbackgroundshape.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_VIEWBACKGROUNDSHAPE_HXX #define INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_VIEWBACKGROUNDSHAPE_HXX +#include "drawinglayer/primitive2d/Primitive2DContainer.hxx" #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/rendering/XBitmap.hpp> @@ -63,7 +64,8 @@ namespace slideshow::internal */ const ViewLayerSharedPtr& getViewLayer() const; - bool render( const GDIMetaFileSharedPtr& rMtf ) const; + bool render(const GDIMetaFileSharedPtr& rMtf, + drawinglayer::primitive2d::Primitive2DContainer& rContainer) const; private: /** Prefetch bitmap for given canvas diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx index 91e828e09ea0..f835363ccd69 100644 --- a/slideshow/source/engine/slide/slideimpl.cxx +++ b/slideshow/source/engine/slide/slideimpl.cxx @@ -273,10 +273,10 @@ public: void slideRenderer( SlideImpl const * pSlide, const UnoViewSharedPtr& rView ) { // fully clear view content to background color - rView->clearAll(); + // rView->clearAll(); - SlideBitmapSharedPtr pBitmap( pSlide->getCurrentSlideBitmap( rView ) ); - ::cppcanvas::CanvasSharedPtr pCanvas( rView->getCanvas() ); + // SlideBitmapSharedPtr pBitmap( pSlide->getCurrentSlideBitmap( rView ) ); + /* ::cppcanvas::CanvasSharedPtr pCanvas( rView->getCanvas() ); const ::basegfx::B2DHomMatrix aViewTransform( rView->getTransformation() ); const ::basegfx::B2DPoint aOutPosPixel( aViewTransform * ::basegfx::B2DPoint() ); @@ -292,7 +292,7 @@ void slideRenderer( SlideImpl const * pSlide, const UnoViewSharedPtr& rView ) // clear clip (might have been changed, e.g. from comb // transition) pBitmap->clip( ::basegfx::B2DPolyPolygon() ); - pBitmap->draw( pDevicePixelCanvas ); + pBitmap->draw( pDevicePixelCanvas ); */ } @@ -453,8 +453,10 @@ void SlideImpl::show( bool bSlideBackgroundPainted ) // render slide to screen, if requested if( !bSlideBackgroundPainted ) { - /* for( const auto& rContext : maContext.mrViewContainer ) - slideRenderer( this, rContext ); */ + for( const auto& rContext : maContext.mrViewContainer ) + { + // slideRenderer( this, rContext ); + } maContext.mrScreenUpdater.notifyUpdate(); } diff --git a/slideshow/source/engine/slideview.cxx b/slideshow/source/engine/slideview.cxx index b6efaa503c1f..53c20428fc00 100644 --- a/slideshow/source/engine/slideview.cxx +++ b/slideshow/source/engine/slideview.cxx @@ -861,6 +861,7 @@ void SlideView::clear() const { osl::MutexGuard aGuard( m_aMutex ); + getSpriteCanvas()->clear(); OSL_ENSURE( mxView.is() && mpCanvas, "SlideView::clear(): Disposed" ); if( !mxView.is() || !mpCanvas ) @@ -879,6 +880,7 @@ void SlideView::clearAll() const { osl::MutexGuard aGuard( m_aMutex ); + getSpriteCanvas()->clear(); OSL_ENSURE( mxView.is() && mpCanvas, "SlideView::clear(): Disposed" ); if( !mxView.is() || !mpCanvas ) commit c608e53b8283778e04837a93da144ef6ffb815af Author: Shardul Vikram Singh <[email protected]> AuthorDate: Sat Aug 9 15:31:44 2025 +0530 Commit: Shardul Vikram Singh <[email protected]> CommitDate: Sat Aug 9 15:31:44 2025 +0530 fix sprite resize in ViewShape::renderSprite(...) Change-Id: I2dbb171e1b4ddad29e4fe53dbdd6dc8e30e1b5b1 diff --git a/slideshow/source/engine/shapes/viewshape.cxx b/slideshow/source/engine/shapes/viewshape.cxx index 9e9104b242e6..f98c7ae0655d 100644 --- a/slideshow/source/engine/shapes/viewshape.cxx +++ b/slideshow/source/engine/shapes/viewshape.cxx @@ -378,7 +378,16 @@ namespace slideshow::internal { // TODO(F2): when the sprite _actually_ gets resized, // content needs a repaint! + + // probably inefficient see AnimatedSprite::resize for + // how it was being done originally // mpCustomSprite->resize( rSpriteSizePixel ); + mpCustomSprite->hide(); + vcl_canvas::SpriteCanvasSharedPtr pSpriteCanvasAbstract = mpViewLayer->getSpriteCanvas(); + auto xSpriteSizePixel = ::basegfx::unotools::size2DFromB2DSize(rSpriteSizePixel); + mpCustomSprite = pSpriteCanvasAbstract->createCustomSprite(xSpriteSizePixel); + mpCustomSprite->show(); + mbForceUpdate = true; } ENSURE_OR_RETURN_FALSE( mpCustomSprite, "ViewShape::renderSprite(): No sprite" ); commit 702d6a455daefe3c6aaaaf3281adcbe5b8c5cead Author: Shardul Vikram Singh <[email protected]> AuthorDate: Wed Aug 6 21:13:28 2025 +0530 Commit: Shardul Vikram Singh <[email protected]> CommitDate: Wed Aug 6 21:13:28 2025 +0530 refactor ViewShape::renderSprite(...) diff --git a/slideshow/source/engine/shapes/viewshape.cxx b/slideshow/source/engine/shapes/viewshape.cxx index 4e3fee8107e3..9e9104b242e6 100644 --- a/slideshow/source/engine/shapes/viewshape.cxx +++ b/slideshow/source/engine/shapes/viewshape.cxx @@ -51,6 +51,7 @@ #include "drawinglayer/processor2d/cairopixelprocessor2d.hxx" #include "sal/types.h" #include "vcl/outdev.hxx" +#include "vcl_canvas/customsprite.hxx" #include "vcl_canvas/spritecanvas.hxx" #include <basegfx/utils/canvastools.hxx> #include <tools.hxx> @@ -370,23 +371,24 @@ namespace slideshow::internal rSpriteSizePixel, nPrio ); */ vcl_canvas::SpriteCanvasSharedPtr pSpriteCanvasAbstract = mpViewLayer->getSpriteCanvas(); - mpCustomSprite = pSpriteCanvasAbstract->createCustomSprite(::basegfx::unotools::size2DFromB2DSize(rSpriteSizePixel)); + auto xSpriteSizePixel = ::basegfx::unotools::size2DFromB2DSize(rSpriteSizePixel); + mpCustomSprite = pSpriteCanvasAbstract->createCustomSprite(xSpriteSizePixel); } else { // TODO(F2): when the sprite _actually_ gets resized, // content needs a repaint! - mpCustomSprite->resize( rSpriteSizePixel ); +// mpCustomSprite->resize( rSpriteSizePixel ); } - ENSURE_OR_RETURN_FALSE( mpSprite, "ViewShape::renderSprite(): No sprite" ); + ENSURE_OR_RETURN_FALSE( mpCustomSprite, "ViewShape::renderSprite(): No sprite" ); SAL_INFO("slideshow", "ViewShape::renderSprite(): Rendering sprite " << - mpSprite.get() ); + mpCustomSprite.get() ); // always show the sprite (might have been hidden before) - mpSprite->show(); + mpCustomSprite->show(); // determine center of sprite output position in pixel // (assumption here: all shape transformations have the @@ -422,28 +424,37 @@ namespace slideshow::internal // NOTE: As for now, sprites are always positioned on // integer pixel positions on screen, have to round to // nearest integer here, too - mpSprite->setPixelOffset( - aAAOffset - ::basegfx::B2DSize( - ::basegfx::fround( rSpriteCorrectionOffset.getWidth() ), - ::basegfx::fround( rSpriteCorrectionOffset.getHeight() ) ) ); - - // always set sprite position and transformation, since - // they do not relate directly to the update flags - // (e.g. sprite position changes when sprite size changes) - mpSprite->movePixel( aSpritePosPixel ); - mpSprite->transform( getSpriteTransformation( basegfx::B2DVector(rSpriteSizePixel.getWidth(), rSpriteSizePixel.getHeight()), - rOrigBounds.getRange(), - pAttr ) ); +// mpSprite->setPixelOffset( +// aAAOffset - ::basegfx::B2DSize( +// ::basegfx::fround( rSpriteCorrectionOffset.getWidth() ), +// ::basegfx::fround( rSpriteCorrectionOffset.getHeight() ) ) ); + { + // always set sprite position and transformation, since + // they do not relate directly to the update flags + // (e.g. sprite position changes when sprite size changes) + rendering::ViewState aViewState; + rendering::RenderState aRenderState; + ::canvas::tools::initViewState(aViewState); + ::canvas::tools::initRenderState(aRenderState); + mpCustomSprite->move(::basegfx::unotools::point2DFromB2DPoint(aSpritePosPixel), + aViewState, aRenderState); + geometry::AffineMatrix2D aMatrix; + mpCustomSprite->transform(::basegfx::unotools::affineMatrixFromHomMatrix( + aMatrix, + getSpriteTransformation(basegfx::B2DVector(rSpriteSizePixel.getWidth(), + rSpriteSizePixel.getHeight()), + rOrigBounds.getRange(), pAttr))); + } // process flags // ============= - bool bRedrawRequired( mbForceUpdate || (nUpdateFlags & UpdateFlags::Force) ); + bool bRedrawRequired(mbForceUpdate || (nUpdateFlags & UpdateFlags::Force)); if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Alpha) ) { - mpSprite->setAlpha( (pAttr && pAttr->isAlphaValid()) ? + mpCustomSprite->setAlpha( (pAttr && pAttr->isAlphaValid()) ? std::clamp(pAttr->getAlpha(), 0.0, 1.0) : @@ -473,10 +484,10 @@ namespace slideshow::internal // coordinate space aClipPoly.transform( aViewTransform ); - mpSprite->clip( aClipPoly ); +// mpSprite->clip( aClipPoly ); } - else - mpSprite->clip(); +// else +// mpSprite->clip(); } if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Content) ) { @@ -499,12 +510,10 @@ namespace slideshow::internal // sprite needs repaint - output to sprite canvas // ============================================== - ::cppcanvas::CanvasSharedPtr pContentCanvas(mpSprite->getContentCanvas()); - cairocanvas::CanvasCustomSprite* pCanvasCustomSprite - = static_cast<cairocanvas::CanvasCustomSprite*>( - pContentCanvas->getUNOCanvas().get()); + ::vcl_canvas::CanvasSharedPtr pContentCanvas(mpCustomSprite->getContentCanvas()); + auto pCanvasCustomSprite + = std::static_pointer_cast<::vcl_cairocanvas::CanvasCustomSprite>(pContentCanvas); cairo::SurfaceSharedPtr pSurface = pCanvasCustomSprite->getSurface(); - pSurface = pCanvasCustomSprite->getSurface(); /* return draw( pContentCanvas, rMtf, @@ -742,7 +751,7 @@ namespace slideshow::internal ViewShape::ViewShape( ViewLayerSharedPtr xViewLayer ) : mpViewLayer(std::move( xViewLayer )), maRenderers(), - mpSprite(), + /* mpSprite(), */ mbAnimationMode( false ), mbForceUpdate( true ) { @@ -850,7 +859,7 @@ namespace slideshow::internal void ViewShape::leaveAnimationMode() { - mpSprite.reset(); + mpCustomSprite.reset(); mbAnimationMode = false; mbForceUpdate = true; } diff --git a/slideshow/source/engine/shapes/viewshape.hxx b/slideshow/source/engine/shapes/viewshape.hxx index b3deebe6869a..c8807619f69e 100644 --- a/slideshow/source/engine/shapes/viewshape.hxx +++ b/slideshow/source/engine/shapes/viewshape.hxx @@ -312,13 +312,14 @@ namespace slideshow::internal mutable RendererCacheVector maRenderers; /// The sprite object - mutable AnimatedSpriteSharedPtr mpSprite; +// mutable AnimatedSpriteSharedPtr mpSprite; /// If true, render() calls go to the sprite mutable bool mbAnimationMode; /// If true, shape needs full repaint (and the sprite a setup, if any) mutable bool mbForceUpdate; + mutable ::vcl_canvas::CustomSpriteSharedPtr mpCustomSprite; }; typedef ::std::shared_ptr< ViewShape > ViewShapeSharedPtr; diff --git a/slideshow/source/engine/slideview.cxx b/slideshow/source/engine/slideview.cxx index d1755e4e5f73..b6efaa503c1f 100644 --- a/slideshow/source/engine/slideview.cxx +++ b/slideshow/source/engine/slideview.cxx @@ -549,6 +549,7 @@ private: virtual void clearAll() const override { + getSpriteCanvas()->clear(); // grab canvas - that also lazy-initializes maLayerBoundsPixel ::cppcanvas::CanvasSharedPtr pCanvas( getCanvas()->clone() ); diff --git a/vcl/source/canvas/cairo/cairo_spritecanvashelper.cxx b/vcl/source/canvas/cairo/cairo_spritecanvashelper.cxx index c1f63cc1d444..c9c7be87140a 100644 --- a/vcl/source/canvas/cairo/cairo_spritecanvashelper.cxx +++ b/vcl/source/canvas/cairo/cairo_spritecanvashelper.cxx @@ -131,7 +131,7 @@ namespace vcl_cairocanvas ::vcl_canvas::CustomSpriteSharedPtr SpriteCanvasHelper::createCustomSprite( const geometry::RealSize2D& spriteSize ) { - if( !mpRedrawManager || mpOwningSpriteCanvas.lock()) + if( !mpRedrawManager || !mpOwningSpriteCanvas.lock()) return nullptr; // we're disposed return std::make_shared<CanvasCustomSprite>( spriteSize, commit 92fe4a037794d5d742799f7309dc7c1c7b73d2e0 Author: Shardul Vikram Singh <[email protected]> AuthorDate: Mon Aug 4 19:55:18 2025 +0530 Commit: Shardul Vikram Singh <[email protected]> CommitDate: Mon Aug 4 19:55:18 2025 +0530 Uncomment ViewShape::renderSprite( ... ) Change-Id: Id2fb137e2fc2c4bb9490af9c39bed520a19fa1b1 diff --git a/slideshow/source/engine/shapes/viewshape.cxx b/slideshow/source/engine/shapes/viewshape.cxx index b4e571f87016..4e3fee8107e3 100644 --- a/slideshow/source/engine/shapes/viewshape.cxx +++ b/slideshow/source/engine/shapes/viewshape.cxx @@ -301,230 +301,230 @@ namespace slideshow::internal double nPrio, bool bIsVisible ) const { -// // TODO(P1): For multiple views, it might pay off to reorg Shape and ViewShape, -// // in that all the common setup steps here are refactored to Shape (would then -// // have to be performed only _once_ per Shape paint). -// -// if( !bIsVisible || -// rUnitBounds.isEmpty() || -// rOrigBounds.isEmpty() || -// rBounds.isEmpty() ) -// { -// // shape is invisible or has zero size, no need to -// // update anything. -// if( mpCustomSprite ) -// mpCustomSprite->hide(); -// -// return true; -// } -// -// -// // calc sprite position, size and content transformation -// // ===================================================== -// -// // the shape transformation for a sprite is always a -// // simple scale-up to the nominal shape size. Everything -// // else is handled via the sprite transformation -// ::basegfx::B2DHomMatrix aNonTranslationalShapeTransformation; -// aNonTranslationalShapeTransformation.scale( rOrigBounds.getWidth(), -// rOrigBounds.getHeight() ); -// ::basegfx::B2DHomMatrix aShapeTransformation( aNonTranslationalShapeTransformation ); -// aShapeTransformation.translate( rOrigBounds.getMinX(), -// rOrigBounds.getMinY() ); -// -// const ::basegfx::B2DHomMatrix aCanvasTransform( -// rViewLayer->getSpriteTransformation() ); -// -// // area actually needed for the sprite -// const ::basegfx::B2DRectangle aSpriteBoundsPixel( -// calcUpdateAreaPixel( rUnitBounds, -// aShapeTransformation, -// aCanvasTransform, -// pAttr ) ); -// -// // actual area for the shape (without subsetting, but -// // including char scaling) -// const ::basegfx::B2DRectangle aShapeBoundsPixel( -// calcUpdateAreaPixel( ::basegfx::B2DRectangle(0.0,0.0,1.0,1.0), -// aShapeTransformation, -// aCanvasTransform, -// pAttr ) ); -// -// // nominal area for the shape (without subsetting, without -// // char scaling). NOTE: to cancel the shape translation, -// // contained in rSpriteBoundsPixel, this is _without_ any -// // translational component. -// const ::basegfx::B2DRectangle aNominalShapeBoundsPixel( -// shapeArea2AreaPixel( aCanvasTransform, -// ::canvas::tools::calcTransformedRectBounds( -// ::basegfx::B2DRectangle(0.0,0.0,1.0,1.0), -// aNonTranslationalShapeTransformation ) ) ); -// -// // create (or resize) sprite with sprite's pixel size, if -// // not done already -// auto aRange = aSpriteBoundsPixel.getRange(); -// basegfx::B2DSize rSpriteSizePixel(aRange.getX(), aRange.getY()); -// if( !mpCustomSprite ) -// { -// /* mpSprite = std::make_shared<AnimatedSprite>( mpViewLayer, -// rSpriteSizePixel, -// nPrio ); */ -// vcl_canvas::SpriteCanvasSharedPtr pSpriteCanvasAbstract = mpViewLayer->getSpriteCanvas(); -// mpCustomSprite = pSpriteCanvasAbstract->createCustomSprite(::basegfx::unotools::size2DFromB2DSize(rSpriteSizePixel)); -// } -// else -// { -// // TODO(F2): when the sprite _actually_ gets resized, -// // content needs a repaint! -// mpCustomSprite->resize( rSpriteSizePixel ); -// } -// -// ENSURE_OR_RETURN_FALSE( mpSprite, "ViewShape::renderSprite(): No sprite" ); -// -// SAL_INFO("slideshow", "ViewShape::renderSprite(): Rendering sprite " << -// mpSprite.get() ); -// -// -// // always show the sprite (might have been hidden before) -// mpSprite->show(); -// -// // determine center of sprite output position in pixel -// // (assumption here: all shape transformations have the -// // shape center as the pivot point). From that, subtract -// // distance of rSpriteBoundsPixel's left, top edge from -// // rShapeBoundsPixel's center. This moves the sprite at -// // the appropriate output position within the virtual -// // rShapeBoundsPixel area. -// ::basegfx::B2DPoint aSpritePosPixel( rBounds.getCenter() ); -// aSpritePosPixel *= aCanvasTransform; -// aSpritePosPixel -= aShapeBoundsPixel.getCenter() - aSpriteBoundsPixel.getMinimum(); -// -// // the difference between rShapeBoundsPixel and -// // rSpriteBoundsPixel upper, left corner is: the offset we -// // have to move sprite output to the right, top (to make -// // the desired subset content visible at all) -// auto aDifference = aSpriteBoundsPixel.getMinimum() - aNominalShapeBoundsPixel.getMinimum(); -// const basegfx::B2DSize rSpriteCorrectionOffset(aDifference.getX(), aDifference.getY()); -// -// // offset added top, left for anti-aliasing (otherwise, -// // shapes fully filling the sprite will have anti-aliased -// // pixel cut off) -// const ::basegfx::B2DSize aAAOffset( -// ::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE, -// ::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE ); -// -// // set pixel output offset to sprite: we always leave -// // ANTIALIASING_EXTRA_SIZE room atop and to the left, and, -// // what's more, for subsetted shapes, we _have_ to cancel -// // the effect of the shape renderer outputting the subset -// // at its absolute position inside the shape, instead of -// // at the origin. -// // NOTE: As for now, sprites are always positioned on -// // integer pixel positions on screen, have to round to -// // nearest integer here, too -// mpSprite->setPixelOffset( -// aAAOffset - ::basegfx::B2DSize( -// ::basegfx::fround( rSpriteCorrectionOffset.getWidth() ), -// ::basegfx::fround( rSpriteCorrectionOffset.getHeight() ) ) ); -// -// // always set sprite position and transformation, since -// // they do not relate directly to the update flags -// // (e.g. sprite position changes when sprite size changes) -// mpSprite->movePixel( aSpritePosPixel ); -// mpSprite->transform( getSpriteTransformation( basegfx::B2DVector(rSpriteSizePixel.getWidth(), rSpriteSizePixel.getHeight()), -// rOrigBounds.getRange(), -// pAttr ) ); -// -// -// // process flags -// // ============= -// -// bool bRedrawRequired( mbForceUpdate || (nUpdateFlags & UpdateFlags::Force) ); -// -// if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Alpha) ) -// { -// mpSprite->setAlpha( (pAttr && pAttr->isAlphaValid()) ? -// std::clamp(pAttr->getAlpha(), -// 0.0, -// 1.0) : -// 1.0 ); -// } -// if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Clip) ) -// { -// if( pAttr && pAttr->isClipValid() ) -// { -// ::basegfx::B2DPolyPolygon aClipPoly( pAttr->getClip() ); -// -// // extract linear part of canvas view transformation -// // (linear means: without translational components) -// ::basegfx::B2DHomMatrix aViewTransform( -// mpViewLayer->getTransformation() ); -// aViewTransform.set( 0, 2, 0.0 ); -// aViewTransform.set( 1, 2, 0.0 ); -// -// // make the clip 2*ANTIALIASING_EXTRA_SIZE larger -// // such that it's again centered over the sprite. -// aViewTransform.scale(rSpriteSizePixel.getWidth()/ -// (rSpriteSizePixel.getWidth()-2*::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE), -// rSpriteSizePixel.getHeight()/ -// (rSpriteSizePixel.getHeight()-2*::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE)); -// -// // transform clip polygon from view to device -// // coordinate space -// aClipPoly.transform( aViewTransform ); -// -// mpSprite->clip( aClipPoly ); -// } -// else -// mpSprite->clip(); -// } -// if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Content) ) -// { -// bRedrawRequired = true; -// -// // TODO(P1): maybe provide some appearance change methods at -// // the Renderer interface -// -// // force the renderer to be regenerated below, for the -// // different attributes to take effect -// invalidateRenderer(); -// } -// -// mbForceUpdate = false; -// -// if( !bRedrawRequired ) -// return true; -// -// -// // sprite needs repaint - output to sprite canvas -// // ============================================== -// -// ::cppcanvas::CanvasSharedPtr pContentCanvas(mpSprite->getContentCanvas()); -// cairocanvas::CanvasCustomSprite* pCanvasCustomSprite -// = static_cast<cairocanvas::CanvasCustomSprite*>( -// pContentCanvas->getUNOCanvas().get()); -// cairo::SurfaceSharedPtr pSurface = pCanvasCustomSprite->getSurface(); -// pSurface = pCanvasCustomSprite->getSurface(); -// -// /* return draw( pContentCanvas, -// rMtf, -// pAttr, -// aShapeTransformation, -// nullptr, // clipping is done via Sprite::clip() -// rSubsets ); */ -// -// drawinglayer::geometry::ViewInformation2D aViewInformation; -// basegfx::B2DHomMatrix aMatrix(rViewLayer->getTransformation()); -// const ::basegfx::B2DPoint aAAGap(::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE, -// ::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE); -// // Bring the renderable area of the shape to the origin -// aMatrix.translate(-aSpriteBoundsPixel.getMinimum() + aAAGap); -// aViewInformation.setViewTransformation(aMatrix); -// drawinglayer::processor2d::CairoPixelProcessor2D aProcessor( -// aViewInformation, pSurface->getCairoSurface().get()); -// aProcessor.process(rContainer); -// -// return true; + // TODO(P1): For multiple views, it might pay off to reorg Shape and ViewShape, + // in that all the common setup steps here are refactored to Shape (would then + // have to be performed only _once_ per Shape paint). + + if( !bIsVisible || + rUnitBounds.isEmpty() || + rOrigBounds.isEmpty() || + rBounds.isEmpty() ) + { + // shape is invisible or has zero size, no need to + // update anything. + if( mpCustomSprite ) + mpCustomSprite->hide(); + + return true; + } + + + // calc sprite position, size and content transformation + // ===================================================== + + // the shape transformation for a sprite is always a + // simple scale-up to the nominal shape size. Everything + // else is handled via the sprite transformation + ::basegfx::B2DHomMatrix aNonTranslationalShapeTransformation; + aNonTranslationalShapeTransformation.scale( rOrigBounds.getWidth(), + rOrigBounds.getHeight() ); + ::basegfx::B2DHomMatrix aShapeTransformation( aNonTranslationalShapeTransformation ); + aShapeTransformation.translate( rOrigBounds.getMinX(), + rOrigBounds.getMinY() ); + + const ::basegfx::B2DHomMatrix aCanvasTransform( + rViewLayer->getSpriteTransformation() ); + + // area actually needed for the sprite + const ::basegfx::B2DRectangle aSpriteBoundsPixel( + calcUpdateAreaPixel( rUnitBounds, + aShapeTransformation, + aCanvasTransform, + pAttr ) ); + + // actual area for the shape (without subsetting, but + // including char scaling) + const ::basegfx::B2DRectangle aShapeBoundsPixel( + calcUpdateAreaPixel( ::basegfx::B2DRectangle(0.0,0.0,1.0,1.0), + aShapeTransformation, + aCanvasTransform, + pAttr ) ); + + // nominal area for the shape (without subsetting, without + // char scaling). NOTE: to cancel the shape translation, + // contained in rSpriteBoundsPixel, this is _without_ any + // translational component. + const ::basegfx::B2DRectangle aNominalShapeBoundsPixel( + shapeArea2AreaPixel( aCanvasTransform, + ::canvas::tools::calcTransformedRectBounds( + ::basegfx::B2DRectangle(0.0,0.0,1.0,1.0), + aNonTranslationalShapeTransformation ) ) ); + + // create (or resize) sprite with sprite's pixel size, if + // not done already + auto aRange = aSpriteBoundsPixel.getRange(); + basegfx::B2DSize rSpriteSizePixel(aRange.getX(), aRange.getY()); + if( !mpCustomSprite ) + { + /* mpSprite = std::make_shared<AnimatedSprite>( mpViewLayer, + rSpriteSizePixel, + nPrio ); */ + vcl_canvas::SpriteCanvasSharedPtr pSpriteCanvasAbstract = mpViewLayer->getSpriteCanvas(); + mpCustomSprite = pSpriteCanvasAbstract->createCustomSprite(::basegfx::unotools::size2DFromB2DSize(rSpriteSizePixel)); + } + else + { + // TODO(F2): when the sprite _actually_ gets resized, + // content needs a repaint! + mpCustomSprite->resize( rSpriteSizePixel ); + } + + ENSURE_OR_RETURN_FALSE( mpSprite, "ViewShape::renderSprite(): No sprite" ); + + SAL_INFO("slideshow", "ViewShape::renderSprite(): Rendering sprite " << + mpSprite.get() ); + + + // always show the sprite (might have been hidden before) + mpSprite->show(); + + // determine center of sprite output position in pixel + // (assumption here: all shape transformations have the + // shape center as the pivot point). From that, subtract + // distance of rSpriteBoundsPixel's left, top edge from + // rShapeBoundsPixel's center. This moves the sprite at + // the appropriate output position within the virtual + // rShapeBoundsPixel area. + ::basegfx::B2DPoint aSpritePosPixel( rBounds.getCenter() ); + aSpritePosPixel *= aCanvasTransform; + aSpritePosPixel -= aShapeBoundsPixel.getCenter() - aSpriteBoundsPixel.getMinimum(); + + // the difference between rShapeBoundsPixel and + // rSpriteBoundsPixel upper, left corner is: the offset we + // have to move sprite output to the right, top (to make + // the desired subset content visible at all) + auto aDifference = aSpriteBoundsPixel.getMinimum() - aNominalShapeBoundsPixel.getMinimum(); + const basegfx::B2DSize rSpriteCorrectionOffset(aDifference.getX(), aDifference.getY()); + + // offset added top, left for anti-aliasing (otherwise, + // shapes fully filling the sprite will have anti-aliased + // pixel cut off) + const ::basegfx::B2DSize aAAOffset( + ::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE, + ::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE ); + + // set pixel output offset to sprite: we always leave + // ANTIALIASING_EXTRA_SIZE room atop and to the left, and, + // what's more, for subsetted shapes, we _have_ to cancel + // the effect of the shape renderer outputting the subset + // at its absolute position inside the shape, instead of + // at the origin. + // NOTE: As for now, sprites are always positioned on + // integer pixel positions on screen, have to round to + // nearest integer here, too + mpSprite->setPixelOffset( + aAAOffset - ::basegfx::B2DSize( + ::basegfx::fround( rSpriteCorrectionOffset.getWidth() ), + ::basegfx::fround( rSpriteCorrectionOffset.getHeight() ) ) ); + + // always set sprite position and transformation, since + // they do not relate directly to the update flags + // (e.g. sprite position changes when sprite size changes) + mpSprite->movePixel( aSpritePosPixel ); + mpSprite->transform( getSpriteTransformation( basegfx::B2DVector(rSpriteSizePixel.getWidth(), rSpriteSizePixel.getHeight()), + rOrigBounds.getRange(), + pAttr ) ); + + + // process flags + // ============= + + bool bRedrawRequired( mbForceUpdate || (nUpdateFlags & UpdateFlags::Force) ); + + if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Alpha) ) + { + mpSprite->setAlpha( (pAttr && pAttr->isAlphaValid()) ? + std::clamp(pAttr->getAlpha(), + 0.0, + 1.0) : + 1.0 ); + } + if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Clip) ) + { + if( pAttr && pAttr->isClipValid() ) + { + ::basegfx::B2DPolyPolygon aClipPoly( pAttr->getClip() ); + + // extract linear part of canvas view transformation + // (linear means: without translational components) + ::basegfx::B2DHomMatrix aViewTransform( + mpViewLayer->getTransformation() ); + aViewTransform.set( 0, 2, 0.0 ); + aViewTransform.set( 1, 2, 0.0 ); + + // make the clip 2*ANTIALIASING_EXTRA_SIZE larger + // such that it's again centered over the sprite. + aViewTransform.scale(rSpriteSizePixel.getWidth()/ + (rSpriteSizePixel.getWidth()-2*::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE), + rSpriteSizePixel.getHeight()/ + (rSpriteSizePixel.getHeight()-2*::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE)); + + // transform clip polygon from view to device + // coordinate space + aClipPoly.transform( aViewTransform ); + + mpSprite->clip( aClipPoly ); + } + else + mpSprite->clip(); + } + if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Content) ) + { + bRedrawRequired = true; + + // TODO(P1): maybe provide some appearance change methods at + // the Renderer interface + + // force the renderer to be regenerated below, for the + // different attributes to take effect + invalidateRenderer(); + } + + mbForceUpdate = false; + + if( !bRedrawRequired ) + return true; + + + // sprite needs repaint - output to sprite canvas + // ============================================== + + ::cppcanvas::CanvasSharedPtr pContentCanvas(mpSprite->getContentCanvas()); + cairocanvas::CanvasCustomSprite* pCanvasCustomSprite + = static_cast<cairocanvas::CanvasCustomSprite*>( + pContentCanvas->getUNOCanvas().get()); + cairo::SurfaceSharedPtr pSurface = pCanvasCustomSprite->getSurface(); + pSurface = pCanvasCustomSprite->getSurface(); + + /* return draw( pContentCanvas, + rMtf, + pAttr, + aShapeTransformation, + nullptr, // clipping is done via Sprite::clip() + rSubsets ); */ + + drawinglayer::geometry::ViewInformation2D aViewInformation; + basegfx::B2DHomMatrix aMatrix(rViewLayer->getTransformation()); + const ::basegfx::B2DPoint aAAGap(::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE, + ::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE); + // Bring the renderable area of the shape to the origin + aMatrix.translate(-aSpriteBoundsPixel.getMinimum() + aAAGap); + aViewInformation.setViewTransformation(aMatrix); + drawinglayer::processor2d::CairoPixelProcessor2D aProcessor( + aViewInformation, pSurface->getCairoSurface().get()); + aProcessor.process(rContainer); + + return true; } bool ViewShape::render( const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas, commit 015ceb772ee84823825c8b4a8fdbe58012e5a39c Author: Shardul Vikram Singh <[email protected]> AuthorDate: Sun Aug 3 21:11:06 2025 +0530 Commit: Shardul Vikram Singh <[email protected]> CommitDate: Sun Aug 3 21:11:06 2025 +0530 add updateScreen calls Change-Id: I4605d4a3279e25af86ddbb434f2b4aed5d78398d diff --git a/slideshow/source/engine/slideview.cxx b/slideshow/source/engine/slideview.cxx index 8cf3acefc437..d1755e4e5f73 100644 --- a/slideshow/source/engine/slideview.cxx +++ b/slideshow/source/engine/slideview.cxx @@ -841,7 +841,8 @@ bool SlideView::updateScreen() const ENSURE_OR_RETURN_FALSE( mpCanvas, "SlideView::updateScreen(): Disposed" ); - return mpCanvas->updateScreen( false ); + return getSpriteCanvas()->updateScreen(false); + // return mpCanvas->updateScreen( false ); } bool SlideView::paintScreen() const @@ -851,7 +852,8 @@ bool SlideView::paintScreen() const ENSURE_OR_RETURN_FALSE( mpCanvas, "SlideView::paintScreen(): Disposed" ); - return mpCanvas->updateScreen( true ); + return getSpriteCanvas()->updateScreen(true); + // return mpCanvas->updateScreen( true ); } void SlideView::clear() const commit 653f8614bea45878bbb226cea44efff553bc9a6b Author: Shardul Vikram Singh <[email protected]> AuthorDate: Sat Aug 2 18:40:28 2025 +0530 Commit: Shardul Vikram Singh <[email protected]> CommitDate: Sat Aug 2 18:40:28 2025 +0530 Fix args passed to vcl_cairocanvas::SpriteCanvas Change-Id: I749b492a18b9c923e63fb589e4dd3410e32ebbb6 diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index aeed95955e2e..b5945e25d3f4 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -201,12 +201,14 @@ private: tools::Long mnOutOffOrigY; /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset) tools::Long mnOutOffLogicY; +public: /// Output offset for device output in pixel (pseudo window offset within window system's frames) tools::Long mnOutOffX; /// Output offset for device output in pixel (pseudo window offset within window system's frames) tools::Long mnOutOffY; tools::Long mnOutWidth; tools::Long mnOutHeight; +private: sal_Int32 mnDPIX; sal_Int32 mnDPIY; sal_Int32 mnDPIScalePercentage; ///< For HiDPI displays, we want to draw elements for a percentage larger diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 417d302fef10..2f0f9943beba 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -473,6 +473,7 @@ private: // but use class WindowImpl instead std::unique_ptr<WindowImpl> mpWindowImpl; + std::shared_ptr<vcl_canvas::SpriteCanvas> mpSpriteCanvas; #ifdef DBG_UTIL friend const char* ::ImplDbgCheckWindow( const void* pObj ); diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index db07cbafaa11..d2a94f0bf907 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -578,18 +578,23 @@ Window::~Window() std::shared_ptr<::vcl_canvas::SpriteCanvas> Window::GetSpriteCanvas() { - const Sequence< Any > aArg{ - Any(reinterpret_cast<sal_Int64>(GetOutDev())), - Any(css::awt::Rectangle( 0, 0, 0, 0 )), - Any(false), - Any(Reference< css::awt::XWindow >()), - GetOutDev()->GetSystemGfxDataAny() - }; + if(mpSpriteCanvas) + return mpSpriteCanvas; + const Sequence<Any> aArg{ Any(reinterpret_cast<sal_Int64>(mpWindowImpl->mxOutDev.get())), + Any(css::awt::Rectangle(mpWindowImpl->mxOutDev->mnOutOffX, + mpWindowImpl->mxOutDev->mnOutOffY, + mpWindowImpl->mxOutDev->mnOutWidth, + mpWindowImpl->mxOutDev->mnOutHeight)), + Any(mpWindowImpl->mbAlwaysOnTop), + Any(Reference<css::awt::XWindow>(GetComponentInterface(), UNO_QUERY)), + mpWindowImpl->mxOutDev->GetSystemGfxDataAny() }; const Reference< XComponentContext >& xContext = comphelper::getProcessComponentContext(); - auto pSpriteCanvas = std::shared_ptr<vcl_cairocanvas::SpriteCanvas>( + auto mpSpriteCanvasImpl = std::shared_ptr<vcl_cairocanvas::SpriteCanvas>( new vcl_cairocanvas::SpriteCanvas(aArg, xContext) ); - return pSpriteCanvas; + mpSpriteCanvasImpl->initialize(); + mpSpriteCanvas = mpSpriteCanvasImpl; + return mpSpriteCanvas; } Color WindowOutputDevice::GetBackgroundColor() const commit 12356f734e445b9344d6f056ea118ab39ce6bbfe Author: Shardul Vikram Singh <[email protected]> AuthorDate: Sat Aug 2 01:27:49 2025 +0530 Commit: Shardul Vikram Singh <[email protected]> CommitDate: Sat Aug 2 01:27:49 2025 +0530 Compiles but nothing works diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 7cca00775eba..417d302fef10 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -32,6 +32,7 @@ #include <rtl/ustring.hxx> #include <com/sun/star/uno/Reference.hxx> #include <memory> +#include <vcl_canvas/spritecanvas.hxx> struct ImplSVEvent; struct ImplWinData; @@ -85,10 +86,6 @@ namespace vcl { struct ControlLayoutData; } -namespace vcl_cairocanvas { - class SpriteCanvas; -} - namespace svt { class PopupWindowControllerImpl; } namespace weld { class Window; } @@ -555,7 +552,7 @@ public: void DecModalCount(); SAL_DLLPRIVATE static void ImplCalcSymbolRect( tools::Rectangle& rRect ); - std::shared_ptr<vcl_cairocanvas::SpriteCanvas> GetSpriteCanvas(); + std::shared_ptr<::vcl_canvas::SpriteCanvas> GetSpriteCanvas(); protected: diff --git a/include/vcl_canvas/spritecanvas.hxx b/include/vcl_canvas/spritecanvas.hxx index 5ec9e6512be6..cd0f885667b5 100644 --- a/include/vcl_canvas/spritecanvas.hxx +++ b/include/vcl_canvas/spritecanvas.hxx @@ -1,6 +1,5 @@ #pragma once -#include <com/sun/star/rendering/XAnimation.hpp> #include <com/sun/star/rendering/XBitmap.hpp> #include "canvas.hxx" #include "customsprite.hxx" diff --git a/sd/source/ui/slideshow/slideshowviewimpl.hxx b/sd/source/ui/slideshow/slideshowviewimpl.hxx index 0e9c0a601123..07f9abd77e94 100644 --- a/sd/source/ui/slideshow/slideshowviewimpl.hxx +++ b/sd/source/ui/slideshow/slideshowviewimpl.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/presentation/XSlideShowView.hpp> #include <cppcanvas/spritecanvas.hxx> #include <cppuhelper/weakref.hxx> +#include <vcl_canvas/spritecanvas.hxx> #include <memory> #include <slideshow.hxx> @@ -34,7 +35,6 @@ namespace com::sun::star::awt { class XPointer; } namespace com::sun::star::awt { class XWindow; } namespace com::sun::star::awt { class XWindowPeer; } -namespace vcl_cairocanvas { class SpriteCanvas; } class SdDrawDocument; namespace sd @@ -159,7 +159,7 @@ private: void disposingImpl( std::unique_lock<std::mutex>& ); ::cppcanvas::SpriteCanvasSharedPtr mpCanvas; - std::shared_ptr<vcl_cairocanvas::SpriteCanvas> mpSpriteCanvas; + std::shared_ptr<vcl_canvas::SpriteCanvas> mpSpriteCanvas; css::uno::Reference< css::awt::XWindow > mxWindow; css::uno::Reference< css::awt::XWindowPeer > mxWindowPeer; css::uno::Reference< css::awt::XPointer > mxPointer; @@ -178,6 +178,7 @@ private: css::geometry::IntegerSize2D mTranslationOffset; public: ShowWindow& getOutWin() { return mrOutputWindow; } + std::shared_ptr<vcl_canvas::SpriteCanvas> getSpriteCanvas() { return mpSpriteCanvas; } }; } // namespace ::sd diff --git a/slideshow/Library_slideshow.mk b/slideshow/Library_slideshow.mk index 655516490632..155b8c791b78 100644 --- a/slideshow/Library_slideshow.mk +++ b/slideshow/Library_slideshow.mk @@ -16,6 +16,7 @@ $(eval $(call gb_Library_set_include,slideshow,\ -I$(SRCDIR)/sd/inc \ -I$(SRCDIR)/sd/source/ui/inc \ -I$(SRCDIR)/sd/source/ui/slideshow \ + -I$(SRCDIR)/vcl/canvas_inc \ -I$(SRCDIR)/canvas/source/cairo \ -I$(SRCDIR)/canvas/inc \ -I$(SRCDIR)/svx/inc \ diff --git a/slideshow/source/engine/shapes/viewshape.cxx b/slideshow/source/engine/shapes/viewshape.cxx index 3cdb74ba5631..b4e571f87016 100644 --- a/slideshow/source/engine/shapes/viewshape.cxx +++ b/slideshow/source/engine/shapes/viewshape.cxx @@ -19,6 +19,7 @@ #include <cairo.h> #include <cairo_spritecanvas.hxx> +#include <memory> #include <sal/config.h> #include <comphelper/diagnose_ex.hxx> @@ -50,6 +51,8 @@ #include "drawinglayer/processor2d/cairopixelprocessor2d.hxx" #include "sal/types.h" #include "vcl/outdev.hxx" +#include "vcl_canvas/spritecanvas.hxx" +#include <basegfx/utils/canvastools.hxx> #include <tools.hxx> #include <utility> @@ -298,228 +301,230 @@ namespace slideshow::internal double nPrio, bool bIsVisible ) const { - // TODO(P1): For multiple views, it might pay off to reorg Shape and ViewShape, - // in that all the common setup steps here are refactored to Shape (would then - // have to be performed only _once_ per Shape paint). - - if( !bIsVisible || - rUnitBounds.isEmpty() || - rOrigBounds.isEmpty() || - rBounds.isEmpty() ) - { - // shape is invisible or has zero size, no need to - // update anything. - if( mpSprite ) - mpSprite->hide(); - - return true; - } - - - // calc sprite position, size and content transformation - // ===================================================== - - // the shape transformation for a sprite is always a - // simple scale-up to the nominal shape size. Everything - // else is handled via the sprite transformation - ::basegfx::B2DHomMatrix aNonTranslationalShapeTransformation; - aNonTranslationalShapeTransformation.scale( rOrigBounds.getWidth(), - rOrigBounds.getHeight() ); - ::basegfx::B2DHomMatrix aShapeTransformation( aNonTranslationalShapeTransformation ); - aShapeTransformation.translate( rOrigBounds.getMinX(), - rOrigBounds.getMinY() ); - - const ::basegfx::B2DHomMatrix aCanvasTransform( - rViewLayer->getSpriteTransformation() ); - - // area actually needed for the sprite - const ::basegfx::B2DRectangle aSpriteBoundsPixel( - calcUpdateAreaPixel( rUnitBounds, - aShapeTransformation, - aCanvasTransform, - pAttr ) ); - - // actual area for the shape (without subsetting, but - // including char scaling) - const ::basegfx::B2DRectangle aShapeBoundsPixel( - calcUpdateAreaPixel( ::basegfx::B2DRectangle(0.0,0.0,1.0,1.0), - aShapeTransformation, - aCanvasTransform, - pAttr ) ); - - // nominal area for the shape (without subsetting, without - // char scaling). NOTE: to cancel the shape translation, - // contained in rSpriteBoundsPixel, this is _without_ any - // translational component. - const ::basegfx::B2DRectangle aNominalShapeBoundsPixel( - shapeArea2AreaPixel( aCanvasTransform, - ::canvas::tools::calcTransformedRectBounds( - ::basegfx::B2DRectangle(0.0,0.0,1.0,1.0), - aNonTranslationalShapeTransformation ) ) ); - - // create (or resize) sprite with sprite's pixel size, if - // not done already - auto aRange = aSpriteBoundsPixel.getRange(); - basegfx::B2DSize rSpriteSizePixel(aRange.getX(), aRange.getY()); - if( !mpSprite ) - { - mpSprite = std::make_shared<AnimatedSprite>( mpViewLayer, - rSpriteSizePixel, - nPrio ); - } - else - { - // TODO(F2): when the sprite _actually_ gets resized, - // content needs a repaint! - mpSprite->resize( rSpriteSizePixel ); - } - - ENSURE_OR_RETURN_FALSE( mpSprite, "ViewShape::renderSprite(): No sprite" ); - - SAL_INFO("slideshow", "ViewShape::renderSprite(): Rendering sprite " << - mpSprite.get() ); - - - // always show the sprite (might have been hidden before) - mpSprite->show(); - - // determine center of sprite output position in pixel - // (assumption here: all shape transformations have the - // shape center as the pivot point). From that, subtract - // distance of rSpriteBoundsPixel's left, top edge from - // rShapeBoundsPixel's center. This moves the sprite at - // the appropriate output position within the virtual - // rShapeBoundsPixel area. - ::basegfx::B2DPoint aSpritePosPixel( rBounds.getCenter() ); - aSpritePosPixel *= aCanvasTransform; - aSpritePosPixel -= aShapeBoundsPixel.getCenter() - aSpriteBoundsPixel.getMinimum(); - - // the difference between rShapeBoundsPixel and - // rSpriteBoundsPixel upper, left corner is: the offset we - // have to move sprite output to the right, top (to make - // the desired subset content visible at all) - auto aDifference = aSpriteBoundsPixel.getMinimum() - aNominalShapeBoundsPixel.getMinimum(); - const basegfx::B2DSize rSpriteCorrectionOffset(aDifference.getX(), aDifference.getY()); - - // offset added top, left for anti-aliasing (otherwise, - // shapes fully filling the sprite will have anti-aliased - // pixel cut off) - const ::basegfx::B2DSize aAAOffset( - ::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE, - ::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE ); - - // set pixel output offset to sprite: we always leave - // ANTIALIASING_EXTRA_SIZE room atop and to the left, and, - // what's more, for subsetted shapes, we _have_ to cancel - // the effect of the shape renderer outputting the subset - // at its absolute position inside the shape, instead of - // at the origin. - // NOTE: As for now, sprites are always positioned on - // integer pixel positions on screen, have to round to - // nearest integer here, too - mpSprite->setPixelOffset( - aAAOffset - ::basegfx::B2DSize( - ::basegfx::fround( rSpriteCorrectionOffset.getWidth() ), - ::basegfx::fround( rSpriteCorrectionOffset.getHeight() ) ) ); - - // always set sprite position and transformation, since - // they do not relate directly to the update flags - // (e.g. sprite position changes when sprite size changes) - mpSprite->movePixel( aSpritePosPixel ); - mpSprite->transform( getSpriteTransformation( basegfx::B2DVector(rSpriteSizePixel.getWidth(), rSpriteSizePixel.getHeight()), - rOrigBounds.getRange(), - pAttr ) ); - - - // process flags - // ============= - - bool bRedrawRequired( mbForceUpdate || (nUpdateFlags & UpdateFlags::Force) ); - - if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Alpha) ) - { - mpSprite->setAlpha( (pAttr && pAttr->isAlphaValid()) ? - std::clamp(pAttr->getAlpha(), - 0.0, - 1.0) : - 1.0 ); - } - if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Clip) ) - { - if( pAttr && pAttr->isClipValid() ) - { - ::basegfx::B2DPolyPolygon aClipPoly( pAttr->getClip() ); - - // extract linear part of canvas view transformation - // (linear means: without translational components) - ::basegfx::B2DHomMatrix aViewTransform( - mpViewLayer->getTransformation() ); - aViewTransform.set( 0, 2, 0.0 ); - aViewTransform.set( 1, 2, 0.0 ); - - // make the clip 2*ANTIALIASING_EXTRA_SIZE larger - // such that it's again centered over the sprite. - aViewTransform.scale(rSpriteSizePixel.getWidth()/ - (rSpriteSizePixel.getWidth()-2*::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE), - rSpriteSizePixel.getHeight()/ - (rSpriteSizePixel.getHeight()-2*::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE)); - - // transform clip polygon from view to device - // coordinate space - aClipPoly.transform( aViewTransform ); - - mpSprite->clip( aClipPoly ); - } - else - mpSprite->clip(); - } - if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Content) ) - { - bRedrawRequired = true; - - // TODO(P1): maybe provide some appearance change methods at - // the Renderer interface - - // force the renderer to be regenerated below, for the - // different attributes to take effect - invalidateRenderer(); - } - - mbForceUpdate = false; - - if( !bRedrawRequired ) - return true; - - - // sprite needs repaint - output to sprite canvas - // ============================================== - - ::cppcanvas::CanvasSharedPtr pContentCanvas(mpSprite->getContentCanvas()); - cairocanvas::CanvasCustomSprite* pCanvasCustomSprite - = static_cast<cairocanvas::CanvasCustomSprite*>( - pContentCanvas->getUNOCanvas().get()); - cairo::SurfaceSharedPtr pSurface = pCanvasCustomSprite->getSurface(); - pSurface = pCanvasCustomSprite->getSurface(); - - /* return draw( pContentCanvas, - rMtf, - pAttr, - aShapeTransformation, - nullptr, // clipping is done via Sprite::clip() - rSubsets ); */ - - drawinglayer::geometry::ViewInformation2D aViewInformation; - basegfx::B2DHomMatrix aMatrix(rViewLayer->getTransformation()); - const ::basegfx::B2DPoint aAAGap(::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE, - ::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE); - // Bring the renderable area of the shape to the origin - aMatrix.translate(-aSpriteBoundsPixel.getMinimum() + aAAGap); - aViewInformation.setViewTransformation(aMatrix); - drawinglayer::processor2d::CairoPixelProcessor2D aProcessor( - aViewInformation, pSurface->getCairoSurface().get()); - aProcessor.process(rContainer); - - return true; +// // TODO(P1): For multiple views, it might pay off to reorg Shape and ViewShape, +// // in that all the common setup steps here are refactored to Shape (would then +// // have to be performed only _once_ per Shape paint). +// +// if( !bIsVisible || +// rUnitBounds.isEmpty() || +// rOrigBounds.isEmpty() || +// rBounds.isEmpty() ) +// { +// // shape is invisible or has zero size, no need to +// // update anything. +// if( mpCustomSprite ) +// mpCustomSprite->hide(); +// +// return true; +// } +// +// +// // calc sprite position, size and content transformation +// // ===================================================== +// +// // the shape transformation for a sprite is always a +// // simple scale-up to the nominal shape size. Everything +// // else is handled via the sprite transformation +// ::basegfx::B2DHomMatrix aNonTranslationalShapeTransformation; +// aNonTranslationalShapeTransformation.scale( rOrigBounds.getWidth(), +// rOrigBounds.getHeight() ); +// ::basegfx::B2DHomMatrix aShapeTransformation( aNonTranslationalShapeTransformation ); +// aShapeTransformation.translate( rOrigBounds.getMinX(), +// rOrigBounds.getMinY() ); +// +// const ::basegfx::B2DHomMatrix aCanvasTransform( +// rViewLayer->getSpriteTransformation() ); +// +// // area actually needed for the sprite +// const ::basegfx::B2DRectangle aSpriteBoundsPixel( +// calcUpdateAreaPixel( rUnitBounds, +// aShapeTransformation, +// aCanvasTransform, +// pAttr ) ); +// +// // actual area for the shape (without subsetting, but +// // including char scaling) +// const ::basegfx::B2DRectangle aShapeBoundsPixel( +// calcUpdateAreaPixel( ::basegfx::B2DRectangle(0.0,0.0,1.0,1.0), +// aShapeTransformation, +// aCanvasTransform, +// pAttr ) ); +// +// // nominal area for the shape (without subsetting, without +// // char scaling). NOTE: to cancel the shape translation, +// // contained in rSpriteBoundsPixel, this is _without_ any +// // translational component. +// const ::basegfx::B2DRectangle aNominalShapeBoundsPixel( +// shapeArea2AreaPixel( aCanvasTransform, +// ::canvas::tools::calcTransformedRectBounds( +// ::basegfx::B2DRectangle(0.0,0.0,1.0,1.0), +// aNonTranslationalShapeTransformation ) ) ); +// +// // create (or resize) sprite with sprite's pixel size, if +// // not done already +// auto aRange = aSpriteBoundsPixel.getRange(); +// basegfx::B2DSize rSpriteSizePixel(aRange.getX(), aRange.getY()); +// if( !mpCustomSprite ) +// { +// /* mpSprite = std::make_shared<AnimatedSprite>( mpViewLayer, +// rSpriteSizePixel, +// nPrio ); */ +// vcl_canvas::SpriteCanvasSharedPtr pSpriteCanvasAbstract = mpViewLayer->getSpriteCanvas(); +// mpCustomSprite = pSpriteCanvasAbstract->createCustomSprite(::basegfx::unotools::size2DFromB2DSize(rSpriteSizePixel)); +// } +// else +// { +// // TODO(F2): when the sprite _actually_ gets resized, +// // content needs a repaint! +// mpCustomSprite->resize( rSpriteSizePixel ); +// } +// +// ENSURE_OR_RETURN_FALSE( mpSprite, "ViewShape::renderSprite(): No sprite" ); +// +// SAL_INFO("slideshow", "ViewShape::renderSprite(): Rendering sprite " << +// mpSprite.get() ); +// +// +// // always show the sprite (might have been hidden before) +// mpSprite->show(); +// +// // determine center of sprite output position in pixel +// // (assumption here: all shape transformations have the +// // shape center as the pivot point). From that, subtract +// // distance of rSpriteBoundsPixel's left, top edge from +// // rShapeBoundsPixel's center. This moves the sprite at +// // the appropriate output position within the virtual +// // rShapeBoundsPixel area. +// ::basegfx::B2DPoint aSpritePosPixel( rBounds.getCenter() ); +// aSpritePosPixel *= aCanvasTransform; +// aSpritePosPixel -= aShapeBoundsPixel.getCenter() - aSpriteBoundsPixel.getMinimum(); +// +// // the difference between rShapeBoundsPixel and +// // rSpriteBoundsPixel upper, left corner is: the offset we +// // have to move sprite output to the right, top (to make +// // the desired subset content visible at all) +// auto aDifference = aSpriteBoundsPixel.getMinimum() - aNominalShapeBoundsPixel.getMinimum(); +// const basegfx::B2DSize rSpriteCorrectionOffset(aDifference.getX(), aDifference.getY()); +// +// // offset added top, left for anti-aliasing (otherwise, +// // shapes fully filling the sprite will have anti-aliased +// // pixel cut off) +// const ::basegfx::B2DSize aAAOffset( +// ::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE, +// ::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE ); +// +// // set pixel output offset to sprite: we always leave +// // ANTIALIASING_EXTRA_SIZE room atop and to the left, and, +// // what's more, for subsetted shapes, we _have_ to cancel +// // the effect of the shape renderer outputting the subset +// // at its absolute position inside the shape, instead of +// // at the origin. +// // NOTE: As for now, sprites are always positioned on +// // integer pixel positions on screen, have to round to +// // nearest integer here, too +// mpSprite->setPixelOffset( +// aAAOffset - ::basegfx::B2DSize( +// ::basegfx::fround( rSpriteCorrectionOffset.getWidth() ), +// ::basegfx::fround( rSpriteCorrectionOffset.getHeight() ) ) ); +// +// // always set sprite position and transformation, since +// // they do not relate directly to the update flags +// // (e.g. sprite position changes when sprite size changes) +// mpSprite->movePixel( aSpritePosPixel ); +// mpSprite->transform( getSpriteTransformation( basegfx::B2DVector(rSpriteSizePixel.getWidth(), rSpriteSizePixel.getHeight()), +// rOrigBounds.getRange(), +// pAttr ) ); +// +// +// // process flags +// // ============= +// +// bool bRedrawRequired( mbForceUpdate || (nUpdateFlags & UpdateFlags::Force) ); +// +// if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Alpha) ) +// { +// mpSprite->setAlpha( (pAttr && pAttr->isAlphaValid()) ? +// std::clamp(pAttr->getAlpha(), +// 0.0, +// 1.0) : +// 1.0 ); +// } +// if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Clip) ) +// { +// if( pAttr && pAttr->isClipValid() ) +// { +// ::basegfx::B2DPolyPolygon aClipPoly( pAttr->getClip() ); +// +// // extract linear part of canvas view transformation +// // (linear means: without translational components) +// ::basegfx::B2DHomMatrix aViewTransform( +// mpViewLayer->getTransformation() ); +// aViewTransform.set( 0, 2, 0.0 ); +// aViewTransform.set( 1, 2, 0.0 ); +// +// // make the clip 2*ANTIALIASING_EXTRA_SIZE larger +// // such that it's again centered over the sprite. +// aViewTransform.scale(rSpriteSizePixel.getWidth()/ +// (rSpriteSizePixel.getWidth()-2*::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE), +// rSpriteSizePixel.getHeight()/ +// (rSpriteSizePixel.getHeight()-2*::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE)); +// +// // transform clip polygon from view to device +// // coordinate space +// aClipPoly.transform( aViewTransform ); +// +// mpSprite->clip( aClipPoly ); +// } +// else +// mpSprite->clip(); +// } +// if( mbForceUpdate || (nUpdateFlags & UpdateFlags::Content) ) +// { +// bRedrawRequired = true; +// +// // TODO(P1): maybe provide some appearance change methods at +// // the Renderer interface +// +// // force the renderer to be regenerated below, for the +// // different attributes to take effect +// invalidateRenderer(); +// } +// +// mbForceUpdate = false; +// +// if( !bRedrawRequired ) +// return true; +// +// +// // sprite needs repaint - output to sprite canvas +// // ============================================== +// +// ::cppcanvas::CanvasSharedPtr pContentCanvas(mpSprite->getContentCanvas()); +// cairocanvas::CanvasCustomSprite* pCanvasCustomSprite +// = static_cast<cairocanvas::CanvasCustomSprite*>( +// pContentCanvas->getUNOCanvas().get()); +// cairo::SurfaceSharedPtr pSurface = pCanvasCustomSprite->getSurface(); +// pSurface = pCanvasCustomSprite->getSurface(); +// +// /* return draw( pContentCanvas, +// rMtf, +// pAttr, +// aShapeTransformation, +// nullptr, // clipping is done via Sprite::clip() +// rSubsets ); */ +// +// drawinglayer::geometry::ViewInformation2D aViewInformation; +// basegfx::B2DHomMatrix aMatrix(rViewLayer->getTransformation()); +// const ::basegfx::B2DPoint aAAGap(::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE, +// ::cppcanvas::Canvas::ANTIALIASING_EXTRA_SIZE); +// // Bring the renderable area of the shape to the origin +// aMatrix.translate(-aSpriteBoundsPixel.getMinimum() + aAAGap); +// aViewInformation.setViewTransformation(aMatrix); +// drawinglayer::processor2d::CairoPixelProcessor2D aProcessor( +// aViewInformation, pSurface->getCairoSurface().get()); +// aProcessor.process(rContainer); +// +// return true; } bool ViewShape::render( const ::cppcanvas::CanvasSharedPtr& rDestinationCanvas, @@ -891,19 +896,19 @@ namespace slideshow::internal return true; if (!bIsVisible) return true; - uno::Reference<css::lang::XServiceInfo> xInfo( - mpViewLayer->getCanvas()->getUNOCanvas(), uno::UNO_QUERY); + /* uno::Reference<css::lang::XServiceInfo> xInfo( + mpViewLayer->getCanvas()->getUNOCanvas(), uno::UNO_QUERY); */ cairo::SurfaceSharedPtr pSurface; - if (!xInfo.is() || xInfo->getImplementationName().indexOf("VCLCanvas") != -1) + /* if (!xInfo.is() || xInfo->getImplementationName().indexOf("VCLCanvas") != -1) { - /* return render( mpViewLayer->getCanvas(), - rMtf, - rArgs.maBounds, - rArgs.maUpdateBounds, - nUpdateFlags, - rArgs.mrAttr, - rArgs.mrSubsets, - bIsVisible ); */ + // return render( mpViewLayer->getCanvas(), + // rMtf, + // rArgs.maBounds, + // rArgs.maUpdateBounds, + // nUpdateFlags, + // rArgs.mrAttr, + // rArgs.mrSubsets, + // bIsVisible ); return true; } if (xInfo->getImplementationName().indexOf("SpriteCanvas") != -1) @@ -929,8 +934,12 @@ namespace slideshow::internal = static_cast<cairocanvas::CanvasBitmap*>( mpViewLayer->getCanvas()->getUNOCanvas().get()); pSurface = pCanvasBitmap->getSurface(); - } - + } */ + vcl_canvas::SpriteCanvasSharedPtr pSpriteCanvasAbstract = mpViewLayer->getSpriteCanvas(); + std::shared_ptr<::vcl_cairocanvas::SpriteCanvas> pSpriteCanvas + = std::static_pointer_cast<::vcl_cairocanvas::SpriteCanvas>( + pSpriteCanvasAbstract); + pSurface = pSpriteCanvas->getSurface(); drawinglayer::geometry::ViewInformation2D aViewInormation; aViewInormation.setViewTime(rArgs.mnElapsedTime*1000); basegfx::B2DHomMatrix aMatrix(mpViewLayer->getTransformation()); diff --git a/slideshow/source/engine/shapes/viewshape.hxx b/slideshow/source/engine/shapes/viewshape.hxx index 191002790314..b3deebe6869a 100644 --- a/slideshow/source/engine/shapes/viewshape.hxx +++ b/slideshow/source/engine/shapes/viewshape.hxx @@ -20,10 +20,9 @@ #ifndef INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_VIEWSHAPE_HXX #define INCLUDED_SLIDESHOW_SOURCE_ENGINE_SHAPES_VIEWSHAPE_HXX -#include "canvas/elapsedtime.hxx" #include "drawinglayer/primitive2d/Primitive2DContainer.hxx" #include "sal/types.h" -#include "svx/sdr/animation/objectanimator.hxx" +#include "vcl_canvas/customsprite.hxx" #include <cppcanvas/renderer.hxx> #include <cppcanvas/bitmap.hxx> diff --git a/slideshow/source/engine/slide/layermanager.cxx b/slideshow/source/engine/slide/layermanager.cxx index 947b4f2580b6..fc7502a528b7 100644 --- a/slideshow/source/engine/slide/layermanager.cxx +++ b/slideshow/source/engine/slide/layermanager.cxx @@ -25,6 +25,7 @@ #include <functional> #include <algorithm> +#include <memory> #include <utility> #include "layermanager.hxx" @@ -575,6 +576,13 @@ namespace slideshow::internal return ::cppcanvas::CustomSpriteSharedPtr(); } + vcl_canvas::SpriteCanvasSharedPtr getSpriteCanvas() const override + { + ENSURE_OR_THROW( false, + "DummyLayer::getSpriteCanvas(): This method is not supposed to be called!" ); + return std::shared_ptr<vcl_canvas::SpriteCanvas>(); + } + virtual void setPriority( const basegfx::B1DRange& /*rRange*/ ) override { OSL_FAIL( "BitmapView::setPriority(): This method is not supposed to be called!" ); diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx index afc489b53921..91e828e09ea0 100644 --- a/slideshow/source/engine/slide/slideimpl.cxx +++ b/slideshow/source/engine/slide/slideimpl.cxx @@ -453,8 +453,8 @@ void SlideImpl::show( bool bSlideBackgroundPainted ) // render slide to screen, if requested if( !bSlideBackgroundPainted ) { - for( const auto& rContext : maContext.mrViewContainer ) - slideRenderer( this, rContext ); + /* for( const auto& rContext : maContext.mrViewContainer ) + slideRenderer( this, rContext ); */ maContext.mrScreenUpdater.notifyUpdate(); } diff --git a/slideshow/source/engine/slideview.cxx b/slideshow/source/engine/slideview.cxx index 44f7c3a0e4d3..8cf3acefc437 100644 --- a/slideshow/source/engine/slideview.cxx +++ b/slideshow/source/engine/slideview.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include "vcl_canvas/spritecanvas.hxx" +#include "slideshowviewimpl.hxx" #include <comphelper/diagnose_ex.hxx> #include <canvas/canvastools.hxx> @@ -622,6 +624,11 @@ private: return mpOutputCanvas; } + virtual vcl_canvas::SpriteCanvasSharedPtr getSpriteCanvas() const override + { + return mpParentView->getSpriteCanvas(); + } + virtual void setClip( const basegfx::B2DPolyPolygon& rClip ) override { basegfx::B2DPolyPolygon aNewClip = prepareClip( rClip ); @@ -682,6 +689,7 @@ private: virtual void clear() const override; virtual void clearAll() const override; virtual cppcanvas::CanvasSharedPtr getCanvas() const override; + virtual vcl_canvas::SpriteCanvasSharedPtr getSpriteCanvas() const override; virtual cppcanvas::CustomSpriteSharedPtr createSprite( const ::basegfx::B2DSize& rSpriteSizePixel, double nPriority ) const override; virtual void setPriority( const basegfx::B1DRange& rRange ) override; @@ -913,6 +921,13 @@ cppcanvas::CanvasSharedPtr SlideView::getCanvas() const return mpCanvas; } +vcl_canvas::SpriteCanvasSharedPtr SlideView::getSpriteCanvas() const +{ + rtl::Reference< sd::SlideShowView > pImpl = static_cast< sd::SlideShowView* >( mxView.get() ); + return pImpl->getSpriteCanvas(); + // return vcl_canvas::SpriteCanvasSharedPtr(); +} + cppcanvas::CustomSpriteSharedPtr SlideView::createSprite( const basegfx::B2DSize& rSpriteSizePixel, double nPriority ) const diff --git a/slideshow/source/inc/viewlayer.hxx b/slideshow/source/inc/viewlayer.hxx index 1dd713b2dbed..a360e4dca766 100644 --- a/slideshow/source/inc/viewlayer.hxx +++ b/slideshow/source/inc/viewlayer.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_VIEWLAYER_HXX #define INCLUDED_SLIDESHOW_SOURCE_INC_VIEWLAYER_HXX +#include "vcl_canvas/spritecanvas.hxx" #include <sal/config.h> #include <memory> #include <com/sun/star/geometry/IntegerSize2D.hpp> @@ -66,6 +67,7 @@ namespace slideshow::internal long as this object is alive. */ virtual cppcanvas::CanvasSharedPtr getCanvas() const = 0; + virtual vcl_canvas::SpriteCanvasSharedPtr getSpriteCanvas() const = 0; /** Clear the clipped view layer area diff --git a/vcl/canvas_inc/cairo_spritecanvas.hxx b/vcl/canvas_inc/cairo_spritecanvas.hxx index e944c941194e..ac99ca349d70 100644 --- a/vcl/canvas_inc/cairo_spritecanvas.hxx +++ b/vcl/canvas_inc/cairo_spritecanvas.hxx @@ -38,7 +38,6 @@ #include "cairo_repainttarget.hxx" #include "cairo_surfaceprovider.hxx" #include "cairo_spritecanvashelper.hxx" -#include "com/sun/star/awt/XWindowListener.hdl" namespace vcl_cairocanvas { diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index afc6f4acb6b1..db07cbafaa11 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -576,7 +576,7 @@ Window::~Window() return mpWindowImpl ? mpWindowImpl->mxOutDev.get() : nullptr; } -std::shared_ptr<vcl_cairocanvas::SpriteCanvas> Window::GetSpriteCanvas() +std::shared_ptr<::vcl_canvas::SpriteCanvas> Window::GetSpriteCanvas() { const Sequence< Any > aArg{ Any(reinterpret_cast<sal_Int64>(GetOutDev())), @@ -586,7 +586,6 @@ std::shared_ptr<vcl_cairocanvas::SpriteCanvas> Window::GetSpriteCanvas() GetOutDev()->GetSystemGfxDataAny() }; const Reference< XComponentContext >& xContext = comphelper::getProcessComponentContext(); - // auto pSpriteCanvas = std::make_shared<vcl_cairocanvas::SpriteCanvas>(aArg, xContext); auto pSpriteCanvas = std::shared_ptr<vcl_cairocanvas::SpriteCanvas>( new vcl_cairocanvas::SpriteCanvas(aArg, xContext) ); commit 81430c0bb6cbe271faea33b2c43a597958dc5e3f Author: Shardul Vikram Singh <[email protected]> AuthorDate: Tue Jul 29 21:13:36 2025 +0530 Commit: Shardul Vikram Singh <[email protected]> CommitDate: Tue Jul 29 21:13:36 2025 +0530 add WindowListenerBridge diff --git a/vcl/canvas_inc/base/bufferedgraphicdevicebase.hxx b/vcl/canvas_inc/base/bufferedgraphicdevicebase.hxx index dd501859262a..a31e61e06098 100644 --- a/vcl/canvas_inc/base/bufferedgraphicdevicebase.hxx +++ b/vcl/canvas_inc/base/bufferedgraphicdevicebase.hxx @@ -19,6 +19,8 @@ #pragma once +#include "com/sun/star/awt/XWindowListener.hdl" +#include "com/sun/star/uno/Reference.h" #include <com/sun/star/awt/XWindow2.hpp> #include <vcl_canvas/canvastools.hxx> @@ -75,6 +77,47 @@ namespace vcl_canvas class UnambiguousBase = css::uno::XInterface > class BufferedGraphicDeviceBase : public GraphicDeviceBase< Base, DeviceHelper, Mutex, UnambiguousBase > { + private: + class WindowListenerBridge : public ::cppu::WeakImplHelper<css::awt::XWindowListener> + { + private: + typedef BufferedGraphicDeviceBase<Base, DeviceHelper, Mutex, UnambiguousBase> + BufferedGraphicDeviceBase; + BufferedGraphicDeviceBase& mrBufferedGraphicDeviceBase; + // XWindowListener + virtual void disposing(const css::lang::EventObject& Source) override + { + mrBufferedGraphicDeviceBase.disposeEventSource(Source); + } + + virtual void SAL_CALL windowResized(const css::awt::WindowEvent& e) override + { + mrBufferedGraphicDeviceBase.windowResized(e); + } + + virtual void SAL_CALL windowMoved(const css::awt::WindowEvent& e) override + { + mrBufferedGraphicDeviceBase.windowMoved(e); + } + + virtual void SAL_CALL windowShown(const css::lang::EventObject& e) override + { + mrBufferedGraphicDeviceBase.windowShown(e); + } + + virtual void SAL_CALL windowHidden(const css::lang::EventObject& e) override + { + mrBufferedGraphicDeviceBase.windowHidden(e); + } + + public: + WindowListenerBridge(BufferedGraphicDeviceBase& rBufferedGraphicDeviceBase) + : mrBufferedGraphicDeviceBase(rBufferedGraphicDeviceBase) + { + } + }; + css::uno::Reference<css::awt::XWindowListener> mxWindowListener; + public: typedef GraphicDeviceBase< Base, DeviceHelper, Mutex, UnambiguousBase > BaseType; typedef Mutex MutexType; @@ -86,6 +129,7 @@ namespace vcl_canvas BaseType::maPropHelper.addProperties( PropertySetHelper::MakeMap("Window", [this] () { return this->getXWindow(); })); + mxWindowListener = new WindowListenerBridge(*this); } // XGraphicDevice @@ -135,7 +179,7 @@ namespace vcl_canvas void setWindow( const css::uno::Reference< css::awt::XWindow2 >& rWindow ) { if( mxWindow.is() ) - mxWindow->removeWindowListener( this ); + mxWindow->removeWindowListener( mxWindowListener ); mxWindow = rWindow; @@ -148,7 +192,7 @@ namespace vcl_canvas css::uno::UNO_QUERY ).is(); maBounds = transformBounds( mxWindow->getPosSize() ); - mxWindow->addWindowListener( this ); + mxWindow->addWindowListener( mxWindowListener ); } } @@ -204,34 +248,33 @@ namespace vcl_canvas } // XWindowListener - /* virtual void disposeEventSource( const css::lang::EventObject& Source ) override + virtual void disposeEventSource( const css::lang::EventObject& Source ) { typename BaseType::MutexType aGuard( BaseType::m_aMutex ); if( Source.Source == mxWindow ) mxWindow.clear(); - BaseType::disposeEventSource(Source); - } */ + } - virtual void SAL_CALL windowResized( const css::awt::WindowEvent& e ) override + virtual void SAL_CALL windowResized( const css::awt::WindowEvent& e ) { boundsChanged( e ); } - virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& e ) override + virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& e ) { boundsChanged( e ); } - virtual void SAL_CALL windowShown( const css::lang::EventObject& ) override + virtual void SAL_CALL windowShown( const css::lang::EventObject& ) { typename BaseType::MutexType aGuard( BaseType::m_aMutex ); mbIsVisible = true; } - virtual void SAL_CALL windowHidden( const css::lang::EventObject& ) override + virtual void SAL_CALL windowHidden( const css::lang::EventObject& ) { typename BaseType::MutexType aGuard( BaseType::m_aMutex ); diff --git a/vcl/canvas_inc/cairo_spritecanvas.hxx b/vcl/canvas_inc/cairo_spritecanvas.hxx index 1b8723d7b17b..e944c941194e 100644 --- a/vcl/canvas_inc/cairo_spritecanvas.hxx +++ b/vcl/canvas_inc/cairo_spritecanvas.hxx @@ -46,8 +46,7 @@ namespace vcl_cairocanvas public ::vcl_canvas::GraphicDevice, public ::vcl_canvas::Updatable, public ::vcl_canvas::SpriteSurface, - public SurfaceProvider, - public css::awt::XWindowListener + public SurfaceProvider { protected: mutable ::osl::Mutex m_aMutex; @@ -90,13 +89,13 @@ namespace vcl_cairocanvas const css::uno::Reference< css::uno::XComponentContext >& rxContext ); void initialize(); - virtual void SAL_CALL acquire() override{} + /* virtual void SAL_CALL acquire() override{} virtual void SAL_CALL release() override{} virtual ::css::uno::Any SAL_CALL queryInterface( const ::css::uno::Type& aType ) override { return ::css::uno::Any(); } - virtual void SAL_CALL disposing( const ::css::lang::EventObject& Source ) override{} + virtual void SAL_CALL disposing( const ::css::lang::EventObject& Source ) override{} */ /// Dispose all internal references // virtual void disposeThis() override;
