[Libreoffice-commits] core.git: Branch 'feature/priorities' - include/vcl vcl/inc vcl/source
include/vcl/timer.hxx|1 + vcl/inc/svdata.hxx |1 - vcl/source/app/idle.cxx | 10 +- vcl/source/app/svapp.cxx |9 +++-- vcl/source/app/timer.cxx | 41 +++-- 5 files changed, 20 insertions(+), 42 deletions(-) New commits: commit 6168c160f89887d90c3b969e99b09d847f60140e Author: Tobias Madl tobias.madl@gmail.com Date: Mon Jan 19 13:08:26 2015 + Optimized Timer/Idle code Change-Id: I285bd632faba5a29a770404d6967f4faf7667b16 diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx index 3aca8e5..635a045 100644 --- a/include/vcl/timer.hxx +++ b/include/vcl/timer.hxx @@ -63,6 +63,7 @@ public: static void ImplDeInitTimer(); static void ImplTimerCallbackProc(); static bool TimerReady(); +static bool CheckExpiredTimer(const bool bDoInvoke); }; /// An auto-timer is a multi-shot timer re-emitting itself at diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index fc49591..b227173 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -320,7 +320,6 @@ struct ImplSVData sal_uLong mnTimerPeriod; // current timer period sal_uLong mnTimerUpdate; // TimerCallbackProcs on stack boolmbNotAllTimerCalled;// true: Timer must still be processed -boolmbNoCallTimer; // true: No Timeout calls ImplSVAppData maAppData; // indepen data for class Application ImplSVGDIData maGDIData; // indepen data for Output classes ImplSVWinData maWinData; // indepen data for Windows classes diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx index 74f0eaf..c3e24e1 100644 --- a/vcl/source/app/idle.cxx +++ b/vcl/source/app/idle.cxx @@ -185,7 +185,6 @@ void Idle::Start() // insert timer and start mpIdleData = new ImplIdleData; mpIdleData-mpIdle= this; -mpIdleData-mbDelete = false; mpIdleData-mbInIdle= false; // insert last due to SFX! @@ -202,14 +201,7 @@ void Idle::Start() else pSVData-mpFirstIdleData = mpIdleData; } -else if( !mpIdleData-mpIdle ) // TODO: remove when guilty found -{ -OSL_FAIL( Idle::Start() on a destroyed Idle! ); -} -else -{ -mpIdleData-mbDelete= false; -} +mpIdleData-mbDelete= false; } void Idle::Stop() diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index fa97a4f..0dcdee9 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -343,11 +343,8 @@ inline void ImplYield( bool i_bWait, bool i_bAllEvents ) ImplSVData* pSVData = ImplGetSVData(); // run timers that have timed out -if ( !pSVData-mbNoCallTimer ) -{ -while ( pSVData-mbNotAllTimerCalled ) -Timer::ImplTimerCallbackProc(); -} +while ( pSVData-mbNotAllTimerCalled ) +Timer::ImplTimerCallbackProc(); //Process all idles Idle::Idle::ProcessAllIdleHandlers(); @@ -368,7 +365,7 @@ inline void ImplYield( bool i_bWait, bool i_bAllEvents ) // the system timer events will not necessarily come in non waiting mode // e.g. on OS X; need to trigger timer checks manually -if( pSVData-maAppData.mbNoYield !pSVData-mbNoCallTimer ) +if( pSVData-maAppData.mbNoYield ) { do { diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx index 4adc8e8..ff7233c 100644 --- a/vcl/source/app/timer.cxx +++ b/vcl/source/app/timer.cxx @@ -117,33 +117,10 @@ void Timer::ImplTimerCallbackProc() sal_uLong nDeltaTime; sal_uLong nTime = tools::Time::GetSystemTicks(); -if ( pSVData-mbNoCallTimer ) -return; - pSVData-mnTimerUpdate++; pSVData-mbNotAllTimerCalled = true; -// find timer where the timer handler needs to be called -pTimerData = pSVData-mpFirstTimerData; -while ( pTimerData ) -{ -// If the timer is not new, was not deleted, and if it is not in the timeout handler, then -// call the handler as soon as the time is up. -if ( (pTimerData-mnTimerUpdate pSVData-mnTimerUpdate) - !pTimerData-mbDelete !pTimerData-mbInTimeout) -{ -// time has expired -if ( pTimerData-GetDeadline() = nTime ) -{ -// set new update time -pTimerData-mnUpdateTime = nTime; - -pTimerData-Invoke(); -} -} - -pTimerData = pTimerData-mpNext; -} +Timer::CheckExpiredTimer(true); // determine new time sal_uLong nNewTime = tools::Time::GetSystemTicks(); @@ -212,10 +189,16 @@ void Timer::ImplTimerCallbackProc() bool Timer::TimerReady() { +return Timer::CheckExpiredTimer(false); +} + +bool
[Libreoffice-commits] core.git: Branch 'feature/priorities' - include/vcl vcl/inc vcl/source
include/vcl/idle.hxx | 84 ++ include/vcl/timer.hxx| 41 vcl/inc/svdata.hxx |3 vcl/inc/window.h |1 vcl/source/app/idle.cxx | 218 +++ vcl/source/app/svapp.cxx |3 vcl/source/app/timer.cxx | 98 - 7 files changed, 310 insertions(+), 138 deletions(-) New commits: commit f23d12b5fc9e1750972b0f67cff8b6ac40538469 Author: Tobias Madl tobias.madl@gmail.com Date: Wed Jan 14 08:29:37 2015 +0100 Idle: Idle and Timer completely independend Now the Idle and Timer are divided in two seperate classes. But now all changed idles need a new import, before the programm is working again. Change-Id: I5be7424622b6fcc993c621fa4a11fbee1b6d9bf2 diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx new file mode 100644 index 000..9da8414 --- /dev/null +++ b/include/vcl/idle.hxx @@ -0,0 +1,84 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_VCL_IDLE_HXX +#define INCLUDED_VCL_IDLE_HXX + +#include tools/link.hxx +#include tools/solar.h +#include vcl/dllapi.h + +struct ImplIdleData; +struct ImplSVData; + +enum class IdlePriority { +VCL_IDLE_PRIORITY_HIGHEST = 0, // - 0ms +VCL_IDLE_PRIORITY_HIGH = 1,// - 1ms +VCL_IDLE_PRIORITY_REPAINT = 2, // - 30ms +VCL_IDLE_PRIORITY_RESIZE= 3, // - 50ms +VCL_IDLE_PRIORITY_MEDIUM= 4, // - 50ms +VCL_IDLE_PRIORITY_LOW = 5, // - 100ms +VCL_IDLE_PRIORITY_LOWER = 6, // - 200ms +VCL_IDLE_PRIORITY_LOWEST= 7 // - 400ms +}; + + +// To port from Timer - Idle switch class name, +// s/Timeout/DoIdle/ etc. and select priority +class VCL_DLLPUBLIC Idle +{ +protected: +ImplIdleData* mpIdleData; +IdlePrioritymePriority; +boolmbActive; +LinkmaIdleHdl; + +friend struct ImplIdleData; + +public: +Idle(); +Idle( const Idle rIdle ); +virtual ~Idle(); + +void SetPriority( IdlePriority ePriority ) { mePriority = ePriority; } +IdlePriority GetPriority() const { return mePriority; } + +/// Make it possible to associate a callback with this idle handler +/// of course, you can also sub-class and override 'DoIdle' +voidSetIdleHdl( const Link rLink ) { maIdleHdl = rLink; } +const Link GetIdleHdl() const { return maIdleHdl; } + +virtual voidDoIdle(); + +voidStart(); +voidStop(); + +boolIsActive() const { return mbActive; } + +Idle operator=( const Idle rIdle ); +static void ImplDeInitIdle(); +static void ImplIdleCallbackProc(); + +/// Process all pending idle tasks ahead of time in priority order. +static void ProcessAllIdleHandlers(); +}; + +#endif // INCLUDED_VCL_IDLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx index 11e8f3f..ea65d6f 100644 --- a/include/vcl/timer.hxx +++ b/include/vcl/timer.hxx @@ -35,7 +35,6 @@ protected: sal_uLong mnTimeout; boolmbActive; boolmbAuto; -boolmbIdle; LinkmaTimeoutHdl; friend struct ImplTimerData; @@ -63,9 +62,6 @@ public: static void ImplDeInitTimer(); static void ImplTimerCallbackProc(); - -/// Process all pending idle tasks ahead of time in priority order. -static void ProcessAllIdleHandlers(); }; /// An auto-timer is a multi-shot timer re-emitting itself at @@ -78,43 +74,6 @@ public: AutoTimer operator=( const AutoTimer rTimer ); }; - -enum IdlePriority { -VCL_IDLE_PRIORITY_HIGHEST, // - 0ms -VCL_IDLE_PRIORITY_HIGH,// - 1ms -VCL_IDLE_PRIORITY_REPAINT, // - 30ms -VCL_IDLE_PRIORITY_RESIZE, // - 50ms -VCL_IDLE_PRIORITY_MEDIUM, // - 50ms -VCL_IDLE_PRIORITY_LOW, // - 100ms -VCL_IDLE_PRIORITY_LOWER, // - 200ms -VCL_IDLE_PRIORITY_LOWEST // - 400ms -}; - - -// To port from Timer - Idle switch class name, -// s/Timeout/DoIdle/ etc. and select
[Libreoffice-commits] core.git: Branch 'feature/priorities' - include/vcl vcl/inc vcl/source
include/vcl/timer.hxx| 35 + vcl/inc/window.h |4 +-- vcl/source/app/timer.cxx | 45 +++ vcl/source/window/window.cxx |8 +++ 4 files changed, 86 insertions(+), 6 deletions(-) New commits: commit ad71bd6715be6b37ecc3af1beef96e22caa5b394 Author: Jennifer Liebel jliebe...@gmail.com Date: Fri Oct 31 08:17:33 2014 + applied patch from Michael Meeks Change-Id: I57f22b6d9bfbef4a50d162076b01e8e64edb4718 diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx index d3ebe1a..5c3a49a 100644 --- a/include/vcl/timer.hxx +++ b/include/vcl/timer.hxx @@ -73,6 +73,41 @@ public: AutoTimer operator=( const AutoTimer rTimer ); }; +enum IdlePriority { +VCL_IDLE_PRIORITY_HIGHEST, // - 0ms +VCL_IDLE_PRIORITY_HIGH,// - 1ms +VCL_IDLE_PRIORITY_REPAINT, // - 30ms +VCL_IDLE_PRIORITY_RESIZE, // - 50ms +VCL_IDLE_PRIORITY_MEDIUM, // - 50ms +VCL_IDLE_PRIORITY_LOW, // - 100ms +VCL_IDLE_PRIORITY_LOWER, // - 200ms +VCL_IDLE_PRIORITY_LOWEST // - 400ms +}; + + +// To port from Timer - Idle switch class name, +// s/Timeout/DoIdle/ etc. and select priority +class VCL_DLLPUBLIC Idle : private Timer +{ + public: +Idle( IdlePriority ePriority ); +virtual ~Idle(); + +void SetPriority( IdlePriority ePriority ); + +/// Make it possible to associate a callback with this idle handler +/// of course, you can also sub-class and override 'DoIdle' +voidSetIdleHdl( const Link rLink ) { SetTimeoutHdl( rLink ); } +const Link GetIdleHdl() const { return GetTimeoutHdl(); } + +voidStart() { Timer::Start(); } +voidStop() { Timer::Stop(); } + +virtual voidDoIdle() = 0; + +virtual voidTimeout() SAL_OVERRIDE { DoIdle(); } +}; + #endif // INCLUDED_VCL_TIMER_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/window.h b/vcl/inc/window.h index 53d077f..60a4489 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -127,8 +127,8 @@ struct ImplOverlapData struct ImplFrameData { -Timer maPaintTimer; // paint timer -Timer maResizeTimer; // resize timer +IdlemaPaintIdle;// paint idle handler +IdlemaResizeTimer; // resize timer InputContextmaOldInputContext; // last set Input Context vcl::Window*mpNextFrame;// next frame window vcl::Window*mpFirstOverlap; // first overlap vcl::Window diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx index ecbfa74..e38c347 100644 --- a/vcl/source/app/timer.cxx +++ b/vcl/source/app/timer.cxx @@ -336,4 +336,49 @@ AutoTimer AutoTimer::operator=( const AutoTimer rTimer ) return *this; } +Idle::Idle( IdlePriority ePriority ) +: Timer() +{ +SetPriority( ePriority ); +} + +void Idle::SetPriority( IdlePriority ePriority ) +{ +sal_ulong nTimeoutMS = 0; + +// Ultimately this will just be a sort key in a work queue. +switch (ePriority) { +case VCL_IDLE_PRIORITY_HIGHEST: +nTimeoutMS = 0; +break; +case VCL_IDLE_PRIORITY_HIGH: +nTimeoutMS = 1; +break; +case VCL_IDLE_PRIORITY_REPAINT: +nTimeoutMS = 30; +break; +case VCL_IDLE_PRIORITY_RESIZE: +nTimeoutMS = 50; +break; +case VCL_IDLE_PRIORITY_MEDIUM: +nTimeoutMS = 50; +break; +case VCL_IDLE_PRIORITY_LOW: +nTimeoutMS = 100; +break; +case VCL_IDLE_PRIORITY_LOWER: +nTimeoutMS = 200; +break; +case VCL_IDLE_PRIORITY_LOWEST: +default: +nTimeoutMS = 400; +break; +} +SetTimeout( nTimeoutMS ); +} + +Idle::~Idle() +{ +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 606a4f5..a1ac1a1 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -1029,11 +1029,11 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p mpWindowImpl-mpFrameData-mbSysObjFocus = false; if (!ImplDoTiledRendering()) { -mpWindowImpl-mpFrameData-maPaintTimer.SetTimeout( 30 ); -mpWindowImpl-mpFrameData-maPaintTimer.SetTimeoutHdl( LINK( this, Window, ImplHandlePaintHdl ) ); +mpWindowImpl-mpFrameData-maPaintIdle.SetPriority( VCL_IDLE_PRIORITY_REPAINT ); +mpWindowImpl-mpFrameData-maPaintIDle.SetIdleHdl( LINK( this, Window, ImplHandlePaintHdl ) ); } -mpWindowImpl-mpFrameData-maResizeTimer.SetTimeout( 50 ); -mpWindowImpl-mpFrameData-maResizeTimer.SetTimeoutHdl( LINK( this, Window, ImplHandleResizeTimerHdl ) ); +mpWindowImpl-mpFrameData-maResizeIdle.SetPriority(
[Libreoffice-commits] core.git: Branch 'feature/priorities' - include/vcl vcl/inc vcl/source
include/vcl/timer.hxx |5 +++-- vcl/inc/window.h |2 +- vcl/source/app/timer.cxx | 14 +- vcl/source/window/paint.cxx | 16 vcl/source/window/window.cxx |8 vcl/source/window/winproc.cxx |2 +- 6 files changed, 30 insertions(+), 17 deletions(-) New commits: commit 74afbb7aa871c846f23c85cb1e1620b3b3590ab1 Author: Tobias Madl tobias.madl@gmail.com Date: Fri Oct 31 10:25:49 2014 + Michael's patch implemented Change-Id: I3f0802d5001172fc7b8409274bc5a3632e5dad34 diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx index 5c3a49a..10dd3fc 100644 --- a/include/vcl/timer.hxx +++ b/include/vcl/timer.hxx @@ -87,9 +87,10 @@ enum IdlePriority { // To port from Timer - Idle switch class name, // s/Timeout/DoIdle/ etc. and select priority -class VCL_DLLPUBLIC Idle : private Timer +class VCL_DLLPUBLIC Idle : public Timer { public: +Idle(); Idle( IdlePriority ePriority ); virtual ~Idle(); @@ -103,7 +104,7 @@ class VCL_DLLPUBLIC Idle : private Timer voidStart() { Timer::Start(); } voidStop() { Timer::Stop(); } -virtual voidDoIdle() = 0; +virtual voidDoIdle(); virtual voidTimeout() SAL_OVERRIDE { DoIdle(); } }; diff --git a/vcl/inc/window.h b/vcl/inc/window.h index 60a4489..2b2082e 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -128,7 +128,7 @@ struct ImplOverlapData struct ImplFrameData { IdlemaPaintIdle;// paint idle handler -IdlemaResizeTimer; // resize timer +IdlemaResizeIdle; // resize timer InputContextmaOldInputContext; // last set Input Context vcl::Window*mpNextFrame;// next frame window vcl::Window*mpFirstOverlap; // first overlap vcl::Window diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx index e38c347..5f706ab 100644 --- a/vcl/source/app/timer.cxx +++ b/vcl/source/app/timer.cxx @@ -336,6 +336,12 @@ AutoTimer AutoTimer::operator=( const AutoTimer rTimer ) return *this; } +Idle::Idle() +: Timer() +{ +SetPriority(VCL_IDLE_PRIORITY_LOWEST); +} + Idle::Idle( IdlePriority ePriority ) : Timer() { @@ -344,7 +350,7 @@ Idle::Idle( IdlePriority ePriority ) void Idle::SetPriority( IdlePriority ePriority ) { -sal_ulong nTimeoutMS = 0; +sal_uLong nTimeoutMS = 0; // Ultimately this will just be a sort key in a work queue. switch (ePriority) { @@ -377,6 +383,12 @@ void Idle::SetPriority( IdlePriority ePriority ) SetTimeout( nTimeoutMS ); } +void Idle::DoIdle() +{ +maTimeoutHdl.Call( this ); +} + + Idle::~Idle() { } diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx index ce10aba..7ec329c 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -283,8 +283,8 @@ void Window::ImplCallOverlapPaint() void Window::ImplPostPaint() { -if ( !ImplDoTiledRendering() !mpWindowImpl-mpFrameData-maPaintTimer.IsActive() ) -mpWindowImpl-mpFrameData-maPaintTimer.Start(); +if ( !ImplDoTiledRendering() !mpWindowImpl-mpFrameData-maPaintIdle.IsActive() ) +mpWindowImpl-mpFrameData-maPaintIdle.Start(); } IMPL_LINK_NOARG(Window, ImplHandlePaintHdl) @@ -292,14 +292,14 @@ IMPL_LINK_NOARG(Window, ImplHandlePaintHdl) // save paint events until layout is done if (!ImplDoTiledRendering() IsSystemWindow() static_castconst SystemWindow*(this)-hasPendingLayout()) { -mpWindowImpl-mpFrameData-maPaintTimer.Start(); +mpWindowImpl-mpFrameData-maPaintIdle.Start(); return 0; } // save paint events until resizing is done if( !ImplDoTiledRendering() -mpWindowImpl-mbFrame mpWindowImpl-mpFrameData-maResizeTimer.IsActive() ) -mpWindowImpl-mpFrameData-maPaintTimer.Start(); +mpWindowImpl-mbFrame mpWindowImpl-mpFrameData-maResizeIdle.IsActive() ) +mpWindowImpl-mpFrameData-maPaintIdle.Start(); else if ( mpWindowImpl-mbReallyVisible ) ImplCallOverlapPaint(); return 0; @@ -314,10 +314,10 @@ IMPL_LINK_NOARG(Window, ImplHandleResizeTimerHdl) { ImplHandlePaintHdl(NULL); } -else if( mpWindowImpl-mpFrameData-maPaintTimer.IsActive() ) +else if( mpWindowImpl-mpFrameData-maPaintIdle.IsActive() ) { -mpWindowImpl-mpFrameData-maPaintTimer.Stop(); -mpWindowImpl-mpFrameData-maPaintTimer.GetTimeoutHdl().Call( NULL ); +mpWindowImpl-mpFrameData-maPaintIdle.Stop(); +mpWindowImpl-mpFrameData-maPaintIdle.GetIdleHdl().Call( NULL ); } } diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index a1ac1a1..b446884 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -1030,7 +1030,7 @@ void