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