Mercurial > sdl-ios-xcode
comparison src/video/photon/SDL_ph_image.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
31 #include "SDL_ph_image_c.h" | 31 #include "SDL_ph_image_c.h" |
32 #include "SDL_ph_modes_c.h" | 32 #include "SDL_ph_modes_c.h" |
33 #include "SDL_ph_gl.h" | 33 #include "SDL_ph_gl.h" |
34 | 34 |
35 int | 35 int |
36 ph_SetupImage (_THIS, SDL_Surface * screen) | 36 ph_SetupImage(_THIS, SDL_Surface * screen) |
37 { | 37 { |
38 PgColor_t *palette = NULL; | 38 PgColor_t *palette = NULL; |
39 int type = 0; | 39 int type = 0; |
40 int bpp; | 40 int bpp; |
41 | 41 |
68 type = Pg_IMAGE_DIRECT_8888; | 68 type = Pg_IMAGE_DIRECT_8888; |
69 } | 69 } |
70 break; | 70 break; |
71 default: | 71 default: |
72 { | 72 { |
73 SDL_SetError ("ph_SetupImage(): unsupported bpp=%d !\n", bpp); | 73 SDL_SetError("ph_SetupImage(): unsupported bpp=%d !\n", bpp); |
74 return -1; | 74 return -1; |
75 } | 75 } |
76 break; | 76 break; |
77 } | 77 } |
78 | 78 |
79 /* palette emulation code */ | 79 /* palette emulation code */ |
80 if ((bpp == 8) && (desktoppal == SDLPH_PAL_EMULATE)) { | 80 if ((bpp == 8) && (desktoppal == SDLPH_PAL_EMULATE)) { |
81 /* creating image palette */ | 81 /* creating image palette */ |
82 palette = SDL_malloc (_Pg_MAX_PALETTE * sizeof (PgColor_t)); | 82 palette = SDL_malloc(_Pg_MAX_PALETTE * sizeof(PgColor_t)); |
83 if (palette == NULL) { | 83 if (palette == NULL) { |
84 SDL_SetError | 84 SDL_SetError |
85 ("ph_SetupImage(): can't allocate memory for palette !\n"); | 85 ("ph_SetupImage(): can't allocate memory for palette !\n"); |
86 return -1; | 86 return -1; |
87 } | 87 } |
88 PgGetPalette (palette); | 88 PgGetPalette(palette); |
89 | 89 |
90 /* using shared memory for speed (set last param to 1) */ | 90 /* using shared memory for speed (set last param to 1) */ |
91 if ((SDL_Image = | 91 if ((SDL_Image = |
92 PhCreateImage (NULL, screen->w, screen->h, type, palette, | 92 PhCreateImage(NULL, screen->w, screen->h, type, palette, |
93 _Pg_MAX_PALETTE, 1)) == NULL) { | 93 _Pg_MAX_PALETTE, 1)) == NULL) { |
94 SDL_SetError | 94 SDL_SetError |
95 ("ph_SetupImage(): PhCreateImage() failed for bpp=8 !\n"); | 95 ("ph_SetupImage(): PhCreateImage() failed for bpp=8 !\n"); |
96 SDL_free (palette); | 96 SDL_free(palette); |
97 return -1; | 97 return -1; |
98 } | 98 } |
99 } else { | 99 } else { |
100 /* using shared memory for speed (set last param to 1) */ | 100 /* using shared memory for speed (set last param to 1) */ |
101 if ((SDL_Image = | 101 if ((SDL_Image = |
102 PhCreateImage (NULL, screen->w, screen->h, type, NULL, 0, | 102 PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, |
103 1)) == NULL) { | 103 1)) == NULL) { |
104 SDL_SetError | 104 SDL_SetError |
105 ("ph_SetupImage(): PhCreateImage() failed for bpp=%d !\n", | 105 ("ph_SetupImage(): PhCreateImage() failed for bpp=%d !\n", |
106 bpp); | 106 bpp); |
107 return -1; | 107 return -1; |
108 } | 108 } |
115 | 115 |
116 return 0; | 116 return 0; |
117 } | 117 } |
118 | 118 |
119 int | 119 int |
120 ph_SetupOCImage (_THIS, SDL_Surface * screen) | 120 ph_SetupOCImage(_THIS, SDL_Surface * screen) |
121 { | 121 { |
122 int type = 0; | 122 int type = 0; |
123 int bpp; | 123 int bpp; |
124 | 124 |
125 OCImage.flags = screen->flags; | 125 OCImage.flags = screen->flags; |
153 type = Pg_IMAGE_DIRECT_8888; | 153 type = Pg_IMAGE_DIRECT_8888; |
154 } | 154 } |
155 break; | 155 break; |
156 default: | 156 default: |
157 { | 157 { |
158 SDL_SetError ("ph_SetupOCImage(): unsupported bpp=%d !\n", bpp); | 158 SDL_SetError("ph_SetupOCImage(): unsupported bpp=%d !\n", bpp); |
159 return -1; | 159 return -1; |
160 } | 160 } |
161 break; | 161 break; |
162 } | 162 } |
163 | 163 |
164 /* Currently offscreen contexts with the same bit depth as display bpp only can be created */ | 164 /* Currently offscreen contexts with the same bit depth as display bpp only can be created */ |
165 OCImage.offscreen_context = | 165 OCImage.offscreen_context = |
166 PdCreateOffscreenContext (0, screen->w, screen->h, | 166 PdCreateOffscreenContext(0, screen->w, screen->h, |
167 Pg_OSC_MEM_PAGE_ALIGN); | 167 Pg_OSC_MEM_PAGE_ALIGN); |
168 | 168 |
169 if (OCImage.offscreen_context == NULL) { | 169 if (OCImage.offscreen_context == NULL) { |
170 SDL_SetError | 170 SDL_SetError |
171 ("ph_SetupOCImage(): PdCreateOffscreenContext() function failed !\n"); | 171 ("ph_SetupOCImage(): PdCreateOffscreenContext() function failed !\n"); |
172 return -1; | 172 return -1; |
173 } | 173 } |
174 | 174 |
175 screen->pitch = OCImage.offscreen_context->pitch; | 175 screen->pitch = OCImage.offscreen_context->pitch; |
176 | 176 |
177 OCImage.dc_ptr = | 177 OCImage.dc_ptr = |
178 (unsigned char *) PdGetOffscreenContextPtr (OCImage. | 178 (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context); |
179 offscreen_context); | |
180 | 179 |
181 if (OCImage.dc_ptr == NULL) { | 180 if (OCImage.dc_ptr == NULL) { |
182 SDL_SetError | 181 SDL_SetError |
183 ("ph_SetupOCImage(): PdGetOffscreenContextPtr function failed !\n"); | 182 ("ph_SetupOCImage(): PdGetOffscreenContextPtr function failed !\n"); |
184 PhDCRelease (OCImage.offscreen_context); | 183 PhDCRelease(OCImage.offscreen_context); |
185 return -1; | 184 return -1; |
186 } | 185 } |
187 | 186 |
188 OCImage.FrameData0 = OCImage.dc_ptr; | 187 OCImage.FrameData0 = OCImage.dc_ptr; |
189 OCImage.CurrentFrameData = OCImage.FrameData0; | 188 OCImage.CurrentFrameData = OCImage.FrameData0; |
190 OCImage.current = 0; | 189 OCImage.current = 0; |
191 | 190 |
192 PhDCSetCurrent (OCImage.offscreen_context); | 191 PhDCSetCurrent(OCImage.offscreen_context); |
193 | 192 |
194 screen->pixels = OCImage.CurrentFrameData; | 193 screen->pixels = OCImage.CurrentFrameData; |
195 | 194 |
196 this->UpdateRects = ph_OCUpdate; | 195 this->UpdateRects = ph_OCUpdate; |
197 | 196 |
198 return 0; | 197 return 0; |
199 } | 198 } |
200 | 199 |
201 int | 200 int |
202 ph_SetupFullScreenImage (_THIS, SDL_Surface * screen) | 201 ph_SetupFullScreenImage(_THIS, SDL_Surface * screen) |
203 { | 202 { |
204 OCImage.flags = screen->flags; | 203 OCImage.flags = screen->flags; |
205 | 204 |
206 /* Begin direct and fullscreen mode */ | 205 /* Begin direct and fullscreen mode */ |
207 if (!ph_EnterFullScreen (this, screen, PH_ENTER_DIRECTMODE)) { | 206 if (!ph_EnterFullScreen(this, screen, PH_ENTER_DIRECTMODE)) { |
208 return -1; | 207 return -1; |
209 } | 208 } |
210 | 209 |
211 /* store palette for fullscreen */ | 210 /* store palette for fullscreen */ |
212 if ((screen->format->BitsPerPixel == 8) && (desktopbpp != 8)) { | 211 if ((screen->format->BitsPerPixel == 8) && (desktopbpp != 8)) { |
213 PgGetPalette (savedpal); | 212 PgGetPalette(savedpal); |
214 PgGetPalette (syspalph); | 213 PgGetPalette(syspalph); |
215 } | 214 } |
216 | 215 |
217 OCImage.offscreen_context = | 216 OCImage.offscreen_context = |
218 PdCreateOffscreenContext (0, 0, 0, | 217 PdCreateOffscreenContext(0, 0, 0, |
219 Pg_OSC_MAIN_DISPLAY | Pg_OSC_MEM_PAGE_ALIGN | 218 Pg_OSC_MAIN_DISPLAY | Pg_OSC_MEM_PAGE_ALIGN |
220 | Pg_OSC_CRTC_SAFE); | 219 | Pg_OSC_CRTC_SAFE); |
221 if (OCImage.offscreen_context == NULL) { | 220 if (OCImage.offscreen_context == NULL) { |
222 SDL_SetError | 221 SDL_SetError |
223 ("ph_SetupFullScreenImage(): PdCreateOffscreenContext() function failed !\n"); | 222 ("ph_SetupFullScreenImage(): PdCreateOffscreenContext() function failed !\n"); |
224 return -1; | 223 return -1; |
225 } | 224 } |
226 | 225 |
227 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { | 226 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { |
228 OCImage.offscreen_backcontext = | 227 OCImage.offscreen_backcontext = |
229 PdDupOffscreenContext (OCImage.offscreen_context, | 228 PdDupOffscreenContext(OCImage.offscreen_context, |
230 Pg_OSC_MEM_PAGE_ALIGN | Pg_OSC_CRTC_SAFE); | 229 Pg_OSC_MEM_PAGE_ALIGN | Pg_OSC_CRTC_SAFE); |
231 if (OCImage.offscreen_backcontext == NULL) { | 230 if (OCImage.offscreen_backcontext == NULL) { |
232 SDL_SetError | 231 SDL_SetError |
233 ("ph_SetupFullScreenImage(): PdCreateOffscreenContext(back) function failed !\n"); | 232 ("ph_SetupFullScreenImage(): PdCreateOffscreenContext(back) function failed !\n"); |
234 return -1; | 233 return -1; |
235 } | 234 } |
236 } | 235 } |
237 | 236 |
238 OCImage.FrameData0 = | 237 OCImage.FrameData0 = |
239 (unsigned char *) PdGetOffscreenContextPtr (OCImage. | 238 (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context); |
240 offscreen_context); | |
241 if (OCImage.FrameData0 == NULL) { | 239 if (OCImage.FrameData0 == NULL) { |
242 SDL_SetError | 240 SDL_SetError |
243 ("ph_SetupFullScreenImage(): PdGetOffscreenContextPtr() function failed !\n"); | 241 ("ph_SetupFullScreenImage(): PdGetOffscreenContextPtr() function failed !\n"); |
244 ph_DestroyImage (this, screen); | 242 ph_DestroyImage(this, screen); |
245 return -1; | 243 return -1; |
246 } | 244 } |
247 | 245 |
248 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { | 246 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { |
249 OCImage.FrameData1 = | 247 OCImage.FrameData1 = |
250 (unsigned char *) PdGetOffscreenContextPtr (OCImage. | 248 (unsigned char *) PdGetOffscreenContextPtr(OCImage. |
251 offscreen_backcontext); | 249 offscreen_backcontext); |
252 if (OCImage.FrameData1 == NULL) { | 250 if (OCImage.FrameData1 == NULL) { |
253 SDL_SetError | 251 SDL_SetError |
254 ("ph_SetupFullScreenImage(back): PdGetOffscreenContextPtr() function failed !\n"); | 252 ("ph_SetupFullScreenImage(back): PdGetOffscreenContextPtr() function failed !\n"); |
255 ph_DestroyImage (this, screen); | 253 ph_DestroyImage(this, screen); |
256 return -1; | 254 return -1; |
257 } | 255 } |
258 } | 256 } |
259 | 257 |
260 /* wait for the hardware */ | 258 /* wait for the hardware */ |
261 PgFlush (); | 259 PgFlush(); |
262 PgWaitHWIdle (); | 260 PgWaitHWIdle(); |
263 | 261 |
264 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { | 262 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { |
265 OCImage.current = 0; | 263 OCImage.current = 0; |
266 PhDCSetCurrent (OCImage.offscreen_context); | 264 PhDCSetCurrent(OCImage.offscreen_context); |
267 screen->pitch = OCImage.offscreen_context->pitch; | 265 screen->pitch = OCImage.offscreen_context->pitch; |
268 screen->pixels = OCImage.FrameData0; | 266 screen->pixels = OCImage.FrameData0; |
269 | 267 |
270 /* emulate 640x400 videomode */ | 268 /* emulate 640x400 videomode */ |
271 if (videomode_emulatemode == 1) { | 269 if (videomode_emulatemode == 1) { |
272 int i; | 270 int i; |
273 | 271 |
274 for (i = 0; i < 40; i++) { | 272 for (i = 0; i < 40; i++) { |
275 SDL_memset (screen->pixels + screen->pitch * i, 0x00, | 273 SDL_memset(screen->pixels + screen->pitch * i, 0x00, |
276 screen->pitch); | 274 screen->pitch); |
277 } | 275 } |
278 for (i = 440; i < 480; i++) { | 276 for (i = 440; i < 480; i++) { |
279 SDL_memset (screen->pixels + screen->pitch * i, 0x00, | 277 SDL_memset(screen->pixels + screen->pitch * i, 0x00, |
280 screen->pitch); | 278 screen->pitch); |
281 } | 279 } |
282 screen->pixels += screen->pitch * 40; | 280 screen->pixels += screen->pitch * 40; |
283 } | 281 } |
284 PgSwapDisplay (OCImage.offscreen_backcontext, 0); | 282 PgSwapDisplay(OCImage.offscreen_backcontext, 0); |
285 } else { | 283 } else { |
286 OCImage.current = 0; | 284 OCImage.current = 0; |
287 PhDCSetCurrent (OCImage.offscreen_context); | 285 PhDCSetCurrent(OCImage.offscreen_context); |
288 screen->pitch = OCImage.offscreen_context->pitch; | 286 screen->pitch = OCImage.offscreen_context->pitch; |
289 screen->pixels = OCImage.FrameData0; | 287 screen->pixels = OCImage.FrameData0; |
290 | 288 |
291 /* emulate 640x400 videomode */ | 289 /* emulate 640x400 videomode */ |
292 if (videomode_emulatemode == 1) { | 290 if (videomode_emulatemode == 1) { |
293 int i; | 291 int i; |
294 | 292 |
295 for (i = 0; i < 40; i++) { | 293 for (i = 0; i < 40; i++) { |
296 SDL_memset (screen->pixels + screen->pitch * i, 0x00, | 294 SDL_memset(screen->pixels + screen->pitch * i, 0x00, |
297 screen->pitch); | 295 screen->pitch); |
298 } | 296 } |
299 for (i = 440; i < 480; i++) { | 297 for (i = 440; i < 480; i++) { |
300 SDL_memset (screen->pixels + screen->pitch * i, 0x00, | 298 SDL_memset(screen->pixels + screen->pitch * i, 0x00, |
301 screen->pitch); | 299 screen->pitch); |
302 } | 300 } |
303 screen->pixels += screen->pitch * 40; | 301 screen->pixels += screen->pitch * 40; |
304 } | 302 } |
305 } | 303 } |
306 | 304 |
307 this->UpdateRects = ph_OCDCUpdate; | 305 this->UpdateRects = ph_OCDCUpdate; |
308 | 306 |
309 /* wait for the hardware */ | 307 /* wait for the hardware */ |
310 PgFlush (); | 308 PgFlush(); |
311 PgWaitHWIdle (); | 309 PgWaitHWIdle(); |
312 | 310 |
313 return 0; | 311 return 0; |
314 } | 312 } |
315 | 313 |
316 #if SDL_VIDEO_OPENGL | 314 #if SDL_VIDEO_OPENGL |
317 | 315 |
318 int | 316 int |
319 ph_SetupOpenGLImage (_THIS, SDL_Surface * screen) | 317 ph_SetupOpenGLImage(_THIS, SDL_Surface * screen) |
320 { | 318 { |
321 this->UpdateRects = ph_OpenGLUpdate; | 319 this->UpdateRects = ph_OpenGLUpdate; |
322 screen->pixels = NULL; | 320 screen->pixels = NULL; |
323 screen->pitch = NULL; | 321 screen->pitch = NULL; |
324 | 322 |
325 #if (_NTO_VERSION >= 630) | 323 #if (_NTO_VERSION >= 630) |
326 if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { | 324 if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
327 if (!ph_EnterFullScreen (this, screen, PH_IGNORE_DIRECTMODE)) { | 325 if (!ph_EnterFullScreen(this, screen, PH_IGNORE_DIRECTMODE)) { |
328 screen->flags &= ~SDL_FULLSCREEN; | 326 screen->flags &= ~SDL_FULLSCREEN; |
329 return -1; | 327 return -1; |
330 } | 328 } |
331 } | 329 } |
332 #endif /* 6.3.0 */ | 330 #endif /* 6.3.0 */ |
342 } | 340 } |
343 | 341 |
344 #endif /* SDL_VIDEO_OPENGL */ | 342 #endif /* SDL_VIDEO_OPENGL */ |
345 | 343 |
346 void | 344 void |
347 ph_DestroyImage (_THIS, SDL_Surface * screen) | 345 ph_DestroyImage(_THIS, SDL_Surface * screen) |
348 { | 346 { |
349 | 347 |
350 #if SDL_VIDEO_OPENGL | 348 #if SDL_VIDEO_OPENGL |
351 if (screen->flags & SDL_INTERNALOPENGL) { | 349 if (screen->flags & SDL_INTERNALOPENGL) { |
352 if (oglctx) { | 350 if (oglctx) { |
353 #if (_NTO_VERSION < 630) | 351 #if (_NTO_VERSION < 630) |
354 PhDCSetCurrent (NULL); | 352 PhDCSetCurrent(NULL); |
355 PhDCRelease (oglctx); | 353 PhDCRelease(oglctx); |
356 #else | 354 #else |
357 qnxgl_context_destroy (oglctx); | 355 qnxgl_context_destroy(oglctx); |
358 qnxgl_buffers_destroy (oglbuffers); | 356 qnxgl_buffers_destroy(oglbuffers); |
359 qnxgl_finish (); | 357 qnxgl_finish(); |
360 #endif /* 6.3.0 */ | 358 #endif /* 6.3.0 */ |
361 oglctx = NULL; | 359 oglctx = NULL; |
362 oglbuffers = NULL; | 360 oglbuffers = NULL; |
363 oglflags = 0; | 361 oglflags = 0; |
364 oglbpp = 0; | 362 oglbpp = 0; |
365 } | 363 } |
366 #if (_NTO_VERSION >= 630) | 364 #if (_NTO_VERSION >= 630) |
367 if (currently_fullscreen) { | 365 if (currently_fullscreen) { |
368 ph_LeaveFullScreen (this); | 366 ph_LeaveFullScreen(this); |
369 } | 367 } |
370 #endif /* 6.3.0 */ | 368 #endif /* 6.3.0 */ |
371 | 369 |
372 return; | 370 return; |
373 } | 371 } |
374 #endif /* SDL_VIDEO_OPENGL */ | 372 #endif /* SDL_VIDEO_OPENGL */ |
375 | 373 |
376 if (currently_fullscreen) { | 374 if (currently_fullscreen) { |
377 /* if we right now in 8bpp fullscreen we must release palette */ | 375 /* if we right now in 8bpp fullscreen we must release palette */ |
378 if ((screen->format->BitsPerPixel == 8) && (desktopbpp != 8)) { | 376 if ((screen->format->BitsPerPixel == 8) && (desktopbpp != 8)) { |
379 PgSetPalette (syspalph, 0, -1, 0, 0, 0); | 377 PgSetPalette(syspalph, 0, -1, 0, 0, 0); |
380 PgSetPalette (savedpal, 0, 0, _Pg_MAX_PALETTE, | 378 PgSetPalette(savedpal, 0, 0, _Pg_MAX_PALETTE, |
381 Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0); | 379 Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0); |
382 PgFlush (); | 380 PgFlush(); |
383 } | 381 } |
384 ph_LeaveFullScreen (this); | 382 ph_LeaveFullScreen(this); |
385 } | 383 } |
386 | 384 |
387 if (OCImage.offscreen_context != NULL) { | 385 if (OCImage.offscreen_context != NULL) { |
388 PhDCRelease (OCImage.offscreen_context); | 386 PhDCRelease(OCImage.offscreen_context); |
389 OCImage.offscreen_context = NULL; | 387 OCImage.offscreen_context = NULL; |
390 OCImage.FrameData0 = NULL; | 388 OCImage.FrameData0 = NULL; |
391 } | 389 } |
392 if (OCImage.offscreen_backcontext != NULL) { | 390 if (OCImage.offscreen_backcontext != NULL) { |
393 PhDCRelease (OCImage.offscreen_backcontext); | 391 PhDCRelease(OCImage.offscreen_backcontext); |
394 OCImage.offscreen_backcontext = NULL; | 392 OCImage.offscreen_backcontext = NULL; |
395 OCImage.FrameData1 = NULL; | 393 OCImage.FrameData1 = NULL; |
396 } | 394 } |
397 OCImage.CurrentFrameData = NULL; | 395 OCImage.CurrentFrameData = NULL; |
398 | 396 |
399 if (SDL_Image) { | 397 if (SDL_Image) { |
400 /* if palette allocated, free it */ | 398 /* if palette allocated, free it */ |
401 if (SDL_Image->palette) { | 399 if (SDL_Image->palette) { |
402 SDL_free (SDL_Image->palette); | 400 SDL_free(SDL_Image->palette); |
403 } | 401 } |
404 PgShmemDestroy (SDL_Image->image); | 402 PgShmemDestroy(SDL_Image->image); |
405 SDL_free (SDL_Image); | 403 SDL_free(SDL_Image); |
406 } | 404 } |
407 | 405 |
408 /* Must be zeroed everytime */ | 406 /* Must be zeroed everytime */ |
409 SDL_Image = NULL; | 407 SDL_Image = NULL; |
410 | 408 |
412 screen->pixels = NULL; | 410 screen->pixels = NULL; |
413 } | 411 } |
414 } | 412 } |
415 | 413 |
416 int | 414 int |
417 ph_UpdateHWInfo (_THIS) | 415 ph_UpdateHWInfo(_THIS) |
418 { | 416 { |
419 PgVideoModeInfo_t vmode; | 417 PgVideoModeInfo_t vmode; |
420 PgHWCaps_t hwcaps; | 418 PgHWCaps_t hwcaps; |
421 | 419 |
422 /* Update video ram amount */ | 420 /* Update video ram amount */ |
423 if (PgGetGraphicsHWCaps (&hwcaps) < 0) { | 421 if (PgGetGraphicsHWCaps(&hwcaps) < 0) { |
424 SDL_SetError | 422 SDL_SetError |
425 ("ph_UpdateHWInfo(): GetGraphicsHWCaps() function failed !\n"); | 423 ("ph_UpdateHWInfo(): GetGraphicsHWCaps() function failed !\n"); |
426 return -1; | 424 return -1; |
427 } | 425 } |
428 this->info.video_mem = hwcaps.currently_available_video_ram / 1024; | 426 this->info.video_mem = hwcaps.currently_available_video_ram / 1024; |
429 | 427 |
430 /* obtain current mode capabilities */ | 428 /* obtain current mode capabilities */ |
431 if (PgGetVideoModeInfo (hwcaps.current_video_mode, &vmode) < 0) { | 429 if (PgGetVideoModeInfo(hwcaps.current_video_mode, &vmode) < 0) { |
432 SDL_SetError | 430 SDL_SetError |
433 ("ph_UpdateHWInfo(): GetVideoModeInfo() function failed !\n"); | 431 ("ph_UpdateHWInfo(): GetVideoModeInfo() function failed !\n"); |
434 return -1; | 432 return -1; |
435 } | 433 } |
436 | 434 |
476 | 474 |
477 return 0; | 475 return 0; |
478 } | 476 } |
479 | 477 |
480 int | 478 int |
481 ph_SetupUpdateFunction (_THIS, SDL_Surface * screen, Uint32 flags) | 479 ph_SetupUpdateFunction(_THIS, SDL_Surface * screen, Uint32 flags) |
482 { | 480 { |
483 int setupresult = -1; | 481 int setupresult = -1; |
484 | 482 |
485 ph_DestroyImage (this, screen); | 483 ph_DestroyImage(this, screen); |
486 | 484 |
487 #if SDL_VIDEO_OPENGL | 485 #if SDL_VIDEO_OPENGL |
488 if (flags & SDL_INTERNALOPENGL) { | 486 if (flags & SDL_INTERNALOPENGL) { |
489 setupresult = ph_SetupOpenGLImage (this, screen); | 487 setupresult = ph_SetupOpenGLImage(this, screen); |
490 } else { | 488 } else { |
491 #endif | 489 #endif |
492 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { | 490 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
493 setupresult = ph_SetupFullScreenImage (this, screen); | 491 setupresult = ph_SetupFullScreenImage(this, screen); |
494 } else { | 492 } else { |
495 if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE) { | 493 if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE) { |
496 setupresult = ph_SetupOCImage (this, screen); | 494 setupresult = ph_SetupOCImage(this, screen); |
497 } else { | 495 } else { |
498 setupresult = ph_SetupImage (this, screen); | 496 setupresult = ph_SetupImage(this, screen); |
499 } | 497 } |
500 } | 498 } |
501 #if SDL_VIDEO_OPENGL | 499 #if SDL_VIDEO_OPENGL |
502 } | 500 } |
503 #endif | 501 #endif |
504 if (setupresult != -1) { | 502 if (setupresult != -1) { |
505 ph_UpdateHWInfo (this); | 503 ph_UpdateHWInfo(this); |
506 } | 504 } |
507 | 505 |
508 return setupresult; | 506 return setupresult; |
509 } | 507 } |
510 | 508 |
511 int | 509 int |
512 ph_AllocHWSurface (_THIS, SDL_Surface * surface) | 510 ph_AllocHWSurface(_THIS, SDL_Surface * surface) |
513 { | 511 { |
514 PgHWCaps_t hwcaps; | 512 PgHWCaps_t hwcaps; |
515 | 513 |
516 if (surface->hwdata != NULL) { | 514 if (surface->hwdata != NULL) { |
517 SDL_SetError ("ph_AllocHWSurface(): hwdata already exists!\n"); | 515 SDL_SetError("ph_AllocHWSurface(): hwdata already exists!\n"); |
518 return -1; | 516 return -1; |
519 } | 517 } |
520 surface->hwdata = SDL_malloc (sizeof (struct private_hwdata)); | 518 surface->hwdata = SDL_malloc(sizeof(struct private_hwdata)); |
521 SDL_memset (surface->hwdata, 0x00, sizeof (struct private_hwdata)); | 519 SDL_memset(surface->hwdata, 0x00, sizeof(struct private_hwdata)); |
522 surface->hwdata->offscreenctx = | 520 surface->hwdata->offscreenctx = |
523 PdCreateOffscreenContext (0, surface->w, surface->h, | 521 PdCreateOffscreenContext(0, surface->w, surface->h, |
524 Pg_OSC_MEM_PAGE_ALIGN); | 522 Pg_OSC_MEM_PAGE_ALIGN); |
525 if (surface->hwdata->offscreenctx == NULL) { | 523 if (surface->hwdata->offscreenctx == NULL) { |
526 SDL_SetError | 524 SDL_SetError |
527 ("ph_AllocHWSurface(): PdCreateOffscreenContext() function failed !\n"); | 525 ("ph_AllocHWSurface(): PdCreateOffscreenContext() function failed !\n"); |
528 return -1; | 526 return -1; |
529 } | 527 } |
530 surface->pixels = | 528 surface->pixels = PdGetOffscreenContextPtr(surface->hwdata->offscreenctx); |
531 PdGetOffscreenContextPtr (surface->hwdata->offscreenctx); | |
532 if (surface->pixels == NULL) { | 529 if (surface->pixels == NULL) { |
533 PhDCRelease (surface->hwdata->offscreenctx); | 530 PhDCRelease(surface->hwdata->offscreenctx); |
534 SDL_SetError | 531 SDL_SetError |
535 ("ph_AllocHWSurface(): PdGetOffscreenContextPtr() function failed !\n"); | 532 ("ph_AllocHWSurface(): PdGetOffscreenContextPtr() function failed !\n"); |
536 return -1; | 533 return -1; |
537 } | 534 } |
538 surface->pitch = surface->hwdata->offscreenctx->pitch; | 535 surface->pitch = surface->hwdata->offscreenctx->pitch; |
543 /* create simple offscreen lock */ | 540 /* create simple offscreen lock */ |
544 surface->hwdata->crlockparam.flags = 0; | 541 surface->hwdata->crlockparam.flags = 0; |
545 if (PdCreateOffscreenLock | 542 if (PdCreateOffscreenLock |
546 (surface->hwdata->offscreenctx, &surface->hwdata->crlockparam) != EOK) | 543 (surface->hwdata->offscreenctx, &surface->hwdata->crlockparam) != EOK) |
547 { | 544 { |
548 PhDCRelease (surface->hwdata->offscreenctx); | 545 PhDCRelease(surface->hwdata->offscreenctx); |
549 SDL_SetError ("ph_AllocHWSurface(): Can't create offscreen lock !\n"); | 546 SDL_SetError("ph_AllocHWSurface(): Can't create offscreen lock !\n"); |
550 return -1; | 547 return -1; |
551 } | 548 } |
552 #endif /* 0 */ | 549 #endif /* 0 */ |
553 | 550 |
554 /* Update video ram amount */ | 551 /* Update video ram amount */ |
555 if (PgGetGraphicsHWCaps (&hwcaps) < 0) { | 552 if (PgGetGraphicsHWCaps(&hwcaps) < 0) { |
556 PdDestroyOffscreenLock (surface->hwdata->offscreenctx); | 553 PdDestroyOffscreenLock(surface->hwdata->offscreenctx); |
557 PhDCRelease (surface->hwdata->offscreenctx); | 554 PhDCRelease(surface->hwdata->offscreenctx); |
558 SDL_SetError | 555 SDL_SetError |
559 ("ph_AllocHWSurface(): GetGraphicsHWCaps() function failed !\n"); | 556 ("ph_AllocHWSurface(): GetGraphicsHWCaps() function failed !\n"); |
560 return -1; | 557 return -1; |
561 } | 558 } |
562 this->info.video_mem = hwcaps.currently_available_video_ram / 1024; | 559 this->info.video_mem = hwcaps.currently_available_video_ram / 1024; |
563 | 560 |
564 return 0; | 561 return 0; |
565 } | 562 } |
566 | 563 |
567 void | 564 void |
568 ph_FreeHWSurface (_THIS, SDL_Surface * surface) | 565 ph_FreeHWSurface(_THIS, SDL_Surface * surface) |
569 { | 566 { |
570 PgHWCaps_t hwcaps; | 567 PgHWCaps_t hwcaps; |
571 | 568 |
572 if (surface->hwdata == NULL) { | 569 if (surface->hwdata == NULL) { |
573 SDL_SetError ("ph_FreeHWSurface(): no hwdata!\n"); | 570 SDL_SetError("ph_FreeHWSurface(): no hwdata!\n"); |
574 return; | 571 return; |
575 } | 572 } |
576 if (surface->hwdata->offscreenctx == NULL) { | 573 if (surface->hwdata->offscreenctx == NULL) { |
577 SDL_SetError | 574 SDL_SetError("ph_FreeHWSurface(): no offscreen context to delete!\n"); |
578 ("ph_FreeHWSurface(): no offscreen context to delete!\n"); | |
579 return; | 575 return; |
580 } | 576 } |
581 #if 0 /* FIXME */ | 577 #if 0 /* FIXME */ |
582 /* unlock the offscreen context if it has been locked before destroy it */ | 578 /* unlock the offscreen context if it has been locked before destroy it */ |
583 if (PdIsOffscreenLocked (surface->hwdata->offscreenctx) == Pg_OSC_LOCKED) { | 579 if (PdIsOffscreenLocked(surface->hwdata->offscreenctx) == Pg_OSC_LOCKED) { |
584 PdUnlockOffscreen (surface->hwdata->offscreenctx); | 580 PdUnlockOffscreen(surface->hwdata->offscreenctx); |
585 } | 581 } |
586 | 582 |
587 PdDestroyOffscreenLock (surface->hwdata->offscreenctx); | 583 PdDestroyOffscreenLock(surface->hwdata->offscreenctx); |
588 #endif /* 0 */ | 584 #endif /* 0 */ |
589 | 585 |
590 PhDCRelease (surface->hwdata->offscreenctx); | 586 PhDCRelease(surface->hwdata->offscreenctx); |
591 | 587 |
592 SDL_free (surface->hwdata); | 588 SDL_free(surface->hwdata); |
593 surface->hwdata = NULL; | 589 surface->hwdata = NULL; |
594 | 590 |
595 /* Update video ram amount */ | 591 /* Update video ram amount */ |
596 if (PgGetGraphicsHWCaps (&hwcaps) < 0) { | 592 if (PgGetGraphicsHWCaps(&hwcaps) < 0) { |
597 SDL_SetError | 593 SDL_SetError |
598 ("ph_FreeHWSurface(): GetGraphicsHWCaps() function failed !\n"); | 594 ("ph_FreeHWSurface(): GetGraphicsHWCaps() function failed !\n"); |
599 return; | 595 return; |
600 } | 596 } |
601 this->info.video_mem = hwcaps.currently_available_video_ram / 1024; | 597 this->info.video_mem = hwcaps.currently_available_video_ram / 1024; |
602 | 598 |
603 return; | 599 return; |
604 } | 600 } |
605 | 601 |
606 int | 602 int |
607 ph_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) | 603 ph_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) |
608 { | 604 { |
609 if ((src->hwdata == NULL) && (src != this->screen)) { | 605 if ((src->hwdata == NULL) && (src != this->screen)) { |
610 SDL_SetError | 606 SDL_SetError |
611 ("ph_CheckHWBlit(): Source surface haven't hardware specific data.\n"); | 607 ("ph_CheckHWBlit(): Source surface haven't hardware specific data.\n"); |
612 src->flags &= ~SDL_HWACCEL; | 608 src->flags &= ~SDL_HWACCEL; |
640 | 636 |
641 return 1; | 637 return 1; |
642 } | 638 } |
643 | 639 |
644 PgColor_t | 640 PgColor_t |
645 ph_ExpandColor (_THIS, SDL_Surface * surface, Uint32 color) | 641 ph_ExpandColor(_THIS, SDL_Surface * surface, Uint32 color) |
646 { | 642 { |
647 Uint32 truecolor; | 643 Uint32 truecolor; |
648 | 644 |
649 /* Photon API accepts true colors only during hw filling operations */ | 645 /* Photon API accepts true colors only during hw filling operations */ |
650 switch (surface->format->BitsPerPixel) { | 646 switch (surface->format->BitsPerPixel) { |
651 case 8: | 647 case 8: |
652 { | 648 { |
653 if ((surface->format->palette) | 649 if ((surface->format->palette) |
654 && (color <= surface->format->palette->ncolors)) { | 650 && (color <= surface->format->palette->ncolors)) { |
655 truecolor = | 651 truecolor = |
656 PgRGB (surface->format->palette->colors[color].r, | 652 PgRGB(surface->format->palette->colors[color].r, |
657 surface->format->palette->colors[color].g, | 653 surface->format->palette->colors[color].g, |
658 surface->format->palette->colors[color].b); | 654 surface->format->palette->colors[color].b); |
659 } else { | 655 } else { |
660 SDL_SetError | 656 SDL_SetError |
661 ("ph_ExpandColor(): Color out of range for the 8bpp mode !\n"); | 657 ("ph_ExpandColor(): Color out of range for the 8bpp mode !\n"); |
662 return 0xFFFFFFFFUL; | 658 return 0xFFFFFFFFUL; |
663 } | 659 } |
704 | 700 |
705 return truecolor; | 701 return truecolor; |
706 } | 702 } |
707 | 703 |
708 int | 704 int |
709 ph_FillHWRect (_THIS, SDL_Surface * surface, SDL_Rect * rect, Uint32 color) | 705 ph_FillHWRect(_THIS, SDL_Surface * surface, SDL_Rect * rect, Uint32 color) |
710 { | 706 { |
711 PgColor_t oldcolor; | 707 PgColor_t oldcolor; |
712 Uint32 truecolor; | 708 Uint32 truecolor; |
713 int ydisp = 0; | 709 int ydisp = 0; |
714 | 710 |
715 if (this->info.blit_fill != 1) { | 711 if (this->info.blit_fill != 1) { |
716 return -1; | 712 return -1; |
717 } | 713 } |
718 | 714 |
719 truecolor = ph_ExpandColor (this, surface, color); | 715 truecolor = ph_ExpandColor(this, surface, color); |
720 if (truecolor == 0xFFFFFFFFUL) { | 716 if (truecolor == 0xFFFFFFFFUL) { |
721 return -1; | 717 return -1; |
722 } | 718 } |
723 | 719 |
724 oldcolor = PgSetFillColor (truecolor); | 720 oldcolor = PgSetFillColor(truecolor); |
725 | 721 |
726 /* 640x400 videomode emulation */ | 722 /* 640x400 videomode emulation */ |
727 if (videomode_emulatemode == 1) { | 723 if (videomode_emulatemode == 1) { |
728 ydisp += 40; | 724 ydisp += 40; |
729 } | 725 } |
730 | 726 |
731 PgDrawIRect (rect->x, rect->y + ydisp, rect->w + rect->x - 1, | 727 PgDrawIRect(rect->x, rect->y + ydisp, rect->w + rect->x - 1, |
732 rect->h + rect->y + ydisp - 1, Pg_DRAW_FILL); | 728 rect->h + rect->y + ydisp - 1, Pg_DRAW_FILL); |
733 PgSetFillColor (oldcolor); | 729 PgSetFillColor(oldcolor); |
734 PgFlush (); | 730 PgFlush(); |
735 PgWaitHWIdle (); | 731 PgWaitHWIdle(); |
736 | 732 |
737 return 0; | 733 return 0; |
738 } | 734 } |
739 | 735 |
740 int | 736 int |
741 ph_FlipHWSurface (_THIS, SDL_Surface * screen) | 737 ph_FlipHWSurface(_THIS, SDL_Surface * screen) |
742 { | 738 { |
743 PhArea_t farea; | 739 PhArea_t farea; |
744 | 740 |
745 if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { | 741 if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
746 /* flush all drawing ops before blitting */ | 742 /* flush all drawing ops before blitting */ |
747 PgFlush (); | 743 PgFlush(); |
748 PgWaitHWIdle (); | 744 PgWaitHWIdle(); |
749 | 745 |
750 farea.pos.x = 0; | 746 farea.pos.x = 0; |
751 farea.pos.y = 0; | 747 farea.pos.y = 0; |
752 farea.size.w = screen->w; | 748 farea.size.w = screen->w; |
753 farea.size.h = screen->h; | 749 farea.size.h = screen->h; |
755 /* emulate 640x400 videomode */ | 751 /* emulate 640x400 videomode */ |
756 if (videomode_emulatemode == 1) { | 752 if (videomode_emulatemode == 1) { |
757 farea.pos.y += 40; | 753 farea.pos.y += 40; |
758 } | 754 } |
759 | 755 |
760 PgContextBlitArea (OCImage.offscreen_context, &farea, | 756 PgContextBlitArea(OCImage.offscreen_context, &farea, |
761 OCImage.offscreen_backcontext, &farea); | 757 OCImage.offscreen_backcontext, &farea); |
762 | 758 |
763 /* flush the blitting */ | 759 /* flush the blitting */ |
764 PgFlush (); | 760 PgFlush(); |
765 PgWaitHWIdle (); | 761 PgWaitHWIdle(); |
766 } | 762 } |
767 return 0; | 763 return 0; |
768 } | 764 } |
769 | 765 |
770 int | 766 int |
771 ph_LockHWSurface (_THIS, SDL_Surface * surface) | 767 ph_LockHWSurface(_THIS, SDL_Surface * surface) |
772 { | 768 { |
773 | 769 |
774 #if 0 /* FIXME */ | 770 #if 0 /* FIXME */ |
775 int lockresult; | 771 int lockresult; |
776 | 772 |
779 } | 775 } |
780 | 776 |
781 surface->hwdata->lockparam.flags = 0; | 777 surface->hwdata->lockparam.flags = 0; |
782 surface->hwdata->lockparam.time_out = NULL; | 778 surface->hwdata->lockparam.time_out = NULL; |
783 lockresult = | 779 lockresult = |
784 PdLockOffscreen (surface->hwdata->offscreenctx, | 780 PdLockOffscreen(surface->hwdata->offscreenctx, |
785 &surface->hwdata->lockparam); | 781 &surface->hwdata->lockparam); |
786 | 782 |
787 switch (lockresult) { | 783 switch (lockresult) { |
788 case EOK: | 784 case EOK: |
789 break; | 785 break; |
790 case Pg_OSC_LOCK_DEADLOCK: | 786 case Pg_OSC_LOCK_DEADLOCK: |
791 SDL_SetError ("ph_LockHWSurface(): Deadlock detected !\n"); | 787 SDL_SetError("ph_LockHWSurface(): Deadlock detected !\n"); |
792 return -1; | 788 return -1; |
793 case Pg_OSC_LOCK_INVALID: | 789 case Pg_OSC_LOCK_INVALID: |
794 SDL_SetError ("ph_LockHWSurface(): Lock invalid !\n"); | 790 SDL_SetError("ph_LockHWSurface(): Lock invalid !\n"); |
795 return -1; | 791 return -1; |
796 default: | 792 default: |
797 SDL_SetError ("ph_LockHWSurface(): Can't lock the surface !\n"); | 793 SDL_SetError("ph_LockHWSurface(): Can't lock the surface !\n"); |
798 return -1; | 794 return -1; |
799 } | 795 } |
800 #endif /* 0 */ | 796 #endif /* 0 */ |
801 | 797 |
802 return 0; | 798 return 0; |
803 } | 799 } |
804 | 800 |
805 void | 801 void |
806 ph_UnlockHWSurface (_THIS, SDL_Surface * surface) | 802 ph_UnlockHWSurface(_THIS, SDL_Surface * surface) |
807 { | 803 { |
808 | 804 |
809 #if 0 /* FIXME */ | 805 #if 0 /* FIXME */ |
810 int unlockresult; | 806 int unlockresult; |
811 | 807 |
812 if ((surface == NULL) || (surface->hwdata == NULL)) { | 808 if ((surface == NULL) || (surface->hwdata == NULL)) { |
813 return; | 809 return; |
814 } | 810 } |
815 | 811 |
816 if (PdIsOffscreenLocked (surface->hwdata->offscreenctx) == Pg_OSC_LOCKED) { | 812 if (PdIsOffscreenLocked(surface->hwdata->offscreenctx) == Pg_OSC_LOCKED) { |
817 unlockresult = PdUnlockOffscreen (surface->hwdata->offscreenctx); | 813 unlockresult = PdUnlockOffscreen(surface->hwdata->offscreenctx); |
818 } | 814 } |
819 #endif /* 0 */ | 815 #endif /* 0 */ |
820 | 816 |
821 return; | 817 return; |
822 } | 818 } |
823 | 819 |
824 int | 820 int |
825 ph_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, | 821 ph_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, |
826 SDL_Rect * dstrect) | 822 SDL_Rect * dstrect) |
827 { | 823 { |
828 SDL_VideoDevice *this = current_video; | 824 SDL_VideoDevice *this = current_video; |
829 PhArea_t srcarea; | 825 PhArea_t srcarea; |
830 PhArea_t dstarea; | 826 PhArea_t dstarea; |
831 int ydisp = 0; | 827 int ydisp = 0; |
846 dstarea.size.h = dstrect->h; | 842 dstarea.size.h = dstrect->h; |
847 | 843 |
848 if (((src == this->screen) || (src->hwdata != NULL)) | 844 if (((src == this->screen) || (src->hwdata != NULL)) |
849 && ((dst == this->screen) || (dst->hwdata != NULL))) { | 845 && ((dst == this->screen) || (dst->hwdata != NULL))) { |
850 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { | 846 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { |
851 ph_SetHWColorKey (this, src, src->format->colorkey); | 847 ph_SetHWColorKey(this, src, src->format->colorkey); |
852 PgChromaOn (); | 848 PgChromaOn(); |
853 } | 849 } |
854 | 850 |
855 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { | 851 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { |
856 ph_SetHWAlpha (this, src, src->format->alpha); | 852 ph_SetHWAlpha(this, src, src->format->alpha); |
857 PgAlphaOn (); | 853 PgAlphaOn(); |
858 } | 854 } |
859 | 855 |
860 if (dst == this->screen) { | 856 if (dst == this->screen) { |
861 if (src == this->screen) { | 857 if (src == this->screen) { |
862 /* blitting from main screen to main screen */ | 858 /* blitting from main screen to main screen */ |
863 dstarea.pos.y += ydisp; | 859 dstarea.pos.y += ydisp; |
864 srcarea.pos.y += ydisp; | 860 srcarea.pos.y += ydisp; |
865 PgContextBlitArea (OCImage.offscreen_context, &srcarea, | 861 PgContextBlitArea(OCImage.offscreen_context, &srcarea, |
866 OCImage.offscreen_context, &dstarea); | 862 OCImage.offscreen_context, &dstarea); |
867 } else { | 863 } else { |
868 /* blitting from offscreen to main screen */ | 864 /* blitting from offscreen to main screen */ |
869 dstarea.pos.y += ydisp; | 865 dstarea.pos.y += ydisp; |
870 PgContextBlitArea (src->hwdata->offscreenctx, &srcarea, | 866 PgContextBlitArea(src->hwdata->offscreenctx, &srcarea, |
871 OCImage.offscreen_context, &dstarea); | 867 OCImage.offscreen_context, &dstarea); |
872 } | 868 } |
873 } else { | 869 } else { |
874 if (src == this->screen) { | 870 if (src == this->screen) { |
875 /* blitting from main screen to offscreen */ | 871 /* blitting from main screen to offscreen */ |
876 srcarea.pos.y += ydisp; | 872 srcarea.pos.y += ydisp; |
877 PgContextBlitArea (OCImage.offscreen_context, &srcarea, | 873 PgContextBlitArea(OCImage.offscreen_context, &srcarea, |
878 dst->hwdata->offscreenctx, &dstarea); | 874 dst->hwdata->offscreenctx, &dstarea); |
879 } else { | 875 } else { |
880 /* blitting offscreen to offscreen */ | 876 /* blitting offscreen to offscreen */ |
881 PgContextBlitArea (src->hwdata->offscreenctx, &srcarea, | 877 PgContextBlitArea(src->hwdata->offscreenctx, &srcarea, |
882 dst->hwdata->offscreenctx, &dstarea); | 878 dst->hwdata->offscreenctx, &dstarea); |
883 } | 879 } |
884 } | 880 } |
885 | 881 |
886 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { | 882 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { |
887 PgAlphaOff (); | 883 PgAlphaOff(); |
888 } | 884 } |
889 | 885 |
890 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { | 886 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { |
891 PgChromaOff (); | 887 PgChromaOff(); |
892 } | 888 } |
893 } else { | 889 } else { |
894 SDL_SetError | 890 SDL_SetError |
895 ("ph_HWAccelBlit(): Source or target surface is not a hardware surface !\n"); | 891 ("ph_HWAccelBlit(): Source or target surface is not a hardware surface !\n"); |
896 return -1; | 892 return -1; |
897 } | 893 } |
898 | 894 |
899 PgFlush (); | 895 PgFlush(); |
900 PgWaitHWIdle (); | 896 PgWaitHWIdle(); |
901 | 897 |
902 return 0; | 898 return 0; |
903 } | 899 } |
904 | 900 |
905 int | 901 int |
906 ph_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key) | 902 ph_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) |
907 { | 903 { |
908 if (this->info.blit_hw_CC != 1) { | 904 if (this->info.blit_hw_CC != 1) { |
909 return -1; | 905 return -1; |
910 } | 906 } |
911 | 907 |
912 if (surface->hwdata != NULL) { | 908 if (surface->hwdata != NULL) { |
913 surface->hwdata->colorkey = ph_ExpandColor (this, surface, key); | 909 surface->hwdata->colorkey = ph_ExpandColor(this, surface, key); |
914 if (surface->hwdata->colorkey == 0xFFFFFFFFUL) { | 910 if (surface->hwdata->colorkey == 0xFFFFFFFFUL) { |
915 return -1; | 911 return -1; |
916 } | 912 } |
917 } | 913 } |
918 PgSetChroma (surface->hwdata->colorkey, | 914 PgSetChroma(surface->hwdata->colorkey, |
919 Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); | 915 Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); |
920 | 916 |
921 return 0; | 917 return 0; |
922 } | 918 } |
923 | 919 |
924 int | 920 int |
925 ph_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha) | 921 ph_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha) |
926 { | 922 { |
927 if (this->info.blit_hw_A != 1) { | 923 if (this->info.blit_hw_A != 1) { |
928 return -1; | 924 return -1; |
929 } | 925 } |
930 | 926 |
931 PgSetAlphaBlend (NULL, alpha); | 927 PgSetAlphaBlend(NULL, alpha); |
932 | 928 |
933 return 0; | 929 return 0; |
934 } | 930 } |
935 | 931 |
936 #if SDL_VIDEO_OPENGL | 932 #if SDL_VIDEO_OPENGL |
937 void | 933 void |
938 ph_OpenGLUpdate (_THIS, int numrects, SDL_Rect * rects) | 934 ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect * rects) |
939 { | 935 { |
940 this->GL_SwapBuffers (this); | 936 this->GL_SwapBuffers(this); |
941 | 937 |
942 return; | 938 return; |
943 } | 939 } |
944 #endif /* SDL_VIDEO_OPENGL */ | 940 #endif /* SDL_VIDEO_OPENGL */ |
945 | 941 |
946 void | 942 void |
947 ph_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) | 943 ph_NormalUpdate(_THIS, int numrects, SDL_Rect * rects) |
948 { | 944 { |
949 PhPoint_t ph_pos; | 945 PhPoint_t ph_pos; |
950 PhRect_t ph_rect; | 946 PhRect_t ph_rect; |
951 int i; | 947 int i; |
952 | 948 |
964 ph_rect.ul.x = rects[i].x; | 960 ph_rect.ul.x = rects[i].x; |
965 ph_rect.ul.y = rects[i].y; | 961 ph_rect.ul.y = rects[i].y; |
966 ph_rect.lr.x = rects[i].x + rects[i].w; | 962 ph_rect.lr.x = rects[i].x + rects[i].w; |
967 ph_rect.lr.y = rects[i].y + rects[i].h; | 963 ph_rect.lr.y = rects[i].y + rects[i].h; |
968 | 964 |
969 if (PgDrawPhImageRectmx (&ph_pos, SDL_Image, &ph_rect, 0) < 0) { | 965 if (PgDrawPhImageRectmx(&ph_pos, SDL_Image, &ph_rect, 0) < 0) { |
970 SDL_SetError ("ph_NormalUpdate(): PgDrawPhImageRectmx failed!\n"); | 966 SDL_SetError("ph_NormalUpdate(): PgDrawPhImageRectmx failed!\n"); |
971 return; | 967 return; |
972 } | 968 } |
973 } | 969 } |
974 | 970 |
975 if (PgFlush () < 0) { | 971 if (PgFlush() < 0) { |
976 SDL_SetError ("ph_NormalUpdate(): PgFlush() function failed!\n"); | 972 SDL_SetError("ph_NormalUpdate(): PgFlush() function failed!\n"); |
977 } | 973 } |
978 } | 974 } |
979 | 975 |
980 void | 976 void |
981 ph_OCUpdate (_THIS, int numrects, SDL_Rect * rects) | 977 ph_OCUpdate(_THIS, int numrects, SDL_Rect * rects) |
982 { | 978 { |
983 int i; | 979 int i; |
984 | 980 |
985 PhPoint_t zero = { 0, 0 }; | 981 PhPoint_t zero = { 0, 0 }; |
986 PhArea_t src_rect; | 982 PhArea_t src_rect; |
987 PhArea_t dest_rect; | 983 PhArea_t dest_rect; |
988 | 984 |
989 PgSetTranslation (&zero, 0); | 985 PgSetTranslation(&zero, 0); |
990 PgSetRegion (PtWidgetRid (window)); | 986 PgSetRegion(PtWidgetRid(window)); |
991 PgSetClipping (0, NULL); | 987 PgSetClipping(0, NULL); |
992 | 988 |
993 PgFlush (); | 989 PgFlush(); |
994 PgWaitHWIdle (); | 990 PgWaitHWIdle(); |
995 | 991 |
996 for (i = 0; i < numrects; ++i) { | 992 for (i = 0; i < numrects; ++i) { |
997 if (rects[i].w == 0) { /* Clipped? */ | 993 if (rects[i].w == 0) { /* Clipped? */ |
998 continue; | 994 continue; |
999 } | 995 } |
1010 src_rect.size.w = rects[i].w; | 1006 src_rect.size.w = rects[i].w; |
1011 src_rect.size.h = rects[i].h; | 1007 src_rect.size.h = rects[i].h; |
1012 dest_rect.size.w = rects[i].w; | 1008 dest_rect.size.w = rects[i].w; |
1013 dest_rect.size.h = rects[i].h; | 1009 dest_rect.size.h = rects[i].h; |
1014 | 1010 |
1015 PgContextBlitArea (OCImage.offscreen_context, &src_rect, NULL, | 1011 PgContextBlitArea(OCImage.offscreen_context, &src_rect, NULL, |
1016 &dest_rect); | 1012 &dest_rect); |
1017 } | 1013 } |
1018 | 1014 |
1019 if (PgFlush () < 0) { | 1015 if (PgFlush() < 0) { |
1020 SDL_SetError ("ph_OCUpdate(): PgFlush failed.\n"); | 1016 SDL_SetError("ph_OCUpdate(): PgFlush failed.\n"); |
1021 } | 1017 } |
1022 } | 1018 } |
1023 | 1019 |
1024 void | 1020 void |
1025 ph_OCDCUpdate (_THIS, int numrects, SDL_Rect * rects) | 1021 ph_OCDCUpdate(_THIS, int numrects, SDL_Rect * rects) |
1026 { | 1022 { |
1027 PgWaitHWIdle (); | 1023 PgWaitHWIdle(); |
1028 | 1024 |
1029 if (PgFlush () < 0) { | 1025 if (PgFlush() < 0) { |
1030 SDL_SetError ("ph_OCDCUpdate(): PgFlush failed.\n"); | 1026 SDL_SetError("ph_OCDCUpdate(): PgFlush failed.\n"); |
1031 } | 1027 } |
1032 } | 1028 } |
1033 | 1029 |
1034 /* vi: set ts=4 sw=4 expandtab: */ | 1030 /* vi: set ts=4 sw=4 expandtab: */ |