comparison src/video/cybergfx/SDL_cgximage.c @ 21:75a95f82bc1f

Updated the Amiga OS port of SDL (thanks Gabriele)
author Sam Lantinga <slouken@lokigames.com>
date Thu, 10 May 2001 20:13:29 +0000
parents 74212992fb08
children e8157fcb3114
comparison
equal deleted inserted replaced
20:3dc008dc229d 21:75a95f82bc1f
55 55
56 int CGX_SetupImage(_THIS, SDL_Surface *screen) 56 int CGX_SetupImage(_THIS, SDL_Surface *screen)
57 { 57 {
58 if(screen->flags&SDL_HWSURFACE) 58 if(screen->flags&SDL_HWSURFACE)
59 { 59 {
60 Uint32 pitch;
60 SDL_Ximage=NULL; 61 SDL_Ximage=NULL;
61 62
62 if(!screen->hwdata) 63 if(!screen->hwdata)
63 { 64 {
64 if(!(screen->hwdata=malloc(sizeof(struct private_hwdata)))) 65 if(!(screen->hwdata=malloc(sizeof(struct private_hwdata))))
65 { 66 {
66 return -1; 67 return -1;
67 } 68 }
68 D(bug("Creating system accel struct\n")); 69 D(bug("Creating system accel struct\n"));
69 screen->hwdata->lock=0; 70 }
70 screen->hwdata->bmap=SDL_RastPort->BitMap; 71 screen->hwdata->lock=0;
71 screen->hwdata->videodata=this; 72 screen->hwdata->bmap=SDL_RastPort->BitMap;
72 } 73 screen->hwdata->videodata=this;
74
75 if(!(screen->hwdata->lock=LockBitMapTags(screen->hwdata->bmap,
76 LBMI_BASEADDRESS,(ULONG)&screen->pixels,
77 LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE)))
78 {
79 free(screen->hwdata);
80 screen->hwdata=NULL;
81 return -1;
82 }
83 else
84 {
85 UnLockBitMap(screen->hwdata->lock);
86 screen->hwdata->lock=NULL;
87 }
88
89 screen->pitch=pitch;
73 90
74 this->UpdateRects = CGX_FakeUpdate; 91 this->UpdateRects = CGX_FakeUpdate;
75 92
76 D(bug("Accel video image configured.\n")); 93 D(bug("Accel video image configured (%lx, pitch %ld).\n",screen->pixels,screen->pitch));
77 return 0; 94 return 0;
78 } 95 }
79 96
80 screen->pixels = malloc(screen->h*screen->pitch); 97 screen->pixels = malloc(screen->h*screen->pitch);
81 98
82 if ( screen->pixels == NULL ) { 99 if ( screen->pixels == NULL ) {
83 SDL_OutOfMemory(); 100 SDL_OutOfMemory();
84 return(-1); 101 return(-1);
85 } 102 }
103
104 /*
105 {
106 int bpp = screen->format->BytesPerPixel;
107 SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual,
108 this->hidden->depth, ZPixmap, 0,
109 (char *)screen->pixels,
110 screen->w, screen->h,
111 (bpp == 3) ? 32 : bpp * 8,
112 0);
113 }
114 */
86 SDL_Ximage=screen->pixels; 115 SDL_Ximage=screen->pixels;
87 116
88 if ( SDL_Ximage == NULL ) { 117 if ( SDL_Ximage == NULL ) {
89 SDL_SetError("Couldn't create XImage"); 118 SDL_SetError("Couldn't create XImage");
90 return(-1); 119 return(-1);
104 if ( screen ) { 133 if ( screen ) {
105 screen->pixels = NULL; 134 screen->pixels = NULL;
106 } 135 }
107 } 136 }
108 137
138 /* This is a hack to see whether this system has more than 1 CPU */
139 static int num_CPU(void)
140 {
141 return 1;
142 }
143
109 int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags) 144 int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
110 { 145 {
111 int retval; 146 int retval;
112 147
148 D(bug("Chiamata ResizeImage!\n"));
149
113 CGX_DestroyImage(this, screen); 150 CGX_DestroyImage(this, screen);
114 151
115 if ( flags & SDL_OPENGL ) { /* No image when using GL */ 152 if ( flags & SDL_OPENGL ) { /* No image when using GL */
116 retval = 0; 153 retval = 0;
117 } else { 154 } else {
118 retval = CGX_SetupImage(this, screen); 155 retval = CGX_SetupImage(this, screen);
156 /* We support asynchronous blitting on the display */
157 if ( flags & SDL_ASYNCBLIT ) {
158 /* This is actually slower on single-CPU systems,
159 probably because of CPU contention between the
160 X server and the application.
161 Note: Is this still true with XFree86 4.0?
162 */
163 if ( num_CPU() > 1 ) {
164 screen->flags |= SDL_ASYNCBLIT;
165 }
166 }
119 } 167 }
120 return(retval); 168 return(retval);
121 } 169 }
122 170
123 /* We don't actually allow hardware surfaces other than the main one */ 171 /* We don't actually allow hardware surfaces other than the main one */
133 181
134 if(!surface->hwdata) 182 if(!surface->hwdata)
135 { 183 {
136 if(!(surface->hwdata=malloc(sizeof(struct private_hwdata)))) 184 if(!(surface->hwdata=malloc(sizeof(struct private_hwdata))))
137 return -1; 185 return -1;
138 186 }
139 surface->hwdata->lock=NULL; 187
140 surface->hwdata->videodata=this; 188 surface->hwdata->lock=NULL;
141 } 189 surface->hwdata->videodata=this;
142 190
143 if(surface->hwdata->bmap=AllocBitMap(surface->w,surface->h,this->hidden->depth,BMF_MINPLANES,SDL_Display->RastPort.BitMap)) 191 if(surface->hwdata->bmap=AllocBitMap(surface->w,surface->h,this->hidden->depth,BMF_MINPLANES,SDL_Display->RastPort.BitMap))
144 { 192 {
145 surface->flags|=SDL_HWSURFACE; 193 surface->flags|=SDL_HWSURFACE;
146 D(bug("...OK\n")); 194 D(bug("...OK\n"));
203 { 251 {
204 if(surface->hwdata && surface->hwdata->lock) 252 if(surface->hwdata && surface->hwdata->lock)
205 { 253 {
206 UnLockBitMap(surface->hwdata->lock); 254 UnLockBitMap(surface->hwdata->lock);
207 surface->hwdata->lock=NULL; 255 surface->hwdata->lock=NULL;
208 surface->pixels=NULL; 256 // surface->pixels=NULL;
209 } 257 }
210 } 258 }
211 259
212 int CGX_FlipHWSurface(_THIS, SDL_Surface *surface) 260 int CGX_FlipHWSurface(_THIS, SDL_Surface *surface)
213 { 261 {