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 KISDABRENDERINGJOB_H
0008 #define KISDABRENDERINGJOB_H
0009 
0010 #include <QRunnable>
0011 #include <KisDabCacheUtils.h>
0012 #include <kis_fixed_paint_device.h>
0013 #include <kis_types.h>
0014 #include "kritadefaultpaintops_export.h"
0015 
0016 class KisDabRenderingQueue;
0017 class KisRunnableStrokeJobsInterface;
0018 
0019 class KRITADEFAULTPAINTOPS_EXPORT KisDabRenderingJob
0020 {
0021 public:
0022     enum JobType {
0023         Dab,
0024         Postprocess,
0025         Copy
0026     };
0027 
0028     enum Status {
0029         New,
0030         Running,
0031         Completed
0032     };
0033 
0034 public:
0035     KisDabRenderingJob(int _seqNo,
0036                        JobType _type, qreal opacity = OPACITY_OPAQUE_F, qreal flow = OPACITY_OPAQUE_F);
0037     KisDabRenderingJob(const KisDabRenderingJob &rhs);
0038     KisDabRenderingJob& operator=(const KisDabRenderingJob &rhs);
0039 
0040     QPoint dstDabOffset() const;
0041 
0042     int seqNo = -1;
0043     KisDabCacheUtils::DabGenerationInfo generationInfo;
0044     JobType type = Dab;
0045     KisFixedPaintDeviceSP originalDevice;
0046     KisFixedPaintDeviceSP postprocessedDevice;
0047 
0048     // high-level members, not directly related to job execution itself
0049     Status status = New;
0050 
0051     qreal opacity = OPACITY_OPAQUE_F;
0052     qreal flow = OPACITY_OPAQUE_F;
0053 };
0054 
0055 #include <QSharedPointer>
0056 typedef QSharedPointer<KisDabRenderingJob> KisDabRenderingJobSP;
0057 
0058 class KRITADEFAULTPAINTOPS_EXPORT KisDabRenderingJobRunner : public QRunnable
0059 {
0060 public:
0061     KisDabRenderingJobRunner(KisDabRenderingJobSP job,
0062                              KisDabRenderingQueue *parentQueue,
0063                              KisRunnableStrokeJobsInterface *runnableJobsInterface);
0064     ~KisDabRenderingJobRunner();
0065 
0066     void run() override;
0067 
0068     static int executeOneJob(KisDabRenderingJob *job, KisDabCacheUtils::DabRenderingResources *resources, KisDabRenderingQueue *parentQueue);
0069 
0070 private:
0071     KisDabRenderingJobSP m_job;
0072     KisDabRenderingQueue *m_parentQueue = 0;
0073     KisRunnableStrokeJobsInterface *m_runnableJobsInterface = 0;
0074 };
0075 
0076 
0077 #endif // KISDABRENDERINGJOB_H