Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11render.c @ 4582:a17fbd25767b
It seems that the off-screen buffers (or pixmaps) only need to be cleared while initializing.
author | Sunny Sachanandani <sunnysachanandani@gmail.com> |
---|---|
date | Wed, 02 Jun 2010 11:55:40 +0530 |
parents | ef0aa488fff6 |
children | 5c925d4f220f |
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 /* |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 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
|
4 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 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
|
6 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
|
7 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
|
8 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
|
9 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 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
|
11 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
|
12 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
|
13 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
|
14 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 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
|
16 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
|
17 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
|
18 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #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
|
25 |
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
|
26 #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
|
27 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #include "SDL_x11video.h" |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #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
|
30 #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
|
31 #include "../SDL_yuv_sw_c.h" |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 /* X11 renderer implementation */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 int *pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 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
|
42 SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 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
|
44 SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 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
|
46 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
|
47 int pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 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
|
49 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
|
50 void **pixels, int *pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 Uint32 format, void * pixels, int pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
65 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
|
66 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
|
67 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
|
68 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
|
69 SDL_Texture * texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 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
|
71 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 SDL_RenderDriver X11_RenderDriver = { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 X11_CreateRenderer, |
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 "x11", |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 (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
|
78 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
|
79 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
|
80 SDL_TEXTUREMODULATE_NONE, |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
81 SDL_BLENDMODE_NONE, |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 SDL_TEXTURESCALEMODE_NONE, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 0, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 {0}, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 0, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 0} |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 }; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 typedef struct |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 Display *display; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 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
|
93 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
|
94 int depth; |
2916
ffdd533f7add
Fixed pitch alignment problem causing MITSHM error on 16-bit displays
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
95 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
|
96 Window xwindow; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 Pixmap pixmaps[3]; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
98 #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
|
99 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
|
100 Picture pixmap_picts[3]; |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
101 Picture drawable_pict; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
102 XRenderPictFormat* xwindow_pict_fmt; |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
103 XRenderPictureAttributes xwindow_pict_attr; |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
104 unsigned int xwindow_pict_attr_valuemask; |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
105 SDL_bool xrender_available; |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
106 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 int current_pixmap; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 Drawable drawable; |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
109 SDL_PixelFormat format; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 GC gc; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 SDL_DirtyRectList dirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 SDL_bool makedirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 } X11_RenderData; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 typedef struct |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 SDL_SW_YUVTexture *yuv; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 Uint32 format; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 Pixmap pixmap; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
120 #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
|
121 Picture picture; |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
122 XRenderPictFormat* picture_fmt; |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
123 XRenderPictureAttributes picture_attr; |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
124 unsigned int picture_attr_valuemask; |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
125 SDL_bool xrender_available; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
126 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 XImage *image; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 /* 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
|
130 XShmSegmentInfo shminfo; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 #endif |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
132 XImage *scaling_image; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 void *pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 int pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 } X11_TextureData; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 /* 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
|
139 static int shm_error; |
2814 | 140 static int (*X_handler) (Display *, XErrorEvent *) = NULL; |
141 static int | |
142 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
|
143 { |
2814 | 144 if (e->error_code == BadAccess) { |
145 shm_error = True; | |
146 return (0); | |
147 } else { | |
148 return (X_handler(d, e)); | |
149 } | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 #endif /* ! NO_SHARED_MEMORY */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 UpdateYUVTextureData(SDL_Texture * texture) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 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
|
157 SDL_Rect rect; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 rect.x = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 rect.y = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 rect.w = texture->w; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 rect.h = texture->h; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 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
|
164 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
|
165 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 X11_AddRenderDriver(_THIS) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 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
|
171 SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode; |
3520
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
172 int i; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 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
|
179 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 |
3520
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
181 for (i = 0; i < _this->num_displays; ++i) { |
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
182 SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver); |
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3239
diff
changeset
|
183 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 SDL_Renderer * |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 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
|
188 { |
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
|
189 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
|
190 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
|
191 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
|
192 SDL_Renderer *renderer; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 X11_RenderData *data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 XGCValues gcv; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 int i, n; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 int bpp; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 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
|
198 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 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
|
200 if (!renderer) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 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
|
206 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 data->xwindow = windowdata->xwindow; |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
217 #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
|
218 int event_basep, error_basep; |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
219 if(XRenderQueryExtension(data->display, &event_basep, &error_basep) == True) { |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
220 data->xrender_available = SDL_TRUE; |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
221 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, data->visual); |
4577
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
222 if(!data->xwindow_pict_fmt) { |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
223 data->xrender_available = SDL_FALSE; |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
224 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
225 data->xwindow_pict_attr.graphics_exposures = False; |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
226 data->xwindow_pict_attr_valuemask = CPGraphicsExposure; |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
227 data->xwindow_pict = XRenderCreatePicture(data->display, data->xwindow, data->xwindow_pict_fmt, |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
228 data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr); |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
229 if(!data->xwindow_pict) { |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
230 data->xrender_available = SDL_FALSE; |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
231 } |
4571
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
232 } |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
233 else { |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
234 data->xrender_available = SDL_FALSE; |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
235 } |
97dcf6f6213c
Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4458
diff
changeset
|
236 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 renderer->DisplayModeChanged = X11_DisplayModeChanged; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 renderer->CreateTexture = X11_CreateTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 renderer->QueryTexturePixels = X11_QueryTexturePixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 renderer->SetTextureBlendMode = X11_SetTextureBlendMode; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 renderer->SetTextureScaleMode = X11_SetTextureScaleMode; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 renderer->UpdateTexture = X11_UpdateTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 renderer->LockTexture = X11_LockTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 renderer->UnlockTexture = X11_UnlockTexture; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
245 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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 renderer->RenderCopy = X11_RenderCopy; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
251 renderer->RenderReadPixels = X11_RenderReadPixels; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
252 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
|
253 renderer->RenderPresent = X11_RenderPresent; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 renderer->DestroyTexture = X11_DestroyTexture; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 renderer->DestroyRenderer = X11_DestroyRenderer; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 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
|
257 renderer->window = window; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 renderer->driverdata = data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 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
|
261 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 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
|
263 renderer->info.flags |= |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 (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
|
265 n = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 } 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
|
267 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
|
268 n = 2; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 } 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
|
270 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
|
271 n = 3; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 n = 1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 for (i = 0; i < n; ++i) { |
2814 | 277 data->pixmaps[i] = |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
278 XCreatePixmap(data->display, data->xwindow, window->w, window->h, |
2870
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
279 displaydata->depth); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 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
|
281 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 SDL_SetError("XCreatePixmap() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 } |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
285 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
286 if(data->xrender_available == SDL_TRUE) { |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
287 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
|
288 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt, |
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
289 data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr); |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
290 if(!data->pixmap_picts[i]) { |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
291 data->xrender_available = SDL_FALSE; |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
292 } |
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
|
293 XRenderComposite(data->display, PictOpClear, data->pixmap_picts[i], None, data->pixmap_picts[i], |
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
|
294 0, 0, 0, 0, 0, 0, window->w, window->h); |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
295 } |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
296 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 if (n > 0) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 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
|
300 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
301 if(data->xrender_available == SDL_TRUE) |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
302 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
|
303 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 data->makedirty = SDL_TRUE; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 } 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
|
306 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
|
307 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
308 if(data->xrender_available == SDL_TRUE) |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
309 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
|
310 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 data->makedirty = SDL_FALSE; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 data->current_pixmap = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 /* Get the format of the window */ |
2874 | 316 if (!SDL_PixelFormatEnumToMasks |
317 (display->current_mode.format, &bpp, &Rmask, &Gmask, &Bmask, | |
318 &Amask)) { | |
2870
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
319 SDL_SetError("Unknown display format"); |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
320 X11_DestroyRenderer(renderer); |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
321 return NULL; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 } |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
323 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
|
324 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 /* Create the drawing context */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 gcv.graphics_exposures = False; |
2814 | 327 data->gc = |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
328 XCreateGC(data->display, data->xwindow, GCGraphicsExposures, &gcv); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 if (!data->gc) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 SDL_SetError("XCreateGC() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 return renderer; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 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
|
340 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 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
|
342 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
|
343 int i, n; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 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
|
346 n = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 } 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
|
348 n = 2; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 } 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
|
350 n = 3; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 n = 1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 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
|
358 #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
|
359 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
|
360 #endif |
2810
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 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 for (i = 0; i < n; ++i) { |
2814 | 364 data->pixmaps[i] = |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
365 XCreatePixmap(data->display, data->xwindow, window->w, window->h, |
2870
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
366 data->depth); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 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
|
368 SDL_SetError("XCreatePixmap() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
371 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
372 if(data->xrender_available == SDL_TRUE) { |
4577
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
373 data->pixmap_picts[i] = |
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
374 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt, |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
375 data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr); |
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
|
376 if(!data->pixmap_picts[i]) { |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
377 data->xrender_available = SDL_FALSE; |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
378 } |
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
|
379 XRenderComposite(data->display, PictOpClear, data->pixmap_picts[i], None, data->pixmap_picts[i], |
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
|
380 0, 0, 0, 0, 0, 0, window->w, window->h); |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
381 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
382 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 if (n > 0) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 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
|
386 #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
|
387 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
|
388 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 data->current_pixmap = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 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
|
397 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 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
|
399 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
|
400 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
|
401 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
|
402 int pitch_alignmask = ((renderdata->scanline_pad / 8) - 1); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 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
|
405 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 texture->driverdata = data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 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
|
412 data->yuv = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 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
|
414 if (!data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 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
|
418 } else { |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
419 /* If Xrender support is builtin we only need to check whether |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
420 Xrender is available at runtime. If it is available there |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
421 can be no BadMatch error since Xrender takes care of that. |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
422 */ |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
423 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4574
bfb4933c0efa
Fix initial value of the xrender_available boolean in X11_CreateTexture.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4573
diff
changeset
|
424 // Assume the texture is supported by Xrender |
4575
037ddbeee6c3
Fix typo.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4574
diff
changeset
|
425 data->xrender_available = SDL_TRUE; |
4577
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
426 if(renderdata->xrender_available == SDL_FALSE) { |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
427 if (texture->format != display->current_mode.format) { |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
428 SDL_SetError("Texture format doesn't match window format"); |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
429 return -1; |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
430 } |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
431 } |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
432 #else |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
433 /* The image/pixmap depth must be the same as the window or you |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
434 get a BadMatch error when trying to putimage or copyarea. |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
435 This BadMatch error |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
436 */ |
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
|
437 if (texture->format != display->current_mode.format) { |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
438 SDL_SetError("Texture format doesn't match window format"); |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
439 return -1; |
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
440 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
441 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 data->format = texture->format; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 } |
2814 | 444 data->pitch = texture->w * SDL_BYTESPERPIXEL(data->format); |
2916
ffdd533f7add
Fixed pitch alignment problem causing MITSHM error on 16-bit displays
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
445 data->pitch = (data->pitch + pitch_alignmask) & ~pitch_alignmask; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 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
|
448 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 XShmSegmentInfo *shminfo = &data->shminfo; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 shm_error = True; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 if (SDL_X11_HAVE_SHM) { |
2814 | 454 shminfo->shmid = |
455 shmget(IPC_PRIVATE, texture->h * data->pitch, | |
456 IPC_CREAT | 0777); | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 if (shminfo->shmid >= 0) { |
2814 | 458 shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 shminfo->readOnly = False; |
2814 | 460 if (shminfo->shmaddr != (char *) -1) { |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 shm_error = False; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 X_handler = XSetErrorHandler(shm_errhandler); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 XShmAttach(renderdata->display, shminfo); |
3239 | 464 XSync(renderdata->display, False); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 XSetErrorHandler(X_handler); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 if (shm_error) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 shmdt(shminfo->shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
469 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
470 shmctl(shminfo->shmid, IPC_RMID, NULL); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 if (!shm_error) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 data->pixels = shminfo->shmaddr; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 |
2814 | 476 data->image = |
2874 | 477 XShmCreateImage(renderdata->display, renderdata->visual, |
478 renderdata->depth, ZPixmap, shminfo->shmaddr, | |
479 shminfo, texture->w, texture->h); | |
4580
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
480 |
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
|
481 // This Pixmap is used by Xrender |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
482 data->pixmap = |
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
|
483 XShmCreatePixmap(renderdata->display, renderdata->xwindow, shminfo->shmaddr, |
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
|
484 shminfo, texture->w, texture->h, renderdata->depth); |
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
|
485 |
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
|
486 if (!(data->pixmap && data->image)) { |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 XShmDetach(renderdata->display, shminfo); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 XSync(renderdata->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 shmdt(shminfo->shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 shm_error = True; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 if (shm_error) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 shminfo->shmaddr = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 if (!data->image) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 #endif /* not NO_SHARED_MEMORY */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
498 { |
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
|
499 /* This is the case where the server does not have |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
500 shared memory support and the texture is streaming. |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
501 It does not make sense to use Xrender here because |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
502 we would have to copy the data onto a server side |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
503 pixmap with XPutImage first and only then can we |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
504 use Xrender |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
505 */ |
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
|
506 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 data->pixels = SDL_malloc(texture->h * data->pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 if (!data->pixels) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
509 X11_DestroyTexture(renderer, texture); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 |
2814 | 514 data->image = |
2874 | 515 XCreateImage(renderdata->display, renderdata->visual, |
516 renderdata->depth, ZPixmap, 0, data->pixels, | |
517 texture->w, texture->h, | |
518 SDL_BYTESPERPIXEL(data->format) * 8, | |
519 data->pitch); | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 if (!data->image) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
521 X11_DestroyTexture(renderer, texture); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 SDL_SetError("XCreateImage() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 } |
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
|
526 } |
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
|
527 else { |
2814 | 528 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
|
529 XCreatePixmap(renderdata->display, renderdata->xwindow, texture->w, |
2870
b801df19835f
The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents:
2868
diff
changeset
|
530 texture->h, renderdata->depth); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 if (data->pixmap == None) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
532 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
|
533 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
|
534 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 } |
2814 | 536 data->image = |
2874 | 537 XCreateImage(renderdata->display, renderdata->visual, |
4580
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
538 renderdata->depth, ZPixmap, 0, NULL, |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
539 texture->w, texture->h, |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
540 SDL_BYTESPERPIXEL(data->format) * 8, |
2874 | 541 data->pitch); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 if (!data->image) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
543 X11_DestroyTexture(renderer, texture); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 SDL_SetError("XCreateImage() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
545 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 } |
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
|
548 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
549 if(renderdata->xrender_available && data->pixmap) { |
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
|
550 data->xrender_available = SDL_TRUE; |
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
|
551 unsigned long x11_fmt_mask; // Format mask |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
552 XRenderPictFormat x11_templ_fmt; // Format template |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
553 x11_fmt_mask = |
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
|
554 (PictFormatDepth | PictFormatRedMask | PictFormatGreenMask |
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
|
555 | PictFormatBlueMask); |
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
|
556 Uint32 Rmask, Gmask, Bmask, Amask; |
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
|
557 int bpp; |
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
|
558 SDL_PixelFormatEnumToMasks(data->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); |
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
|
559 x11_templ_fmt.depth = bpp; |
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
|
560 x11_templ_fmt.direct.redMask = Rmask; |
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
|
561 x11_templ_fmt.direct.greenMask = Gmask; |
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
|
562 x11_templ_fmt.direct.blueMask = Bmask; |
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
|
563 x11_templ_fmt.direct.alphaMask = Amask; |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
564 /* Return one matching XRenderPictFormat */ |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
565 data->picture_fmt = |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
566 XRenderFindFormat(renderdata->display, x11_fmt_mask, &x11_templ_fmt, 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
|
567 if(!data->picture_fmt) { |
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
|
568 data->xrender_available = SDL_FALSE; |
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
|
569 } |
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
|
570 data->picture_attr_valuemask = CPGraphicsExposure; |
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
|
571 (data->picture_attr).graphics_exposures = False; |
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
|
572 data->picture = |
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
|
573 XRenderCreatePicture(renderdata->display, data->pixmap, data->picture_fmt, |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
574 data->picture_attr_valuemask, &(data->picture_attr)); |
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
|
575 if(!data->picture) { |
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
|
576 data->xrender_available = SDL_FALSE; |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
577 } |
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
|
578 } |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
579 /* We thought we could render the texture with Xrender but this was |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
580 not possible for some reason. Now we must ensure that texture |
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
|
581 format and window format match to avoid a BadMatch error. |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
582 */ |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
583 if(data->xrender_available == SDL_FALSE) { |
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
|
584 if (texture->format != display->current_mode.format) { |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
585 SDL_SetError("Texture format doesn't match window format"); |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
586 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
|
587 } |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
588 } |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
589 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
590 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
592 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
593 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
594 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
|
595 void **pixels, int *pitch) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
597 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
|
598 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
599 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 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
|
601 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 *pixels = data->pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
603 *pitch = data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 } |
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 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
608 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
609 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
|
610 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
611 switch (texture->blendMode) { |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
612 case SDL_BLENDMODE_NONE: |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
613 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
614 default: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
615 SDL_Unsupported(); |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
616 texture->blendMode = SDL_BLENDMODE_NONE; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
617 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
620 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
622 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
|
623 { |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
624 X11_TextureData *data = (X11_TextureData *) texture->driverdata; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
625 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
626 switch (texture->scaleMode) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
627 case SDL_TEXTURESCALEMODE_NONE: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
628 return 0; |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
629 case SDL_TEXTURESCALEMODE_FAST: |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
630 /* 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
|
631 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
|
632 return 0; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
633 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
634 /* 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
|
635 default: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
636 SDL_Unsupported(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
637 texture->scaleMode = SDL_TEXTURESCALEMODE_NONE; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
638 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
639 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
640 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
641 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
644 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
|
645 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
|
646 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
647 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
|
648 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
649 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
650 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
|
651 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
652 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
653 UpdateYUVTextureData(texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
656 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
|
657 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
658 if (data->pixels) { |
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
|
659 // If we have already allocated memory or were given memory by XShm |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
660 Uint8 *src, *dst; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
661 int row; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
662 size_t length; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
663 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
664 src = (Uint8 *) pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
665 dst = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
666 (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
|
667 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
|
668 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
|
669 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
|
670 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
|
671 src += pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
672 dst += data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
673 } |
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
|
674 /* If this is a static texture we would use Xrender for it |
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
|
675 but this requires that the server side Pixmap associated |
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
|
676 with this texture be updated with the data as well and |
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
|
677 that the pixmap is not a shared memory pixmap. |
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
|
678 Hopefully the user will not update static textures so |
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
|
679 frequently as to cause a slowdown. |
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
|
680 */ |
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
|
681 if (texture->access == SDL_TEXTUREACCESS_STATIC) { |
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
|
682 #ifndef NO_SHARED_MEMORY |
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
|
683 if(!data->shminfo.shmaddr) |
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
|
684 #endif |
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
|
685 { |
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
|
686 XPutImage(renderdata->display, data->pixmap, renderdata->gc, |
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
|
687 data->image, 0, 0, rect->x, rect->y, rect->w, rect->h); |
cfea5b007bc7
Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4579
diff
changeset
|
688 } |
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
|
689 } |
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
|
690 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
691 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
692 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
|
693 data->image->height = rect->h; |
2814 | 694 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
|
695 data->image->bytes_per_line = pitch; |
2814 | 696 XPutImage(renderdata->display, data->pixmap, renderdata->gc, |
697 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
|
698 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
699 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
700 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
701 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
702 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
703 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
704 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
|
705 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
|
706 int *pitch) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
707 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 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
|
709 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
710 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
711 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
|
712 pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
713 } else if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
714 *pixels = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
715 (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
|
716 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
|
717 *pitch = data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
718 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
719 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
720 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
|
721 return -1; |
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 } |
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 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
726 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
|
727 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
728 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
|
729 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
730 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
731 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
|
732 UpdateYUVTextureData(texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
733 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
734 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
735 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
736 static int |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
737 X11_SetDrawBlendMode(SDL_Renderer * renderer) |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
738 { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
739 switch (renderer->blendMode) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
740 case SDL_BLENDMODE_NONE: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
741 return 0; |
4581
ef0aa488fff6
Fix X11_FillRects to work with double buffering as well as triple buffering. This requires that the buffer pixmap be cleared after every render.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4580
diff
changeset
|
742 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
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
|
743 case SDL_BLENDMODE_MASK: // Use src pict as mask |
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
|
744 case SDL_BLENDMODE_ADD: // PictOpAdd |
ef0aa488fff6
Fix X11_FillRects to work with double buffering as well as triple buffering. This requires that the buffer pixmap be cleared after every render.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4580
diff
changeset
|
745 case SDL_BLENDMODE_BLEND: // PictOpOver |
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
|
746 /* 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
|
747 #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
|
748 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
749 default: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
750 SDL_Unsupported(); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
751 renderer->blendMode = SDL_BLENDMODE_NONE; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
752 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
753 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
754 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
755 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
756 static Uint32 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
757 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
|
758 { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
759 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
|
760 Uint8 r = renderer->r; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
761 Uint8 g = renderer->g; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
762 Uint8 b = renderer->b; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
763 Uint8 a = renderer->a; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
764 if (premult) |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
765 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
|
766 ((int) g * (int) a) / 255, |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
767 ((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
|
768 else |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
769 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
|
770 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
771 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
772 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
|
773 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
|
774 int count) |
2901 | 775 { |
776 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
|
777 SDL_Window *window = renderer->window; |
2901 | 778 unsigned long foreground; |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
779 XPoint *xpoints, *xpoint; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
780 int i, xcount; |
2901 | 781 |
782 if (data->makedirty) { | |
783 SDL_Rect rect; | |
784 | |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
785 /* Get the smallest rectangle that contains everything */ |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
786 rect.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
787 rect.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
788 rect.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
789 rect.h = window->h; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
790 if (!SDL_EnclosePoints(points, count, &rect, &rect)) { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
791 /* Nothing to draw */ |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
792 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
793 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
794 SDL_AddDirtyRect(&data->dirty, &rect); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
795 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
796 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
797 foreground = renderdrawcolor(renderer, 1); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
798 XSetForeground(data->display, data->gc, foreground); |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
799 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
800 xpoint = xpoints = SDL_stack_alloc(XPoint, count); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
801 xcount = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
802 for (i = 0; i < count; ++i) { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
803 int x = points[i].x; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
804 int y = points[i].y; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
805 if (x < 0 || x >= window->w || y < 0 || y >= window->h) { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
806 continue; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
807 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
808 xpoint->x = (short)x; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
809 xpoint->y = (short)y; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
810 ++xpoint; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
811 ++xcount; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
812 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
813 if (xcount > 0) { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
814 XDrawPoints(data->display, data->drawable, data->gc, xpoints, xcount, |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
815 CoordModeOrigin); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
816 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
817 SDL_stack_free(xpoints); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
818 |
2894 | 819 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
820 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
821 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
822 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
|
823 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
|
824 int count) |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
825 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
826 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
|
827 SDL_Window *window = renderer->window; |
4458
c9584df65367
Removed unused variables
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
828 SDL_Rect clip; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
829 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
|
830 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
|
831 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
|
832 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
|
833 int maxx, maxy; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
834 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
835 clip.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
836 clip.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
837 clip.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
838 clip.h = window->h; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
839 |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
840 foreground = renderdrawcolor(renderer, 1); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
841 XSetForeground(data->display, data->gc, foreground); |
3543
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
842 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
843 xpoint = xpoints = SDL_stack_alloc(XPoint, count); |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
844 xcount = 0; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
845 minx = INT_MAX; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
846 miny = INT_MAX; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
847 maxx = INT_MIN; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
848 maxy = INT_MIN; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
849 for (i = 0; i < count; ++i) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
850 int x = points[i].x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
851 int y = points[i].y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
852 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
853 /* If the point is inside the window, add it to the list */ |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
854 if (x >= 0 && x < window->w && y >= 0 && y < window->h) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
855 if (x < minx) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
856 minx = x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
857 } else if (x > maxx) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
858 maxx = x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
859 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
860 if (y < miny) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
861 miny = y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
862 } else if (y > maxy) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
863 maxy = y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
864 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
865 xpoint->x = (short)x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
866 xpoint->y = (short)y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
867 ++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
|
868 ++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
|
869 continue; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
870 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
871 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
872 /* We need to clip the line segments joined by this point */ |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
873 if (xcount > 0) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
874 int x1 = xpoint[-1].x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
875 int y1 = xpoint[-1].y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
876 int x2 = x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
877 int y2 = y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
878 if (SDL_IntersectRectAndLine(&clip, &x1, &y1, &x2, &y2)) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
879 if (x2 < minx) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
880 minx = x2; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
881 } else if (x2 > maxx) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
882 maxx = x2; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
883 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
884 if (y2 < miny) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
885 miny = y2; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
886 } else if (y2 > maxy) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
887 maxy = y2; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
888 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
889 xpoint->x = (short)x2; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
890 xpoint->y = (short)y2; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
891 ++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
|
892 ++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
|
893 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
894 XDrawLines(data->display, data->drawable, data->gc, |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
895 xpoints, xcount, CoordModeOrigin); |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
896 if (xpoints[0].x != x2 || xpoints[0].y != y2) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
897 XDrawPoint(data->display, data->drawable, data->gc, x2, y2); |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
898 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
899 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
|
900 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
|
901 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
902 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
|
903 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
|
904 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
|
905 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
|
906 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
|
907 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
908 xpoint = xpoints; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
909 xcount = 0; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
910 minx = INT_MAX; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
911 miny = INT_MAX; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
912 maxx = INT_MIN; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
913 maxy = INT_MIN; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
914 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
915 if (i < (count-1)) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
916 int x1 = x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
917 int y1 = y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
918 int x2 = points[i+1].x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
919 int y2 = points[i+1].y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
920 if (SDL_IntersectRectAndLine(&clip, &x1, &y1, &x2, &y2)) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
921 if (x1 < minx) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
922 minx = x1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
923 } else if (x1 > maxx) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
924 maxx = x1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
925 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
926 if (y1 < miny) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
927 miny = y1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
928 } else if (y1 > maxy) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
929 maxy = y1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
930 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
931 xpoint->x = (short)x1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
932 xpoint->y = (short)y1; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
933 ++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
|
934 ++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
|
935 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
936 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
937 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
938 if (xcount > 1) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
939 int x2 = xpoint[-1].x; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
940 int y2 = xpoint[-1].y; |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
941 XDrawLines(data->display, data->drawable, data->gc, xpoints, 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
|
942 CoordModeOrigin); |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
943 if (xpoints[0].x != x2 || xpoints[0].y != y2) { |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
944 XDrawPoint(data->display, data->drawable, data->gc, x2, y2); |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
945 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
946 if (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
|
947 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
|
948 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
949 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
|
950 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
|
951 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
|
952 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
|
953 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
|
954 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
955 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
956 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
|
957 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
958 return 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
959 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
960 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
961 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
|
962 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
|
963 { |
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
|
964 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
|
965 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
|
966 SDL_Rect clip, rect; |
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
|
967 unsigned long foreground; |
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
|
968 XRectangle *xrects, *xrect; |
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
|
969 int i, xcount; |
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
|
970 |
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
|
971 clip.x = 0; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
972 clip.y = 0; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
973 clip.w = window->w; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
974 clip.h = window->h; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
975 |
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
|
976 foreground = renderdrawcolor(renderer, 1); |
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
|
977 XSetForeground(data->display, data->gc, foreground); |
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
|
978 |
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
|
979 xrect = xrects = SDL_stack_alloc(XRectangle, 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
|
980 xcount = 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
|
981 for (i = 0; i < count; ++i) { |
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
|
982 if (!SDL_IntersectRect(rects[i], &clip, &rect)) { |
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
|
983 continue; |
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
|
984 } |
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
|
985 |
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
|
986 xrect->x = (short)rect.x; |
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
|
987 xrect->y = (short)rect.y; |
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
|
988 xrect->width = (unsigned short)rect.w; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
989 xrect->height = (unsigned short)rect.h; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3559
diff
changeset
|
990 ++xrect; |
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
|
991 ++xcount; |
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
|
992 |
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
|
993 if (data->makedirty) { |
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
|
994 SDL_AddDirtyRect(&data->dirty, &rect); |
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
|
995 } |
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
|
996 } |
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
|
997 if (xcount > 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
|
998 XDrawRectangles(data->display, data->drawable, data->gc, |
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
|
999 xrects, xcount); |
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
|
1000 } |
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
|
1001 SDL_stack_free(xpoints); |
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
|
1002 |
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
|
1003 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
|
1004 } |
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
|
1005 |
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
|
1006 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
|
1007 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
|
1008 { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1009 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
|
1010 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
|
1011 SDL_Rect clip, rect; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1012 unsigned long foreground; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1013 XRectangle *xrects, *xrect; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1014 int i, xcount; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1015 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1016 clip.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1017 clip.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1018 clip.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1019 clip.h = window->h; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1020 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1021 foreground = renderdrawcolor(renderer, 1); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1022 XSetForeground(data->display, data->gc, foreground); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1023 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1024 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
|
1025 xcount = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1026 for (i = 0; i < count; ++i) { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1027 if (!SDL_IntersectRect(rects[i], &clip, &rect)) { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1028 continue; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1029 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1030 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1031 xrect->x = (short)rect.x; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1032 xrect->y = (short)rect.y; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1033 xrect->width = (unsigned short)rect.w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1034 xrect->height = (unsigned short)rect.h; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1035 ++xrect; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1036 ++xcount; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1037 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1038 if (data->makedirty) { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1039 SDL_AddDirtyRect(&data->dirty, &rect); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1040 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1041 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1042 if (xcount > 0) { |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1043 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1044 if(data->xrender_available == SDL_TRUE) |
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1045 { |
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
|
1046 XRenderColor xrender_foreground_color; |
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
|
1047 // Premultiply the color channels as well as modulate them to a 16 bit color space |
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
|
1048 xrender_foreground_color.red = ((unsigned short)renderer->r + 1) * ((unsigned short)renderer->a + 1) - 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
|
1049 xrender_foreground_color.green = ((unsigned short)renderer->g + 1) * ((unsigned short)renderer->a + 1) - 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
|
1050 xrender_foreground_color.blue = ((unsigned short)renderer->b + 1) * ((unsigned short)renderer->a + 1) - 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
|
1051 xrender_foreground_color.alpha = ((unsigned short)renderer->a + 1) * ((unsigned short)renderer->a + 1) - 1; |
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
|
1052 XRenderFillRectangles(data->display, PictOpOver, data->drawable_pict, |
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
|
1053 &xrender_foreground_color, xrects, xcount); |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1054 } |
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1055 else |
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1056 #endif |
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1057 { |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1058 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
|
1059 xrects, xcount); |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1060 } |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1061 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1062 SDL_stack_free(xpoints); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1063 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1064 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1065 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1066 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1067 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1068 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
|
1069 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
|
1070 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1071 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
|
1072 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
|
1073 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1074 if (data->makedirty) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1075 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
|
1076 } |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1077 if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) { |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1078 #ifndef NO_SHARED_MEMORY |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1079 if (texturedata->shminfo.shmaddr) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1080 XShmPutImage(data->display, data->drawable, data->gc, |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1081 texturedata->image, srcrect->x, srcrect->y, |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1082 dstrect->x, dstrect->y, srcrect->w, srcrect->h, |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1083 False); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1084 } else |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1085 #endif |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1086 if (texturedata->pixels) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1087 XPutImage(data->display, data->drawable, data->gc, |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1088 texturedata->image, srcrect->x, srcrect->y, dstrect->x, |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1089 dstrect->y, srcrect->w, srcrect->h); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1090 } else { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1091 XCopyArea(data->display, texturedata->pixmap, data->drawable, |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1092 data->gc, srcrect->x, srcrect->y, dstrect->w, |
3066
8cbf68bdf81b
Fixed destination of XCopyArea()
Sam Lantinga <slouken@libsdl.org>
parents:
3044
diff
changeset
|
1093 dstrect->h, dstrect->x, dstrect->y); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1094 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1095 } else if (texturedata->yuv |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1096 || texture->access == SDL_TEXTUREACCESS_STREAMING) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1097 SDL_Surface src, dst; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1098 SDL_PixelFormat fmt; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1099 SDL_Rect rect; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1100 XImage *image = texturedata->scaling_image; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1101 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1102 if (!image) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1103 void *pixels; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1104 int pitch; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1105 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1106 pitch = dstrect->w * SDL_BYTESPERPIXEL(texturedata->format); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1107 pixels = SDL_malloc(dstrect->h * pitch); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1108 if (!pixels) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1109 SDL_OutOfMemory(); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1110 return -1; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1111 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1112 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1113 image = |
2874 | 1114 XCreateImage(data->display, data->visual, data->depth, |
1115 ZPixmap, 0, pixels, dstrect->w, dstrect->h, | |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1116 SDL_BYTESPERPIXEL(texturedata->format) * 8, |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1117 pitch); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1118 if (!image) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1119 SDL_SetError("XCreateImage() failed"); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1120 return -1; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1121 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1122 texturedata->scaling_image = image; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1123 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1124 } else if (image->width != dstrect->w || image->height != dstrect->h |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1125 || !image->data) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1126 image->width = dstrect->w; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1127 image->height = dstrect->h; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1128 image->bytes_per_line = |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1129 image->width * SDL_BYTESPERPIXEL(texturedata->format); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1130 image->data = |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1131 (char *) SDL_realloc(image->data, |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1132 image->height * image->bytes_per_line); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1133 if (!image->data) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1134 SDL_OutOfMemory(); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1135 return -1; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1136 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1137 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1138 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1139 /* Set up fake surfaces for SDL_SoftStretch() */ |
2882
04e89201f6ed
Fixed crash when resizing YUV textures
Sam Lantinga <slouken@libsdl.org>
parents:
2874
diff
changeset
|
1140 SDL_zero(src); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1141 src.format = &fmt; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1142 src.w = texture->w; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1143 src.h = texture->h; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1144 #ifndef NO_SHARED_MEMORY |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1145 if (texturedata->shminfo.shmaddr) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1146 src.pixels = texturedata->shminfo.shmaddr; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1147 } else |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1148 #endif |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1149 src.pixels = texturedata->pixels; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1150 src.pitch = texturedata->pitch; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1151 |
2882
04e89201f6ed
Fixed crash when resizing YUV textures
Sam Lantinga <slouken@libsdl.org>
parents:
2874
diff
changeset
|
1152 SDL_zero(dst); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1153 dst.format = &fmt; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1154 dst.w = image->width; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1155 dst.h = image->height; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1156 dst.pixels = image->data; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1157 dst.pitch = image->bytes_per_line; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1158 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1159 fmt.BytesPerPixel = SDL_BYTESPERPIXEL(texturedata->format); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1160 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1161 rect.x = 0; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1162 rect.y = 0; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1163 rect.w = dstrect->w; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1164 rect.h = dstrect->h; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1165 if (SDL_SoftStretch(&src, srcrect, &dst, &rect) < 0) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1166 return -1; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1167 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1168 XPutImage(data->display, data->drawable, data->gc, image, 0, 0, |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1169 dstrect->x, dstrect->y, dstrect->w, dstrect->h); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1170 } else { |
2827
aec4399c507a
If scaling isn't supported, do an unscaled copy instead of not showing anything.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1171 XCopyArea(data->display, texturedata->pixmap, data->drawable, |
aec4399c507a
If scaling isn't supported, do an unscaled copy instead of not showing anything.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1172 data->gc, srcrect->x, srcrect->y, dstrect->w, dstrect->h, |
aec4399c507a
If scaling isn't supported, do an unscaled copy instead of not showing anything.
Sam Lantinga <slouken@libsdl.org>
parents:
2814
diff
changeset
|
1173 srcrect->x, srcrect->y); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1174 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1175 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1176 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1177 |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1178 static int |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1179 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
|
1180 Uint32 format, void * pixels, int pitch) |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1181 { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1182 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
|
1183 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
|
1184 SDL_VideoDisplay *display = window->display; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1185 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
|
1186 XImage *image; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1187 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1188 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
|
1189 rect->w, rect->h, AllPlanes, ZPixmap); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1190 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1191 SDL_ConvertPixels(rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1192 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
|
1193 format, pixels, pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1194 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1195 XDestroyImage(image); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1196 return 0; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1197 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1198 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1199 static int |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1200 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
|
1201 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
|
1202 { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1203 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
|
1204 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
|
1205 SDL_VideoDisplay *display = window->display; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1206 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
|
1207 XImage *image; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1208 void *image_pixels; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1209 int image_pitch; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1210 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1211 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
|
1212 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
|
1213 if (!image_pixels) { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1214 SDL_OutOfMemory(); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1215 return -1; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1216 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1217 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1218 image = XCreateImage(data->display, data->visual, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1219 data->depth, ZPixmap, 0, image_pixels, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1220 rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1221 SDL_BYTESPERPIXEL(screen_format) * 8, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1222 image_pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1223 if (!image) { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1224 SDL_SetError("XCreateImage() failed"); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1225 return -1; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1226 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1227 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1228 SDL_ConvertPixels(rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1229 format, pixels, pitch, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1230 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
|
1231 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1232 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
|
1233 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
|
1234 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1235 image->data = NULL; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1236 XDestroyImage(image); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1237 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1238 SDL_free(image_pixels); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1239 return 0; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1240 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1241 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1242 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1243 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
|
1244 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1245 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
|
1246 SDL_DirtyRect *dirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1247 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1248 /* 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
|
1249 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
|
1250 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
|
1251 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
|
1252 #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
|
1253 if(data->xrender_available == SDL_TRUE) |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1254 { |
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
|
1255 XRenderComposite(data->display, PictOpOver, data->drawable_pict, None, data->xwindow_pict, |
4579
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1256 rect->x, rect->y, 0, 0, rect->x, rect->y, rect->w, rect->h); |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1257 } |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1258 else |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1259 #endif |
d490d63bcc5e
X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4578
diff
changeset
|
1260 { |
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
|
1261 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
|
1262 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
|
1263 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
|
1264 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1265 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1266 SDL_ClearDirtyRects(&data->dirty); |
4582
a17fbd25767b
It seems that the off-screen buffers (or pixmaps) only need to be cleared while initializing.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4581
diff
changeset
|
1267 /*#ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
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
|
1268 // Clear each pixmap after a render |
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
|
1269 if(data->xrender_available == SDL_TRUE) { |
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
|
1270 XRenderComposite(data->display, PictOpClear, data->drawable_pict, None, data->drawable_pict, |
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
|
1271 0, 0, 0, 0, 0, 0, renderer->window->w, renderer->window->h); |
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
|
1272 } |
4582
a17fbd25767b
It seems that the off-screen buffers (or pixmaps) only need to be cleared while initializing.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4581
diff
changeset
|
1273 #endif*/ |
2810
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 XSync(data->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1276 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1277 /* 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
|
1278 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
|
1279 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
|
1280 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
|
1281 #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
|
1282 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
|
1283 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1284 } 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
|
1285 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
|
1286 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
|
1287 #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
|
1288 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
|
1289 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1290 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1291 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1292 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1293 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1294 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
|
1295 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1296 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
|
1297 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
|
1298 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1299 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1300 return; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1301 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1302 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1303 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
|
1304 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1305 if (data->pixmap != None) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1306 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
|
1307 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1308 if (data->image) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1309 data->image->data = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1310 XDestroyImage(data->image); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1311 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1312 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1313 if (data->shminfo.shmaddr) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1314 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
|
1315 XSync(renderdata->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1316 shmdt(data->shminfo.shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1317 data->pixels = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1318 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1319 #endif |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1320 if (data->scaling_image) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1321 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
|
1322 data->scaling_image->data = NULL; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1323 XDestroyImage(data->scaling_image); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1324 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1325 if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1326 SDL_free(data->pixels); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1327 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1328 SDL_free(data); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1329 texture->driverdata = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1330 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1331 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1332 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1333 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
|
1334 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1335 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
|
1336 int i; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1337 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1338 if (data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1339 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
|
1340 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
|
1341 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
|
1342 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1343 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1344 if (data->gc) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1345 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
|
1346 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1347 SDL_FreeDirtyRects(&data->dirty); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1348 SDL_free(data); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1349 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1350 SDL_free(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1351 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1352 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1353 #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
|
1354 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1355 /* vi: set ts=4 sw=4 expandtab: */ |