src/video/cocoa/SDL_cocoawindow.m
changeset 5466 006883d5fa51
parent 5406 1517da4ab6b1
child 5478 6b65ff3cee62
equal deleted inserted replaced
5465:46bd121b04a2 5466:006883d5fa51
   854     [nswindow makeKeyAndOrderFront:nil];
   854     [nswindow makeKeyAndOrderFront:nil];
   855 
   855 
   856     [pool release];
   856     [pool release];
   857 }
   857 }
   858 
   858 
   859 NSPoint origin;
   859 int
       
   860 Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp)
       
   861 {
       
   862     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
       
   863     CGDirectDisplayID display_id = ((SDL_DisplayData *)display->driverdata)->display;
       
   864     const uint32_t tableSize = 256;
       
   865     CGGammaValue redTable[tableSize];
       
   866     CGGammaValue greenTable[tableSize];
       
   867     CGGammaValue blueTable[tableSize];
       
   868     uint32_t i;
       
   869     float inv65535 = 1.0f / 65535.0f;
       
   870 
       
   871     /* Extract gamma values into separate tables, convert to floats between 0.0 and 1.0 */
       
   872     for (i = 0; i < 256; i++) {
       
   873         redTable[i] = ramp[0*256+i] * inv65535;
       
   874         greenTable[i] = ramp[1*256+i] * inv65535;
       
   875         blueTable[i] = ramp[2*256+i] * inv65535;
       
   876     }
       
   877 
       
   878     if (CGSetDisplayTransferByTable(display_id, tableSize,
       
   879                                     redTable, greenTable, blueTable) != CGDisplayNoErr) {
       
   880         SDL_SetError("CGSetDisplayTransferByTable()");
       
   881         return -1;
       
   882     }
       
   883     return 0;
       
   884 }
       
   885 
       
   886 int
       
   887 Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
       
   888 {
       
   889     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
       
   890     CGDirectDisplayID display_id = ((SDL_DisplayData *)display->driverdata)->display;
       
   891     const uint32_t tableSize = 256;
       
   892     CGGammaValue redTable[tableSize];
       
   893     CGGammaValue greenTable[tableSize];
       
   894     CGGammaValue blueTable[tableSize];
       
   895     uint32_t i, tableCopied;
       
   896 
       
   897     if (CGGetDisplayTransferByTable(display_id, tableSize,
       
   898                                     redTable, greenTable, blueTable, &tableCopied) != CGDisplayNoErr) {
       
   899         SDL_SetError("CGGetDisplayTransferByTable()");
       
   900         return -1;
       
   901     }
       
   902 
       
   903     for (i = 0; i < tableCopied; i++) {
       
   904         ramp[0*256+i] = (Uint16)(redTable[i] * 65535.0f);
       
   905         ramp[1*256+i] = (Uint16)(greenTable[i] * 65535.0f);
       
   906         ramp[2*256+i] = (Uint16)(blueTable[i] * 65535.0f);
       
   907     }
       
   908     return 0;
       
   909 }
       
   910 
   860 void
   911 void
   861 Cocoa_SetWindowGrab(_THIS, SDL_Window * window)
   912 Cocoa_SetWindowGrab(_THIS, SDL_Window * window)
   862 {
   913 {
   863     /* Move the cursor to the nearest point in the window */
   914     /* Move the cursor to the nearest point in the window */
   864     if ((window->flags & SDL_WINDOW_INPUT_GRABBED) &&
   915     if ((window->flags & SDL_WINDOW_INPUT_GRABBED) &&