From 9090dc1f3b27195f5defd35586ac79357992be21 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 18 Jan 2021 18:27:19 +0200 Subject: split OutputDevice from Window as part of a longer-term goal of doing our widget rendering only inside a top-level render- context. I moved all of the OutputDevice-related code that existed in vcl::Window into a new subclass of OutputDevice called WindowOutputDevice. Notes for further work (*) not sure why we are getting an 1x1 surface in SvpSalGraphics::releaseCairoContext, but to fix it I clamp the size there (*) might have to dump VCLXDevice, and move it's code down into VCLXWindow and VCLXVirtualDevice (*) can we remove use of VCLXDevice in other places, in favour of just talking to the VCL code? Change-Id: I105946377f5322677d6f7d0c1c23847178a720b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113204 Tested-by: Jenkins Reviewed-by: Noel Grandin --- canvas/source/cairo/cairo_canvas.cxx | 2 +- canvas/source/cairo/cairo_spritecanvas.cxx | 2 +- canvas/source/cairo/cairo_spritedevicehelper.cxx | 2 +- canvas/source/directx/dx_canvas.cxx | 1 + canvas/source/vcl/canvas.cxx | 1 + canvas/source/vcl/outdevholder.hxx | 1 + canvas/source/vcl/spritecanvashelper.cxx | 4 ++-- canvas/source/vcl/windowoutdevholder.hxx | 4 ++-- canvas/workben/canvasdemo.cxx | 4 ++-- 9 files changed, 12 insertions(+), 9 deletions(-) (limited to 'canvas') diff --git a/canvas/source/cairo/cairo_canvas.cxx b/canvas/source/cairo/cairo_canvas.cxx index 10edc0681843..5b727905673a 100644 --- a/canvas/source/cairo/cairo_canvas.cxx +++ b/canvas/source/cairo/cairo_canvas.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "cairo_canvas.hxx" @@ -68,7 +69,6 @@ namespace cairocanvas sal_Int64 nPtr = 0; maArguments[0] >>= nPtr; OutputDevice* pOutDev = reinterpret_cast(nPtr); - ENSURE_ARG_OR_THROW( pOutDev != nullptr, "Canvas::initialize: invalid OutDev pointer" ); diff --git a/canvas/source/cairo/cairo_spritecanvas.cxx b/canvas/source/cairo/cairo_spritecanvas.cxx index 91ac7c376b4d..562157f52c60 100644 --- a/canvas/source/cairo/cairo_spritecanvas.cxx +++ b/canvas/source/cairo/cairo_spritecanvas.cxx @@ -77,7 +77,7 @@ namespace cairocanvas throw lang::NoSupportException( "Parent window not VCL window, or canvas out-of-process!", nullptr); - bool bHasCairo = pParentWindow->SupportsCairo(); + bool bHasCairo = pParentWindow->GetOutDev()->SupportsCairo(); ENSURE_ARG_OR_THROW(bHasCairo, "CairoSpriteCanvas::SpriteCanvas: No Cairo capability"); diff --git a/canvas/source/cairo/cairo_spritedevicehelper.cxx b/canvas/source/cairo/cairo_spritedevicehelper.cxx index 825d6f343b43..f2d018937be2 100644 --- a/canvas/source/cairo/cairo_spritedevicehelper.cxx +++ b/canvas/source/cairo/cairo_spritedevicehelper.cxx @@ -46,7 +46,7 @@ namespace cairocanvas bool bFullscreen ) { DeviceHelper::init(rSpriteCanvas, - rOutputWindow); + *rOutputWindow.GetOutDev()); mpSpriteCanvas = &rSpriteCanvas; mbFullScreen = bFullscreen; diff --git a/canvas/source/directx/dx_canvas.cxx b/canvas/source/directx/dx_canvas.cxx index 3d5bda00288b..7f29813c953b 100644 --- a/canvas/source/directx/dx_canvas.cxx +++ b/canvas/source/directx/dx_canvas.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include diff --git a/canvas/source/vcl/canvas.cxx b/canvas/source/vcl/canvas.cxx index e9ebf85b3b3a..2ad0a61fc9fd 100644 --- a/canvas/source/vcl/canvas.cxx +++ b/canvas/source/vcl/canvas.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include "outdevholder.hxx" diff --git a/canvas/source/vcl/outdevholder.hxx b/canvas/source/vcl/outdevholder.hxx index 78f3badf8bb6..28dfd4317fe0 100644 --- a/canvas/source/vcl/outdevholder.hxx +++ b/canvas/source/vcl/outdevholder.hxx @@ -35,6 +35,7 @@ public: explicit OutDevHolder(OutputDevice& rOutDev) : mrOutDev(rOutDev) { + assert(&rOutDev); } private: diff --git a/canvas/source/vcl/spritecanvashelper.cxx b/canvas/source/vcl/spritecanvashelper.cxx index 0c1a454c3260..1796c8ac7ffe 100644 --- a/canvas/source/vcl/spritecanvashelper.cxx +++ b/canvas/source/vcl/spritecanvashelper.cxx @@ -220,7 +220,7 @@ namespace vclcanvas vcl::Window* pTargetWindow = nullptr; if( rOutDev.GetOutDevType() == OUTDEV_WINDOW ) { - pTargetWindow = &static_cast(rOutDev); // TODO(Q3): Evil downcast. + pTargetWindow = rOutDev.GetOwnerWindow(); // TODO(Q3): Evil downcast. // we're double-buffered, thus no need for paint area-limiting // clips. besides that, will interfere with animations (as for @@ -309,7 +309,7 @@ namespace vclcanvas if( pTargetWindow ) { // commit to screen - pTargetWindow->Flush(); + pTargetWindow->GetOutDev()->Flush(); } return true; diff --git a/canvas/source/vcl/windowoutdevholder.hxx b/canvas/source/vcl/windowoutdevholder.hxx index d9d69e9a37c9..87138a8a9106 100644 --- a/canvas/source/vcl/windowoutdevholder.hxx +++ b/canvas/source/vcl/windowoutdevholder.hxx @@ -36,8 +36,8 @@ namespace vclcanvas explicit WindowOutDevHolder( const css::uno::Reference< css::awt::XWindow>& xWin ); private: - virtual OutputDevice& getOutDev() override { return mrOutputWindow; } - virtual const OutputDevice& getOutDev() const override { return mrOutputWindow; } + virtual OutputDevice& getOutDev() override { return *mrOutputWindow.GetOutDev(); } + virtual const OutputDevice& getOutDev() const override { return *mrOutputWindow.GetOutDev(); } // TODO(Q2): Lifetime issue. Though WindowGraphicDeviceBase // now listens to the window component, I still consider diff --git a/canvas/workben/canvasdemo.cxx b/canvas/workben/canvasdemo.cxx index e19e1f45f2af..9d48b84132d6 100644 --- a/canvas/workben/canvasdemo.cxx +++ b/canvas/workben/canvasdemo.cxx @@ -536,7 +536,7 @@ void TestWindow::Paint(vcl::RenderContext&, const tools::Rectangle&) { try { - uno::Reference< rendering::XCanvas > xVDevCanvas( GetCanvas(), + uno::Reference< rendering::XCanvas > xVDevCanvas( GetOutDev()->GetCanvas(), uno::UNO_SET_THROW ); uno::Reference< rendering::XGraphicDevice > xVDevDevice( xVDevCanvas->getDevice(), uno::UNO_SET_THROW ); @@ -551,7 +551,7 @@ void TestWindow::Paint(vcl::RenderContext&, const tools::Rectangle&) aVDevRenderer.drawArcs(); aVDevRenderer.drawPolygons(); - uno::Reference< rendering::XCanvas > xCanvas( GetSpriteCanvas(), + uno::Reference< rendering::XCanvas > xCanvas( GetOutDev()->GetSpriteCanvas(), uno::UNO_QUERY_THROW ); uno::Reference< rendering::XGraphicDevice > xDevice( xCanvas->getDevice(), uno::UNO_SET_THROW ); -- cgit