Mercurial > sdl-ios-xcode
comparison src/video/SDL_gamma.c @ 1672:8e754b82cecc SDL-1.3
Updated SDL_Surface code for software-only access, fixed some build errors
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 09 Jun 2006 07:06:12 +0000 |
parents | 4da1ee79c9af |
children | 7179cb72dbba |
comparison
equal
deleted
inserted
replaced
1671:89f7510fe17a | 1672:8e754b82cecc |
---|---|
107 CalculateGammaRamp(red, ramp[0]); | 107 CalculateGammaRamp(red, ramp[0]); |
108 CalculateGammaRamp(green, ramp[1]); | 108 CalculateGammaRamp(green, ramp[1]); |
109 CalculateGammaRamp(blue, ramp[2]); | 109 CalculateGammaRamp(blue, ramp[2]); |
110 succeeded = SDL_SetGammaRamp(ramp[0], ramp[1], ramp[2]); | 110 succeeded = SDL_SetGammaRamp(ramp[0], ramp[1], ramp[2]); |
111 } | 111 } |
112 if ((succeeded < 0) && _this->SetGamma) { | 112 if ((succeeded < 0) && _this && _this->SetGamma) { |
113 SDL_ClearError(); | 113 SDL_ClearError(); |
114 succeeded = _this->SetGamma(_this, red, green, blue); | 114 succeeded = _this->SetGamma(_this, red, green, blue); |
115 } | 115 } |
116 return succeeded; | 116 return succeeded; |
117 } | 117 } |
135 CalculateGammaFromRamp(red, ramp[0]); | 135 CalculateGammaFromRamp(red, ramp[0]); |
136 CalculateGammaFromRamp(green, ramp[1]); | 136 CalculateGammaFromRamp(green, ramp[1]); |
137 CalculateGammaFromRamp(blue, ramp[2]); | 137 CalculateGammaFromRamp(blue, ramp[2]); |
138 } | 138 } |
139 } | 139 } |
140 if ((succeeded < 0) && _this->GetGamma) { | 140 if ((succeeded < 0) && _this && _this->GetGamma) { |
141 SDL_ClearError(); | 141 SDL_ClearError(); |
142 succeeded = _this->GetGamma(_this, red, green, blue); | 142 succeeded = _this->GetGamma(_this, red, green, blue); |
143 } | 143 } |
144 return succeeded; | 144 return succeeded; |
145 } | 145 } |
148 SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, | 148 SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, |
149 const Uint16 * blue) | 149 const Uint16 * blue) |
150 { | 150 { |
151 SDL_VideoDevice *_this = SDL_GetVideoDevice(); | 151 SDL_VideoDevice *_this = SDL_GetVideoDevice(); |
152 int succeeded; | 152 int succeeded; |
153 SDL_Surface *screen = SDL_PublicSurface; | |
154 | |
155 /* Verify the screen parameter */ | |
156 if (!screen) { | |
157 SDL_SetError("No video mode has been set"); | |
158 return -1; | |
159 } | |
160 | 153 |
161 /* Lazily allocate the gamma tables */ | 154 /* Lazily allocate the gamma tables */ |
162 if (!SDL_CurrentWindow.gamma) { | 155 if (!SDL_CurrentWindow.gamma) { |
163 SDL_GetGammaRamp(0, 0, 0); | 156 SDL_GetGammaRamp(0, 0, 0); |
164 } | 157 } |
177 256 * sizeof(*SDL_CurrentWindow.gamma)); | 170 256 * sizeof(*SDL_CurrentWindow.gamma)); |
178 } | 171 } |
179 | 172 |
180 /* Try to set the gamma ramp in the driver */ | 173 /* Try to set the gamma ramp in the driver */ |
181 succeeded = -1; | 174 succeeded = -1; |
182 if (_this->SetGammaRamp) { | 175 if (_this && _this->SetGammaRamp) { |
183 succeeded = _this->SetGammaRamp(_this, SDL_CurrentWindow.gamma); | 176 succeeded = _this->SetGammaRamp(_this, SDL_CurrentWindow.gamma); |
184 } else { | 177 } else { |
185 SDL_SetError("Gamma ramp manipulation not supported"); | 178 SDL_SetError("Gamma ramp manipulation not supported"); |
186 } | 179 } |
187 return succeeded; | 180 return succeeded; |
198 SDL_malloc(3 * 256 * sizeof(*SDL_CurrentWindow.gamma)); | 191 SDL_malloc(3 * 256 * sizeof(*SDL_CurrentWindow.gamma)); |
199 if (!SDL_CurrentWindow.gamma) { | 192 if (!SDL_CurrentWindow.gamma) { |
200 SDL_OutOfMemory(); | 193 SDL_OutOfMemory(); |
201 return -1; | 194 return -1; |
202 } | 195 } |
203 if (_this->GetGammaRamp) { | 196 if (_this && _this->GetGammaRamp) { |
204 /* Get the real hardware gamma */ | 197 /* Get the real hardware gamma */ |
205 _this->GetGammaRamp(_this, SDL_CurrentWindow.gamma); | 198 _this->GetGammaRamp(_this, SDL_CurrentWindow.gamma); |
206 } else { | 199 } else { |
207 /* Assume an identity gamma */ | 200 /* Assume an identity gamma */ |
208 int i; | 201 int i; |