Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11render.c @ 4589:8d8a889530eb
Fix blending modes for primitives.
author | Sunny Sachanandani <sunnysachanandani@gmail.com> |
---|---|
date | Thu, 01 Jul 2010 07:35:15 +0530 |
parents | 0ddd78496d68 |
children | 1ad70fb49fcb |
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" |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 /* X11 renderer implementation */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 int *pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 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
|
43 SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 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
|
45 SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 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
|
47 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
|
48 int pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 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
|
50 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
|
51 void **pixels, int *pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 Uint32 format, void * pixels, int pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
66 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
|
67 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
|
68 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
|
69 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
|
70 SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 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
|
72 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 SDL_RenderDriver X11_RenderDriver = { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 X11_CreateRenderer, |
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 "x11", |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 (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
|
79 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
|
80 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
|
81 SDL_TEXTUREMODULATE_NONE, |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
82 SDL_BLENDMODE_NONE, |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 SDL_TEXTURESCALEMODE_NONE, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 0, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 {0}, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 0, |
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 }; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 typedef struct |
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 Display *display; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 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
|
94 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
|
95 int depth; |
2916
ffdd533f7add
Fixed pitch alignment problem causing MITSHM error on 16-bit displays
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
96 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
|
97 Window xwindow; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 Pixmap pixmaps[3]; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
99 #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
|
100 Pixmap mask; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
101 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
|
102 Picture pixmap_picts[3]; |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
103 Picture drawable_pict; |
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
|
104 Picture mask_pict; |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
105 int blend_op; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
106 XRenderPictFormat* xwindow_pict_fmt; |
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
|
107 GC mask_gc; |
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
|
108 SDL_bool use_xrender; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
109 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 int current_pixmap; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 Drawable drawable; |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
112 SDL_PixelFormat format; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 GC gc; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 SDL_DirtyRectList dirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 SDL_bool makedirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 } X11_RenderData; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 typedef struct |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 SDL_SW_YUVTexture *yuv; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 Uint32 format; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 Pixmap pixmap; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
123 #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
|
124 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
|
125 XRenderPictFormat* picture_fmt; |
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
|
126 SDL_bool use_xrender; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
127 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 XImage *image; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 /* 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
|
131 XShmSegmentInfo shminfo; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 #endif |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
133 XImage *scaling_image; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 void *pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 int pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 } X11_TextureData; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 /* 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
|
140 static int shm_error; |
2814 | 141 static int (*X_handler) (Display *, XErrorEvent *) = NULL; |
142 static int | |
143 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
|
144 { |
2814 | 145 if (e->error_code == BadAccess) { |
146 shm_error = True; | |
147 return (0); | |
148 } else { | |
149 return (X_handler(d, e)); | |
150 } | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 #endif /* ! NO_SHARED_MEMORY */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 UpdateYUVTextureData(SDL_Texture * texture) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 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
|
158 SDL_Rect rect; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 rect.x = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 rect.y = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 rect.w = texture->w; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 rect.h = texture->h; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 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
|
165 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
|
166 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 X11_AddRenderDriver(_THIS) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 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
|
172 SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode; |
3520
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
173 int i; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 |
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
|
175 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
|
176 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
|
177 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
|
178 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
|
179 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
|
180 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 |
3520
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
182 for (i = 0; i < _this->num_displays; ++i) { |
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
183 SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver); |
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
184 } |
2810
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 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 SDL_Renderer * |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 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
|
189 { |
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
|
190 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
|
191 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
|
192 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
|
193 SDL_Renderer *renderer; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 X11_RenderData *data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 XGCValues gcv; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 int i, n; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 int bpp; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 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
|
199 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 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
|
201 if (!renderer) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 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
|
207 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 data->xwindow = windowdata->xwindow; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
218 #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
|
219 int event_basep, error_basep; |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
220 if(XRenderQueryExtension(data->display, &event_basep, &error_basep) == True) { |
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
|
221 data->use_xrender = SDL_TRUE; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
222 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, data->visual); |
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
|
223 if(!data->xwindow_pict_fmt) { |
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
|
224 data->use_xrender = SDL_FALSE; |
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
|
225 goto fallback; |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
226 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
227 data->xwindow_pict = XRenderCreatePicture(data->display, data->xwindow, data->xwindow_pict_fmt, |
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
|
228 0, NULL); |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
229 if(!data->xwindow_pict) { |
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
|
230 data->use_xrender = SDL_FALSE; |
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
|
231 goto fallback; |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
232 } |
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
|
233 // Create a 1 bit depth mask |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
234 data->mask = XCreatePixmap(data->display, data->xwindow, |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
235 window->w, window->h, 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
|
236 data->mask_pict = XRenderCreatePicture(data->display, data->mask, |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
237 XRenderFindStandardFormat(data->display, |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
238 PictStandardA1), |
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
|
239 0, NULL); |
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
|
240 XGCValues gcv_mask; |
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
|
241 gcv_mask.foreground = 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
|
242 gcv_mask.background = 0; |
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
|
243 data->mask_gc = XCreateGC(data->display, data->mask, GCBackground | GCForeground, &gcv_mask); |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
244 } |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
245 else { |
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
|
246 data->use_xrender = SDL_FALSE; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
247 } |
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
|
248 fallback: |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
249 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 renderer->DisplayModeChanged = X11_DisplayModeChanged; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 renderer->CreateTexture = X11_CreateTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 renderer->QueryTexturePixels = X11_QueryTexturePixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 renderer->SetTextureBlendMode = X11_SetTextureBlendMode; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 renderer->SetTextureScaleMode = X11_SetTextureScaleMode; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 renderer->UpdateTexture = X11_UpdateTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 renderer->LockTexture = X11_LockTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 renderer->UnlockTexture = X11_UnlockTexture; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
258 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
|
259 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
|
260 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
|
261 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
|
262 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
|
263 renderer->RenderCopy = X11_RenderCopy; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
264 renderer->RenderReadPixels = X11_RenderReadPixels; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
265 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
|
266 renderer->RenderPresent = X11_RenderPresent; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 renderer->DestroyTexture = X11_DestroyTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 renderer->DestroyRenderer = X11_DestroyRenderer; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 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
|
270 renderer->window = window; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 renderer->driverdata = data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 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
|
274 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 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
|
276 renderer->info.flags |= |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 (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
|
278 n = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 } 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
|
280 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
|
281 n = 2; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 } 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
|
283 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
|
284 n = 3; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 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
|
287 n = 1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 for (i = 0; i < n; ++i) { |
2814 | 290 data->pixmaps[i] = |
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
|
291 XCreatePixmap(data->display, data->xwindow, window->w, window->h, |
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
|
292 displaydata->depth); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 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
|
294 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 SDL_SetError("XCreatePixmap() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 } |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
298 #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
|
299 if(data->use_xrender == SDL_TRUE) { |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
300 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
|
301 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt, |
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
|
302 0, None); |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
303 if(!data->pixmap_picts[i]) { |
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
|
304 data->use_xrender = SDL_FALSE; |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
305 } |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
306 XRenderComposite(data->display, PictOpClear, |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
307 data->pixmap_picts[i], None, data->pixmap_picts[i], |
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
|
308 0, 0, 0, 0, 0, 0, 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
|
309 } |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
310 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 if (n > 0) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 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
|
314 #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
|
315 if(data->use_xrender == SDL_TRUE) |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
316 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
|
317 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 data->makedirty = SDL_TRUE; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 } 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
|
320 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
|
321 #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
|
322 if(data->use_xrender == SDL_TRUE) |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
323 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
|
324 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 data->makedirty = SDL_FALSE; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 data->current_pixmap = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 /* Get the format of the window */ |
2874 | 330 if (!SDL_PixelFormatEnumToMasks |
331 (display->current_mode.format, &bpp, &Rmask, &Gmask, &Bmask, | |
332 &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
|
333 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
|
334 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
|
335 return NULL; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 } |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
337 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
|
338 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 /* Create the drawing context */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 gcv.graphics_exposures = False; |
2814 | 341 data->gc = |
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
|
342 XCreateGC(data->display, data->xwindow, GCGraphicsExposures, &gcv); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 if (!data->gc) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 SDL_SetError("XCreateGC() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 return renderer; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 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
|
354 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 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
|
356 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
|
357 int i, n; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 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
|
360 n = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 } 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
|
362 n = 2; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 } 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
|
364 n = 3; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 n = 1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 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
|
369 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
|
370 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
|
371 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
|
372 #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
|
373 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
|
374 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 for (i = 0; i < n; ++i) { |
2814 | 378 data->pixmaps[i] = |
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
|
379 XCreatePixmap(data->display, data->xwindow, window->w, window->h, |
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
|
380 data->depth); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 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
|
382 SDL_SetError("XCreatePixmap() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
385 #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
|
386 if(data->use_xrender == SDL_TRUE) { |
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
|
387 data->pixmap_picts[i] = |
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
388 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt, |
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
|
389 0, None); |
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
|
390 if(!data->pixmap_picts[i]) { |
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
|
391 data->use_xrender = SDL_FALSE; |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
392 } |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
393 XRenderComposite(data->display, PictOpClear, |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
394 data->pixmap_picts[i], None, data->pixmap_picts[i], |
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
|
395 0, 0, 0, 0, 0, 0, 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
|
396 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
397 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 if (n > 0) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 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
|
401 #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
|
402 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
|
403 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 data->current_pixmap = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 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
|
412 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 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
|
414 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
|
415 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
|
416 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
|
417 int pitch_alignmask = ((renderdata->scanline_pad / 8) - 1); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 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
|
420 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 texture->driverdata = data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 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
|
427 data->yuv = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 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
|
429 if (!data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 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
|
433 } else { |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
434 /* 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
|
435 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
|
436 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
|
437 */ |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
438 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4574
bfb4933c0efa
Fix initial value of the xrender_available boolean in X11_CreateTexture.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4573
diff
changeset
|
439 // Assume the texture is supported by 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
|
440 data->use_xrender = SDL_TRUE; |
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
|
441 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
|
442 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
|
443 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
|
444 return -1; |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
445 } |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
446 } |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
447 #else |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
448 /* 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
|
449 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
|
450 This BadMatch error |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
451 */ |
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
|
452 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
|
453 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
|
454 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
|
455 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
456 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 data->format = texture->format; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 } |
2814 | 459 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
|
460 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
|
461 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 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
|
463 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 XShmSegmentInfo *shminfo = &data->shminfo; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 shm_error = True; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 if (SDL_X11_HAVE_SHM) { |
2814 | 469 shminfo->shmid = |
470 shmget(IPC_PRIVATE, texture->h * data->pitch, | |
471 IPC_CREAT | 0777); | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 if (shminfo->shmid >= 0) { |
2814 | 473 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
|
474 shminfo->readOnly = False; |
2814 | 475 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
|
476 shm_error = False; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 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
|
478 XShmAttach(renderdata->display, shminfo); |
3239 | 479 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
|
480 XSetErrorHandler(X_handler); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 if (shm_error) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 shmdt(shminfo->shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 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
|
486 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 if (!shm_error) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 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
|
490 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
|
491 XCreatePixmap(renderdata->display, renderdata->xwindow, texture->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
|
492 texture->h, renderdata->depth); |
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
|
493 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
|
494 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
|
495 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
|
496 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
|
497 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
498 |
2814 | 499 data->image = |
2874 | 500 XShmCreateImage(renderdata->display, renderdata->visual, |
501 renderdata->depth, ZPixmap, shminfo->shmaddr, | |
502 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
|
503 |
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
|
504 if (!data->image) { |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 XShmDetach(renderdata->display, shminfo); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 XSync(renderdata->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 shmdt(shminfo->shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 shm_error = True; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 if (shm_error) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 shminfo->shmaddr = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 if (!data->image) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 #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
|
516 { |
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
|
517 /* This is the case where the server does not have |
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
|
518 shared memory support and the texture is streaming. |
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
|
519 It does not make sense to use Xrender here because |
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
|
520 we would have to copy the data onto a server side |
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
|
521 pixmap with XPutImage first and only then can we |
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
|
522 use Xrender |
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
|
523 */ |
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
|
524 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 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
|
526 if (!data->pixels) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
527 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
|
528 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 |
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
|
532 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
|
533 XCreatePixmap(renderdata->display, renderdata->xwindow, texture->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
|
534 texture->h, renderdata->depth); |
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
|
535 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
|
536 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
|
537 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
|
538 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
|
539 } |
2814 | 540 data->image = |
2874 | 541 XCreateImage(renderdata->display, renderdata->visual, |
542 renderdata->depth, ZPixmap, 0, data->pixels, | |
543 texture->w, texture->h, | |
544 SDL_BYTESPERPIXEL(data->format) * 8, | |
545 data->pitch); | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 if (!data->image) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
547 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
|
548 SDL_SetError("XCreateImage() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 return -1; |
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 } |
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
|
552 } |
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
|
553 else { |
2814 | 554 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
|
555 XCreatePixmap(renderdata->display, renderdata->xwindow, texture->w, |
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
|
556 texture->h, renderdata->depth); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
557 if (data->pixmap == None) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
558 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
|
559 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
|
560 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
561 } |
2814 | 562 data->image = |
2874 | 563 XCreateImage(renderdata->display, renderdata->visual, |
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
|
564 renderdata->depth, ZPixmap, 0, NULL, |
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
|
565 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
|
566 SDL_BYTESPERPIXEL(data->format) * 8, |
2874 | 567 data->pitch); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
568 if (!data->image) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
569 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
|
570 SDL_SetError("XCreateImage() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 } |
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
|
574 #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
|
575 if(renderdata->use_xrender && data->pixmap) { |
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
|
576 data->use_xrender = SDL_TRUE; |
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
|
577 data->picture_fmt = |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
578 XRenderFindVisualFormat(renderdata->display, renderdata->visual); |
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
|
579 if(!data->picture_fmt) { |
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
|
580 printf("XRenderFindFormat failed!\n"); |
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
|
581 data->use_xrender = SDL_FALSE; |
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
|
582 } |
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
|
583 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
|
584 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
|
585 data->picture_fmt, 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
|
586 if(!data->picture) { |
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
|
587 data->use_xrender = SDL_FALSE; |
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
|
588 } |
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
|
589 } |
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
|
590 /* We thought we could render the texture with Xrender but this was |
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
|
591 not possible for some reason. Now we must ensure that texture |
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
|
592 format and window format match to avoid a BadMatch error when |
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
|
593 rendering using the old pipeline. |
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
|
594 */ |
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
|
595 if(data->use_xrender == SDL_FALSE) { |
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
|
596 if (texture->format != display->current_mode.format) { |
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
|
597 SDL_SetError("Texture format doesn't match window format"); |
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
|
598 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
|
599 } |
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
|
600 } |
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
|
601 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
603 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
606 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
|
607 void **pixels, int *pitch) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
608 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
609 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
|
610 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
611 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
612 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
|
613 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
614 *pixels = data->pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
615 *pitch = data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
616 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
617 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
620 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 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
|
622 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 switch (texture->blendMode) { |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
624 case SDL_BLENDMODE_NONE: |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
625 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
626 default: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
627 SDL_Unsupported(); |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
628 texture->blendMode = SDL_BLENDMODE_NONE; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
629 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
630 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
631 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
632 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
633 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
634 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
|
635 { |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
636 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
|
637 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
638 switch (texture->scaleMode) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
639 case SDL_TEXTURESCALEMODE_NONE: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
640 return 0; |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
641 case SDL_TEXTURESCALEMODE_FAST: |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
642 /* 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
|
643 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
|
644 return 0; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
645 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
646 /* 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
|
647 default: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
648 SDL_Unsupported(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
649 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
|
650 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
651 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
652 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
653 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
656 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
|
657 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
|
658 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
659 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
|
660 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
661 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
662 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
|
663 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
664 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
665 UpdateYUVTextureData(texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
666 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
667 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
668 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
|
669 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
670 if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
671 Uint8 *src, *dst; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
672 int row; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
673 size_t length; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
674 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
675 src = (Uint8 *) pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
676 dst = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
677 (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
|
678 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
|
679 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
|
680 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
|
681 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
|
682 src += pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
683 dst += data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
684 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
685 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
686 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
|
687 data->image->height = rect->h; |
2814 | 688 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
|
689 data->image->bytes_per_line = pitch; |
2814 | 690 XPutImage(renderdata->display, data->pixmap, renderdata->gc, |
691 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
|
692 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
693 return 0; |
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 } |
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 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
698 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
|
699 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
|
700 int *pitch) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
701 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
702 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
|
703 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
704 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
705 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
|
706 pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
707 } else if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 *pixels = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
709 (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
|
710 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
|
711 *pitch = data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
712 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
713 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
714 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
|
715 return -1; |
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 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
718 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
719 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
720 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
|
721 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
722 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
|
723 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
724 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
725 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
|
726 UpdateYUVTextureData(texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
727 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
728 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
729 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
730 static int |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
731 X11_SetDrawBlendMode(SDL_Renderer * renderer) |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
732 { |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
733 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
|
734 switch (renderer->blendMode) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
735 case SDL_BLENDMODE_NONE: |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
736 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
737 data->blend_op = PictOpSrc; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
738 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
|
739 case SDL_BLENDMODE_MASK: // Use src pict as mask |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
740 data->blend_op = PictOpSrc; |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
741 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
|
742 case SDL_BLENDMODE_ADD: // PictOpAdd |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
743 data->blend_op = PictOpAdd; |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
744 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
|
745 case SDL_BLENDMODE_BLEND: // PictOpOver |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
746 data->blend_op = PictOpOver; |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
747 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
|
748 /* 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
|
749 #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
|
750 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
751 default: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
752 SDL_Unsupported(); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
753 renderer->blendMode = SDL_BLENDMODE_NONE; |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
754 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
755 data->blend_op = PictOpSrc; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
756 #endif |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
757 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
758 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
759 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
760 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
761 static Uint32 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
762 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
|
763 { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
764 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
|
765 Uint8 r = renderer->r; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
766 Uint8 g = renderer->g; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
767 Uint8 b = renderer->b; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
768 Uint8 a = renderer->a; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
769 if (premult) |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
770 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
|
771 ((int) g * (int) a) / 255, |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
772 ((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
|
773 else |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
774 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
|
775 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
776 |
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
|
777 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
|
778 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
|
779 { |
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
|
780 // 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
|
781 XRenderColor 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
|
782 xrender_color.red = ((unsigned short)renderer->r + 1) * ((unsigned short)renderer->a + 1) - 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
|
783 xrender_color.green = ((unsigned short)renderer->g + 1) * ((unsigned short)renderer->a + 1) - 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
|
784 xrender_color.blue = ((unsigned short)renderer->b + 1) * ((unsigned short)renderer->a + 1) - 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
|
785 xrender_color.alpha = ((unsigned short)renderer->a + 1) * ((unsigned short)renderer->a + 1) - 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
|
786 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
|
787 } |
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
|
788 |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
789 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
|
790 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
|
791 int count) |
2901 | 792 { |
793 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
|
794 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
|
795 XPoint *xpoints, *xpoint; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
796 int i, xcount; |
2901 | 797 |
798 if (data->makedirty) { | |
799 SDL_Rect rect; | |
800 | |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
801 /* Get the smallest rectangle that contains everything */ |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
802 rect.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
803 rect.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
804 rect.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
805 rect.h = window->h; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
806 if (!SDL_EnclosePoints(points, count, &rect, &rect)) { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
807 /* Nothing to draw */ |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
808 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
809 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
810 SDL_AddDirtyRect(&data->dirty, &rect); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
811 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
812 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
813 xpoint = xpoints = SDL_stack_alloc(XPoint, count); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
814 xcount = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
815 for (i = 0; i < count; ++i) { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
816 int x = points[i].x; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
817 int y = points[i].y; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
818 if (x < 0 || x >= window->w || y < 0 || y >= window->h) { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
819 continue; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
820 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
821 xpoint->x = (short)x; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
822 xpoint->y = (short)y; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
823 ++xpoint; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
824 ++xcount; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
825 } |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
826 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
827 if (data->use_xrender == SDL_TRUE) { |
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
|
828 XRenderColor foreground; |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
829 XRenderPictureAttributes attributes; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
830 unsigned long valuemask; |
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
|
831 |
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
|
832 foreground = xrenderdrawcolor(renderer); |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
833 /* Set the clip mask to restrict rendering to |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
834 * the primitive being drawn |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
835 */ |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
836 attributes.clip_mask = data->mask; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
837 valuemask = CPClipMask; |
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
|
838 |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
839 XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict, |
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
|
840 0, 0, 0, 0, 0, 0, window->w, window->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
|
841 |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
842 XDrawPoints(data->display, data->mask, data->mask_gc, xpoints, xcount, |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
843 CoordModeOrigin); |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
844 XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
845 Picture fill = |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
846 XRenderCreateSolidFill(data->display, &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
|
847 |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
848 XRenderComposite(data->display, data->blend_op, fill, data->mask_pict, |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
849 data->drawable_pict, 0, 0, 0, 0, 0, 0, window->w, window->h); |
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
|
850 |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
851 // Reset the clip_mask |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
852 attributes.clip_mask = None; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
853 XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
854 XRenderFreePicture(data->display, fill); |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
855 } |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
856 else |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
857 #endif |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
858 { |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
859 unsigned long foreground = renderdrawcolor(renderer, 1); |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
860 XSetForeground(data->display, data->gc, foreground); |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
861 |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
862 |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
863 if (xcount > 0) { |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
864 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
|
865 CoordModeOrigin); |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
866 } |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
867 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
868 SDL_stack_free(xpoints); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
869 |
2894 | 870 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
871 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
872 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
873 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
|
874 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
|
875 int count) |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
876 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
877 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
|
878 SDL_Window *window = renderer->window; |
4458
c9584df65367
Removed unused variables
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
879 SDL_Rect clip; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
880 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
|
881 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
|
882 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
|
883 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
|
884 int maxx, maxy; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
885 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
886 clip.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
887 clip.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
888 clip.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
889 clip.h = window->h; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
890 |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
891 Pixmap drawable; |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
892 GC gc; |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
893 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
894 if (data->use_xrender == SDL_TRUE) { |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
895 drawable = data->mask; |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
896 gc = data->mask_gc; |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
897 XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict, |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
898 0, 0, 0, 0, 0, 0, window->w, window->h); |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
899 } |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
900 else |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
901 #endif |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
902 { |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
903 drawable = data->drawable; |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
904 gc = data->gc; |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
905 } |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
906 |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
907 foreground = renderdrawcolor(renderer, 1); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
908 XSetForeground(data->display, data->gc, 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
|
909 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
910 xpoint = xpoints = SDL_stack_alloc(XPoint, count); |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
911 xcount = 0; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
912 minx = 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
|
913 miny = 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
|
914 maxx = INT_MIN; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
915 maxy = INT_MIN; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
916 for (i = 0; i < count; ++i) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
917 int x = points[i].x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
918 int y = points[i].y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
919 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
920 /* If the point is inside the window, add it to the list */ |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
921 if (x >= 0 && x < window->w && y >= 0 && y < window->h) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
922 if (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
|
923 minx = x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
924 } else if (x > maxx) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
925 maxx = x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
926 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
927 if (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
|
928 miny = y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
929 } else if (y > maxy) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
930 maxy = y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
931 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
932 xpoint->x = (short)x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
933 xpoint->y = (short)y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
934 ++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
|
935 ++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
|
936 continue; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
937 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
938 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
939 /* We need to clip the line segments joined by this point */ |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
940 if (xcount > 0) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
941 int x1 = xpoint[-1].x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
942 int y1 = xpoint[-1].y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
943 int x2 = x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
944 int y2 = y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
945 if (SDL_IntersectRectAndLine(&clip, &x1, &y1, &x2, &y2)) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
946 if (x2 < 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
|
947 minx = x2; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
948 } else if (x2 > maxx) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
949 maxx = x2; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
950 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
951 if (y2 < 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
|
952 miny = y2; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
953 } else if (y2 > maxy) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
954 maxy = y2; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
955 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
956 xpoint->x = (short)x2; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
957 xpoint->y = (short)y2; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
958 ++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
|
959 ++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
|
960 } |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
961 XDrawLines(data->display, drawable, 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
|
962 xpoints, xcount, CoordModeOrigin); |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
963 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
|
964 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
|
965 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
966 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
|
967 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
|
968 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
969 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
|
970 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
|
971 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
|
972 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
|
973 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
|
974 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
975 xpoint = 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
|
976 xcount = 0; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
977 minx = 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
|
978 miny = 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
|
979 maxx = INT_MIN; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
980 maxy = INT_MIN; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
981 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
982 if (i < (count-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
|
983 int x1 = x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
984 int y1 = y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
985 int x2 = points[i+1].x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
986 int y2 = points[i+1].y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
987 if (SDL_IntersectRectAndLine(&clip, &x1, &y1, &x2, &y2)) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
988 if (x1 < 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
|
989 minx = x1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
990 } else if (x1 > maxx) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
991 maxx = x1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
992 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
993 if (y1 < 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
|
994 miny = y1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
995 } else if (y1 > maxy) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
996 maxy = y1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
997 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
998 xpoint->x = (short)x1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
999 xpoint->y = (short)y1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1000 ++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
|
1001 ++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
|
1002 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1003 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1004 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1005 if (xcount > 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
|
1006 int x2 = xpoint[-1].x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1007 int y2 = xpoint[-1].y; |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1008 XDrawLines(data->display, drawable, gc, xpoints, xcount, |
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
|
1009 CoordModeOrigin); |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1010 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
|
1011 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
|
1012 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1013 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
|
1014 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
|
1015 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1016 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
|
1017 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
|
1018 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
|
1019 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
|
1020 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
|
1021 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1022 } |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1023 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1024 if(data->use_xrender == SDL_TRUE) { |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1025 XRenderColor xrforeground = xrenderdrawcolor(renderer); |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1026 XRenderPictureAttributes attributes; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1027 attributes.clip_mask = data->mask; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1028 unsigned long valuemask = CPClipMask; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1029 XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1030 Picture fill = XRenderCreateSolidFill(data->display, &xrforeground); |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1031 XRenderComposite(data->display, data->blend_op, fill, data->mask_pict, |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1032 data->drawable_pict, 0, 0, 0, 0, 0, 0, window->w, window->h); |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1033 attributes.clip_mask = None; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1034 XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1035 XRenderFreePicture(data->display, fill); |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1036 } |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1037 #endif |
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
|
1038 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
|
1039 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1040 return 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1041 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1042 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1043 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
|
1044 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
|
1045 { |
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
|
1046 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
|
1047 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
|
1048 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
|
1049 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
|
1050 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
|
1051 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
|
1052 xcount = 0; |
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
|
1053 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
|
1054 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
|
1055 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
|
1056 } |
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
|
1057 |
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
|
1058 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
|
1059 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
|
1060 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
|
1061 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
|
1062 ++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
|
1063 ++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
|
1064 |
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
|
1065 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
|
1066 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
|
1067 } |
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
|
1068 } |
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
|
1069 clip.x = 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
|
1070 clip.y = 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
|
1071 clip.w = window->w; |
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
|
1072 clip.h = window->h; |
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
|
1073 |
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
|
1074 #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
|
1075 if(data->use_xrender == SDL_TRUE) { |
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
|
1076 XRenderColor foreground; |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1077 XRenderPictureAttributes attributes; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1078 unsigned long valuemask; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1079 |
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
|
1080 foreground = xrenderdrawcolor(renderer); |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1081 valuemask = CPClipMask; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1082 attributes.clip_mask = data->mask; |
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
|
1083 |
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
|
1084 XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_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
|
1085 0, 0, 0, 0, 0, 0, window->w, window->h); |
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
|
1086 XDrawRectangles(data->display, data->mask, data->mask_gc, xrects, xcount); |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1087 XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); |
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
|
1088 Picture fill = |
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
|
1089 XRenderCreateSolidFill(data->display, &foreground); |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1090 XRenderComposite(data->display, data->blend_op, fill, data->mask_pict, |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1091 data->drawable_pict, 0, 0, 0, 0, 0, 0, window->w, window->h); |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1092 attributes.clip_mask = None; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1093 XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); |
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
|
1094 XRenderFreePicture(data->display, fill); |
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
|
1095 } |
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
|
1096 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
|
1097 #endif |
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
|
1098 { |
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
|
1099 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
|
1100 |
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
|
1101 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
|
1102 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
|
1103 |
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
|
1104 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
|
1105 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
|
1106 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
|
1107 } |
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
|
1108 } |
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
|
1109 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
|
1110 |
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
|
1111 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
|
1112 } |
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
|
1113 |
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
|
1114 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
|
1115 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
|
1116 { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1117 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
|
1118 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
|
1119 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
|
1120 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1121 clip.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1122 clip.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1123 clip.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1124 clip.h = window->h; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1125 |
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
|
1126 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
|
1127 XRectangle *xrects, *xrect; |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1128 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
|
1129 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
|
1130 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
|
1131 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
|
1132 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
|
1133 } |
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
|
1134 |
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
|
1135 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
|
1136 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
|
1137 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
|
1138 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
|
1139 ++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
|
1140 ++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
|
1141 |
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
|
1142 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
|
1143 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
|
1144 } |
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
|
1145 } |
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
|
1146 |
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
|
1147 #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
|
1148 if(data->use_xrender == SDL_TRUE) { |
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
|
1149 XRenderColor foreground; |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1150 XRenderPictureAttributes attributes; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1151 unsigned long valuemask; |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1152 |
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
|
1153 foreground = xrenderdrawcolor(renderer); |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1154 attributes.clip_mask = data->mask; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1155 valuemask = CPClipMask; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1156 attributes.clip_mask = data->mask; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1157 |
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
|
1158 XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_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
|
1159 0, 0, 0, 0, 0, 0, window->w, window->h); |
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
|
1160 XFillRectangles(data->display, data->mask, data->mask_gc, |
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
|
1161 xrects, xcount); |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1162 |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1163 XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1164 |
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
|
1165 Picture fill = |
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
|
1166 XRenderCreateSolidFill(data->display, &foreground); |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1167 XRenderComposite(data->display, data->blend_op, fill, data->mask_pict, |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1168 data->drawable_pict, 0, 0, 0, 0, 0, 0, window->w, window->h); |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1169 attributes.clip_mask = None; |
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1170 XRenderChangePicture(data->display, data->drawable_pict, valuemask, &attributes); |
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
|
1171 XRenderFreePicture(data->display, fill); |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1172 } |
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
|
1173 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
|
1174 #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
|
1175 { |
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
|
1176 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
|
1177 |
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
|
1178 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
|
1179 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
|
1180 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1181 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
|
1182 xrects, xcount); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1183 } |
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
|
1184 |
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
|
1185 SDL_stack_free(xrects); |
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
|
1186 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1187 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1188 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1189 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1190 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1191 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
|
1192 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
|
1193 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1194 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
|
1195 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
|
1196 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1197 if (data->makedirty) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1198 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
|
1199 } |
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
|
1200 #ifdef SDL_VIDEO_DRIVER_X11_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
|
1201 if (data->use_xrender && texturedata->use_xrender) { |
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
|
1202 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
|
1203 #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
|
1204 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
|
1205 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
|
1206 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
|
1207 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
|
1208 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
|
1209 } |
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
|
1210 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
|
1211 #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
|
1212 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
|
1213 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
|
1214 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
|
1215 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
|
1216 } |
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
|
1217 } |
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
|
1218 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
|
1219 XRenderComposite(data->display, PictOpOver, texturedata->picture, None, data->drawable_pict, |
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
|
1220 srcrect->x, srcrect->y, 0, 0, dstrect->x, dstrect->y, srcrect->w, srcrect->h); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1221 } 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
|
1222 Pixmap scaling_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
|
1223 XCreatePixmap(data->display, texturedata->pixmap, 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
|
1224 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
|
1225 Picture scaling_picture = |
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
|
1226 XRenderCreatePicture(data->display, scaling_pixmap, texturedata->picture_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
|
1227 0, NULL); |
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
|
1228 XRenderComposite(data->display, PictOpClear, scaling_picture, None, scaling_picture, |
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
|
1229 0, 0, 0, 0, 0, 0, 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
|
1230 XRenderComposite(data->display, PictOpSrc, texturedata->picture, None, scaling_picture, |
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
|
1231 srcrect->x, srcrect->y, 0, 0, 0, 0, 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
|
1232 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
|
1233 double yscale = ((double) dstrect->h) / 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
|
1234 XTransform xform = |
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
|
1235 {{{XDoubleToFixed(xscale), XDoubleToFixed(0), XDoubleToFixed(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
|
1236 {XDoubleToFixed(0), XDoubleToFixed(yscale), XDoubleToFixed(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
|
1237 {XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(xscale * yscale)}}}; |
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
|
1238 XRenderSetPictureTransform(data->display, scaling_picture, &xform); |
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
|
1239 XRenderComposite(data->display, PictOpOver, scaling_picture, None, data->drawable_pict, |
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
|
1240 0, 0, 0, 0, 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
|
1241 XRenderFreePicture(data->display, scaling_picture); |
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
|
1242 XFreePixmap(data->display, scaling_pixmap); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1243 } |
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
|
1244 } |
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
|
1245 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
|
1246 #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
|
1247 { |
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
|
1248 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
|
1249 #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
|
1250 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
|
1251 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
|
1252 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
|
1253 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
|
1254 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
|
1255 } 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
|
1256 #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
|
1257 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
|
1258 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
|
1259 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
|
1260 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
|
1261 } 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
|
1262 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
|
1263 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
|
1264 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
|
1265 } |
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
|
1266 } 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
|
1267 || 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
|
1268 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
|
1269 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
|
1270 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
|
1271 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
|
1272 |
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
|
1273 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
|
1274 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
|
1275 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
|
1276 |
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
|
1277 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
|
1278 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
|
1279 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
|
1280 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
|
1281 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
|
1282 } |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1283 |
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
|
1284 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
|
1285 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
|
1286 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
|
1287 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
|
1288 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
|
1289 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
|
1290 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
|
1291 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
|
1292 } |
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
|
1293 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
|
1294 |
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
|
1295 } 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
|
1296 || !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
|
1297 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
|
1298 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
|
1299 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
|
1300 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
|
1301 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
|
1302 (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
|
1303 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
|
1304 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
|
1305 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
|
1306 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
|
1307 } |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1308 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1309 |
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
|
1310 /* 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
|
1311 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
|
1312 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
|
1313 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
|
1314 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
|
1315 #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
|
1316 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
|
1317 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
|
1318 } 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
|
1319 #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
|
1320 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
|
1321 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
|
1322 |
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
|
1323 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
|
1324 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
|
1325 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
|
1326 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
|
1327 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
|
1328 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
|
1329 |
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
|
1330 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
|
1331 |
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
|
1332 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
|
1333 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
|
1334 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
|
1335 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
|
1336 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
|
1337 return -1; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1338 } |
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
|
1339 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
|
1340 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
|
1341 } 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
|
1342 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
|
1343 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
|
1344 srcrect->x, srcrect->y); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1345 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1346 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1347 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1348 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1349 |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1350 static int |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1351 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
|
1352 Uint32 format, void * pixels, int pitch) |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1353 { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1354 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
|
1355 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
|
1356 SDL_VideoDisplay *display = window->display; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1357 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
|
1358 XImage *image; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1359 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1360 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
|
1361 rect->w, rect->h, AllPlanes, ZPixmap); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1362 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1363 SDL_ConvertPixels(rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1364 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
|
1365 format, pixels, pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1366 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1367 XDestroyImage(image); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1368 return 0; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1369 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1370 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1371 static int |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1372 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
|
1373 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
|
1374 { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1375 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
|
1376 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
|
1377 SDL_VideoDisplay *display = window->display; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1378 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
|
1379 XImage *image; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1380 void *image_pixels; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1381 int image_pitch; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1382 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1383 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
|
1384 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
|
1385 if (!image_pixels) { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1386 SDL_OutOfMemory(); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1387 return -1; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1388 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1389 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1390 image = XCreateImage(data->display, data->visual, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1391 data->depth, ZPixmap, 0, image_pixels, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1392 rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1393 SDL_BYTESPERPIXEL(screen_format) * 8, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1394 image_pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1395 if (!image) { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1396 SDL_SetError("XCreateImage() failed"); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1397 return -1; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1398 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1399 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1400 SDL_ConvertPixels(rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1401 format, pixels, pitch, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1402 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
|
1403 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1404 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
|
1405 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
|
1406 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1407 image->data = NULL; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1408 XDestroyImage(image); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1409 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1410 SDL_free(image_pixels); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1411 return 0; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1412 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1413 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1414 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1415 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
|
1416 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1417 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
|
1418 SDL_DirtyRect *dirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1419 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1420 /* 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
|
1421 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
|
1422 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
|
1423 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
|
1424 #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
|
1425 if(data->use_xrender == SDL_TRUE) |
4579
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1426 { |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1427 if(renderer->blendMode == SDL_BLENDMODE_MASK) |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1428 XRenderComposite(data->display, data->blend_op, data->drawable_pict, |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1429 data->drawable_pict, data->xwindow_pict, rect->x, rect->y, |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1430 0, 0, rect->x, rect->y, rect->w, rect->h); |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1431 else |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1432 XRenderComposite(data->display, data->blend_op, data->drawable_pict, None, |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1433 data->xwindow_pict, rect->x, rect->y, 0, 0, rect->x, rect->y, |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1434 rect->w, rect->h); |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1435 |
4579
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1436 } |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1437 else |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1438 #endif |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1439 { |
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
|
1440 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
|
1441 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
|
1442 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
|
1443 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1444 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1445 SDL_ClearDirtyRects(&data->dirty); |
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
|
1446 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1447 XSync(data->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1448 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1449 /* 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
|
1450 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
|
1451 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
|
1452 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
|
1453 #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
|
1454 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
|
1455 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1456 } 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
|
1457 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
|
1458 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
|
1459 #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
|
1460 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
|
1461 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1462 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1463 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1464 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1465 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1466 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
|
1467 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1468 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
|
1469 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
|
1470 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1471 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1472 return; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1473 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1474 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1475 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
|
1476 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1477 if (data->pixmap != None) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1478 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
|
1479 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1480 if (data->image) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1481 data->image->data = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1482 XDestroyImage(data->image); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1483 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1484 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1485 if (data->shminfo.shmaddr) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1486 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
|
1487 XSync(renderdata->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1488 shmdt(data->shminfo.shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1489 data->pixels = NULL; |
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 #endif |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1492 if (data->scaling_image) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1493 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
|
1494 data->scaling_image->data = NULL; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1495 XDestroyImage(data->scaling_image); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1496 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1497 if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1498 SDL_free(data->pixels); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1499 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1500 SDL_free(data); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1501 texture->driverdata = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1502 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1503 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1504 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1505 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
|
1506 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1507 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
|
1508 int i; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1509 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1510 if (data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1511 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
|
1512 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
|
1513 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
|
1514 } |
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
|
1515 #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
|
1516 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
|
1517 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
|
1518 } |
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
|
1519 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1520 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1521 if (data->gc) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1522 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
|
1523 } |
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
|
1524 if (data->drawable) { |
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
|
1525 XFreePixmap(data->display, data->drawable); |
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
|
1526 } |
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
|
1527 #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
|
1528 if (data->mask_gc) { |
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
|
1529 XFreeGC(data->display, data->gc); |
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
|
1530 } |
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
|
1531 if (data->mask_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
|
1532 XRenderFreePicture(data->display, data->mask_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
|
1533 } |
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
|
1534 if (data->mask) { |
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
|
1535 XFreePixmap(data->display, data->mask); |
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
|
1536 } |
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
|
1537 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
|
1538 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
|
1539 } |
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
|
1540 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
|
1541 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
|
1542 } |
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
|
1543 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1544 SDL_FreeDirtyRects(&data->dirty); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1545 SDL_free(data); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1546 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1547 SDL_free(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1548 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1549 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1550 #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
|
1551 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1552 /* vi: set ts=4 sw=4 expandtab: */ |