Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11render.c @ 4599:ce0643707bb0 experimental
Minor changes.
author | Sunny Sachanandani <sunnysachanandani@gmail.com> |
---|---|
date | Sun, 18 Jul 2010 18:42:33 +0530 |
parents | 66e13a224bd6 |
children |
rev | line source |
---|---|
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
2 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 SDL - Simple DirectMedia Layer |
3697 | 4 Copyright (C) 1997-2010 Sam Lantinga |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 This library is free software; you can redistribute it and/or |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 modify it under the terms of the GNU Lesser General Public |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 License as published by the Free Software Foundation; either |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 version 2.1 of the License, or (at your option) any later version. |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 This library is distributed in the hope that it will be useful, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 Lesser General Public License for more details. |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 You should have received a copy of the GNU Lesser General Public |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 License along with this library; if not, write to the Free Software |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 Sam Lantinga |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 slouken@libsdl.org |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 #include "SDL_config.h" |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #if SDL_VIDEO_RENDER_X11 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
27 #include <limits.h> /* For INT_MIN and INT_MAX */ |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
28 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include "SDL_x11video.h" |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #include "../SDL_rect_c.h" |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 #include "../SDL_pixels_c.h" |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #include "../SDL_yuv_sw_c.h" |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
33 #include "SDL_surface.h" |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
35 #define EXPT |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
36 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 /* X11 renderer implementation */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 static SDL_Renderer *X11_CreateRenderer(SDL_Window * window, Uint32 flags); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 static int X11_DisplayModeChanged(SDL_Renderer * renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 static int X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 static int X11_QueryTexturePixels(SDL_Renderer * renderer, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 SDL_Texture * texture, void **pixels, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 int *pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 static int X11_SetTextureBlendMode(SDL_Renderer * renderer, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 static int X11_SetTextureScaleMode(SDL_Renderer * renderer, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 static int X11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 const SDL_Rect * rect, const void *pixels, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 int pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 static int X11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 const SDL_Rect * rect, int markDirty, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 void **pixels, int *pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 static void X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
56 static int X11_SetDrawBlendMode(SDL_Renderer * renderer); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
57 static int X11_RenderDrawPoints(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
58 const SDL_Point * points, int count); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
59 static int X11_RenderDrawLines(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
60 const SDL_Point * points, int count); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
61 static int X11_RenderDrawRects(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
62 const SDL_Rect ** rects, int count); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
63 static int X11_RenderFillRects(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
64 const SDL_Rect ** rects, int count); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 static int X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 const SDL_Rect * srcrect, const SDL_Rect * dstrect); |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
67 static int X11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
68 Uint32 format, void * pixels, int pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
69 static int X11_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
70 Uint32 format, const void * pixels, int pitch); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 static void X11_RenderPresent(SDL_Renderer * renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 static void X11_DestroyTexture(SDL_Renderer * renderer, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 static void X11_DestroyRenderer(SDL_Renderer * renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 SDL_RenderDriver X11_RenderDriver = { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 X11_CreateRenderer, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 "x11", |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED), |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 SDL_TEXTUREMODULATE_NONE, |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
85 SDL_BLENDMODE_NONE, |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 SDL_TEXTURESCALEMODE_NONE, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 0, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 {0}, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 0, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 0} |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 }; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 typedef struct |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 Display *display; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 int screen; |
2870
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
97 Visual *visual; |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
98 int depth; |
2916
ffdd533f7add
Fixed pitch alignment problem causing MITSHM error on 16-bit displays
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
99 int scanline_pad; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
100 Window xwindow; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 Pixmap pixmaps[3]; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
102 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
103 Pixmap stencil; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
104 Pixmap brush; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
105 Picture brush_pict; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
106 #ifndef NO_SHARED_MEMORY |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
107 #ifdef EXPT |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
108 XImage *stencil_image; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
109 SDL_Surface *stencil_surface; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
110 XShmSegmentInfo stencil_shminfo; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
111 #endif |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
112 #endif |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
113 Picture xwindow_pict; |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
114 Picture pixmap_picts[3]; |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
115 Picture drawable_pict; |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
116 Picture stencil_pict; |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
117 int blend_op; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
118 XRenderPictFormat* xwindow_pict_fmt; |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
119 GC stencil_gc; |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
120 SDL_bool use_xrender; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
121 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 int current_pixmap; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 Drawable drawable; |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
124 SDL_PixelFormat format; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 GC gc; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 SDL_DirtyRectList dirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 SDL_bool makedirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 } X11_RenderData; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 typedef struct |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 SDL_SW_YUVTexture *yuv; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 Uint32 format; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 Pixmap pixmap; |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
135 int depth; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
136 Visual *visual; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
137 GC gc; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
138 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
139 Picture picture; |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
140 XRenderPictFormat* picture_fmt; |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
141 int blend_op; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
142 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 XImage *image; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 /* MIT shared memory extension information */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 XShmSegmentInfo shminfo; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 #endif |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
148 XImage *scaling_image; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 void *pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 int pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 } X11_TextureData; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 /* Shared memory error handler routine */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 static int shm_error; |
2814 | 156 static int (*X_handler) (Display *, XErrorEvent *) = NULL; |
157 static int | |
158 shm_errhandler(Display * d, XErrorEvent * e) | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 { |
2814 | 160 if (e->error_code == BadAccess) { |
161 shm_error = True; | |
162 return (0); | |
163 } else { | |
164 return (X_handler(d, e)); | |
165 } | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 #endif /* ! NO_SHARED_MEMORY */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 UpdateYUVTextureData(SDL_Texture * texture) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 X11_TextureData *data = (X11_TextureData *) texture->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 SDL_Rect rect; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 rect.x = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 rect.y = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 rect.w = texture->w; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 rect.h = texture->h; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 texture->h, data->pixels, data->pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 X11_AddRenderDriver(_THIS) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 SDL_RendererInfo *info = &X11_RenderDriver.info; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
187 SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode; |
3520
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
188 int i; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 |
2870
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
190 info->texture_formats[info->num_texture_formats++] = mode->format; |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
191 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YV12; |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
192 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_IYUV; |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
193 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2; |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
194 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_UYVY; |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
195 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; |
4596
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
196 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_ARGB8888; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 |
3520
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
198 for (i = 0; i < _this->num_displays; ++i) { |
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
199 SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver); |
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
200 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 SDL_Renderer * |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 X11_CreateRenderer(SDL_Window * window, Uint32 flags) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
206 SDL_VideoDisplay *display = window->display; |
2870
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
207 SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 SDL_Renderer *renderer; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 X11_RenderData *data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 XGCValues gcv; |
4596
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
212 gcv.graphics_exposures = False; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 int i, n; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 int bpp; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 Uint32 Rmask, Gmask, Bmask, Amask; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 if (!renderer) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 data = (X11_RenderData *) SDL_calloc(1, sizeof(*data)); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 data->display = windowdata->videodata->display; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 data->screen = displaydata->screen; |
2870
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
231 data->visual = displaydata->visual; |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
232 data->depth = displaydata->depth; |
2916
ffdd533f7add
Fixed pitch alignment problem causing MITSHM error on 16-bit displays
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
233 data->scanline_pad = displaydata->scanline_pad; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
234 data->xwindow = windowdata->xwindow; |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
235 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 renderer->DisplayModeChanged = X11_DisplayModeChanged; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 renderer->CreateTexture = X11_CreateTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 renderer->QueryTexturePixels = X11_QueryTexturePixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 renderer->SetTextureBlendMode = X11_SetTextureBlendMode; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 renderer->SetTextureScaleMode = X11_SetTextureScaleMode; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 renderer->UpdateTexture = X11_UpdateTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 renderer->LockTexture = X11_LockTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 renderer->UnlockTexture = X11_UnlockTexture; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
244 renderer->SetDrawBlendMode = X11_SetDrawBlendMode; |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
245 renderer->RenderDrawPoints = X11_RenderDrawPoints; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
246 renderer->RenderDrawLines = X11_RenderDrawLines; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
247 renderer->RenderDrawRects = X11_RenderDrawRects; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
248 renderer->RenderFillRects = X11_RenderFillRects; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 renderer->RenderCopy = X11_RenderCopy; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
250 renderer->RenderReadPixels = X11_RenderReadPixels; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
251 renderer->RenderWritePixels = X11_RenderWritePixels; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 renderer->RenderPresent = X11_RenderPresent; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 renderer->DestroyTexture = X11_DestroyTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 renderer->DestroyRenderer = X11_DestroyRenderer; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 renderer->info = X11_RenderDriver.info; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
256 renderer->window = window; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 renderer->driverdata = data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 renderer->info.flags = SDL_RENDERER_ACCELERATED; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
261 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
262 data->use_xrender = SDL_FALSE; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
263 if (SDL_X11_HAVE_XRENDER) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
264 // Query the extension. This is the server runtime check. |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
265 int event_basep, error_basep; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
266 if(XRenderQueryExtension(data->display, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
267 &event_basep, &error_basep) == True) |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
268 data->use_xrender = SDL_TRUE; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
269 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
270 if (data->use_xrender) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
271 // Find the PictFormat from the visual. |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
272 // Should be an RGB PictFormat most of the time. |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
273 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
274 data->visual); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
275 if (!data->xwindow_pict_fmt) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
276 SDL_SetError("XRenderFindVisualFormat() failed"); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
277 return NULL; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
278 } |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
279 data->xwindow_pict = XRenderCreatePicture(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
280 data->xwindow, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
281 data->xwindow_pict_fmt, |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
282 0, NULL); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
283 if (!data->xwindow_pict) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
284 SDL_SetError("XRenderCreatePicture() failed"); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
285 return NULL; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
286 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
287 // FIXME: Clear the window. Is this required? |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
288 XRenderComposite(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
289 PictOpClear, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
290 data->xwindow_pict, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
291 None, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
292 data->xwindow_pict, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
293 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
294 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
295 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
296 window->w, window->h); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
297 // Add some blending modes to the list of supported blending modes |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
298 renderer->info.blend_modes |= |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
299 (SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MASK); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
300 // Create a clip mask that is used for rendering primitives. |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
301 data->stencil = XCreatePixmap(data->display, data->xwindow, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
302 window->w, window->h, 8); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
303 |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
304 // Create the GC for the clip mask. |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
305 data->stencil_gc = XCreateGC(data->display, data->stencil, |
4596
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
306 GCGraphicsExposures, &gcv); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
307 XSetBackground(data->display, data->stencil_gc, 0x00); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
308 XSetForeground(data->display, data->stencil_gc, 0xFF); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
309 data->stencil_pict = |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
310 XRenderCreatePicture(data->display, data->stencil, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
311 XRenderFindStandardFormat(data->display, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
312 PictStandardA8), |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
313 0, NULL); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
314 data->brush = |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
315 XCreatePixmap(data->display, data->xwindow, 1, 1, 32); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
316 XRenderPictureAttributes brush_attr; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
317 brush_attr.repeat = RepeatNormal; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
318 data->brush_pict = |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
319 XRenderCreatePicture(data->display, data->brush, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
320 XRenderFindStandardFormat(data->display, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
321 PictStandardARGB32), |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
322 CPRepeat, &brush_attr); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
323 #ifndef NO_SHARED_MEMORY |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
324 #ifdef EXPT |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
325 /* Create a mask image using MIT-SHM */ |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
326 data->stencil_image = NULL; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
327 data->stencil_surface = NULL; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
328 XShmSegmentInfo *shminfo = &data->stencil_shminfo; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
329 while (SDL_X11_HAVE_SHM) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
330 data->stencil_image = |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
331 XShmCreateImage(data->display, data->visual, 8, ZPixmap, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
332 NULL, shminfo, window->w, window->h); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
333 shminfo->shmid = shmget(IPC_PRIVATE, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
334 data->stencil_image->bytes_per_line * |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
335 data->stencil_image->height, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
336 IPC_CREAT|0777); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
337 shminfo->shmaddr = data->stencil_image->data = shmat(shminfo->shmid, 0, 0); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
338 shminfo->readOnly = False; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
339 XShmAttach(data->display, shminfo); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
340 XSync(data->display, False); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
341 shmctl(shminfo->shmid, IPC_RMID, NULL); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
342 data->stencil_surface = |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
343 SDL_CreateRGBSurfaceFrom(shminfo->shmaddr, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
344 data->stencil_image->width, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
345 data->stencil_image->height, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
346 8, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
347 data->stencil_image->bytes_per_line, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
348 0, 0, 0, 0xFF); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
349 break; |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
350 } |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
351 #endif |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
352 #endif |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
353 // Set the default blending mode. |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
354 renderer->blendMode = SDL_BLENDMODE_BLEND; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
355 data->blend_op = PictOpOver; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
356 } |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
357 #endif |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
358 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 if (flags & SDL_RENDERER_SINGLEBUFFER) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 renderer->info.flags |= |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 n = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 } else if (flags & SDL_RENDERER_PRESENTFLIP2) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 n = 2; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 } else if (flags & SDL_RENDERER_PRESENTFLIP3) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 n = 3; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 n = 1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 for (i = 0; i < n; ++i) { |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
374 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
375 if (data->use_xrender) { |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
376 data->pixmaps[i] = XCreatePixmap(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
377 data->xwindow, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
378 window->w, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
379 window->h, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
380 32); |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
381 } |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
382 else |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
383 #endif |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
384 { |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
385 data->pixmaps[i] = |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
386 XCreatePixmap(data->display, data->xwindow, window->w, window->h, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
387 displaydata->depth); |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
388 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 if (data->pixmaps[i] == None) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 SDL_SetError("XCreatePixmap() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 } |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
394 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
395 if (data->use_xrender) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
396 // Create xrender pictures for each of the pixmaps |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
397 // and clear the pixmaps. |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
398 data->pixmap_picts[i] = |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
399 XRenderCreatePicture(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
400 data->pixmaps[i], |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
401 XRenderFindStandardFormat(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
402 PictStandardARGB32), |
4583
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
403 0, None); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
404 if (!data->pixmap_picts[i]) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
405 SDL_SetError("XRenderCreatePicture() failed"); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
406 return NULL; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
407 } |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
408 |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
409 XRenderComposite(data->display, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
410 PictOpClear, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
411 data->pixmap_picts[i], |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
412 None, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
413 data->pixmap_picts[i], |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
414 0, 0, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
415 0, 0, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
416 0, 0, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
417 window->w, window->h); |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
418 } |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
419 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 if (n > 0) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 data->drawable = data->pixmaps[0]; |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
423 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
424 if(data->use_xrender == SDL_TRUE) |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
425 data->drawable_pict = data->pixmap_picts[0]; |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
426 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 data->makedirty = SDL_TRUE; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 } else { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
429 data->drawable = data->xwindow; |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
430 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
431 if(data->use_xrender == SDL_TRUE) |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
432 data->drawable_pict = data->xwindow_pict; |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
433 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 data->makedirty = SDL_FALSE; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 data->current_pixmap = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 /* Get the format of the window */ |
2874 | 439 if (!SDL_PixelFormatEnumToMasks |
440 (display->current_mode.format, &bpp, &Rmask, &Gmask, &Bmask, | |
441 &Amask)) { | |
2870
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
442 SDL_SetError("Unknown display format"); |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
443 X11_DestroyRenderer(renderer); |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
444 return NULL; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 } |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
446 SDL_InitFormat(&data->format, bpp, Rmask, Gmask, Bmask, Amask); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 /* Create the drawing context */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 gcv.graphics_exposures = False; |
2814 | 450 data->gc = |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
451 XCreateGC(data->display, data->drawable, GCGraphicsExposures, &gcv); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 if (!data->gc) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 SDL_SetError("XCreateGC() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 return renderer; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 X11_DisplayModeChanged(SDL_Renderer * renderer) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
465 SDL_Window *window = renderer->window; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 int i, n; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 |
4596
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
468 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
469 if (data->use_xrender) { |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
470 XRenderFreePicture(data->display, data->xwindow_pict); |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
471 data->xwindow_pict_fmt = |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
472 XRenderFindVisualFormat(data->display, data->visual); |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
473 data->xwindow_pict = |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
474 XRenderCreatePicture(data->display, data->xwindow, |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
475 data->xwindow_pict_fmt, 0, NULL); |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
476 } |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
477 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 if (renderer->info.flags & SDL_RENDERER_SINGLEBUFFER) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 n = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 n = 2; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 n = 3; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 n = 1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 for (i = 0; i < n; ++i) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 if (data->pixmaps[i] != None) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 XFreePixmap(data->display, data->pixmaps[i]); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 data->pixmaps[i] = None; |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
491 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4596
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
492 XRenderFreePicture(data->display, data->pixmap_picts[i]); |
4577
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
493 data->pixmap_picts[i] = None; |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
494 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 for (i = 0; i < n; ++i) { |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
498 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
499 if (data->use_xrender) { |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
500 data->pixmaps[i] = |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
501 XCreatePixmap(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
502 data->xwindow, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
503 window->w, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
504 window->h, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
505 32); |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
506 } |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
507 else |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
508 #endif |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
509 { |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
510 data->pixmaps[i] = |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
511 XCreatePixmap(data->display, data->xwindow, window->w, window->h, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
512 data->depth); |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
513 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 if (data->pixmaps[i] == None) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 SDL_SetError("XCreatePixmap() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
518 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
519 if (data->use_xrender) { |
4577
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
520 data->pixmap_picts[i] = |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
521 XRenderCreatePicture(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
522 data->pixmaps[i], |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
523 XRenderFindStandardFormat(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
524 PictStandardARGB32), |
4583
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
525 0, None); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
526 if (!data->pixmap_picts[i]) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
527 SDL_SetError("XRenderCreatePicture() failed"); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
528 return -1; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
529 } |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
530 XRenderComposite(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
531 PictOpClear, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
532 data->pixmap_picts[i], |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
533 None, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
534 data->pixmap_picts[i], |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
535 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
536 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
537 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
538 window->w, window->h); |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
539 |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
540 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
541 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
543 if (n > 0) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 data->drawable = data->pixmaps[0]; |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
545 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4577
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
546 data->drawable_pict = data->pixmap_picts[0]; |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
547 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
548 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 data->current_pixmap = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
552 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
553 |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
554 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
555 static void |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
556 SDLMaskToXRenderMask(Uint32 sdl_mask, short *comp, short *compMask) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
557 (*comp) = 0; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
558 (*compMask) = 0; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
559 while(!(sdl_mask & 1)) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
560 (*comp)++; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
561 sdl_mask >>= 1; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
562 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
563 while(sdl_mask & 1) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
564 (*compMask) = ((*compMask) << 1) | 1; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
565 sdl_mask >>= 1; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
566 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
567 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
568 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
569 static XRenderPictFormat* |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
570 PixelFormatEnumToXRenderPictFormat(SDL_Renderer * renderer, Uint32 format) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
571 XRenderPictFormat* pict_fmt = NULL; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
572 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
573 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
574 if (data->use_xrender) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
575 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
576 int bpp; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
577 Uint32 Amask, Rmask, Gmask, Bmask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
578 SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
579 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
580 XRenderPictFormat templ; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
581 unsigned long mask = (PictFormatType | PictFormatDepth | PictFormatRed | |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
582 PictFormatRedMask | PictFormatGreen | PictFormatGreenMask | |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
583 PictFormatBlue | PictFormatBlueMask | PictFormatAlpha | |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
584 PictFormatAlphaMask); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
585 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
586 templ.type = PictTypeDirect; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
587 templ.depth = bpp; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
588 SDLMaskToXRenderMask(Amask, &(templ.direct.alpha), &(templ.direct.alphaMask)); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
589 SDLMaskToXRenderMask(Rmask, &(templ.direct.red), &(templ.direct.redMask)); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
590 SDLMaskToXRenderMask(Gmask, &(templ.direct.green), &(templ.direct.greenMask)); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
591 SDLMaskToXRenderMask(Bmask, &(templ.direct.blue), &(templ.direct.blueMask)); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
592 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
593 pict_fmt = XRenderFindFormat(data->display, mask, &templ, 0); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
594 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
595 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
596 return pict_fmt; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
597 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
598 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
599 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
600 static Visual* |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
601 PixelFormatEnumToVisual(SDL_Renderer * renderer, Uint32 format) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
602 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
603 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
604 if (data->use_xrender) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
605 int bpp; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
606 Uint32 Amask, Rmask, Gmask, Bmask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
607 SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
608 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
609 XVisualInfo vinfo_templ; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
610 long vinfo_mask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
611 int nitems_return; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
612 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
613 vinfo_mask = (VisualDepthMask | VisualRedMaskMask | |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
614 VisualGreenMaskMask | VisualBlueMaskMask); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
615 vinfo_templ.depth = bpp; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
616 vinfo_templ.red_mask = Rmask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
617 vinfo_templ.green_mask = Gmask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
618 vinfo_templ.blue_mask = Bmask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
619 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
620 XVisualInfo * ret = XGetVisualInfo(data->display, vinfo_mask, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
621 &vinfo_templ, &nitems_return); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
622 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
623 if (nitems_return) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
624 return ret[0].visual; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
625 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
626 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
627 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
628 return NULL; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
629 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
630 #endif |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
631 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
632 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
633 X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
634 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
635 X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
636 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
637 SDL_VideoDisplay *display = window->display; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
638 X11_TextureData *data; |
2916
ffdd533f7add
Fixed pitch alignment problem causing MITSHM error on 16-bit displays
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
639 int pitch_alignmask = ((renderdata->scanline_pad / 8) - 1); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
640 XGCValues gcv; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
641 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 data = (X11_TextureData *) SDL_calloc(1, sizeof(*data)); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
644 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
645 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
646 } |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
647 data->depth = renderdata->depth; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
648 data->visual = renderdata->visual; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
649 data->gc = renderdata->gc; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
650 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
651 texture->driverdata = data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
652 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
653 data->yuv = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 if (!data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
656 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
657 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
658 data->format = display->current_mode.format; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
659 } else { |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
660 /* If Xrender support is builtin we only need to check whether |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
661 Xrender is available at runtime. If it is available there |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
662 can be no BadMatch error since Xrender takes care of that. |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
663 */ |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
664 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4586
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
665 if (renderdata->use_xrender == SDL_FALSE) { |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
666 if (texture->format != display->current_mode.format) { |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
667 SDL_SetError("Texture format doesn't match window format"); |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
668 return -1; |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
669 } |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
670 } else { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
671 Uint32 Amask, Rmask, Gmask, Bmask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
672 SDL_PixelFormatEnumToMasks(texture->format, &(data->depth), |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
673 &Rmask, &Gmask, &Bmask, &Amask); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
674 data->visual = PixelFormatEnumToVisual(renderer, texture->format); |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
675 } |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
676 #else |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
677 /* The image/pixmap depth must be the same as the window or you |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
678 get a BadMatch error when trying to putimage or copyarea. |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
679 This BadMatch error |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
680 */ |
2870
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
681 if (texture->format != display->current_mode.format) { |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
682 SDL_SetError("Texture format doesn't match window format"); |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
683 return -1; |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
684 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
685 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
686 data->format = texture->format; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
687 } |
2814 | 688 data->pitch = texture->w * SDL_BYTESPERPIXEL(data->format); |
2916
ffdd533f7add
Fixed pitch alignment problem causing MITSHM error on 16-bit displays
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
689 data->pitch = (data->pitch + pitch_alignmask) & ~pitch_alignmask; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
690 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
691 if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
692 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
693 XShmSegmentInfo *shminfo = &data->shminfo; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
694 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
695 shm_error = True; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
696 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
697 if (SDL_X11_HAVE_SHM) { |
2814 | 698 shminfo->shmid = |
699 shmget(IPC_PRIVATE, texture->h * data->pitch, | |
700 IPC_CREAT | 0777); | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
701 if (shminfo->shmid >= 0) { |
2814 | 702 shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
703 shminfo->readOnly = False; |
2814 | 704 if (shminfo->shmaddr != (char *) -1) { |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
705 shm_error = False; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
706 X_handler = XSetErrorHandler(shm_errhandler); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
707 XShmAttach(renderdata->display, shminfo); |
3239 | 708 XSync(renderdata->display, False); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
709 XSetErrorHandler(X_handler); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
710 if (shm_error) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
711 shmdt(shminfo->shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
712 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
713 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
714 shmctl(shminfo->shmid, IPC_RMID, NULL); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
715 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
716 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
717 if (!shm_error) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
718 data->pixels = shminfo->shmaddr; |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
719 data->pixmap = |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
720 XCreatePixmap(renderdata->display, renderdata->xwindow, texture->w, |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
721 texture->h, data->depth); |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
722 if (data->pixmap == None) { |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
723 X11_DestroyTexture(renderer, texture); |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
724 SDL_SetError("XCreatePixmap() failed"); |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
725 return -1; |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
726 } |
2814 | 727 data->image = |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
728 XShmCreateImage(renderdata->display, data->visual, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
729 data->depth, ZPixmap, shminfo->shmaddr, |
2874 | 730 shminfo, texture->w, texture->h); |
4580
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
731 |
4586
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
732 if (!data->image) { |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
733 XShmDetach(renderdata->display, shminfo); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
734 XSync(renderdata->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
735 shmdt(shminfo->shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
736 shm_error = True; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
737 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
738 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
739 if (shm_error) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
740 shminfo->shmaddr = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
741 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
742 if (!data->image) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
743 #endif /* not NO_SHARED_MEMORY */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
744 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
745 data->pixels = SDL_malloc(texture->h * data->pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
746 if (!data->pixels) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
747 X11_DestroyTexture(renderer, texture); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
748 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
749 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
750 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
751 |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
752 data->pixmap = |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
753 XCreatePixmap(renderdata->display, renderdata->xwindow, texture->w, |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
754 texture->h, data->depth); |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
755 if (data->pixmap == None) { |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
756 X11_DestroyTexture(renderer, texture); |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
757 SDL_SetError("XCreatePixmap() failed"); |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
758 return -1; |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
759 } |
2814 | 760 data->image = |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
761 XCreateImage(renderdata->display, data->visual, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
762 data->depth, ZPixmap, 0, data->pixels, |
2874 | 763 texture->w, texture->h, |
764 SDL_BYTESPERPIXEL(data->format) * 8, | |
765 data->pitch); | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
766 if (!data->image) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
767 X11_DestroyTexture(renderer, texture); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
768 SDL_SetError("XCreateImage() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
769 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
770 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
771 } |
4580
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
772 } |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
773 else { |
2814 | 774 data->pixmap = |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
775 XCreatePixmap(renderdata->display, renderdata->xwindow, texture->w, |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
776 texture->h, data->depth); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
777 if (data->pixmap == None) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
778 X11_DestroyTexture(renderer, texture); |
3044
b36579172f27
Changes to hopefully handle the creation of a colormap for 8 bit PseudoColor visuals in X11
Bob Pendleton <bob@pendleton.com>
parents:
2967
diff
changeset
|
779 SDL_SetError("XCreatePixmap() failed"); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
780 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
781 } |
2814 | 782 data->image = |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
783 XCreateImage(renderdata->display, data->visual, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
784 data->depth, ZPixmap, 0, NULL, |
4580
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
785 texture->w, texture->h, |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
786 SDL_BYTESPERPIXEL(data->format) * 8, |
2874 | 787 data->pitch); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
788 if (!data->image) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
789 X11_DestroyTexture(renderer, texture); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
790 SDL_SetError("XCreateImage() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
791 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
792 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
793 } |
4580
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
794 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
795 if(renderdata->use_xrender) { |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
796 gcv.graphics_exposures = False; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
797 data->gc = |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
798 XCreateGC(renderdata->display, data->pixmap, GCGraphicsExposures, &gcv); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
799 if (!data->gc) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
800 SDL_SetError("XCreateGC() failed"); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
801 return -1; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
802 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
803 data->picture_fmt = |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
804 PixelFormatEnumToXRenderPictFormat(renderer, texture->format); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
805 if (data->picture_fmt == NULL) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
806 X11_DestroyTexture(renderer, texture); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
807 SDL_SetError("Texture format not supported by driver"); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
808 return -1; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
809 } |
4580
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
810 data->picture = |
4586
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
811 XRenderCreatePicture(renderdata->display, data->pixmap, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
812 data->picture_fmt, 0, NULL); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
813 if (!data->picture) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
814 X11_DestroyTexture(renderer, texture); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
815 SDL_SetError("XRenderCreatePicture() failed"); |
4580
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
816 return -1; |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
817 } |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
818 } |
4580
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
819 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
820 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
821 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
822 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
823 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
824 X11_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
825 void **pixels, int *pitch) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
826 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
827 X11_TextureData *data = (X11_TextureData *) texture->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
828 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
829 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
830 return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
831 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
832 *pixels = data->pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
833 *pitch = data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
834 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
835 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
836 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
837 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
838 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
839 X11_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
840 { |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
841 X11_TextureData *data = (X11_TextureData *) texture->driverdata; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
842 switch (texture->blendMode) { |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
843 case SDL_BLENDMODE_NONE: |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
844 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
845 data->blend_op = PictOpSrc; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
846 return 0; |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
847 case SDL_BLENDMODE_BLEND: |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
848 data->blend_op = PictOpOver; |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
849 return 0; |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
850 case SDL_BLENDMODE_ADD: |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
851 data->blend_op = PictOpAdd; |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
852 return 0; |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
853 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
854 default: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
855 SDL_Unsupported(); |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
856 texture->blendMode = SDL_BLENDMODE_NONE; |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
857 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
858 texture->blendMode = SDL_BLENDMODE_BLEND; |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
859 data->blend_op = PictOpOver; |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
860 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
861 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
862 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
863 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
864 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
865 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
866 X11_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
867 { |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
868 X11_TextureData *data = (X11_TextureData *) texture->driverdata; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
869 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
870 switch (texture->scaleMode) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
871 case SDL_TEXTURESCALEMODE_NONE: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
872 return 0; |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
873 case SDL_TEXTURESCALEMODE_FAST: |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
874 /* We can sort of fake it for streaming textures */ |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
875 if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
876 return 0; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
877 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
878 /* Fall through to unsupported case */ |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
879 default: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
880 SDL_Unsupported(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
881 texture->scaleMode = SDL_TEXTURESCALEMODE_NONE; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
882 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
883 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
884 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
885 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
886 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
887 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
888 X11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
889 const SDL_Rect * rect, const void *pixels, int pitch) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
890 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
891 X11_TextureData *data = (X11_TextureData *) texture->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
892 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
893 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
894 if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
895 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
896 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
897 UpdateYUVTextureData(texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
898 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
899 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
900 X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
901 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
902 if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
903 Uint8 *src, *dst; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
904 int row; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
905 size_t length; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
906 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
907 src = (Uint8 *) pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
908 dst = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
909 (Uint8 *) data->pixels + rect->y * data->pitch + |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
910 rect->x * SDL_BYTESPERPIXEL(texture->format); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
911 length = rect->w * SDL_BYTESPERPIXEL(texture->format); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
912 for (row = 0; row < rect->h; ++row) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
913 SDL_memcpy(dst, src, length); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
914 src += pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
915 dst += data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
916 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
917 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
918 data->image->width = rect->w; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
919 data->image->height = rect->h; |
2814 | 920 data->image->data = (char *) pixels; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
921 data->image->bytes_per_line = pitch; |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
922 XPutImage(renderdata->display, data->pixmap, data->gc, |
2814 | 923 data->image, 0, 0, rect->x, rect->y, rect->w, rect->h); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
924 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
925 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
926 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
927 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
928 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
929 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
930 X11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
931 const SDL_Rect * rect, int markDirty, void **pixels, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
932 int *pitch) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
933 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
934 X11_TextureData *data = (X11_TextureData *) texture->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
935 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
936 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
937 return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
938 pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
939 } else if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
940 *pixels = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
941 (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
942 rect->x * SDL_BYTESPERPIXEL(texture->format)); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
943 *pitch = data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
944 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
945 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
946 SDL_SetError("No pixels available"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
947 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
948 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
949 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
950 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
951 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
952 X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
953 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
954 X11_TextureData *data = (X11_TextureData *) texture->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
955 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
956 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
957 SDL_SW_UnlockYUVTexture(data->yuv); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
958 UpdateYUVTextureData(texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
959 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
960 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
961 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
962 static int |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
963 X11_SetDrawBlendMode(SDL_Renderer * renderer) |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
964 { |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
965 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
966 switch (renderer->blendMode) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
967 case SDL_BLENDMODE_NONE: |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
968 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
969 //PictOpSrc |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
970 data->blend_op = PictOpSrc; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
971 return 0; |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
972 case SDL_BLENDMODE_BLEND: // PictOpOver |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
973 data->blend_op = PictOpOver; |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
974 return 0; |
4581
ef0aa488fff6
Fix X11_FillRects to work with double buffering as well as triple buffering. This requires that the buffer pixmap be cleared after every render.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4580
diff
changeset
|
975 case SDL_BLENDMODE_ADD: // PictOpAdd |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
976 data->blend_op = PictOpAdd; |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
977 return 0; |
4581
ef0aa488fff6
Fix X11_FillRects to work with double buffering as well as triple buffering. This requires that the buffer pixmap be cleared after every render.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4580
diff
changeset
|
978 /* FIXME case SDL_BLENDMODE_MOD: */ |
ef0aa488fff6
Fix X11_FillRects to work with double buffering as well as triple buffering. This requires that the buffer pixmap be cleared after every render.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4580
diff
changeset
|
979 #endif |
ef0aa488fff6
Fix X11_FillRects to work with double buffering as well as triple buffering. This requires that the buffer pixmap be cleared after every render.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4580
diff
changeset
|
980 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
981 default: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
982 SDL_Unsupported(); |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
983 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
984 if(data->use_xrender) { |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
985 renderer->blendMode = SDL_BLENDMODE_BLEND; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
986 data->blend_op = PictOpOver; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
987 } |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
988 else |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
989 #endif |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
990 { |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
991 renderer->blendMode = SDL_BLENDMODE_NONE; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
992 } |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
993 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
994 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
995 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
996 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
997 static Uint32 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
998 renderdrawcolor(SDL_Renderer * renderer, int premult) |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
999 { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1000 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1001 Uint8 r = renderer->r; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1002 Uint8 g = renderer->g; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1003 Uint8 b = renderer->b; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1004 Uint8 a = renderer->a; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1005 if (premult) |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
1006 return SDL_MapRGBA(&data->format, ((int) r * (int) a) / 255, |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1007 ((int) g * (int) a) / 255, |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1008 ((int) b * (int) a) / 255, 255); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1009 else |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
1010 return SDL_MapRGBA(&data->format, r, g, b, a); |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1011 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1012 |
4583
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1013 static XRenderColor |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1014 xrenderdrawcolor(SDL_Renderer *renderer) |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1015 { |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1016 // Premultiply the color channels as well as modulate them to a 16 bit color space |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1017 XRenderColor xrender_color; |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1018 double alphad; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1019 if(renderer->blendMode == SDL_BLENDMODE_NONE) |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1020 alphad = 1.0; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1021 else |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1022 alphad = (renderer->a) / 255.0; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1023 |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1024 xrender_color.alpha = (unsigned short) ((renderer->a / 255.0) * 0xFFFF); |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1025 |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1026 xrender_color.red = |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1027 (unsigned short) ((renderer->r / 255.0) * alphad * 0xFFFF); |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1028 xrender_color.green = |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1029 (unsigned short) ((renderer->g / 255.0) * alphad * 0xFFFF); |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1030 xrender_color.blue = |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1031 (unsigned short) ((renderer->b / 255.0) * alphad * 0xFFFF); |
4583
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1032 return xrender_color; |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1033 } |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1034 |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1035 static int |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1036 X11_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1037 int count) |
2901 | 1038 { |
1039 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; | |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1040 SDL_Window *window = renderer->window; |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1041 XPoint *xpoints, *xpoint; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1042 int i, xcount; |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1043 SDL_Rect clip, rect; |
2901 | 1044 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1045 clip.x = 0; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1046 clip.y = 0; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1047 clip.w = window->w; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1048 clip.h = window->h; |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1049 if (data->makedirty) { |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1050 |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1051 /* Get the smallest rectangle that contains everything */ |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1052 rect.x = 0; |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1053 rect.y = 0; |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1054 rect.w = window->w; |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1055 rect.h = window->h; |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1056 if (!SDL_EnclosePoints(points, count, &rect, &rect)) { |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1057 /* Nothing to draw */ |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1058 return 0; |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1059 } |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1060 SDL_AddDirtyRect(&data->dirty, &rect); |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1061 } |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1062 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1063 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1064 #ifndef NO_SHARED_MEMORY |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1065 #ifdef EXPT |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1066 if (data->use_xrender && data->stencil_image && data->stencil_surface) { |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1067 SDL_FillRect(data->stencil_surface, &rect, 0x00); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1068 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1069 SDL_SetClipRect(data->stencil_surface, NULL); |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1070 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1071 SDL_DrawPoints(data->stencil_surface, points, count, 0xFF); |
2901 | 1072 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1073 XShmPutImage(data->display, data->stencil, data->stencil_gc, data->stencil_image, |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1074 rect.x, rect.y, rect.x, rect.y, rect.w, rect.h, False); |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1075 |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1076 XSync(data->display, False); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1077 } else |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1078 #endif |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1079 #endif |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1080 #endif |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1081 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1082 { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1083 xpoint = xpoints = SDL_stack_alloc(XPoint, count); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1084 xcount = 0; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1085 for (i = 0; i < count; ++i) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1086 int x = points[i].x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1087 int y = points[i].y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1088 if (x < 0 || x >= window->w || y < 0 || y >= window->h) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1089 continue; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1090 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1091 xpoint->x = (short)x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1092 xpoint->y = (short)y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1093 ++xpoint; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1094 ++xcount; |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1095 } |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1096 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1097 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1098 if (data->use_xrender) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1099 XSetForeground(data->display, data->stencil_gc, 0x00); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1100 XFillRectangle(data->display, data->stencil, data->stencil_gc, |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1101 rect.x, rect.y, rect.w, rect.h); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1102 XSetForeground(data->display, data->stencil_gc, 0xFF); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1103 XDrawPoints(data->display, data->stencil, data->stencil_gc, xpoints, xcount, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1104 CoordModeOrigin); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1105 } |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1106 #endif |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1107 } |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1108 |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1109 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1110 if (data->use_xrender) { |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1111 XRenderColor foreground; |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1112 foreground = xrenderdrawcolor(renderer); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1113 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1114 &foreground, 0, 0, 1, 1); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1115 XRenderComposite(data->display, data->blend_op, data->brush_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1116 data->stencil_pict, data->drawable_pict, |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1117 rect.x, rect.y, rect.x, rect.y, rect.x, rect.y, rect.w, rect.h); |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1118 } |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1119 else |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1120 #endif |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1121 |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1122 { |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1123 unsigned long foreground = renderdrawcolor(renderer, 1); |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1124 XSetForeground(data->display, data->gc, foreground); |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1125 |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1126 |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1127 if (xcount > 0) { |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1128 XDrawPoints(data->display, data->drawable, data->gc, xpoints, xcount, |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1129 CoordModeOrigin); |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1130 } |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1131 } |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1132 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1133 SDL_stack_free(xpoints); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1134 |
2894 | 1135 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1136 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1137 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1138 static int |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1139 X11_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1140 int count) |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1141 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1142 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1143 SDL_Window *window = renderer->window; |
4458
c9584df65367
Removed unused variables
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
1144 SDL_Rect clip; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1145 unsigned long foreground; |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1146 XPoint *xpoints, *xpoint; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1147 int i, xcount; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1148 int minx, miny; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1149 int maxx, maxy; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1150 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1151 clip.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1152 clip.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1153 clip.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1154 clip.h = window->h; |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1155 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1156 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1157 #ifndef NO_SHARED_MEMORY |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1158 #ifdef EXPT |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1159 if (data->use_xrender && data->stencil_image && data->stencil_surface) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1160 SDL_FillRect(data->stencil_surface, NULL, 0x00); |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1161 |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1162 SDL_DrawLines(data->stencil_surface, points, count, 0xFF); |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1163 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1164 SDL_SetClipRect(data->stencil_surface, NULL); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1165 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1166 XShmPutImage(data->display, data->stencil, data->stencil_gc, data->stencil_image, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1167 0, 0, 0, 0, window->w, window->h, False); |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1168 |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1169 XSync(data->display, False); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1170 } else |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1171 #endif |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1172 #endif |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1173 #endif |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1174 |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1175 { |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1176 Pixmap drawable; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1177 GC gc; |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1178 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1179 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1180 if (data->use_xrender) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1181 drawable = data->stencil; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1182 gc = data->stencil_gc; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1183 XSetForeground(data->display, data->stencil_gc, 0x00); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1184 XFillRectangle(data->display, data->stencil, data->stencil_gc, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1185 0, 0, window->w, window->h); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1186 XSetForeground(data->display, data->stencil_gc, 0xFF); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1187 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1188 else |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1189 #endif |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1190 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1191 { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1192 drawable = data->drawable; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1193 gc = data->gc; |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1194 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1195 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1196 foreground = renderdrawcolor(renderer, 1); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1197 XSetForeground(data->display, data->gc, foreground); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1198 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1199 xpoint = xpoints = SDL_stack_alloc(XPoint, count); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1200 xcount = 0; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1201 minx = INT_MAX; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1202 miny = INT_MAX; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1203 maxx = INT_MIN; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1204 maxy = INT_MIN; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1205 for (i = 0; i < count; ++i) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1206 int x = points[i].x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1207 int y = points[i].y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1208 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1209 /* If the point is inside the window, add it to the list */ |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1210 if (x >= 0 && x < window->w && y >= 0 && y < window->h) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1211 if (x < minx) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1212 minx = x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1213 } else if (x > maxx) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1214 maxx = x; |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1215 } |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1216 if (y < miny) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1217 miny = y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1218 } else if (y > maxy) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1219 maxy = y; |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1220 } |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1221 xpoint->x = (short)x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1222 xpoint->y = (short)y; |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1223 ++xpoint; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1224 ++xcount; |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1225 continue; |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1226 } |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1227 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1228 /* We need to clip the line segments joined by this point */ |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1229 if (xcount > 0) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1230 int x1 = xpoint[-1].x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1231 int y1 = xpoint[-1].y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1232 int x2 = x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1233 int y2 = y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1234 if (SDL_IntersectRectAndLine(&clip, &x1, &y1, &x2, &y2)) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1235 if (x2 < minx) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1236 minx = x2; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1237 } else if (x2 > maxx) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1238 maxx = x2; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1239 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1240 if (y2 < miny) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1241 miny = y2; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1242 } else if (y2 > maxy) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1243 maxy = y2; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1244 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1245 xpoint->x = (short)x2; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1246 xpoint->y = (short)y2; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1247 ++xpoint; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1248 ++xcount; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1249 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1250 XDrawLines(data->display, drawable, gc, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1251 xpoints, xcount, CoordModeOrigin); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1252 if (xpoints[0].x != x2 || xpoints[0].y != y2) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1253 XDrawPoint(data->display, drawable, gc, x2, y2); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1254 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1255 if (data->makedirty) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1256 SDL_Rect rect; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1257 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1258 rect.x = minx; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1259 rect.y = miny; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1260 rect.w = (maxx - minx) + 1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1261 rect.h = (maxy - miny) + 1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1262 SDL_AddDirtyRect(&data->dirty, &rect); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1263 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1264 xpoint = xpoints; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1265 xcount = 0; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1266 minx = INT_MAX; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1267 miny = INT_MAX; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1268 maxx = INT_MIN; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1269 maxy = INT_MIN; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1270 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1271 if (i < (count-1)) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1272 int x1 = x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1273 int y1 = y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1274 int x2 = points[i+1].x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1275 int y2 = points[i+1].y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1276 if (SDL_IntersectRectAndLine(&clip, &x1, &y1, &x2, &y2)) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1277 if (x1 < minx) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1278 minx = x1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1279 } else if (x1 > maxx) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1280 maxx = x1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1281 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1282 if (y1 < miny) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1283 miny = y1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1284 } else if (y1 > maxy) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1285 maxy = y1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1286 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1287 xpoint->x = (short)x1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1288 xpoint->y = (short)y1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1289 ++xpoint; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1290 ++xcount; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1291 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1292 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1293 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1294 if (xcount > 1) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1295 int x2 = xpoint[-1].x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1296 int y2 = xpoint[-1].y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1297 XDrawLines(data->display, drawable, gc, xpoints, xcount, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1298 CoordModeOrigin); |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1299 if (xpoints[0].x != x2 || xpoints[0].y != y2) { |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1300 XDrawPoint(data->display, drawable, gc, x2, y2); |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1301 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1302 if (data->makedirty) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1303 SDL_Rect rect; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1304 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1305 rect.x = minx; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1306 rect.y = miny; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1307 rect.w = (maxx - minx) + 1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1308 rect.h = (maxy - miny) + 1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1309 SDL_AddDirtyRect(&data->dirty, &rect); |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1310 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1311 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1312 } |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1313 |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1314 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1315 if (data->use_xrender) { |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1316 XRenderColor xrforeground = xrenderdrawcolor(renderer); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1317 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1318 &xrforeground, 0, 0, 1, 1); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1319 XRenderComposite(data->display, data->blend_op, data->brush_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1320 data->stencil_pict, data->drawable_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1321 0, 0, 0, 0, 0, 0, window->w, window->h); |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1322 } |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1323 #endif |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1324 |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1325 SDL_stack_free(xpoints); |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1326 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1327 return 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1328 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1329 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1330 static int |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1331 X11_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1332 { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1333 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1334 SDL_Window *window = renderer->window; |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1335 SDL_Rect clip, rect; |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1336 int i, xcount; |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1337 XRectangle *xrects, *xrect; |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1338 xrect = xrects = SDL_stack_alloc(XRectangle, count); |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1339 xcount = 0; |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1340 |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1341 clip.x = 0; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1342 clip.y = 0; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1343 clip.w = window->w; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1344 clip.h = window->h; |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1345 |
4583
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1346 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1347 #ifndef NO_SHARED_MEMORY |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1348 #ifdef EXPT |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1349 if (data->use_xrender && data->stencil_image && data->stencil_surface) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1350 SDL_FillRect(data->stencil_surface, NULL, 0x00); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1351 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1352 SDL_SetClipRect(data->stencil_surface, NULL); |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1353 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1354 SDL_DrawRects(data->stencil_surface, rects, count, 1); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1355 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1356 XShmPutImage(data->display, data->stencil, data->stencil_gc, data->stencil_image, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1357 0, 0, 0, 0, window->w, window->h, False); |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1358 |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1359 XSync(data->display, False); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1360 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1361 else |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1362 #endif |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1363 #endif |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1364 #endif |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1365 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1366 { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1367 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1368 for (i = 0; i < count; ++i) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1369 if (!SDL_IntersectRect(rects[i], &clip, &rect)) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1370 continue; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1371 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1372 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1373 xrect->x = (short)rect.x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1374 xrect->y = (short)rect.y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1375 xrect->width = (unsigned short)rect.w; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1376 xrect->height = (unsigned short)rect.h; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1377 ++xrect; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1378 ++xcount; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1379 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1380 if (data->makedirty) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1381 SDL_AddDirtyRect(&data->dirty, &rect); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1382 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1383 } |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1384 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1385 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1386 if (data->use_xrender) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1387 XSetForeground(data->display, data->stencil_gc, 0x00); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1388 XFillRectangle(data->display, data->stencil, data->stencil_gc, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1389 0, 0, window->w, window->h); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1390 XSetForeground(data->display, data->stencil_gc, 0xFF); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1391 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1392 XDrawRectangles(data->display, data->stencil, data->stencil_gc, xrects, xcount); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1393 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1394 #endif |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1395 |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1396 } |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1397 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1398 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1399 if (data->use_xrender) { |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1400 XRenderColor foreground; |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1401 foreground = xrenderdrawcolor(renderer); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1402 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1403 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1404 &foreground, 0, 0, 1, 1); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1405 XRenderComposite(data->display, data->blend_op, data->brush_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1406 data->stencil_pict, data->drawable_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1407 0, 0, 0, 0, 0, 0, window->w, window->h); |
4583
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1408 } |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1409 else |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1410 #endif |
4599
ce0643707bb0
Minor changes.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4598
diff
changeset
|
1411 |
4583
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1412 { |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1413 unsigned long foreground; |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1414 |
4583
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1415 foreground = renderdrawcolor(renderer, 1); |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1416 XSetForeground(data->display, data->gc, foreground); |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1417 |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1418 if (xcount > 0) { |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1419 XDrawRectangles(data->display, data->drawable, data->gc, |
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1420 xrects, xcount); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1421 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1422 } |
4583
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
1423 SDL_stack_free(xrects); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1424 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1425 return 0; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1426 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1427 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1428 static int |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
1429 X11_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1430 { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1431 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1432 SDL_Window *window = renderer->window; |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1433 SDL_Rect clip, rect; |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1434 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1435 clip.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1436 clip.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1437 clip.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1438 clip.h = window->h; |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1439 |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1440 int i, xcount; |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1441 XRectangle *xrects, *xrect; |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1442 xrect = xrects = SDL_stack_alloc(XRectangle, count); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1443 xcount = 0; |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1444 for (i = 0; i < count; ++i) { |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1445 if (!SDL_IntersectRect(rects[i], &clip, &rect)) { |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1446 continue; |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1447 } |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1448 |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1449 xrect->x = (short)rect.x; |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1450 xrect->y = (short)rect.y; |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1451 xrect->width = (unsigned short)rect.w; |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1452 xrect->height = (unsigned short)rect.h; |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1453 ++xrect; |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1454 ++xcount; |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1455 |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1456 if (data->makedirty) { |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1457 SDL_AddDirtyRect(&data->dirty, &rect); |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1458 } |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1459 } |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1460 |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1461 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1462 if (data->use_xrender) { |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1463 XRenderColor foreground; |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1464 foreground = xrenderdrawcolor(renderer); |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1465 if (xcount == 1) { |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1466 XRenderFillRectangle(data->display, data->blend_op, data->drawable_pict, |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1467 &foreground, xrects[0].x, xrects[0].y, |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1468 xrects[0].width, xrects[0].height); |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1469 } |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1470 else if (xcount > 1) { |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1471 XRenderFillRectangles(data->display, data->blend_op, data->drawable_pict, |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1472 &foreground, xrects, xcount); |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1473 } |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1474 } |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1475 else |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1476 #endif |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1477 { |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1478 unsigned long foreground; |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1479 |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1480 foreground = renderdrawcolor(renderer, 1); |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1481 XSetForeground(data->display, data->gc, foreground); |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1482 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1483 XFillRectangles(data->display, data->drawable, data->gc, |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1484 xrects, xcount); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1485 } |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1486 |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1487 SDL_stack_free(xrects); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1488 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1489 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1490 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1491 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1492 X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1493 const SDL_Rect * srcrect, const SDL_Rect * dstrect) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1494 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1495 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1496 X11_TextureData *texturedata = (X11_TextureData *) texture->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1497 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1498 if (data->makedirty) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1499 SDL_AddDirtyRect(&data->dirty, dstrect); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1500 } |
4586
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1501 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1502 if (data->use_xrender) { |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1503 if(texture->access == SDL_TEXTUREACCESS_STREAMING) { |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1504 #ifndef NO_SHARED_MEMORY |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1505 if(texturedata->shminfo.shmaddr) { |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1506 XShmPutImage(data->display, texturedata->pixmap, data->gc, |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1507 texturedata->image, srcrect->x, srcrect->y, |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1508 srcrect->x, srcrect->y, srcrect->w, srcrect->h, |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1509 False); |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1510 } |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1511 else |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1512 #endif |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1513 if (texturedata->pixels) { |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1514 XPutImage(data->display, texturedata->pixmap, data->gc, |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1515 texturedata->image, srcrect->x, srcrect->y, dstrect->x, |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1516 dstrect->y, srcrect->w, srcrect->h); |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1517 } |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1518 } |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1519 Picture pict; |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1520 if(texture->blendMode == SDL_BLENDMODE_NONE) |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1521 pict = None; |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1522 else |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1523 pict = texturedata->picture; |
4586
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1524 if(srcrect->w == dstrect->w && srcrect->h == dstrect->h) { |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1525 XRenderComposite(data->display, texturedata->blend_op, texturedata->picture, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1526 pict, data->drawable_pict, srcrect->x, srcrect->y, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1527 srcrect->x, srcrect->y, dstrect->x, dstrect->y, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1528 srcrect->w, srcrect->h); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1529 } else { |
4586
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1530 double xscale = ((double) dstrect->w) / srcrect->w; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1531 double yscale = ((double) dstrect->h) / srcrect->h; |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1532 XTransform xform = {{ |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1533 {XDoubleToFixed(xscale), XDoubleToFixed(0), XDoubleToFixed(0)}, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1534 {XDoubleToFixed(0), XDoubleToFixed(yscale), XDoubleToFixed(0)}, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1535 {XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(xscale * yscale)}}}; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1536 XRenderSetPictureTransform(data->display, texturedata->picture, &xform); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1537 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1538 XRenderComposite(data->display, texturedata->blend_op, |
4595
73eeadf7ed8e
Fixed a minor bug with texture blending.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4594
diff
changeset
|
1539 texturedata->picture, pict, data->drawable_pict, |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1540 0, 0, 0, 0, dstrect->x, dstrect->y, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1541 dstrect->w, dstrect->h); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1542 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1543 XTransform identity = {{ |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1544 {XDoubleToFixed(1), XDoubleToFixed(0), XDoubleToFixed(0)}, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1545 {XDoubleToFixed(0), XDoubleToFixed(1), XDoubleToFixed(0)}, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1546 {XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(1)}}}; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1547 XRenderSetPictureTransform(data->display, texturedata->picture, &identity); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1548 } |
4586
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1549 } |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1550 else |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1551 #endif |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1552 { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1553 if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1554 #ifndef NO_SHARED_MEMORY |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1555 if (texturedata->shminfo.shmaddr) { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1556 XShmPutImage(data->display, data->drawable, data->gc, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1557 texturedata->image, srcrect->x, srcrect->y, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1558 dstrect->x, dstrect->y, srcrect->w, srcrect->h, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1559 False); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1560 } else |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1561 #endif |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1562 if (texturedata->pixels) { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1563 XPutImage(data->display, data->drawable, data->gc, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1564 texturedata->image, srcrect->x, srcrect->y, dstrect->x, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1565 dstrect->y, srcrect->w, srcrect->h); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1566 } else { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1567 XCopyArea(data->display, texturedata->pixmap, data->drawable, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1568 data->gc, srcrect->x, srcrect->y, dstrect->w, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1569 dstrect->h, dstrect->x, dstrect->y); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1570 } |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1571 } else if (texturedata->yuv |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1572 || texture->access == SDL_TEXTUREACCESS_STREAMING) { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1573 SDL_Surface src, dst; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1574 SDL_PixelFormat fmt; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1575 SDL_Rect rect; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1576 XImage *image = texturedata->scaling_image; |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1577 |
4586
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1578 if (!image) { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1579 void *pixels; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1580 int pitch; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1581 |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1582 pitch = dstrect->w * SDL_BYTESPERPIXEL(texturedata->format); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1583 pixels = SDL_malloc(dstrect->h * pitch); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1584 if (!pixels) { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1585 SDL_OutOfMemory(); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1586 return -1; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1587 } |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1588 |
4586
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1589 image = |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1590 XCreateImage(data->display, data->visual, data->depth, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1591 ZPixmap, 0, pixels, dstrect->w, dstrect->h, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1592 SDL_BYTESPERPIXEL(texturedata->format) * 8, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1593 pitch); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1594 if (!image) { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1595 SDL_SetError("XCreateImage() failed"); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1596 return -1; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1597 } |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1598 texturedata->scaling_image = image; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1599 |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1600 } else if (image->width != dstrect->w || image->height != dstrect->h |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1601 || !image->data) { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1602 image->width = dstrect->w; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1603 image->height = dstrect->h; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1604 image->bytes_per_line = |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1605 image->width * SDL_BYTESPERPIXEL(texturedata->format); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1606 image->data = |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1607 (char *) SDL_realloc(image->data, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1608 image->height * image->bytes_per_line); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1609 if (!image->data) { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1610 SDL_OutOfMemory(); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1611 return -1; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1612 } |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1613 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1614 |
4586
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1615 /* Set up fake surfaces for SDL_SoftStretch() */ |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1616 SDL_zero(src); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1617 src.format = &fmt; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1618 src.w = texture->w; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1619 src.h = texture->h; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1620 #ifndef NO_SHARED_MEMORY |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1621 if (texturedata->shminfo.shmaddr) { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1622 src.pixels = texturedata->shminfo.shmaddr; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1623 } else |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1624 #endif |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1625 src.pixels = texturedata->pixels; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1626 src.pitch = texturedata->pitch; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1627 |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1628 SDL_zero(dst); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1629 dst.format = &fmt; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1630 dst.w = image->width; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1631 dst.h = image->height; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1632 dst.pixels = image->data; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1633 dst.pitch = image->bytes_per_line; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1634 |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1635 fmt.BytesPerPixel = SDL_BYTESPERPIXEL(texturedata->format); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1636 |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1637 rect.x = 0; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1638 rect.y = 0; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1639 rect.w = dstrect->w; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1640 rect.h = dstrect->h; |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1641 if (SDL_SoftStretch(&src, srcrect, &dst, &rect) < 0) { |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1642 return -1; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1643 } |
4586
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1644 XPutImage(data->display, data->drawable, data->gc, image, 0, 0, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1645 dstrect->x, dstrect->y, dstrect->w, dstrect->h); |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1646 } else { |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1647 XCopyArea(data->display, texturedata->pixmap, data->drawable, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1648 data->gc, srcrect->x, srcrect->y, dstrect->w, dstrect->h, |
e479c1e57c52
SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4585
diff
changeset
|
1649 srcrect->x, srcrect->y); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1650 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1651 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1652 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1653 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1654 |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1655 static int |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1656 X11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1657 Uint32 format, void * pixels, int pitch) |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1658 { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1659 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1660 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1661 SDL_VideoDisplay *display = window->display; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1662 Uint32 screen_format = display->current_mode.format; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1663 XImage *image; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1664 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1665 image = XGetImage(data->display, data->drawable, rect->x, rect->y, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1666 rect->w, rect->h, AllPlanes, ZPixmap); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1667 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1668 SDL_ConvertPixels(rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1669 screen_format, image->data, image->bytes_per_line, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1670 format, pixels, pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1671 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1672 XDestroyImage(image); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1673 return 0; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1674 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1675 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1676 static int |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1677 X11_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1678 Uint32 format, const void * pixels, int pitch) |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1679 { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1680 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1681 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1682 SDL_VideoDisplay *display = window->display; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1683 Uint32 screen_format = display->current_mode.format; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1684 XImage *image; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1685 void *image_pixels; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1686 int image_pitch; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1687 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1688 image_pitch = rect->w * SDL_BYTESPERPIXEL(screen_format); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1689 image_pixels = SDL_malloc(rect->h * image_pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1690 if (!image_pixels) { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1691 SDL_OutOfMemory(); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1692 return -1; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1693 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1694 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1695 image = XCreateImage(data->display, data->visual, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1696 data->depth, ZPixmap, 0, image_pixels, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1697 rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1698 SDL_BYTESPERPIXEL(screen_format) * 8, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1699 image_pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1700 if (!image) { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1701 SDL_SetError("XCreateImage() failed"); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1702 return -1; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1703 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1704 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1705 SDL_ConvertPixels(rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1706 format, pixels, pitch, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1707 screen_format, image->data, image->bytes_per_line); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1708 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1709 XPutImage(data->display, data->drawable, data->gc, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1710 image, 0, 0, rect->x, rect->y, rect->w, rect->h); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1711 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1712 image->data = NULL; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1713 XDestroyImage(image); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1714 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1715 SDL_free(image_pixels); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1716 return 0; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1717 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1718 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1719 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1720 X11_RenderPresent(SDL_Renderer * renderer) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1721 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1722 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1723 SDL_DirtyRect *dirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1724 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1725 /* Send the data to the display */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1726 if (!(renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1727 for (dirty = data->dirty.list; dirty; dirty = dirty->next) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1728 const SDL_Rect *rect = &dirty->rect; |
4579
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1729 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1730 if (data->use_xrender) |
4579
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1731 { |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1732 XRenderComposite(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1733 data->blend_op, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1734 data->drawable_pict, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1735 None, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1736 data->xwindow_pict, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1737 rect->x, rect->y, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1738 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1739 rect->x, rect->y, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1740 rect->w, rect->h); |
4579
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1741 } |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1742 else |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1743 #endif |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1744 { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
1745 XCopyArea(data->display, data->drawable, data->xwindow, |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1746 data->gc, rect->x, rect->y, rect->w, rect->h, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1747 rect->x, rect->y); |
4579
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1748 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1749 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1750 SDL_ClearDirtyRects(&data->dirty); |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1751 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1752 XSync(data->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1753 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1754 /* Update the flipping chain, if any */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1755 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1756 data->current_pixmap = (data->current_pixmap + 1) % 2; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1757 data->drawable = data->pixmaps[data->current_pixmap]; |
4579
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1758 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1759 data->drawable_pict = data->pixmap_picts[data->current_pixmap]; |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1760 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1761 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1762 data->current_pixmap = (data->current_pixmap + 1) % 3; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1763 data->drawable = data->pixmaps[data->current_pixmap]; |
4579
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1764 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1765 data->drawable_pict = data->pixmap_picts[data->current_pixmap]; |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1766 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1767 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1768 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1769 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1770 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1771 X11_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1772 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1773 X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1774 X11_TextureData *data = (X11_TextureData *) texture->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1775 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1776 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1777 return; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1778 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1779 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1780 SDL_SW_DestroyYUVTexture(data->yuv); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1781 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1782 if (data->pixmap != None) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1783 XFreePixmap(renderdata->display, data->pixmap); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1784 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1785 if (data->image) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1786 data->image->data = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1787 XDestroyImage(data->image); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1788 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1789 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1790 if (data->shminfo.shmaddr) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1791 XShmDetach(renderdata->display, &data->shminfo); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1792 XSync(renderdata->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1793 shmdt(data->shminfo.shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1794 data->pixels = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1795 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1796 #endif |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1797 if (data->scaling_image) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1798 SDL_free(data->scaling_image->data); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1799 data->scaling_image->data = NULL; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1800 XDestroyImage(data->scaling_image); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1801 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1802 if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1803 SDL_free(data->pixels); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1804 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1805 SDL_free(data); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1806 texture->driverdata = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1807 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1808 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1809 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1810 X11_DestroyRenderer(SDL_Renderer * renderer) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1811 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1812 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1813 int i; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1814 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1815 if (data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1816 for (i = 0; i < SDL_arraysize(data->pixmaps); ++i) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1817 if (data->pixmaps[i] != None) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1818 XFreePixmap(data->display, data->pixmaps[i]); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1819 } |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1820 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1821 if (data->pixmap_picts[i] != None) { |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1822 XRenderFreePicture(data->display, data->pixmap_picts[i]); |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1823 } |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1824 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1825 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1826 if (data->gc) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1827 XFreeGC(data->display, data->gc); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1828 } |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1829 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1830 if (data->stencil_gc) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1831 XFreeGC(data->display, data->stencil_gc); |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1832 } |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1833 if (data->stencil) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1834 XFreePixmap(data->display, data->stencil); |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1835 } |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1836 if (data->drawable_pict) { |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1837 XRenderFreePicture(data->display, data->drawable_pict); |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1838 } |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1839 if (data->xwindow_pict) { |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1840 XRenderFreePicture(data->display, data->xwindow_pict); |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1841 } |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1842 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1843 SDL_FreeDirtyRects(&data->dirty); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1844 SDL_free(data); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1845 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1846 SDL_free(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1847 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1848 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1849 #endif /* SDL_VIDEO_RENDER_X11 */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1850 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1851 /* vi: set ts=4 sw=4 expandtab: */ |