1 /* 2 * Copyright (c) 2017 Dmitry Kazakov <dimula73@gmail.com> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef KISDABRENDERINGJOB_H 20 #define KISDABRENDERINGJOB_H 21 22 #include <QRunnable> 23 #include <KisDabCacheUtils.h> 24 #include <kis_fixed_paint_device.h> 25 #include <kis_types.h> 26 #include "kritadefaultpaintops_export.h" 27 28 class KisDabRenderingQueue; 29 class KisRunnableStrokeJobsInterface; 30 31 class KRITADEFAULTPAINTOPS_EXPORT KisDabRenderingJob 32 { 33 public: 34 enum JobType { 35 Dab, 36 Postprocess, 37 Copy 38 }; 39 40 enum Status { 41 New, 42 Running, 43 Completed 44 }; 45 46 public: 47 KisDabRenderingJob(); 48 KisDabRenderingJob(int _seqNo, 49 KisDabCacheUtils::DabGenerationInfo _generationInfo, 50 JobType _type); 51 KisDabRenderingJob(const KisDabRenderingJob &rhs); 52 KisDabRenderingJob& operator=(const KisDabRenderingJob &rhs); 53 54 QPoint dstDabOffset() const; 55 56 int seqNo = -1; 57 KisDabCacheUtils::DabGenerationInfo generationInfo; 58 JobType type = Dab; 59 KisFixedPaintDeviceSP originalDevice; 60 KisFixedPaintDeviceSP postprocessedDevice; 61 62 // high-level members, not directly related to job execution itself 63 Status status = New; 64 65 qreal opacity = OPACITY_OPAQUE_F; 66 qreal flow = OPACITY_OPAQUE_F; 67 }; 68 69 #include <QSharedPointer> 70 typedef QSharedPointer<KisDabRenderingJob> KisDabRenderingJobSP; 71 72 class KRITADEFAULTPAINTOPS_EXPORT KisDabRenderingJobRunner : public QRunnable 73 { 74 public: 75 KisDabRenderingJobRunner(KisDabRenderingJobSP job, 76 KisDabRenderingQueue *parentQueue, 77 KisRunnableStrokeJobsInterface *runnableJobsInterface); 78 ~KisDabRenderingJobRunner(); 79 80 void run() override; 81 82 static int executeOneJob(KisDabRenderingJob *job, KisDabCacheUtils::DabRenderingResources *resources, KisDabRenderingQueue *parentQueue); 83 84 private: 85 KisDabRenderingJobSP m_job; 86 KisDabRenderingQueue *m_parentQueue = 0; 87 KisRunnableStrokeJobsInterface *m_runnableJobsInterface = 0; 88 }; 89 90 91 #endif // KISDABRENDERINGJOB_H 92