/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// Provide the layers. if (o3tl::make_unsigned(nLayer) >= mpLayers->size())
{ const sal_Int32 nOldLayerCount (mpLayers->size());
mpLayers->resize(nLayer+1);
for (size_t nIndex=nOldLayerCount; nIndex<mpLayers->size(); ++nIndex)
(*mpLayers)[nIndex] = std::make_shared<Layer>();
}
(*mpLayers)[nLayer]->AddPainter(rpPainter); if (nLayer == 0)
(*mpLayers)[nLayer]->Initialize(mpTargetWindow);
// Remove top most layers that do not contain any painters. while ( ! mpLayers->empty() && ! mpLayers->back()->HasPainter())
mpLayers->pop_back();
}
void LayeredDevice::Repaint (const vcl::Region& rRepaintRegion)
{ // Validate the contents of all layers (that have their own devices.) for (autoconst& it : *mpLayers)
{
it->Validate(mpTargetWindow->GetMapMode());
}
void LayeredDevice::RepaintRectangle (const ::tools::Rectangle& rRepaintRectangle)
{ if (mpLayers->empty()) return; elseif (mpLayers->size() == 1)
{ // Just copy the main layer into the target device.
(*mpLayers)[0]->Repaint(*mpTargetWindow->GetOutDev(), rRepaintRectangle);
} else
{ // Paint all layers first into the back buffer (to avoid flickering // due to synchronous paints) and then copy that into the target // device.
mpBackBuffer->SetMapMode(mpTargetWindow->GetMapMode()); for (autoconst& it : *mpLayers)
{
it->Repaint(*mpBackBuffer, rRepaintRectangle);
}
DeviceCopy(*mpTargetWindow->GetOutDev(), *mpBackBuffer, rRepaintRectangle);
}
}
void LayeredDevice::Resize()
{ const Size aSize (mpTargetWindow->GetSizePixel());
mpBackBuffer->SetOutputSizePixel(aSize); for (autoconst& it : *mpLayers)
{
it->Resize(aSize);
}
}
void LayeredDevice::Dispose()
{ for (autoconst& it : *mpLayers)
{
it->Dispose();
}
mpLayers->clear();
}
const ::tools::Rectangle aLogicWindowBox (
mpTargetWindow->PixelToLogic(::tools::Rectangle(Point(0,0), mpTargetWindow->GetSizePixel()))); if (maSavedMapMode.GetScaleX() != rMapMode.GetScaleX()
|| maSavedMapMode.GetScaleY() != rMapMode.GetScaleY()
|| maSavedMapMode.GetMapUnit() != rMapMode.GetMapUnit())
{ // When the scale has changed then we have to paint everything.
InvalidateAllLayers(aLogicWindowBox);
} elseif (maSavedMapMode.GetOrigin() != rMapMode.GetOrigin())
{ // Window has been scrolled. Adapt contents of backbuffers and // layer devices. const Point aDelta (rMapMode.GetOrigin() - maSavedMapMode.GetOrigin());
mpBackBuffer->CopyArea(
aLogicWindowBox.TopLeft(),
mpTargetWindow->PixelToLogic(Point(0,0), maSavedMapMode),
aLogicWindowBox.GetSize());
// Invalidate the area(s) that have been exposed. const ::tools::Rectangle aWindowBox (Point(0,0), mpTargetWindow->GetSizePixel()); if (aDelta.Y() < 0)
InvalidateAllLayers(mpTargetWindow->PixelToLogic(::tools::Rectangle(
aWindowBox.Left(),
aWindowBox.Bottom()+aDelta.Y(),
aWindowBox.Right(),
aWindowBox.Bottom()))); elseif (aDelta.Y() > 0)
InvalidateAllLayers(mpTargetWindow->PixelToLogic(::tools::Rectangle(
aWindowBox.Left(),
aWindowBox.Top(),
aWindowBox.Right(),
aWindowBox.Top()+aDelta.Y()))); if (aDelta.X() < 0)
InvalidateAllLayers(mpTargetWindow->PixelToLogic(::tools::Rectangle(
aWindowBox.Right()+aDelta.X(),
aWindowBox.Top(),
aWindowBox.Right(),
aWindowBox.Bottom()))); elseif (aDelta.X() > 0)
InvalidateAllLayers(mpTargetWindow->PixelToLogic(::tools::Rectangle(
aWindowBox.Left(),
aWindowBox.Top(),
aWindowBox.Left()+aDelta.X(),
aWindowBox.Bottom())));
} else
{ // Can this happen? Lets trigger a warning when it does.
OSL_ASSERT(false);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.