comparison src/video/x11/SDL_x11render.c @ 3596:f638ded38b8a

Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color. Renamed SDL_RenderPoint() and SDL_RenderLine() to SDL_RenderDrawPoint() and SDL_RenderDrawLine(). Added API for rectangle drawing (as opposed to filling) Added placeholder API functions for circles and ellipses ... I'm not sure whether these will stay. Optimized software line drawing quite a bit. Added support for Wu's anti-aliased line drawing, currently disabled by default.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 23 Dec 2009 01:55:00 +0000
parents 5f26a7eb5ff0
children 64ce267332c6
comparison
equal deleted inserted replaced
3595:b7c6828d4039 3596:f638ded38b8a
48 static int X11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, 48 static int X11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
49 const SDL_Rect * rect, int markDirty, 49 const SDL_Rect * rect, int markDirty,
50 void **pixels, int *pitch); 50 void **pixels, int *pitch);
51 static void X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); 51 static void X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
52 static int X11_SetDrawBlendMode(SDL_Renderer * renderer); 52 static int X11_SetDrawBlendMode(SDL_Renderer * renderer);
53 static int X11_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, 53 static int X11_RenderDrawPoints(SDL_Renderer * renderer,
54 int count); 54 const SDL_Point * points, int count);
55 static int X11_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, 55 static int X11_RenderDrawLines(SDL_Renderer * renderer,
56 int count); 56 const SDL_Point * points, int count);
57 static int X11_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, 57 static int X11_RenderDrawRects(SDL_Renderer * renderer,
58 int count); 58 const SDL_Rect ** rects, int count);
59 static int X11_RenderFillRects(SDL_Renderer * renderer,
60 const SDL_Rect ** rects, int count);
59 static int X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 61 static int X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
60 const SDL_Rect * srcrect, const SDL_Rect * dstrect); 62 const SDL_Rect * srcrect, const SDL_Rect * dstrect);
61 static int X11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, 63 static int X11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
62 Uint32 format, void * pixels, int pitch); 64 Uint32 format, void * pixels, int pitch);
63 static int X11_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, 65 static int X11_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
206 renderer->SetTextureScaleMode = X11_SetTextureScaleMode; 208 renderer->SetTextureScaleMode = X11_SetTextureScaleMode;
207 renderer->UpdateTexture = X11_UpdateTexture; 209 renderer->UpdateTexture = X11_UpdateTexture;
208 renderer->LockTexture = X11_LockTexture; 210 renderer->LockTexture = X11_LockTexture;
209 renderer->UnlockTexture = X11_UnlockTexture; 211 renderer->UnlockTexture = X11_UnlockTexture;
210 renderer->SetDrawBlendMode = X11_SetDrawBlendMode; 212 renderer->SetDrawBlendMode = X11_SetDrawBlendMode;
211 renderer->RenderPoints = X11_RenderPoints; 213 renderer->RenderDrawPoints = X11_RenderDrawPoints;
212 renderer->RenderLines = X11_RenderLines; 214 renderer->RenderDrawLines = X11_RenderDrawLines;
213 renderer->RenderRects = X11_RenderRects; 215 renderer->RenderDrawRects = X11_RenderDrawRects;
216 renderer->RenderFillRects = X11_RenderFillRects;
214 renderer->RenderCopy = X11_RenderCopy; 217 renderer->RenderCopy = X11_RenderCopy;
215 renderer->RenderReadPixels = X11_RenderReadPixels; 218 renderer->RenderReadPixels = X11_RenderReadPixels;
216 renderer->RenderWritePixels = X11_RenderWritePixels; 219 renderer->RenderWritePixels = X11_RenderWritePixels;
217 renderer->RenderPresent = X11_RenderPresent; 220 renderer->RenderPresent = X11_RenderPresent;
218 renderer->DestroyTexture = X11_DestroyTexture; 221 renderer->DestroyTexture = X11_DestroyTexture;
598 else 601 else
599 return SDL_MapRGBA(&data->format, r, g, b, a); 602 return SDL_MapRGBA(&data->format, r, g, b, a);
600 } 603 }
601 604
602 static int 605 static int
603 X11_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count) 606 X11_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
607 int count)
604 { 608 {
605 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; 609 X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
606 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 610 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
607 unsigned long foreground; 611 unsigned long foreground;
608 XPoint *xpoints, *xpoint; 612 XPoint *xpoints, *xpoint;
647 651
648 return 0; 652 return 0;
649 } 653 }
650 654
651 static int 655 static int
652 X11_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count) 656 X11_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
657 int count)
653 { 658 {
654 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; 659 X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
655 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 660 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
656 SDL_Rect clip, rect; 661 SDL_Rect clip, rect;
657 unsigned long foreground; 662 unsigned long foreground;
785 790
786 return 0; 791 return 0;
787 } 792 }
788 793
789 static int 794 static int
790 X11_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) 795 X11_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
796 {
797 X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
798 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
799 SDL_Rect clip, rect;
800 unsigned long foreground;
801 XRectangle *xrects, *xrect;
802 int i, xcount;
803
804 clip.x = 0;
805 clip.y = 0;
806 clip.w = window->w;
807 clip.h = window->h;
808
809 foreground = renderdrawcolor(renderer, 1);
810 XSetForeground(data->display, data->gc, foreground);
811
812 xrect = xrects = SDL_stack_alloc(XRectangle, count);
813 xcount = 0;
814 for (i = 0; i < count; ++i) {
815 if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
816 continue;
817 }
818
819 xrect->x = (short)rect.x;
820 xrect->y = (short)rect.y;
821 xrect->width = (unsigned short)rect.w;
822 xrect->height = (unsigned short)rect.h;
823 ++xrect;
824 ++xcount;
825
826 if (data->makedirty) {
827 SDL_AddDirtyRect(&data->dirty, &rect);
828 }
829 }
830 if (xcount > 0) {
831 XDrawRectangles(data->display, data->drawable, data->gc,
832 xrects, xcount);
833 }
834 SDL_stack_free(xpoints);
835
836 return 0;
837 }
838
839 static int
840 X11_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
791 { 841 {
792 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; 842 X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
793 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 843 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
794 SDL_Rect clip, rect; 844 SDL_Rect clip, rect;
795 unsigned long foreground; 845 unsigned long foreground;