Mercurial > sdl-ios-xcode
comparison src/video/directfb/SDL_DirectFB_yuv.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
47 Uint16 pitches[3]; | 47 Uint16 pitches[3]; |
48 Uint8 *planes[3]; | 48 Uint8 *planes[3]; |
49 }; | 49 }; |
50 | 50 |
51 static DFBEnumerationResult | 51 static DFBEnumerationResult |
52 enum_layers_callback (DFBDisplayLayerID id, | 52 enum_layers_callback(DFBDisplayLayerID id, |
53 DFBDisplayLayerDescription desc, void *data) | 53 DFBDisplayLayerDescription desc, void *data) |
54 { | 54 { |
55 struct private_yuvhwdata *hwdata = (struct private_yuvhwdata *) data; | 55 struct private_yuvhwdata *hwdata = (struct private_yuvhwdata *) data; |
56 | 56 |
57 /* we don't want the primary */ | 57 /* we don't want the primary */ |
58 if (id == DLID_PRIMARY) | 58 if (id == DLID_PRIMARY) |
68 return DFENUM_OK; | 68 return DFENUM_OK; |
69 } | 69 } |
70 | 70 |
71 | 71 |
72 static DFBResult | 72 static DFBResult |
73 CreateYUVSurface (_THIS, struct private_yuvhwdata *hwdata, | 73 CreateYUVSurface(_THIS, struct private_yuvhwdata *hwdata, |
74 int width, int height, Uint32 format) | 74 int width, int height, Uint32 format) |
75 { | 75 { |
76 DFBResult ret; | 76 DFBResult ret; |
77 IDirectFB *dfb = HIDDEN->dfb; | 77 IDirectFB *dfb = HIDDEN->dfb; |
78 IDirectFBDisplayLayer *layer; | 78 IDirectFBDisplayLayer *layer; |
79 DFBDisplayLayerConfig conf; | 79 DFBDisplayLayerConfig conf; |
80 | 80 |
81 ret = dfb->EnumDisplayLayers (dfb, enum_layers_callback, hwdata); | 81 ret = dfb->EnumDisplayLayers(dfb, enum_layers_callback, hwdata); |
82 if (ret) { | 82 if (ret) { |
83 SetDirectFBerror ("IDirectFB::EnumDisplayLayers", ret); | 83 SetDirectFBerror("IDirectFB::EnumDisplayLayers", ret); |
84 return ret; | 84 return ret; |
85 } | 85 } |
86 | 86 |
87 if (!hwdata->layer_id) | 87 if (!hwdata->layer_id) |
88 return DFB_UNSUPPORTED; | 88 return DFB_UNSUPPORTED; |
89 | 89 |
90 ret = dfb->GetDisplayLayer (dfb, hwdata->layer_id, &layer); | 90 ret = dfb->GetDisplayLayer(dfb, hwdata->layer_id, &layer); |
91 if (ret) { | 91 if (ret) { |
92 SetDirectFBerror ("IDirectFB::GetDisplayLayer", ret); | 92 SetDirectFBerror("IDirectFB::GetDisplayLayer", ret); |
93 return ret; | 93 return ret; |
94 } | 94 } |
95 | 95 |
96 conf.flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT; | 96 conf.flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT; |
97 conf.width = width; | 97 conf.width = width; |
109 break; | 109 break; |
110 case SDL_UYVY_OVERLAY: | 110 case SDL_UYVY_OVERLAY: |
111 conf.pixelformat = DSPF_UYVY; | 111 conf.pixelformat = DSPF_UYVY; |
112 break; | 112 break; |
113 default: | 113 default: |
114 fprintf (stderr, "SDL_DirectFB: Unsupported YUV format (0x%08x)!\n", | 114 fprintf(stderr, "SDL_DirectFB: Unsupported YUV format (0x%08x)!\n", |
115 format); | 115 format); |
116 break; | 116 break; |
117 } | 117 } |
118 | 118 |
119 ret = layer->SetConfiguration (layer, &conf); | 119 ret = layer->SetConfiguration(layer, &conf); |
120 if (ret) { | 120 if (ret) { |
121 SetDirectFBerror ("IDirectFBDisplayLayer::SetConfiguration", ret); | 121 SetDirectFBerror("IDirectFBDisplayLayer::SetConfiguration", ret); |
122 layer->Release (layer); | 122 layer->Release(layer); |
123 return ret; | 123 return ret; |
124 } | 124 } |
125 | 125 |
126 ret = layer->GetSurface (layer, &hwdata->surface); | 126 ret = layer->GetSurface(layer, &hwdata->surface); |
127 if (ret) { | 127 if (ret) { |
128 SetDirectFBerror ("IDirectFBDisplayLayer::GetSurface", ret); | 128 SetDirectFBerror("IDirectFBDisplayLayer::GetSurface", ret); |
129 layer->Release (layer); | 129 layer->Release(layer); |
130 return ret; | 130 return ret; |
131 } | 131 } |
132 | 132 |
133 hwdata->layer = layer; | 133 hwdata->layer = layer; |
134 | 134 |
135 return DFB_OK; | 135 return DFB_OK; |
136 } | 136 } |
137 | 137 |
138 SDL_Overlay * | 138 SDL_Overlay * |
139 DirectFB_CreateYUVOverlay (_THIS, int width, int height, Uint32 format, | 139 DirectFB_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, |
140 SDL_Surface * display) | 140 SDL_Surface * display) |
141 { | 141 { |
142 SDL_Overlay *overlay; | 142 SDL_Overlay *overlay; |
143 struct private_yuvhwdata *hwdata; | 143 struct private_yuvhwdata *hwdata; |
144 | 144 |
145 /* Create the overlay structure */ | 145 /* Create the overlay structure */ |
146 overlay = SDL_calloc (1, sizeof (SDL_Overlay)); | 146 overlay = SDL_calloc(1, sizeof(SDL_Overlay)); |
147 if (!overlay) { | 147 if (!overlay) { |
148 SDL_OutOfMemory (); | 148 SDL_OutOfMemory(); |
149 return NULL; | 149 return NULL; |
150 } | 150 } |
151 | 151 |
152 /* Fill in the basic members */ | 152 /* Fill in the basic members */ |
153 overlay->format = format; | 153 overlay->format = format; |
156 | 156 |
157 /* Set up the YUV surface function structure */ | 157 /* Set up the YUV surface function structure */ |
158 overlay->hwfuncs = &directfb_yuvfuncs; | 158 overlay->hwfuncs = &directfb_yuvfuncs; |
159 | 159 |
160 /* Create the pixel data and lookup tables */ | 160 /* Create the pixel data and lookup tables */ |
161 hwdata = SDL_calloc (1, sizeof (struct private_yuvhwdata)); | 161 hwdata = SDL_calloc(1, sizeof(struct private_yuvhwdata)); |
162 overlay->hwdata = hwdata; | 162 overlay->hwdata = hwdata; |
163 if (!hwdata) { | 163 if (!hwdata) { |
164 SDL_OutOfMemory (); | 164 SDL_OutOfMemory(); |
165 SDL_FreeYUVOverlay (overlay); | 165 SDL_FreeYUVOverlay(overlay); |
166 return NULL; | 166 return NULL; |
167 } | 167 } |
168 | 168 |
169 if (CreateYUVSurface (this, hwdata, width, height, format)) { | 169 if (CreateYUVSurface(this, hwdata, width, height, format)) { |
170 SDL_FreeYUVOverlay (overlay); | 170 SDL_FreeYUVOverlay(overlay); |
171 return NULL; | 171 return NULL; |
172 } | 172 } |
173 | 173 |
174 overlay->hw_overlay = 1; | 174 overlay->hw_overlay = 1; |
175 | 175 |
189 /* We're all done.. */ | 189 /* We're all done.. */ |
190 return overlay; | 190 return overlay; |
191 } | 191 } |
192 | 192 |
193 int | 193 int |
194 DirectFB_LockYUVOverlay (_THIS, SDL_Overlay * overlay) | 194 DirectFB_LockYUVOverlay(_THIS, SDL_Overlay * overlay) |
195 { | 195 { |
196 DFBResult ret; | 196 DFBResult ret; |
197 void *data; | 197 void *data; |
198 int pitch; | 198 int pitch; |
199 IDirectFBSurface *surface = overlay->hwdata->surface; | 199 IDirectFBSurface *surface = overlay->hwdata->surface; |
200 | 200 |
201 ret = surface->Lock (surface, DSLF_READ | DSLF_WRITE, &data, &pitch); | 201 ret = surface->Lock(surface, DSLF_READ | DSLF_WRITE, &data, &pitch); |
202 if (ret) { | 202 if (ret) { |
203 SetDirectFBerror ("IDirectFBSurface::Lock", ret); | 203 SetDirectFBerror("IDirectFBSurface::Lock", ret); |
204 return -1; | 204 return -1; |
205 } | 205 } |
206 | 206 |
207 /* Find the pitch and offset values for the overlay */ | 207 /* Find the pitch and offset values for the overlay */ |
208 overlay->pitches[0] = (Uint16) pitch; | 208 overlay->pitches[0] = (Uint16) pitch; |
226 | 226 |
227 return 0; | 227 return 0; |
228 } | 228 } |
229 | 229 |
230 void | 230 void |
231 DirectFB_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay) | 231 DirectFB_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay) |
232 { | 232 { |
233 IDirectFBSurface *surface = overlay->hwdata->surface; | 233 IDirectFBSurface *surface = overlay->hwdata->surface; |
234 | 234 |
235 overlay->pixels[0] = overlay->pixels[1] = overlay->pixels[2] = NULL; | 235 overlay->pixels[0] = overlay->pixels[1] = overlay->pixels[2] = NULL; |
236 | 236 |
237 surface->Unlock (surface); | 237 surface->Unlock(surface); |
238 } | 238 } |
239 | 239 |
240 int | 240 int |
241 DirectFB_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, SDL_Rect * src, | 241 DirectFB_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src, |
242 SDL_Rect * dst) | 242 SDL_Rect * dst) |
243 { | 243 { |
244 DFBResult ret; | 244 DFBResult ret; |
245 DFBDisplayLayerConfig conf; | 245 DFBDisplayLayerConfig conf; |
246 IDirectFBDisplayLayer *primary = HIDDEN->layer; | 246 IDirectFBDisplayLayer *primary = HIDDEN->layer; |
247 IDirectFBDisplayLayer *layer = overlay->hwdata->layer; | 247 IDirectFBDisplayLayer *layer = overlay->hwdata->layer; |
248 | 248 |
249 primary->GetConfiguration (primary, &conf); | 249 primary->GetConfiguration(primary, &conf); |
250 | 250 |
251 ret = layer->SetScreenLocation (layer, | 251 ret = layer->SetScreenLocation(layer, |
252 dst->x / (float) conf.width, | 252 dst->x / (float) conf.width, |
253 dst->y / (float) conf.height, | 253 dst->y / (float) conf.height, |
254 dst->w / (float) conf.width, | 254 dst->w / (float) conf.width, |
255 dst->h / (float) conf.height); | 255 dst->h / (float) conf.height); |
256 if (ret) { | 256 if (ret) { |
257 SetDirectFBerror ("IDirectFBDisplayLayer::SetScreenLocation", ret); | 257 SetDirectFBerror("IDirectFBDisplayLayer::SetScreenLocation", ret); |
258 return -1; | 258 return -1; |
259 } | 259 } |
260 | 260 |
261 return 0; | 261 return 0; |
262 } | 262 } |
263 | 263 |
264 void | 264 void |
265 DirectFB_FreeYUVOverlay (_THIS, SDL_Overlay * overlay) | 265 DirectFB_FreeYUVOverlay(_THIS, SDL_Overlay * overlay) |
266 { | 266 { |
267 struct private_yuvhwdata *hwdata; | 267 struct private_yuvhwdata *hwdata; |
268 | 268 |
269 hwdata = overlay->hwdata; | 269 hwdata = overlay->hwdata; |
270 if (hwdata) { | 270 if (hwdata) { |
271 if (hwdata->surface) | 271 if (hwdata->surface) |
272 hwdata->surface->Release (hwdata->surface); | 272 hwdata->surface->Release(hwdata->surface); |
273 | 273 |
274 if (hwdata->layer) | 274 if (hwdata->layer) |
275 hwdata->layer->Release (hwdata->layer); | 275 hwdata->layer->Release(hwdata->layer); |
276 | 276 |
277 free (hwdata); | 277 free(hwdata); |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 /* vi: set ts=4 sw=4 expandtab: */ | 281 /* vi: set ts=4 sw=4 expandtab: */ |