Mir: Add gamma support set/get. Still need one more function to complete the set
authorBrandon Schaefer
Wed, 21 Sep 2016 18:23:59 -0700
changeset 103644bbf64fdd9d9
parent 10363 7a2367601792
child 10365 7f3be5258f80
Mir: Add gamma support set/get. Still need one more function to complete the set
src/video/mir/SDL_mirsym.h
src/video/mir/SDL_mirvideo.c
src/video/mir/SDL_mirwindow.c
src/video/mir/SDL_mirwindow.h
     1.1 --- a/src/video/mir/SDL_mirsym.h	Wed Sep 21 16:28:23 2016 -0700
     1.2 +++ b/src/video/mir/SDL_mirsym.h	Wed Sep 21 18:23:59 2016 -0700
     1.3 @@ -115,6 +115,10 @@
     1.4  SDL_MIR_SYM(int,mir_output_mode_get_width,(MirOutputMode const* mode))
     1.5  SDL_MIR_SYM(int,mir_output_mode_get_height,(MirOutputMode const* mode))
     1.6  SDL_MIR_SYM(double,mir_output_mode_get_refresh_rate,(MirOutputMode const* mode))
     1.7 +SDL_MIR_SYM(MirOutputGammaSupported,mir_output_is_gamma_supported,(MirOutput const* output))
     1.8 +SDL_MIR_SYM(uint32_t,mir_output_get_gamma_size,(MirOutput const* output))
     1.9 +SDL_MIR_SYM(void,mir_output_get_gamma,(MirOutput const* output, uint16_t* red, uint16_t* green, uint16_t* blue, uint32_t size))
    1.10 +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))
    1.11  
    1.12  SDL_MIR_SYM_CONST(char const*,mir_omnidirectional_resize_cursor_name)
    1.13  SDL_MIR_SYM_CONST(char const*,mir_busy_cursor_name)
     2.1 --- a/src/video/mir/SDL_mirvideo.c	Wed Sep 21 16:28:23 2016 -0700
     2.2 +++ b/src/video/mir/SDL_mirvideo.c	Wed Sep 21 18:23:59 2016 -0700
     2.3 @@ -179,13 +179,13 @@
     2.4      device->SetWindowMaximumSize = MIR_SetWindowMaximumSize;
     2.5      device->SetWindowTitle       = MIR_SetWindowTitle;
     2.6      device->SetWindowGrab        = MIR_SetWindowGrab;
     2.7 +    device->SetWindowGammaRamp   = MIR_SetWindowGammaRamp;
     2.8 +    device->GetWindowGammaRamp   = MIR_GetWindowGammaRamp;
     2.9  
    2.10      device->CreateWindowFrom     = NULL;
    2.11      device->SetWindowIcon        = NULL;
    2.12      device->RaiseWindow          = NULL;
    2.13      device->SetWindowBordered    = NULL;
    2.14 -    device->SetWindowGammaRamp   = NULL;
    2.15 -    device->GetWindowGammaRamp   = NULL;
    2.16      device->OnWindowEnter        = NULL;
    2.17      device->SetWindowPosition    = NULL;
    2.18  
     3.1 --- a/src/video/mir/SDL_mirwindow.c	Wed Sep 21 16:28:23 2016 -0700
     3.2 +++ b/src/video/mir/SDL_mirwindow.c	Wed Sep 21 18:23:59 2016 -0700
     3.3 @@ -376,7 +376,45 @@
     3.4  
     3.5      MIR_mir_surface_apply_spec(mir_window->surface, spec);
     3.6      MIR_mir_surface_spec_release(spec);
     3.7 +}
     3.8  
     3.9 +int
    3.10 +MIR_SetWindowGammaRamp(_THIS, SDL_Window* window, Uint16 const* ramp)
    3.11 +{
    3.12 +    MirOutput* output = SDL_GetDisplayForWindow(window)->driverdata;
    3.13 +    Uint32 ramp_size = 256;
    3.14 +
    3.15 +    // FIXME Need to apply the changes to the output, once that public API function is around
    3.16 +    if (MIR_mir_output_is_gamma_supported(output) == mir_output_gamma_supported) {
    3.17 +        MIR_mir_output_set_gamma(output,
    3.18 +                                 ramp + ramp_size * 0,
    3.19 +                                 ramp + ramp_size * 1,
    3.20 +                                 ramp + ramp_size * 2,
    3.21 +                                 ramp_size);
    3.22 +        return 0;
    3.23 +    }
    3.24 +
    3.25 +    return -1;
    3.26 +}
    3.27 +
    3.28 +int
    3.29 +MIR_GetWindowGammaRamp(_THIS, SDL_Window* window, Uint16* ramp)
    3.30 +{
    3.31 +    MirOutput* output = SDL_GetDisplayForWindow(window)->driverdata;
    3.32 +    Uint32 ramp_size = 256;
    3.33 +
    3.34 +    if (MIR_mir_output_is_gamma_supported(output) == mir_output_gamma_supported) {
    3.35 +        if (MIR_mir_output_get_gamma_size(output) == ramp_size) {
    3.36 +            MIR_mir_output_get_gamma(output,
    3.37 +                                     ramp + ramp_size * 0,
    3.38 +                                     ramp + ramp_size * 1,
    3.39 +                                     ramp + ramp_size * 2,
    3.40 +                                     ramp_size);
    3.41 +            return 0;
    3.42 +        }
    3.43 +    }
    3.44 +
    3.45 +    return -1;
    3.46  }
    3.47  
    3.48  #endif /* SDL_VIDEO_DRIVER_MIR */
     4.1 --- a/src/video/mir/SDL_mirwindow.h	Wed Sep 21 16:28:23 2016 -0700
     4.2 +++ b/src/video/mir/SDL_mirwindow.h	Wed Sep 21 18:23:59 2016 -0700
     4.3 @@ -81,6 +81,11 @@
     4.4  extern void
     4.5  MIR_SetWindowGrab(_THIS, SDL_Window* window, SDL_bool grabbed);
     4.6  
     4.7 +extern int
     4.8 +MIR_SetWindowGammaRamp(_THIS, SDL_Window* window, Uint16 const* ramp);
     4.9 +
    4.10 +extern int
    4.11 +MIR_GetWindowGammaRamp(_THIS, SDL_Window* window, Uint16* ramp);
    4.12  
    4.13  #endif /* _SDL_mirwindow_h */
    4.14