1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
/**
* libgamma -- Display server abstraction layer for gamma ramp adjustments
* Copyright (C) 2014 Mattias Andrée (maandree@member.fsf.org)
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBGAMMA_FAKE_QUARTZ_CG_H
#define LIBGAMMA_FAKE_QUARTZ_CG_H
#ifndef FAKE_LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS
# error Including fake-quartz-cg.h without FAKE_LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS
#endif
#ifndef __GCC__
# define __attribute__(x)
#endif
/* This header file contains some capabilities of
* <CoreGraphics/CGDirectDisplay.h> and <CoreGraphics/CGError.h>,
* and can be used modify gamma ramps without Mac OS X and Quartz
* but with its API.
*
* The content of this file is based on the documentation found on:
*
* https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html
*
* https://developer.apple.com/library/mac/documentation/CoreGraphics/Reference/CoreGraphicsConstantsRef/Reference/reference.html#//apple_ref/c/tdef/CGError */
#include <stdint.h>
/**
* Numerical `typedef` for errors that occur in CoreGraphics calls.
*/
typedef int32_t CGError;
/**
* The call was successful.
*/
#define kCGErrorSuccess 0
/**
* The data type that is used for the values in the gamma ramps.
*/
typedef float CGGammaValue;
/**
* The data type for display ID:s.
*/
typedef uint32_t CGDirectDisplayID;
/**
* Get a list of all online displays on the system.
*
* @param max_size The number of elements allocated for `displays_out`.
* @param displays_out List ot fill with the ID for each online display on the system.
* @param count_out Output parameter for the number of elements stored in `displays_out`.
* if `displays_out` is too small to fit all display ID:s,
* `*count_out` will be `max_size`.
* @return `kCGErrorSuccess` on success, and error number of failure.
*/
CGError CGGetOnlineDisplayList(uint32_t max_size,
CGDirectDisplayID* restrict displays_out, uint32_t* restrict count_out);
/**
* Set the gamma ramps for a display.
*
* @param display The ID of the display.
* @param gamma_size The number of stops in gamma ramps.
* @param red The gamma ramp for the red channel.
* @param green The gamma ramp for the green channel.
* @param blue The gamma ramp for the blue channel.
* @return `kCGErrorSuccess` on success, and error number of failure.
*/
CGError CGSetDisplayTransferByTable(CGDirectDisplayID display, uint32_t gamma_size, const CGGammaValue* red,
const CGGammaValue* green, const CGGammaValue* blue);
/**
* Get the current gamma ramps for a display.
*
* @param display The ID of the display.
* @param gamma_size The number of stops you have allocated for the gamma ramps.
* @param red Table allocated for the gamma ramp for the red channel.
* @param green Table allocated for the gamma ramp for the green channel.
* @param blue Table allocated for the gamma ramp for the blue channel.
* @param gamma_size_out Output parameter for the actual number of stops in the gamma ramps.
* @return `kCGErrorSuccess` on success, and error number of failure.
*/
CGError CGGetDisplayTransferByTable(CGDirectDisplayID display, uint32_t gamma_size,
CGGammaValue* restrict red, CGGammaValue* restrict green,
CGGammaValue* restrict blue, uint32_t* restrict gamma_size_out);
/**
* Restore each display's gamma ramps to the settings in ColorSync.
*/
void CGDisplayRestoreColorSyncSettings(void);
/**
* Get the number of stops in the gamma ramps for a display.
*
* @param display The ID of the display.
* @return The number of stops in the gamma ramps.
*/
uint32_t CGDisplayGammaTableCapacity(CGDirectDisplayID display) __attribute__((const));
/* The follow part most only be used when this module is used,
* it cannot be used when the real CoreGraphics is used.
* CoreGraphics does not have this function, it is added so
* that there is a way to cleanly close the X connection
* and free resources needed by this module. */
/**
* Release resources used by the backend.
*/
void close_fake_quartz_cg(void);
#ifndef __GCC__
# undef __attribute__
#endif
#endif
|