Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
1030 lines (876 loc) · 27.4 KB

SDL_ph_image.c

File metadata and controls

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