comparison src/video/SDL_renderer_sw.c @ 1680:9488fca10677 SDL-1.3

Dummy video driver works again in high color video modes. Yay!
author Sam Lantinga <slouken@libsdl.org>
date Wed, 14 Jun 2006 08:41:13 +0000
parents 90bf530ced8e
children 80a5e6a4e1e2
comparison
equal deleted inserted replaced
1679:153477a6cc31 1680:9488fca10677
31 static int SDL_SW_CreateTexture(SDL_Renderer * renderer, 31 static int SDL_SW_CreateTexture(SDL_Renderer * renderer,
32 SDL_Texture * texture); 32 SDL_Texture * texture);
33 static int SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, 33 static int SDL_SW_QueryTexturePixels(SDL_Renderer * renderer,
34 SDL_Texture * texture, void **pixels, 34 SDL_Texture * texture, void **pixels,
35 int *pitch); 35 int *pitch);
36 static int SDL_SW_SetTexturePalette(SDL_Renderer * renderer,
37 SDL_Texture * texture, SDL_Color * colors,
38 int firstcolor, int ncolors);
36 static int SDL_SW_UpdateTexture(SDL_Renderer * renderer, 39 static int SDL_SW_UpdateTexture(SDL_Renderer * renderer,
37 SDL_Texture * texture, SDL_Rect * rect, 40 SDL_Texture * texture, SDL_Rect * rect,
38 const void *pixels, int pitch); 41 const void *pixels, int pitch);
39 static int SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, 42 static int SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
40 SDL_Rect * rect, int markDirty, void **pixels, 43 SDL_Rect * rect, int markDirty, void **pixels,
128 } 131 }
129 SDL_zerop(data); 132 SDL_zerop(data);
130 133
131 renderer->CreateTexture = SDL_SW_CreateTexture; 134 renderer->CreateTexture = SDL_SW_CreateTexture;
132 renderer->QueryTexturePixels = SDL_SW_QueryTexturePixels; 135 renderer->QueryTexturePixels = SDL_SW_QueryTexturePixels;
136 renderer->SetTexturePalette = SDL_SW_SetTexturePalette;
133 renderer->UpdateTexture = SDL_SW_UpdateTexture; 137 renderer->UpdateTexture = SDL_SW_UpdateTexture;
134 renderer->LockTexture = SDL_SW_LockTexture; 138 renderer->LockTexture = SDL_SW_LockTexture;
135 renderer->UnlockTexture = SDL_SW_UnlockTexture; 139 renderer->UnlockTexture = SDL_SW_UnlockTexture;
136 renderer->DirtyTexture = SDL_SW_DirtyTexture; 140 renderer->DirtyTexture = SDL_SW_DirtyTexture;
137 renderer->SelectRenderTexture = SDL_SW_SelectRenderTexture; 141 renderer->SelectRenderTexture = SDL_SW_SelectRenderTexture;
187 return NULL; 191 return NULL;
188 } 192 }
189 return renderer; 193 return renderer;
190 } 194 }
191 195
192 int 196 static int
193 SDL_SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) 197 SDL_SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
194 { 198 {
195 SDL_Surface *surface; 199 SDL_Surface *surface;
196 int bpp; 200 int bpp;
197 Uint32 Rmask, Gmask, Bmask, Amask; 201 Uint32 Rmask, Gmask, Bmask, Amask;
216 220
217 texture->driverdata = surface; 221 texture->driverdata = surface;
218 return 0; 222 return 0;
219 } 223 }
220 224
221 int 225 static int
222 SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, 226 SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
223 void **pixels, int *pitch) 227 void **pixels, int *pitch)
224 { 228 {
225 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; 229 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
226 230
227 *pixels = surface->pixels; 231 *pixels = surface->pixels;
228 *pitch = surface->pitch; 232 *pitch = surface->pitch;
229 return 0; 233 return 0;
230 } 234 }
231 235
232 int 236 static int
237 SDL_SW_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
238 SDL_Color * colors, int firstcolor, int ncolors)
239 {
240 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
241
242 SDL_SetColors(surface, colors, firstcolor, ncolors);
243 return 0;
244 }
245
246 static int
233 SDL_SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, 247 SDL_SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
234 SDL_Rect * rect, const void *pixels, int pitch) 248 SDL_Rect * rect, const void *pixels, int pitch)
235 { 249 {
236 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; 250 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
237 Uint8 *src, *dst; 251 Uint8 *src, *dst;
249 dst += surface->pitch; 263 dst += surface->pitch;
250 } 264 }
251 return 0; 265 return 0;
252 } 266 }
253 267
254 int 268 static int
255 SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, 269 SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
256 SDL_Rect * rect, int markDirty, void **pixels, int *pitch) 270 SDL_Rect * rect, int markDirty, void **pixels, int *pitch)
257 { 271 {
258 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; 272 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
259 273
262 rect->x * surface->format->BytesPerPixel); 276 rect->x * surface->format->BytesPerPixel);
263 *pitch = surface->pitch; 277 *pitch = surface->pitch;
264 return 0; 278 return 0;
265 } 279 }
266 280
267 void 281 static void
268 SDL_SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) 282 SDL_SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
269 { 283 {
270 } 284 }
271 285
272 void 286 static void
273 SDL_SW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, 287 SDL_SW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
274 int numrects, SDL_Rect * rects) 288 int numrects, SDL_Rect * rects)
275 { 289 {
276 } 290 }
277 291
278 void 292 static void
279 SDL_SW_SelectRenderTexture(SDL_Renderer * renderer, SDL_Texture * texture) 293 SDL_SW_SelectRenderTexture(SDL_Renderer * renderer, SDL_Texture * texture)
280 { 294 {
281 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; 295 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
282 data->target = (SDL_Surface *) texture->driverdata; 296 data->target = (SDL_Surface *) texture->driverdata;
283 } 297 }
284 298
285 void 299 static void
286 SDL_SW_RenderFill(SDL_Renderer * renderer, SDL_Rect * rect, Uint32 color) 300 SDL_SW_RenderFill(SDL_Renderer * renderer, SDL_Rect * rect, Uint32 color)
287 { 301 {
288 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; 302 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
289 Uint8 r, g, b, a; 303 Uint8 r, g, b, a;
290 304
295 color = SDL_MapRGBA(data->target->format, r, g, b, a); 309 color = SDL_MapRGBA(data->target->format, r, g, b, a);
296 310
297 SDL_FillRect(data->target, rect, color); 311 SDL_FillRect(data->target, rect, color);
298 } 312 }
299 313
300 int 314 static int
301 SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 315 SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
302 SDL_Rect * srcrect, SDL_Rect * dstrect, int blendMode, 316 SDL_Rect * srcrect, SDL_Rect * dstrect, int blendMode,
303 int scaleMode) 317 int scaleMode)
304 { 318 {
305 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; 319 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
316 } else { 330 } else {
317 return SDL_LowerBlit(surface, srcrect, data->target, dstrect); 331 return SDL_LowerBlit(surface, srcrect, data->target, dstrect);
318 } 332 }
319 } 333 }
320 334
321 int 335 static int
322 SDL_SW_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect, 336 SDL_SW_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect,
323 void *pixels, int pitch) 337 void *pixels, int pitch)
324 { 338 {
325 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; 339 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
326 SDL_Surface *surface = data->target; 340 SDL_Surface *surface = data->target;
339 dst += pitch; 353 dst += pitch;
340 } 354 }
341 return 0; 355 return 0;
342 } 356 }
343 357
344 int 358 static int
345 SDL_SW_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect, 359 SDL_SW_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect,
346 const void *pixels, int pitch) 360 const void *pixels, int pitch)
347 { 361 {
348 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; 362 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
349 SDL_Surface *surface = data->target; 363 SDL_Surface *surface = data->target;
362 dst += surface->pitch; 376 dst += surface->pitch;
363 } 377 }
364 return 0; 378 return 0;
365 } 379 }
366 380
367 void 381 static void
368 SDL_SW_RenderPresent(SDL_Renderer * renderer) 382 SDL_SW_RenderPresent(SDL_Renderer * renderer)
369 { 383 {
370 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; 384 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
371 SDL_Surface *surface = data->screens[data->current_screen]; 385 SDL_Surface *surface = data->screens[data->current_screen];
372 SDL_Rect rect; 386 SDL_Rect rect;
394 data->target = data->screens[new_screen]; 408 data->target = data->screens[new_screen];
395 } 409 }
396 data->current_screen = new_screen; 410 data->current_screen = new_screen;
397 } 411 }
398 412
399 void 413 static void
400 SDL_SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) 414 SDL_SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
401 { 415 {
402 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; 416 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
403 417
404 SDL_FreeSurface(surface); 418 SDL_FreeSurface(surface);
405 } 419 }
406 420
407 void 421 static void
408 SDL_SW_DestroyRenderer(SDL_Renderer * renderer) 422 SDL_SW_DestroyRenderer(SDL_Renderer * renderer)
409 { 423 {
410 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; 424 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
411 int i; 425 int i;
412 426