summaryrefslogtreecommitdiff
path: root/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2008-04-03 13:20:19 +0000
committerKurt Zenker <kz@openoffice.org>2008-04-03 13:20:19 +0000
commit1e6c04a8bd9ab555c73ae1ae39ead86061bd063c (patch)
treed37b864cca36192d1c46a620f7f8a55371c12c6e /sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
parent41622d70157da426de62d9504ee42f59ef9ba7a4 (diff)
INTEGRATION: CWS presenterview (1.8.54); FILE MERGED
2008/02/26 12:17:38 af 1.8.54.1: #i18486# Dropped the use of templates for implementing cache classes.
Diffstat (limited to 'sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx')
-rw-r--r--sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx199
1 files changed, 186 insertions, 13 deletions
diff --git a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
index 69a686e3acc8..58c20aaf6470 100644
--- a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: SlsQueueProcessor.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: kz $ $Date: 2006-12-12 18:19:19 $
+ * last change: $Author: kz $ $Date: 2008-04-03 14:20:19 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -33,21 +33,34 @@
*
************************************************************************/
-// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx"
#include "SlsQueueProcessor.hxx"
#include "SlsCacheConfiguration.hxx"
+#include "SlsRequestQueue.hxx"
+#include "SlsIdleDetector.hxx"
namespace sd { namespace slidesorter { namespace cache {
-//===== QueueProcessorBase ===================================================
+//===== QueueProcessor ======================================================
-QueueProcessorBase::QueueProcessorBase (void)
- : mnTimeBetweenHighPriorityRequests (10/*ms*/),
+QueueProcessor::QueueProcessor (
+ RequestQueue& rQueue,
+ const ::boost::shared_ptr<BitmapCache>& rpCache,
+ const Size& rPreviewSize,
+ const SharedCacheContext& rpCacheContext)
+ : maMutex(),
+ maTimer(),
+ mnTimeBetweenHighPriorityRequests (10/*ms*/),
mnTimeBetweenLowPriorityRequests (100/*ms*/),
- mnTimeBetweenRequestsWhenNotIdle (1000/*ms*/)
+ mnTimeBetweenRequestsWhenNotIdle (1000/*ms*/),
+ maPreviewSize(rPreviewSize),
+ mpCacheContext(rpCacheContext),
+ mrQueue(rQueue),
+ mpCache(rpCache),
+ maBitmapFactory(),
+ mbIsPaused(false)
{
// Look into the configuration if there for overriding values.
::com::sun::star::uno::Any aTimeBetweenReqeusts;
@@ -66,16 +79,25 @@ QueueProcessorBase::QueueProcessorBase (void)
if (aTimeBetweenReqeusts.has<sal_Int32>())
aTimeBetweenReqeusts >>= mnTimeBetweenRequestsWhenNotIdle;
- maTimer.SetTimeoutHdl (LINK(this,QueueProcessorBase,ProcessRequestHdl));
+ maTimer.SetTimeoutHdl (LINK(this,QueueProcessor,ProcessRequestHdl));
maTimer.SetTimeout (mnTimeBetweenHighPriorityRequests);
}
-QueueProcessorBase::~QueueProcessorBase()
+
+
+
+
+QueueProcessor::~QueueProcessor (void)
{
}
-void QueueProcessorBase::Start (int nPriorityClass)
+
+
+
+void QueueProcessor::Start (int nPriorityClass)
{
+ if (mbIsPaused)
+ return;
if ( ! maTimer.IsActive())
{
if (nPriorityClass == 0)
@@ -89,7 +111,7 @@ void QueueProcessorBase::Start (int nPriorityClass)
-void QueueProcessorBase::Stop (void)
+void QueueProcessor::Stop (void)
{
if (maTimer.IsActive())
maTimer.Stop();
@@ -98,13 +120,164 @@ void QueueProcessorBase::Stop (void)
-IMPL_LINK(QueueProcessorBase, ProcessRequestHdl, Timer*, EMPTYARG)
+void QueueProcessor::Pause (void)
+{
+ mbIsPaused = true;
+}
+
+
+
+
+void QueueProcessor::Resume (void)
+{
+ mbIsPaused = false;
+ if ( ! mrQueue.IsEmpty())
+ Start(mrQueue.GetFrontPriorityClass());
+}
+
+
+
+
+void QueueProcessor::Terminate (void)
+{
+}
+
+
+
+
+void QueueProcessor::SetPreviewSize (const Size& rPreviewSize)
+{
+ maPreviewSize = rPreviewSize;
+}
+
+
+
+
+IMPL_LINK(QueueProcessor, ProcessRequestHdl, Timer*, EMPTYARG)
{
- ProcessRequest();
+ ProcessRequests();
return 1;
}
+void QueueProcessor::ProcessRequests (void)
+{
+ OSL_ASSERT(mpCacheContext.get()!=NULL);
+
+ while ( ! mrQueue.IsEmpty() && ! mbIsPaused)
+ {
+ if ( ! mpCacheContext->IsIdle())
+ break;
+
+ CacheKey aKey = NULL;
+ RequestPriorityClass ePriorityClass (NOT_VISIBLE);
+ {
+ ::osl::MutexGuard aGuard (mrQueue.GetMutex());
+
+ if ( ! mrQueue.IsEmpty())
+ {
+ // Get the request with the highest priority from the queue.
+ ePriorityClass = mrQueue.GetFrontPriorityClass();
+ aKey = mrQueue.GetFront();
+ mrQueue.PopFront();
+ }
+ }
+
+ if (aKey != NULL)
+ ProcessOneRequest(aKey, ePriorityClass);
+
+ // Requests of lower priority are processed one at a time.
+ {
+ ::osl::MutexGuard aGuard (mrQueue.GetMutex());
+ if ( ! mrQueue.IsEmpty())
+ if (mrQueue.GetFrontPriorityClass() > 0)
+ break;
+ }
+ }
+
+ // Schedule the processing of the next element(s).
+ {
+ ::osl::MutexGuard aGuard (mrQueue.GetMutex());
+ if ( ! mrQueue.IsEmpty())
+ /*
+ if (bIsShowingFullScreenShow)
+ Start(mnTimeBetweenRequestsWhenNotIdle);
+ else
+ */
+ Start(mrQueue.GetFrontPriorityClass());
+ }
+}
+
+
+
+
+void QueueProcessor::ProcessOneRequest (
+ CacheKey aKey,
+ const RequestPriorityClass ePriorityClass)
+{
+ const SdrPage* pPage = mpCacheContext->GetPage(aKey);
+ SSCD_SET_STATUS(pPage,RENDERING);
+
+#ifdef VERBOSE
+ OSL_TRACE ("processing request for page %d with priority class %d",
+ (pPage->GetPageNum()-1)/2,
+ ePriorityClass);
+#endif
+ try
+ {
+ ::osl::MutexGuard aGuard (maMutex);
+ // Create a new preview bitmap and store it in the cache.
+ if (mpCache.get() != NULL)
+ {
+ const SdPage* pSdPage = dynamic_cast<const SdPage*>(pPage);
+ if (pSdPage != NULL)
+ {
+ const ::boost::shared_ptr<BitmapEx> pPreview (
+ maBitmapFactory.CreateBitmap(*pSdPage, maPreviewSize));
+ mpCache->SetBitmap (
+ pPage,
+ pPreview,
+ ePriorityClass!=NOT_VISIBLE);
+
+ // Initiate a repaint of the new preview.
+ mpCacheContext->NotifyPreviewCreation(aKey, pPreview);
+
+ SSCD_SET_STATUS(pPage,NONE);
+ }
+ }
+ }
+ catch (::com::sun::star::uno::RuntimeException aException)
+ {
+ OSL_ASSERT("RuntimeException caught in QueueProcessor");
+ (void) aException;
+ }
+ catch (::com::sun::star::uno::Exception aException)
+ {
+ OSL_ASSERT("Exception caught in QueueProcessor");
+ (void) aException;
+ }
+}
+
+
+
+
+void QueueProcessor::RemoveRequest (CacheKey aKey)
+{
+ (void)aKey;
+ // See the method declaration above for an explanation why this makes sense.
+ ::osl::MutexGuard aGuard (maMutex);
+}
+
+
+
+
+void QueueProcessor::SetBitmapCache (
+ const ::boost::shared_ptr<BitmapCache>& rpCache)
+{
+ mpCache = rpCache;
+}
+
+
} } } // end of namespace ::sd::slidesorter::cache