Mercurial > sdl-ios-xcode
comparison src/video/photon/SDL_ph_image.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | e49147870aac |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
30 #include "SDL_ph_video.h" | 30 #include "SDL_ph_video.h" |
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 ph_SetupImage(_THIS, SDL_Surface *screen) | 35 int |
36 { | 36 ph_SetupImage (_THIS, SDL_Surface * screen) |
37 PgColor_t* palette=NULL; | 37 { |
38 int type=0; | 38 PgColor_t *palette = NULL; |
39 int type = 0; | |
39 int bpp; | 40 int bpp; |
40 | 41 |
41 bpp=screen->format->BitsPerPixel; | 42 bpp = screen->format->BitsPerPixel; |
42 | 43 |
43 /* Determine image type */ | 44 /* Determine image type */ |
44 switch(bpp) | 45 switch (bpp) { |
45 { | 46 case 8: |
46 case 8:{ | 47 { |
47 type = Pg_IMAGE_PALETTE_BYTE; | 48 type = Pg_IMAGE_PALETTE_BYTE; |
48 } | 49 } |
49 break; | 50 break; |
50 case 15:{ | 51 case 15: |
51 type = Pg_IMAGE_DIRECT_555; | 52 { |
52 } | 53 type = Pg_IMAGE_DIRECT_555; |
53 break; | 54 } |
54 case 16:{ | 55 break; |
55 type = Pg_IMAGE_DIRECT_565; | 56 case 16: |
56 } | 57 { |
57 break; | 58 type = Pg_IMAGE_DIRECT_565; |
58 case 24:{ | 59 } |
60 break; | |
61 case 24: | |
62 { | |
59 type = Pg_IMAGE_DIRECT_888; | 63 type = Pg_IMAGE_DIRECT_888; |
60 } | 64 } |
61 break; | 65 break; |
62 case 32:{ | 66 case 32: |
67 { | |
63 type = Pg_IMAGE_DIRECT_8888; | 68 type = Pg_IMAGE_DIRECT_8888; |
64 } | 69 } |
65 break; | 70 break; |
66 default:{ | 71 default: |
67 SDL_SetError("ph_SetupImage(): unsupported bpp=%d !\n", bpp); | 72 { |
73 SDL_SetError ("ph_SetupImage(): unsupported bpp=%d !\n", bpp); | |
68 return -1; | 74 return -1; |
69 } | 75 } |
70 break; | 76 break; |
71 } | 77 } |
72 | 78 |
73 /* palette emulation code */ | 79 /* palette emulation code */ |
74 if ((bpp==8) && (desktoppal==SDLPH_PAL_EMULATE)) | 80 if ((bpp == 8) && (desktoppal == SDLPH_PAL_EMULATE)) { |
75 { | |
76 /* creating image palette */ | 81 /* creating image palette */ |
77 palette=SDL_malloc(_Pg_MAX_PALETTE*sizeof(PgColor_t)); | 82 palette = SDL_malloc (_Pg_MAX_PALETTE * sizeof (PgColor_t)); |
78 if (palette==NULL) | 83 if (palette == NULL) { |
79 { | 84 SDL_SetError |
80 SDL_SetError("ph_SetupImage(): can't allocate memory for palette !\n"); | 85 ("ph_SetupImage(): can't allocate memory for palette !\n"); |
81 return -1; | 86 return -1; |
82 } | 87 } |
83 PgGetPalette(palette); | 88 PgGetPalette (palette); |
84 | 89 |
85 /* using shared memory for speed (set last param to 1) */ | 90 /* using shared memory for speed (set last param to 1) */ |
86 if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, palette, _Pg_MAX_PALETTE, 1)) == NULL) | 91 if ((SDL_Image = |
87 { | 92 PhCreateImage (NULL, screen->w, screen->h, type, palette, |
88 SDL_SetError("ph_SetupImage(): PhCreateImage() failed for bpp=8 !\n"); | 93 _Pg_MAX_PALETTE, 1)) == NULL) { |
89 SDL_free(palette); | 94 SDL_SetError |
95 ("ph_SetupImage(): PhCreateImage() failed for bpp=8 !\n"); | |
96 SDL_free (palette); | |
90 return -1; | 97 return -1; |
91 } | 98 } |
92 } | 99 } else { |
93 else | |
94 { | |
95 /* using shared memory for speed (set last param to 1) */ | 100 /* using shared memory for speed (set last param to 1) */ |
96 if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, 1)) == NULL) | 101 if ((SDL_Image = |
97 { | 102 PhCreateImage (NULL, screen->w, screen->h, type, NULL, 0, |
98 SDL_SetError("ph_SetupImage(): PhCreateImage() failed for bpp=%d !\n", bpp); | 103 1)) == NULL) { |
104 SDL_SetError | |
105 ("ph_SetupImage(): PhCreateImage() failed for bpp=%d !\n", | |
106 bpp); | |
99 return -1; | 107 return -1; |
100 } | 108 } |
101 } | 109 } |
102 | 110 |
103 screen->pixels = SDL_Image->image; | 111 screen->pixels = SDL_Image->image; |
106 this->UpdateRects = ph_NormalUpdate; | 114 this->UpdateRects = ph_NormalUpdate; |
107 | 115 |
108 return 0; | 116 return 0; |
109 } | 117 } |
110 | 118 |
111 int ph_SetupOCImage(_THIS, SDL_Surface *screen) | 119 int |
120 ph_SetupOCImage (_THIS, SDL_Surface * screen) | |
112 { | 121 { |
113 int type = 0; | 122 int type = 0; |
114 int bpp; | 123 int bpp; |
115 | 124 |
116 OCImage.flags = screen->flags; | 125 OCImage.flags = screen->flags; |
117 | 126 |
118 bpp=screen->format->BitsPerPixel; | 127 bpp = screen->format->BitsPerPixel; |
119 | 128 |
120 /* Determine image type */ | 129 /* Determine image type */ |
121 switch(bpp) | 130 switch (bpp) { |
122 { | 131 case 8: |
123 case 8: { | 132 { |
124 type = Pg_IMAGE_PALETTE_BYTE; | 133 type = Pg_IMAGE_PALETTE_BYTE; |
125 } | 134 } |
126 break; | 135 break; |
127 case 15:{ | 136 case 15: |
128 type = Pg_IMAGE_DIRECT_555; | 137 { |
129 } | 138 type = Pg_IMAGE_DIRECT_555; |
130 break; | 139 } |
131 case 16:{ | 140 break; |
132 type = Pg_IMAGE_DIRECT_565; | 141 case 16: |
133 } | 142 { |
134 break; | 143 type = Pg_IMAGE_DIRECT_565; |
135 case 24:{ | 144 } |
136 type = Pg_IMAGE_DIRECT_888; | 145 break; |
137 } | 146 case 24: |
138 break; | 147 { |
139 case 32:{ | 148 type = Pg_IMAGE_DIRECT_888; |
140 type = Pg_IMAGE_DIRECT_8888; | 149 } |
141 } | 150 break; |
142 break; | 151 case 32: |
143 default:{ | 152 { |
144 SDL_SetError("ph_SetupOCImage(): unsupported bpp=%d !\n", bpp); | 153 type = Pg_IMAGE_DIRECT_8888; |
145 return -1; | 154 } |
146 } | 155 break; |
147 break; | 156 default: |
157 { | |
158 SDL_SetError ("ph_SetupOCImage(): unsupported bpp=%d !\n", bpp); | |
159 return -1; | |
160 } | |
161 break; | |
148 } | 162 } |
149 | 163 |
150 /* 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 */ |
151 OCImage.offscreen_context = PdCreateOffscreenContext(0, screen->w, screen->h, Pg_OSC_MEM_PAGE_ALIGN); | 165 OCImage.offscreen_context = |
152 | 166 PdCreateOffscreenContext (0, screen->w, screen->h, |
153 if (OCImage.offscreen_context == NULL) | 167 Pg_OSC_MEM_PAGE_ALIGN); |
154 { | 168 |
155 SDL_SetError("ph_SetupOCImage(): PdCreateOffscreenContext() function failed !\n"); | 169 if (OCImage.offscreen_context == NULL) { |
170 SDL_SetError | |
171 ("ph_SetupOCImage(): PdCreateOffscreenContext() function failed !\n"); | |
156 return -1; | 172 return -1; |
157 } | 173 } |
158 | 174 |
159 screen->pitch = OCImage.offscreen_context->pitch; | 175 screen->pitch = OCImage.offscreen_context->pitch; |
160 | 176 |
161 OCImage.dc_ptr = (unsigned char *)PdGetOffscreenContextPtr(OCImage.offscreen_context); | 177 OCImage.dc_ptr = |
162 | 178 (unsigned char *) PdGetOffscreenContextPtr (OCImage. |
163 if (OCImage.dc_ptr == NULL) | 179 offscreen_context); |
164 { | 180 |
165 SDL_SetError("ph_SetupOCImage(): PdGetOffscreenContextPtr function failed !\n"); | 181 if (OCImage.dc_ptr == NULL) { |
166 PhDCRelease(OCImage.offscreen_context); | 182 SDL_SetError |
183 ("ph_SetupOCImage(): PdGetOffscreenContextPtr function failed !\n"); | |
184 PhDCRelease (OCImage.offscreen_context); | |
167 return -1; | 185 return -1; |
168 } | 186 } |
169 | 187 |
170 OCImage.FrameData0 = OCImage.dc_ptr; | 188 OCImage.FrameData0 = OCImage.dc_ptr; |
171 OCImage.CurrentFrameData = OCImage.FrameData0; | 189 OCImage.CurrentFrameData = OCImage.FrameData0; |
172 OCImage.current = 0; | 190 OCImage.current = 0; |
173 | 191 |
174 PhDCSetCurrent(OCImage.offscreen_context); | 192 PhDCSetCurrent (OCImage.offscreen_context); |
175 | 193 |
176 screen->pixels = OCImage.CurrentFrameData; | 194 screen->pixels = OCImage.CurrentFrameData; |
177 | 195 |
178 this->UpdateRects = ph_OCUpdate; | 196 this->UpdateRects = ph_OCUpdate; |
179 | 197 |
180 return 0; | 198 return 0; |
181 } | 199 } |
182 | 200 |
183 int ph_SetupFullScreenImage(_THIS, SDL_Surface* screen) | 201 int |
202 ph_SetupFullScreenImage (_THIS, SDL_Surface * screen) | |
184 { | 203 { |
185 OCImage.flags = screen->flags; | 204 OCImage.flags = screen->flags; |
186 | 205 |
187 /* Begin direct and fullscreen mode */ | 206 /* Begin direct and fullscreen mode */ |
188 if (!ph_EnterFullScreen(this, screen, PH_ENTER_DIRECTMODE)) | 207 if (!ph_EnterFullScreen (this, screen, PH_ENTER_DIRECTMODE)) { |
189 { | |
190 return -1; | 208 return -1; |
191 } | 209 } |
192 | 210 |
193 /* store palette for fullscreen */ | 211 /* store palette for fullscreen */ |
194 if ((screen->format->BitsPerPixel==8) && (desktopbpp!=8)) | 212 if ((screen->format->BitsPerPixel == 8) && (desktopbpp != 8)) { |
195 { | 213 PgGetPalette (savedpal); |
196 PgGetPalette(savedpal); | 214 PgGetPalette (syspalph); |
197 PgGetPalette(syspalph); | 215 } |
198 } | 216 |
199 | 217 OCImage.offscreen_context = |
200 OCImage.offscreen_context = PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY | Pg_OSC_MEM_PAGE_ALIGN | Pg_OSC_CRTC_SAFE); | 218 PdCreateOffscreenContext (0, 0, 0, |
201 if (OCImage.offscreen_context == NULL) | 219 Pg_OSC_MAIN_DISPLAY | Pg_OSC_MEM_PAGE_ALIGN |
202 { | 220 | Pg_OSC_CRTC_SAFE); |
203 SDL_SetError("ph_SetupFullScreenImage(): PdCreateOffscreenContext() function failed !\n"); | 221 if (OCImage.offscreen_context == NULL) { |
204 return -1; | 222 SDL_SetError |
205 } | 223 ("ph_SetupFullScreenImage(): PdCreateOffscreenContext() function failed !\n"); |
206 | 224 return -1; |
207 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) | 225 } |
208 { | 226 |
209 OCImage.offscreen_backcontext = PdDupOffscreenContext(OCImage.offscreen_context, Pg_OSC_MEM_PAGE_ALIGN | Pg_OSC_CRTC_SAFE); | 227 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { |
210 if (OCImage.offscreen_backcontext == NULL) | 228 OCImage.offscreen_backcontext = |
211 { | 229 PdDupOffscreenContext (OCImage.offscreen_context, |
212 SDL_SetError("ph_SetupFullScreenImage(): PdCreateOffscreenContext(back) function failed !\n"); | 230 Pg_OSC_MEM_PAGE_ALIGN | Pg_OSC_CRTC_SAFE); |
231 if (OCImage.offscreen_backcontext == NULL) { | |
232 SDL_SetError | |
233 ("ph_SetupFullScreenImage(): PdCreateOffscreenContext(back) function failed !\n"); | |
213 return -1; | 234 return -1; |
214 } | 235 } |
215 } | 236 } |
216 | 237 |
217 OCImage.FrameData0 = (unsigned char *)PdGetOffscreenContextPtr(OCImage.offscreen_context); | 238 OCImage.FrameData0 = |
218 if (OCImage.FrameData0 == NULL) | 239 (unsigned char *) PdGetOffscreenContextPtr (OCImage. |
219 { | 240 offscreen_context); |
220 SDL_SetError("ph_SetupFullScreenImage(): PdGetOffscreenContextPtr() function failed !\n"); | 241 if (OCImage.FrameData0 == NULL) { |
221 ph_DestroyImage(this, screen); | 242 SDL_SetError |
222 return -1; | 243 ("ph_SetupFullScreenImage(): PdGetOffscreenContextPtr() function failed !\n"); |
223 } | 244 ph_DestroyImage (this, screen); |
224 | 245 return -1; |
225 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) | 246 } |
226 { | 247 |
227 OCImage.FrameData1 = (unsigned char *)PdGetOffscreenContextPtr(OCImage.offscreen_backcontext); | 248 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { |
228 if (OCImage.FrameData1 == NULL) | 249 OCImage.FrameData1 = |
229 { | 250 (unsigned char *) PdGetOffscreenContextPtr (OCImage. |
230 SDL_SetError("ph_SetupFullScreenImage(back): PdGetOffscreenContextPtr() function failed !\n"); | 251 offscreen_backcontext); |
231 ph_DestroyImage(this, screen); | 252 if (OCImage.FrameData1 == NULL) { |
253 SDL_SetError | |
254 ("ph_SetupFullScreenImage(back): PdGetOffscreenContextPtr() function failed !\n"); | |
255 ph_DestroyImage (this, screen); | |
232 return -1; | 256 return -1; |
233 } | 257 } |
234 } | 258 } |
235 | 259 |
236 /* wait for the hardware */ | 260 /* wait for the hardware */ |
237 PgFlush(); | 261 PgFlush (); |
238 PgWaitHWIdle(); | 262 PgWaitHWIdle (); |
239 | 263 |
240 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) | 264 if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { |
241 { | |
242 OCImage.current = 0; | 265 OCImage.current = 0; |
243 PhDCSetCurrent(OCImage.offscreen_context); | 266 PhDCSetCurrent (OCImage.offscreen_context); |
244 screen->pitch = OCImage.offscreen_context->pitch; | 267 screen->pitch = OCImage.offscreen_context->pitch; |
245 screen->pixels = OCImage.FrameData0; | 268 screen->pixels = OCImage.FrameData0; |
246 | 269 |
247 /* emulate 640x400 videomode */ | 270 /* emulate 640x400 videomode */ |
248 if (videomode_emulatemode==1) | 271 if (videomode_emulatemode == 1) { |
249 { | 272 int i; |
250 int i; | 273 |
251 | 274 for (i = 0; i < 40; i++) { |
252 for (i=0; i<40; i++) | 275 SDL_memset (screen->pixels + screen->pitch * i, 0x00, |
253 { | 276 screen->pitch); |
254 SDL_memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); | 277 } |
255 } | 278 for (i = 440; i < 480; i++) { |
256 for (i=440; i<480; i++) | 279 SDL_memset (screen->pixels + screen->pitch * i, 0x00, |
257 { | 280 screen->pitch); |
258 SDL_memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); | 281 } |
259 } | 282 screen->pixels += screen->pitch * 40; |
260 screen->pixels+=screen->pitch*40; | 283 } |
261 } | 284 PgSwapDisplay (OCImage.offscreen_backcontext, 0); |
262 PgSwapDisplay(OCImage.offscreen_backcontext, 0); | 285 } else { |
263 } | |
264 else | |
265 { | |
266 OCImage.current = 0; | 286 OCImage.current = 0; |
267 PhDCSetCurrent(OCImage.offscreen_context); | 287 PhDCSetCurrent (OCImage.offscreen_context); |
268 screen->pitch = OCImage.offscreen_context->pitch; | 288 screen->pitch = OCImage.offscreen_context->pitch; |
269 screen->pixels = OCImage.FrameData0; | 289 screen->pixels = OCImage.FrameData0; |
270 | 290 |
271 /* emulate 640x400 videomode */ | 291 /* emulate 640x400 videomode */ |
272 if (videomode_emulatemode==1) | 292 if (videomode_emulatemode == 1) { |
273 { | 293 int i; |
274 int i; | 294 |
275 | 295 for (i = 0; i < 40; i++) { |
276 for (i=0; i<40; i++) | 296 SDL_memset (screen->pixels + screen->pitch * i, 0x00, |
277 { | 297 screen->pitch); |
278 SDL_memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); | 298 } |
279 } | 299 for (i = 440; i < 480; i++) { |
280 for (i=440; i<480; i++) | 300 SDL_memset (screen->pixels + screen->pitch * i, 0x00, |
281 { | 301 screen->pitch); |
282 SDL_memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); | 302 } |
283 } | 303 screen->pixels += screen->pitch * 40; |
284 screen->pixels+=screen->pitch*40; | |
285 } | 304 } |
286 } | 305 } |
287 | 306 |
288 this->UpdateRects = ph_OCDCUpdate; | 307 this->UpdateRects = ph_OCDCUpdate; |
289 | 308 |
290 /* wait for the hardware */ | 309 /* wait for the hardware */ |
291 PgFlush(); | 310 PgFlush (); |
292 PgWaitHWIdle(); | 311 PgWaitHWIdle (); |
293 | 312 |
294 return 0; | 313 return 0; |
295 } | 314 } |
296 | 315 |
297 #if SDL_VIDEO_OPENGL | 316 #if SDL_VIDEO_OPENGL |
298 | 317 |
299 int ph_SetupOpenGLImage(_THIS, SDL_Surface* screen) | 318 int |
319 ph_SetupOpenGLImage (_THIS, SDL_Surface * screen) | |
300 { | 320 { |
301 this->UpdateRects = ph_OpenGLUpdate; | 321 this->UpdateRects = ph_OpenGLUpdate; |
302 screen->pixels=NULL; | 322 screen->pixels = NULL; |
303 screen->pitch=NULL; | 323 screen->pitch = NULL; |
304 | 324 |
305 #if (_NTO_VERSION >= 630) | 325 #if (_NTO_VERSION >= 630) |
306 if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) | 326 if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
307 { | 327 if (!ph_EnterFullScreen (this, screen, PH_IGNORE_DIRECTMODE)) { |
308 if (!ph_EnterFullScreen(this, screen, PH_IGNORE_DIRECTMODE)) | 328 screen->flags &= ~SDL_FULLSCREEN; |
309 { | 329 return -1; |
310 screen->flags &= ~SDL_FULLSCREEN; | 330 } |
311 return -1; | 331 } |
312 } | 332 #endif /* 6.3.0 */ |
313 } | 333 |
314 #endif /* 6.3.0 */ | 334 if (ph_SetupOpenGLContext |
315 | 335 (this, screen->w, screen->h, screen->format->BitsPerPixel, |
316 if (ph_SetupOpenGLContext(this, screen->w, screen->h, screen->format->BitsPerPixel, screen->flags)!=0) | 336 screen->flags) != 0) { |
317 { | |
318 screen->flags &= ~SDL_INTERNALOPENGL; | 337 screen->flags &= ~SDL_INTERNALOPENGL; |
319 return -1; | 338 return -1; |
320 } | 339 } |
321 | 340 |
322 return 0; | 341 return 0; |
323 } | 342 } |
324 | 343 |
325 #endif /* SDL_VIDEO_OPENGL */ | 344 #endif /* SDL_VIDEO_OPENGL */ |
326 | 345 |
327 void ph_DestroyImage(_THIS, SDL_Surface* screen) | 346 void |
347 ph_DestroyImage (_THIS, SDL_Surface * screen) | |
328 { | 348 { |
329 | 349 |
330 #if SDL_VIDEO_OPENGL | 350 #if SDL_VIDEO_OPENGL |
331 if (screen->flags & SDL_INTERNALOPENGL) | 351 if (screen->flags & SDL_INTERNALOPENGL) { |
332 { | 352 if (oglctx) { |
333 if (oglctx) | 353 #if (_NTO_VERSION < 630) |
334 { | 354 PhDCSetCurrent (NULL); |
335 #if (_NTO_VERSION < 630) | 355 PhDCRelease (oglctx); |
336 PhDCSetCurrent(NULL); | 356 #else |
337 PhDCRelease(oglctx); | 357 qnxgl_context_destroy (oglctx); |
338 #else | 358 qnxgl_buffers_destroy (oglbuffers); |
339 qnxgl_context_destroy(oglctx); | 359 qnxgl_finish (); |
340 qnxgl_buffers_destroy(oglbuffers); | 360 #endif /* 6.3.0 */ |
341 qnxgl_finish(); | 361 oglctx = NULL; |
342 #endif /* 6.3.0 */ | 362 oglbuffers = NULL; |
343 oglctx=NULL; | 363 oglflags = 0; |
344 oglbuffers=NULL; | 364 oglbpp = 0; |
345 oglflags=0; | 365 } |
346 oglbpp=0; | 366 #if (_NTO_VERSION >= 630) |
347 } | 367 if (currently_fullscreen) { |
348 | 368 ph_LeaveFullScreen (this); |
349 #if (_NTO_VERSION >= 630) | 369 } |
350 if (currently_fullscreen) | 370 #endif /* 6.3.0 */ |
351 { | |
352 ph_LeaveFullScreen(this); | |
353 } | |
354 #endif /* 6.3.0 */ | |
355 | 371 |
356 return; | 372 return; |
357 } | 373 } |
358 #endif /* SDL_VIDEO_OPENGL */ | 374 #endif /* SDL_VIDEO_OPENGL */ |
359 | 375 |
360 if (currently_fullscreen) | 376 if (currently_fullscreen) { |
361 { | |
362 /* if we right now in 8bpp fullscreen we must release palette */ | 377 /* if we right now in 8bpp fullscreen we must release palette */ |
363 if ((screen->format->BitsPerPixel==8) && (desktopbpp!=8)) | 378 if ((screen->format->BitsPerPixel == 8) && (desktopbpp != 8)) { |
364 { | 379 PgSetPalette (syspalph, 0, -1, 0, 0, 0); |
365 PgSetPalette(syspalph, 0, -1, 0, 0, 0); | 380 PgSetPalette (savedpal, 0, 0, _Pg_MAX_PALETTE, |
366 PgSetPalette(savedpal, 0, 0, _Pg_MAX_PALETTE, Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0); | 381 Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0); |
367 PgFlush(); | 382 PgFlush (); |
368 } | 383 } |
369 ph_LeaveFullScreen(this); | 384 ph_LeaveFullScreen (this); |
370 } | 385 } |
371 | 386 |
372 if (OCImage.offscreen_context != NULL) | 387 if (OCImage.offscreen_context != NULL) { |
373 { | 388 PhDCRelease (OCImage.offscreen_context); |
374 PhDCRelease(OCImage.offscreen_context); | |
375 OCImage.offscreen_context = NULL; | 389 OCImage.offscreen_context = NULL; |
376 OCImage.FrameData0 = NULL; | 390 OCImage.FrameData0 = NULL; |
377 } | 391 } |
378 if (OCImage.offscreen_backcontext != NULL) | 392 if (OCImage.offscreen_backcontext != NULL) { |
379 { | 393 PhDCRelease (OCImage.offscreen_backcontext); |
380 PhDCRelease(OCImage.offscreen_backcontext); | |
381 OCImage.offscreen_backcontext = NULL; | 394 OCImage.offscreen_backcontext = NULL; |
382 OCImage.FrameData1 = NULL; | 395 OCImage.FrameData1 = NULL; |
383 } | 396 } |
384 OCImage.CurrentFrameData = NULL; | 397 OCImage.CurrentFrameData = NULL; |
385 | 398 |
386 if (SDL_Image) | 399 if (SDL_Image) { |
387 { | |
388 /* if palette allocated, free it */ | 400 /* if palette allocated, free it */ |
389 if (SDL_Image->palette) | 401 if (SDL_Image->palette) { |
390 { | 402 SDL_free (SDL_Image->palette); |
391 SDL_free(SDL_Image->palette); | 403 } |
392 } | 404 PgShmemDestroy (SDL_Image->image); |
393 PgShmemDestroy(SDL_Image->image); | 405 SDL_free (SDL_Image); |
394 SDL_free(SDL_Image); | |
395 } | 406 } |
396 | 407 |
397 /* Must be zeroed everytime */ | 408 /* Must be zeroed everytime */ |
398 SDL_Image = NULL; | 409 SDL_Image = NULL; |
399 | 410 |
400 if (screen) | 411 if (screen) { |
401 { | |
402 screen->pixels = NULL; | 412 screen->pixels = NULL; |
403 } | 413 } |
404 } | 414 } |
405 | 415 |
406 int ph_UpdateHWInfo(_THIS) | 416 int |
417 ph_UpdateHWInfo (_THIS) | |
407 { | 418 { |
408 PgVideoModeInfo_t vmode; | 419 PgVideoModeInfo_t vmode; |
409 PgHWCaps_t hwcaps; | 420 PgHWCaps_t hwcaps; |
410 | 421 |
411 /* Update video ram amount */ | 422 /* Update video ram amount */ |
412 if (PgGetGraphicsHWCaps(&hwcaps) < 0) | 423 if (PgGetGraphicsHWCaps (&hwcaps) < 0) { |
424 SDL_SetError | |
425 ("ph_UpdateHWInfo(): GetGraphicsHWCaps() function failed !\n"); | |
426 return -1; | |
427 } | |
428 this->info.video_mem = hwcaps.currently_available_video_ram / 1024; | |
429 | |
430 /* obtain current mode capabilities */ | |
431 if (PgGetVideoModeInfo (hwcaps.current_video_mode, &vmode) < 0) { | |
432 SDL_SetError | |
433 ("ph_UpdateHWInfo(): GetVideoModeInfo() function failed !\n"); | |
434 return -1; | |
435 } | |
436 | |
437 if ((vmode.mode_capabilities1 & PgVM_MODE_CAP1_OFFSCREEN) == | |
438 PgVM_MODE_CAP1_OFFSCREEN) { | |
439 /* this is a special test for drivers which tries to lie about offscreen capability */ | |
440 if (hwcaps.currently_available_video_ram != 0) { | |
441 this->info.hw_available = 1; | |
442 } else { | |
443 this->info.hw_available = 0; | |
444 } | |
445 } else { | |
446 this->info.hw_available = 0; | |
447 } | |
448 | |
449 if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_RECTANGLE) == | |
450 PgVM_MODE_CAP2_RECTANGLE) { | |
451 this->info.blit_fill = 1; | |
452 } else { | |
453 this->info.blit_fill = 0; | |
454 } | |
455 | |
456 if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_BITBLT) == | |
457 PgVM_MODE_CAP2_BITBLT) { | |
458 this->info.blit_hw = 1; | |
459 } else { | |
460 this->info.blit_hw = 0; | |
461 } | |
462 | |
463 if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND) == | |
464 PgVM_MODE_CAP2_ALPHA_BLEND) { | |
465 this->info.blit_hw_A = 1; | |
466 } else { | |
467 this->info.blit_hw_A = 0; | |
468 } | |
469 | |
470 if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_CHROMA) == | |
471 PgVM_MODE_CAP2_CHROMA) { | |
472 this->info.blit_hw_CC = 1; | |
473 } else { | |
474 this->info.blit_hw_CC = 0; | |
475 } | |
476 | |
477 return 0; | |
478 } | |
479 | |
480 int | |
481 ph_SetupUpdateFunction (_THIS, SDL_Surface * screen, Uint32 flags) | |
482 { | |
483 int setupresult = -1; | |
484 | |
485 ph_DestroyImage (this, screen); | |
486 | |
487 #if SDL_VIDEO_OPENGL | |
488 if (flags & SDL_INTERNALOPENGL) { | |
489 setupresult = ph_SetupOpenGLImage (this, screen); | |
490 } else { | |
491 #endif | |
492 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { | |
493 setupresult = ph_SetupFullScreenImage (this, screen); | |
494 } else { | |
495 if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE) { | |
496 setupresult = ph_SetupOCImage (this, screen); | |
497 } else { | |
498 setupresult = ph_SetupImage (this, screen); | |
499 } | |
500 } | |
501 #if SDL_VIDEO_OPENGL | |
502 } | |
503 #endif | |
504 if (setupresult != -1) { | |
505 ph_UpdateHWInfo (this); | |
506 } | |
507 | |
508 return setupresult; | |
509 } | |
510 | |
511 int | |
512 ph_AllocHWSurface (_THIS, SDL_Surface * surface) | |
513 { | |
514 PgHWCaps_t hwcaps; | |
515 | |
516 if (surface->hwdata != NULL) { | |
517 SDL_SetError ("ph_AllocHWSurface(): hwdata already exists!\n"); | |
518 return -1; | |
519 } | |
520 surface->hwdata = SDL_malloc (sizeof (struct private_hwdata)); | |
521 SDL_memset (surface->hwdata, 0x00, sizeof (struct private_hwdata)); | |
522 surface->hwdata->offscreenctx = | |
523 PdCreateOffscreenContext (0, surface->w, surface->h, | |
524 Pg_OSC_MEM_PAGE_ALIGN); | |
525 if (surface->hwdata->offscreenctx == NULL) { | |
526 SDL_SetError | |
527 ("ph_AllocHWSurface(): PdCreateOffscreenContext() function failed !\n"); | |
528 return -1; | |
529 } | |
530 surface->pixels = | |
531 PdGetOffscreenContextPtr (surface->hwdata->offscreenctx); | |
532 if (surface->pixels == NULL) { | |
533 PhDCRelease (surface->hwdata->offscreenctx); | |
534 SDL_SetError | |
535 ("ph_AllocHWSurface(): PdGetOffscreenContextPtr() function failed !\n"); | |
536 return -1; | |
537 } | |
538 surface->pitch = surface->hwdata->offscreenctx->pitch; | |
539 surface->flags |= SDL_HWSURFACE; | |
540 surface->flags |= SDL_PREALLOC; | |
541 | |
542 #if 0 /* FIXME */ | |
543 /* create simple offscreen lock */ | |
544 surface->hwdata->crlockparam.flags = 0; | |
545 if (PdCreateOffscreenLock | |
546 (surface->hwdata->offscreenctx, &surface->hwdata->crlockparam) != EOK) | |
413 { | 547 { |
414 SDL_SetError("ph_UpdateHWInfo(): GetGraphicsHWCaps() function failed !\n"); | 548 PhDCRelease (surface->hwdata->offscreenctx); |
415 return -1; | 549 SDL_SetError ("ph_AllocHWSurface(): Can't create offscreen lock !\n"); |
416 } | 550 return -1; |
417 this->info.video_mem=hwcaps.currently_available_video_ram/1024; | 551 } |
418 | 552 #endif /* 0 */ |
419 /* obtain current mode capabilities */ | 553 |
420 if (PgGetVideoModeInfo(hwcaps.current_video_mode, &vmode) < 0) | 554 /* Update video ram amount */ |
421 { | 555 if (PgGetGraphicsHWCaps (&hwcaps) < 0) { |
422 SDL_SetError("ph_UpdateHWInfo(): GetVideoModeInfo() function failed !\n"); | 556 PdDestroyOffscreenLock (surface->hwdata->offscreenctx); |
423 return -1; | 557 PhDCRelease (surface->hwdata->offscreenctx); |
424 } | 558 SDL_SetError |
425 | 559 ("ph_AllocHWSurface(): GetGraphicsHWCaps() function failed !\n"); |
426 if ((vmode.mode_capabilities1 & PgVM_MODE_CAP1_OFFSCREEN) == PgVM_MODE_CAP1_OFFSCREEN) | 560 return -1; |
427 { | 561 } |
428 /* this is a special test for drivers which tries to lie about offscreen capability */ | 562 this->info.video_mem = hwcaps.currently_available_video_ram / 1024; |
429 if (hwcaps.currently_available_video_ram!=0) | 563 |
430 { | 564 return 0; |
431 this->info.hw_available = 1; | 565 } |
432 } | 566 |
433 else | 567 void |
434 { | 568 ph_FreeHWSurface (_THIS, SDL_Surface * surface) |
435 this->info.hw_available = 0; | |
436 } | |
437 } | |
438 else | |
439 { | |
440 this->info.hw_available = 0; | |
441 } | |
442 | |
443 if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_RECTANGLE) == PgVM_MODE_CAP2_RECTANGLE) | |
444 { | |
445 this->info.blit_fill = 1; | |
446 } | |
447 else | |
448 { | |
449 this->info.blit_fill = 0; | |
450 } | |
451 | |
452 if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_BITBLT) == PgVM_MODE_CAP2_BITBLT) | |
453 { | |
454 this->info.blit_hw = 1; | |
455 } | |
456 else | |
457 { | |
458 this->info.blit_hw = 0; | |
459 } | |
460 | |
461 if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND) == PgVM_MODE_CAP2_ALPHA_BLEND) | |
462 { | |
463 this->info.blit_hw_A = 1; | |
464 } | |
465 else | |
466 { | |
467 this->info.blit_hw_A = 0; | |
468 } | |
469 | |
470 if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_CHROMA) == PgVM_MODE_CAP2_CHROMA) | |
471 { | |
472 this->info.blit_hw_CC = 1; | |
473 } | |
474 else | |
475 { | |
476 this->info.blit_hw_CC = 0; | |
477 } | |
478 | |
479 return 0; | |
480 } | |
481 | |
482 int ph_SetupUpdateFunction(_THIS, SDL_Surface* screen, Uint32 flags) | |
483 { | |
484 int setupresult=-1; | |
485 | |
486 ph_DestroyImage(this, screen); | |
487 | |
488 #if SDL_VIDEO_OPENGL | |
489 if (flags & SDL_INTERNALOPENGL) | |
490 { | |
491 setupresult=ph_SetupOpenGLImage(this, screen); | |
492 } | |
493 else | |
494 { | |
495 #endif | |
496 if ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN) | |
497 { | |
498 setupresult=ph_SetupFullScreenImage(this, screen); | |
499 } | |
500 else | |
501 { | |
502 if ((flags & SDL_HWSURFACE)==SDL_HWSURFACE) | |
503 { | |
504 setupresult=ph_SetupOCImage(this, screen); | |
505 } | |
506 else | |
507 { | |
508 setupresult=ph_SetupImage(this, screen); | |
509 } | |
510 } | |
511 #if SDL_VIDEO_OPENGL | |
512 } | |
513 #endif | |
514 if (setupresult!=-1) | |
515 { | |
516 ph_UpdateHWInfo(this); | |
517 } | |
518 | |
519 return setupresult; | |
520 } | |
521 | |
522 int ph_AllocHWSurface(_THIS, SDL_Surface* surface) | |
523 { | 569 { |
524 PgHWCaps_t hwcaps; | 570 PgHWCaps_t hwcaps; |
525 | 571 |
526 if (surface->hwdata!=NULL) | 572 if (surface->hwdata == NULL) { |
527 { | 573 SDL_SetError ("ph_FreeHWSurface(): no hwdata!\n"); |
528 SDL_SetError("ph_AllocHWSurface(): hwdata already exists!\n"); | 574 return; |
529 return -1; | 575 } |
530 } | 576 if (surface->hwdata->offscreenctx == NULL) { |
531 surface->hwdata=SDL_malloc(sizeof(struct private_hwdata)); | 577 SDL_SetError |
532 SDL_memset(surface->hwdata, 0x00, sizeof(struct private_hwdata)); | 578 ("ph_FreeHWSurface(): no offscreen context to delete!\n"); |
533 surface->hwdata->offscreenctx=PdCreateOffscreenContext(0, surface->w, surface->h, Pg_OSC_MEM_PAGE_ALIGN); | 579 return; |
534 if (surface->hwdata->offscreenctx == NULL) | 580 } |
535 { | 581 #if 0 /* FIXME */ |
536 SDL_SetError("ph_AllocHWSurface(): PdCreateOffscreenContext() function failed !\n"); | 582 /* unlock the offscreen context if it has been locked before destroy it */ |
537 return -1; | 583 if (PdIsOffscreenLocked (surface->hwdata->offscreenctx) == Pg_OSC_LOCKED) { |
538 } | 584 PdUnlockOffscreen (surface->hwdata->offscreenctx); |
539 surface->pixels=PdGetOffscreenContextPtr(surface->hwdata->offscreenctx); | 585 } |
540 if (surface->pixels==NULL) | 586 |
541 { | 587 PdDestroyOffscreenLock (surface->hwdata->offscreenctx); |
542 PhDCRelease(surface->hwdata->offscreenctx); | |
543 SDL_SetError("ph_AllocHWSurface(): PdGetOffscreenContextPtr() function failed !\n"); | |
544 return -1; | |
545 } | |
546 surface->pitch=surface->hwdata->offscreenctx->pitch; | |
547 surface->flags|=SDL_HWSURFACE; | |
548 surface->flags|=SDL_PREALLOC; | |
549 | |
550 #if 0 /* FIXME */ | |
551 /* create simple offscreen lock */ | |
552 surface->hwdata->crlockparam.flags=0; | |
553 if (PdCreateOffscreenLock(surface->hwdata->offscreenctx, &surface->hwdata->crlockparam)!=EOK) | |
554 { | |
555 PhDCRelease(surface->hwdata->offscreenctx); | |
556 SDL_SetError("ph_AllocHWSurface(): Can't create offscreen lock !\n"); | |
557 return -1; | |
558 } | |
559 #endif /* 0 */ | 588 #endif /* 0 */ |
560 | 589 |
590 PhDCRelease (surface->hwdata->offscreenctx); | |
591 | |
592 SDL_free (surface->hwdata); | |
593 surface->hwdata = NULL; | |
594 | |
561 /* Update video ram amount */ | 595 /* Update video ram amount */ |
562 if (PgGetGraphicsHWCaps(&hwcaps) < 0) | 596 if (PgGetGraphicsHWCaps (&hwcaps) < 0) { |
563 { | 597 SDL_SetError |
564 PdDestroyOffscreenLock(surface->hwdata->offscreenctx); | 598 ("ph_FreeHWSurface(): GetGraphicsHWCaps() function failed !\n"); |
565 PhDCRelease(surface->hwdata->offscreenctx); | |
566 SDL_SetError("ph_AllocHWSurface(): GetGraphicsHWCaps() function failed !\n"); | |
567 return -1; | |
568 } | |
569 this->info.video_mem=hwcaps.currently_available_video_ram/1024; | |
570 | |
571 return 0; | |
572 } | |
573 | |
574 void ph_FreeHWSurface(_THIS, SDL_Surface* surface) | |
575 { | |
576 PgHWCaps_t hwcaps; | |
577 | |
578 if (surface->hwdata==NULL) | |
579 { | |
580 SDL_SetError("ph_FreeHWSurface(): no hwdata!\n"); | |
581 return; | |
582 } | |
583 if (surface->hwdata->offscreenctx == NULL) | |
584 { | |
585 SDL_SetError("ph_FreeHWSurface(): no offscreen context to delete!\n"); | |
586 return; | |
587 } | |
588 | |
589 #if 0 /* FIXME */ | |
590 /* unlock the offscreen context if it has been locked before destroy it */ | |
591 if (PdIsOffscreenLocked(surface->hwdata->offscreenctx)==Pg_OSC_LOCKED) | |
592 { | |
593 PdUnlockOffscreen(surface->hwdata->offscreenctx); | |
594 } | |
595 | |
596 PdDestroyOffscreenLock(surface->hwdata->offscreenctx); | |
597 #endif /* 0 */ | |
598 | |
599 PhDCRelease(surface->hwdata->offscreenctx); | |
600 | |
601 SDL_free(surface->hwdata); | |
602 surface->hwdata=NULL; | |
603 | |
604 /* Update video ram amount */ | |
605 if (PgGetGraphicsHWCaps(&hwcaps) < 0) | |
606 { | |
607 SDL_SetError("ph_FreeHWSurface(): GetGraphicsHWCaps() function failed !\n"); | |
608 return; | 599 return; |
609 } | 600 } |
610 this->info.video_mem=hwcaps.currently_available_video_ram/1024; | 601 this->info.video_mem = hwcaps.currently_available_video_ram / 1024; |
611 | 602 |
612 return; | 603 return; |
613 } | 604 } |
614 | 605 |
615 int ph_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst) | 606 int |
616 { | 607 ph_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) |
617 if ((src->hwdata==NULL) && (src != this->screen)) | 608 { |
618 { | 609 if ((src->hwdata == NULL) && (src != this->screen)) { |
619 SDL_SetError("ph_CheckHWBlit(): Source surface haven't hardware specific data.\n"); | 610 SDL_SetError |
620 src->flags&=~SDL_HWACCEL; | 611 ("ph_CheckHWBlit(): Source surface haven't hardware specific data.\n"); |
621 return -1; | 612 src->flags &= ~SDL_HWACCEL; |
622 } | 613 return -1; |
623 if ((src->flags & SDL_HWSURFACE) != SDL_HWSURFACE) | 614 } |
624 { | 615 if ((src->flags & SDL_HWSURFACE) != SDL_HWSURFACE) { |
625 SDL_SetError("ph_CheckHWBlit(): Source surface isn't a hardware surface.\n"); | 616 SDL_SetError |
626 src->flags&=~SDL_HWACCEL; | 617 ("ph_CheckHWBlit(): Source surface isn't a hardware surface.\n"); |
627 return -1; | 618 src->flags &= ~SDL_HWACCEL; |
628 } | 619 return -1; |
629 | 620 } |
630 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) | 621 |
631 { | 622 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { |
632 if (this->info.blit_hw_CC!=1) | 623 if (this->info.blit_hw_CC != 1) { |
633 { | 624 src->flags &= ~SDL_HWACCEL; |
634 src->flags&=~SDL_HWACCEL; | 625 src->map->hw_blit = NULL; |
635 src->map->hw_blit=NULL; | 626 return -1; |
636 return -1; | 627 } |
637 } | 628 } |
638 } | 629 |
639 | 630 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { |
640 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) | 631 if (this->info.blit_hw_A != 1) { |
641 { | 632 src->flags &= ~SDL_HWACCEL; |
642 if (this->info.blit_hw_A!=1) | 633 src->map->hw_blit = NULL; |
643 { | 634 return -1; |
644 src->flags&=~SDL_HWACCEL; | 635 } |
645 src->map->hw_blit=NULL; | 636 } |
646 return -1; | 637 |
647 } | 638 src->flags |= SDL_HWACCEL; |
648 } | 639 src->map->hw_blit = ph_HWAccelBlit; |
649 | 640 |
650 src->flags|=SDL_HWACCEL; | 641 return 1; |
651 src->map->hw_blit = ph_HWAccelBlit; | 642 } |
652 | 643 |
653 return 1; | 644 PgColor_t |
654 } | 645 ph_ExpandColor (_THIS, SDL_Surface * surface, Uint32 color) |
655 | |
656 PgColor_t ph_ExpandColor(_THIS, SDL_Surface* surface, Uint32 color) | |
657 { | 646 { |
658 Uint32 truecolor; | 647 Uint32 truecolor; |
659 | 648 |
660 /* Photon API accepts true colors only during hw filling operations */ | 649 /* Photon API accepts true colors only during hw filling operations */ |
661 switch(surface->format->BitsPerPixel) | 650 switch (surface->format->BitsPerPixel) { |
662 { | 651 case 8: |
663 case 8: | 652 { |
664 { | 653 if ((surface->format->palette) |
665 if ((surface->format->palette) && (color<=surface->format->palette->ncolors)) | 654 && (color <= surface->format->palette->ncolors)) { |
666 { | 655 truecolor = |
667 truecolor=PgRGB(surface->format->palette->colors[color].r, | 656 PgRGB (surface->format->palette->colors[color].r, |
668 surface->format->palette->colors[color].g, | 657 surface->format->palette->colors[color].g, |
669 surface->format->palette->colors[color].b); | 658 surface->format->palette->colors[color].b); |
670 } | 659 } else { |
671 else | 660 SDL_SetError |
672 { | 661 ("ph_ExpandColor(): Color out of range for the 8bpp mode !\n"); |
673 SDL_SetError("ph_ExpandColor(): Color out of range for the 8bpp mode !\n"); | |
674 return 0xFFFFFFFFUL; | |
675 } | |
676 } | |
677 break; | |
678 case 15: | |
679 { | |
680 truecolor = ((color & 0x00007C00UL) << 9) | /* R */ | |
681 ((color & 0x000003E0UL) << 6) | /* G */ | |
682 ((color & 0x0000001FUL) << 3) | /* B */ | |
683 ((color & 0x00007000UL) << 4) | /* R compensation */ | |
684 ((color & 0x00000380UL) << 1) | /* G compensation */ | |
685 ((color & 0x0000001CUL) >> 2); /* B compensation */ | |
686 } | |
687 break; | |
688 case 16: | |
689 { | |
690 truecolor = ((color & 0x0000F800UL) << 8) | /* R */ | |
691 ((color & 0x000007E0UL) << 5) | /* G */ | |
692 ((color & 0x0000001FUL) << 3) | /* B */ | |
693 ((color & 0x0000E000UL) << 3) | /* R compensation */ | |
694 ((color & 0x00000600UL) >> 1) | /* G compensation */ | |
695 ((color & 0x0000001CUL) >> 2); /* B compensation */ | |
696 | |
697 } | |
698 break; | |
699 case 24: | |
700 { | |
701 truecolor=color & 0x00FFFFFFUL; | |
702 } | |
703 break; | |
704 case 32: | |
705 { | |
706 truecolor=color; | |
707 } | |
708 break; | |
709 default: | |
710 { | |
711 SDL_SetError("ph_ExpandColor(): Unsupported depth for the hardware operations !\n"); | |
712 return 0xFFFFFFFFUL; | 662 return 0xFFFFFFFFUL; |
713 } | 663 } |
664 } | |
665 break; | |
666 case 15: | |
667 { | |
668 truecolor = ((color & 0x00007C00UL) << 9) | /* R */ | |
669 ((color & 0x000003E0UL) << 6) | /* G */ | |
670 ((color & 0x0000001FUL) << 3) | /* B */ | |
671 ((color & 0x00007000UL) << 4) | /* R compensation */ | |
672 ((color & 0x00000380UL) << 1) | /* G compensation */ | |
673 ((color & 0x0000001CUL) >> 2); /* B compensation */ | |
674 } | |
675 break; | |
676 case 16: | |
677 { | |
678 truecolor = ((color & 0x0000F800UL) << 8) | /* R */ | |
679 ((color & 0x000007E0UL) << 5) | /* G */ | |
680 ((color & 0x0000001FUL) << 3) | /* B */ | |
681 ((color & 0x0000E000UL) << 3) | /* R compensation */ | |
682 ((color & 0x00000600UL) >> 1) | /* G compensation */ | |
683 ((color & 0x0000001CUL) >> 2); /* B compensation */ | |
684 | |
685 } | |
686 break; | |
687 case 24: | |
688 { | |
689 truecolor = color & 0x00FFFFFFUL; | |
690 } | |
691 break; | |
692 case 32: | |
693 { | |
694 truecolor = color; | |
695 } | |
696 break; | |
697 default: | |
698 { | |
699 SDL_SetError | |
700 ("ph_ExpandColor(): Unsupported depth for the hardware operations !\n"); | |
701 return 0xFFFFFFFFUL; | |
702 } | |
714 } | 703 } |
715 | 704 |
716 return truecolor; | 705 return truecolor; |
717 } | 706 } |
718 | 707 |
719 int ph_FillHWRect(_THIS, SDL_Surface* surface, SDL_Rect* rect, Uint32 color) | 708 int |
709 ph_FillHWRect (_THIS, SDL_Surface * surface, SDL_Rect * rect, Uint32 color) | |
720 { | 710 { |
721 PgColor_t oldcolor; | 711 PgColor_t oldcolor; |
722 Uint32 truecolor; | 712 Uint32 truecolor; |
723 int ydisp=0; | 713 int ydisp = 0; |
724 | 714 |
725 if (this->info.blit_fill!=1) | 715 if (this->info.blit_fill != 1) { |
726 { | 716 return -1; |
727 return -1; | 717 } |
728 } | 718 |
729 | 719 truecolor = ph_ExpandColor (this, surface, color); |
730 truecolor=ph_ExpandColor(this, surface, color); | 720 if (truecolor == 0xFFFFFFFFUL) { |
731 if (truecolor==0xFFFFFFFFUL) | 721 return -1; |
732 { | 722 } |
733 return -1; | 723 |
734 } | 724 oldcolor = PgSetFillColor (truecolor); |
735 | |
736 oldcolor=PgSetFillColor(truecolor); | |
737 | 725 |
738 /* 640x400 videomode emulation */ | 726 /* 640x400 videomode emulation */ |
739 if (videomode_emulatemode==1) | 727 if (videomode_emulatemode == 1) { |
740 { | 728 ydisp += 40; |
741 ydisp+=40; | 729 } |
742 } | 730 |
743 | 731 PgDrawIRect (rect->x, rect->y + ydisp, rect->w + rect->x - 1, |
744 PgDrawIRect(rect->x, rect->y+ydisp, rect->w+rect->x-1, rect->h+rect->y+ydisp-1, Pg_DRAW_FILL); | 732 rect->h + rect->y + ydisp - 1, Pg_DRAW_FILL); |
745 PgSetFillColor(oldcolor); | 733 PgSetFillColor (oldcolor); |
746 PgFlush(); | 734 PgFlush (); |
747 PgWaitHWIdle(); | 735 PgWaitHWIdle (); |
748 | 736 |
749 return 0; | 737 return 0; |
750 } | 738 } |
751 | 739 |
752 int ph_FlipHWSurface(_THIS, SDL_Surface* screen) | 740 int |
741 ph_FlipHWSurface (_THIS, SDL_Surface * screen) | |
753 { | 742 { |
754 PhArea_t farea; | 743 PhArea_t farea; |
755 | 744 |
756 if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) | 745 if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
757 { | |
758 /* flush all drawing ops before blitting */ | 746 /* flush all drawing ops before blitting */ |
759 PgFlush(); | 747 PgFlush (); |
760 PgWaitHWIdle(); | 748 PgWaitHWIdle (); |
761 | 749 |
762 farea.pos.x=0; | 750 farea.pos.x = 0; |
763 farea.pos.y=0; | 751 farea.pos.y = 0; |
764 farea.size.w=screen->w; | 752 farea.size.w = screen->w; |
765 farea.size.h=screen->h; | 753 farea.size.h = screen->h; |
766 | 754 |
767 /* emulate 640x400 videomode */ | 755 /* emulate 640x400 videomode */ |
768 if (videomode_emulatemode==1) | 756 if (videomode_emulatemode == 1) { |
769 { | 757 farea.pos.y += 40; |
770 farea.pos.y+=40; | 758 } |
771 } | 759 |
772 | 760 PgContextBlitArea (OCImage.offscreen_context, &farea, |
773 PgContextBlitArea(OCImage.offscreen_context, &farea, OCImage.offscreen_backcontext, &farea); | 761 OCImage.offscreen_backcontext, &farea); |
774 | 762 |
775 /* flush the blitting */ | 763 /* flush the blitting */ |
776 PgFlush(); | 764 PgFlush (); |
777 PgWaitHWIdle(); | 765 PgWaitHWIdle (); |
778 } | 766 } |
779 return 0; | 767 return 0; |
780 } | 768 } |
781 | 769 |
782 int ph_LockHWSurface(_THIS, SDL_Surface* surface) | 770 int |
783 { | 771 ph_LockHWSurface (_THIS, SDL_Surface * surface) |
784 | 772 { |
785 #if 0 /* FIXME */ | 773 |
774 #if 0 /* FIXME */ | |
786 int lockresult; | 775 int lockresult; |
787 | 776 |
788 if (surface->hwdata == NULL) | 777 if (surface->hwdata == NULL) { |
789 { | |
790 return; | 778 return; |
791 } | 779 } |
792 | 780 |
793 surface->hwdata->lockparam.flags=0; | 781 surface->hwdata->lockparam.flags = 0; |
794 surface->hwdata->lockparam.time_out=NULL; | 782 surface->hwdata->lockparam.time_out = NULL; |
795 lockresult=PdLockOffscreen(surface->hwdata->offscreenctx, &surface->hwdata->lockparam); | 783 lockresult = |
796 | 784 PdLockOffscreen (surface->hwdata->offscreenctx, |
797 switch (lockresult) | 785 &surface->hwdata->lockparam); |
798 { | 786 |
799 case EOK: | 787 switch (lockresult) { |
800 break; | 788 case EOK: |
801 case Pg_OSC_LOCK_DEADLOCK: | 789 break; |
802 SDL_SetError("ph_LockHWSurface(): Deadlock detected !\n"); | 790 case Pg_OSC_LOCK_DEADLOCK: |
803 return -1; | 791 SDL_SetError ("ph_LockHWSurface(): Deadlock detected !\n"); |
804 case Pg_OSC_LOCK_INVALID: | 792 return -1; |
805 SDL_SetError("ph_LockHWSurface(): Lock invalid !\n"); | 793 case Pg_OSC_LOCK_INVALID: |
806 return -1; | 794 SDL_SetError ("ph_LockHWSurface(): Lock invalid !\n"); |
807 default: | 795 return -1; |
808 SDL_SetError("ph_LockHWSurface(): Can't lock the surface !\n"); | 796 default: |
809 return -1; | 797 SDL_SetError ("ph_LockHWSurface(): Can't lock the surface !\n"); |
798 return -1; | |
810 } | 799 } |
811 #endif /* 0 */ | 800 #endif /* 0 */ |
812 | 801 |
813 return 0; | 802 return 0; |
814 } | 803 } |
815 | 804 |
816 void ph_UnlockHWSurface(_THIS, SDL_Surface* surface) | 805 void |
817 { | 806 ph_UnlockHWSurface (_THIS, SDL_Surface * surface) |
818 | 807 { |
819 #if 0 /* FIXME */ | 808 |
809 #if 0 /* FIXME */ | |
820 int unlockresult; | 810 int unlockresult; |
821 | 811 |
822 if ((surface == NULL) || (surface->hwdata == NULL)) | 812 if ((surface == NULL) || (surface->hwdata == NULL)) { |
823 { | |
824 return; | 813 return; |
825 } | 814 } |
826 | 815 |
827 if (PdIsOffscreenLocked(surface->hwdata->offscreenctx)==Pg_OSC_LOCKED) | 816 if (PdIsOffscreenLocked (surface->hwdata->offscreenctx) == Pg_OSC_LOCKED) { |
828 { | 817 unlockresult = PdUnlockOffscreen (surface->hwdata->offscreenctx); |
829 unlockresult=PdUnlockOffscreen(surface->hwdata->offscreenctx); | |
830 } | 818 } |
831 #endif /* 0 */ | 819 #endif /* 0 */ |
832 | 820 |
833 return; | 821 return; |
834 } | 822 } |
835 | 823 |
836 int ph_HWAccelBlit(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect) | 824 int |
837 { | 825 ph_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, |
838 SDL_VideoDevice* this=current_video; | 826 SDL_Rect * dstrect) |
827 { | |
828 SDL_VideoDevice *this = current_video; | |
839 PhArea_t srcarea; | 829 PhArea_t srcarea; |
840 PhArea_t dstarea; | 830 PhArea_t dstarea; |
841 int ydisp=0; | 831 int ydisp = 0; |
842 | 832 |
843 /* 640x400 videomode emulation */ | 833 /* 640x400 videomode emulation */ |
844 if (videomode_emulatemode==1) | 834 if (videomode_emulatemode == 1) { |
845 { | 835 ydisp += 40; |
846 ydisp+=40; | 836 } |
847 } | 837 |
848 | 838 srcarea.pos.x = srcrect->x; |
849 srcarea.pos.x=srcrect->x; | 839 srcarea.pos.y = srcrect->y; |
850 srcarea.pos.y=srcrect->y; | 840 srcarea.size.w = srcrect->w; |
851 srcarea.size.w=srcrect->w; | 841 srcarea.size.h = srcrect->h; |
852 srcarea.size.h=srcrect->h; | 842 |
853 | 843 dstarea.pos.x = dstrect->x; |
854 dstarea.pos.x=dstrect->x; | 844 dstarea.pos.y = dstrect->y; |
855 dstarea.pos.y=dstrect->y; | 845 dstarea.size.w = dstrect->w; |
856 dstarea.size.w=dstrect->w; | 846 dstarea.size.h = dstrect->h; |
857 dstarea.size.h=dstrect->h; | 847 |
858 | 848 if (((src == this->screen) || (src->hwdata != NULL)) |
859 if (((src == this->screen) || (src->hwdata!=NULL)) && ((dst == this->screen) || (dst->hwdata!=NULL))) | 849 && ((dst == this->screen) || (dst->hwdata != NULL))) { |
860 { | 850 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { |
861 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) | 851 ph_SetHWColorKey (this, src, src->format->colorkey); |
862 { | 852 PgChromaOn (); |
863 ph_SetHWColorKey(this, src, src->format->colorkey); | 853 } |
864 PgChromaOn(); | 854 |
865 } | 855 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { |
866 | 856 ph_SetHWAlpha (this, src, src->format->alpha); |
867 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) | 857 PgAlphaOn (); |
868 { | 858 } |
869 ph_SetHWAlpha(this, src, src->format->alpha); | 859 |
870 PgAlphaOn(); | 860 if (dst == this->screen) { |
871 } | 861 if (src == this->screen) { |
872 | |
873 if (dst == this->screen) | |
874 { | |
875 if (src == this->screen) | |
876 { | |
877 /* blitting from main screen to main screen */ | 862 /* blitting from main screen to main screen */ |
878 dstarea.pos.y+=ydisp; | 863 dstarea.pos.y += ydisp; |
879 srcarea.pos.y+=ydisp; | 864 srcarea.pos.y += ydisp; |
880 PgContextBlitArea(OCImage.offscreen_context, &srcarea, OCImage.offscreen_context, &dstarea); | 865 PgContextBlitArea (OCImage.offscreen_context, &srcarea, |
866 OCImage.offscreen_context, &dstarea); | |
867 } else { | |
868 /* blitting from offscreen to main screen */ | |
869 dstarea.pos.y += ydisp; | |
870 PgContextBlitArea (src->hwdata->offscreenctx, &srcarea, | |
871 OCImage.offscreen_context, &dstarea); | |
881 } | 872 } |
882 else | 873 } else { |
883 { | 874 if (src == this->screen) { |
884 /* blitting from offscreen to main screen */ | 875 /* blitting from main screen to offscreen */ |
885 dstarea.pos.y+=ydisp; | 876 srcarea.pos.y += ydisp; |
886 PgContextBlitArea(src->hwdata->offscreenctx, &srcarea, OCImage.offscreen_context, &dstarea); | 877 PgContextBlitArea (OCImage.offscreen_context, &srcarea, |
878 dst->hwdata->offscreenctx, &dstarea); | |
879 } else { | |
880 /* blitting offscreen to offscreen */ | |
881 PgContextBlitArea (src->hwdata->offscreenctx, &srcarea, | |
882 dst->hwdata->offscreenctx, &dstarea); | |
887 } | 883 } |
888 } | 884 } |
889 else | 885 |
890 { | 886 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { |
891 if (src == this->screen) | 887 PgAlphaOff (); |
892 { | 888 } |
893 /* blitting from main screen to offscreen */ | 889 |
894 srcarea.pos.y+=ydisp; | 890 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { |
895 PgContextBlitArea(OCImage.offscreen_context, &srcarea, dst->hwdata->offscreenctx, &dstarea); | 891 PgChromaOff (); |
896 } | 892 } |
897 else | 893 } else { |
898 { | 894 SDL_SetError |
899 /* blitting offscreen to offscreen */ | 895 ("ph_HWAccelBlit(): Source or target surface is not a hardware surface !\n"); |
900 PgContextBlitArea(src->hwdata->offscreenctx, &srcarea, dst->hwdata->offscreenctx, &dstarea); | 896 return -1; |
901 } | 897 } |
902 } | 898 |
903 | 899 PgFlush (); |
904 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) | 900 PgWaitHWIdle (); |
905 { | 901 |
906 PgAlphaOff(); | 902 return 0; |
907 } | 903 } |
908 | 904 |
909 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) | 905 int |
910 { | 906 ph_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key) |
911 PgChromaOff(); | 907 { |
912 } | 908 if (this->info.blit_hw_CC != 1) { |
913 } | 909 return -1; |
914 else | 910 } |
915 { | 911 |
916 SDL_SetError("ph_HWAccelBlit(): Source or target surface is not a hardware surface !\n"); | 912 if (surface->hwdata != NULL) { |
917 return -1; | 913 surface->hwdata->colorkey = ph_ExpandColor (this, surface, key); |
918 } | 914 if (surface->hwdata->colorkey == 0xFFFFFFFFUL) { |
919 | |
920 PgFlush(); | |
921 PgWaitHWIdle(); | |
922 | |
923 return 0; | |
924 } | |
925 | |
926 int ph_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key) | |
927 { | |
928 if (this->info.blit_hw_CC!=1) | |
929 { | |
930 return -1; | |
931 } | |
932 | |
933 if (surface->hwdata!=NULL) | |
934 { | |
935 surface->hwdata->colorkey=ph_ExpandColor(this, surface, key); | |
936 if (surface->hwdata->colorkey==0xFFFFFFFFUL) | |
937 { | |
938 return -1; | 915 return -1; |
939 } | 916 } |
940 } | 917 } |
941 PgSetChroma(surface->hwdata->colorkey, Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); | 918 PgSetChroma (surface->hwdata->colorkey, |
942 | 919 Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); |
943 return 0; | 920 |
944 } | 921 return 0; |
945 | 922 } |
946 int ph_SetHWAlpha(_THIS, SDL_Surface* surface, Uint8 alpha) | 923 |
947 { | 924 int |
948 if (this->info.blit_hw_A!=1) | 925 ph_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha) |
949 { | 926 { |
950 return -1; | 927 if (this->info.blit_hw_A != 1) { |
951 } | 928 return -1; |
952 | 929 } |
953 PgSetAlphaBlend(NULL, alpha); | 930 |
931 PgSetAlphaBlend (NULL, alpha); | |
954 | 932 |
955 return 0; | 933 return 0; |
956 } | 934 } |
957 | 935 |
958 #if SDL_VIDEO_OPENGL | 936 #if SDL_VIDEO_OPENGL |
959 void ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect* rects) | 937 void |
960 { | 938 ph_OpenGLUpdate (_THIS, int numrects, SDL_Rect * rects) |
961 this->GL_SwapBuffers(this); | 939 { |
962 | 940 this->GL_SwapBuffers (this); |
963 return; | 941 |
942 return; | |
964 } | 943 } |
965 #endif /* SDL_VIDEO_OPENGL */ | 944 #endif /* SDL_VIDEO_OPENGL */ |
966 | 945 |
967 void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) | 946 void |
947 ph_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) | |
968 { | 948 { |
969 PhPoint_t ph_pos; | 949 PhPoint_t ph_pos; |
970 PhRect_t ph_rect; | 950 PhRect_t ph_rect; |
971 int i; | 951 int i; |
972 | 952 |
973 for (i=0; i<numrects; ++i) | 953 for (i = 0; i < numrects; ++i) { |
974 { | 954 if (rects[i].w == 0) { /* Clipped? dunno why but this occurs sometime. */ |
975 if (rects[i].w==0) /* Clipped? dunno why but this occurs sometime. */ | |
976 { | |
977 continue; | 955 continue; |
978 } | 956 } |
979 | 957 |
980 if (rects[i].h==0) /* Clipped? dunno why but this occurs sometime. */ | 958 if (rects[i].h == 0) { /* Clipped? dunno why but this occurs sometime. */ |
981 { | |
982 continue; | 959 continue; |
983 } | 960 } |
984 | 961 |
985 ph_pos.x = rects[i].x; | 962 ph_pos.x = rects[i].x; |
986 ph_pos.y = rects[i].y; | 963 ph_pos.y = rects[i].y; |
987 ph_rect.ul.x = rects[i].x; | 964 ph_rect.ul.x = rects[i].x; |
988 ph_rect.ul.y = rects[i].y; | 965 ph_rect.ul.y = rects[i].y; |
989 ph_rect.lr.x = rects[i].x + rects[i].w; | 966 ph_rect.lr.x = rects[i].x + rects[i].w; |
990 ph_rect.lr.y = rects[i].y + rects[i].h; | 967 ph_rect.lr.y = rects[i].y + rects[i].h; |
991 | 968 |
992 if (PgDrawPhImageRectmx(&ph_pos, SDL_Image, &ph_rect, 0) < 0) | 969 if (PgDrawPhImageRectmx (&ph_pos, SDL_Image, &ph_rect, 0) < 0) { |
993 { | 970 SDL_SetError ("ph_NormalUpdate(): PgDrawPhImageRectmx failed!\n"); |
994 SDL_SetError("ph_NormalUpdate(): PgDrawPhImageRectmx failed!\n"); | |
995 return; | 971 return; |
996 } | 972 } |
997 } | 973 } |
998 | 974 |
999 if (PgFlush() < 0) | 975 if (PgFlush () < 0) { |
1000 { | 976 SDL_SetError ("ph_NormalUpdate(): PgFlush() function failed!\n"); |
1001 SDL_SetError("ph_NormalUpdate(): PgFlush() function failed!\n"); | 977 } |
1002 } | 978 } |
1003 } | 979 |
1004 | 980 void |
1005 void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects) | 981 ph_OCUpdate (_THIS, int numrects, SDL_Rect * rects) |
1006 { | 982 { |
1007 int i; | 983 int i; |
1008 | 984 |
1009 PhPoint_t zero = {0, 0}; | 985 PhPoint_t zero = { 0, 0 }; |
1010 PhArea_t src_rect; | 986 PhArea_t src_rect; |
1011 PhArea_t dest_rect; | 987 PhArea_t dest_rect; |
1012 | 988 |
1013 PgSetTranslation(&zero, 0); | 989 PgSetTranslation (&zero, 0); |
1014 PgSetRegion(PtWidgetRid(window)); | 990 PgSetRegion (PtWidgetRid (window)); |
1015 PgSetClipping(0, NULL); | 991 PgSetClipping (0, NULL); |
1016 | 992 |
1017 PgFlush(); | 993 PgFlush (); |
1018 PgWaitHWIdle(); | 994 PgWaitHWIdle (); |
1019 | 995 |
1020 for (i=0; i<numrects; ++i) | 996 for (i = 0; i < numrects; ++i) { |
1021 { | 997 if (rects[i].w == 0) { /* Clipped? */ |
1022 if (rects[i].w == 0) /* Clipped? */ | |
1023 { | |
1024 continue; | 998 continue; |
1025 } | 999 } |
1026 | 1000 |
1027 if (rects[i].h == 0) /* Clipped? */ | 1001 if (rects[i].h == 0) { /* Clipped? */ |
1028 { | |
1029 continue; | 1002 continue; |
1030 } | 1003 } |
1031 | 1004 |
1032 src_rect.pos.x=rects[i].x; | 1005 src_rect.pos.x = rects[i].x; |
1033 src_rect.pos.y=rects[i].y; | 1006 src_rect.pos.y = rects[i].y; |
1034 dest_rect.pos.x=rects[i].x; | 1007 dest_rect.pos.x = rects[i].x; |
1035 dest_rect.pos.y=rects[i].y; | 1008 dest_rect.pos.y = rects[i].y; |
1036 | 1009 |
1037 src_rect.size.w=rects[i].w; | 1010 src_rect.size.w = rects[i].w; |
1038 src_rect.size.h=rects[i].h; | 1011 src_rect.size.h = rects[i].h; |
1039 dest_rect.size.w=rects[i].w; | 1012 dest_rect.size.w = rects[i].w; |
1040 dest_rect.size.h=rects[i].h; | 1013 dest_rect.size.h = rects[i].h; |
1041 | 1014 |
1042 PgContextBlitArea(OCImage.offscreen_context, &src_rect, NULL, &dest_rect); | 1015 PgContextBlitArea (OCImage.offscreen_context, &src_rect, NULL, |
1043 } | 1016 &dest_rect); |
1044 | 1017 } |
1045 if (PgFlush() < 0) | 1018 |
1046 { | 1019 if (PgFlush () < 0) { |
1047 SDL_SetError("ph_OCUpdate(): PgFlush failed.\n"); | 1020 SDL_SetError ("ph_OCUpdate(): PgFlush failed.\n"); |
1048 } | 1021 } |
1049 } | 1022 } |
1050 | 1023 |
1051 void ph_OCDCUpdate(_THIS, int numrects, SDL_Rect *rects) | 1024 void |
1052 { | 1025 ph_OCDCUpdate (_THIS, int numrects, SDL_Rect * rects) |
1053 PgWaitHWIdle(); | 1026 { |
1054 | 1027 PgWaitHWIdle (); |
1055 if (PgFlush() < 0) | 1028 |
1056 { | 1029 if (PgFlush () < 0) { |
1057 SDL_SetError("ph_OCDCUpdate(): PgFlush failed.\n"); | 1030 SDL_SetError ("ph_OCDCUpdate(): PgFlush failed.\n"); |
1058 } | 1031 } |
1059 } | 1032 } |
1033 | |
1034 /* vi: set ts=4 sw=4 expandtab: */ |