Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_object_crtc.cpp
Show All 24 Lines | |||||
25 | 25 | | |||
26 | namespace KWin | 26 | namespace KWin | ||
27 | { | 27 | { | ||
28 | 28 | | |||
29 | DrmCrtc::DrmCrtc(uint32_t crtc_id, DrmBackend *backend, int resIndex) | 29 | DrmCrtc::DrmCrtc(uint32_t crtc_id, DrmBackend *backend, int resIndex) | ||
30 | : DrmObject(crtc_id, backend), | 30 | : DrmObject(crtc_id, backend), | ||
31 | m_resIndex(resIndex) | 31 | m_resIndex(resIndex) | ||
32 | { | 32 | { | ||
33 | ScopedDrmPointer<_drmModeCrtc, &drmModeFreeCrtc> modeCrtc(drmModeGetCrtc(backend->fd(), crtc_id)); | ||||
34 | if (!modeCrtc) { | ||||
35 | return; | ||||
36 | } | ||||
37 | m_gammaSize = modeCrtc->gamma_size; | ||||
33 | } | 38 | } | ||
34 | 39 | | |||
35 | DrmCrtc::~DrmCrtc() | 40 | DrmCrtc::~DrmCrtc() | ||
36 | { | 41 | { | ||
37 | } | 42 | } | ||
38 | 43 | | |||
39 | bool DrmCrtc::atomicInit() | 44 | bool DrmCrtc::atomicInit() | ||
40 | { | 45 | { | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 99 | if (m_output->setModeLegacy(m_blackBuffer)) { | |||
98 | } | 103 | } | ||
99 | m_currentBuffer = nullptr; | 104 | m_currentBuffer = nullptr; | ||
100 | m_nextBuffer = nullptr; | 105 | m_nextBuffer = nullptr; | ||
101 | return true; | 106 | return true; | ||
102 | } | 107 | } | ||
103 | return false; | 108 | return false; | ||
104 | } | 109 | } | ||
105 | 110 | | |||
111 | bool DrmCrtc::setGammaRamp(uint16_t *gammaRamp) { | ||||
112 | if (m_gammaSize <= 1) { | ||||
113 | return false; | ||||
114 | } | ||||
115 | bool isError = drmModeCrtcSetGamma(m_backend->fd(), m_id, m_gammaSize, | ||||
davidedmundson: so we have 3 arrays of size m_gammaSize
we can pass the GammaRamp object and do:
gammaRamp. | |||||
116 | gammaRamp, // red | ||||
117 | gammaRamp + m_gammaSize, // green | ||||
118 | gammaRamp + 2 * m_gammaSize // blue | ||||
119 | ); | ||||
120 | return !isError; | ||||
121 | } | ||||
122 | | ||||
106 | } | 123 | } |
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.