Krita Source Code Documentation
Loading...
Searching...
No Matches
KisDabRenderingJob.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QElapsedTimer>
10
13
14#include "KisDabCacheUtils.h"
16
18
19KisDabRenderingJob::KisDabRenderingJob(int _seqNo, KisDabRenderingJob::JobType _type, qreal _opacity, qreal _flow)
20 : seqNo(_seqNo)
21 , type(_type)
22 , opacity(_opacity)
23 , flow(_flow)
24{
25}
26
28 : seqNo(rhs.seqNo),
29 generationInfo(rhs.generationInfo),
30 type(rhs.type),
31 originalDevice(rhs.originalDevice),
32 postprocessedDevice(rhs.postprocessedDevice),
33 status(rhs.status),
34 opacity(rhs.opacity),
35 flow(rhs.flow)
36{
37}
38
52
54{
57 const QPoint p1 = generationInfo.dstDabRect.topLeft();
58 const QPoint s1 = QPoint(generationInfo.dstDabRect.width(),
59 generationInfo.dstDabRect.height());
60 const QPoint s2 = QPoint(postprocessedDevice->bounds().width(),
61 postprocessedDevice->bounds().height());
62 return p1 + (s1 - s2) / 2;
63}
64
65
66
68 KisDabRenderingQueue *parentQueue,
69 KisRunnableStrokeJobsInterface *runnableJobsInterface)
70 : m_job(job),
71 m_parentQueue(parentQueue),
72 m_runnableJobsInterface(runnableJobsInterface)
73{
74}
75
79
82 KisDabRenderingQueue *parentQueue)
83{
84 using namespace KisDabCacheUtils;
85
88
89 QElapsedTimer executionTime;
90 executionTime.start();
91
92 resources->syncResourcesToSeqNo(job->seqNo, job->generationInfo.info);
93
94 if (job->type == KisDabRenderingJob::Dab) {
95 // TODO: thing about better interface for the reverse queue link
96 job->originalDevice = parentQueue->fetchCachedPaintDevice();
97
98 generateDab(job->generationInfo, resources, &job->originalDevice);
99 }
100
101 // by now the original device should be already prepared
103
104 if (job->type == KisDabRenderingJob::Dab ||
106
108 // TODO: cache postprocessed device
109
110 if (!job->postprocessedDevice ||
112
113 job->postprocessedDevice = parentQueue->fetchCachedPaintDevice();
115 } else {
117 }
118
119 postProcessDab(job->postprocessedDevice,
120 job->generationInfo.dstDabRect.topLeft(),
121 job->generationInfo.info,
122 resources);
123 } else {
125 }
126 }
127
128 return executionTime.nsecsElapsed() / 1000;
129}
130
132{
133 int executionTime = 0;
134
136
137 executionTime = executeOneJob(m_job.data(), resources, m_parentQueue);
139
140 while (!jobs.isEmpty()) {
142
143 // start all-but-the-first jobs asynchronously
144 for (int i = 1; i < jobs.size(); i++) {
145 dataList.append(new FreehandStrokeRunnableJobDataWithUpdate(
148 }
149
151
152
153 // execute the first job in the current thread
154 KisDabRenderingJobSP job = jobs.first();
155 executionTime = executeOneJob(job.data(), resources, m_parentQueue);
156 jobs = m_parentQueue->notifyJobFinished(job->seqNo, executionTime);
157 }
158
160}
QPointF s1
QPointF s2
QPointF p1
KisRunnableStrokeJobsInterface * m_runnableJobsInterface
static int executeOneJob(KisDabRenderingJob *job, KisDabCacheUtils::DabRenderingResources *resources, KisDabRenderingQueue *parentQueue)
KisDabRenderingQueue * m_parentQueue
KisDabRenderingJobSP m_job
KisDabRenderingJobRunner(KisDabRenderingJobSP job, KisDabRenderingQueue *parentQueue, KisRunnableStrokeJobsInterface *runnableJobsInterface)
KisFixedPaintDeviceSP postprocessedDevice
KisFixedPaintDeviceSP originalDevice
QPoint dstDabOffset() const
KisDabCacheUtils::DabGenerationInfo generationInfo
KisDabRenderingJob(int _seqNo, JobType _type, qreal opacity=OPACITY_OPAQUE_F, qreal flow=OPACITY_OPAQUE_F)
KisDabRenderingJob & operator=(const KisDabRenderingJob &rhs)
KisDabCacheUtils::DabRenderingResources * fetchResourcesFromCache()
KisFixedPaintDeviceSP fetchCachedPaintDevice()
QList< KisDabRenderingJobSP > notifyJobFinished(int seqNo, int usecsTime=-1)
void putResourcesToCache(KisDabCacheUtils::DabRenderingResources *resources)
const KoColorSpace * colorSpace() const
virtual void addRunnableJobs(const QVector< KisRunnableStrokeJobDataBase * > &list)=0
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
virtual void syncResourcesToSeqNo(int seqNo, const KisPaintInformation &info)