File indexing completed on 2025-01-26 04:11:17

0001 /*
0002  *  SPDX-FileCopyrightText: 2017 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KISDABRENDERINGQUEUE_H
0008 #define KISDABRENDERINGQUEUE_H
0009 
0010 #include <QScopedPointer>
0011 
0012 #include "kritadefaultpaintops_export.h"
0013 
0014 #include <QList>
0015 class KisDabRenderingJob;
0016 struct KisRenderedDab;
0017 
0018 #include "KisDabCacheUtils.h"
0019 
0020 class KRITADEFAULTPAINTOPS_EXPORT KisDabRenderingQueue
0021 {
0022 public:
0023     struct CacheInterface {
0024         virtual ~CacheInterface() {}
0025         virtual void getDabType(bool hasDabInCache,
0026                                 KisDabCacheUtils::DabRenderingResources *resources,
0027                                 const KisDabCacheUtils::DabRequestInfo &request,
0028                                 /* out */
0029                                 KisDabCacheUtils::DabGenerationInfo *di,
0030                                 bool *shouldUseCache) = 0;
0031 
0032         virtual bool hasSeparateOriginal(KisDabCacheUtils::DabRenderingResources *resources) const = 0;
0033     };
0034 
0035 
0036 public:
0037     KisDabRenderingQueue(const KoColorSpace *cs, KisDabCacheUtils::ResourcesFactory resourcesFactory);
0038     ~KisDabRenderingQueue();
0039 
0040     KisDabRenderingJobSP addDab(const KisDabCacheUtils::DabRequestInfo &request,
0041                                qreal opacity, qreal flow);
0042 
0043     QList<KisDabRenderingJobSP> notifyJobFinished(int seqNo, int usecsTime = -1);
0044 
0045     QList<KisRenderedDab> takeReadyDabs(bool returnMutableDabs = false, int oneTimeLimit = -1, bool *someDabsLeft = 0);
0046 
0047     bool hasPreparedDabs() const;
0048 
0049     void setCacheInterface(CacheInterface *interface);
0050 
0051     KisFixedPaintDeviceSP fetchCachedPaintDevice();
0052 
0053     void putResourcesToCache(KisDabCacheUtils::DabRenderingResources *resources);
0054     KisDabCacheUtils::DabRenderingResources* fetchResourcesFromCache();
0055 
0056     qreal averageExecutionTime() const;
0057     int averageDabSize() const;
0058 
0059     int testingGetQueueSize() const;
0060 
0061 private:
0062     struct Private;
0063     const QScopedPointer<Private> m_d;
0064 };
0065 
0066 #endif // KISDABRENDERINGQUEUE_H