std::unique_ptr<SalVirtualDevice> SvpSalInstance::CreateVirtualDevice(SalGraphics& rGraphics,
tools::Long &nDX, tools::Long &nDY,
DeviceFormat /*eFormat*/, const SystemGraphicsData& rGd)
{
SvpSalGraphics *pSvpSalGraphics = dynamic_cast<SvpSalGraphics*>(&rGraphics);
assert(pSvpSalGraphics); #ifndef ANDROID // tdf#127529 normally pPreExistingTarget is null and we are a true virtualdevice drawing to a backing buffer. // Occasionally, for canvas/slideshow, pPreExistingTarget is pre-provided as a hack to use the vcl drawing // apis to render onto a preexisting cairo surface. The necessity for that precedes the use of cairo in vcl proper
cairo_surface_t* pPreExistingTarget = static_cast<cairo_surface_t*>(rGd.pSurface); #else //ANDROID case
(void)rGd;
cairo_surface_t* pPreExistingTarget = nullptr; #endif
std::unique_ptr<SalVirtualDevice> xNew(new SvpSalVirtualDevice(pSvpSalGraphics->getSurface(), pPreExistingTarget)); if (!xNew->SetSize(nDX, nDY))
xNew.reset(); return xNew;
}
aEvent.m_pFrame->CallCallback( aEvent.m_nEvent, aEvent.m_pData ); if( aEvent.m_nEvent == SalEvent::Resize )
{ // this would be a good time to post a paint const SvpSalFrame* pSvpFrame = static_cast<const SvpSalFrame*>( aEvent.m_pFrame);
pSvpFrame->PostPaint();
}
bool SvpSalInstance::DoExecute(int &) {
assert(Application::IsUseSystemEventLoop()); // emscripten_set_main_loop will unwind the stack by throwing a JavaScript exception, so we need // to manually undo the call of AcquireYieldMutex() done in InitVCL:
ReleaseYieldMutex(false); // Somewhat randomly use an fps=100 argument so the loop callback is called 100 times per // second:
emscripten_set_main_loop_arg(loop, this, 100, 1);
O3TL_UNREACHABLE;
}
bool bWasEvent = DispatchUserEvents(bHandleAllCurrentEvents); if (!bHandleAllCurrentEvents && bWasEvent) returntrue;
// CheckTimeout() invokes the sal timer, which invokes the scheduler.
bWasEvent = CheckTimeout() || bWasEvent; constbool bMustSleep = bWait && !bWasEvent;
// This is wrong and must be removed! // We always want to drop the SolarMutex on yield; that is the whole point of yield. // If we know the LOK client has pending input events, then don't yet return, so those events // can be processed as well. if (!bMustSleep && !comphelper::LibreOfficeKit::anyInput()) return bWasEvent;
if (vcl::lok::isUnipoll())
{
ImplSVData* pSVData = ImplGetSVData(); if (pSVData->mpPollClosure)
{ int nPollResult = pSVData->mpPollCallback(pSVData->mpPollClosure, nTimeoutMicroS); if (nPollResult < 0)
pSVData->maAppData.mbAppQuit = true;
bWasEvent = bWasEvent || (nPollResult != 0);
}
} elseif (bMustSleep)
{
SvpSalYieldMutex *const pMutex(static_cast<SvpSalYieldMutex*>(GetYieldMutex()));
std::unique_lock<std::mutex> g(pMutex->m_WakeUpMainMutex); // wait for doRelease() or Wakeup() to set the condition if (nTimeoutMicroS == -1)
{
pMutex->m_WakeUpMainCond.wait(g,
[pMutex]() { return pMutex->m_wakeUpMain; });
} else
{ int nTimeoutMS = nTimeoutMicroS / 1000; if (nTimeoutMicroS % 1000)
nTimeoutMS += 1;
pMutex->m_WakeUpMainCond.wait_for(g,
std::chrono::milliseconds(nTimeoutMS),
[pMutex]() { return pMutex->m_wakeUpMain; });
} // here no need to check m_Request because Acquire will do it
}
if (IsMainThread())
{
bWasEvent = ImplYield(bWait, bHandleAllCurrentEvents); if (bWasEvent)
pMutex->m_NonMainWaitingYieldCond.set(); // wake up other threads
} else
{ // TODO: use a SolarMutexReleaser here and drop the m_bNoYieldLock usage
Wakeup(bHandleAllCurrentEvents
? SvpRequest::MainThreadDispatchAllEvents
: SvpRequest::MainThreadDispatchOneEvent);
// blocking read (for synchronisation)
{
std::unique_lock lock(pMutex->m_FeedbackMutex);
pMutex->m_FeedbackCV.wait(lock, [pMutex] { return !pMutex->m_FeedbackPipe.empty(); });
bWasEvent = pMutex->m_FeedbackPipe.front();
pMutex->m_FeedbackPipe.pop();
} if (!bWasEvent && bWait)
{ // block & release YieldMutex until the main thread does something
pMutex->m_NonMainWaitingYieldCond.reset();
SolarMutexReleaser aReleaser;
pMutex->m_NonMainWaitingYieldCond.wait();
}
}
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.