diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2018-06-26 18:40:23 +0200 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2018-06-26 18:40:23 +0200 |
commit | 8e98195e58f77fd1f354b2707360bd4445aef5b4 (patch) | |
tree | 79e3417a316fc8b7f73c7ada582266d169423e8f /src | |
parent | 606075b852d8e1d40ed0a56b5a928abdd7012f95 (diff) |
Don't apply gamma to HW cursor data if colour management is enabled
In that case (with DC as of 4.17 kernels), the display hardware applies
gamma to the HW cursor.
v2:
* Also use all 0s when alpha == 0 in the gamma passthrough case.
Bugzilla: https://bugs.freedesktop.org/106578
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/drmmode_display.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c index fa0c05b..1563417 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1516,6 +1516,17 @@ drmmode_cursor_src_offset(Rotation rotation, int width, int height, #endif static uint32_t +drmmode_cursor_gamma_passthrough(xf86CrtcPtr crtc, uint32_t argb) +{ + uint32_t alpha = argb >> 24; + + if (!alpha) + return 0; + + return argb; +} + +static uint32_t drmmode_cursor_gamma(xf86CrtcPtr crtc, uint32_t argb) { uint32_t alpha = argb >> 24; @@ -1525,9 +1536,6 @@ drmmode_cursor_gamma(xf86CrtcPtr crtc, uint32_t argb) if (!alpha) return 0; - if (crtc->scrn->depth != 24 && crtc->scrn->depth != 32) - return argb; - /* Un-premultiply alpha */ for (i = 0; i < 3; i++) rgb[i] = ((argb >> (i * 8)) & 0xff) * 0xff / alpha; @@ -1544,6 +1552,12 @@ static void drmmode_do_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image, uint32_ { ScrnInfoPtr pScrn = crtc->scrn; AMDGPUInfoPtr info = AMDGPUPTR(pScrn); + uint32_t (*cursor_gamma)(xf86CrtcPtr crtc, uint32_t argb) = + drmmode_cursor_gamma; + + if ((crtc->scrn->depth != 24 && crtc->scrn->depth != 32) || + drmmode_cm_enabled(&info->drmmode)) + cursor_gamma = drmmode_cursor_gamma_passthrough; #if XF86_CRTC_VERSION < 7 if (crtc->driverIsPerformingTransform) { @@ -1559,8 +1573,7 @@ static void drmmode_do_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image, uint32_ dstx, dsty); ptr[dsty * info->cursor_w + dstx] = - cpu_to_le32(drmmode_cursor_gamma(crtc, - image[srcoffset])); + cpu_to_le32(cursor_gamma(crtc, image[srcoffset])); } } } else @@ -1570,7 +1583,7 @@ static void drmmode_do_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image, uint32_ int i; for (i = 0; i < cursor_size; i++) - ptr[i] = cpu_to_le32(drmmode_cursor_gamma(crtc, image[i])); + ptr[i] = cpu_to_le32(cursor_gamma(crtc, image[i])); } } |