src/video/quartz/SDL_QuartzVideo.m
branchSDL-1.2
changeset 7069 f7fd5c3951b9
parent 6233 fdb37a6dc407
child 8040 22a7f096bb9d
equal deleted inserted replaced
6935:b6b2829cd7ef 7069:f7fd5c3951b9
  1633         return -1;
  1633         return -1;
  1634 }
  1634 }
  1635 
  1635 
  1636 int QZ_SetGammaRamp (_THIS, Uint16 *ramp)
  1636 int QZ_SetGammaRamp (_THIS, Uint16 *ramp)
  1637 {
  1637 {
  1638     const uint32_t tableSize = 255;
  1638     const uint32_t tableSize = 256;
  1639     CGGammaValue redTable[tableSize];
  1639     CGGammaValue redTable[tableSize];
  1640     CGGammaValue greenTable[tableSize];
  1640     CGGammaValue greenTable[tableSize];
  1641     CGGammaValue blueTable[tableSize];
  1641     CGGammaValue blueTable[tableSize];
  1642 
  1642 
  1643     int i;
  1643     int i;
  1644 
  1644 
  1645     /* Extract gamma values into separate tables, convert to floats between 0.0 and 1.0 */
  1645     /* Extract gamma values into separate tables, convert to floats between 0.0 and 1.0 */
  1646     for (i = 0; i < 256; i++)
  1646     for (i = 0; i < 256; i++)
  1647         redTable[i % 256] = ramp[i] / 65535.0;
  1647         redTable[i % tableSize] = ramp[i] / 65535.0;
  1648 
  1648 
  1649     for (i=256; i < 512; i++)
  1649     for (i=256; i < 512; i++)
  1650         greenTable[i % 256] = ramp[i] / 65535.0;
  1650         greenTable[i % tableSize] = ramp[i] / 65535.0;
  1651 
  1651 
  1652     for (i=512; i < 768; i++)
  1652     for (i=512; i < 768; i++)
  1653         blueTable[i % 256] = ramp[i] / 65535.0;
  1653         blueTable[i % tableSize] = ramp[i] / 65535.0;
  1654 
  1654 
  1655     if ( CGDisplayNoErr == CGSetDisplayTransferByTable
  1655     if ( CGDisplayNoErr == CGSetDisplayTransferByTable
  1656          (display_id, tableSize, redTable, greenTable, blueTable) )
  1656          (display_id, tableSize, redTable, greenTable, blueTable) )
  1657         return 0;
  1657         return 0;
  1658     else
  1658     else
  1659         return -1;
  1659         return -1;
  1660 }
  1660 }
  1661 
  1661 
  1662 int QZ_GetGammaRamp (_THIS, Uint16 *ramp)
  1662 int QZ_GetGammaRamp (_THIS, Uint16 *ramp)
  1663 {
  1663 {
  1664     const uint32_t tableSize = 255;
  1664     const uint32_t tableSize = 256;
  1665     CGGammaValue redTable[tableSize];
  1665     CGGammaValue redTable[tableSize];
  1666     CGGammaValue greenTable[tableSize];
  1666     CGGammaValue greenTable[tableSize];
  1667     CGGammaValue blueTable[tableSize];
  1667     CGGammaValue blueTable[tableSize];
  1668     uint32_t actual;
  1668     uint32_t actual;
  1669     int i;
  1669     int i;
  1674 
  1674 
  1675         return -1;
  1675         return -1;
  1676 
  1676 
  1677     /* Pack tables into one array, with values from 0 to 65535 */
  1677     /* Pack tables into one array, with values from 0 to 65535 */
  1678     for (i = 0; i < 256; i++)
  1678     for (i = 0; i < 256; i++)
  1679         ramp[i] = redTable[i % 256] * 65535.0;
  1679         ramp[i] = redTable[i % tableSize] * 65535.0;
  1680 
  1680 
  1681     for (i=256; i < 512; i++)
  1681     for (i=256; i < 512; i++)
  1682         ramp[i] = greenTable[i % 256] * 65535.0;
  1682         ramp[i] = greenTable[i % tableSize] * 65535.0;
  1683 
  1683 
  1684     for (i=512; i < 768; i++)
  1684     for (i=512; i < 768; i++)
  1685         ramp[i] = blueTable[i % 256] * 65535.0;
  1685         ramp[i] = blueTable[i % tableSize] * 65535.0;
  1686 
  1686 
  1687     return 0;
  1687     return 0;
  1688 }
  1688 }
  1689 
  1689