summaryrefslogtreecommitdiff
path: root/sd/source/ui/slidesorter/cache
diff options
context:
space:
mode:
Diffstat (limited to 'sd/source/ui/slidesorter/cache')
-rw-r--r--[-rwxr-xr-x]sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx150
-rw-r--r--[-rwxr-xr-x]sd/source/ui/slidesorter/cache/SlsBitmapCache.hxx44
-rwxr-xr-x[-rw-r--r--]sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx83
-rwxr-xr-x[-rw-r--r--]sd/source/ui/slidesorter/cache/SlsBitmapCompressor.hxx28
-rwxr-xr-x[-rw-r--r--]sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx41
-rwxr-xr-x[-rw-r--r--]sd/source/ui/slidesorter/cache/SlsBitmapFactory.hxx6
-rw-r--r--[-rwxr-xr-x]sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx141
-rw-r--r--[-rwxr-xr-x]sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx66
-rw-r--r--[-rwxr-xr-x]sd/source/ui/slidesorter/cache/SlsPageCache.cxx64
-rwxr-xr-x[-rw-r--r--]sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx51
-rwxr-xr-xsd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx18
-rwxr-xr-x[-rw-r--r--]sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx8
-rwxr-xr-x[-rw-r--r--]sd/source/ui/slidesorter/cache/SlsQueueProcessorThread.hxx46
-rwxr-xr-x[-rw-r--r--]sd/source/ui/slidesorter/cache/SlsRequestFactory.cxx2
-rwxr-xr-x[-rw-r--r--]sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx2
15 files changed, 484 insertions, 266 deletions
diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx b/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx
index 1bbecbef3d66..ddb50ea878e0 100755..100644
--- a/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx
@@ -33,7 +33,6 @@
#include "SlsBitmapCompressor.hxx"
#include "SlsCacheConfiguration.hxx"
-#include "taskpane/SlideSorterCacheDisplay.hxx"
#include "sdpage.hxx"
#include "drawdoc.hxx"
@@ -55,8 +54,7 @@ namespace sd { namespace slidesorter { namespace cache {
class BitmapCache::CacheEntry
{
public:
- CacheEntry(const ::boost::shared_ptr<BitmapEx>& rpBitmap,
- sal_Int32 nLastAccessTime, bool bIsPrecious);
+ CacheEntry(const Bitmap& rBitmap, sal_Int32 nLastAccessTime, bool bIsPrecious);
CacheEntry(sal_Int32 nLastAccessTime, bool bIsPrecious);
~CacheEntry (void) {};
inline void Recycle (const CacheEntry& rEntry);
@@ -68,18 +66,26 @@ public:
void SetUpToDate (bool bIsUpToDate) { mbIsUpToDate = bIsUpToDate; }
sal_Int32 GetAccessTime (void) const { return mnLastAccessTime; }
void SetAccessTime (sal_Int32 nAccessTime) { mnLastAccessTime = nAccessTime; }
- ::boost::shared_ptr<BitmapEx> GetPreview (void) const { return mpPreview; }
- inline void SetPreview (const ::boost::shared_ptr<BitmapEx>& rpPreview);
+
+ Bitmap GetPreview (void) const { return maPreview; }
+ inline void SetPreview (const Bitmap& rPreview);
bool HasPreview (void) const;
+
+ Bitmap GetMarkedPreview (void) const { return maMarkedPreview; }
+ inline void SetMarkedPreview (const Bitmap& rMarkePreview);
+ bool HasMarkedPreview (void) const;
+
bool HasReplacement (void) const { return (mpReplacement.get() != NULL); }
inline bool HasLosslessReplacement (void) const;
- void Clear (void) { mpPreview.reset(); mpReplacement.reset(); mpCompressor.reset(); }
+ void Clear (void) { maPreview.SetEmpty(); maMarkedPreview.SetEmpty();
+ mpReplacement.reset(); mpCompressor.reset(); }
void Invalidate (void) { mpReplacement.reset(); mpCompressor.reset(); mbIsUpToDate = false; }
bool IsPrecious (void) const { return mbIsPrecious; }
void SetPrecious (bool bIsPrecious) { mbIsPrecious = bIsPrecious; }
private:
- ::boost::shared_ptr<BitmapEx> mpPreview;
+ Bitmap maPreview;
+ Bitmap maMarkedPreview;
::boost::shared_ptr<BitmapReplacement> mpReplacement;
::boost::shared_ptr<BitmapCompressor> mpCompressor;
Size maBitmapSize;
@@ -221,7 +227,7 @@ bool BitmapCache::BitmapIsUpToDate (const CacheKey& rKey)
-::boost::shared_ptr<BitmapEx> BitmapCache::GetBitmap (const CacheKey& rKey)
+Bitmap BitmapCache::GetBitmap (const CacheKey& rKey)
{
::osl::MutexGuard aGuard (maMutex);
@@ -230,10 +236,9 @@ bool BitmapCache::BitmapIsUpToDate (const CacheKey& rKey)
{
// Create an empty bitmap for the given key that acts as placeholder
// until we are given the real one. Mark it as not being up to date.
- SetBitmap (rKey, ::boost::shared_ptr<BitmapEx>(new BitmapEx()), false);
+ SetBitmap(rKey, Bitmap(), false);
iEntry = mpBitmapContainer->find(rKey);
iEntry->second.SetUpToDate(false);
- SSCD_SET_UPTODATE(iEntry->first,false);
}
else
{
@@ -253,7 +258,39 @@ bool BitmapCache::BitmapIsUpToDate (const CacheKey& rKey)
-void BitmapCache::InvalidateBitmap (const CacheKey& rKey)
+Bitmap BitmapCache::GetMarkedBitmap (const CacheKey& rKey)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ CacheBitmapContainer::iterator iEntry (mpBitmapContainer->find(rKey));
+ if (iEntry != mpBitmapContainer->end())
+ {
+ iEntry->second.SetAccessTime(mnCurrentAccessTime++);
+ return iEntry->second.GetMarkedPreview();
+ }
+ else
+ return Bitmap();
+}
+
+
+
+
+void BitmapCache::ReleaseBitmap (const CacheKey& rKey)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ CacheBitmapContainer::iterator aIterator (mpBitmapContainer->find(rKey));
+ if (aIterator != mpBitmapContainer->end())
+ {
+ UpdateCacheSize(aIterator->second, REMOVE);
+ mpBitmapContainer->erase(aIterator);
+ }
+}
+
+
+
+
+bool BitmapCache::InvalidateBitmap (const CacheKey& rKey)
{
::osl::MutexGuard aGuard (maMutex);
@@ -261,7 +298,6 @@ void BitmapCache::InvalidateBitmap (const CacheKey& rKey)
if (iEntry != mpBitmapContainer->end())
{
iEntry->second.SetUpToDate(false);
- SSCD_SET_UPTODATE(iEntry->first,false);
// When there is a preview then we release the replacement. The
// preview itself is kept until a new one is created.
@@ -269,10 +305,12 @@ void BitmapCache::InvalidateBitmap (const CacheKey& rKey)
{
UpdateCacheSize(iEntry->second, REMOVE);
iEntry->second.Invalidate();
- SSCD_SET_UPTODATE(iEntry->first,false);
UpdateCacheSize(iEntry->second, ADD);
}
+ return true;
}
+ else
+ return false;
}
@@ -286,7 +324,6 @@ void BitmapCache::InvalidateCache (void)
for (iEntry=mpBitmapContainer->begin(); iEntry!=mpBitmapContainer->end(); ++iEntry)
{
iEntry->second.Invalidate();
- SSCD_SET_UPTODATE(iEntry->first,false);
}
ReCalculateTotalCacheSize();
}
@@ -296,7 +333,7 @@ void BitmapCache::InvalidateCache (void)
void BitmapCache::SetBitmap (
const CacheKey& rKey,
- const ::boost::shared_ptr<BitmapEx>& rpPreview,
+ const Bitmap& rPreview,
bool bIsPrecious)
{
::osl::MutexGuard aGuard (maMutex);
@@ -305,16 +342,15 @@ void BitmapCache::SetBitmap (
if (iEntry != mpBitmapContainer->end())
{
UpdateCacheSize(iEntry->second, REMOVE);
- iEntry->second.SetPreview(rpPreview);
+ iEntry->second.SetPreview(rPreview);
iEntry->second.SetUpToDate(true);
- SSCD_SET_UPTODATE(iEntry->first,true);
iEntry->second.SetAccessTime(mnCurrentAccessTime++);
}
else
{
iEntry = mpBitmapContainer->insert(CacheBitmapContainer::value_type (
rKey,
- CacheEntry (rpPreview, mnCurrentAccessTime++, bIsPrecious))
+ CacheEntry(rPreview, mnCurrentAccessTime++, bIsPrecious))
).first;
}
@@ -325,6 +361,25 @@ void BitmapCache::SetBitmap (
+void BitmapCache::SetMarkedBitmap (
+ const CacheKey& rKey,
+ const Bitmap& rPreview)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ CacheBitmapContainer::iterator iEntry (mpBitmapContainer->find(rKey));
+ if (iEntry != mpBitmapContainer->end())
+ {
+ UpdateCacheSize(iEntry->second, REMOVE);
+ iEntry->second.SetMarkedPreview(rPreview);
+ iEntry->second.SetAccessTime(mnCurrentAccessTime++);
+ UpdateCacheSize(iEntry->second, ADD);
+ }
+}
+
+
+
+
void BitmapCache::SetPrecious (const CacheKey& rKey, bool bIsPrecious)
{
::osl::MutexGuard aGuard (maMutex);
@@ -343,9 +398,7 @@ void BitmapCache::SetPrecious (const CacheKey& rKey, bool bIsPrecious)
{
iEntry = mpBitmapContainer->insert(CacheBitmapContainer::value_type (
rKey,
- CacheEntry (
- ::boost::shared_ptr<BitmapEx>(),
- mnCurrentAccessTime++, bIsPrecious))
+ CacheEntry(Bitmap(), mnCurrentAccessTime++, bIsPrecious))
).first;
UpdateCacheSize(iEntry->second, ADD);
}
@@ -503,7 +556,8 @@ void BitmapCache::UpdateCacheSize (const CacheEntry& rEntry, CacheOperation eOpe
BitmapCache::CacheEntry::CacheEntry(
sal_Int32 nLastAccessTime,
bool bIsPrecious)
- : mpPreview(),
+ : maPreview(),
+ maMarkedPreview(),
mbIsUpToDate(true),
mnLastAccessTime(nLastAccessTime),
mbIsPrecious(bIsPrecious)
@@ -514,10 +568,11 @@ BitmapCache::CacheEntry::CacheEntry(
BitmapCache::CacheEntry::CacheEntry(
- const ::boost::shared_ptr<BitmapEx>& rpPreview,
+ const Bitmap& rPreview,
sal_Int32 nLastAccessTime,
bool bIsPrecious)
- : mpPreview(rpPreview),
+ : maPreview(rPreview),
+ maMarkedPreview(),
mbIsUpToDate(true),
mnLastAccessTime(nLastAccessTime),
mbIsPrecious(bIsPrecious)
@@ -532,7 +587,8 @@ inline void BitmapCache::CacheEntry::Recycle (const CacheEntry& rEntry)
if ((rEntry.HasPreview() || rEntry.HasLosslessReplacement())
&& ! (HasPreview() || HasLosslessReplacement()))
{
- mpPreview = rEntry.mpPreview;
+ maPreview = rEntry.maPreview;
+ maMarkedPreview = rEntry.maMarkedPreview;
mpReplacement = rEntry.mpReplacement;
mpCompressor = rEntry.mpCompressor;
mnLastAccessTime = rEntry.mnLastAccessTime;
@@ -546,8 +602,8 @@ inline void BitmapCache::CacheEntry::Recycle (const CacheEntry& rEntry)
inline sal_Int32 BitmapCache::CacheEntry::GetMemorySize (void) const
{
sal_Int32 nSize (0);
- if (mpPreview.get() != NULL)
- nSize += mpPreview->GetSizeBytes();
+ nSize += maPreview.GetSizeBytes();
+ nSize += maMarkedPreview.GetSizeBytes();
if (mpReplacement.get() != NULL)
nSize += mpReplacement->GetMemorySize();
return nSize;
@@ -558,14 +614,14 @@ inline sal_Int32 BitmapCache::CacheEntry::GetMemorySize (void) const
void BitmapCache::CacheEntry::Compress (const ::boost::shared_ptr<BitmapCompressor>& rpCompressor)
{
- if (mpPreview.get() != NULL)
+ if ( ! maPreview.IsEmpty())
{
if (mpReplacement.get() == NULL)
{
- mpReplacement = rpCompressor->Compress(mpPreview);
+ mpReplacement = rpCompressor->Compress(maPreview);
#ifdef VERBOSE
- sal_uInt32 nOldSize (mpPreview->GetSizeBytes());
+ sal_uInt32 nOldSize (maPreview.GetSizeBytes());
sal_uInt32 nNewSize (mpReplacement.get()!=NULL ? mpReplacement->GetMemorySize() : 0);
if (nOldSize == 0)
nOldSize = 1;
@@ -580,7 +636,8 @@ void BitmapCache::CacheEntry::Compress (const ::boost::shared_ptr<BitmapCompress
mpCompressor = rpCompressor;
}
- mpPreview.reset();
+ maPreview.SetEmpty();
+ maMarkedPreview.SetEmpty();
}
}
@@ -589,9 +646,10 @@ void BitmapCache::CacheEntry::Compress (const ::boost::shared_ptr<BitmapCompress
inline void BitmapCache::CacheEntry::Decompress (void)
{
- if (mpReplacement.get()!=NULL && mpCompressor.get()!=NULL && mpPreview.get()==NULL)
+ if (mpReplacement.get()!=NULL && mpCompressor.get()!=NULL && maPreview.IsEmpty())
{
- mpPreview = mpCompressor->Decompress(*mpReplacement);
+ maPreview = mpCompressor->Decompress(*mpReplacement);
+ maMarkedPreview.SetEmpty();
if ( ! mpCompressor->IsLossless())
mbIsUpToDate = false;
}
@@ -599,9 +657,10 @@ inline void BitmapCache::CacheEntry::Decompress (void)
-inline void BitmapCache::CacheEntry::SetPreview (const ::boost::shared_ptr<BitmapEx>& rpPreview)
+inline void BitmapCache::CacheEntry::SetPreview (const Bitmap& rPreview)
{
- mpPreview = rpPreview;
+ maPreview = rPreview;
+ maMarkedPreview.SetEmpty();
mpReplacement.reset();
mpCompressor.reset();
}
@@ -611,10 +670,23 @@ inline void BitmapCache::CacheEntry::SetPreview (const ::boost::shared_ptr<Bitma
bool BitmapCache::CacheEntry::HasPreview (void) const
{
- if (mpPreview.get() != NULL)
- return mpPreview->GetSizePixel().Width()>0 && mpPreview->GetSizePixel().Height()>0;
- else
- return false;
+ return ! maPreview.IsEmpty();
+}
+
+
+
+
+inline void BitmapCache::CacheEntry::SetMarkedPreview (const Bitmap& rMarkedPreview)
+{
+ maMarkedPreview = rMarkedPreview;
+}
+
+
+
+
+bool BitmapCache::CacheEntry::HasMarkedPreview (void) const
+{
+ return ! maMarkedPreview.IsEmpty();
}
diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapCache.hxx b/sd/source/ui/slidesorter/cache/SlsBitmapCache.hxx
index 2c33e042342f..734c630d31ce 100755..100644
--- a/sd/source/ui/slidesorter/cache/SlsBitmapCache.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsBitmapCache.hxx
@@ -32,8 +32,8 @@ class SdrPage;
#include <vcl/bitmapex.hxx>
#include <osl/mutex.hxx>
-#include <memory>
#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
#include <hash_map>
namespace sd { namespace slidesorter { namespace cache {
@@ -44,10 +44,14 @@ class BitmapCompressor;
/** This low level cache is the actual bitmap container. It supports a
precious flag for every preview bitmap and keeps track of total sizes
- for all previews with as well as those without the flag. The precious
- flag is used by compaction algorithms to determine which previews may be
- compressed or even discarded and which have to remain in their original
- form. The precious flag is usually set for the visible previews.
+ for all previews with/without this flag. The precious flag is used by
+ compaction algorithms to determine which previews may be compressed or
+ even discarded and which have to remain in their original form. The
+ precious flag is usually set for the visible previews.
+
+ Additionally to the actual preview there is an optional marked preview.
+ This is used for slides excluded from the slide show which have a preview
+ that shows a mark (some sort of bitmap overlay) to that effect.
*/
class BitmapCache
{
@@ -102,11 +106,25 @@ public:
/** Return the preview bitmap for the given contact object.
*/
- ::boost::shared_ptr<BitmapEx> GetBitmap (const CacheKey& rKey);
+ Bitmap GetBitmap (const CacheKey& rKey);
- /** Mark the specified preview bitmap as not being up-to-date anymore.
+ /** Return the marked preview bitmap for the given contact object.
*/
- void InvalidateBitmap (const CacheKey& rKey);
+ Bitmap GetMarkedBitmap (const CacheKey& rKey);
+
+ /** Release the reference to the preview bitmap that is associated with
+ the given key.
+ */
+ void ReleaseBitmap (const CacheKey& rKey);
+
+ /** Mark the specified preview bitmap as not being up-to-date
+ anymore.
+ @return
+ When the key references a page in the cache then
+ return <TRUE/>. When the key is not known then <FALSE/>
+ is returned.
+ */
+ bool InvalidateBitmap (const CacheKey& rKey);
/** Mark all preview bitmaps as not being up-to-date anymore.
*/
@@ -116,9 +134,15 @@ public:
*/
void SetBitmap (
const CacheKey& rKey,
- const ::boost::shared_ptr<BitmapEx>& rpPreview,
+ const Bitmap& rPreview,
bool bIsPrecious);
+ /** Add or replace a marked bitmap for the given key.
+ */
+ void SetMarkedBitmap (
+ const CacheKey& rKey,
+ const Bitmap& rPreview);
+
/** Mark the specified preview bitmap as precious, i.e. that it must not
be compressed or otherwise removed from the cache.
*/
@@ -161,7 +185,7 @@ public:
private:
mutable ::osl::Mutex maMutex;
- ::std::auto_ptr<CacheBitmapContainer> mpBitmapContainer;
+ ::boost::scoped_ptr<CacheBitmapContainer> mpBitmapContainer;
/** Total size of bytes that are occupied by bitmaps in the cache for
whom the slides are currently not inside the visible area.
diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx b/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx
index 86fc72885414..e0f950442bb5 100644..100755
--- a/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.cxx
@@ -47,37 +47,24 @@ class NoBitmapCompression::DummyReplacement
: public BitmapReplacement
{
public:
- ::boost::shared_ptr<BitmapEx> mpPreview;
+ Bitmap maPreview;
Size maOriginalSize;
- DummyReplacement (const ::boost::shared_ptr<BitmapEx>& rpPreview) : mpPreview(rpPreview)
- {
- }
-
- virtual ~DummyReplacement();
-
- virtual sal_Int32 GetMemorySize (void) const;
+ DummyReplacement (const Bitmap& rPreview) : maPreview(rPreview) { }
+ virtual ~DummyReplacement(void) {}
+ virtual sal_Int32 GetMemorySize (void) const { return maPreview.GetSizeBytes(); }
};
-NoBitmapCompression::DummyReplacement::~DummyReplacement()
-{
-}
-sal_Int32 NoBitmapCompression::DummyReplacement::GetMemorySize (void) const
-{
- return mpPreview->GetSizeBytes();
-}
-::boost::shared_ptr<BitmapReplacement> NoBitmapCompression::Compress (
- const ::boost::shared_ptr<BitmapEx>& rpBitmap) const
+::boost::shared_ptr<BitmapReplacement> NoBitmapCompression::Compress (const Bitmap& rBitmap) const
{
- return ::boost::shared_ptr<BitmapReplacement>(new DummyReplacement(rpBitmap));
+ return ::boost::shared_ptr<BitmapReplacement>(new DummyReplacement(rBitmap));
}
-::boost::shared_ptr<BitmapEx> NoBitmapCompression::Decompress (
- const BitmapReplacement& rBitmapData) const
+Bitmap NoBitmapCompression::Decompress (const BitmapReplacement& rBitmapData) const
{
- return dynamic_cast<const DummyReplacement&>(rBitmapData).mpPreview;
+ return dynamic_cast<const DummyReplacement&>(rBitmapData).maPreview;
}
@@ -93,8 +80,7 @@ bool NoBitmapCompression::IsLossless (void) const
//===== CompressionByDeletion =================================================
-::boost::shared_ptr<BitmapReplacement> CompressionByDeletion::Compress (
- const ::boost::shared_ptr<BitmapEx>& ) const
+::boost::shared_ptr<BitmapReplacement> CompressionByDeletion::Compress (const Bitmap& ) const
{
return ::boost::shared_ptr<BitmapReplacement>();
}
@@ -102,12 +88,11 @@ bool NoBitmapCompression::IsLossless (void) const
-::boost::shared_ptr<BitmapEx> CompressionByDeletion::Decompress (
- const BitmapReplacement& ) const
+Bitmap CompressionByDeletion::Decompress (const BitmapReplacement& ) const
{
// Return a NULL pointer. This will eventually lead to a request for
// the creation of a new one.
- return ::boost::shared_ptr<BitmapEx>();
+ return Bitmap();
}
@@ -128,11 +113,10 @@ bool CompressionByDeletion::IsLossless (void) const
class ResolutionReduction::ResolutionReducedReplacement : public BitmapReplacement
{
public:
- ::boost::shared_ptr<BitmapEx> mpPreview;
+ Bitmap maPreview;
Size maOriginalSize;
virtual ~ResolutionReducedReplacement();
-
virtual sal_Int32 GetMemorySize (void) const;
};
@@ -142,23 +126,20 @@ ResolutionReduction::ResolutionReducedReplacement::~ResolutionReducedReplacement
sal_Int32 ResolutionReduction::ResolutionReducedReplacement::GetMemorySize (void) const
{
- if (mpPreview.get() != NULL)
- return mpPreview->GetSizeBytes();
- else
- return 0;
+ return maPreview.GetSizeBytes();
}
::boost::shared_ptr<BitmapReplacement> ResolutionReduction::Compress (
- const ::boost::shared_ptr<BitmapEx>& rpBitmap) const
+ const Bitmap& rBitmap) const
{
ResolutionReducedReplacement* pResult = new ResolutionReducedReplacement();
- pResult->mpPreview.reset(new BitmapEx(*rpBitmap));
- Size aSize (rpBitmap->GetSizePixel());
+ pResult->maPreview = rBitmap;
+ Size aSize (rBitmap.GetSizePixel());
pResult->maOriginalSize = aSize;
if (aSize.Width()>0 && aSize.Width()<mnWidth)
{
int nHeight = aSize.Height() * mnWidth / aSize.Width() ;
- pResult->mpPreview->Scale(Size(mnWidth,nHeight));
+ pResult->maPreview.Scale(Size(mnWidth,nHeight));
}
return ::boost::shared_ptr<BitmapReplacement>(pResult);
@@ -167,22 +148,21 @@ sal_Int32 ResolutionReduction::ResolutionReducedReplacement::GetMemorySize (void
-::boost::shared_ptr<BitmapEx> ResolutionReduction::Decompress (
- const BitmapReplacement& rBitmapData) const
+Bitmap ResolutionReduction::Decompress (const BitmapReplacement& rBitmapData) const
{
- ::boost::shared_ptr<BitmapEx> pResult;
+ Bitmap aResult;
const ResolutionReducedReplacement* pData (
dynamic_cast<const ResolutionReducedReplacement*>(&rBitmapData));
- if (pData->mpPreview.get() != NULL)
+ if ( ! pData->maPreview.IsEmpty())
{
- pResult.reset(new BitmapEx(*pData->mpPreview));
+ aResult = pData->maPreview;
if (pData->maOriginalSize.Width() > mnWidth)
- pResult->Scale(pData->maOriginalSize);
+ aResult.Scale(pData->maOriginalSize);
}
- return pResult;
+ return aResult;
}
@@ -223,15 +203,14 @@ public:
-::boost::shared_ptr<BitmapReplacement> PngCompression::Compress (
- const ::boost::shared_ptr<BitmapEx>& rpBitmap) const
+::boost::shared_ptr<BitmapReplacement> PngCompression::Compress (const Bitmap& rBitmap) const
{
- ::vcl::PNGWriter aWriter (*rpBitmap);
+ ::vcl::PNGWriter aWriter (rBitmap);
SvMemoryStream aStream (32768, 32768);
aWriter.Write(aStream);
PngReplacement* pResult = new PngReplacement();
- pResult->maImageSize = rpBitmap->GetSizePixel();
+ pResult->maImageSize = rBitmap.GetSizePixel();
pResult->mnDataSize = aStream.Tell();
pResult->mpData = new char[pResult->mnDataSize];
memcpy(pResult->mpData, aStream.GetData(), pResult->mnDataSize);
@@ -242,21 +221,19 @@ public:
-::boost::shared_ptr<BitmapEx> PngCompression::Decompress (
+Bitmap PngCompression::Decompress (
const BitmapReplacement& rBitmapData) const
{
- BitmapEx* pResult = NULL;
+ Bitmap aResult;
const PngReplacement* pData (dynamic_cast<const PngReplacement*>(&rBitmapData));
if (pData != NULL)
{
SvMemoryStream aStream (pData->mpData, pData->mnDataSize, STREAM_READ);
::vcl::PNGReader aReader (aStream);
- pResult = new BitmapEx(aReader.Read());
+ aResult = aReader.Read().GetBitmap();
}
-// sal_Int32 nRatio ((100L * (ULONG)pResult->GetSizeBytes()) / (ULONG)pData->mnDataSize);
-
- return ::boost::shared_ptr<BitmapEx>(pResult);
+ return aResult;
}
diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.hxx b/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.hxx
index cd564ddddcfd..35184449bfe2 100644..100755
--- a/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsBitmapCompressor.hxx
@@ -32,7 +32,8 @@
#include <tools/gen.hxx>
#include <boost/shared_ptr.hpp>
-class BitmapEx;
+
+class Bitmap;
namespace sd { namespace slidesorter { namespace cache {
@@ -48,8 +49,7 @@ public:
/** Compress the given bitmap into a replacement format that is specific
to the compressor class.
*/
- virtual ::boost::shared_ptr<BitmapReplacement> Compress (
- const ::boost::shared_ptr<BitmapEx>& rpBitmap) const = 0;
+ virtual ::boost::shared_ptr<BitmapReplacement> Compress (const Bitmap& rBitmap) const = 0;
/** Decompress the given replacement data into a preview bitmap.
Depending on the compression technique the returned bitmap may
@@ -58,7 +58,7 @@ public:
task of the caller to create a new preview bitmap if the returned
one is not as desired.
*/
- virtual ::boost::shared_ptr<BitmapEx> Decompress (const BitmapReplacement& rBitmapData)const=0;
+ virtual Bitmap Decompress (const BitmapReplacement& rBitmapData)const=0;
/** Return whether the compression and decompression is lossless. This
value is used by the caller of Decompress() to decide whether to use
@@ -91,9 +91,8 @@ class NoBitmapCompression
{
class DummyReplacement;
public:
- virtual ::boost::shared_ptr<BitmapReplacement> Compress (
- const ::boost::shared_ptr<BitmapEx>& rpBitmap) const;
- virtual ::boost::shared_ptr<BitmapEx> Decompress (const BitmapReplacement& rBitmapData) const;
+ virtual ::boost::shared_ptr<BitmapReplacement> Compress (const Bitmap& rpBitmap) const;
+ virtual Bitmap Decompress (const BitmapReplacement& rBitmapData) const;
virtual bool IsLossless (void) const;
};
@@ -109,9 +108,8 @@ class CompressionByDeletion
: public BitmapCompressor
{
public:
- virtual ::boost::shared_ptr<BitmapReplacement> Compress (
- const ::boost::shared_ptr<BitmapEx>& rpBitmap) const;
- virtual ::boost::shared_ptr<BitmapEx> Decompress (const BitmapReplacement& rBitmapData) const;
+ virtual ::boost::shared_ptr<BitmapReplacement> Compress (const Bitmap& rBitmap) const;
+ virtual Bitmap Decompress (const BitmapReplacement& rBitmapData) const;
virtual bool IsLossless (void) const;
};
@@ -129,11 +127,10 @@ class ResolutionReduction
class ResolutionReducedReplacement;
static const sal_Int32 mnWidth = 100;
public:
- virtual ::boost::shared_ptr<BitmapReplacement> Compress (
- const ::boost::shared_ptr<BitmapEx>& rpBitmap) const;
+ virtual ::boost::shared_ptr<BitmapReplacement> Compress (const Bitmap& rpBitmap) const;
/** Scale the replacement bitmap up to the original size.
*/
- virtual ::boost::shared_ptr<BitmapEx> Decompress (const BitmapReplacement& rBitmapData) const;
+ virtual Bitmap Decompress (const BitmapReplacement& rBitmapData) const;
virtual bool IsLossless (void) const;
};
@@ -148,9 +145,8 @@ class PngCompression
{
class PngReplacement;
public:
- virtual ::boost::shared_ptr<BitmapReplacement> Compress (
- const ::boost::shared_ptr<BitmapEx>& rpBitmap) const;
- virtual ::boost::shared_ptr<BitmapEx> Decompress (const BitmapReplacement& rBitmapData) const;
+ virtual ::boost::shared_ptr<BitmapReplacement> Compress (const Bitmap& rBitmap) const;
+ virtual Bitmap Decompress (const BitmapReplacement& rBitmapData) const;
virtual bool IsLossless (void) const;
};
diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx b/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx
index 5ad30ef43c1f..8abba77faf4f 100644..100755
--- a/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsBitmapFactory.cxx
@@ -24,8 +24,6 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sd.hxx"
#include "precompiled_sd.hxx"
@@ -33,12 +31,19 @@
#include "PreviewRenderer.hxx"
#include "view/SlideSorterView.hxx"
-#include "view/SlsPageObjectViewObjectContact.hxx"
#include "sdpage.hxx"
#include "Window.hxx"
+#include <drawdoc.hxx>
+#include "DrawDocShell.hxx"
#include <svx/svdtypes.hxx>
#include <svx/svdpage.hxx>
#include <vcl/bitmapex.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/pngwrite.hxx>
+
+const static sal_Int32 gnSuperSampleFactor (2);
+const static bool gbAllowSuperSampling (false);
+
namespace sd { namespace slidesorter { namespace view {
class SlideSorterView;
@@ -48,7 +53,7 @@ class PageObjectViewObjectContact;
namespace sd { namespace slidesorter { namespace cache {
BitmapFactory::BitmapFactory (void)
- : maRenderer(NULL,false)
+ : maRenderer(NULL, false)
{
}
@@ -62,16 +67,30 @@ BitmapFactory::~BitmapFactory (void)
-::boost::shared_ptr<BitmapEx> BitmapFactory::CreateBitmap (
+Bitmap BitmapFactory::CreateBitmap (
const SdPage& rPage,
- const Size& rPixelSize)
+ const Size& rPixelSize,
+ const bool bDoSuperSampling)
{
- Image aPreview (maRenderer.RenderPage (
+ Size aSize (rPixelSize);
+ if (bDoSuperSampling && gbAllowSuperSampling)
+ {
+ aSize.Width() *= gnSuperSampleFactor;
+ aSize.Height() *= gnSuperSampleFactor;
+ }
+
+ Bitmap aPreview (maRenderer.RenderPage (
&rPage,
- rPixelSize,
- String()));
-
- return ::boost::shared_ptr<BitmapEx>(new BitmapEx(aPreview.GetBitmapEx()));
+ aSize,
+ String(),
+ true,
+ false).GetBitmapEx().GetBitmap());
+ if (bDoSuperSampling && gbAllowSuperSampling)
+ {
+ aPreview.Scale(rPixelSize, BMP_SCALE_INTERPOLATE);
+ }
+
+ return aPreview;
}
diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapFactory.hxx b/sd/source/ui/slidesorter/cache/SlsBitmapFactory.hxx
index 87cd1f268f80..7e6aca940ec6 100644..100755
--- a/sd/source/ui/slidesorter/cache/SlsBitmapFactory.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsBitmapFactory.hxx
@@ -31,7 +31,6 @@
#include "PreviewRenderer.hxx"
#include <boost/shared_ptr.hpp>
-class BitmapEx;
class SdPage;
class Size;
@@ -50,9 +49,10 @@ public:
BitmapFactory (void);
~BitmapFactory (void);
- ::boost::shared_ptr<BitmapEx> CreateBitmap (
+ Bitmap CreateBitmap (
const SdPage& rPage,
- const Size& rPixelSize);
+ const Size& rPixelSize,
+ const bool bDoSuperSampling);
private:
PreviewRenderer maRenderer;
diff --git a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
index 780a429df29e..f7fb30a4c6ec 100755..100644
--- a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
@@ -24,8 +24,6 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sd.hxx"
#include "precompiled_sd.hxx"
@@ -37,20 +35,27 @@
#include "cache/SlsPageCacheManager.hxx"
#include "model/SlideSorterModel.hxx"
#include "model/SlsPageDescriptor.hxx"
-#include "view/SlsPageObjectViewObjectContact.hxx"
#include "controller/SlideSorterController.hxx"
+
namespace sd { namespace slidesorter { namespace cache {
GenericPageCache::GenericPageCache (
const Size& rPreviewSize,
+ const bool bDoSuperSampling,
const SharedCacheContext& rpCacheContext)
: mpBitmapCache(),
maRequestQueue(rpCacheContext),
mpQueueProcessor(),
mpCacheContext(rpCacheContext),
- maPreviewSize(rPreviewSize)
+ maPreviewSize(rPreviewSize),
+ mbDoSuperSampling(bDoSuperSampling)
{
+ // A large size may indicate an error of the caller. After all we
+ // are creating previews.
+ DBG_ASSERT (maPreviewSize.Width()<1000 && maPreviewSize.Height()<1000,
+ "GenericPageCache<>::GetPreviewBitmap(): bitmap requested with large width. "
+ "This may indicate an error.");
}
@@ -58,14 +63,12 @@ GenericPageCache::GenericPageCache (
GenericPageCache::~GenericPageCache (void)
{
- OSL_TRACE("terminating queue processor %p", mpQueueProcessor.get());
if (mpQueueProcessor.get() != NULL)
mpQueueProcessor->Stop();
maRequestQueue.Clear();
if (mpQueueProcessor.get() != NULL)
mpQueueProcessor->Terminate();
mpQueueProcessor.reset();
- OSL_TRACE("queue processor stopped and terminated");
if (mpBitmapCache.get() != NULL)
PageCacheManager::Instance()->ReleaseCache(mpBitmapCache);
@@ -87,62 +90,69 @@ void GenericPageCache::ProvideCacheAndProcessor (void)
maRequestQueue,
mpBitmapCache,
maPreviewSize,
+ mbDoSuperSampling,
mpCacheContext));
}
-void GenericPageCache::ChangePreviewSize (const Size& rPreviewSize)
+void GenericPageCache::ChangePreviewSize (
+ const Size& rPreviewSize,
+ const bool bDoSuperSampling)
{
- if (rPreviewSize != maPreviewSize)
+ if (rPreviewSize!=maPreviewSize || bDoSuperSampling!=mbDoSuperSampling)
{
+ // A large size may indicate an error of the caller. After all we
+ // are creating previews.
+ DBG_ASSERT (maPreviewSize.Width()<1000 && maPreviewSize.Height()<1000,
+ "GenericPageCache<>::GetPreviewBitmap(): bitmap requested with large width. "
+ "This may indicate an error.");
+
if (mpBitmapCache.get() != NULL)
{
mpBitmapCache = PageCacheManager::Instance()->ChangeSize(
mpBitmapCache, maPreviewSize, rPreviewSize);
if (mpQueueProcessor.get() != NULL)
{
- mpQueueProcessor->SetPreviewSize(rPreviewSize);
+ mpQueueProcessor->SetPreviewSize(rPreviewSize, bDoSuperSampling);
mpQueueProcessor->SetBitmapCache(mpBitmapCache);
}
}
maPreviewSize = rPreviewSize;
+ mbDoSuperSampling = bDoSuperSampling;
}
}
-BitmapEx GenericPageCache::GetPreviewBitmap (
- CacheKey aKey,
- const Size& rSize)
+Bitmap GenericPageCache::GetPreviewBitmap (
+ const CacheKey aKey,
+ const bool bResize)
{
OSL_ASSERT(aKey != NULL);
- BitmapEx aPreview;
+ Bitmap aPreview;
bool bMayBeUpToDate = true;
ProvideCacheAndProcessor();
const SdrPage* pPage = mpCacheContext->GetPage(aKey);
if (mpBitmapCache->HasBitmap(pPage))
{
- ::boost::shared_ptr<BitmapEx> pPreview(mpBitmapCache->GetBitmap(pPage));
- OSL_ASSERT(pPreview.get() != NULL);
- aPreview = *pPreview;
- Size aBitmapSize (aPreview.GetSizePixel());
- if (aBitmapSize != rSize)
+ aPreview = mpBitmapCache->GetBitmap(pPage);
+ const Size aBitmapSize (aPreview.GetSizePixel());
+ if (aBitmapSize != maPreviewSize)
{
- // The bitmap has the wrong size.
- DBG_ASSERT (rSize.Width() < 1000,
- "GenericPageCache<>::GetPreviewBitmap(): bitmap requested with large width. "
- "This may indicate an error.");
-
// Scale the bitmap to the desired size when that is possible,
// i.e. the bitmap is not empty.
- if (aBitmapSize.Width()>0 && aBitmapSize.Height()>0)
- aPreview.Scale (rSize, BMP_SCALE_FAST);
+ if (bResize && aBitmapSize.Width()>0 && aBitmapSize.Height()>0)
+ {
+ aPreview.Scale(maPreviewSize, BMP_SCALE_FAST);
+ }
+ bMayBeUpToDate = false;
}
- bMayBeUpToDate = true;
+ else
+ bMayBeUpToDate = true;
}
else
bMayBeUpToDate = false;
@@ -150,7 +160,7 @@ BitmapEx GenericPageCache::GetPreviewBitmap (
// Request the creation of a correctly sized preview bitmap. We do this
// even when the size of the bitmap in the cache is correct because its
// content may be not up-to-date anymore.
- RequestPreviewBitmap(aKey, rSize, bMayBeUpToDate);
+ RequestPreviewBitmap(aKey, bMayBeUpToDate);
return aPreview;
}
@@ -158,10 +168,49 @@ BitmapEx GenericPageCache::GetPreviewBitmap (
+Bitmap GenericPageCache::GetMarkedPreviewBitmap (
+ const CacheKey aKey,
+ const bool bResize)
+{
+ OSL_ASSERT(aKey != NULL);
+
+ ProvideCacheAndProcessor();
+ const SdrPage* pPage = mpCacheContext->GetPage(aKey);
+ Bitmap aMarkedPreview (mpBitmapCache->GetMarkedBitmap(pPage));
+ const Size aBitmapSize (aMarkedPreview.GetSizePixel());
+ if (bResize && aBitmapSize != maPreviewSize)
+ {
+ // Scale the bitmap to the desired size when that is possible,
+ // i.e. the bitmap is not empty.
+ if (aBitmapSize.Width()>0 && aBitmapSize.Height()>0)
+ {
+ aMarkedPreview.Scale(maPreviewSize, BMP_SCALE_FAST);
+ }
+ }
+
+ return aMarkedPreview;
+}
+
+
+
+
+void GenericPageCache::SetMarkedPreviewBitmap (
+ const CacheKey aKey,
+ const Bitmap& rMarkedBitmap)
+{
+ OSL_ASSERT(aKey != NULL);
+
+ ProvideCacheAndProcessor();
+ const SdrPage* pPage = mpCacheContext->GetPage(aKey);
+ mpBitmapCache->SetMarkedBitmap(pPage, rMarkedBitmap);
+}
+
+
+
+
void GenericPageCache::RequestPreviewBitmap (
- CacheKey aKey,
- const Size& rSize,
- bool bMayBeUpToDate)
+ const CacheKey aKey,
+ const bool bMayBeUpToDate)
{
OSL_ASSERT(aKey != NULL);
@@ -175,8 +224,8 @@ void GenericPageCache::RequestPreviewBitmap (
bIsUpToDate = mpBitmapCache->BitmapIsUpToDate (pPage);
if (bIsUpToDate)
{
- ::boost::shared_ptr<BitmapEx> pPreview (mpBitmapCache->GetBitmap(pPage));
- if (pPreview.get()==NULL || pPreview->GetSizePixel()!=rSize)
+ const Bitmap aPreview (mpBitmapCache->GetBitmap(pPage));
+ if (aPreview.IsEmpty() || aPreview.GetSizePixel()!=maPreviewSize)
bIsUpToDate = false;
}
@@ -199,7 +248,25 @@ void GenericPageCache::RequestPreviewBitmap (
-void GenericPageCache::ReleasePreviewBitmap (CacheKey aKey)
+bool GenericPageCache::InvalidatePreviewBitmap (const CacheKey aKey)
+{
+ // Invalidate the page in all caches that reference it, not just this one.
+ ::boost::shared_ptr<cache::PageCacheManager> pCacheManager (
+ cache::PageCacheManager::Instance());
+ if (pCacheManager)
+ return pCacheManager->InvalidatePreviewBitmap(
+ mpCacheContext->GetModel(),
+ aKey);
+ else if (mpBitmapCache.get() != NULL)
+ return mpBitmapCache->InvalidateBitmap(mpCacheContext->GetPage(aKey));
+ else
+ return false;
+}
+
+
+
+
+void GenericPageCache::ReleasePreviewBitmap (const CacheKey aKey)
{
if (mpBitmapCache.get() != NULL)
{
@@ -233,9 +300,9 @@ void GenericPageCache::ReleasePreviewBitmap (CacheKey aKey)
-void GenericPageCache::InvalidateCache (bool bUpdateCache)
+void GenericPageCache::InvalidateCache (const bool bUpdateCache)
{
- if (mpBitmapCache.get() != NULL)
+ if (mpBitmapCache)
{
// When the cache is being invalidated then it makes no sense to
// continue creating preview bitmaps. However, this may be
@@ -255,7 +322,9 @@ void GenericPageCache::InvalidateCache (bool bUpdateCache)
-void GenericPageCache::SetPreciousFlag (CacheKey aKey, bool bIsPrecious)
+void GenericPageCache::SetPreciousFlag (
+ const CacheKey aKey,
+ const bool bIsPrecious)
{
ProvideCacheAndProcessor();
diff --git a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx
index 89fc657004e8..96636576f79a 100755..100644
--- a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.hxx
@@ -30,8 +30,6 @@
#include "SlideSorter.hxx"
#include "SlsRequestQueue.hxx"
-#include "SlsQueueProcessor.hxx"
-#include <boost/function.hpp>
#include <boost/scoped_ptr.hpp>
namespace sd { namespace slidesorter { namespace cache {
@@ -44,12 +42,18 @@ class QueueProcessor;
class GenericPageCache
{
public:
- /** The page chache is created with references both to the SlideSorter.
- This allows access to both view and model and the cache can so fill
- itself with requests for all or just the visible pages.
+ /** The page chache is created with a reference to the SlideSorter and
+ thus has access to both view and model. This allows the cache to
+ fill itself with requests for all pages or just the visible ones.
+ @param rPreviewSize
+ The size of the previews is expected in pixel values.
+ @param bDoSuperSampling
+ When <TRUE/> the previews are rendered larger and then scaled
+ down to the requested size to improve image quality.
*/
GenericPageCache (
const Size& rPreviewSize,
+ const bool bDoSuperSampling,
const SharedCacheContext& rpCacheContext);
~GenericPageCache (void);
@@ -58,10 +62,12 @@ public:
resize of the slide sorter window or a change of the number of
columns.
*/
- void ChangePreviewSize (const Size& rPreviewSize);
+ void ChangePreviewSize (
+ const Size& rPreviewSize,
+ const bool bDoSuperSampling);
/** Request a preview bitmap for the specified page object in the
- specified size. The returned bitmap may be preview of the preview,
+ specified size. The returned bitmap may be a preview of the preview,
i.e. either a scaled (up or down) version of a previous preview (of
the wrong size) or an empty bitmap. In this case a request for the
generation of a new preview is created and inserted into the request
@@ -70,53 +76,67 @@ public:
receives the correctly sized preview bitmap.
@param rRequestData
This data is used to determine the preview.
- @param rSize
- The size of the requested preview bitmap.
+ @param bResize
+ When <TRUE/> then when the available bitmap has not the
+ requested size, it is scaled before it is returned. When
+ <FALSE/> then the bitmap is returned in the wrong size and it is
+ the task of the caller to scale it.
@return
Returns a bitmap that is either empty, contains a scaled (up or
down) version or is the requested bitmap.
*/
- BitmapEx GetPreviewBitmap (
- CacheKey aKey,
- const Size& rSize);
+ Bitmap GetPreviewBitmap (
+ const CacheKey aKey,
+ const bool bResize);
+ Bitmap GetMarkedPreviewBitmap (
+ const CacheKey aKey,
+ const bool bResize);
+ void SetMarkedPreviewBitmap (
+ const CacheKey aKey,
+ const Bitmap& rMarkedBitmap);
/** When the requested preview bitmap does not yet exist or is not
up-to-date then the rendering of one is scheduled. Otherwise this
method does nothing.
@param rRequestData
This data is used to determine the preview.
- @param rSize
- The size of the requested preview bitmap in pixel coordinates.
@param bMayBeUpToDate
This flag helps the method to determine whether an existing
preview that matches the request is up to date. If the caller
- know that it is not then by passing <FALSE/> he tells us that we
+ knows that it is not then by passing <FALSE/> he tells us that we
do not have to check the up-to-date flag a second time. If
- unsure pass <TRUE/>.
+ unsure use <TRUE/>.
*/
void RequestPreviewBitmap (
- CacheKey aKey,
- const Size& rSize,
- bool bMayBeUpToDate = true);
+ const CacheKey aKey,
+ const bool bMayBeUpToDate = true);
+
+ /** Tell the cache to replace the bitmap associated with the given
+ request data with a new one that reflects recent changes in the
+ content of the page object.
+ @return
+ When the key is kown then return <TRUE/>.
+ */
+ bool InvalidatePreviewBitmap (const CacheKey aKey);
/** Call this method when a view-object-contact object is being deleted
and does not need (a) its current bitmap in the cache and (b) a
requested a new bitmap.
*/
- void ReleasePreviewBitmap (CacheKey aKey);
+ void ReleasePreviewBitmap (const CacheKey aKey);
/** Call this method when all preview bitmaps have to be generated anew.
This is the case when the size of the page objects on the screen has
changed or when the model has changed.
*/
- void InvalidateCache (bool bUpdateCache);
+ void InvalidateCache (const bool bUpdateCache);
/** With the precious flag you can control whether a bitmap can be
removed from the cache or reduced in size to make room for other
bitmaps or is so precious that it will not be touched. A typical
use is to set the precious flag for the visible pages.
*/
- void SetPreciousFlag (CacheKey aKey, bool bIsPrecious);
+ void SetPreciousFlag (const CacheKey aKey, const bool bIsPrecious);
void Pause (void);
void Resume (void);
@@ -134,6 +154,8 @@ private:
*/
Size maPreviewSize;
+ bool mbDoSuperSampling;
+
/** Both bitmap cache and queue processor are created on demand by this
method.
*/
diff --git a/sd/source/ui/slidesorter/cache/SlsPageCache.cxx b/sd/source/ui/slidesorter/cache/SlsPageCache.cxx
index 714e1f008329..e51630ec79ac 100755..100644
--- a/sd/source/ui/slidesorter/cache/SlsPageCache.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsPageCache.cxx
@@ -44,10 +44,12 @@ namespace sd { namespace slidesorter { namespace cache {
PageCache::PageCache (
const Size& rPreviewSize,
+ const bool bDoSuperSampling,
const SharedCacheContext& rpCacheContext)
: mpImplementation(
new GenericPageCache(
rPreviewSize,
+ bDoSuperSampling,
rpCacheContext))
{
}
@@ -62,26 +64,66 @@ PageCache::~PageCache (void)
-void PageCache::ChangeSize(const Size& rPreviewSize)
+void PageCache::ChangeSize (
+ const Size& rPreviewSize,
+ const bool bDoSuperSampling)
+{
+ mpImplementation->ChangePreviewSize(rPreviewSize, bDoSuperSampling);
+}
+
+
+
+
+Bitmap PageCache::GetPreviewBitmap (
+ const CacheKey aKey,
+ const bool bResize)
+{
+ return mpImplementation->GetPreviewBitmap(aKey, bResize);
+}
+
+
+
+
+Bitmap PageCache::GetMarkedPreviewBitmap (
+ const CacheKey aKey,
+ const bool bResize)
+{
+ return mpImplementation->GetMarkedPreviewBitmap(aKey, bResize);
+}
+
+
+
+
+void PageCache::SetMarkedPreviewBitmap (
+ const CacheKey aKey,
+ const Bitmap& rMarkedBitmap)
+{
+ mpImplementation->SetMarkedPreviewBitmap(aKey, rMarkedBitmap);
+}
+
+
+
+
+void PageCache::RequestPreviewBitmap (const CacheKey aKey)
{
- mpImplementation->ChangePreviewSize(rPreviewSize);
+ return mpImplementation->RequestPreviewBitmap(aKey);
}
-BitmapEx PageCache::GetPreviewBitmap (
- CacheKey aKey,
- const Size& rSize)
+void PageCache::InvalidatePreviewBitmap (
+ const CacheKey aKey,
+ const bool bRequestPreview)
{
- return mpImplementation->GetPreviewBitmap(aKey, rSize);
+ if (mpImplementation->InvalidatePreviewBitmap(aKey) && bRequestPreview)
+ RequestPreviewBitmap(aKey);
}
-void PageCache::ReleasePreviewBitmap (
- CacheKey aKey)
+void PageCache::ReleasePreviewBitmap (const CacheKey aKey)
{
mpImplementation->ReleasePreviewBitmap(aKey);
}
@@ -89,7 +131,7 @@ void PageCache::ReleasePreviewBitmap (
-void PageCache::InvalidateCache (bool bUpdateCache)
+void PageCache::InvalidateCache (const bool bUpdateCache)
{
mpImplementation->InvalidateCache(bUpdateCache);
}
@@ -98,8 +140,8 @@ void PageCache::InvalidateCache (bool bUpdateCache)
void PageCache::SetPreciousFlag (
- CacheKey aKey,
- bool bIsPrecious)
+ const CacheKey aKey,
+ const bool bIsPrecious)
{
mpImplementation->SetPreciousFlag(aKey, bIsPrecious);
}
diff --git a/sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx b/sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx
index 3c8a15892e7c..e3083ecb4aaf 100644..100755
--- a/sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx
@@ -325,7 +325,6 @@ void PageCacheManager::ReleaseCache (const ::boost::shared_ptr<Cache>& rpCache)
mpPageCaches->begin(),
mpPageCaches->end(),
PageCacheContainer::CompareWithCache(rpCache)));
- OSL_ASSERT(iCacheToChange != mpPageCaches->end());
if (iCacheToChange != mpPageCaches->end())
{
OSL_ASSERT(iCacheToChange->second == rpCache);
@@ -342,6 +341,10 @@ void PageCacheManager::ReleaseCache (const ::boost::shared_ptr<Cache>& rpCache)
pResult = rpCache;
}
+ else
+ {
+ OSL_ASSERT(iCacheToChange != mpPageCaches->end());
+ }
}
return pResult;
@@ -350,10 +353,12 @@ void PageCacheManager::ReleaseCache (const ::boost::shared_ptr<Cache>& rpCache)
-void PageCacheManager::InvalidatePreviewBitmap (
+bool PageCacheManager::InvalidatePreviewBitmap (
DocumentKey pDocument,
const SdrPage* pKey)
{
+ bool bHasChanged (false);
+
if (pDocument!=NULL)
{
// Iterate over all caches that are currently in use and invalidate
@@ -361,7 +366,7 @@ void PageCacheManager::InvalidatePreviewBitmap (
PageCacheContainer::iterator iCache;
for (iCache=mpPageCaches->begin(); iCache!=mpPageCaches->end(); ++iCache)
if (iCache->first.mpDocument == pDocument)
- iCache->second->InvalidateBitmap(pKey);
+ bHasChanged |= iCache->second->InvalidateBitmap(pKey);
// Invalidate the previews in the recently used caches belonging to
// the given document.
@@ -370,9 +375,37 @@ void PageCacheManager::InvalidatePreviewBitmap (
{
RecentlyUsedQueue::const_iterator iCache2;
for (iCache2=iQueue->second.begin(); iCache2!=iQueue->second.end(); ++iCache2)
- iCache2->mpCache->InvalidateBitmap(pKey);
+ bHasChanged |= iCache2->mpCache->InvalidateBitmap(pKey);
}
}
+
+ return bHasChanged;
+}
+
+
+
+
+void PageCacheManager::InvalidateAllPreviewBitmaps (DocumentKey pDocument)
+{
+ if (pDocument == NULL)
+ return;
+
+ // Iterate over all caches that are currently in use and invalidate the
+ // previews in those that belong to the document.
+ PageCacheContainer::iterator iCache;
+ for (iCache=mpPageCaches->begin(); iCache!=mpPageCaches->end(); ++iCache)
+ if (iCache->first.mpDocument == pDocument)
+ iCache->second->InvalidateCache();
+
+ // Invalidate the previews in the recently used caches belonging to the
+ // given document.
+ RecentlyUsedPageCaches::iterator iQueue (mpRecentlyUsedPageCaches->find(pDocument));
+ if (iQueue != mpRecentlyUsedPageCaches->end())
+ {
+ RecentlyUsedQueue::const_iterator iCache2;
+ for (iCache2=iQueue->second.begin(); iCache2!=iQueue->second.end(); ++iCache2)
+ iCache2->mpCache->InvalidateCache();
+ }
}
@@ -394,6 +427,16 @@ void PageCacheManager::InvalidateAllCaches (void)
+void PageCacheManager::ReleasePreviewBitmap (const SdrPage* pPage)
+{
+ PageCacheContainer::iterator iCache;
+ for (iCache=mpPageCaches->begin(); iCache!=mpPageCaches->end(); ++iCache)
+ iCache->second->ReleaseBitmap(pPage);
+}
+
+
+
+
::boost::shared_ptr<PageCacheManager::Cache> PageCacheManager::GetRecentlyUsedCache (
DocumentKey pDocument,
const Size& rPreviewSize)
diff --git a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
index bec9c7fa369d..86d20d6c8924 100755
--- a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.cxx
@@ -40,6 +40,7 @@ QueueProcessor::QueueProcessor (
RequestQueue& rQueue,
const ::boost::shared_ptr<BitmapCache>& rpCache,
const Size& rPreviewSize,
+ const bool bDoSuperSampling,
const SharedCacheContext& rpCacheContext)
: maMutex(),
maTimer(),
@@ -47,6 +48,7 @@ QueueProcessor::QueueProcessor (
mnTimeBetweenLowPriorityRequests (100/*ms*/),
mnTimeBetweenRequestsWhenNotIdle (1000/*ms*/),
maPreviewSize(rPreviewSize),
+ mbDoSuperSampling(bDoSuperSampling),
mpCacheContext(rpCacheContext),
mrQueue(rQueue),
mpCache(rpCache),
@@ -136,9 +138,12 @@ void QueueProcessor::Terminate (void)
-void QueueProcessor::SetPreviewSize (const Size& rPreviewSize)
+void QueueProcessor::SetPreviewSize (
+ const Size& rPreviewSize,
+ const bool bDoSuperSampling)
{
maPreviewSize = rPreviewSize;
+ mbDoSuperSampling = bDoSuperSampling;
}
@@ -207,15 +212,12 @@ void QueueProcessor::ProcessOneRequest (
const SdPage* pSdPage = dynamic_cast<const SdPage*>(mpCacheContext->GetPage(aKey));
if (pSdPage != NULL)
{
- const ::boost::shared_ptr<BitmapEx> pPreview (
- maBitmapFactory.CreateBitmap(*pSdPage, maPreviewSize));
- mpCache->SetBitmap (
- pSdPage,
- pPreview,
- ePriorityClass!=NOT_VISIBLE);
+ const Bitmap aPreview (
+ maBitmapFactory.CreateBitmap(*pSdPage, maPreviewSize, mbDoSuperSampling));
+ mpCache->SetBitmap (pSdPage, aPreview, ePriorityClass!=NOT_VISIBLE);
// Initiate a repaint of the new preview.
- mpCacheContext->NotifyPreviewCreation(aKey, pPreview);
+ mpCacheContext->NotifyPreviewCreation(aKey, aPreview);
}
}
}
diff --git a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx
index e42ad092d0e2..f84b774c4280 100644..100755
--- a/sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsQueueProcessor.hxx
@@ -31,9 +31,7 @@
#include "cache/SlsPageCache.hxx"
#include "SlsRequestPriorityClass.hxx"
#include "SlsBitmapFactory.hxx"
-#include "view/SlsPageObject.hxx"
#include "view/SlideSorterView.hxx"
-#include "view/SlsPageObjectViewObjectContact.hxx"
#include "tools/IdleDetection.hxx"
#include "SlsBitmapCache.hxx"
#include "sdpage.hxx"
@@ -71,6 +69,7 @@ public:
RequestQueue& rQueue,
const ::boost::shared_ptr<BitmapCache>& rpCache,
const Size& rPreviewSize,
+ const bool bDoSuperSampling,
const SharedCacheContext& rpCacheContext);
virtual ~QueueProcessor();
@@ -90,7 +89,9 @@ public:
void Terminate (void);
- void SetPreviewSize (const Size& rSize);
+ void SetPreviewSize (
+ const Size& rSize,
+ const bool bDoSuperSampling);
/** As we can not really terminate the rendering of a preview bitmap for
a request in midair this method acts more like a semaphor. It
@@ -118,6 +119,7 @@ private:
sal_uInt32 mnTimeBetweenLowPriorityRequests;
sal_uInt32 mnTimeBetweenRequestsWhenNotIdle;
Size maPreviewSize;
+ bool mbDoSuperSampling;
SharedCacheContext mpCacheContext;
RequestQueue& mrQueue;
::boost::shared_ptr<BitmapCache> mpCache;
diff --git a/sd/source/ui/slidesorter/cache/SlsQueueProcessorThread.hxx b/sd/source/ui/slidesorter/cache/SlsQueueProcessorThread.hxx
index 08ca63284ea6..e813a5ac5f2b 100644..100755
--- a/sd/source/ui/slidesorter/cache/SlsQueueProcessorThread.hxx
+++ b/sd/source/ui/slidesorter/cache/SlsQueueProcessorThread.hxx
@@ -128,7 +128,6 @@ template <class Queue, class Request, class Cache, class Factory>
mrQueue (rQueue),
mrCache (rCache)
{
- OSL_TRACE("QueueProcessorThread::constructor %p", this);
create();
}
@@ -139,7 +138,6 @@ template <class Queue, class Request, class Cache, class Factory>
QueueProcessorThread<Queue, Request, Cache, Factory>
::~QueueProcessorThread (void)
{
- OSL_TRACE("QueueProcessorThread::destructor %p", this);
}
@@ -148,16 +146,12 @@ template <class Queue, class Request, class Cache, class Factory>
template <class Queue, class Request, class Cache, class Factory>
void SAL_CALL QueueProcessorThread<Queue, Request, Cache, Factory>::run (void)
{
- OSL_TRACE("QueueProcessorThread::run(): running thread %p", this);
while ( ! mbIsTerminated)
{
- OSL_TRACE("QueueProcessorThread::run(): still running thread %p: %d", this, mbIsTerminated?1:0);
if (mrQueue.IsEmpty())
{
// Sleep while the queue is empty.
- OSL_TRACE("QueueProcessorThread::run(): suspending thread %p", this);
suspend();
- OSL_TRACE("QueueProcessorThread::run(): running again thread %p", this);
}
else if (GetpApp()->AnyInput())
@@ -168,19 +162,15 @@ void SAL_CALL QueueProcessorThread<Queue, Request, Cache, Factory>::run (void)
TimeValue aTimeToWait;
aTimeToWait.Seconds = 0;
aTimeToWait.Nanosec = 50*1000*1000;
- OSL_TRACE("QueueProcessorThread::run(): input pending: waiting %d nanoseconds",
- aTimeToWait.Nanosec);
wait (aTimeToWait);
}
else
{
- OSL_TRACE ("QueueProcessorThread::run(): Processing Query");
ProcessQueueEntry();
yield ();
}
}
- OSL_TRACE("QueueProcessorThread::run(): exiting run %p", this);
}
@@ -196,7 +186,6 @@ void QueueProcessorThread<Queue, Request, Cache, Factory>
do
{
- OSL_TRACE ("QueueProcessorThread::ProcessQueueEntry(): testing for mbIsTerminated %p", this);
{
::osl::MutexGuard aGuard (maMutex);
if (mbIsTerminated)
@@ -204,7 +193,6 @@ void QueueProcessorThread<Queue, Request, Cache, Factory>
if (mrQueue.IsEmpty())
break;
}
- OSL_TRACE ("QueueProcessorThread::ProcessQueueEntry():acquiring mutex for bitmap creation %p", this);
::vos::OGuard aSolarGuard (Application::GetSolarMutex());
::osl::MutexGuard aGuard (maMutex);
if (mbIsTerminated)
@@ -213,18 +201,12 @@ void QueueProcessorThread<Queue, Request, Cache, Factory>
if (mrQueue.IsEmpty())
break;
- OSL_TRACE ("QueueProcessorThread::ProcessQueueEntry(): have mutexes %p", this);
-
// Get the requeuest with the highest priority from the queue.
nPriorityClass = mrQueue.GetFrontPriorityClass();
pRequest = &mrQueue.GetFront();
mrQueue.PopFront();
bRequestIsValid = true;
-
- OSL_TRACE ("QueueProcessorThread::ProcessQueueEntry():using request %p for creating bitmap", pRequest);
- OSL_TRACE ("QueueProcessorThread::ProcessQueueEntry():processing request for page %d with priority class ",
- pRequest->GetPage()->GetPageNum(), nPriorityClass);
try
{
// Create a new preview bitmap and store it in the cache.
@@ -260,7 +242,6 @@ void QueueProcessorThread<
Queue, RequestData, BitmapCache, BitmapFactory
>::Start (void)
{
- OSL_TRACE ("QueueProcessorThread::Start %p", this);
resume ();
}
@@ -275,7 +256,6 @@ void QueueProcessorThread<
Queue, RequestData, BitmapCache, BitmapFactory
>::Stop (void)
{
- OSL_TRACE ("QueueProcessorThread::Stop %p", this);
suspend();
}
@@ -290,7 +270,6 @@ void QueueProcessorThread<
Queue, RequestData, BitmapCache, BitmapFactory
>::RemoveRequest (RequestData& rRequest)
{
- OSL_TRACE ("QueueProcessorThread::RemoveRequest %p", this);
// Do nothing else then wait for the mutex to be released.
::osl::MutexGuard aGuard (mrQueue.GetMutex());
}
@@ -307,11 +286,9 @@ void QueueProcessorThread<
>::Terminate (void)
{
// ::vos::OGuard aSolarGuard (Application::GetSolarMutex());
- OSL_TRACE("QueueProcessorThread::Terminate(): terminating thread %p", this);
::osl::Thread::terminate ();
{
::osl::MutexGuard aGuard (maMutex);
- OSL_TRACE("QueueProcessorThread::Terminate(): starting to join %p, %d", this, mbIsTerminated?1:0);
mbIsTerminated = true;
}
Start();
@@ -332,29 +309,6 @@ void SAL_CALL QueueProcessorThread<
{
::osl::MutexGuard aGuard (maMutex);
mbCanBeJoined = true;
- /*
- OSL_TRACE("QueueProcessorThread::Terminate():join %p, %d", this, mbIsTerminated?1:0);
- while (true)
- {
- {
- ::osl::MutexGuard aGuard (maMutex);
- if (mbCanBeJoined)
- break;
- }
- Start();
- TimeValue aTimeToWait;
- aTimeToWait.Seconds = 0;
- aTimeToWait.Nanosec = 50*1000*1000;
- OSL_TRACE("QueueProcessorThread::Terminate(): waiting for join");
- wait (aTimeToWait);
- }
- if (mbCanBeJoined)
- join();
- else
- OSL_TRACE("Can not join");
- OSL_TRACE("QueueProcessorThread::Terminate():terminated thread %p :%d",
- this, mbIsTerminated?1:0);
- */
}
diff --git a/sd/source/ui/slidesorter/cache/SlsRequestFactory.cxx b/sd/source/ui/slidesorter/cache/SlsRequestFactory.cxx
index 8030558759f3..166b04661d99 100644..100755
--- a/sd/source/ui/slidesorter/cache/SlsRequestFactory.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsRequestFactory.cxx
@@ -24,8 +24,6 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sd.hxx"
#include "precompiled_sd.hxx"
diff --git a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
index ccd590131343..11721e09ecb3 100644..100755
--- a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
@@ -24,8 +24,6 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sd.hxx"
#include "precompiled_sd.hxx"