Remove SDL_SetWindowBrightness and SDL_SetWindowGammaRamp.

main
slime 2022-11-24 22:42:57 -04:00 committed by Sam Lantinga
parent d14530ea82
commit 52f4cc843d
23 changed files with 16 additions and 629 deletions

View File

@ -139,3 +139,8 @@ The structures in this file are versioned separately from the rest of SDL, allow
This function now returns a standard int result instead of SDL_bool, returning 0 if the function succeeds or a negative error code if there was an error. You should also pass `SDL_SYSWM_CURRENT_VERSION` as the new third version parameter. The version member of the info structure will be filled in with the version of data that is returned, the minimum of the version you requested and the version supported by the runtime SDL library.
## SDL_video.h
SDL_SetWindowBrightness and SDL_SetWindowGammaRamp have been removed from the API, because they interact poorly with modern operating systems and aren't able to limit their effects to the SDL window.
Programs which have access to shaders can implement more robust versions of those functions using custom shader code rendered as a post-process effect.

View File

@ -627,8 +627,6 @@ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
* \param ramp an array of 256 values filled in with the gamma ramp
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetWindowGammaRamp
*/
extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp);

View File

@ -1509,53 +1509,6 @@ extern DECLSPEC int SDLCALL SDL_SetWindowMouseRect(SDL_Window * window, const SD
*/
extern DECLSPEC const SDL_Rect * SDLCALL SDL_GetWindowMouseRect(SDL_Window * window);
/**
* Set the brightness (gamma multiplier) for a given window's display.
*
* Despite the name and signature, this method sets the brightness of the
* entire display, not an individual window. A window is considered to be
* owned by the display that contains the window's center pixel. (The index of
* this display can be retrieved using SDL_GetWindowDisplayIndex().) The
* brightness set will not follow the window if it is moved to another
* display.
*
* Many platforms will refuse to set the display brightness in modern times.
* You are better off using a shader to adjust gamma during rendering, or
* something similar.
*
* \param window the window used to select the display whose brightness will
* be changed
* \param brightness the brightness (gamma multiplier) value to set where 0.0
* is completely dark and 1.0 is normal brightness
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetWindowBrightness
* \sa SDL_SetWindowGammaRamp
*/
extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float brightness);
/**
* Get the brightness (gamma multiplier) for a given window's display.
*
* Despite the name and signature, this method retrieves the brightness of the
* entire display, not an individual window. A window is considered to be
* owned by the display that contains the window's center pixel. (The index of
* this display can be retrieved using SDL_GetWindowDisplayIndex().)
*
* \param window the window used to select the display whose brightness will
* be queried
* \returns the brightness for the display where 0.0 is completely dark and
* 1.0 is normal brightness.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetWindowBrightness
*/
extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window);
/**
* Set the opacity for a window.
*
@ -1625,69 +1578,6 @@ extern DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window * modal_window, SDL
*/
extern DECLSPEC int SDLCALL SDL_SetWindowInputFocus(SDL_Window * window);
/**
* Set the gamma ramp for the display that owns a given window.
*
* Set the gamma translation table for the red, green, and blue channels of
* the video hardware. Each table is an array of 256 16-bit quantities,
* representing a mapping between the input and output for that channel. The
* input is the index into the array, and the output is the 16-bit gamma value
* at that index, scaled to the output color precision.
*
* Despite the name and signature, this method sets the gamma ramp of the
* entire display, not an individual window. A window is considered to be
* owned by the display that contains the window's center pixel. (The index of
* this display can be retrieved using SDL_GetWindowDisplayIndex().) The gamma
* ramp set will not follow the window if it is moved to another display.
*
* \param window the window used to select the display whose gamma ramp will
* be changed
* \param red a 256 element array of 16-bit quantities representing the
* translation table for the red channel, or NULL
* \param green a 256 element array of 16-bit quantities representing the
* translation table for the green channel, or NULL
* \param blue a 256 element array of 16-bit quantities representing the
* translation table for the blue channel, or NULL
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetWindowGammaRamp
*/
extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window,
const Uint16 * red,
const Uint16 * green,
const Uint16 * blue);
/**
* Get the gamma ramp for a given window's display.
*
* Despite the name and signature, this method retrieves the gamma ramp of the
* entire display, not an individual window. A window is considered to be
* owned by the display that contains the window's center pixel. (The index of
* this display can be retrieved using SDL_GetWindowDisplayIndex().)
*
* \param window the window used to select the display whose gamma ramp will
* be queried
* \param red a 256 element array of 16-bit quantities filled in with the
* translation table for the red channel, or NULL
* \param green a 256 element array of 16-bit quantities filled in with the
* translation table for the green channel, or NULL
* \param blue a 256 element array of 16-bit quantities filled in with the
* translation table for the blue channel, or NULL
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetWindowGammaRamp
*/
extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window,
Uint16 * red,
Uint16 * green,
Uint16 * blue);
/**
* Possible return values from the SDL_HitTest callback.
*

View File

@ -538,10 +538,6 @@
#define SDL_UpdateWindowSurfaceRects SDL_UpdateWindowSurfaceRects_REAL
#define SDL_SetWindowGrab SDL_SetWindowGrab_REAL
#define SDL_GetWindowGrab SDL_GetWindowGrab_REAL
#define SDL_SetWindowBrightness SDL_SetWindowBrightness_REAL
#define SDL_GetWindowBrightness SDL_GetWindowBrightness_REAL
#define SDL_SetWindowGammaRamp SDL_SetWindowGammaRamp_REAL
#define SDL_GetWindowGammaRamp SDL_GetWindowGammaRamp_REAL
#define SDL_DestroyWindow SDL_DestroyWindow_REAL
#define SDL_IsScreenSaverEnabled SDL_IsScreenSaverEnabled_REAL
#define SDL_EnableScreenSaver SDL_EnableScreenSaver_REAL

View File

@ -564,10 +564,6 @@ SDL_DYNAPI_PROC(int,SDL_UpdateWindowSurface,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_UpdateWindowSurfaceRects,(SDL_Window *a, const SDL_Rect *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_SetWindowGrab,(SDL_Window *a, SDL_bool b),(a,b),)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowGrab,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowBrightness,(SDL_Window *a, float b),(a,b),return)
SDL_DYNAPI_PROC(float,SDL_GetWindowBrightness,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SetWindowGammaRamp,(SDL_Window *a, const Uint16 *b, const Uint16 *c, const Uint16 *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_GetWindowGammaRamp,(SDL_Window *a, Uint16 *b, Uint16 *c, Uint16 *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(void,SDL_DestroyWindow,(SDL_Window *a),(a),)
SDL_DYNAPI_PROC(SDL_bool,SDL_IsScreenSaverEnabled,(void),(),return)
SDL_DYNAPI_PROC(void,SDL_EnableScreenSaver,(void),(),)

View File

@ -92,10 +92,6 @@ struct SDL_Window
float opacity;
float brightness;
Uint16 *gamma;
Uint16 *saved_gamma; /* (just offset into gamma) */
SDL_Surface *surface;
SDL_bool surface_valid;
@ -241,8 +237,6 @@ struct SDL_VideoDevice
void (*SetWindowResizable) (_THIS, SDL_Window * window, SDL_bool resizable);
void (*SetWindowAlwaysOnTop) (_THIS, SDL_Window * window, SDL_bool on_top);
void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
void* (*GetWindowICCProfile) (_THIS, SDL_Window * window, size_t* size);
int (*GetWindowDisplayIndex)(_THIS, SDL_Window * window);
void (*SetWindowMouseRect)(_THIS, SDL_Window * window);

