diff --git a/src/video/mir/SDL_mirsym.h b/src/video/mir/SDL_mirsym.h index 2bd90997c..4f97ed96c 100644 --- a/src/video/mir/SDL_mirsym.h +++ b/src/video/mir/SDL_mirsym.h @@ -115,6 +115,10 @@ SDL_MIR_SYM(MirOutputMode const*,mir_output_get_mode,(MirOutput const* output, s SDL_MIR_SYM(int,mir_output_mode_get_width,(MirOutputMode const* mode)) SDL_MIR_SYM(int,mir_output_mode_get_height,(MirOutputMode const* mode)) SDL_MIR_SYM(double,mir_output_mode_get_refresh_rate,(MirOutputMode const* mode)) +SDL_MIR_SYM(MirOutputGammaSupported,mir_output_is_gamma_supported,(MirOutput const* output)) +SDL_MIR_SYM(uint32_t,mir_output_get_gamma_size,(MirOutput const* output)) +SDL_MIR_SYM(void,mir_output_get_gamma,(MirOutput const* output, uint16_t* red, uint16_t* green, uint16_t* blue, uint32_t size)) +SDL_MIR_SYM(void,mir_output_set_gamma,(MirOutput* output, uint16_t const* red, uint16_t const* green, uint16_t const* blue, uint32_t size)) SDL_MIR_SYM_CONST(char const*,mir_omnidirectional_resize_cursor_name) SDL_MIR_SYM_CONST(char const*,mir_busy_cursor_name) diff --git a/src/video/mir/SDL_mirvideo.c b/src/video/mir/SDL_mirvideo.c index 0a5064d5d..886cee7fd 100644 --- a/src/video/mir/SDL_mirvideo.c +++ b/src/video/mir/SDL_mirvideo.c @@ -179,13 +179,13 @@ MIR_CreateDevice(int device_index) device->SetWindowMaximumSize = MIR_SetWindowMaximumSize; device->SetWindowTitle = MIR_SetWindowTitle; device->SetWindowGrab = MIR_SetWindowGrab; + device->SetWindowGammaRamp = MIR_SetWindowGammaRamp; + device->GetWindowGammaRamp = MIR_GetWindowGammaRamp; device->CreateWindowFrom = NULL; device->SetWindowIcon = NULL; device->RaiseWindow = NULL; device->SetWindowBordered = NULL; - device->SetWindowGammaRamp = NULL; - device->GetWindowGammaRamp = NULL; device->OnWindowEnter = NULL; device->SetWindowPosition = NULL; diff --git a/src/video/mir/SDL_mirwindow.c b/src/video/mir/SDL_mirwindow.c index 7328cb977..1bf9016a0 100644 --- a/src/video/mir/SDL_mirwindow.c +++ b/src/video/mir/SDL_mirwindow.c @@ -376,7 +376,45 @@ MIR_SetWindowGrab(_THIS, SDL_Window* window, SDL_bool grabbed) MIR_mir_surface_apply_spec(mir_window->surface, spec); MIR_mir_surface_spec_release(spec); +} +int +MIR_SetWindowGammaRamp(_THIS, SDL_Window* window, Uint16 const* ramp) +{ + MirOutput* output = SDL_GetDisplayForWindow(window)->driverdata; + Uint32 ramp_size = 256; + + // FIXME Need to apply the changes to the output, once that public API function is around + if (MIR_mir_output_is_gamma_supported(output) == mir_output_gamma_supported) { + MIR_mir_output_set_gamma(output, + ramp + ramp_size * 0, + ramp + ramp_size * 1, + ramp + ramp_size * 2, + ramp_size); + return 0; + } + + return -1; +} + +int +MIR_GetWindowGammaRamp(_THIS, SDL_Window* window, Uint16* ramp) +{ + MirOutput* output = SDL_GetDisplayForWindow(window)->driverdata; + Uint32 ramp_size = 256; + + if (MIR_mir_output_is_gamma_supported(output) == mir_output_gamma_supported) { + if (MIR_mir_output_get_gamma_size(output) == ramp_size) { + MIR_mir_output_get_gamma(output, + ramp + ramp_size * 0, + ramp + ramp_size * 1, + ramp + ramp_size * 2, + ramp_size); + return 0; + } + } + + return -1; } #endif /* SDL_VIDEO_DRIVER_MIR */ diff --git a/src/video/mir/SDL_mirwindow.h b/src/video/mir/SDL_mirwindow.h index 997678e0a..c4084aa4e 100644 --- a/src/video/mir/SDL_mirwindow.h +++ b/src/video/mir/SDL_mirwindow.h @@ -81,6 +81,11 @@ MIR_SetWindowTitle(_THIS, SDL_Window* window); extern void MIR_SetWindowGrab(_THIS, SDL_Window* window, SDL_bool grabbed); +extern int +MIR_SetWindowGammaRamp(_THIS, SDL_Window* window, Uint16 const* ramp); + +extern int +MIR_GetWindowGammaRamp(_THIS, SDL_Window* window, Uint16* ramp); #endif /* _SDL_mirwindow_h */