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

Latest commit

 

History

History
936 lines (807 loc) · 29.1 KB

SDL_cgximage.c

File metadata and controls

936 lines (807 loc) · 29.1 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
28
29
30
31
32
#include "SDL_endian.h"
#include "SDL_cgximage_c.h"
#ifdef HAVE_KSTAT
#include <kstat.h>
#endif
#ifdef USE_CGX_WRITELUTPIXEL
#if defined(__SASC) || defined(__PPC__)
May 28, 2006
May 28, 2006
33
#define WLUT WriteLUTPixelArray
Apr 26, 2001
Apr 26, 2001
34
#else
May 28, 2006
May 28, 2006
35
36
37
38
39
40
void
WLUT (APTR a, UWORD b, UWORD c, UWORD d, struct RastPort *e, APTR f, UWORD g,
UWORD h, UWORD i, UWORD l, UBYTE m)
{
WriteLUTPixelArray (a, b, c, d, e, f, g, h, i, l, m);
}
Apr 26, 2001
Apr 26, 2001
41
42
43
44
45
#endif
#endif
/* Various screen update functions available */
May 28, 2006
May 28, 2006
46
47
static void CGX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects);
static void CGX_FakeUpdate (_THIS, int numrects, SDL_Rect * rects);
Apr 26, 2001
Apr 26, 2001
48
May 28, 2006
May 28, 2006
49
50
51
52
BOOL SafeDisp = TRUE, SafeChange = TRUE;
struct MsgPort *safeport = NULL, *dispport = NULL;
ULONG safe_sigbit, disp_sigbit;
int use_picasso96 = 1;
Apr 26, 2001
Apr 26, 2001
53
May 28, 2006
May 28, 2006
54
55
int
CGX_SetupImage (_THIS, SDL_Surface * screen)
Apr 26, 2001
Apr 26, 2001
56
{
May 28, 2006
May 28, 2006
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
SDL_Ximage = NULL;
if (screen->flags & SDL_HWSURFACE) {
ULONG pitch;
if (!screen->hwdata) {
if (!
(screen->hwdata =
SDL_malloc (sizeof (struct private_hwdata))))
return -1;
D (bug ("Creating system accel struct\n"));
}
screen->hwdata->lock = NULL;
screen->hwdata->allocated = 0;
screen->hwdata->mask = NULL;
screen->hwdata->bmap = SDL_RastPort->BitMap;
screen->hwdata->videodata = this;
if (!(screen->hwdata->lock = LockBitMapTags (screen->hwdata->bmap,
LBMI_BASEADDRESS,
(ULONG) & screen->
pixels,
LBMI_BYTESPERROW,
(ULONG) & pitch,
TAG_DONE))) {
SDL_free (screen->hwdata);
screen->hwdata = NULL;
return -1;
} else {
UnLockBitMap (screen->hwdata->lock);
screen->hwdata->lock = NULL;
}
screen->pitch = pitch;
this->UpdateRects = CGX_FakeUpdate;
D (bug
("Accel video image configured (%lx, pitch %ld).\n",
screen->pixels, screen->pitch));
return 0;
}
screen->pixels = SDL_malloc (screen->h * screen->pitch);
if (screen->pixels == NULL) {
SDL_OutOfMemory ();
return (-1);
}
SDL_Ximage = screen->pixels;
if (SDL_Ximage == NULL) {
SDL_SetError ("Couldn't create XImage");
return (-1);
}
this->UpdateRects = CGX_NormalUpdate;
return (0);
Apr 26, 2001
Apr 26, 2001
118
119
}
May 28, 2006
May 28, 2006
120
121
void
CGX_DestroyImage (_THIS, SDL_Surface * screen)
Apr 26, 2001
Apr 26, 2001
122
{
May 28, 2006
May 28, 2006
123
124
125
126
127
128
129
130
131
132
133
134
if (SDL_Ximage) {
SDL_free (SDL_Ximage);
SDL_Ximage = NULL;
}
if (screen) {
screen->pixels = NULL;
if (screen->hwdata) {
SDL_free (screen->hwdata);
screen->hwdata = NULL;
}
}
Apr 26, 2001
Apr 26, 2001
135
136
}
May 10, 2001
May 10, 2001
137
/* This is a hack to see whether this system has more than 1 CPU */
May 28, 2006
May 28, 2006
138
139
static int
num_CPU (void)
May 10, 2001
May 10, 2001
140
{
May 28, 2006
May 28, 2006
141
return 1;
May 10, 2001
May 10, 2001
142
143
}
May 28, 2006
May 28, 2006
144
145
int
CGX_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags)
Apr 26, 2001
Apr 26, 2001
146
{
May 28, 2006
May 28, 2006
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
int retval;
D (bug ("Calling ResizeImage()\n"));
CGX_DestroyImage (this, screen);
if (flags & SDL_INTERNALOPENGL) { /* No image when using GL */
retval = 0;
} else {
retval = CGX_SetupImage (this, screen);
/* We support asynchronous blitting on the display */
if (flags & SDL_ASYNCBLIT) {
if (num_CPU () > 1) {
screen->flags |= SDL_ASYNCBLIT;
}
}
}
return (retval);
Apr 26, 2001
Apr 26, 2001
165
166
}
May 28, 2006
May 28, 2006
167
168
int
CGX_AllocHWSurface (_THIS, SDL_Surface * surface)
Apr 26, 2001
Apr 26, 2001
169
{
May 28, 2006
May 28, 2006
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
D (bug
("Alloc HW surface...%ld x %ld x %ld!\n", surface->w, surface->h,
this->hidden->depth));
if (surface == SDL_VideoSurface) {
D (bug ("Allocation skipped, it's system one!\n"));
return 0;
}
if (!surface->hwdata) {
if (!(surface->hwdata = SDL_malloc (sizeof (struct private_hwdata))))
return -1;
}
surface->hwdata->mask = NULL;
surface->hwdata->lock = NULL;
surface->hwdata->videodata = this;
surface->hwdata->allocated = 0;
if (surface->hwdata->bmap =
AllocBitMap (surface->w, surface->h, this->hidden->depth,
BMF_MINPLANES, SDL_Display->RastPort.BitMap)) {
surface->hwdata->allocated = 1;
surface->flags |= SDL_HWSURFACE;
D (bug ("...OK\n"));
return 0;
} else {
SDL_free (surface->hwdata);
surface->hwdata = NULL;
}
return (-1);
Apr 26, 2001
Apr 26, 2001
202
}
May 28, 2006
May 28, 2006
203
204
205
void
CGX_FreeHWSurface (_THIS, SDL_Surface * surface)
Apr 26, 2001
Apr 26, 2001
206
{
May 28, 2006
May 28, 2006
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
if (surface && surface != SDL_VideoSurface && surface->hwdata) {
D (bug ("Free hw surface.\n"));
if (surface->hwdata->mask)
SDL_free (surface->hwdata->mask);
if (surface->hwdata->bmap && surface->hwdata->allocated)
FreeBitMap (surface->hwdata->bmap);
SDL_free (surface->hwdata);
surface->hwdata = NULL;
surface->pixels = NULL;
D (bug ("end of free hw surface\n"));
}
return;
Apr 26, 2001
Apr 26, 2001
222
223
}
May 28, 2006
May 28, 2006
224
225
int
CGX_LockHWSurface (_THIS, SDL_Surface * surface)
Apr 26, 2001
Apr 26, 2001
226
{
May 28, 2006
May 28, 2006
227
228
229
230
231
232
233
234
235
236
237
238
if (surface->hwdata) {
// D(bug("Locking a bitmap...\n"));
if (!surface->hwdata->lock) {
Uint32 pitch;
if (!
(surface->hwdata->lock =
LockBitMapTags (surface->hwdata->bmap, LBMI_BASEADDRESS,
(ULONG) & surface->pixels,
LBMI_BYTESPERROW, (ULONG) & pitch,
TAG_DONE)))
return -1;
Apr 26, 2001
Apr 26, 2001
239
240
241
// surface->pitch e' a 16bit!
May 28, 2006
May 28, 2006
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
surface->pitch = pitch;
if (!currently_fullscreen && surface == SDL_VideoSurface)
surface->pixels =
((char *) surface->pixels) +
(surface->pitch *
(SDL_Window->BorderTop + SDL_Window->TopEdge) +
surface->format->BytesPerPixel *
(SDL_Window->BorderLeft + SDL_Window->LeftEdge));
}
D (
else
bug ("Already locked!!!\n"));
}
return (0);
Apr 26, 2001
Apr 26, 2001
257
}
Dec 16, 2001
Dec 16, 2001
258
May 28, 2006
May 28, 2006
259
260
void
CGX_UnlockHWSurface (_THIS, SDL_Surface * surface)
Apr 26, 2001
Apr 26, 2001
261
{
May 28, 2006
May 28, 2006
262
263
264
265
266
if (surface->hwdata && surface->hwdata->lock) {
UnLockBitMap (surface->hwdata->lock);
surface->hwdata->lock = NULL;
// surface->pixels=NULL;
}
Apr 26, 2001
Apr 26, 2001
267
268
}
May 28, 2006
May 28, 2006
269
270
int
CGX_FlipHWSurface (_THIS, SDL_Surface * surface)
Apr 26, 2001
Apr 26, 2001
271
{
May 28, 2006
May 28, 2006
272
static int current = 0;
Apr 26, 2001
Apr 26, 2001
273
May 28, 2006
May 28, 2006
274
275
276
if (this->hidden->dbuffer) {
if (!SafeChange) {
Wait (disp_sigbit);
Apr 26, 2001
Apr 26, 2001
277
// Non faccio nulla, vuoto solo la porta
May 28, 2006
May 28, 2006
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
while (GetMsg (dispport) != NULL);
SafeChange = TRUE;
}
if (ChangeScreenBuffer (SDL_Display, this->hidden->SB[current ^ 1])) {
surface->hwdata->bmap = SDL_RastPort->BitMap =
this->hidden->SB[current]->sb_BitMap;
SafeChange = FALSE;
SafeDisp = FALSE;
current ^= 1;
}
if (!SafeDisp) {
Wait (safe_sigbit);
while (GetMsg (safeport) != NULL);
SafeDisp = TRUE;
}
}
return (0);
Apr 26, 2001
Apr 26, 2001
298
299
300
}
/* Byte-swap the pixels in the display image */
May 28, 2006
May 28, 2006
301
302
static void
CGX_SwapAllPixels (SDL_Surface * screen)
Apr 26, 2001
Apr 26, 2001
303
{
May 28, 2006
May 28, 2006
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
int x, y;
switch (screen->format->BytesPerPixel) {
case 2:
{
Uint16 *spot;
for (y = 0; y < screen->h; ++y) {
spot = (Uint16 *) ((Uint8 *) screen->pixels +
y * screen->pitch);
for (x = 0; x < screen->w; ++x, ++spot) {
*spot = SDL_Swap16 (*spot);
}
}
}
break;
case 4:
{
Uint32 *spot;
for (y = 0; y < screen->h; ++y) {
spot = (Uint32 *) ((Uint8 *) screen->pixels +
y * screen->pitch);
for (x = 0; x < screen->w; ++x, ++spot) {
*spot = SDL_Swap32 (*spot);
}
}
}
break;
default:
/* should never get here */
break;
}
Apr 26, 2001
Apr 26, 2001
337
}
May 28, 2006
May 28, 2006
338
339
static void
CGX_SwapPixels (SDL_Surface * screen, int numrects, SDL_Rect * rects)
Apr 26, 2001
Apr 26, 2001
340
{
May 28, 2006
May 28, 2006
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
int i;
int x, minx, maxx;
int y, miny, maxy;
switch (screen->format->BytesPerPixel) {
case 2:
{
Uint16 *spot;
for (i = 0; i < numrects; ++i) {
minx = rects[i].x;
maxx = rects[i].x + rects[i].w;
miny = rects[i].y;
maxy = rects[i].y + rects[i].h;
for (y = miny; y < maxy; ++y) {
spot = (Uint16 *) ((Uint8 *) screen->pixels +
y * screen->pitch + minx * 2);
for (x = minx; x < maxx; ++x, ++spot) {
*spot = SDL_Swap16 (*spot);
}
}
}
}
break;
case 4:
{
Uint32 *spot;
for (i = 0; i < numrects; ++i) {
minx = rects[i].x;
maxx = rects[i].x + rects[i].w;
miny = rects[i].y;
maxy = rects[i].y + rects[i].h;
for (y = miny; y < maxy; ++y) {
spot = (Uint32 *) ((Uint8 *) screen->pixels +
y * screen->pitch + minx * 4);
for (x = minx; x < maxx; ++x, ++spot) {
*spot = SDL_Swap32 (*spot);
}
}
}
}
break;
default:
/* should never get here */
break;
}
Apr 26, 2001
Apr 26, 2001
388
389
390
391
392
393
394
}
#ifdef __SASC
#define USE_WPA WritePixelArray
#else
May 28, 2006
May 28, 2006
395
396
397
void
USE_WPA (char *a, int b, int c, int d, struct RastPort *e, int f, int g,
int h, int i, Uint32 l)
Apr 26, 2001
Apr 26, 2001
398
{
May 28, 2006
May 28, 2006
399
WritePixelArray (a, b, c, d, e, f, g, h, i, l);
Apr 26, 2001
Apr 26, 2001
400
401
402
403
}
#endif
May 28, 2006
May 28, 2006
404
405
static void
CGX_FakeUpdate (_THIS, int numrects, SDL_Rect * rects)
Apr 26, 2001
Apr 26, 2001
406
407
408
{
}
May 28, 2006
May 28, 2006
409
410
static void
CGX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects)
Apr 26, 2001
Apr 26, 2001
411
{
May 28, 2006
May 28, 2006
412
int i, format, customroutine = 0;
Apr 26, 2001
Apr 26, 2001
413
#ifndef USE_CGX_WRITELUTPIXEL
May 28, 2006
May 28, 2006
414
int bpp;
Apr 26, 2001
Apr 26, 2001
415
#endif
May 28, 2006
May 28, 2006
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
if (this->hidden->same_format && !use_picasso96) {
format = RECTFMT_RAW;
} else
switch (this->screen->format->BytesPerPixel) {
case 4:
format = RECTFMT_RGBA;
break;
case 3:
format = RECTFMT_RGB;
break;
case 2:
customroutine = 1;
break;
case 1:
// D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth));
if (this->hidden->depth > 8) {
Apr 26, 2001
Apr 26, 2001
432
#ifndef USE_CGX_WRITELUTPIXEL
May 28, 2006
May 28, 2006
433
434
435
436
437
438
439
if (this->hidden->depth > 32)
customroutine = 4;
else if (this->hidden->depth > 16) {
bpp = this->hidden->BytesPerPixel; // That one is the only one that needs bpp
customroutine = 2; // The slow one!
} else
customroutine = 3;
Apr 26, 2001
Apr 26, 2001
440
441
#else
May 28, 2006
May 28, 2006
442
customroutine = 2;
Apr 26, 2001
Apr 26, 2001
443
#endif
May 28, 2006
May 28, 2006
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
// format=RECTFMT_LUT8; Vecchia funzione x usare la WritePixelArray.
} else
customroutine = 1;
break;
default:
D (bug ("Unable to blit this surface!\n"));
return;
}
/* Check for endian-swapped X server, swap if necessary (VERY slow!) */
if (swap_pixels && ((this->screen->format->BytesPerPixel % 2) == 0)) {
D (bug ("Software Swapping! SLOOOW!\n"));
CGX_SwapPixels (this->screen, numrects, rects);
for (i = 0; i < numrects; ++i) {
if (!rects[i].w) { /* Clipped? */
continue;
}
USE_WPA (this->screen->pixels, rects[i].x, rects[i].y,
this->screen->pitch, SDL_RastPort,
SDL_Window->BorderLeft + rects[i].x,
SDL_Window->BorderTop + rects[i].y, rects[i].w,
rects[i].h, format);
}
CGX_SwapPixels (this->screen, numrects, rects);
} else if (customroutine == 2) {
Apr 26, 2001
Apr 26, 2001
470
#ifdef USE_CGX_WRITELUTPIXEL
May 28, 2006
May 28, 2006
471
472
473
474
475
476
477
478
479
480
481
for (i = 0; i < numrects; ++i) {
if (!rects[i].w) { /* Clipped? */
continue;
}
WLUT (this->screen->pixels, rects[i].x, rects[i].y,
this->screen->pitch, SDL_RastPort, SDL_XPixels,
SDL_Window->BorderLeft + rects[i].x,
SDL_Window->BorderTop + rects[i].y, rects[i].w,
rects[i].h, CTABFMT_XRGB8);
}
Apr 26, 2001
Apr 26, 2001
482
#else
May 28, 2006
May 28, 2006
483
484
485
486
487
488
489
490
491
492
493
494
495
unsigned char *bm_address;
Uint32 destpitch;
APTR handle;
if (handle =
LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS,
&bm_address, LBMI_BYTESPERROW, &destpitch,
TAG_DONE)) {
int srcwidth;
unsigned char *destbase;
register int j, k, t;
register unsigned char *mask, *dst;
register unsigned char *src, *dest;
Apr 26, 2001
Apr 26, 2001
496
497
// Aggiungo il bordo della finestra se sono fullscreen.
May 28, 2006
May 28, 2006
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
if (currently_fullscreen)
destbase = bm_address;
else
destbase =
bm_address + (SDL_Window->TopEdge +
SDL_Window->BorderTop) * destpitch +
(SDL_Window->BorderLeft +
SDL_Window->LeftEdge) * this->hidden->BytesPerPixel;
for (i = 0; i < numrects; ++i) {
srcwidth = rects[i].w;
if (!srcwidth) { /* Clipped? */
continue;
}
dest = destbase + rects[i].x * this->hidden->BytesPerPixel;
dest += (rects[i].y * destpitch);
src = ((char *) (this->screen->pixels)) + rects[i].x;
src += (rects[i].y * this->screen->pitch);
for (j = rects[i].h; j; --j) {
dst = dest;
Apr 26, 2001
Apr 26, 2001
521
// SLOW routine, used for 8->24 bit mapping
May 28, 2006
May 28, 2006
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
for (k = 0; k < srcwidth; k++) {
mask = (unsigned char *) (&SDL_XPixels[src[k]]);
for (t = 0; t < bpp; t++) {
dst[t] = mask[t];
}
dst += bpp;
}
src += this->screen->pitch;
dest += destpitch;
}
}
UnLockBitMap (handle);
}
} else if (customroutine == 3) {
unsigned char *bm_address;
Uint32 destpitch;
APTR handle;
if (handle =
LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS,
&bm_address, LBMI_BYTESPERROW, &destpitch,
TAG_DONE)) {
int srcwidth;
unsigned char *destbase;
register int j, k;
register unsigned char *src, *dest;
register Uint16 *destl, *srcl;
if (currently_fullscreen)
destbase = bm_address;
else
destbase =
bm_address + (SDL_Window->TopEdge +
SDL_Window->BorderTop) * destpitch +
(SDL_Window->BorderLeft +
SDL_Window->LeftEdge) * this->hidden->BytesPerPixel;
for (i = 0; i < numrects; ++i) {
srcwidth = rects[i].w;
if (!srcwidth) { /* Clipped? */
continue;
}
dest = destbase + rects[i].x * this->hidden->BytesPerPixel;
dest += (rects[i].y * destpitch);
src = ((char *) (this->screen->pixels)) + rects[i].x;
src += (rects[i].y * this->screen->pitch);
Apr 26, 2001
Apr 26, 2001
571
572
// This is the fast, well not too slow, remapping code for 16bit displays
May 28, 2006
May 28, 2006
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
for (j = rects[i].h; j; --j) {
destl = (Uint16 *) dest;
for (k = 0; k < srcwidth; k++) {
srcl = (Uint16 *) & SDL_XPixels[src[k]];
*destl = *srcl;
destl++;
}
src += this->screen->pitch;
dest += destpitch;
}
}
UnLockBitMap (handle);
}
} else if (customroutine == 4) {
unsigned char *bm_address;
Uint32 destpitch;
APTR handle;
if (handle =
LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS,
&bm_address, LBMI_BYTESPERROW, &destpitch,
TAG_DONE)) {
int srcwidth;
unsigned char *destbase;
register int j, k;
register unsigned char *src, *dest;
register Uint32 *destl, *srcl;
if (currently_fullscreen)
destbase = bm_address;
else
destbase =
bm_address + (SDL_Window->TopEdge +
SDL_Window->BorderTop) * destpitch +
(SDL_Window->BorderLeft +
SDL_Window->LeftEdge) * this->hidden->BytesPerPixel;
for (i = 0; i < numrects; ++i) {
srcwidth = rects[i].w;
if (!srcwidth) { /* Clipped? */
continue;
}
dest = destbase + rects[i].x * this->hidden->BytesPerPixel;
dest += (rects[i].y * destpitch);
src = ((char *) (this->screen->pixels)) + rects[i].x;
src += (rects[i].y * this->screen->pitch);
Apr 26, 2001
Apr 26, 2001
623
624
// This is the fast, well not too slow, remapping code for 32bit displays
May 28, 2006
May 28, 2006
625
626
627
628
629
630
631
632
633
634
635
636
637
638
for (j = rects[i].h; j; --j) {
destl = (Uint32 *) dest;
for (k = 0; k < srcwidth; k++) {
srcl = (Uint32 *) & SDL_XPixels[src[k]];
*destl = *srcl;
destl++;
}
src += this->screen->pitch;
dest += destpitch;
}
}
UnLockBitMap (handle);
}
Apr 26, 2001
Apr 26, 2001
639
#endif
May 28, 2006
May 28, 2006
640
641
642
643
644
645
646
647
648
649
650
651
652
653
} else if (customroutine) {
unsigned char *bm_address;
Uint32 destpitch;
APTR handle;
// D(bug("Using customroutine!\n"));
if (handle =
LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS,
(ULONG) & bm_address, LBMI_BYTESPERROW,
(ULONG) & destpitch, TAG_DONE)) {
unsigned char *destbase;
register int j, srcwidth;
register unsigned char *src, *dest;
Apr 26, 2001
Apr 26, 2001
654
655
// Aggiungo il bordo della finestra se sono fullscreen.
May 28, 2006
May 28, 2006
656
657
658
659
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
699
700
701
702
703
704
705
706
if (currently_fullscreen)
destbase = bm_address;
else
destbase =
bm_address + (SDL_Window->TopEdge +
SDL_Window->BorderTop) * destpitch +
(SDL_Window->BorderLeft +
SDL_Window->LeftEdge) *
this->screen->format->BytesPerPixel;
for (i = 0; i < numrects; ++i) {
srcwidth = rects[i].w;
if (!srcwidth) { /* Clipped? */
continue;
}
dest =
destbase +
rects[i].x * this->screen->format->BytesPerPixel;
dest += (rects[i].y * destpitch);
src =
((char *) (this->screen->pixels)) +
rects[i].x * this->screen->format->BytesPerPixel;
src += (rects[i].y * this->screen->pitch);
srcwidth *= this->screen->format->BytesPerPixel;
// D(bug("Rects: %ld,%ld %ld,%ld Src:%lx Dest:%lx\n",rects[i].x,rects[i].y,rects[i].w,rects[i].h,src,dest));
for (j = rects[i].h; j; --j) {
SDL_memcpy (dest, src, srcwidth);
src += this->screen->pitch;
dest += destpitch;
}
}
UnLockBitMap (handle);
// D(bug("Rectblit addr: %lx pitch: %ld rects:%ld srcptr: %lx srcpitch: %ld\n",bm_address,destpitch,numrects,this->screen->pixels,this->screen->pitch));
}
} else {
for (i = 0; i < numrects; ++i) {
if (!rects[i].w) { /* Clipped? */
continue;
}
USE_WPA (this->screen->pixels, rects[i].x, rects[i].y,
this->screen->pitch, SDL_RastPort,
SDL_Window->BorderLeft + rects[i].x,
SDL_Window->BorderTop + rects[i].y, rects[i].w,
rects[i].h, format);
}
}
Apr 26, 2001
Apr 26, 2001
707
708
}
May 28, 2006
May 28, 2006
709
710
void
CGX_RefreshDisplay (_THIS)
Apr 26, 2001
Apr 26, 2001
711
{
May 28, 2006
May 28, 2006
712
int format, customroutine = 0;
Apr 26, 2001
Apr 26, 2001
713
#ifndef USE_CGX_WRITELUTPIXEL
May 28, 2006
May 28, 2006
714
int bpp;
Apr 26, 2001
Apr 26, 2001
715
#endif
May 28, 2006
May 28, 2006
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
/* Don't refresh a display that doesn't have an image (like GL) */
if (!SDL_Ximage) {
return;
}
if (this->hidden->same_format && !use_picasso96) {
format = RECTFMT_RAW;
} else
switch (this->screen->format->BytesPerPixel) {
case 4:
format = RECTFMT_RGBA;
break;
case 3:
format = RECTFMT_RGB;
break;
case 2:
customroutine = 1;
break;
case 1:
// D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth));
if (this->hidden->depth > 8) {
Apr 26, 2001
Apr 26, 2001
737
#ifndef USE_CGX_WRITELUTPIXEL
May 28, 2006
May 28, 2006
738
739
740
741
742
743
744
if (this->hidden->depth > 32)
customroutine = 4;
else if (this->hidden->depth > 16) {
bpp = this->hidden->BytesPerPixel; // That one is the only one that needs bpp
customroutine = 2; // The slow one!
} else
customroutine = 3;
Apr 26, 2001
Apr 26, 2001
745
746
#else
May 28, 2006
May 28, 2006
747
customroutine = 2;
Apr 26, 2001
Apr 26, 2001
748
#endif
May 28, 2006
May 28, 2006
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
// format=RECTFMT_LUT8;
} else
customroutine = 1;
break;
}
/* Check for endian-swapped X server, swap if necessary */
if (swap_pixels && ((this->screen->format->BytesPerPixel % 2) == 0)) {
CGX_SwapAllPixels (this->screen);
USE_WPA (this->screen->pixels, 0, 0, this->screen->pitch,
SDL_RastPort, SDL_Window->BorderLeft,
SDL_Window->BorderTop, this->screen->w, this->screen->h,
format);
CGX_SwapAllPixels (this->screen);
} else if (customroutine == 2) {
Apr 26, 2001
Apr 26, 2001
765
#ifdef USE_CGX_WRITELUTPIXEL
May 28, 2006
May 28, 2006
766
767
768
769
WLUT (this->screen->pixels, 0, 0, this->screen->pitch,
SDL_RastPort, SDL_XPixels, SDL_Window->BorderLeft,
SDL_Window->BorderTop, this->screen->w, this->screen->h,
CTABFMT_XRGB8);
Apr 26, 2001
Apr 26, 2001
770
#else
May 28, 2006
May 28, 2006
771
772
773
774
775
776
777
778
779
780
781
unsigned char *bm_address;
Uint32 destpitch;
APTR handle;
if (handle =
LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS,
(ULONG) & bm_address, LBMI_BYTESPERROW,
(ULONG) & destpitch, TAG_DONE)) {
register int j, k, t;
register unsigned char *mask, *dst;
register unsigned char *src, *dest;
Apr 26, 2001
Apr 26, 2001
782
783
// Aggiungo il bordo della finestra se sono fullscreen.
May 28, 2006
May 28, 2006
784
785
786
787
788
789
790
791
792
793
794
795
796
if (!currently_fullscreen)
dest =
bm_address + (SDL_Window->TopEdge +
SDL_Window->BorderTop) * destpitch +
(SDL_Window->BorderLeft +
SDL_Window->LeftEdge) * this->hidden->BytesPerPixel;
else
dest = bm_address;
src = this->screen->pixels;
for (j = this->screen->h; j; --j) {
dst = dest;
Apr 26, 2001
Apr 26, 2001
797
// SLOW routine, used for 8->24 bit mapping
May 28, 2006
May 28, 2006
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
for (k = 0; k < this->screen->w; k++) {
mask = (unsigned char *) (&SDL_XPixels[src[k]]);
for (t = 0; t < bpp; t++) {
dst[t] = mask[t];
}
dst += bpp;
}
src += this->screen->pitch;
dest += destpitch;
}
UnLockBitMap (handle);
}
} else if (customroutine == 3) {
unsigned char *bm_address;
Uint32 destpitch;
APTR handle;
if (handle =
LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS,
(ULONG) & bm_address, LBMI_BYTESPERROW,
(ULONG) & destpitch, TAG_DONE)) {
register int j, k;
register unsigned char *src, *dest;
register Uint16 *destl, *srcl;
if (!currently_fullscreen)
dest =
bm_address + (SDL_Window->TopEdge +
SDL_Window->BorderTop) * destpitch +
(SDL_Window->BorderLeft +
SDL_Window->LeftEdge) * this->hidden->BytesPerPixel;
else
dest = bm_address;
src = this->screen->pixels;
Apr 26, 2001
Apr 26, 2001
834
835
// This is the fast, well not too slow, remapping code for 16bit displays
May 28, 2006
May 28, 2006
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
for (j = this->screen->h; j; --j) {
destl = (Uint16 *) dest;
for (k = 0; k < this->screen->w; k++) {
srcl = (Uint16 *) & SDL_XPixels[src[k]];
*destl = *srcl;
destl++;
}
src += this->screen->pitch;
dest += destpitch;
}
UnLockBitMap (handle);
}
} else if (customroutine == 4) {
unsigned char *bm_address;
Uint32 destpitch;
APTR handle;
if (handle =
LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS,
(ULONG) & bm_address, LBMI_BYTESPERROW,
(ULONG) & destpitch, TAG_DONE)) {
register int j, k;
register unsigned char *src, *dest;
register Uint32 *destl, *srcl;
if (!currently_fullscreen)
dest =
bm_address + (SDL_Window->TopEdge +
SDL_Window->BorderTop) * destpitch +
(SDL_Window->BorderLeft +
SDL_Window->LeftEdge) * this->hidden->BytesPerPixel;
else
dest = bm_address;
src = this->screen->pixels;
Apr 26, 2001
Apr 26, 2001
873
874
// This is the fast, well not too slow, remapping code for 32bit displays
May 28, 2006
May 28, 2006
875
876
877
878
879
880
881
882
883
884
885
886
887
for (j = this->screen->h; j; --j) {
destl = (Uint32 *) dest;
for (k = 0; k < this->screen->w; k++) {
srcl = (Uint32 *) & SDL_XPixels[src[k]];
*destl = *srcl;
destl++;
}
src += this->screen->pitch;
dest += destpitch;
}
UnLockBitMap (handle);
}
Apr 26, 2001
Apr 26, 2001
888
#endif
May 28, 2006
May 28, 2006
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
} else if (customroutine) {
unsigned char *bm_address;
Uint32 destpitch;
APTR handle;
if (handle = LockBitMapTags (SDL_RastPort->BitMap,
LBMI_BASEADDRESS, (ULONG) & bm_address,
LBMI_BYTESPERROW, (ULONG) & destpitch,
TAG_DONE)) {
register int j;
register unsigned char *src, *dest;
if (!currently_fullscreen)
dest =
bm_address + (SDL_Window->TopEdge +
SDL_Window->BorderTop) * destpitch +
(SDL_Window->BorderLeft +
SDL_Window->LeftEdge) *
this->screen->format->BytesPerPixel;
else
dest = bm_address;
src = this->screen->pixels;
// D(bug("addr: %lx pitch: %ld src:%lx srcpitch: %ld\n",dest,destpitch,this->screen->pixels,this->screen->pitch));
if (this->screen->pitch == destpitch) {
SDL_memcpy (dest, src, this->screen->pitch * this->screen->h);
} else {
for (j = this->screen->h; j; --j) {
SDL_memcpy (dest, src, this->screen->pitch);
src += this->screen->pitch;
dest += destpitch;
}
}
UnLockBitMap (handle);
}
} else {
USE_WPA (this->screen->pixels, 0, 0, this->screen->pitch,
SDL_RastPort, SDL_Window->BorderLeft,
SDL_Window->BorderTop, this->screen->w, this->screen->h,
format);
}
Apr 26, 2001
Apr 26, 2001
933
934
}
May 28, 2006
May 28, 2006
935
936
/* vi: set ts=4 sw=4 expandtab: */