comparison src/video/photon/SDL_ph_image.c @ 266:c6abdda2f666

Added QNX cleanups by Mike Gorchak (thanks!)
author Sam Lantinga <slouken@libsdl.org>
date Fri, 18 Jan 2002 18:14:03 +0000
parents e8157fcb3114
children 3d8b6b9f1e18
comparison
equal deleted inserted replaced
265:35d9c8a5aa10 266:c6abdda2f666
127 return -1; 127 return -1;
128 } 128 }
129 break; 129 break;
130 } 130 }
131 131
132 OCImage.FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA))); 132 OCImage.FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
133 OCImage.FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA))); 133 OCImage.FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
134 134
135 if(OCImage.direct_context == NULL) 135 if(OCImage.direct_context == NULL)
136 OCImage.direct_context = PdCreateDirectContext(); 136 OCImage.direct_context = PdCreateDirectContext();
137 137
138 OCImage.offscreen_context = PdCreateOffscreenContext(0,screen->w,screen->h, Pg_OSC_MEM_PAGE_ALIGN); 138 OCImage.offscreen_context = PdCreateOffscreenContext(0,screen->w,screen->h, Pg_OSC_MEM_PAGE_ALIGN);
139 139
140 if (OCImage.offscreen_context == NULL) 140 if (OCImage.offscreen_context == NULL)
141 { 141 {
142 printf("PdCreateOffscreenContext failed\n"); 142 printf("PdCreateOffscreenContext failed\n");
143 return -1; 143 return -1;
144 } 144 }
145 145
146 OCImage.Stride = OCImage.offscreen_context->pitch; 146 OCImage.Stride = OCImage.offscreen_context->pitch;
147 147
148 if (OCImage.flags & SDL_DOUBLEBUF) 148 if (OCImage.flags & SDL_DOUBLEBUF)
149 printf("hardware flag for doublebuf offscreen context\n"); 149 printf("hardware flag for doublebuf offscreen context\n");
150 150
151 151
152 OCImage.dc_ptr.ptr8 = (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context); 152 OCImage.dc_ptr.ptr8 = (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context);
153 153
154 OCImage.CurrentFrameData = OCImage.FrameData0; 154 OCImage.CurrentFrameData = OCImage.FrameData0;
173 } 173 }
174 174
175 175
176 void ph_DestroyImage(_THIS, SDL_Surface *screen) 176 void ph_DestroyImage(_THIS, SDL_Surface *screen)
177 { 177 {
178
179
180 if(SDL_Image == NULL) 178 if(SDL_Image == NULL)
181 return; 179 return;
182 180
183 if (OCImage.offscreen_context != NULL) 181 if (OCImage.offscreen_context != NULL)
184 { 182 {
185 183 PhDCRelease(OCImage.offscreen_context);
186 PhDCRelease(OCImage.offscreen_context); 184 OCImage.offscreen_context = NULL;
187 OCImage.offscreen_context = NULL; 185 free(OCImage.FrameData0);
188 free(OCImage.FrameData0); 186 OCImage.FrameData0 = NULL;
189 OCImage.FrameData0 = NULL; 187 free(OCImage.FrameData1);
190 free(OCImage.FrameData1); 188 OCImage.FrameData1 = NULL;
191 OCImage.FrameData1 = NULL; 189 }
192 }
193 190
194 if (SDL_Image->image) 191 if (SDL_Image->image)
195 { 192 {
196 // SDL_Image->flags=Ph_RELEASE_IMAGE; 193 // SDL_Image->flags=Ph_RELEASE_IMAGE;
197 // PhReleaseImage(SDL_Image); 194 // PhReleaseImage(SDL_Image);
208 SDL_Image = NULL; 205 SDL_Image = NULL;
209 } 206 }
210 207
211 int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags) 208 int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
212 { 209 {
213
214 ph_DestroyImage(this, screen); 210 ph_DestroyImage(this, screen);
215 211
216 if( flags & SDL_HWSURFACE) 212 if( flags & SDL_HWSURFACE)
217 { 213 {
218 OCImage.flags = flags; //needed for SDL_DOUBLEBUF check 214 OCImage.flags = flags; //needed for SDL_DOUBLEBUF check
224 } 220 }
225 else 221 else
226 { 222 {
227 return ph_SetupImage(this, screen); 223 return ph_SetupImage(this, screen);
228 } 224 }
229
230 } 225 }
231 226
232 int ph_AllocHWSurface(_THIS, SDL_Surface *surface) 227 int ph_AllocHWSurface(_THIS, SDL_Surface *surface)
233 { 228 {
234
235 return(-1); 229 return(-1);
236 } 230 }
237 231
238 void ph_FreeHWSurface(_THIS, SDL_Surface *surface) 232 void ph_FreeHWSurface(_THIS, SDL_Surface *surface)
239 { 233 {
240
241 return; 234 return;
242 } 235 }
243 236
244 int ph_FlipHWSurface(_THIS, SDL_Surface *surface) 237 int ph_FlipHWSurface(_THIS, SDL_Surface *surface)
245 { 238 {
246
247 return(0); 239 return(0);
248 } 240 }
249 241
250 int ph_LockHWSurface(_THIS, SDL_Surface *surface) 242 int ph_LockHWSurface(_THIS, SDL_Surface *surface)
251 { 243 {
252
253 if ( (surface == SDL_VideoSurface) && blit_queued ) { 244 if ( (surface == SDL_VideoSurface) && blit_queued ) {
254 // XSync(GFX_Display, False); 245 // XSync(GFX_Display, False);
255 PgFlush(); 246 PgFlush();
256 blit_queued = 0; 247 blit_queued = 0;
257 } 248 }
258 return(0); 249 return(0);
259 } 250 }
260 251
261 void ph_UnlockHWSurface(_THIS, SDL_Surface *surface) 252 void ph_UnlockHWSurface(_THIS, SDL_Surface *surface)
262 { 253 {
263
264 return; 254 return;
265 } 255 }
266 256
267 static PhPoint_t ph_pos; 257 static PhPoint_t ph_pos;
268 static PhRect_t ph_rect; 258 static PhRect_t ph_rect;
288 { 278 {
289 fprintf(stderr,"error: PgDrawPhImageRectmx failed.\n"); 279 fprintf(stderr,"error: PgDrawPhImageRectmx failed.\n");
290 } 280 }
291 } 281 }
292 if (PgFlush() < 0) 282 if (PgFlush() < 0)
293 { 283 {
294 fprintf(stderr,"error: PgFlush failed.\n"); 284 fprintf(stderr,"error: PgFlush failed.\n");
295 } 285 }
296 } 286 }
297 void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects) 287 void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects)
298 { 288 {
324 dest_rect.lr.x=src_rect.lr.x= rects[i].x +rects[i].w; 314 dest_rect.lr.x=src_rect.lr.x= rects[i].x +rects[i].w;
325 dest_rect.lr.y=src_rect.lr.y= rects[i].y +rects[i].h; 315 dest_rect.lr.y=src_rect.lr.y= rects[i].y +rects[i].h;
326 316
327 zero.x = zero.y = 0; 317 zero.x = zero.y = 0;
328 PgSetTranslation (&zero, 0); 318 PgSetTranslation (&zero, 0);
329 PgSetRegion(PtWidgetRid(window)); 319 PgSetRegion(PtWidgetRid(window));
330 PgSetClipping(0,NULL); 320 PgSetClipping(0,NULL);
331 PgContextBlitArea(OCImage.offscreen_context, (PhArea_t *)(&src_rect), NULL, (PhArea_t *)(&dest_rect)); 321 PgContextBlitArea(OCImage.offscreen_context, (PhArea_t *)(&src_rect), NULL, (PhArea_t *)(&dest_rect));
332 322
333 } 323 }
334 if (PgFlush() < 0) 324 if (PgFlush() < 0)
335 { 325 {
336 fprintf(stderr,"error: PgFlush failed.\n"); 326 fprintf(stderr,"error: PgFlush failed.\n");
337 } 327 }
338 328
339 //later used to toggling double buffer 329 //later used to toggling double buffer
340 if(OCImage.current == 0) 330 if(OCImage.current == 0)