View File

@ -1739,7 +1739,6 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
window->last_fullscreen_flags = window->flags;
window->opacity = 1.0f;
window->brightness = 1.0f;
window->next = _this->windows;
window->is_destroying = SDL_FALSE;
window->display_index = SDL_GetWindowDisplayIndex(window);
@ -1838,7 +1837,6 @@ SDL_CreateWindowFrom(const void *data)
window->last_fullscreen_flags = window->flags;
window->is_destroying = SDL_FALSE;
window->opacity = 1.0f;
window->brightness = 1.0f;
window->next = _this->windows;
if (_this->windows) {
_this->windows->prev = window;
@ -2754,30 +2752,6 @@ SDL_UpdateWindowSurfaceRects(SDL_Window * window, const SDL_Rect * rects,
return _this->UpdateWindowFramebuffer(_this, window, rects, numrects);
}
int
SDL_SetWindowBrightness(SDL_Window * window, float brightness)
{
Uint16 ramp[256];
int status;
CHECK_WINDOW_MAGIC(window, -1);
SDL_CalculateGammaRamp(brightness, ramp);
status = SDL_SetWindowGammaRamp(window, ramp, ramp, ramp);
if (status == 0) {
window->brightness = brightness;
}
return status;
}
float
SDL_GetWindowBrightness(SDL_Window * window)
{
CHECK_WINDOW_MAGIC(window, 1.0f);
return window->brightness;
}
int
SDL_SetWindowOpacity(SDL_Window * window, float opacity)
{
@ -2840,85 +2814,6 @@ SDL_SetWindowInputFocus(SDL_Window * window)
}
int
SDL_SetWindowGammaRamp(SDL_Window * window, const Uint16 * red,
const Uint16 * green,
const Uint16 * blue)
{
CHECK_WINDOW_MAGIC(window, -1);
if (!_this->SetWindowGammaRamp) {
return SDL_Unsupported();
}
if (!window->gamma) {
if (SDL_GetWindowGammaRamp(window, NULL, NULL, NULL) < 0) {
return -1;
}
SDL_assert(window->gamma != NULL);
}
if (red) {
SDL_memcpy(&window->gamma[0*256], red, 256*sizeof(Uint16));
}
if (green) {
SDL_memcpy(&window->gamma[1*256], green, 256*sizeof(Uint16));
}
if (blue) {
SDL_memcpy(&window->gamma[2*256], blue, 256*sizeof(Uint16));
}
if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
return _this->SetWindowGammaRamp(_this, window, window->gamma);
} else {
return 0;
}
}
int
SDL_GetWindowGammaRamp(SDL_Window * window, Uint16 * red,
Uint16 * green,
Uint16 * blue)
{
CHECK_WINDOW_MAGIC(window, -1);
if (!window->gamma) {
int i;
window->gamma = (Uint16 *)SDL_malloc(256*6*sizeof(Uint16));
if (!window->gamma) {
return SDL_OutOfMemory();
}
window->saved_gamma = window->gamma + 3*256;
if (_this->GetWindowGammaRamp) {
if (_this->GetWindowGammaRamp(_this, window, window->gamma) < 0) {
return -1;
}
} else {
/* Create an identity gamma ramp */
for (i = 0; i < 256; ++i) {
Uint16 value = (Uint16)((i << 8) | i);
window->gamma[0*256+i] = value;
window->gamma[1*256+i] = value;
window->gamma[2*256+i] = value;
}
}
SDL_memcpy(window->saved_gamma, window->gamma, 3*256*sizeof(Uint16));
}
if (red) {
SDL_memcpy(red, &window->gamma[0*256], 256*sizeof(Uint16));
}
if (green) {
SDL_memcpy(green, &window->gamma[1*256], 256*sizeof(Uint16));
}
if (blue) {
SDL_memcpy(blue, &window->gamma[2*256], 256*sizeof(Uint16));
}
return 0;
}
void
SDL_UpdateWindowGrab(SDL_Window * window)
{
@ -3164,10 +3059,6 @@ SDL_OnWindowFocusGained(SDL_Window * window)
{
SDL_Mouse *mouse = SDL_GetMouse();
if (window->gamma && _this->SetWindowGammaRamp) {
_this->SetWindowGammaRamp(_this, window, window->gamma);
}
if (mouse && mouse->relative_mode) {
SDL_SetMouseFocus(window);
if (mouse->relative_mode_warp) {
@ -3220,10 +3111,6 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
void
SDL_OnWindowFocusLost(SDL_Window * window)
{
if (window->gamma && _this->SetWindowGammaRamp) {
_this->SetWindowGammaRamp(_this, window, window->saved_gamma);
}
SDL_UpdateWindowGrab(window);
if (ShouldMinimizeOnFocusLoss(window)) {
@ -3310,7 +3197,6 @@ SDL_DestroyWindow(SDL_Window * window)
/* Free memory associated with the window */
SDL_free(window->title);
SDL_FreeSurface(window->icon);
SDL_free(window->gamma);
while (window->data) {
SDL_WindowUserData *data = window->data;

View File

@ -112,8 +112,6 @@ Cocoa_CreateDevice(void)
device->SetWindowResizable = Cocoa_SetWindowResizable;
device->SetWindowAlwaysOnTop = Cocoa_SetWindowAlwaysOnTop;
device->SetWindowFullscreen = Cocoa_SetWindowFullscreen;
device->SetWindowGammaRamp = Cocoa_SetWindowGammaRamp;
device->GetWindowGammaRamp = Cocoa_GetWindowGammaRamp;
device->GetWindowICCProfile = Cocoa_GetWindowICCProfile;
device->GetWindowDisplayIndex = Cocoa_GetWindowDisplayIndex;
device->SetWindowMouseRect = Cocoa_SetWindowMouseRect;

View File

@ -158,10 +158,8 @@ extern void Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordere
extern void Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
extern void Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top);
extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
extern void* Cocoa_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size);
extern int Cocoa_GetWindowDisplayIndex(_THIS, SDL_Window * window);
extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
extern void Cocoa_SetWindowMouseRect(_THIS, SDL_Window * window);
extern void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window);

View File

@ -2211,33 +2211,6 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
ScheduleContextUpdates(data);
}}
int
Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
{ @autoreleasepool
{
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
CGDirectDisplayID display_id = ((SDL_DisplayData *)display->driverdata)->display;
const uint32_t tableSize = 256;
CGGammaValue redTable[tableSize];
CGGammaValue greenTable[tableSize];
CGGammaValue blueTable[tableSize];
uint32_t i;
float inv65535 = 1.0f / 65535.0f;
/* Extract gamma values into separate tables, convert to floats between 0.0 and 1.0 */
for (i = 0; i < 256; i++) {
redTable[i] = ramp[0*256+i] * inv65535;
greenTable[i] = ramp[1*256+i] * inv65535;
blueTable[i] = ramp[2*256+i] * inv65535;
}
if (CGSetDisplayTransferByTable(display_id, tableSize,
redTable, greenTable, blueTable) != CGDisplayNoErr) {
return SDL_SetError("CGSetDisplayTransferByTable()");
}
return 0;
}}
void*
Cocoa_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size)
{ @autoreleasepool
@ -2314,30 +2287,6 @@ Cocoa_GetWindowDisplayIndex(_THIS, SDL_Window * window)
return SDL_SetError("Couldn't find the display where the window is located.");
}}
int
Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
{
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
CGDirectDisplayID display_id = ((SDL_DisplayData *)display->driverdata)->display;
const uint32_t tableSize = 256;
CGGammaValue redTable[tableSize];
CGGammaValue greenTable[tableSize];
CGGammaValue blueTable[tableSize];
uint32_t i, tableCopied;
if (CGGetDisplayTransferByTable(display_id, tableSize,
redTable, greenTable, blueTable, &tableCopied) != CGDisplayNoErr) {
return SDL_SetError("CGGetDisplayTransferByTable()");
}
for (i = 0; i < tableCopied; i++) {
ramp[0*256+i] = (Uint16)(redTable[i] * 65535.0f);
ramp[1*256+i] = (Uint16)(greenTable[i] * 65535.0f);
ramp[2*256+i] = (Uint16)(blueTable[i] * 65535.0f);
}
return 0;
}
void
Cocoa_SetWindowMouseRect(_THIS, SDL_Window * window)
{

View File

@ -91,8 +91,6 @@ HAIKU_CreateDevice(void)
device->SetWindowBordered = HAIKU_SetWindowBordered;
device->SetWindowResizable = HAIKU_SetWindowResizable;
device->SetWindowFullscreen = HAIKU_SetWindowFullscreen;
device->SetWindowGammaRamp = HAIKU_SetWindowGammaRamp;
device->GetWindowGammaRamp = HAIKU_GetWindowGammaRamp;
device->SetWindowMouseGrab = HAIKU_SetWindowMouseGrab;
device->SetWindowMinimumSize = HAIKU_SetWindowMinimumSize;
device->DestroyWindow = HAIKU_DestroyWindow;

View File

@ -194,16 +194,6 @@ void HAIKU_SetWindowFullscreen(_THIS, SDL_Window * window,
}
int HAIKU_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) {
/* FIXME: Not Haiku supported */
return -1;
}
int HAIKU_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) {
/* FIXME: Not Haiku supported */
return -1;
}
void HAIKU_SetWindowMinimumSize(_THIS, SDL_Window * window){
BMessage msg(BWIN_MINIMUM_SIZE_WINDOW);

View File

@ -42,8 +42,6 @@ extern void HAIKU_RestoreWindow(_THIS, SDL_Window * window);
extern void HAIKU_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
extern void HAIKU_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
extern void HAIKU_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
extern int HAIKU_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
extern int HAIKU_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
extern void HAIKU_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
extern void HAIKU_DestroyWindow(_THIS, SDL_Window * window);
extern int HAIKU_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info);

