Mercurial > sdl-ios-xcode
comparison src/video/photon/SDL_phyuv.c @ 663:8bedd6d61642
Date: Sat, 2 Aug 2003 16:22:51 +0300
From: "Mike Gorchak"
Subject: New patches for QNX6
Here my patches for the SDL/QNX:
QNXSDL.diff - diff to non-QNX related sources:
- updated BUGS file, I think QNX6 is now will be officially supported
- configure.in - added shared library support for QNX, and removed dependency between the ALSA and QNX6.
- SDL_audio.c - added QNX NTO sound bootstrap insted of ALSA's.
- SDL_sysaudio.h - the same.
- SDL_nto_audio.c - the same.
- SDL_video.c - right now, QNX doesn't offer any method to obtain pointers to the OpenGL functions by function name, so they must be hardcoded in library, otherwise OpenGL will not be supported.
- testsprite.c - fixed: do not draw vertical red line if we are in non-double-buffered mode.
sdlqnxph.tar.gz - archive of the ./src/video/photon/* . Too many changes in code to make diffs :) :
+ Added stub for support hide/unhide window event
+ Added full YUV overlays support.
+ Added window maximize support.
+ Added mouse wheel events.
+ Added support for some specific key codes in Unicode mode (like ESC).
+ Added more checks to the all memory allocation code.
+ Added SDL_DOUBLEBUF support in all fullscreen modes.
+ Added fallback to window mode, if desired fullscreen mode is not supported.
+ Added stub support for the GL_LoadLibrary and GL_GetProcAddress functions.
+ Added resizable window support without caption.
! Fixed bug in the Ph_EV_EXPOSE event handler, when rectangles to update is 0 and when width or height of the rectangle is 0.
! Fixed bug in the event handler code. Events has not been passed to the window widget handler.
! Fixed codes for Win keys (Super/Hyper/Menu).
! Fixed memory leak, when deallocation palette.
! Fixed palette emulation code bugs.
! Fixed fullscreen and hwsurface handling.
! Fixed CLOSE button bug. First event was passed to the handler, but second terminated the application. Now all events passed to the application correctly.
- Removed all printfs in code, now SDL_SetError used instead of them.
- Disabled ToggleFullScreen function.
README.QNX - updated README.QNX file. Added much more issues.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 04 Aug 2003 00:52:42 +0000 |
parents | 8e3ce997621c |
children | b14fdadd8311 |
comparison
equal
deleted
inserted
replaced
662:66c02f83f5bf | 663:8bedd6d61642 |
---|---|
23 #ifdef SAVE_RCSID | 23 #ifdef SAVE_RCSID |
24 static char rcsid = | 24 static char rcsid = |
25 "@(#) $Id$"; | 25 "@(#) $Id$"; |
26 #endif | 26 #endif |
27 | 27 |
28 /* This is the QNX Realtime Platform version for SDL YUV video overlays */ | 28 /* This is the QNX Realtime Platform version of SDL YUV video overlays */ |
29 | 29 |
30 #include <stdlib.h> | 30 #include <stdlib.h> |
31 #include <string.h> | 31 #include <string.h> |
32 #include <errno.h> | 32 #include <errno.h> |
33 | 33 |
41 | 41 |
42 #define OVERLAY_STATE_UNINIT 0 | 42 #define OVERLAY_STATE_UNINIT 0 |
43 #define OVERLAY_STATE_ACTIVE 1 | 43 #define OVERLAY_STATE_ACTIVE 1 |
44 | 44 |
45 /* The functions used to manipulate software video overlays */ | 45 /* The functions used to manipulate software video overlays */ |
46 static struct private_yuvhwfuncs ph_yuvfuncs = { | 46 static struct private_yuvhwfuncs ph_yuvfuncs = |
47 { | |
47 ph_LockYUVOverlay, | 48 ph_LockYUVOverlay, |
48 ph_UnlockYUVOverlay, | 49 ph_UnlockYUVOverlay, |
49 ph_DisplayYUVOverlay, | 50 ph_DisplayYUVOverlay, |
50 ph_FreeYUVOverlay | 51 ph_FreeYUVOverlay |
51 }; | 52 }; |
52 | 53 |
53 struct private_yuvhwdata { | 54 int grab_ptrs2(PgVideoChannel_t* channel, FRAMEDATA* Frame0, FRAMEDATA* Frame1) |
54 FRAMEDATA* CurrentFrameData; | |
55 FRAMEDATA* FrameData0; | |
56 FRAMEDATA* FrameData1; | |
57 PgScalerProps_t props; | |
58 PgScalerCaps_t caps; | |
59 PgVideoChannel_t* channel; | |
60 PhArea_t CurrentWindow; | |
61 long format; | |
62 int planar; | |
63 int scaler_on; | |
64 int current; | |
65 long YStride; | |
66 long VStride; | |
67 long UStride; | |
68 int ischromakey; | |
69 long chromakey; | |
70 unsigned long State; | |
71 long flags; | |
72 int locked; | |
73 }; | |
74 | |
75 int grab_ptrs2(PgVideoChannel_t* channel, FRAMEDATA* Frame0, FRAMEDATA* Frame1 ) | |
76 { | 55 { |
77 int planes = 0; | 56 int planes = 0; |
78 | 57 |
79 /* Buffers have moved; re-obtain the pointers */ | 58 /* Buffers have moved; re-obtain the pointers */ |
80 Frame0->Y = (unsigned char *)PdGetOffscreenContextPtr(channel->yplane1); | 59 Frame0->Y = (unsigned char *)PdGetOffscreenContextPtr(channel->yplane1); |
94 planes++; | 73 planes++; |
95 | 74 |
96 return planes; | 75 return planes; |
97 } | 76 } |
98 | 77 |
99 SDL_Overlay* ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display) | 78 SDL_Overlay* ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface* display) |
100 { | 79 { |
101 SDL_Overlay *overlay; | 80 SDL_Overlay* overlay; |
102 struct private_yuvhwdata *hwdata; | 81 struct private_yuvhwdata* hwdata; |
103 int xv_port; | 82 int vidport; |
104 int rtncode; | 83 int rtncode; |
105 int planes; | 84 int planes; |
106 int i=0; | 85 int i=0; |
107 PhPoint_t pos; | 86 PhPoint_t pos; |
108 | 87 |
109 /* Create the overlay structure */ | 88 /* Create the overlay structure */ |
110 overlay = calloc(1, sizeof(SDL_Overlay)); | 89 overlay = calloc(1, sizeof(SDL_Overlay)); |
111 | 90 |
112 if (overlay == NULL) { | 91 if (overlay == NULL) |
92 { | |
113 SDL_OutOfMemory(); | 93 SDL_OutOfMemory(); |
114 return (NULL); | 94 return NULL; |
115 } | 95 } |
116 | 96 |
117 /* Fill in the basic members */ | 97 /* Fill in the basic members */ |
118 overlay->format = format; | 98 overlay->format = format; |
119 overlay->w = width; | 99 overlay->w = width; |
120 overlay->h = height; | 100 overlay->h = height; |
101 overlay->hwdata = NULL; | |
121 | 102 |
122 /* Set up the YUV surface function structure */ | 103 /* Set up the YUV surface function structure */ |
123 overlay->hwfuncs = &ph_yuvfuncs; | 104 overlay->hwfuncs = &ph_yuvfuncs; |
124 | 105 |
125 /* Create the pixel data and lookup tables */ | 106 /* Create the pixel data and lookup tables */ |
126 hwdata = calloc(1, sizeof(struct private_yuvhwdata)); | 107 hwdata = calloc(1, sizeof(struct private_yuvhwdata)); |
127 | 108 |
128 overlay->hwdata = hwdata; | 109 if (hwdata == NULL) |
129 if (hwdata == NULL) { | 110 { |
130 SDL_OutOfMemory(); | 111 SDL_OutOfMemory(); |
131 SDL_FreeYUVOverlay(overlay); | 112 SDL_FreeYUVOverlay(overlay); |
132 return(NULL); | 113 return NULL; |
133 } | 114 } |
115 | |
116 overlay->hwdata = hwdata; | |
134 | 117 |
135 PhDCSetCurrent(0); | 118 PhDCSetCurrent(0); |
136 if (overlay->hwdata->channel == NULL) | 119 if (overlay->hwdata->channel == NULL) |
137 { | 120 { |
138 if ((overlay->hwdata->channel = PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER,0)) == NULL) | 121 if ((overlay->hwdata->channel = PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER, 0)) == NULL) |
139 { | 122 { |
140 SDL_SetError("ph_CreateYUVOverlay(): Create channel failed: %s\n", strerror(errno)); | 123 SDL_SetError("ph_CreateYUVOverlay(): Create channel failed: %s\n", strerror(errno)); |
141 SDL_FreeYUVOverlay(overlay); | 124 SDL_FreeYUVOverlay(overlay); |
142 | 125 return NULL; |
143 return(NULL); | 126 |
144 | 127 } |
145 } | 128 } |
146 } | 129 |
130 overlay->hwdata->forcedredraw=0; | |
147 | 131 |
148 PtGetAbsPosition(window, &pos.x, &pos.y); | 132 PtGetAbsPosition(window, &pos.x, &pos.y); |
149 overlay->hwdata->CurrentWindow.pos.x = pos.x; | 133 overlay->hwdata->CurrentWindowPos.x = pos.x; |
150 overlay->hwdata->CurrentWindow.pos.y = pos.y; | 134 overlay->hwdata->CurrentWindowPos.y = pos.y; |
151 overlay->hwdata->CurrentWindow.size.w = width; | 135 overlay->hwdata->CurrentViewPort.pos.x = 0; |
152 overlay->hwdata->CurrentWindow.size.h = height; | 136 overlay->hwdata->CurrentViewPort.pos.y = 0; |
137 overlay->hwdata->CurrentViewPort.size.w = width; | |
138 overlay->hwdata->CurrentViewPort.size.h = height; | |
153 overlay->hwdata->State = OVERLAY_STATE_UNINIT; | 139 overlay->hwdata->State = OVERLAY_STATE_UNINIT; |
154 overlay->hwdata->FrameData0 = (FRAMEDATA *) calloc(1, sizeof(FRAMEDATA)); | 140 overlay->hwdata->FrameData0 = (FRAMEDATA *) calloc(1, sizeof(FRAMEDATA)); |
155 overlay->hwdata->FrameData1 = (FRAMEDATA *) calloc(1, sizeof(FRAMEDATA)); | 141 overlay->hwdata->FrameData1 = (FRAMEDATA *) calloc(1, sizeof(FRAMEDATA)); |
156 | 142 |
157 xv_port = -1; | 143 vidport = -1; |
158 i=0; | 144 i=0; |
159 | 145 |
160 overlay->hwdata->ischromakey=0; | 146 overlay->hwdata->ischromakey=0; |
161 | 147 |
162 do { | 148 do { |
169 { | 155 { |
170 if ((overlay->hwdata->caps.flags & Pg_SCALER_CAP_DST_CHROMA_KEY) == Pg_SCALER_CAP_DST_CHROMA_KEY) | 156 if ((overlay->hwdata->caps.flags & Pg_SCALER_CAP_DST_CHROMA_KEY) == Pg_SCALER_CAP_DST_CHROMA_KEY) |
171 { | 157 { |
172 overlay->hwdata->ischromakey=1; | 158 overlay->hwdata->ischromakey=1; |
173 } | 159 } |
174 xv_port=1; | 160 vidport=1; |
175 break; | 161 break; |
176 } | 162 } |
177 } | 163 } |
178 else | 164 else |
179 { | 165 { |
181 } | 167 } |
182 i++; | 168 i++; |
183 } while(1); | 169 } while(1); |
184 | 170 |
185 | 171 |
186 if (xv_port == -1) | 172 if (vidport == -1) |
187 { | 173 { |
188 SDL_SetError("No available video ports for requested format\n"); | 174 SDL_SetError("No available video ports for requested format\n"); |
189 SDL_FreeYUVOverlay(overlay); | 175 SDL_FreeYUVOverlay(overlay); |
190 return(NULL); | 176 return NULL; |
191 } | 177 } |
192 | 178 |
193 overlay->hwdata->format = format; | 179 overlay->hwdata->format = format; |
194 overlay->hwdata->props.format = format; | 180 overlay->hwdata->props.format = format; |
195 overlay->hwdata->props.size = sizeof(PgScalerProps_t); | 181 overlay->hwdata->props.size = sizeof(PgScalerProps_t); |
196 overlay->hwdata->props.src_dim.w = width; | 182 overlay->hwdata->props.src_dim.w = width; |
197 overlay->hwdata->props.src_dim.h = height; | 183 overlay->hwdata->props.src_dim.h = height; |
198 | 184 |
199 /* Don't use chromakey for now, blitting a surface will cover the window, | 185 overlay->hwdata->chromakey = PgGetOverlayChromaColor(); |
200 * and therefore the chroma. */ | 186 |
201 overlay->hwdata->chromakey = 0; | 187 PhAreaToRect(&overlay->hwdata->CurrentViewPort, &overlay->hwdata->props.viewport); |
202 PtSetResource(window, Pt_ARG_FILL_COLOR, overlay->hwdata->chromakey, 0); | |
203 | |
204 PhAreaToRect(&overlay->hwdata->CurrentWindow, &overlay->hwdata->props.viewport); | |
205 | 188 |
206 overlay->hwdata->props.flags = Pg_SCALER_PROP_DOUBLE_BUFFER; | 189 overlay->hwdata->props.flags = Pg_SCALER_PROP_DOUBLE_BUFFER; |
207 | 190 |
208 if ((overlay->hwdata->ischromakey)&&(overlay->hwdata->chromakey)) | 191 if ((overlay->hwdata->ischromakey)&&(overlay->hwdata->chromakey)) |
209 { | 192 { |
210 overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_ENABLE; | 193 overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_ENABLE; |
211 overlay->hwdata->props.color_key = overlay->hwdata->chromakey; | |
212 overlay->hwdata->props.color_key_mask = 0x00FFFFFFUL; | |
213 } | 194 } |
214 else | 195 else |
215 { | 196 { |
216 overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_CHROMA_ENABLE; | 197 overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_CHROMA_ENABLE; |
217 } | 198 } |
219 rtncode = PgConfigScalerChannel(overlay->hwdata->channel, &overlay->hwdata->props); | 200 rtncode = PgConfigScalerChannel(overlay->hwdata->channel, &overlay->hwdata->props); |
220 | 201 |
221 switch(rtncode) | 202 switch(rtncode) |
222 { | 203 { |
223 case -1: SDL_SetError("PgConfigScalerChannel failed\n"); | 204 case -1: SDL_SetError("PgConfigScalerChannel failed\n"); |
224 SDL_FreeYUVOverlay(overlay); | 205 SDL_FreeYUVOverlay(overlay); |
225 return(NULL); | 206 return NULL; |
226 break; | |
227 case 1: | 207 case 1: |
228 case 0: | 208 case 0: |
229 default: | 209 default: |
230 break; | 210 break; |
231 } | 211 } |
232 | 212 |
233 planes = grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1); | 213 planes = grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1); |
234 | 214 |
235 if(overlay->hwdata->channel->yplane1 != NULL) | 215 if(overlay->hwdata->channel->yplane1 != NULL) |
236 overlay->hwdata->YStride = overlay->hwdata->channel->yplane1->pitch; | 216 overlay->hwdata->YStride = overlay->hwdata->channel->yplane1->pitch; |
237 if(overlay->hwdata->channel->uplane1 != NULL) | 217 if(overlay->hwdata->channel->uplane1 != NULL) |
238 overlay->hwdata->UStride = overlay->hwdata->channel->uplane1->pitch; | 218 overlay->hwdata->UStride = overlay->hwdata->channel->uplane1->pitch; |
239 if(overlay->hwdata->channel->vplane1 != NULL) | 219 if(overlay->hwdata->channel->vplane1 != NULL) |
240 overlay->hwdata->VStride = overlay->hwdata->channel->vplane1->pitch; | 220 overlay->hwdata->VStride = overlay->hwdata->channel->vplane1->pitch; |
241 | 221 |
222 /* check for the validness of all planes */ | |
223 if ((overlay->hwdata->channel->yplane1 == NULL) && | |
224 (overlay->hwdata->channel->uplane1 == NULL) && | |
225 (overlay->hwdata->channel->vplane1 == NULL)) | |
226 { | |
227 SDL_FreeYUVOverlay(overlay); | |
228 SDL_SetError("PgConfigScaler() returns all planes equal NULL\n"); | |
229 return NULL; | |
230 } | |
231 /* | |
242 overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel); | 232 overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel); |
243 | 233 |
244 if(overlay->hwdata->current==0) | 234 if (overlay->hwdata->current==0) |
235 { | |
245 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0; | 236 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0; |
237 } | |
246 else | 238 else |
239 { | |
247 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1; | 240 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1; |
248 | 241 } |
242 */ | |
243 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0; | |
244 | |
245 /* | |
249 overlay->hwdata->locked = 1; | 246 overlay->hwdata->locked = 1; |
247 */ | |
250 | 248 |
251 /* Find the pitch and offset values for the overlay */ | 249 /* Find the pitch and offset values for the overlay */ |
252 overlay->planes = planes; | 250 overlay->planes = planes; |
253 overlay->pitches = calloc(overlay->planes, sizeof(Uint16)); | 251 overlay->pitches = calloc(overlay->planes, sizeof(Uint16)); |
254 overlay->pixels = calloc(overlay->planes, sizeof(Uint8*)); | 252 overlay->pixels = calloc(overlay->planes, sizeof(Uint8*)); |
277 | 275 |
278 overlay->hwdata->State = OVERLAY_STATE_ACTIVE; | 276 overlay->hwdata->State = OVERLAY_STATE_ACTIVE; |
279 overlay->hwdata->scaler_on = 0; | 277 overlay->hwdata->scaler_on = 0; |
280 overlay->hw_overlay = 1; | 278 overlay->hw_overlay = 1; |
281 | 279 |
282 return (overlay); | 280 current_overlay=overlay; |
281 | |
282 return overlay; | |
283 } | 283 } |
284 | 284 |
285 int ph_LockYUVOverlay(_THIS, SDL_Overlay *overlay) | 285 int ph_LockYUVOverlay(_THIS, SDL_Overlay* overlay) |
286 { | 286 { |
287 if (overlay == NULL) | 287 if (overlay == NULL) |
288 { | |
288 return 0; | 289 return 0; |
289 | 290 } |
290 overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel); | 291 |
292 overlay->hwdata->locked = 1; | |
293 | |
294 /* overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel); | |
291 if (overlay->hwdata->current == -1) | 295 if (overlay->hwdata->current == -1) |
292 { | 296 { |
293 SDL_SetError("PgNextFrame failed, bailing out\n"); | 297 SDL_SetError("ph_LockYUVOverlay: PgNextFrame() failed, bailing out\n"); |
294 SDL_FreeYUVOverlay(overlay); | 298 SDL_FreeYUVOverlay(overlay); |
295 return(NULL); | 299 return 0; |
296 } | 300 } |
297 | 301 |
298 overlay->hwdata->locked = 1; | |
299 | |
300 /* set current frame for double buffering */ | |
301 if (overlay->hwdata->current == 0) | 302 if (overlay->hwdata->current == 0) |
303 { | |
302 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0; | 304 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0; |
305 } | |
303 else | 306 else |
307 { | |
304 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1; | 308 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1; |
309 } | |
305 | 310 |
306 if (overlay->planes > 0) | 311 if (overlay->planes > 0) |
307 { | 312 { |
308 overlay->pitches[0] = overlay->hwdata->channel->yplane1->pitch; | 313 overlay->pitches[0] = overlay->hwdata->channel->yplane1->pitch; |
309 overlay->pixels[0] = overlay->hwdata->CurrentFrameData->Y; | 314 overlay->pixels[0] = overlay->hwdata->CurrentFrameData->Y; |
316 if (overlay->planes > 2) | 321 if (overlay->planes > 2) |
317 { | 322 { |
318 overlay->pitches[2] = overlay->hwdata->channel->vplane1->pitch; | 323 overlay->pitches[2] = overlay->hwdata->channel->vplane1->pitch; |
319 overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V; | 324 overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V; |
320 } | 325 } |
326 */ | |
321 | 327 |
322 return(0); | 328 return(0); |
323 } | 329 } |
324 | 330 |
325 void ph_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay) | 331 void ph_UnlockYUVOverlay(_THIS, SDL_Overlay* overlay) |
326 { | 332 { |
327 int rtncode; | 333 if (overlay == NULL) |
328 | 334 { |
329 if(overlay == NULL) | |
330 return; | 335 return; |
331 | 336 } |
332 if(overlay->hwdata->scaler_on == 1) | 337 |
333 { | 338 overlay->hwdata->locked = 0; |
334 rtncode =PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props)); | |
335 switch(rtncode) | |
336 { | |
337 case -1: | |
338 SDL_SetError("PgConfigScalerChannel failed\n"); | |
339 SDL_FreeYUVOverlay(overlay); | |
340 break; | |
341 case 1: | |
342 grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1); | |
343 break; | |
344 case 0: | |
345 default: | |
346 break; | |
347 } | |
348 } | |
349 | |
350 /* This would be the best place to draw chromakey but we do not have a SDL_Surface in the args | |
351 * This means we might see a chromakey flicker at startup. */ | |
352 } | 339 } |
353 | 340 |
354 int ph_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect) | 341 int ph_DisplayYUVOverlay(_THIS, SDL_Overlay* overlay, SDL_Rect* dstrect) |
355 { | 342 { |
356 int rtncode; | 343 int rtncode; |
357 PhPoint_t pos; | 344 PhPoint_t pos; |
358 | 345 SDL_Rect backrect; |
359 if(overlay == NULL) | 346 PhRect_t windowextent; |
347 int winchanged=0; | |
348 | |
349 if ((overlay == NULL) || (overlay->hwdata==NULL)) | |
350 { | |
360 return -1; | 351 return -1; |
361 | 352 } |
362 /* If CurrentWindow has change, move the viewport */ | 353 |
363 if((overlay->hwdata->CurrentWindow.pos.x != dstrect->x) || | 354 if (overlay->hwdata->State == OVERLAY_STATE_UNINIT) |
364 (overlay->hwdata->CurrentWindow.pos.y != dstrect->y) || | 355 { |
365 (overlay->hwdata->CurrentWindow.size.w != dstrect->w) || | 356 return -1; |
366 (overlay->hwdata->CurrentWindow.size.h != dstrect->h) || | 357 } |
367 (overlay->hwdata->scaler_on==0)) | 358 |
368 { | 359 PtGetAbsPosition(window, &pos.x, &pos.y); |
369 if(overlay->hwdata->State == OVERLAY_STATE_UNINIT) | 360 if ((pos.x!=overlay->hwdata->CurrentWindowPos.x) || |
370 return -1; | 361 (pos.y!=overlay->hwdata->CurrentWindowPos.y)) |
362 { | |
363 winchanged=1; | |
364 overlay->hwdata->CurrentWindowPos.x=pos.x; | |
365 overlay->hwdata->CurrentWindowPos.y=pos.y; | |
366 } | |
367 | |
368 /* If CurrentViewPort position/size has been changed, then move/resize the viewport */ | |
369 if ((overlay->hwdata->CurrentViewPort.pos.x != dstrect->x) || | |
370 (overlay->hwdata->CurrentViewPort.pos.y != dstrect->y) || | |
371 (overlay->hwdata->CurrentViewPort.size.w != dstrect->w) || | |
372 (overlay->hwdata->CurrentViewPort.size.h != dstrect->h) || | |
373 (overlay->hwdata->scaler_on==0) || (winchanged==1) || | |
374 (overlay->hwdata->forcedredraw==1)) | |
375 { | |
376 | |
377 if (overlay->hwdata->ischromakey==1) | |
378 { | |
379 /* restore screen behind the overlay/chroma color. */ | |
380 backrect.x=overlay->hwdata->CurrentViewPort.pos.x; | |
381 backrect.y=overlay->hwdata->CurrentViewPort.pos.y; | |
382 backrect.w=overlay->hwdata->CurrentViewPort.size.w; | |
383 backrect.h=overlay->hwdata->CurrentViewPort.size.h; | |
384 this->UpdateRects(this, 1, &backrect); | |
385 | |
386 /* Draw the new rectangle of the chroma color at the viewport position */ | |
387 PgSetFillColor(overlay->hwdata->chromakey); | |
388 PgDrawIRect(dstrect->x, dstrect->y, dstrect->x+dstrect->w-1, dstrect->y+dstrect->h-1, Pg_DRAW_FILL); | |
389 PgFlush(); | |
390 } | |
371 | 391 |
372 overlay->hwdata->props.flags |= Pg_SCALER_PROP_SCALER_ENABLE; | 392 overlay->hwdata->props.flags |= Pg_SCALER_PROP_SCALER_ENABLE; |
373 overlay->hwdata->scaler_on = 1; | 393 overlay->hwdata->scaler_on = 1; |
374 | 394 |
375 PtGetAbsPosition(window, &pos.x, &pos.y); | 395 PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, PtWidgetRid(window), &windowextent); |
376 overlay->hwdata->CurrentWindow.pos.x = pos.x + dstrect->x; | 396 overlay->hwdata->CurrentViewPort.pos.x = pos.x-windowextent.ul.x+dstrect->x; |
377 overlay->hwdata->CurrentWindow.pos.y = pos.y + dstrect->y; | 397 overlay->hwdata->CurrentViewPort.pos.y = pos.y-windowextent.ul.y+dstrect->y; |
378 overlay->hwdata->CurrentWindow.size.w = dstrect->w; | 398 overlay->hwdata->CurrentViewPort.size.w = dstrect->w; |
379 overlay->hwdata->CurrentWindow.size.h = dstrect->h; | 399 overlay->hwdata->CurrentViewPort.size.h = dstrect->h; |
380 | 400 PhAreaToRect(&overlay->hwdata->CurrentViewPort, &overlay->hwdata->props.viewport); |
381 PhAreaToRect(&overlay->hwdata->CurrentWindow, &overlay->hwdata->props.viewport); | 401 overlay->hwdata->CurrentViewPort.pos.x = dstrect->x; |
402 overlay->hwdata->CurrentViewPort.pos.y = dstrect->y; | |
382 | 403 |
383 rtncode = PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props)); | 404 rtncode = PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props)); |
384 | 405 |
385 switch(rtncode) | 406 switch(rtncode) |
386 { | 407 { |
395 default: | 416 default: |
396 break; | 417 break; |
397 } | 418 } |
398 } | 419 } |
399 | 420 |
400 if (!overlay->hwdata->locked) | 421 |
422 /* | |
423 if (overlay->hwdata->locked==0) | |
401 { | 424 { |
402 overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel); | 425 overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel); |
403 if (overlay->hwdata->current == -1) | 426 if (overlay->hwdata->current == -1) |
404 { | 427 { |
405 SDL_SetError("PgNextVideoFrame failed\n"); | 428 SDL_SetError("ph_LockYUVOverlay: PgNextFrame() failed, bailing out\n"); |
406 SDL_FreeYUVOverlay(overlay); | 429 SDL_FreeYUVOverlay(overlay); |
407 return 0; | 430 return 0; |
408 } | 431 } |
432 | |
409 if (overlay->hwdata->current == 0) | 433 if (overlay->hwdata->current == 0) |
434 { | |
410 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0; | 435 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0; |
436 } | |
411 else | 437 else |
438 { | |
412 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1; | 439 overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1; |
440 } | |
413 | 441 |
414 if (overlay->planes > 0) | 442 if (overlay->planes > 0) |
415 { | 443 { |
416 overlay->pitches[0] = overlay->hwdata->channel->yplane1->pitch; | 444 overlay->pitches[0] = overlay->hwdata->channel->yplane1->pitch; |
417 overlay->pixels[0] = overlay->hwdata->CurrentFrameData->Y; | 445 overlay->pixels[0] = overlay->hwdata->CurrentFrameData->Y; |
425 { | 453 { |
426 overlay->pitches[2] = overlay->hwdata->channel->vplane1->pitch; | 454 overlay->pitches[2] = overlay->hwdata->channel->vplane1->pitch; |
427 overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V; | 455 overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V; |
428 } | 456 } |
429 } | 457 } |
458 */ | |
430 | 459 |
431 return 0; | 460 return 0; |
432 } | 461 } |
433 | 462 |
434 void ph_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) | 463 void ph_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) |
435 { | 464 { |
465 SDL_Rect backrect; | |
466 | |
436 if (overlay == NULL) | 467 if (overlay == NULL) |
468 { | |
437 return; | 469 return; |
470 } | |
438 | 471 |
439 if (overlay->hwdata == NULL) | 472 if (overlay->hwdata == NULL) |
473 { | |
440 return; | 474 return; |
475 } | |
476 | |
477 current_overlay=NULL; | |
478 | |
479 /* restore screen behind the overlay/chroma color. */ | |
480 backrect.x=overlay->hwdata->CurrentViewPort.pos.x; | |
481 backrect.y=overlay->hwdata->CurrentViewPort.pos.y; | |
482 backrect.w=overlay->hwdata->CurrentViewPort.size.w; | |
483 backrect.h=overlay->hwdata->CurrentViewPort.size.h; | |
484 this->UpdateRects(this, 1, &backrect); | |
441 | 485 |
442 /* it is need for some buggy drivers, that can't hide overlay before */ | 486 /* it is need for some buggy drivers, that can't hide overlay before */ |
443 /* freeing buffer, so we got trash on the srceen */ | 487 /* freeing buffer, so we got trash on the srceen */ |
444 overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_SCALER_ENABLE; | 488 overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_SCALER_ENABLE; |
445 PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props)); | 489 PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props)); |