Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_sw.c @ 5151:5429daf5e3f9
The DrawRect API is implemented using lines
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 01 Feb 2011 20:50:04 -0800 |
parents | ad50b3db78bd |
children | be02be2ea897 |
comparison
equal
deleted
inserted
replaced
5150:ad50b3db78bd | 5151:5429daf5e3f9 |
---|---|
60 static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); | 60 static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
61 static int SW_RenderDrawPoints(SDL_Renderer * renderer, | 61 static int SW_RenderDrawPoints(SDL_Renderer * renderer, |
62 const SDL_Point * points, int count); | 62 const SDL_Point * points, int count); |
63 static int SW_RenderDrawLines(SDL_Renderer * renderer, | 63 static int SW_RenderDrawLines(SDL_Renderer * renderer, |
64 const SDL_Point * points, int count); | 64 const SDL_Point * points, int count); |
65 static int SW_RenderDrawRects(SDL_Renderer * renderer, | |
66 const SDL_Rect ** rects, int count); | |
67 static int SW_RenderFillRects(SDL_Renderer * renderer, | 65 static int SW_RenderFillRects(SDL_Renderer * renderer, |
68 const SDL_Rect ** rects, int count); | 66 const SDL_Rect ** rects, int count); |
69 static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, | 67 static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
70 const SDL_Rect * srcrect, const SDL_Rect * dstrect); | 68 const SDL_Rect * srcrect, const SDL_Rect * dstrect); |
71 static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, | 69 static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
214 } | 212 } |
215 renderer->WindowEvent = SW_WindowEvent; | 213 renderer->WindowEvent = SW_WindowEvent; |
216 | 214 |
217 renderer->RenderDrawPoints = SW_RenderDrawPoints; | 215 renderer->RenderDrawPoints = SW_RenderDrawPoints; |
218 renderer->RenderDrawLines = SW_RenderDrawLines; | 216 renderer->RenderDrawLines = SW_RenderDrawLines; |
219 renderer->RenderDrawRects = SW_RenderDrawRects; | |
220 renderer->RenderFillRects = SW_RenderFillRects; | 217 renderer->RenderFillRects = SW_RenderFillRects; |
221 renderer->RenderCopy = SW_RenderCopy; | 218 renderer->RenderCopy = SW_RenderCopy; |
222 renderer->RenderReadPixels = SW_RenderReadPixels; | 219 renderer->RenderReadPixels = SW_RenderReadPixels; |
223 renderer->RenderWritePixels = SW_RenderWritePixels; | 220 renderer->RenderWritePixels = SW_RenderWritePixels; |
224 renderer->RenderPresent = SW_RenderPresent; | 221 renderer->RenderPresent = SW_RenderPresent; |
607 | 604 |
608 return status; | 605 return status; |
609 } | 606 } |
610 | 607 |
611 static int | 608 static int |
612 SW_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, | |
613 int count) | |
614 { | |
615 SW_RenderData *data = (SW_RenderData *) renderer->driverdata; | |
616 SDL_Texture *texture = SW_ActivateRenderer(renderer); | |
617 SDL_Rect clip, rect; | |
618 Uint32 color = 0; | |
619 int i; | |
620 int status = 0; | |
621 | |
622 if (!texture) { | |
623 return -1; | |
624 } | |
625 | |
626 clip.x = 0; | |
627 clip.y = 0; | |
628 clip.w = texture->w; | |
629 clip.h = texture->h; | |
630 | |
631 if (renderer->blendMode == SDL_BLENDMODE_NONE) { | |
632 color = SDL_MapRGBA(data->surface.format, | |
633 renderer->r, renderer->g, renderer->b, | |
634 renderer->a); | |
635 } | |
636 | |
637 for (i = 0; i < count; ++i) { | |
638 /* FIXME: We don't want to draw clipped edges */ | |
639 if (!SDL_IntersectRect(rects[i], &clip, &rect)) { | |
640 /* Nothing to draw */ | |
641 continue; | |
642 } | |
643 | |
644 if (data->renderer->LockTexture(data->renderer, texture, &rect, 1, | |
645 &data->surface.pixels, | |
646 &data->surface.pitch) < 0) { | |
647 return -1; | |
648 } | |
649 | |
650 data->surface.clip_rect.w = data->surface.w = rect.w; | |
651 data->surface.clip_rect.h = data->surface.h = rect.h; | |
652 | |
653 if (renderer->blendMode == SDL_BLENDMODE_NONE) { | |
654 status = SDL_DrawRect(&data->surface, NULL, color); | |
655 } else { | |
656 status = SDL_BlendRect(&data->surface, NULL, | |
657 renderer->blendMode, | |
658 renderer->r, renderer->g, renderer->b, | |
659 renderer->a); | |
660 } | |
661 | |
662 data->renderer->UnlockTexture(data->renderer, texture); | |
663 } | |
664 return status; | |
665 } | |
666 | |
667 static int | |
668 SW_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, | 609 SW_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
669 int count) | 610 int count) |
670 { | 611 { |
671 SW_RenderData *data = (SW_RenderData *) renderer->driverdata; | 612 SW_RenderData *data = (SW_RenderData *) renderer->driverdata; |
672 SDL_Texture *texture = SW_ActivateRenderer(renderer); | 613 SDL_Texture *texture = SW_ActivateRenderer(renderer); |