View File

@ -59,10 +59,6 @@ SDL_KMSDRM_SYM(drmModeCrtcPtr,drmModeGetCrtc,(int fd, uint32_t crtcId))
SDL_KMSDRM_SYM(int,drmModeSetCrtc,(int fd, uint32_t crtcId, uint32_t bufferId,
uint32_t x, uint32_t y, uint32_t *connectors, int count,
drmModeModeInfoPtr mode))
SDL_KMSDRM_SYM(int,drmModeCrtcGetGamma,(int fd, uint32_t crtc_id, uint32_t size,
uint16_t *red, uint16_t *green, uint16_t *blue))
SDL_KMSDRM_SYM(int,drmModeCrtcSetGamma,(int fd, uint32_t crtc_id, uint32_t size,
uint16_t *red, uint16_t *green, uint16_t *blue))
SDL_KMSDRM_SYM(int,drmModeSetCursor,(int fd, uint32_t crtcId, uint32_t bo_handle,
uint32_t width, uint32_t height))
SDL_KMSDRM_SYM(int,drmModeSetCursor2,(int fd, uint32_t crtcId, uint32_t bo_handle,

View File

@ -274,8 +274,6 @@ KMSDRM_CreateDevice(void)
device->SetWindowPosition = KMSDRM_SetWindowPosition;
device->SetWindowSize = KMSDRM_SetWindowSize;
device->SetWindowFullscreen = KMSDRM_SetWindowFullscreen;
device->GetWindowGammaRamp = KMSDRM_GetWindowGammaRamp;
device->SetWindowGammaRamp = KMSDRM_SetWindowGammaRamp;
device->ShowWindow = KMSDRM_ShowWindow;
device->HideWindow = KMSDRM_HideWindow;
device->RaiseWindow = KMSDRM_RaiseWindow;
@ -1541,42 +1539,6 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
return ret;
}
int
KMSDRM_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
{
SDL_WindowData *windata = (SDL_WindowData*)window->driverdata;
SDL_VideoData *viddata = (SDL_VideoData*)windata->viddata;
SDL_VideoDisplay *disp = SDL_GetDisplayForWindow(window);
SDL_DisplayData* dispdata = (SDL_DisplayData*)disp->driverdata;
if (KMSDRM_drmModeCrtcGetGamma(viddata->drm_fd, dispdata->crtc->crtc_id, 256, &ramp[0*256], &ramp[1*256], &ramp[2*256]) == -1)
{
return SDL_SetError("Failed to get gamma ramp");
}
return 0;
}
int
KMSDRM_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
{
SDL_WindowData *windata = (SDL_WindowData*)window->driverdata;
SDL_VideoData *viddata = (SDL_VideoData*)windata->viddata;
SDL_VideoDisplay *disp = SDL_GetDisplayForWindow(window);
SDL_DisplayData* dispdata = (SDL_DisplayData*)disp->driverdata;
Uint16* tempRamp = SDL_calloc(3 * sizeof(Uint16), 256);
if (tempRamp == NULL)
{
return SDL_OutOfMemory();
}
SDL_memcpy(tempRamp, ramp, 3 * sizeof(Uint16) * 256);
if (KMSDRM_drmModeCrtcSetGamma(viddata->drm_fd, dispdata->crtc->crtc_id, 256, &tempRamp[0*256], &tempRamp[1*256], &tempRamp[2*256]) == -1)
{
SDL_free(tempRamp);
return SDL_SetError("Failed to set gamma ramp");
}
SDL_free(tempRamp);
return 0;
}
int
KMSDRM_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{

View File

@ -130,8 +130,6 @@ void KMSDRM_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
void KMSDRM_SetWindowPosition(_THIS, SDL_Window * window);
void KMSDRM_SetWindowSize(_THIS, SDL_Window * window);
void KMSDRM_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen);
int KMSDRM_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
int KMSDRM_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
void KMSDRM_ShowWindow(_THIS, SDL_Window * window);
void KMSDRM_HideWindow(_THIS, SDL_Window * window);
void KMSDRM_RaiseWindow(_THIS, SDL_Window * window);

View File

@ -193,9 +193,7 @@ WIN_CreateDevice(void)
device->SetWindowAlwaysOnTop = WIN_SetWindowAlwaysOnTop;
device->SetWindowFullscreen = WIN_SetWindowFullscreen;
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
device->SetWindowGammaRamp = WIN_SetWindowGammaRamp;
device->GetWindowICCProfile = WIN_GetWindowICCProfile;
device->GetWindowGammaRamp = WIN_GetWindowGammaRamp;
device->SetWindowMouseRect = WIN_SetWindowMouseRect;
device->SetWindowMouseGrab = WIN_SetWindowMouseGrab;
device->SetWindowKeyboardGrab = WIN_SetWindowKeyboardGrab;

View File

@ -1022,25 +1022,6 @@ WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display,
}
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
int
WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
{
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
HDC hdc;
BOOL succeeded = FALSE;
hdc = CreateDCW(data->DeviceName, NULL, NULL, NULL);
if (hdc) {
succeeded = SetDeviceGammaRamp(hdc, (LPVOID)ramp);
if (!succeeded) {
WIN_SetError("SetDeviceGammaRamp()");
}
DeleteDC(hdc);
}
return succeeded ? 0 : -1;
}
void
WIN_UpdateWindowICCProfile(SDL_Window * window, SDL_bool send_event)
{
@ -1091,25 +1072,6 @@ WIN_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size)
return iccProfileData;
}
int
WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
{
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
HDC hdc;
BOOL succeeded = FALSE;
hdc = CreateDCW(data->DeviceName, NULL, NULL, NULL);
if (hdc) {
succeeded = GetDeviceGammaRamp(hdc, (LPVOID)ramp);
if (!succeeded) {
WIN_SetError("GetDeviceGammaRamp()");
}
DeleteDC(hdc);
}
return succeeded ? 0 : -1;
}
static void WIN_GrabKeyboard(SDL_Window *window)
{
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;

View File

@ -93,10 +93,8 @@ extern void WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
extern void WIN_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
extern void WIN_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top);
extern void WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
extern int WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
extern void WIN_UpdateWindowICCProfile(SDL_Window * window, SDL_bool send_event);
extern void* WIN_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size);
extern int WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
extern void WIN_SetWindowMouseRect(_THIS, SDL_Window * window);
extern void WIN_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
extern void WIN_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed);

