comparison src/video/SDL_renderer_sw.c @ 2901:133601e3b255

Added RenderPiont() API Merged the drawing tests into a single test program
author Sam Lantinga <slouken@libsdl.org>
date Sun, 21 Dec 2008 17:39:41 +0000
parents 3e7856518a34
children fa81cc1ef3d0
comparison
equal deleted inserted replaced
2900:3a9636c83849 2901:133601e3b255
59 const SDL_Rect * rect, int markDirty, void **pixels, 59 const SDL_Rect * rect, int markDirty, void **pixels,
60 int *pitch); 60 int *pitch);
61 static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); 61 static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
62 static int SW_SetDrawColor(SDL_Renderer * renderer); 62 static int SW_SetDrawColor(SDL_Renderer * renderer);
63 static int SW_SetDrawBlendMode(SDL_Renderer * renderer); 63 static int SW_SetDrawBlendMode(SDL_Renderer * renderer);
64 static int SW_RenderPoint(SDL_Renderer * renderer, int x, int y);
64 static int SW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, 65 static int SW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
65 int y2); 66 int y2);
66 static int SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect); 67 static int SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
67 static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 68 static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
68 const SDL_Rect * srcrect, const SDL_Rect * dstrect); 69 const SDL_Rect * srcrect, const SDL_Rect * dstrect);
225 renderer->ActivateRenderer = SW_ActivateRenderer; 226 renderer->ActivateRenderer = SW_ActivateRenderer;
226 renderer->DisplayModeChanged = SW_DisplayModeChanged; 227 renderer->DisplayModeChanged = SW_DisplayModeChanged;
227 228
228 renderer->SetDrawColor = SW_SetDrawColor; 229 renderer->SetDrawColor = SW_SetDrawColor;
229 renderer->SetDrawBlendMode = SW_SetDrawBlendMode; 230 renderer->SetDrawBlendMode = SW_SetDrawBlendMode;
231 renderer->RenderPoint = SW_RenderPoint;
230 renderer->RenderLine = SW_RenderLine; 232 renderer->RenderLine = SW_RenderLine;
231 renderer->RenderFill = SW_RenderFill; 233 renderer->RenderFill = SW_RenderFill;
232 renderer->RenderCopy = SW_RenderCopy; 234 renderer->RenderCopy = SW_RenderCopy;
233 renderer->RenderPresent = SW_RenderPresent; 235 renderer->RenderPresent = SW_RenderPresent;
234 renderer->DestroyRenderer = SW_DestroyRenderer; 236 renderer->DestroyRenderer = SW_DestroyRenderer;
536 { 538 {
537 return 0; 539 return 0;
538 } 540 }
539 541
540 static int 542 static int
543 SW_RenderPoint(SDL_Renderer * renderer, int x, int y)
544 {
545 SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
546 int status;
547
548 if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
549 SDL_Rect rect;
550
551 rect.x = x;
552 rect.y = y;
553 rect.w = 1;
554 rect.h = 1;
555 SDL_AddDirtyRect(&data->dirty, &rect);
556 }
557
558 if (data->renderer->LockTexture(data->renderer,
559 data->texture[data->current_texture],
560 &data->surface.clip_rect, 1,
561 &data->surface.pixels,
562 &data->surface.pitch) < 0) {
563 return -1;
564 }
565
566 if (renderer->blendMode == SDL_BLENDMODE_NONE ||
567 renderer->blendMode == SDL_BLENDMODE_MASK) {
568 Uint32 color =
569 SDL_MapRGBA(data->surface.format, renderer->r, renderer->g,
570 renderer->b, renderer->a);
571
572 status = SDL_DrawPoint(&data->surface, x, y, color);
573 } else {
574 status =
575 SDL_BlendPoint(&data->surface, x, y, renderer->blendMode,
576 renderer->r, renderer->g, renderer->b,
577 renderer->a);
578 }
579
580 data->renderer->UnlockTexture(data->renderer,
581 data->texture[data->current_texture]);
582 return status;
583 }
584
585 static int
541 SW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) 586 SW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
542 { 587 {
543 SW_RenderData *data = (SW_RenderData *) renderer->driverdata; 588 SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
544 int status; 589 int status;
545 590
569 &data->surface.pixels, 614 &data->surface.pixels,
570 &data->surface.pitch) < 0) { 615 &data->surface.pitch) < 0) {
571 return -1; 616 return -1;
572 } 617 }
573 618
574 if (renderer->blendMode == SDL_BLENDMODE_NONE) { 619 if (renderer->blendMode == SDL_BLENDMODE_NONE ||
620 renderer->blendMode == SDL_BLENDMODE_MASK) {
575 Uint32 color = 621 Uint32 color =
576 SDL_MapRGBA(data->surface.format, renderer->r, renderer->g, 622 SDL_MapRGBA(data->surface.format, renderer->r, renderer->g,
577 renderer->b, renderer->a); 623 renderer->b, renderer->a);
578 624
579 status = SDL_DrawLine(&data->surface, x1, y1, x2, y2, color); 625 status = SDL_DrawLine(&data->surface, x1, y1, x2, y2, color);