Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11render.c @ 4624:b70b99ab75b8
Oops!
author | Sunny Sachanandani <sunnysachanandani@gmail.com> |
---|---|
date | Wed, 28 Jul 2010 15:35:18 +0530 |
parents | 10175d54adf4 |
children | 44fd1f0b895a |
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" |
4472
791b3256fb22
Mostly cleaned up warnings with -Wmissing-prototypes
Sam Lantinga <slouken@libsdl.org>
parents:
4458
diff
changeset
|
30 #include "SDL_x11render.h" |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 #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
|
32 #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
|
33 #include "../SDL_yuv_sw_c.h" |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
34 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 /* X11 renderer implementation */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 int *pitch); |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
43 static int X11_SetTextureRGBAMod(SDL_Renderer * renderer, |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
44 SDL_Texture * texture); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 static int X11_SetTextureBlendMode(SDL_Renderer * renderer, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 static int X11_SetTextureScaleMode(SDL_Renderer * renderer, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 static int X11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 const SDL_Rect * rect, const void *pixels, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 int pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 static int X11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 const SDL_Rect * rect, int markDirty, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 void **pixels, int *pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 static void X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
56 static int X11_SetDrawBlendMode(SDL_Renderer * renderer); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
57 static int X11_RenderDrawPoints(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
58 const SDL_Point * points, int count); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
59 static int X11_RenderDrawLines(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
60 const SDL_Point * points, int count); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
61 static int X11_RenderDrawRects(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
62 const SDL_Rect ** rects, int count); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
63 static int X11_RenderFillRects(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
64 const SDL_Rect ** rects, int count); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 static int X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 const SDL_Rect * srcrect, const SDL_Rect * dstrect); |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
67 static int X11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
68 Uint32 format, void * pixels, int pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
69 static int X11_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
70 Uint32 format, const void * pixels, int pitch); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 static void X11_RenderPresent(SDL_Renderer * renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 static void X11_DestroyTexture(SDL_Renderer * renderer, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 static void X11_DestroyRenderer(SDL_Renderer * renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 SDL_RenderDriver X11_RenderDriver = { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 X11_CreateRenderer, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 "x11", |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED), |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 SDL_TEXTUREMODULATE_NONE, |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
85 SDL_BLENDMODE_NONE, |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 SDL_TEXTURESCALEMODE_NONE, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 0, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 {0}, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 0, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 0} |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 }; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 typedef struct |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 Display *display; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 int screen; |
2870
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
97 Visual *visual; |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
98 int depth; |
2916
ffdd533f7add
Fixed pitch alignment problem causing MITSHM error on 16-bit displays
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
99 int scanline_pad; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
100 Window xwindow; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 Pixmap pixmaps[3]; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
102 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
103 Pixmap stencil; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
104 Pixmap brush; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
105 Picture brush_pict; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
106 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
|
107 Picture pixmap_picts[3]; |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
108 Picture drawable_pict; |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
109 Picture stencil_pict; |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
110 int blend_op; |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
111 XRenderPictFormat *xwindow_pict_fmt; |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
112 XRenderPictFormat *drawable_pict_fmt; |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
113 GC stencil_gc; |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
114 SDL_bool use_xrender; |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
115 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
116 SDL_bool use_xdamage; |
4602
4fbf64d504cf
Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4600
diff
changeset
|
117 Damage stencil_damage; |
4fbf64d504cf
Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4600
diff
changeset
|
118 XserverRegion stencil_parts; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
119 #endif |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
120 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 int current_pixmap; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 Drawable drawable; |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
123 SDL_PixelFormat format; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 GC gc; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 SDL_DirtyRectList dirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 SDL_bool makedirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 } X11_RenderData; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 typedef struct |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 SDL_SW_YUVTexture *yuv; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 Uint32 format; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 Pixmap pixmap; |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
134 int depth; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
135 Visual *visual; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
136 GC gc; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
137 #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
|
138 Picture picture; |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
139 Pixmap modulated_pixmap; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
140 Picture modulated_picture; |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
141 XRenderPictFormat* picture_fmt; |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
142 int blend_op; |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
143 const char* filter; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
144 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 XImage *image; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 /* 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
|
148 XShmSegmentInfo shminfo; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 #endif |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
150 XImage *scaling_image; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 void *pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 int pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 } X11_TextureData; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 /* 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
|
157 static int shm_error; |
2814 | 158 static int (*X_handler) (Display *, XErrorEvent *) = NULL; |
159 static int | |
160 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
|
161 { |
2814 | 162 if (e->error_code == BadAccess) { |
163 shm_error = True; | |
164 return (0); | |
165 } else { | |
166 return (X_handler(d, e)); | |
167 } | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 #endif /* ! NO_SHARED_MEMORY */ |
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 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 UpdateYUVTextureData(SDL_Texture * texture) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 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
|
175 SDL_Rect rect; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 rect.x = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 rect.y = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 rect.w = texture->w; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 rect.h = texture->h; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 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
|
182 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
|
183 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 |
4605
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
185 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
186 static SDL_bool |
4619
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
187 CheckXRender(Display *display, int *major, int *minor) |
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
188 { |
4605
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
189 const char *env; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
190 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
191 *major = *minor = 0; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
192 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
193 env = SDL_getenv("SDL_VIDEO_X11_XRENDER"); |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
194 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
195 if (env && !SDL_atoi(env)) { |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
196 return SDL_FALSE; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
197 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
198 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
199 if (!SDL_X11_HAVE_XRENDER) { |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
200 return SDL_FALSE; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
201 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
202 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
203 if (!XRenderQueryVersion(display, major, minor)) { |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
204 return SDL_FALSE; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
205 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
206 |
4624 | 207 if (*major != 0 || *minor < 10) { |
4623
10175d54adf4
Depend on XRender version 0.10 or above and XFixes version 2.0 or above. Moved these dependency checks into CheckXRender() and CheckXFixes().
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4622
diff
changeset
|
208 return SDL_FALSE; |
10175d54adf4
Depend on XRender version 0.10 or above and XFixes version 2.0 or above. Moved these dependency checks into CheckXRender() and CheckXFixes().
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4622
diff
changeset
|
209 } |
10175d54adf4
Depend on XRender version 0.10 or above and XFixes version 2.0 or above. Moved these dependency checks into CheckXRender() and CheckXFixes().
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4622
diff
changeset
|
210 |
4605
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
211 return SDL_TRUE; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
212 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
213 #endif |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
214 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
215 #ifdef SDL_VIDEO_DRIVER_X11_XFIXES |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
216 static SDL_bool |
4619
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
217 CheckXFixes(Display *display, int *major, int *minor) |
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
218 { |
4605
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
219 const char *env; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
220 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
221 *major = *minor = 0; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
222 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
223 env = SDL_getenv("SDL_VIDEO_X11_XFIXES"); |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
224 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
225 if (env && !SDL_atoi(env)) { |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
226 return SDL_FALSE; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
227 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
228 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
229 if (!SDL_X11_HAVE_XFIXES) { |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
230 return SDL_FALSE; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
231 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
232 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
233 if (!XFixesQueryVersion(display, major, minor)) { |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
234 return SDL_FALSE; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
235 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
236 |
4624 | 237 if (*major < 2) { |
4623
10175d54adf4
Depend on XRender version 0.10 or above and XFixes version 2.0 or above. Moved these dependency checks into CheckXRender() and CheckXFixes().
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4622
diff
changeset
|
238 return SDL_FALSE; |
10175d54adf4
Depend on XRender version 0.10 or above and XFixes version 2.0 or above. Moved these dependency checks into CheckXRender() and CheckXFixes().
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4622
diff
changeset
|
239 } |
10175d54adf4
Depend on XRender version 0.10 or above and XFixes version 2.0 or above. Moved these dependency checks into CheckXRender() and CheckXFixes().
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4622
diff
changeset
|
240 |
4605
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
241 return SDL_TRUE; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
242 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
243 #endif |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
244 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
245 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
246 static SDL_bool |
4619
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
247 CheckXDamage(Display *display, int *major, int *minor) |
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
248 { |
4605
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
249 const char *env; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
250 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
251 *major = *minor = 0; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
252 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
253 env = SDL_getenv("SDL_VIDEO_X11_XDAMAGE"); |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
254 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
255 if (env && !SDL_atoi(env)) { |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
256 return SDL_FALSE; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
257 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
258 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
259 if (!SDL_X11_HAVE_XDAMAGE) { |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
260 return SDL_FALSE; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
261 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
262 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
263 if (!XDamageQueryVersion(display, major, minor)) { |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
264 return SDL_FALSE; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
265 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
266 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
267 return SDL_TRUE; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
268 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
269 #endif |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
270 |
4612
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
271 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
272 static Uint32 |
4619
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
273 XRenderPictFormatToSDLPixelFormatEnum(XRenderPictFormat *pict_format) |
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
274 { |
4612
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
275 if (pict_format->type != PictTypeDirect) { |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
276 SDL_SetError("Indexed pict formats not supported ATM"); |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
277 return 0; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
278 } |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
279 Uint32 Amask, Rmask, Gmask, Bmask; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
280 int bpp; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
281 |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
282 Rmask = pict_format->direct.redMask << pict_format->direct.red; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
283 Gmask = pict_format->direct.greenMask << pict_format->direct.green; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
284 Bmask = pict_format->direct.blueMask << pict_format->direct.blue; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
285 Amask = pict_format->direct.alphaMask << pict_format->direct.alpha; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
286 bpp = pict_format->depth; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
287 |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
288 Uint32 format; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
289 format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
290 return format; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
291 } |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
292 #endif |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
293 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 X11_AddRenderDriver(_THIS) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 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
|
298 SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode; |
4605
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
299 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
3520
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
300 int i; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 |
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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; |
4605
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
308 |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
309 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
310 int major, minor; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
311 if (CheckXRender(data->display, &major, &minor)) { |
4612
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
312 XRenderPictFormat templ; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
313 templ.type = PictTypeDirect; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
314 XRenderPictFormat *pict_format; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
315 Uint32 format; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
316 int i = 0; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
317 while (info->num_texture_formats < 50) { |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
318 pict_format = |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
319 XRenderFindFormat(data->display, PictFormatType, &templ, i++); |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
320 if (pict_format) { |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
321 format = XRenderPictFormatToSDLPixelFormatEnum(pict_format); |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
322 if (format != SDL_PIXELTYPE_UNKNOWN) { |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
323 info->texture_formats[info->num_texture_formats++] = format; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
324 } |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
325 } |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
326 else |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
327 break; |
9a5db97cd569
Advertise support for all supported texture formats.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4611
diff
changeset
|
328 } |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
329 info->blend_modes |= (SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | |
4611
a2ed55b5ff85
Advertise support for blending modes and scaling modes in the render driver.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4610
diff
changeset
|
330 SDL_BLENDMODE_MOD | SDL_BLENDMODE_MASK); |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
331 info->scale_modes |= (SDL_TEXTURESCALEMODE_FAST | SDL_TEXTURESCALEMODE_SLOW | |
4611
a2ed55b5ff85
Advertise support for blending modes and scaling modes in the render driver.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4610
diff
changeset
|
332 SDL_TEXTURESCALEMODE_BEST); |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
333 info->mod_modes |= (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA); |
4605
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
334 } |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
335 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 |
3520
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
337 for (i = 0; i < _this->num_displays; ++i) { |
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
338 SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver); |
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
339 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 SDL_Renderer * |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 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
|
344 { |
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
|
345 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
|
346 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
|
347 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
|
348 SDL_Renderer *renderer; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 X11_RenderData *data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 XGCValues gcv; |
4596
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
351 gcv.graphics_exposures = False; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 int i, n; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 int bpp; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 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
|
355 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 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
|
357 if (!renderer) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 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
|
363 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 return NULL; |
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 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
|
369 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
|
370 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
|
371 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
|
372 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
|
373 data->xwindow = windowdata->xwindow; |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
374 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 renderer->DisplayModeChanged = X11_DisplayModeChanged; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 renderer->CreateTexture = X11_CreateTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 renderer->QueryTexturePixels = X11_QueryTexturePixels; |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
378 renderer->SetTextureAlphaMod = X11_SetTextureRGBAMod; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
379 renderer->SetTextureColorMod = X11_SetTextureRGBAMod; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 renderer->SetTextureBlendMode = X11_SetTextureBlendMode; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 renderer->SetTextureScaleMode = X11_SetTextureScaleMode; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 renderer->UpdateTexture = X11_UpdateTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 renderer->LockTexture = X11_LockTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 renderer->UnlockTexture = X11_UnlockTexture; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
385 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
|
386 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
|
387 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
|
388 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
|
389 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
|
390 renderer->RenderCopy = X11_RenderCopy; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
391 renderer->RenderReadPixels = X11_RenderReadPixels; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
392 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
|
393 renderer->RenderPresent = X11_RenderPresent; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 renderer->DestroyTexture = X11_DestroyTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 renderer->DestroyRenderer = X11_DestroyRenderer; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 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
|
397 renderer->window = window; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 renderer->driverdata = data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 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
|
401 |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
402 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4605
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
403 int major, minor; |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
404 data->use_xrender = CheckXRender(data->display, &major, &minor); |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
405 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
406 if (CheckXDamage(data->display, &major, &minor)) { |
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
407 if (CheckXFixes(data->display, &major, &minor)) { |
4623
10175d54adf4
Depend on XRender version 0.10 or above and XFixes version 2.0 or above. Moved these dependency checks into CheckXRender() and CheckXFixes().
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4622
diff
changeset
|
408 data->use_xdamage = SDL_TRUE; |
4605
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
409 } |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
410 } |
4605
0b3a509c53a0
Respect environment variables.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4604
diff
changeset
|
411 #endif |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
412 if (data->use_xrender) { |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
413 /* Find the PictFormat from the visual. |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
414 * Should be an RGB PictFormat most of the time. */ |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
415 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
416 data->visual); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
417 if (!data->xwindow_pict_fmt) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
418 SDL_SetError("XRenderFindVisualFormat() failed"); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
419 return NULL; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
420 } |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
421 data->xwindow_pict = XRenderCreatePicture(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
422 data->xwindow, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
423 data->xwindow_pict_fmt, |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
424 0, NULL); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
425 if (!data->xwindow_pict) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
426 SDL_SetError("XRenderCreatePicture() failed"); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
427 return NULL; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
428 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
429 // FIXME: Clear the window. Is this required? |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
430 XRenderComposite(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
431 PictOpClear, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
432 data->xwindow_pict, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
433 None, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
434 data->xwindow_pict, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
435 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
436 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
437 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
438 window->w, window->h); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
439 /* Create a clip mask that is used for rendering primitives. */ |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
440 data->stencil = XCreatePixmap(data->display, data->xwindow, |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
441 window->w, window->h, 32); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
442 |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
443 /* Create the GC for the clip mask. */ |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
444 data->stencil_gc = XCreateGC(data->display, data->stencil, |
4596
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
445 GCGraphicsExposures, &gcv); |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
446 XSetBackground(data->display, data->stencil_gc, 0); |
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
447 XSetForeground(data->display, data->stencil_gc, 0); |
4602
4fbf64d504cf
Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4600
diff
changeset
|
448 XFillRectangle(data->display, data->stencil, data->stencil_gc, |
4fbf64d504cf
Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4600
diff
changeset
|
449 0, 0, window->w, window->h); |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
450 XSetForeground(data->display, data->stencil_gc, 0xFFFFFFFF); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
451 data->stencil_pict = |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
452 XRenderCreatePicture(data->display, data->stencil, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
453 XRenderFindStandardFormat(data->display, |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
454 PictStandardARGB32), |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
455 0, NULL); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
456 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
457 if (data->use_xdamage) { |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
458 data->stencil_damage = |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
459 XDamageCreate(data->display, data->stencil, XDamageReportNonEmpty); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
460 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
461 } |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
462 #endif |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
463 data->brush = |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
464 XCreatePixmap(data->display, data->xwindow, 1, 1, 32); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
465 XRenderPictureAttributes brush_attr; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
466 brush_attr.repeat = RepeatNormal; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
467 data->brush_pict = |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
468 XRenderCreatePicture(data->display, data->brush, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
469 XRenderFindStandardFormat(data->display, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
470 PictStandardARGB32), |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
471 CPRepeat, &brush_attr); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
472 // Set the default blending mode. |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
473 renderer->blendMode = SDL_BLENDMODE_BLEND; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
474 data->blend_op = PictOpOver; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
475 } |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
476 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 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
|
478 renderer->info.flags |= |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 (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
|
480 n = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 } 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
|
482 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
|
483 n = 2; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 } 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
|
485 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
|
486 n = 3; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 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
|
489 n = 1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 } |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
491 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
492 if (data->use_xrender) { |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
493 if (n > 0) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
494 data->drawable_pict_fmt = |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
495 XRenderFindStandardFormat(data->display, PictStandardARGB32); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
496 else |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
497 data->drawable_pict_fmt = data->xwindow_pict_fmt; |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
498 } |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
499 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
500 for (i = 0; i < n; ++i) { |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
501 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
502 if (data->use_xrender) { |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
503 data->pixmaps[i] = XCreatePixmap(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
504 data->xwindow, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
505 window->w, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
506 window->h, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
507 32); |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
508 } |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
509 else |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
510 #endif |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
511 { |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
512 data->pixmaps[i] = |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
513 XCreatePixmap(data->display, data->xwindow, window->w, window->h, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
514 displaydata->depth); |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
515 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 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
|
517 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 SDL_SetError("XCreatePixmap() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 } |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
521 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
522 if (data->use_xrender) { |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
523 /* Create xrender pictures for each of the pixmaps |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
524 * and clear the pixmaps. */ |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
525 data->pixmap_picts[i] = |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
526 XRenderCreatePicture(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
527 data->pixmaps[i], |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
528 XRenderFindStandardFormat(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
529 PictStandardARGB32), |
4583
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
530 0, None); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
531 if (!data->pixmap_picts[i]) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
532 SDL_SetError("XRenderCreatePicture() failed"); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
533 return NULL; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
534 } |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
535 |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
536 XRenderComposite(data->display, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
537 PictOpClear, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
538 data->pixmap_picts[i], |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
539 None, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
540 data->pixmap_picts[i], |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
541 0, 0, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
542 0, 0, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
543 0, 0, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
544 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
|
545 } |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
546 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
548 if (n > 0) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 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
|
550 #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
|
551 if(data->use_xrender == SDL_TRUE) |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
552 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
|
553 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 data->makedirty = SDL_TRUE; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
555 } 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
|
556 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
|
557 #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
|
558 if(data->use_xrender == SDL_TRUE) |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
559 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
|
560 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
561 data->makedirty = SDL_FALSE; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
562 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
563 data->current_pixmap = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
564 |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
565 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
566 if (data->use_xrender) { |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
567 bpp = data->drawable_pict_fmt->depth; |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
568 Rmask = ((data->drawable_pict_fmt->direct.redMask) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
569 << (data->drawable_pict_fmt->direct.red)); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
570 Gmask = ((data->drawable_pict_fmt->direct.greenMask) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
571 << (data->drawable_pict_fmt->direct.green)); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
572 Bmask = ((data->drawable_pict_fmt->direct.blueMask) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
573 << (data->drawable_pict_fmt->direct.blue)); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
574 Amask = ((data->drawable_pict_fmt->direct.alphaMask) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
575 << (data->drawable_pict_fmt->direct.alpha)); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
576 } |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
577 else |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
578 #endif |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
579 { |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
580 /* Get the format of the window */ |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
581 if (!SDL_PixelFormatEnumToMasks |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
582 (display->current_mode.format, &bpp, &Rmask, &Gmask, &Bmask, |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
583 &Amask)) { |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
584 SDL_SetError("Unknown display format"); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
585 X11_DestroyRenderer(renderer); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
586 return NULL; |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
587 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 } |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
589 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
|
590 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 /* Create the drawing context */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
592 gcv.graphics_exposures = False; |
2814 | 593 data->gc = |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
594 XCreateGC(data->display, data->drawable, GCGraphicsExposures, &gcv); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 if (!data->gc) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
597 SDL_SetError("XCreateGC() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
598 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
599 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
601 return renderer; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 } |
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 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 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
|
606 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
607 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
|
608 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
|
609 int i, n; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
610 |
4596
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
611 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
612 if (data->use_xrender) { |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
613 XRenderFreePicture(data->display, data->xwindow_pict); |
4608
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
614 |
4596
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
615 data->xwindow_pict_fmt = |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
616 XRenderFindVisualFormat(data->display, data->visual); |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
617 data->xwindow_pict = |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
618 XRenderCreatePicture(data->display, data->xwindow, |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
619 data->xwindow_pict_fmt, 0, NULL); |
4608
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
620 |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
621 XRenderComposite(data->display, |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
622 PictOpClear, |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
623 data->xwindow_pict, |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
624 None, |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
625 data->xwindow_pict, |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
626 0, 0, |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
627 0, 0, |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
628 0, 0, |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
629 window->w, window->h); |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
630 |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
631 XFreePixmap(data->display, data->stencil); |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
632 /* Create a clip mask that is used for rendering primitives. */ |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
633 data->stencil = XCreatePixmap(data->display, data->xwindow, |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
634 window->w, window->h, 32); |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
635 |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
636 XRenderFreePicture(data->display, data->stencil_pict); |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
637 data->stencil_pict = |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
638 XRenderCreatePicture(data->display, data->stencil, |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
639 XRenderFindStandardFormat(data->display, |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
640 PictStandardARGB32), |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
641 0, NULL); |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
642 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
643 XDamageDestroy(data->display, data->stencil_damage); |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
644 if (data->use_xdamage) { |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
645 data->stencil_damage = |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
646 XDamageCreate(data->display, data->stencil, XDamageReportNonEmpty); |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
647 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts); |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
648 } |
ff7b00d4b0d3
Fix X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4607
diff
changeset
|
649 #endif |
4596
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
650 } |
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
651 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
652 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
|
653 n = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 } 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
|
655 n = 2; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
656 } 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
|
657 n = 3; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
658 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
659 n = 1; |
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 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
|
662 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
|
663 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
|
664 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
|
665 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4596
dc26c37ad70e
Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4595
diff
changeset
|
666 XRenderFreePicture(data->display, data->pixmap_picts[i]); |
4577
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
667 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
|
668 #endif |
2810
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 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
671 for (i = 0; i < n; ++i) { |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
672 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
673 if (data->use_xrender) { |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
674 data->pixmaps[i] = |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
675 XCreatePixmap(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
676 data->xwindow, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
677 window->w, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
678 window->h, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
679 32); |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
680 } |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
681 else |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
682 #endif |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
683 { |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
684 data->pixmaps[i] = |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
685 XCreatePixmap(data->display, data->xwindow, window->w, window->h, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
686 data->depth); |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
687 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
688 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
|
689 SDL_SetError("XCreatePixmap() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
690 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
691 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
692 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
693 if (data->use_xrender) { |
4577
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
694 data->pixmap_picts[i] = |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
695 XRenderCreatePicture(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
696 data->pixmaps[i], |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
697 XRenderFindStandardFormat(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
698 PictStandardARGB32), |
4583
5c925d4f220f
X11_DrawRects now uses a very hacky way of drawing rectangles with XRender. This will be improved in some time.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4582
diff
changeset
|
699 0, None); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
700 if (!data->pixmap_picts[i]) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
701 SDL_SetError("XRenderCreatePicture() failed"); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
702 return -1; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
703 } |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
704 XRenderComposite(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
705 PictOpClear, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
706 data->pixmap_picts[i], |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
707 None, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
708 data->pixmap_picts[i], |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
709 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
710 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
711 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
712 window->w, window->h); |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
713 |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
714 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
715 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
716 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
717 if (n > 0) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
718 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
|
719 #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
|
720 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
|
721 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
722 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
723 data->current_pixmap = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
724 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
725 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
726 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
727 |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
728 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
729 static void |
4619
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
730 SDLMaskToXRenderMask(Uint32 sdl_mask, short *comp, short *compMask) |
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
731 { |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
732 if (sdl_mask == 0) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
733 *comp = 0; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
734 *compMask = 0; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
735 } else { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
736 (*comp) = 0; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
737 (*compMask) = 0; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
738 while(!(sdl_mask & 1)) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
739 (*comp)++; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
740 sdl_mask >>= 1; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
741 } |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
742 while(sdl_mask & 1) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
743 (*compMask) = ((*compMask) << 1) | 1; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
744 sdl_mask >>= 1; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
745 } |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
746 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
747 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
748 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
749 static XRenderPictFormat* |
4619
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
750 PixelFormatEnumToXRenderPictFormat(SDL_Renderer * renderer, Uint32 format) |
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
751 { |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
752 XRenderPictFormat* pict_fmt = NULL; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
753 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
754 |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
755 if (data->use_xrender) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
756 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
757 int bpp; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
758 Uint32 Amask, Rmask, Gmask, Bmask; |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
759 if(!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
760 SDL_SetError("Unknown pixel format"); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
761 return NULL; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
762 } |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
763 XRenderPictFormat templ; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
764 unsigned long mask = (PictFormatType | PictFormatDepth | PictFormatRed | |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
765 PictFormatRedMask | PictFormatGreen | PictFormatGreenMask | |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
766 PictFormatBlue | PictFormatBlueMask | PictFormatAlpha | |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
767 PictFormatAlphaMask); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
768 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
769 templ.type = PictTypeDirect; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
770 templ.depth = bpp; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
771 SDLMaskToXRenderMask(Amask, &(templ.direct.alpha), &(templ.direct.alphaMask)); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
772 SDLMaskToXRenderMask(Rmask, &(templ.direct.red), &(templ.direct.redMask)); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
773 SDLMaskToXRenderMask(Gmask, &(templ.direct.green), &(templ.direct.greenMask)); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
774 SDLMaskToXRenderMask(Bmask, &(templ.direct.blue), &(templ.direct.blueMask)); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
775 pict_fmt = XRenderFindFormat(data->display, mask, &templ, 0); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
776 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
777 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
778 return pict_fmt; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
779 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
780 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
781 static Visual* |
4619
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
782 PixelFormatEnumToVisual(SDL_Renderer * renderer, Uint32 format) |
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
783 { |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
784 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
785 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
786 if (data->use_xrender) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
787 int bpp; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
788 Uint32 Amask, Rmask, Gmask, Bmask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
789 SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
790 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
791 XVisualInfo vinfo_templ; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
792 long vinfo_mask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
793 int nitems_return; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
794 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
795 vinfo_mask = (VisualDepthMask | VisualRedMaskMask | |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
796 VisualGreenMaskMask | VisualBlueMaskMask); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
797 vinfo_templ.depth = bpp; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
798 vinfo_templ.red_mask = Rmask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
799 vinfo_templ.green_mask = Gmask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
800 vinfo_templ.blue_mask = Bmask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
801 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
802 XVisualInfo * ret = XGetVisualInfo(data->display, vinfo_mask, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
803 &vinfo_templ, &nitems_return); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
804 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
805 if (nitems_return) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
806 return ret[0].visual; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
807 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
808 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
809 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
810 return NULL; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
811 } |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
812 |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
813 static XRenderColor |
4619
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
814 SDLColorToXRenderColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
b9a205e6369f
Moved brace to the beginning of the line for the beginning of functions
Sam Lantinga <slouken@libsdl.org>
parents:
4618
diff
changeset
|
815 { |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
816 double rd, gd, bd, ad; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
817 XRenderColor ret; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
818 rd = r / 255.0; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
819 gd = g / 255.0; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
820 bd = b / 255.0; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
821 ad = a / 255.0; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
822 |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
823 ret.red = (unsigned short) (rd * ad * 0xFFFF); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
824 ret.green = (unsigned short) (gd * ad * 0xFFFF); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
825 ret.blue = (unsigned short) (bd * ad * 0xFFFF); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
826 ret.alpha = (unsigned short) (ad * 0xFFFF); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
827 |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
828 return ret; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
829 } |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
830 #endif |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
831 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
832 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
833 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
|
834 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
835 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
|
836 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
|
837 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
|
838 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
|
839 int pitch_alignmask = ((renderdata->scanline_pad / 8) - 1); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
840 XGCValues gcv; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
841 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
842 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
|
843 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
844 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
845 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
846 } |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
847 data->depth = renderdata->depth; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
848 data->visual = renderdata->visual; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
849 data->gc = renderdata->gc; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
850 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
851 texture->driverdata = data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
852 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
|
853 data->yuv = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
854 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
|
855 if (!data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
856 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
857 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
858 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
|
859 } else { |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
860 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
861 if (renderdata->use_xrender) |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
862 { |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
863 Uint32 Amask, Rmask, Gmask, Bmask; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
864 SDL_PixelFormatEnumToMasks(texture->format, &(data->depth), |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
865 &Rmask, &Gmask, &Bmask, &Amask); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
866 data->visual = PixelFormatEnumToVisual(renderer, texture->format); |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
867 } |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
868 else |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
869 #endif |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
870 { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
871 if (texture->format != display->current_mode.format) |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
872 { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
873 SDL_SetError("Texture format doesn't match window format"); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
874 return -1; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
875 } |
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
|
876 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
877 data->format = texture->format; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
878 } |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
879 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
880 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
|
881 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
882 XShmSegmentInfo *shminfo = &data->shminfo; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
883 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
884 shm_error = True; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
885 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
886 if (SDL_X11_HAVE_SHM) { |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
887 data->image = |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
888 XShmCreateImage(renderdata->display, data->visual, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
889 data->depth, ZPixmap, NULL, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
890 shminfo, texture->w, texture->h); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
891 if (data->image) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
892 shminfo->shmid = |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
893 shmget(IPC_PRIVATE, texture->h * data->image->bytes_per_line, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
894 IPC_CREAT | 0777); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
895 if (shminfo->shmid >= 0) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
896 shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
897 shminfo->readOnly = False; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
898 if (shminfo->shmaddr != (char *) -1) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
899 shm_error = False; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
900 X_handler = XSetErrorHandler(shm_errhandler); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
901 XShmAttach(renderdata->display, shminfo); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
902 XSync(renderdata->display, False); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
903 XSetErrorHandler(X_handler); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
904 if (shm_error) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
905 XShmDetach(renderdata->display, shminfo); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
906 shmdt(shminfo->shmaddr); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
907 XDestroyImage(data->image); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
908 XSync(renderdata->display, False); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
909 } |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
910 else { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
911 data->pixels = data->image->data = shminfo->shmaddr; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
912 shmctl(shminfo->shmid, IPC_RMID, NULL); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
913 data->pixmap = |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
914 XCreatePixmap(renderdata->display, renderdata->xwindow, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
915 texture->w, texture->h, data->depth); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
916 if (!data->pixmap) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
917 SDL_SetError("XCreatePixmap() failed"); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
918 return -1; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
919 } |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
920 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
921 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
922 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
923 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
924 } |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
925 if (shm_error) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
926 shminfo->shmaddr = NULL; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
927 } |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
928 if (!data->image) |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
929 #endif /* not NO_SHARED_MEMORY */ |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
930 { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
931 data->image = |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
932 XCreateImage(renderdata->display, data->visual, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
933 data->depth, ZPixmap, 0, NULL, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
934 texture->w, texture->h, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
935 SDL_BYTESPERPIXEL(data->format) * 8, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
936 0); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
937 if (!data->image) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
938 X11_DestroyTexture(renderer, texture); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
939 SDL_SetError("XCreateImage() failed"); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
940 return -1; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
941 } |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
942 data->pixels = SDL_malloc(texture->h * data->image->bytes_per_line); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
943 if (!data->pixels) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
944 X11_DestroyTexture(renderer, texture); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
945 SDL_OutOfMemory(); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
946 return -1; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
947 } |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
948 data->image->data = data->pixels; |
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
|
949 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
|
950 XCreatePixmap(renderdata->display, renderdata->xwindow, texture->w, |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
951 texture->h, data->depth); |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
952 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
|
953 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
|
954 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
|
955 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
|
956 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
957 } |
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
|
958 } |
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
|
959 else { |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
960 data->image = |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
961 XCreateImage(renderdata->display, data->visual, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
962 data->depth, ZPixmap, 0, NULL, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
963 texture->w, texture->h, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
964 SDL_BYTESPERPIXEL(data->format) * 8, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
965 0); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
966 if (!data->image) { |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
967 X11_DestroyTexture(renderer, texture); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
968 SDL_SetError("XCreateImage() failed"); |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
969 return -1; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
970 } |
2814 | 971 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
|
972 XCreatePixmap(renderdata->display, renderdata->xwindow, texture->w, |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
973 texture->h, data->depth); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
974 if (data->pixmap == None) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
975 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
|
976 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
|
977 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
978 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
979 } |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
980 |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
981 data->pitch = data->image->bytes_per_line; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
982 |
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
|
983 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
984 if(renderdata->use_xrender) { |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
985 gcv.graphics_exposures = False; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
986 data->gc = |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
987 XCreateGC(renderdata->display, data->pixmap, GCGraphicsExposures, &gcv); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
988 if (!data->gc) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
989 SDL_SetError("XCreateGC() failed"); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
990 return -1; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
991 } |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
992 data->picture_fmt = |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
993 PixelFormatEnumToXRenderPictFormat(renderer, texture->format); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
994 if (data->picture_fmt == NULL) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
995 X11_DestroyTexture(renderer, texture); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
996 SDL_SetError("Texture format not supported by driver"); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
997 return -1; |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
998 } |
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
|
999 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
|
1000 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
|
1001 data->picture_fmt, 0, NULL); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1002 if (!data->picture) { |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1003 X11_DestroyTexture(renderer, texture); |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1004 SDL_SetError("XRenderCreatePicture() failed"); |
4580
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
1005 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
|
1006 } |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1007 data->modulated_pixmap = |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1008 XCreatePixmap(renderdata->display, renderdata->xwindow, |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1009 texture->w, texture->h, data->depth); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1010 if (!data->modulated_pixmap) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1011 X11_DestroyTexture(renderer, texture); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1012 SDL_SetError("XCreatePixmap() failed"); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1013 return -1; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1014 } |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1015 data->modulated_picture = |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1016 XRenderCreatePicture(renderdata->display, data->modulated_pixmap, |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1017 data->picture_fmt, 0, NULL); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1018 if (!data->modulated_picture) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1019 X11_DestroyTexture(renderer, texture); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1020 SDL_SetError("XRenderCreatePicture() failed"); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1021 return -1; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1022 } |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
1023 texture->blendMode = SDL_BLENDMODE_NONE; |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
1024 data->blend_op = PictOpSrc; |
4622
453712fd2016
Set the default XRender filter to "fast". testoverlay2 works now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4620
diff
changeset
|
1025 data->filter = "fast"; |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1026 } |
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
|
1027 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1028 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1029 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1030 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1031 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1032 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
|
1033 void **pixels, int *pitch) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1034 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1035 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
|
1036 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1037 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1038 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
|
1039 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1040 *pixels = data->pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1041 *pitch = data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1042 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1043 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1044 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1045 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1046 static int |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1047 X11_SetTextureRGBAMod(SDL_Renderer * renderer, SDL_Texture * texture) |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1048 { |
4620
f4a93bde905f
Fixed compiling without XRender enabled
Sam Lantinga <slouken@libsdl.org>
parents:
4619
diff
changeset
|
1049 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1050 X11_TextureData *data = (X11_TextureData *) texture->driverdata; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1051 X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1052 |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1053 if (renderdata->use_xrender) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1054 |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1055 Uint8 r = 0xFF, g = 0xFF, b = 0xFF, a = 0xFF; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1056 |
4617
cfbb1ff4b8ec
Add some comments.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4616
diff
changeset
|
1057 /* Check if alpha modulation is required. */ |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1058 if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1059 a = texture->a; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1060 } |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1061 |
4617
cfbb1ff4b8ec
Add some comments.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4616
diff
changeset
|
1062 /* Check if color modulation is required. */ |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1063 if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1064 r = texture->r; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1065 g = texture->g; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1066 b = texture->b; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1067 } |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1068 |
4617
cfbb1ff4b8ec
Add some comments.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4616
diff
changeset
|
1069 /* We can save some labour if no modulation is required. */ |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1070 if (texture->modMode != SDL_TEXTUREMODULATE_NONE) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1071 XRenderColor mod_color = |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1072 SDLColorToXRenderColor(r, g, b, a); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1073 XRenderFillRectangle(renderdata->display, PictOpSrc, |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1074 renderdata->brush_pict, &mod_color, |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1075 0, 0, 1, 1); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1076 } |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1077 |
4617
cfbb1ff4b8ec
Add some comments.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4616
diff
changeset
|
1078 /* We can save some labour dealing with component alpha |
cfbb1ff4b8ec
Add some comments.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4616
diff
changeset
|
1079 * if color modulation is not required. */ |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1080 XRenderPictureAttributes attr; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1081 if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1082 attr.component_alpha = True; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1083 XRenderChangePicture(renderdata->display, renderdata->brush_pict, |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1084 CPComponentAlpha, &attr); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1085 } |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1086 |
4617
cfbb1ff4b8ec
Add some comments.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4616
diff
changeset
|
1087 /* Again none of this is necessary is no modulation |
cfbb1ff4b8ec
Add some comments.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4616
diff
changeset
|
1088 * is required. */ |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1089 if (texture->modMode != SDL_TEXTUREMODULATE_NONE) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1090 XRenderComposite(renderdata->display, PictOpSrc, |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1091 data->picture, renderdata->brush_pict, |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1092 data->modulated_picture, |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1093 0, 0, 0, 0, 0, 0, texture->w, texture->h); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1094 } |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1095 |
4617
cfbb1ff4b8ec
Add some comments.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4616
diff
changeset
|
1096 /* We only need to reset the component alpha |
cfbb1ff4b8ec
Add some comments.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4616
diff
changeset
|
1097 * attribute if color modulation is required. */ |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1098 if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1099 attr.component_alpha = False; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1100 XRenderChangePicture(renderdata->display, renderdata->brush_pict, |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1101 CPComponentAlpha, &attr); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1102 } |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1103 |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1104 return 0; |
4620
f4a93bde905f
Fixed compiling without XRender enabled
Sam Lantinga <slouken@libsdl.org>
parents:
4619
diff
changeset
|
1105 } else { |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1106 SDL_Unsupported(); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1107 return -1; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1108 } |
4620
f4a93bde905f
Fixed compiling without XRender enabled
Sam Lantinga <slouken@libsdl.org>
parents:
4619
diff
changeset
|
1109 #else |
f4a93bde905f
Fixed compiling without XRender enabled
Sam Lantinga <slouken@libsdl.org>
parents:
4619
diff
changeset
|
1110 SDL_Unsupported(); |
f4a93bde905f
Fixed compiling without XRender enabled
Sam Lantinga <slouken@libsdl.org>
parents:
4619
diff
changeset
|
1111 return -1; |
f4a93bde905f
Fixed compiling without XRender enabled
Sam Lantinga <slouken@libsdl.org>
parents:
4619
diff
changeset
|
1112 #endif |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1113 } |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1114 |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1115 static int |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1116 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
|
1117 { |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1118 X11_TextureData *data = (X11_TextureData *) texture->driverdata; |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1119 X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1120 switch (texture->blendMode) { |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1121 case SDL_BLENDMODE_NONE: |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1122 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1123 if (renderdata->use_xrender) { |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1124 data->blend_op = PictOpSrc; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1125 return 0; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1126 } |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1127 case SDL_BLENDMODE_MOD: |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1128 case SDL_BLENDMODE_MASK: |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1129 case SDL_BLENDMODE_BLEND: |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1130 if (renderdata->use_xrender) { |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1131 data->blend_op = PictOpOver; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1132 return 0; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1133 } |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1134 case SDL_BLENDMODE_ADD: |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1135 if (renderdata->use_xrender) { |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1136 data->blend_op = PictOpAdd; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1137 return 0; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1138 } |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1139 #endif |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1140 return 0; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1141 default: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1142 SDL_Unsupported(); |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1143 texture->blendMode = SDL_BLENDMODE_NONE; |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1144 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1145 if (renderdata->use_xrender) { |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1146 texture->blendMode = SDL_BLENDMODE_BLEND; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1147 data->blend_op = PictOpOver; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1148 } |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1149 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1150 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1151 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1152 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1153 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1154 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1155 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
|
1156 { |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1157 X11_TextureData *data = (X11_TextureData *) texture->driverdata; |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1158 X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1159 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1160 switch (texture->scaleMode) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1161 case SDL_TEXTURESCALEMODE_NONE: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1162 return 0; |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1163 case SDL_TEXTURESCALEMODE_FAST: |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1164 /* 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
|
1165 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
|
1166 return 0; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1167 } |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1168 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1169 if (renderdata->use_xrender) { |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1170 data->filter = FilterFast; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1171 return 0; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1172 } |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1173 case SDL_TEXTURESCALEMODE_SLOW: |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1174 if (renderdata->use_xrender) { |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1175 data->filter = FilterGood; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1176 return 0; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1177 } |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1178 case SDL_TEXTURESCALEMODE_BEST: |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1179 if (renderdata->use_xrender) { |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1180 data->filter = FilterBest; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1181 return 0; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1182 } |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1183 #endif |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1184 /* 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
|
1185 default: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1186 SDL_Unsupported(); |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1187 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1188 if (renderdata->use_xrender) { |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1189 texture->scaleMode = SDL_TEXTURESCALEMODE_FAST; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1190 data->filter = FilterFast; |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1191 } |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1192 else |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1193 #endif |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1194 texture->scaleMode = SDL_TEXTURESCALEMODE_NONE; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1195 return -1; |
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 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1198 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1199 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1200 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1201 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
|
1202 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
|
1203 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1204 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
|
1205 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1206 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1207 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
|
1208 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1209 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1210 UpdateYUVTextureData(texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1211 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1212 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1213 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
|
1214 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1215 if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1216 Uint8 *src, *dst; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1217 int row; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1218 size_t length; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1219 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1220 src = (Uint8 *) pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1221 dst = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1222 (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
|
1223 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
|
1224 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
|
1225 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
|
1226 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
|
1227 src += pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1228 dst += data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1229 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1230 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1231 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
|
1232 data->image->height = rect->h; |
2814 | 1233 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
|
1234 data->image->bytes_per_line = pitch; |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1235 XPutImage(renderdata->display, data->pixmap, data->gc, |
2814 | 1236 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
|
1237 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1238 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1239 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1240 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1241 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1242 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1243 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
|
1244 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
|
1245 int *pitch) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1246 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1247 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
|
1248 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1249 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1250 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
|
1251 pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1252 } else if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1253 *pixels = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1254 (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
|
1255 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
|
1256 *pitch = data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1257 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1258 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1259 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
|
1260 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1261 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1262 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1263 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1264 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1265 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
|
1266 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1267 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
|
1268 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1269 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1270 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
|
1271 UpdateYUVTextureData(texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1272 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1273 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1274 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1275 static int |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1276 X11_SetDrawBlendMode(SDL_Renderer * renderer) |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1277 { |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1278 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
|
1279 switch (renderer->blendMode) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1280 case SDL_BLENDMODE_NONE: |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1281 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1282 //PictOpSrc |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1283 data->blend_op = PictOpSrc; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1284 return 0; |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1285 case SDL_BLENDMODE_MOD: |
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1286 case SDL_BLENDMODE_MASK: |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1287 case SDL_BLENDMODE_BLEND: // PictOpOver |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1288 data->blend_op = PictOpOver; |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1289 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
|
1290 case SDL_BLENDMODE_ADD: // PictOpAdd |
4588
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1291 data->blend_op = PictOpAdd; |
0ddd78496d68
Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4587
diff
changeset
|
1292 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
|
1293 /* 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
|
1294 #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
|
1295 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1296 default: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1297 SDL_Unsupported(); |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1298 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1299 if(data->use_xrender) { |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1300 renderer->blendMode = SDL_BLENDMODE_BLEND; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1301 data->blend_op = PictOpOver; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1302 } |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1303 else |
4589
8d8a889530eb
Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4588
diff
changeset
|
1304 #endif |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1305 { |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1306 renderer->blendMode = SDL_BLENDMODE_NONE; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1307 } |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1308 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1309 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1310 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1311 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1312 static Uint32 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1313 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
|
1314 { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1315 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
|
1316 Uint8 r = renderer->r; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1317 Uint8 g = renderer->g; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1318 Uint8 b = renderer->b; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1319 Uint8 a = renderer->a; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1320 if (premult) |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
1321 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
|
1322 ((int) g * (int) a) / 255, |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1323 ((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
|
1324 else |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
1325 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
|
1326 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1327 |
4620
f4a93bde905f
Fixed compiling without XRender enabled
Sam Lantinga <slouken@libsdl.org>
parents:
4619
diff
changeset
|
1328 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
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
|
1329 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
|
1330 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
|
1331 { |
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
|
1332 XRenderColor xrender_color; |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1333 if(renderer->blendMode == SDL_BLENDMODE_NONE) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1334 xrender_color = |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1335 SDLColorToXRenderColor(renderer->r, renderer->g, renderer->b, 0xFF); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1336 } |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1337 else { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1338 xrender_color = |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1339 SDLColorToXRenderColor(renderer->r, renderer->g, renderer->b, renderer->a); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1340 } |
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
|
1341 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
|
1342 } |
4620
f4a93bde905f
Fixed compiling without XRender enabled
Sam Lantinga <slouken@libsdl.org>
parents:
4619
diff
changeset
|
1343 #endif |
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
|
1344 |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1345 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
|
1346 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
|
1347 int count) |
2901 | 1348 { |
1349 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
|
1350 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
|
1351 XPoint *xpoints, *xpoint; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1352 int i, xcount; |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1353 SDL_Rect clip; |
2901 | 1354 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1355 clip.x = 0; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1356 clip.y = 0; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1357 clip.w = window->w; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1358 clip.h = window->h; |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1359 if (data->makedirty) { |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1360 SDL_Rect rect; |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1361 |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1362 /* Get the smallest rectangle that contains everything */ |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1363 rect.x = 0; |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1364 rect.y = 0; |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1365 rect.w = window->w; |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1366 rect.h = window->h; |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1367 if (!SDL_EnclosePoints(points, count, &rect, &rect)) { |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1368 /* Nothing to draw */ |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1369 return 0; |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1370 } |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1371 SDL_AddDirtyRect(&data->dirty, &rect); |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1372 } |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1373 { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1374 xpoint = xpoints = SDL_stack_alloc(XPoint, count); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1375 xcount = 0; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1376 for (i = 0; i < count; ++i) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1377 int x = points[i].x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1378 int y = points[i].y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1379 if (x < 0 || x >= window->w || y < 0 || y >= window->h) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1380 continue; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1381 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1382 xpoint->x = (short)x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1383 xpoint->y = (short)y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1384 ++xpoint; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1385 ++xcount; |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1386 } |
4602
4fbf64d504cf
Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4600
diff
changeset
|
1387 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1388 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1389 if (data->use_xrender && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1390 (renderer->blendMode != SDL_BLENDMODE_NONE) && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1391 !(renderer->a == 0xFF && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1392 renderer->blendMode != SDL_BLENDMODE_ADD && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1393 renderer->blendMode != SDL_BLENDMODE_MOD)) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1394 { |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1395 XSetForeground(data->display, data->stencil_gc, 0); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1396 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1397 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1398 { |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1399 /* Update only those parts which were changed |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1400 * in the previous drawing operation */ |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1401 XFixesSetGCClipRegion(data->display, data->stencil_gc, |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1402 0, 0, data->stencil_parts); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1403 } |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1404 #endif |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1405 XFillRectangle(data->display, data->stencil, data->stencil_gc, |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1406 0, 0, window->w, window->h); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1407 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1408 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1409 { |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1410 XFixesSetGCClipRegion(data->display, data->stencil_gc, 0, 0, None); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1411 } |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1412 #endif |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1413 XSetForeground(data->display, data->stencil_gc, 0xFFFFFFFF); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1414 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1415 XDrawPoints(data->display, data->stencil, data->stencil_gc, xpoints, xcount, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1416 CoordModeOrigin); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1417 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1418 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1419 { |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1420 /* Store the damaged region in stencil_parts */ |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1421 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1422 } |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1423 #endif |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1424 } |
4602
4fbf64d504cf
Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4600
diff
changeset
|
1425 #endif |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1426 } |
4602
4fbf64d504cf
Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4600
diff
changeset
|
1427 |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1428 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1429 if (data->use_xrender && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1430 (renderer->blendMode != SDL_BLENDMODE_NONE) && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1431 !(renderer->a == 0xFF && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1432 renderer->blendMode != SDL_BLENDMODE_ADD && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1433 renderer->blendMode != SDL_BLENDMODE_MOD)) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1434 { |
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
|
1435 XRenderColor foreground; |
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1436 foreground = xrenderdrawcolor(renderer); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1437 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1438 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1439 &foreground, 0, 0, 1, 1); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1440 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1441 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1442 { |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1443 /* Update only those parts which drawn |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1444 * to in the current drawing operation */ |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1445 XFixesSetPictureClipRegion(data->display, data->drawable_pict, |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1446 0, 0, data->stencil_parts); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1447 } |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1448 #endif |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1449 XRenderComposite(data->display, data->blend_op, data->brush_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1450 data->stencil_pict, data->drawable_pict, |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1451 0, 0, 0, 0, 0, 0, window->w, window->h); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1452 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1453 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1454 { |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1455 XFixesSetPictureClipRegion(data->display, data->drawable_pict, 0, 0, None); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1456 } |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1457 #endif |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1458 } |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1459 else |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1460 #endif |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1461 { |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1462 unsigned long foreground = renderdrawcolor(renderer, 1); |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1463 XSetForeground(data->display, data->gc, foreground); |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1464 |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1465 |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1466 if (xcount > 0) { |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1467 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
|
1468 CoordModeOrigin); |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1469 } |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1470 } |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1471 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1472 SDL_stack_free(xpoints); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1473 |
2894 | 1474 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1475 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1476 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
1477 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
|
1478 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
|
1479 int count) |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1480 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1481 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
|
1482 SDL_Window *window = renderer->window; |
4458
c9584df65367
Removed unused variables
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
1483 SDL_Rect clip; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1484 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
|
1485 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
|
1486 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
|
1487 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
|
1488 int maxx, maxy; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1489 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1490 clip.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1491 clip.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1492 clip.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1493 clip.h = window->h; |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1494 { |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1495 Pixmap drawable; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1496 GC gc; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1497 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1498 if (data->use_xrender && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1499 (renderer->blendMode != SDL_BLENDMODE_NONE) && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1500 !(renderer->a == 0xFF && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1501 renderer->blendMode != SDL_BLENDMODE_ADD && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1502 renderer->blendMode != SDL_BLENDMODE_MOD)) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1503 { |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1504 drawable = data->stencil; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1505 gc = data->stencil_gc; |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1506 |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1507 XSetForeground(data->display, data->stencil_gc, 0); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1508 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1509 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1510 XFixesSetGCClipRegion(data->display, data->stencil_gc, |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1511 0, 0, data->stencil_parts); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1512 #endif |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1513 XFillRectangle(data->display, data->stencil, data->stencil_gc, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1514 0, 0, window->w, window->h); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1515 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1516 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1517 XFixesSetGCClipRegion(data->display, data->stencil_gc, |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1518 0, 0, None); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1519 #endif |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1520 XSetForeground(data->display, data->stencil_gc, 0xFFFFFFFF); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1521 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1522 else |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1523 #endif |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1524 { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1525 drawable = data->drawable; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1526 gc = data->gc; |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1527 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1528 |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1529 foreground = renderdrawcolor(renderer, 1); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1530 XSetForeground(data->display, data->gc, foreground); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1531 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1532 xpoint = xpoints = SDL_stack_alloc(XPoint, count); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1533 xcount = 0; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1534 minx = INT_MAX; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1535 miny = INT_MAX; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1536 maxx = INT_MIN; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1537 maxy = INT_MIN; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1538 for (i = 0; i < count; ++i) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1539 int x = points[i].x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1540 int y = points[i].y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1541 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1542 /* If the point is inside the window, add it to the list */ |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1543 if (x >= 0 && x < window->w && y >= 0 && y < window->h) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1544 if (x < minx) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1545 minx = x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1546 } else if (x > maxx) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1547 maxx = x; |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1548 } |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1549 if (y < miny) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1550 miny = y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1551 } else if (y > maxy) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1552 maxy = y; |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1553 } |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1554 xpoint->x = (short)x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1555 xpoint->y = (short)y; |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1556 ++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
|
1557 ++xcount; |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1558 continue; |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1559 } |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1560 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1561 /* We need to clip the line segments joined by this point */ |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1562 if (xcount > 0) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1563 int x1 = xpoint[-1].x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1564 int y1 = xpoint[-1].y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1565 int x2 = x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1566 int y2 = y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1567 if (SDL_IntersectRectAndLine(&clip, &x1, &y1, &x2, &y2)) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1568 if (x2 < minx) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1569 minx = x2; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1570 } else if (x2 > maxx) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1571 maxx = x2; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1572 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1573 if (y2 < miny) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1574 miny = y2; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1575 } else if (y2 > maxy) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1576 maxy = y2; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1577 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1578 xpoint->x = (short)x2; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1579 xpoint->y = (short)y2; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1580 ++xpoint; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1581 ++xcount; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1582 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1583 XDrawLines(data->display, drawable, gc, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1584 xpoints, xcount, CoordModeOrigin); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1585 if (xpoints[0].x != x2 || xpoints[0].y != y2) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1586 XDrawPoint(data->display, drawable, gc, x2, y2); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1587 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1588 if (data->makedirty) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1589 SDL_Rect rect; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1590 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1591 rect.x = minx; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1592 rect.y = miny; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1593 rect.w = (maxx - minx) + 1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1594 rect.h = (maxy - miny) + 1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1595 SDL_AddDirtyRect(&data->dirty, &rect); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1596 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1597 xpoint = xpoints; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1598 xcount = 0; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1599 minx = INT_MAX; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1600 miny = INT_MAX; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1601 maxx = INT_MIN; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1602 maxy = INT_MIN; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1603 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1604 if (i < (count-1)) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1605 int x1 = x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1606 int y1 = y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1607 int x2 = points[i+1].x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1608 int y2 = points[i+1].y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1609 if (SDL_IntersectRectAndLine(&clip, &x1, &y1, &x2, &y2)) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1610 if (x1 < minx) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1611 minx = x1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1612 } else if (x1 > maxx) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1613 maxx = x1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1614 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1615 if (y1 < miny) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1616 miny = y1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1617 } else if (y1 > maxy) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1618 maxy = y1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1619 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1620 xpoint->x = (short)x1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1621 xpoint->y = (short)y1; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1622 ++xpoint; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1623 ++xcount; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1624 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1625 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1626 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1627 if (xcount > 1) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1628 int x2 = xpoint[-1].x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1629 int y2 = xpoint[-1].y; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1630 XDrawLines(data->display, drawable, gc, xpoints, xcount, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1631 CoordModeOrigin); |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1632 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
|
1633 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
|
1634 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1635 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
|
1636 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
|
1637 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1638 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
|
1639 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
|
1640 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
|
1641 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
|
1642 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
|
1643 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1644 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
1645 } |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1646 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1647 if (data->use_xrender && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1648 (renderer->blendMode != SDL_BLENDMODE_NONE) && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1649 !(renderer->a == 0xFF && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1650 renderer->blendMode != SDL_BLENDMODE_ADD && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1651 renderer->blendMode != SDL_BLENDMODE_MOD)) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1652 { |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1653 XRenderColor xrforeground = xrenderdrawcolor(renderer); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1654 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1655 &xrforeground, 0, 0, 1, 1); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1656 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1657 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1658 { |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1659 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1660 |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1661 XFixesSetPictureClipRegion(data->display, data->drawable_pict, |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1662 0, 0, data->stencil_parts); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1663 } |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1664 #endif |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1665 XRenderComposite(data->display, data->blend_op, data->brush_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1666 data->stencil_pict, data->drawable_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1667 0, 0, 0, 0, 0, 0, window->w, window->h); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1668 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1669 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1670 XFixesSetPictureClipRegion(data->display, data->drawable_pict, |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1671 0, 0, None); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1672 #endif |
4585
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1673 } |
21600c6d6445
X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4584
diff
changeset
|
1674 #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
|
1675 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
|
1676 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1677 return 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1678 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1679 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1680 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
|
1681 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
|
1682 { |
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
|
1683 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
|
1684 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
|
1685 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
|
1686 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
|
1687 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
|
1688 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
|
1689 xcount = 0; |
4590
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1690 |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1691 clip.x = 0; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1692 clip.y = 0; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1693 clip.w = window->w; |
1ad70fb49fcb
Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4589
diff
changeset
|
1694 clip.h = window->h; |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1695 { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1696 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1697 for (i = 0; i < count; ++i) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1698 if (!SDL_IntersectRect(rects[i], &clip, &rect)) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1699 continue; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1700 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1701 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1702 xrect->x = (short)rect.x; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1703 xrect->y = (short)rect.y; |
4615
789483a20081
Fixed drawing rectangles. X is evil!
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4614
diff
changeset
|
1704 xrect->width = (unsigned short)rect.w - 1; |
789483a20081
Fixed drawing rectangles. X is evil!
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4614
diff
changeset
|
1705 xrect->height = (unsigned short)rect.h - 1; |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1706 ++xrect; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1707 ++xcount; |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1708 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1709 if (data->makedirty) { |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1710 SDL_AddDirtyRect(&data->dirty, &rect); |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1711 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1712 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1713 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1714 if (data->use_xrender && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1715 (renderer->blendMode != SDL_BLENDMODE_NONE) && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1716 !(renderer->a == 0xFF && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1717 renderer->blendMode != SDL_BLENDMODE_ADD && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1718 renderer->blendMode != SDL_BLENDMODE_MOD)) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1719 { |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1720 XSetForeground(data->display, data->stencil_gc, 0); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1721 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1722 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1723 XFixesSetGCClipRegion(data->display, data->stencil_gc, |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1724 0, 0, data->stencil_parts); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1725 #endif |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1726 XFillRectangle(data->display, data->stencil, data->stencil_gc, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1727 0, 0, window->w, window->h); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1728 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1729 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1730 XFixesSetGCClipRegion(data->display, data->stencil_gc, |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1731 0, 0, None); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1732 #endif |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1733 XSetForeground(data->display, data->stencil_gc, 0xFFFFFFFF); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1734 |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1735 XDrawRectangles(data->display, data->stencil, data->stencil_gc, xrects, xcount); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1736 |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1737 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1738 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1739 XDamageSubtract(data->display, data->stencil_damage, |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1740 None, data->stencil_parts); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1741 #endif |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1742 } |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1743 #endif |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1744 } |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1745 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1746 if (data->use_xrender && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1747 (renderer->blendMode != SDL_BLENDMODE_NONE) && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1748 !(renderer->a == 0xFF && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1749 renderer->blendMode != SDL_BLENDMODE_ADD && |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1750 renderer->blendMode != SDL_BLENDMODE_MOD)) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1751 { |
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
|
1752 XRenderColor foreground; |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1753 foreground = xrenderdrawcolor(renderer); |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1754 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1755 &foreground, 0, 0, 1, 1); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1756 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1757 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1758 XFixesSetPictureClipRegion(data->display, data->drawable_pict, |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1759 0, 0, data->stencil_parts); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1760 #endif |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1761 XRenderComposite(data->display, data->blend_op, data->brush_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1762 data->stencil_pict, data->drawable_pict, |
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1763 0, 0, 0, 0, 0, 0, window->w, window->h); |
4603
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1764 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1765 if (data->use_xdamage) |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1766 XFixesSetPictureClipRegion(data->display, data->drawable_pict, |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1767 0, 0, None); |
dffa432f0e2b
Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4602
diff
changeset
|
1768 #endif |
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
|
1769 } |
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
|
1770 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
|
1771 #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
|
1772 { |
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
|
1773 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
|
1774 |
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
|
1775 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
|
1776 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
|
1777 |
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
|
1778 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
|
1779 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
|
1780 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
|
1781 } |
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
|
1782 } |
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
|
1783 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
|
1784 |
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
|
1785 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
|
1786 } |
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
|
1787 |
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
|
1788 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
|
1789 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
|
1790 { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1791 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
|
1792 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
|
1793 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
|
1794 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1795 clip.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1796 clip.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1797 clip.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1798 clip.h = window->h; |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1799 |
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
|
1800 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
|
1801 XRectangle *xrects, *xrect; |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1802 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
|
1803 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
|
1804 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
|
1805 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
|
1806 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
|
1807 } |
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
|
1808 |
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
|
1809 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
|
1810 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
|
1811 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
|
1812 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
|
1813 ++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
|
1814 ++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
|
1815 |
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
|
1816 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
|
1817 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
|
1818 } |
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
|
1819 } |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1820 |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1821 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4597
95be206b3cb7
Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4596
diff
changeset
|
1822 if (data->use_xrender) { |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1823 XRenderColor foreground; |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1824 foreground = xrenderdrawcolor(renderer); |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1825 if (xcount == 1) { |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1826 XRenderFillRectangle(data->display, data->blend_op, data->drawable_pict, |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1827 &foreground, xrects[0].x, xrects[0].y, |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1828 xrects[0].width, xrects[0].height); |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1829 } |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1830 else if (xcount > 1) { |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1831 XRenderFillRectangles(data->display, data->blend_op, data->drawable_pict, |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1832 &foreground, xrects, xcount); |
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
1833 } |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1834 } |
4584
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1835 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
|
1836 #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
|
1837 { |
9907c8cc6015
X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4583
diff
changeset
|
1838 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
|
1839 |
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
|
1840 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
|
1841 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
|
1842 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1843 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
|
1844 xrects, xcount); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1845 } |
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
|
1846 |
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
|
1847 SDL_stack_free(xrects); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1848 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1849 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1850 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1851 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1852 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
|
1853 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
|
1854 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1855 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
|
1856 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
|
1857 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1858 if (data->makedirty) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1859 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
|
1860 } |
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
|
1861 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
1862 if (data->use_xrender) { |
4587
25391ccf16a0
Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4586
diff
changeset
|
1863 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
|
1864 #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
|
1865 if(texturedata->shminfo.shmaddr) { |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
1866 XShmPutImage(data->display, texturedata->pixmap, texturedata->gc, |
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
|
1867 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
|
1868 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
|
1869 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
|
1870 } |
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
|
1871 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
|
1872 #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
|
1873 if (texturedata->pixels) { |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
1874 XPutImage(data->display, texturedata->pixmap, texturedata->gc, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
1875 texturedata->image, srcrect->x, srcrect->y, srcrect->x, |
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
1876 srcrect->y, srcrect->w, srcrect->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
|
1877 } |
4610
32991e17e2b6
Make the SW renderer work properly by fixing support for textures with no alpha channels.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4609
diff
changeset
|
1878 XSync(data->display, False); |
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
|
1879 } |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1880 Picture src, mask; |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1881 XRenderPictureAttributes attr; |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1882 const SDL_Rect *mrect; |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1883 |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1884 if (texture->modMode == SDL_TEXTUREMODULATE_NONE) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1885 src = texturedata->picture; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1886 } |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1887 else { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1888 src = texturedata->modulated_picture; |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1889 } |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1890 |
4614
a17de6a8f796
Code cleanup.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4613
diff
changeset
|
1891 if(texture->blendMode == SDL_BLENDMODE_NONE) |
a17de6a8f796
Code cleanup.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4613
diff
changeset
|
1892 { |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1893 mask = None; |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1894 mrect = srcrect; |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1895 } |
4614
a17de6a8f796
Code cleanup.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4613
diff
changeset
|
1896 else if (texture->blendMode == SDL_BLENDMODE_MOD) |
a17de6a8f796
Code cleanup.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4613
diff
changeset
|
1897 { |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1898 mask = data->stencil_pict; |
4614
a17de6a8f796
Code cleanup.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4613
diff
changeset
|
1899 mrect = dstrect; |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1900 } |
4614
a17de6a8f796
Code cleanup.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4613
diff
changeset
|
1901 else |
a17de6a8f796
Code cleanup.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4613
diff
changeset
|
1902 { |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1903 mask = texturedata->picture; |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1904 mrect = srcrect; |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1905 } |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1906 |
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
|
1907 if(srcrect->w == dstrect->w && srcrect->h == dstrect->h) { |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1908 if (texture->blendMode == SDL_BLENDMODE_MOD) { |
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1909 XRenderComposite(data->display, PictOpSrc, data->drawable_pict, |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1910 src, data->stencil_pict, |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1911 dstrect->x, dstrect->y, srcrect->x, srcrect->y, |
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1912 dstrect->x, dstrect->y, dstrect->w, dstrect->h); |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1913 attr.component_alpha = True; |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1914 XRenderChangePicture(data->display, data->stencil_pict, |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1915 CPComponentAlpha, &attr); |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1916 } |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1917 XRenderComposite(data->display, texturedata->blend_op, |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1918 src, mask, data->drawable_pict, srcrect->x, srcrect->y, |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1919 mrect->x, mrect->y, dstrect->x, dstrect->y, |
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1920 dstrect->w, dstrect->h); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1921 } 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
|
1922 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
|
1923 double yscale = ((double) dstrect->h) / srcrect->h; |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1924 XTransform xform = {{ |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1925 {XDoubleToFixed(xscale), XDoubleToFixed(0), XDoubleToFixed(0)}, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1926 {XDoubleToFixed(0), XDoubleToFixed(yscale), XDoubleToFixed(0)}, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1927 {XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(xscale * yscale)}}}; |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1928 XRenderSetPictureTransform(data->display, src, &xform); |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1929 |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1930 if (texture->blendMode == SDL_BLENDMODE_MOD) { |
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1931 XRenderComposite(data->display, PictOpSrc, data->drawable_pict, |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1932 src, data->stencil_pict, |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1933 dstrect->x, dstrect->y, srcrect->x, srcrect->y, |
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1934 dstrect->x, dstrect->y, dstrect->w, dstrect->h); |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1935 attr.component_alpha = True; |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1936 XRenderChangePicture(data->display, data->stencil_pict, |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1937 CPComponentAlpha, &attr); |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1938 } |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1939 |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1940 XRenderSetPictureFilter(data->display, src, |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1941 texturedata->filter, 0, 0); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1942 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1943 XRenderComposite(data->display, texturedata->blend_op, |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1944 src, mask, data->drawable_pict, |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1945 srcrect->x, srcrect->y, mrect->x, mrect->y, |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1946 dstrect->x, dstrect->y, dstrect->w, dstrect->h); |
4593
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1947 |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1948 XTransform identity = {{ |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1949 {XDoubleToFixed(1), XDoubleToFixed(0), XDoubleToFixed(0)}, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1950 {XDoubleToFixed(0), XDoubleToFixed(1), XDoubleToFixed(0)}, |
3892fe2f6537
Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4591
diff
changeset
|
1951 {XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(1)}}}; |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
1952 XRenderSetPictureTransform(data->display, src, &identity); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1953 } |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1954 if (renderer->blendMode == SDL_BLENDMODE_MOD) { |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1955 attr.component_alpha = False; |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1956 XRenderChangePicture(data->display, data->stencil_pict, |
4606
4e145485971b
Implement support for setting texture scale mode.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4605
diff
changeset
|
1957 CPComponentAlpha, &attr); |
4607
9e9ec5e3be95
Get SDL_BLENDMODE_MOD to work! Tested on nvidia only ATM.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4606
diff
changeset
|
1958 } |
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
|
1959 } |
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
|
1960 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
|
1961 #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
|
1962 { |
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
|
1963 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
|
1964 #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
|
1965 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
|
1966 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
|
1967 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
|
1968 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
|
1969 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
|
1970 } 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
|
1971 #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
|
1972 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
|
1973 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
|
1974 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
|
1975 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
|
1976 } 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
|
1977 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
|
1978 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
|
1979 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
|
1980 } |
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
|
1981 } 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
|
1982 || 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
|
1983 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
|
1984 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
|
1985 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
|
1986 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
|
1987 |
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
|
1988 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
|
1989 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
|
1990 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
|
1991 |
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
|
1992 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
|
1993 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
|
1994 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
|
1995 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
|
1996 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
|
1997 } |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1998 |
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
|
1999 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
|
2000 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
|
2001 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
|
2002 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
|
2003 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
|
2004 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
|
2005 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
|
2006 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
|
2007 } |
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
|
2008 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
|
2009 |
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
|
2010 } 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
|
2011 || !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
|
2012 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
|
2013 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
|
2014 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
|
2015 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
|
2016 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
|
2017 (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
|
2018 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
|
2019 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
|
2020 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
|
2021 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
|
2022 } |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
2023 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
2024 |
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
|
2025 /* 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
|
2026 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
|
2027 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
|
2028 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
|
2029 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
|
2030 #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
|
2031 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
|
2032 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
|
2033 } 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
|
2034 #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
|
2035 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
|
2036 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
|
2037 |
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
|
2038 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
|
2039 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
|
2040 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
|
2041 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
|
2042 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
|
2043 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
|
2044 |
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
|
2045 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
|
2046 |
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
|
2047 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
|
2048 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
|
2049 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
|
2050 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
|
2051 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
|
2052 return -1; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
2053 } |
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
|
2054 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
|
2055 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
|
2056 } 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
|
2057 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
|
2058 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
|
2059 srcrect->x, srcrect->y); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
2060 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2061 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2062 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2063 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2064 |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2065 static int |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2066 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
|
2067 Uint32 format, void * pixels, int pitch) |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2068 { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2069 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
|
2070 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
|
2071 SDL_VideoDisplay *display = window->display; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2072 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
|
2073 XImage *image; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2074 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2075 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
|
2076 rect->w, rect->h, AllPlanes, ZPixmap); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2077 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2078 SDL_ConvertPixels(rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2079 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
|
2080 format, pixels, pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2081 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2082 XDestroyImage(image); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2083 return 0; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2084 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2085 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2086 static int |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2087 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
|
2088 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
|
2089 { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2090 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
|
2091 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
|
2092 SDL_VideoDisplay *display = window->display; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2093 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
|
2094 XImage *image; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2095 void *image_pixels; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2096 int image_pitch; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2097 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2098 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
|
2099 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
|
2100 if (!image_pixels) { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2101 SDL_OutOfMemory(); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2102 return -1; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2103 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2104 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2105 image = XCreateImage(data->display, data->visual, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2106 data->depth, ZPixmap, 0, image_pixels, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2107 rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2108 SDL_BYTESPERPIXEL(screen_format) * 8, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2109 image_pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2110 if (!image) { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2111 SDL_SetError("XCreateImage() failed"); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2112 return -1; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2113 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2114 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2115 SDL_ConvertPixels(rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2116 format, pixels, pitch, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2117 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
|
2118 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2119 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
|
2120 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
|
2121 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2122 image->data = NULL; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2123 XDestroyImage(image); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2124 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2125 SDL_free(image_pixels); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2126 return 0; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2127 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
2128 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2129 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2130 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
|
2131 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2132 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
|
2133 SDL_DirtyRect *dirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2134 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2135 /* 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
|
2136 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
|
2137 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
|
2138 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
|
2139 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
2140 if (data->use_xrender) |
4579
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
2141 { |
4591
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
2142 XRenderComposite(data->display, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
2143 data->blend_op, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
2144 data->drawable_pict, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
2145 None, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
2146 data->xwindow_pict, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
2147 rect->x, rect->y, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
2148 0, 0, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
2149 rect->x, rect->y, |
1e998db9b597
Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4590
diff
changeset
|
2150 rect->w, rect->h); |
4579
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
2151 } |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
2152 else |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
2153 #endif |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
2154 { |
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
|
2155 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
|
2156 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
|
2157 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
|
2158 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2159 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2160 SDL_ClearDirtyRects(&data->dirty); |
4598
66e13a224bd6
Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4597
diff
changeset
|
2161 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2162 XSync(data->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2163 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2164 /* 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
|
2165 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
|
2166 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
|
2167 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
|
2168 #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
|
2169 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
|
2170 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2171 } 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
|
2172 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
|
2173 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
|
2174 #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
|
2175 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
|
2176 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2177 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2178 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2179 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2180 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2181 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
|
2182 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2183 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
|
2184 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
|
2185 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2186 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2187 return; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2188 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2189 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2190 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
|
2191 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2192 if (data->pixmap != None) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2193 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
|
2194 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2195 if (data->image) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2196 data->image->data = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2197 XDestroyImage(data->image); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2198 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2199 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2200 if (data->shminfo.shmaddr) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2201 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
|
2202 XSync(renderdata->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2203 shmdt(data->shminfo.shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2204 data->pixels = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2205 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2206 #endif |
4609
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2207 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2208 if (renderdata->use_xrender) { |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2209 if (data->picture) { |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2210 XRenderFreePicture(renderdata->display, data->picture); |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2211 } |
4616
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
2212 if (data->modulated_pixmap) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
2213 XFreePixmap(renderdata->display, data->modulated_pixmap); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
2214 } |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
2215 if (data->modulated_picture) { |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
2216 XRenderFreePicture(renderdata->display, data->modulated_picture); |
05eb4a07e5e3
Add support for texture modulation (both color and alpha). testsprite2 works now with --cyclealpha and --cyclecolor.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4615
diff
changeset
|
2217 } |
4609
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2218 } |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2219 #endif |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
2220 if (data->scaling_image) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
2221 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
|
2222 data->scaling_image->data = NULL; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
2223 XDestroyImage(data->scaling_image); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
2224 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2225 if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2226 SDL_free(data->pixels); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2227 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2228 SDL_free(data); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2229 texture->driverdata = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2230 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2231 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2232 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2233 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
|
2234 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2235 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
|
2236 int i; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2237 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2238 if (data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2239 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
|
2240 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
|
2241 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
|
2242 } |
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
|
2243 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4609
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2244 if (data->use_xrender && 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
|
2245 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
|
2246 } |
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
|
2247 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2248 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2249 if (data->gc) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2250 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
|
2251 } |
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
|
2252 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4609
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2253 if (data->use_xrender) { |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2254 if (data->stencil_gc) { |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2255 XFreeGC(data->display, data->stencil_gc); |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2256 } |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2257 if (data->stencil) { |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2258 XFreePixmap(data->display, data->stencil); |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2259 } |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2260 if (data->stencil_pict) { |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2261 XRenderFreePicture(data->display, data->stencil_pict); |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2262 } |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2263 if (data->xwindow_pict) { |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2264 XRenderFreePicture(data->display, data->xwindow_pict); |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2265 } |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2266 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2267 if (data->use_xdamage && data->stencil_damage) { |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2268 XDamageDestroy(data->display, data->stencil_damage); |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2269 } |
630002c8be85
Fix cleanup functions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4608
diff
changeset
|
2270 #endif |
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
|
2271 } |
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
|
2272 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2273 SDL_FreeDirtyRects(&data->dirty); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2274 SDL_free(data); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2275 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2276 SDL_free(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2277 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2278 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2279 #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
|
2280 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2281 /* vi: set ts=4 sw=4 expandtab: */ |