1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SD_SOURCE_UI_SLIDESORTER_CACHE_SLSGENERICPAGECACHE_HXX
21 #define INCLUDED_SD_SOURCE_UI_SLIDESORTER_CACHE_SLSGENERICPAGECACHE_HXX
23 #include "SlideSorter.hxx"
24 #include "SlsRequestQueue.hxx"
25 #include <boost/scoped_ptr.hpp>
27 namespace sd
{ namespace slidesorter
{ namespace cache
{
32 /** This basically is the implementation class for the PageCache class.
34 class GenericPageCache
37 /** The page chache is created with a reference to the SlideSorter and
38 thus has access to both view and model. This allows the cache to
39 fill itself with requests for all pages or just the visible ones.
41 The size of the previews is expected in pixel values.
42 @param bDoSuperSampling
43 When <TRUE/> the previews are rendered larger and then scaled
44 down to the requested size to improve image quality.
47 const Size
& rPreviewSize
,
48 const bool bDoSuperSampling
,
49 const SharedCacheContext
& rpCacheContext
);
53 /** Change the size of the preview bitmaps. This may be caused by a
54 resize of the slide sorter window or a change of the number of
57 void ChangePreviewSize (
58 const Size
& rPreviewSize
,
59 const bool bDoSuperSampling
);
61 /** Request a preview bitmap for the specified page object in the
62 specified size. The returned bitmap may be a preview of the preview,
63 i.e. either a scaled (up or down) version of a previous preview (of
64 the wrong size) or an empty bitmap. In this case a request for the
65 generation of a new preview is created and inserted into the request
66 queue. When the preview is available the page shape will be told to
67 paint itself again. When it then calls this method again if
68 receives the correctly sized preview bitmap.
70 This data is used to determine the preview.
72 When <TRUE/> then when the available bitmap has not the
73 requested size, it is scaled before it is returned. When
74 <FALSE/> then the bitmap is returned in the wrong size and it is
75 the task of the caller to scale it.
77 Returns a bitmap that is either empty, contains a scaled (up or
78 down) version or is the requested bitmap.
80 Bitmap
GetPreviewBitmap (
83 Bitmap
GetMarkedPreviewBitmap (
86 void SetMarkedPreviewBitmap (
88 const Bitmap
& rMarkedBitmap
);
90 /** When the requested preview bitmap does not yet exist or is not
91 up-to-date then the rendering of one is scheduled. Otherwise this
94 This data is used to determine the preview.
96 This flag helps the method to determine whether an existing
97 preview that matches the request is up to date. If the caller
98 knows that it is not then by passing <FALSE/> he tells us that we
99 do not have to check the up-to-date flag a second time. If
102 void RequestPreviewBitmap (
104 const bool bMayBeUpToDate
= true);
106 /** Tell the cache to replace the bitmap associated with the given
107 request data with a new one that reflects recent changes in the
108 content of the page object.
110 When the key is kown then return <TRUE/>.
112 bool InvalidatePreviewBitmap (const CacheKey aKey
);
114 /** Call this method when all preview bitmaps have to be generated anew.
115 This is the case when the size of the page objects on the screen has
116 changed or when the model has changed.
118 void InvalidateCache (const bool bUpdateCache
);
120 /** With the precious flag you can control whether a bitmap can be
121 removed from the cache or reduced in size to make room for other
122 bitmaps or is so precious that it will not be touched. A typical
123 use is to set the precious flag for the visible pages.
125 void SetPreciousFlag (const CacheKey aKey
, const bool bIsPrecious
);
131 ::boost::shared_ptr
<BitmapCache
> mpBitmapCache
;
133 RequestQueue maRequestQueue
;
135 ::boost::scoped_ptr
<QueueProcessor
> mpQueueProcessor
;
137 SharedCacheContext mpCacheContext
;
139 /** The current size of preview bitmaps.
143 bool mbDoSuperSampling
;
145 /** Both bitmap cache and queue processor are created on demand by this
148 void ProvideCacheAndProcessor();
151 } } } // end of namespace ::sd::slidesorter::cache
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */