comparison src/video/x11/SDL_x11render.c @ 4585:21600c6d6445

X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
author Sunny Sachanandani <sunnysachanandani@gmail.com>
date Tue, 15 Jun 2010 19:10:06 +0530
parents 9907c8cc6015
children e479c1e57c52
comparison
equal deleted inserted replaced
4584:9907c8cc6015 4585:21600c6d6445
797 X11_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, 797 X11_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
798 int count) 798 int count)
799 { 799 {
800 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; 800 X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
801 SDL_Window *window = renderer->window; 801 SDL_Window *window = renderer->window;
802 unsigned long foreground;
803 XPoint *xpoints, *xpoint; 802 XPoint *xpoints, *xpoint;
804 int i, xcount; 803 int i, xcount;
805 804
806 if (data->makedirty) { 805 if (data->makedirty) {
807 SDL_Rect rect; 806 SDL_Rect rect;
816 return 0; 815 return 0;
817 } 816 }
818 SDL_AddDirtyRect(&data->dirty, &rect); 817 SDL_AddDirtyRect(&data->dirty, &rect);
819 } 818 }
820 819
821 foreground = renderdrawcolor(renderer, 1);
822 XSetForeground(data->display, data->gc, foreground);
823
824 xpoint = xpoints = SDL_stack_alloc(XPoint, count); 820 xpoint = xpoints = SDL_stack_alloc(XPoint, count);
825 xcount = 0; 821 xcount = 0;
826 for (i = 0; i < count; ++i) { 822 for (i = 0; i < count; ++i) {
827 int x = points[i].x; 823 int x = points[i].x;
828 int y = points[i].y; 824 int y = points[i].y;
832 xpoint->x = (short)x; 828 xpoint->x = (short)x;
833 xpoint->y = (short)y; 829 xpoint->y = (short)y;
834 ++xpoint; 830 ++xpoint;
835 ++xcount; 831 ++xcount;
836 } 832 }
837 if (xcount > 0) { 833 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
838 XDrawPoints(data->display, data->drawable, data->gc, xpoints, xcount, 834 if (data->use_xrender == SDL_TRUE) {
835 XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict,
836 0, 0, 0, 0, 0, 0, window->w, window->h);
837 XDrawPoints(data->display, data->mask, data->mask_gc, xpoints, xcount,
839 CoordModeOrigin); 838 CoordModeOrigin);
839 XRenderColor foreground = xrenderdrawcolor(renderer);
840 Picture fill =
841 XRenderCreateSolidFill(data->display, &foreground);
842 XRenderComposite(data->display, PictOpOver, fill, data->mask_pict, data->drawable_pict,
843 0, 0, 0, 0, 0, 0, window->w, window->h);
844 XRenderFreePicture(data->display, fill);
845 }
846 else
847 #endif
848 {
849 unsigned long foreground = renderdrawcolor(renderer, 1);
850 XSetForeground(data->display, data->gc, foreground);
851
852
853 if (xcount > 0) {
854 XDrawPoints(data->display, data->drawable, data->gc, xpoints, xcount,
855 CoordModeOrigin);
856 }
840 } 857 }
841 SDL_stack_free(xpoints); 858 SDL_stack_free(xpoints);
842 859
843 return 0; 860 return 0;
844 } 861 }
858 875
859 clip.x = 0; 876 clip.x = 0;
860 clip.y = 0; 877 clip.y = 0;
861 clip.w = window->w; 878 clip.w = window->w;
862 clip.h = window->h; 879 clip.h = window->h;
880
881 Pixmap drawable;
882 GC gc;
883 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
884 if (data->use_xrender == SDL_TRUE) {
885 drawable = data->mask;
886 gc = data->mask_gc;
887 XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict,
888 0, 0, 0, 0, 0, 0, window->w, window->h);
889 }
890 else
891 #endif
892 {
893 drawable = data->drawable;
894 gc = data->gc;
895 }
863 896
864 foreground = renderdrawcolor(renderer, 1); 897 foreground = renderdrawcolor(renderer, 1);
865 XSetForeground(data->display, data->gc, foreground); 898 XSetForeground(data->display, data->gc, foreground);
866 899
867 xpoint = xpoints = SDL_stack_alloc(XPoint, count); 900 xpoint = xpoints = SDL_stack_alloc(XPoint, count);
913 xpoint->x = (short)x2; 946 xpoint->x = (short)x2;
914 xpoint->y = (short)y2; 947 xpoint->y = (short)y2;
915 ++xpoint; 948 ++xpoint;
916 ++xcount; 949 ++xcount;
917 } 950 }
918 XDrawLines(data->display, data->drawable, data->gc, 951 XDrawLines(data->display, drawable, gc,
919 xpoints, xcount, CoordModeOrigin); 952 xpoints, xcount, CoordModeOrigin);
920 if (xpoints[0].x != x2 || xpoints[0].y != y2) { 953 if (xpoints[0].x != x2 || xpoints[0].y != y2) {
921 XDrawPoint(data->display, data->drawable, data->gc, x2, y2); 954 XDrawPoint(data->display, drawable, gc, x2, y2);
922 } 955 }
923 if (data->makedirty) { 956 if (data->makedirty) {
924 SDL_Rect rect; 957 SDL_Rect rect;
925 958
926 rect.x = minx; 959 rect.x = minx;
960 } 993 }
961 } 994 }
962 if (xcount > 1) { 995 if (xcount > 1) {
963 int x2 = xpoint[-1].x; 996 int x2 = xpoint[-1].x;
964 int y2 = xpoint[-1].y; 997 int y2 = xpoint[-1].y;
965 XDrawLines(data->display, data->drawable, data->gc, xpoints, xcount, 998 XDrawLines(data->display, drawable, gc, xpoints, xcount,
966 CoordModeOrigin); 999 CoordModeOrigin);
967 if (xpoints[0].x != x2 || xpoints[0].y != y2) { 1000 if (xpoints[0].x != x2 || xpoints[0].y != y2) {
968 XDrawPoint(data->display, data->drawable, data->gc, x2, y2); 1001 XDrawPoint(data->display, drawable, gc, x2, y2);
969 } 1002 }
970 if (data->makedirty) { 1003 if (data->makedirty) {
971 SDL_Rect rect; 1004 SDL_Rect rect;
972 1005
973 rect.x = minx; 1006 rect.x = minx;
975 rect.w = (maxx - minx) + 1; 1008 rect.w = (maxx - minx) + 1;
976 rect.h = (maxy - miny) + 1; 1009 rect.h = (maxy - miny) + 1;
977 SDL_AddDirtyRect(&data->dirty, &rect); 1010 SDL_AddDirtyRect(&data->dirty, &rect);
978 } 1011 }
979 } 1012 }
1013 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1014 if(data->use_xrender == SDL_TRUE) {
1015 XRenderColor xrforeground = xrenderdrawcolor(renderer);
1016 Picture fill = XRenderCreateSolidFill(data->display, &xrforeground);
1017 XRenderComposite(data->display, PictOpOver, fill, data->mask_pict, data->drawable_pict,
1018 0, 0, 0, 0, 0, 0, window->w, window->h);
1019 XRenderFreePicture(data->display, fill);
1020 }
1021 #endif
980 SDL_stack_free(xpoints); 1022 SDL_stack_free(xpoints);
981 1023
982 return 0; 1024 return 0;
983 } 1025 }
984 1026