View File

@ -254,7 +254,6 @@ X11_CreateDevice(void)
device->SetWindowResizable = X11_SetWindowResizable;
device->SetWindowAlwaysOnTop = X11_SetWindowAlwaysOnTop;
device->SetWindowFullscreen = X11_SetWindowFullscreen;
device->SetWindowGammaRamp = X11_SetWindowGammaRamp;
device->SetWindowMouseGrab = X11_SetWindowMouseGrab;
device->SetWindowKeyboardGrab = X11_SetWindowKeyboardGrab;
device->DestroyWindow = X11_DestroyWindow;

View File

@ -1479,73 +1479,6 @@ X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display,
X11_SetWindowFullscreenViaWM(_this, window, _display, fullscreen);
}
int
X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
Display *display = data->videodata->display;
Visual *visual = data->visual;
Colormap colormap = data->colormap;
XColor *colorcells;
int ncolors;
int rmask, gmask, bmask;
int rshift, gshift, bshift;
int i;
if (visual->class != DirectColor) {
return SDL_SetError("Window doesn't have DirectColor visual");
}
ncolors = visual->map_entries;
colorcells = SDL_malloc(ncolors * sizeof(XColor));
if (!colorcells) {
return SDL_OutOfMemory();
}
rshift = 0;
rmask = visual->red_mask;
while (0 == (rmask & 1)) {
rshift++;
rmask >>= 1;
}
gshift = 0;
gmask = visual->green_mask;
while (0 == (gmask & 1)) {
gshift++;
gmask >>= 1;
}
bshift = 0;
bmask = visual->blue_mask;
while (0 == (bmask & 1)) {
bshift++;
bmask >>= 1;
}
/* build the color table pixel values */
for (i = 0; i < ncolors; i++) {
Uint32 rbits = (rmask * i) / (ncolors - 1);
Uint32 gbits = (gmask * i) / (ncolors - 1);
Uint32 bbits = (bmask * i) / (ncolors - 1);
Uint32 pix = (rbits << rshift) | (gbits << gshift) | (bbits << bshift);
colorcells[i].pixel = pix;
colorcells[i].red = ramp[(0 * 256) + i];
colorcells[i].green = ramp[(1 * 256) + i];
colorcells[i].blue = ramp[(2 * 256) + i];
colorcells[i].flags = DoRed | DoGreen | DoBlue;
}
X11_XStoreColors(display, colormap, colorcells, ncolors);
X11_XFlush(display);
SDL_free(colorcells);
return 0;
}
typedef struct {
unsigned char *data;
int format, count;

View File

@ -106,7 +106,6 @@ extern void X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
extern void X11_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
extern void X11_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top);
extern void X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
extern int X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
extern void* X11_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size);
extern void X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
extern void X11_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed);

