1 | // Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "filtercompatibletechniquejob_p.h" |
5 | #include <Qt3DRender/private/techniquemanager_p.h> |
6 | #include <Qt3DRender/private/nodemanagers_p.h> |
7 | #include <Qt3DRender/private/job_common_p.h> |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | namespace Qt3DRender { |
12 | namespace Render { |
13 | |
14 | FilterCompatibleTechniqueJob::FilterCompatibleTechniqueJob() |
15 | : m_manager(nullptr) |
16 | , m_renderer(nullptr) |
17 | { |
18 | SET_JOB_RUN_STAT_TYPE(this, JobTypes::FilterCompatibleTechniques, 0) |
19 | } |
20 | |
21 | void FilterCompatibleTechniqueJob::setManager(TechniqueManager *manager) |
22 | { |
23 | m_manager = manager; |
24 | } |
25 | |
26 | TechniqueManager *FilterCompatibleTechniqueJob::manager() const |
27 | { |
28 | return m_manager; |
29 | } |
30 | |
31 | void FilterCompatibleTechniqueJob::setRenderer(AbstractRenderer *renderer) |
32 | { |
33 | m_renderer = renderer; |
34 | } |
35 | |
36 | AbstractRenderer *FilterCompatibleTechniqueJob::renderer() const |
37 | { |
38 | return m_renderer; |
39 | } |
40 | |
41 | void FilterCompatibleTechniqueJob::run() |
42 | { |
43 | Q_ASSERT(m_manager != nullptr && m_renderer != nullptr); |
44 | Q_ASSERT(m_renderer->isRunning()); |
45 | |
46 | const std::vector<Qt3DCore::QNodeId> dirtyTechniqueIds = m_manager->takeDirtyTechniques(); |
47 | for (const Qt3DCore::QNodeId &techniqueId : dirtyTechniqueIds) { |
48 | Technique *technique = m_manager->lookupResource(id: techniqueId); |
49 | if (Q_LIKELY(technique != nullptr)) |
50 | technique->setCompatibleWithRenderer((*m_renderer->contextInfo() == *technique->graphicsApiFilter())); |
51 | } |
52 | } |
53 | |
54 | } // namespace Render |
55 | } // namespace Qt3DRender |
56 | |
57 | QT_END_NAMESPACE |
58 |