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 "SlsRequestQueue.hxx"
26 #include <vcl/bitmapex.hxx>
28 namespace sd
{ namespace slidesorter
{ namespace cache
{
33 /** This basically is the implementation class for the PageCache class.
35 class GenericPageCache
38 /** The page cache is created with a reference to the SlideSorter and
39 thus has access to both view and model. This allows the cache to
40 fill itself with requests for all pages or just the visible ones.
42 The size of the previews is expected in pixel values.
43 @param bDoSuperSampling
44 When <TRUE/> the previews are rendered larger and then scaled
45 down to the requested size to improve image quality.
48 const Size
& rPreviewSize
,
49 const bool bDoSuperSampling
,
50 const SharedCacheContext
& rpCacheContext
);
54 /** Change the size of the preview bitmaps. This may be caused by a
55 resize of the slide sorter window or a change of the number of
58 void ChangePreviewSize (
59 const Size
& rPreviewSize
,
60 const bool bDoSuperSampling
);
62 /** Request a preview bitmap for the specified page object in the
63 specified size. The returned bitmap may be a preview of the preview,
64 i.e. either a scaled (up or down) version of a previous preview (of
65 the wrong size) or an empty bitmap. In this case a request for the
66 generation of a new preview is created and inserted into the request
67 queue. When the preview is available the page shape will be told to
68 paint itself again. When it then calls this method again if
69 receives the correctly sized preview bitmap.
71 This data is used to determine the preview.
73 When <TRUE/> then when the available bitmap has not the
74 requested size, it is scaled before it is returned. When
75 <FALSE/> then the bitmap is returned in the wrong size and it is
76 the task of the caller to scale it.
78 Returns a bitmap that is either empty, contains a scaled (up or
79 down) version or is the requested bitmap.
81 BitmapEx
GetPreviewBitmap (
84 BitmapEx
GetMarkedPreviewBitmap (
86 void SetMarkedPreviewBitmap (
88 const BitmapEx
& 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
);
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 known 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 ();
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 std::shared_ptr
<BitmapCache
> mpBitmapCache
;
133 RequestQueue maRequestQueue
;
135 std::unique_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: */