27#include <osl/diagnose.h>
37const sal_Int32 gnMaximumLayerCount = 8;
39class LayerInvalidator :
public ILayerInvalidator
43 std::shared_ptr<LayeredDevice> pLayeredDevice,
52 virtual void Invalidate (const ::tools::Rectangle& rInvalidationBox)
override
67 const ::tools::Rectangle& rBox)
77void ForAllRectangles (
const vcl::Region& rRegion,
const std::function<
void (const ::tools::Rectangle&)>& aFunction)
79 OSL_ASSERT(aFunction);
83 if(aRectangles.empty())
89 for(
const auto& rRect : aRectangles)
107 Layer(
const Layer&) =
delete;
108 Layer& operator=(
const Layer&) =
delete;
111 void InvalidateRectangle (const ::tools::Rectangle& rInvalidationBox);
112 void InvalidateRegion (
const vcl::Region& rInvalidationRegion);
116 const ::tools::Rectangle& rRepaintRectangle);
120 bool HasPainter()
const;
128 void ValidateRectangle (const ::tools::Rectangle& rBox);
130typedef std::shared_ptr<Layer> SharedLayer;
145 ::std::vector<SharedLayer>::const_iterator
begin()
const {
return mvLayers.begin(); }
146 ::std::vector<SharedLayer>::const_iterator
end()
const {
return mvLayers.end(); }
166 maSavedMapMode(pTargetWindow->GetMapMode())
176 const ::tools::Rectangle& rInvalidationArea,
177 const sal_Int32 nLayer)
185 (*mpLayers)[nLayer]->InvalidateRectangle(rInvalidationArea);
190 for (
size_t nLayer=0; nLayer<
mpLayers->size(); ++nLayer)
191 (*
mpLayers)[nLayer]->InvalidateRectangle(rInvalidationArea);
196 for (
size_t nLayer=0; nLayer<
mpLayers->size(); ++nLayer)
197 (*
mpLayers)[nLayer]->InvalidateRegion(rInvalidationRegion);
202 const sal_Int32 nLayer)
207 OSL_ASSERT(rpPainter);
210 if (nLayer<0 || nLayer>=gnMaximumLayerCount)
212 OSL_ASSERT(nLayer>=0 && nLayer<gnMaximumLayerCount);
219 const sal_Int32 nOldLayerCount (
mpLayers->size());
226 (*mpLayers)[nLayer]->AddPainter(rpPainter);
230 rpPainter->SetLayerInvalidator(
231 std::make_shared<LayerInvalidator>(shared_from_this(),
mpTargetWindow,nLayer));
236 const sal_Int32 nLayer)
240 OSL_ASSERT(rpPainter);
251 (*mpLayers)[nLayer]->RemovePainter(rpPainter);
266 ForAllRectangles(rRepaintRegion,
277 (*mpLayers)[0]->Repaint(*
mpTargetWindow->GetOutDev(), rRepaintRectangle);
318 const ::tools::Rectangle aLogicWindowBox (
333 aLogicWindowBox.TopLeft(),
335 aLogicWindowBox.GetSize());
342 aWindowBox.Bottom()+aDelta.
Y(),
344 aWindowBox.Bottom())));
345 else if (aDelta.
Y() > 0)
350 aWindowBox.Top()+aDelta.
Y())));
353 aWindowBox.Right()+aDelta.
X(),
356 aWindowBox.Bottom())));
357 else if (aDelta.
X() > 0)
361 aWindowBox.Left()+aDelta.
X(),
362 aWindowBox.Bottom())));
381void Layer::Initialize (
sd::Window *pTargetWindow)
394void Layer::InvalidateRectangle (const ::tools::Rectangle& rInvalidationBox)
399void Layer::InvalidateRegion (
const vcl::Region& rInvalidationRegion)
404void Layer::Validate (
const MapMode& rMapMode)
418void Layer::ValidateRectangle (const ::tools::Rectangle& rBox)
435 const ::tools::Rectangle& rRepaintRectangle)
439 DeviceCopy(rTargetDevice, *
mpLayerDevice, rRepaintRectangle);
445 it->Paint(rTargetDevice, rRepaintRectangle);
450void Layer::Resize (
const Size& rSize)
468 const ::std::vector<SharedILayerPainter>::iterator iPainter (
476 SAL_WARN(
"sd",
"LayeredDevice::RemovePainter called for painter that is not registered");
480bool Layer::HasPainter()
const
ScopedVclPtr< VirtualDevice > mpLayerDevice
::std::vector< SharedILayerPainter > maPainters
vcl::Region maInvalidationRegion
const std::shared_ptr< LayeredDevice > mpLayeredDevice
VclPtr< sd::Window > mpTargetWindow
const Fraction & GetScaleX() const
MapUnit GetMapUnit() const
const Point & GetOrigin() const
const Fraction & GetScaleY() const
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
constexpr tools::Long Y() const
constexpr tools::Long X() const
void disposeAndReset(reference_type *pBody)
An SdWindow contains the actual working area of ViewShell.
::std::vector< SharedLayer >::const_iterator end() const
const SharedLayer & back() const
::std::vector< SharedLayer > mvLayers
SharedLayer & operator[](size_t i)
::std::vector< SharedLayer >::const_iterator begin() const
void RepaintRectangle(const ::tools::Rectangle &rRepaintRectangle)
void Repaint(const vcl::Region &rRepaintRegion)
void InvalidateAllLayers(const ::tools::Rectangle &rInvalidationBox)
VclPtr< sd::Window > mpTargetWindow
void Invalidate(const ::tools::Rectangle &rInvalidationBox, const sal_Int32 nLayer)
void RegisterPainter(const SharedILayerPainter &rPainter, const sal_Int32 nLayer)
bool HandleMapModeChange()
ScopedVclPtr< VirtualDevice > mpBackBuffer
LayeredDevice(const VclPtr< sd::Window > &pTargetWindow)
void RemovePainter(const SharedILayerPainter &rPainter, const sal_Int32 nLayer)
std::unique_ptr< LayerContainer > mpLayers
void Union(const tools::Rectangle &rRegion)
void GetRegionRectangles(RectangleVector &rTarget) const
::OutputDevice const * GetOutDev() const
virtual Size GetSizePixel() const
#define SAL_WARN(area, stream)
void Dispose(const T &xInterface)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
std::shared_ptr< ILayerPainter > SharedILayerPainter
std::shared_ptr< ILayerInvalidator > SharedILayerInvalidator
std::vector< tools::Rectangle > RectangleVector