Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_object_crtc.cpp
Show All 17 Lines | |||||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "drm_object_crtc.h" | 20 | #include "drm_object_crtc.h" | ||
21 | #include "drm_backend.h" | 21 | #include "drm_backend.h" | ||
22 | #include "drm_output.h" | 22 | #include "drm_output.h" | ||
23 | #include "drm_buffer.h" | 23 | #include "drm_buffer.h" | ||
24 | #include "logging.h" | 24 | #include "logging.h" | ||
25 | 25 | | |||
26 | #include <colorcorrection/gammaramp.h> | ||||
27 | | ||||
26 | namespace KWin | 28 | namespace KWin | ||
27 | { | 29 | { | ||
28 | 30 | | |||
29 | DrmCrtc::DrmCrtc(uint32_t crtc_id, DrmBackend *backend, int resIndex) | 31 | DrmCrtc::DrmCrtc(uint32_t crtc_id, DrmBackend *backend, int resIndex) | ||
30 | : DrmObject(crtc_id, backend), | 32 | : DrmObject(crtc_id, backend), | ||
31 | m_resIndex(resIndex) | 33 | m_resIndex(resIndex) | ||
32 | { | 34 | { | ||
35 | ScopedDrmPointer<_drmModeCrtc, &drmModeFreeCrtc> modeCrtc(drmModeGetCrtc(backend->fd(), crtc_id)); | ||||
36 | if (!modeCrtc) { | ||||
37 | return; | ||||
38 | } | ||||
39 | m_gammaRampSize = modeCrtc->gamma_size; | ||||
33 | } | 40 | } | ||
34 | 41 | | |||
35 | DrmCrtc::~DrmCrtc() | 42 | DrmCrtc::~DrmCrtc() | ||
36 | { | 43 | { | ||
37 | } | 44 | } | ||
38 | 45 | | |||
39 | bool DrmCrtc::atomicInit() | 46 | bool DrmCrtc::atomicInit() | ||
40 | { | 47 | { | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 101 | if (m_output->setModeLegacy(m_blackBuffer)) { | |||
98 | } | 105 | } | ||
99 | m_currentBuffer = nullptr; | 106 | m_currentBuffer = nullptr; | ||
100 | m_nextBuffer = nullptr; | 107 | m_nextBuffer = nullptr; | ||
101 | return true; | 108 | return true; | ||
102 | } | 109 | } | ||
103 | return false; | 110 | return false; | ||
104 | } | 111 | } | ||
105 | 112 | | |||
113 | bool DrmCrtc::setGammaRamp(ColorCorrect::GammaRamp &gamma) { | ||||
114 | bool isError = drmModeCrtcSetGamma(m_backend->fd(), m_id, gamma.size, | ||||
115 | gamma.red, gamma.green, gamma.blue); | ||||
116 | return !isError; | ||||
117 | } | ||||
davidedmundson: so we have 3 arrays of size m_gammaSize
we can pass the GammaRamp object and do:
gammaRamp. | |||||
118 | | ||||
106 | } | 119 | } |
so we have 3 arrays of size m_gammaSize
we can pass the GammaRamp object and do:
gammaRamp.red,
gammaRamp.green,
gammaRamp.blue,
also it'll be safer to use the gammaSize from the gammaramp. otherwise if it changes, you're going to crash.
if you are trying for separation pass 3 uint*s instead of doing pointer maths.