File indexing completed on 2024-05-12 16:37:12

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2011 Boudewijn Rempt <boud@kogmbh.com>
0003  * Copyright (C) 2011 Marijn Kruisselbrink <mkruisselbrink@kde.org>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 #ifndef KWPAGECACHEMANAGER_H
0021 #define KWPAGECACHEMANAGER_H
0022 
0023 #include "KWPage.h"
0024 // Qt
0025 #include <QCache>
0026 #include <QImage>
0027 
0028 class QSize;
0029 
0030 class KWPageCacheManager;
0031 
0032 class KWPageCache {
0033 
0034 
0035 public:
0036 
0037     /// create a pagecache object with the existing
0038     /// QImage.
0039     //KWPageCache(KWPageCacheManager *manager, QImage *img);
0040     /// create a new pagecache object with a new QImage
0041     KWPageCache(KWPageCacheManager *manager, int w, int h);
0042     ~KWPageCache();
0043 
0044     KWPageCacheManager* m_manager;
0045     QVector<QImage> cache;
0046     int m_tilesx, m_tilesy;
0047     QSize m_size;
0048     // List of logical exposed rects in view coordinates
0049     // These are the rects that are queued for updating, not
0050     // the rects that have already been painted.
0051     QVector<QRect> exposed;
0052     // true if the whole page should be repainted
0053     bool allExposed;
0054 };
0055 
0056 class KWPageCacheManager {
0057 
0058 public:
0059 
0060     explicit KWPageCacheManager(int cacheSize);
0061 
0062     ~KWPageCacheManager();
0063 
0064     KWPageCache *take(const KWPage &page);
0065 
0066     void insert(const KWPage &page, KWPageCache *cache);
0067 
0068     KWPageCache *cache(const QSize &size);
0069 
0070     void clear();
0071 
0072 private:
0073     QCache<KWPage, KWPageCache> m_cache;
0074     friend class KWPageCache;
0075 };
0076 
0077 #endif