View File

@ -510,61 +510,6 @@ video_getClosestDisplayModeRandomResolution(void *arg)
return TEST_COMPLETED;
}
/**
* @brief Tests call to SDL_GetWindowBrightness
*
* @sa http://wiki.libsdl.org/SDL_GetWindowBrightness
*/
int
video_getWindowBrightness(void *arg)
{
SDL_Window* window;
const char* title = "video_getWindowBrightness Test Window";
float result;
/* Call against new test window */
window = _createVideoSuiteTestWindow(title);
if (window != NULL) {
result = SDL_GetWindowBrightness(window);
SDLTest_AssertPass("Call to SDL_GetWindowBrightness()");
SDLTest_AssertCheck(result >= 0.0 && result <= 1.0, "Validate range of result value; expected: [0.0, 1.0], got: %f", result);
}
/* Clean up */
_destroyVideoSuiteTestWindow(window);
return TEST_COMPLETED;
}
/**
* @brief Tests call to SDL_GetWindowBrightness with invalid input
*
* @sa http://wiki.libsdl.org/SDL_GetWindowBrightness
*/
int
video_getWindowBrightnessNegative(void *arg)
{
const char *invalidWindowError = "Invalid window";
char *lastError;
float result;
/* Call against invalid window */
result = SDL_GetWindowBrightness(NULL);
SDLTest_AssertPass("Call to SDL_GetWindowBrightness(window=NULL)");
SDLTest_AssertCheck(result == 1.0, "Validate result value; expected: 1.0, got: %f", result);
lastError = (char *)SDL_GetError();
SDLTest_AssertPass("SDL_GetError()");
SDLTest_AssertCheck(lastError != NULL, "Verify error message is not NULL");
if (lastError != NULL) {
SDLTest_AssertCheck(SDL_strcmp(lastError, invalidWindowError) == 0,
"SDL_GetError(): expected message '%s', was message: '%s'",
invalidWindowError,
lastError);
}
return TEST_COMPLETED;
}
/**
* @brief Tests call to SDL_GetWindowDisplayMode
*
@ -663,92 +608,6 @@ video_getWindowDisplayModeNegative(void *arg)
return TEST_COMPLETED;
}
/**
* @brief Tests call to SDL_GetWindowGammaRamp
*
* @sa http://wiki.libsdl.org/SDL_GetWindowGammaRamp
*/
int
video_getWindowGammaRamp(void *arg)
{
SDL_Window* window;
const char* title = "video_getWindowGammaRamp Test Window";
Uint16 red[256];
Uint16 green[256];
Uint16 blue[256];
int result;
/* Call against new test window */
window = _createVideoSuiteTestWindow(title);
if (window == NULL) return TEST_ABORTED;
/* Retrieve no channel */
result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(all NULL)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
/* Retrieve single channel */
result = SDL_GetWindowGammaRamp(window, red, NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
result = SDL_GetWindowGammaRamp(window, NULL, green, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
result = SDL_GetWindowGammaRamp(window, NULL, NULL, blue);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(b)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
/* Retrieve two channels */
result = SDL_GetWindowGammaRamp(window, red, green, NULL);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r, g)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
result = SDL_GetWindowGammaRamp(window, NULL, green, blue);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(g,b)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
result = SDL_GetWindowGammaRamp(window, red, NULL, blue);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,b)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
/* Retrieve all channels */
result = SDL_GetWindowGammaRamp(window, red, green, blue);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(r,g,b)");
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result);
/* Clean up */
_destroyVideoSuiteTestWindow(window);
return TEST_COMPLETED;
}
/**
* @brief Tests call to SDL_GetWindowGammaRamp with invalid input
*
* @sa http://wiki.libsdl.org/SDL_GetWindowGammaRamp
*/
int
video_getWindowGammaRampNegative(void *arg)
{
Uint16 red[256];
Uint16 green[256];
Uint16 blue[256];
int result;
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
/* Call against invalid window */
result = SDL_GetWindowGammaRamp(NULL, red, green, blue);
SDLTest_AssertPass("Call to SDL_GetWindowGammaRamp(window=NULL,r,g,b)");
SDLTest_AssertCheck(result == -1, "Validate result value; expected: -1, got: %i", result);
_checkInvalidWindowError();
return TEST_COMPLETED;
}
/* Helper for setting and checking the window mouse grab state */
void
_setAndCheckWindowMouseGrabState(SDL_Window* window, SDL_bool desiredState)
@ -2011,48 +1870,36 @@ static const SDLTest_TestCaseReference videoTest9 =
{ (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest10 =
{ (SDLTest_TestCaseFp)video_getWindowBrightness, "video_getWindowBrightness", "Get window brightness", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest11 =
{ (SDLTest_TestCaseFp)video_getWindowBrightnessNegative, "video_getWindowBrightnessNegative", "Get window brightness with invalid input", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest12 =
{ (SDLTest_TestCaseFp)video_getWindowDisplayMode, "video_getWindowDisplayMode", "Get window display mode", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest13 =
static const SDLTest_TestCaseReference videoTest11 =
{ (SDLTest_TestCaseFp)video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative", "Get window display mode with invalid input", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest14 =
{ (SDLTest_TestCaseFp)video_getWindowGammaRamp, "video_getWindowGammaRamp", "Get window gamma ramp", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest15 =
{ (SDLTest_TestCaseFp)video_getWindowGammaRampNegative, "video_getWindowGammaRampNegative", "Get window gamma ramp against invalid input", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest16 =
static const SDLTest_TestCaseReference videoTest12 =
{ (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab", "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest17 =
static const SDLTest_TestCaseReference videoTest13 =
{ (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest18 =
static const SDLTest_TestCaseReference videoTest14 =
{ (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest19 =
static const SDLTest_TestCaseReference videoTest15 =
{ (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest20 =
static const SDLTest_TestCaseReference videoTest16 =
{ (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize", "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest21 =
static const SDLTest_TestCaseReference videoTest17 =
{ (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize", "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest22 =
static const SDLTest_TestCaseReference videoTest18 =
{ (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize", "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest23 =
static const SDLTest_TestCaseReference videoTest19 =
{ (SDLTest_TestCaseFp)video_getSetWindowData, "video_getSetWindowData", "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED };
static const SDLTest_TestCaseReference videoTest24 =
static const SDLTest_TestCaseReference videoTest20 =
{ (SDLTest_TestCaseFp) video_setWindowCenteredOnDisplay, "video_setWindowCenteredOnDisplay", "Checks using SDL_WINDOWPOS_CENTERED_DISPLAY centers the window on a display", TEST_ENABLED };
/* Sequence of Video test cases */
@ -2060,8 +1907,7 @@ static const SDLTest_TestCaseReference *videoTests[] = {
&videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6,
&videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12,
&videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17,
&videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22,
&videoTest23, &videoTest24, NULL
&videoTest18, &videoTest19, &videoTest20, NULL
};
/* Video test suite (global) */