Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11render.c @ 4578:cb338fa6535c
Xrender uses 16 bit color per channel. Fixed the color handling in X11_RenderFillRects to match this. Xrender just works now for filling rectangles :D .
author | Sunny Sachanandani <sunnysachanandani@gmail.com> |
---|---|
date | Mon, 31 May 2010 15:09:36 +0530 |
parents | 87a2d87786d4 |
children | d490d63bcc5e |
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 } |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
293 } |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
294 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 if (n > 0) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 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
|
298 #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
|
299 if(data->xrender_available == SDL_TRUE) |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
300 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
|
301 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 data->makedirty = SDL_TRUE; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 } 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
|
304 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
|
305 #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
|
306 if(data->xrender_available == SDL_TRUE) |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
307 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
|
308 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 data->makedirty = SDL_FALSE; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 data->current_pixmap = 0; |
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 /* Get the format of the window */ |
2874 | 314 if (!SDL_PixelFormatEnumToMasks |
315 (display->current_mode.format, &bpp, &Rmask, &Gmask, &Bmask, | |
316 &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
|
317 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
|
318 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
|
319 return NULL; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 } |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
321 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
|
322 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 /* Create the drawing context */ |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 gcv.graphics_exposures = False; |
2814 | 325 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
|
326 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
|
327 if (!data->gc) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 X11_DestroyRenderer(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 SDL_SetError("XCreateGC() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 return NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 return renderer; |
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 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 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
|
338 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 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
|
340 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
|
341 int i, n; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 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
|
344 n = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 } 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
|
346 n = 2; |
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_PRESENTFLIP3) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 n = 3; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 n = 1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 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
|
353 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
|
354 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
|
355 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
|
356 #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
|
357 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
|
358 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 for (i = 0; i < n; ++i) { |
2814 | 362 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
|
363 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
|
364 data->depth); |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 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
|
366 SDL_SetError("XCreatePixmap() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
369 #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
|
370 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
|
371 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
|
372 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
|
373 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
|
374 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
|
375 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
|
376 } |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
377 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
378 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 if (n > 0) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 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
|
382 #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
|
383 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
|
384 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 data->current_pixmap = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 return 0; |
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 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 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
|
393 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 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
|
395 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
|
396 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
|
397 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
|
398 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
|
399 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 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
|
401 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 texture->driverdata = data; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 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
|
408 data->yuv = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 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
|
410 if (!data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 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
|
414 } else { |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
415 /* 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
|
416 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
|
417 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
|
418 */ |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
419 #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
|
420 // Assume the texture is supported by Xrender |
4575
037ddbeee6c3
Fix typo.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4574
diff
changeset
|
421 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
|
422 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
|
423 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
|
424 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
|
425 return -1; |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
426 } |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
427 } |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
428 #else |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
429 /* 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
|
430 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
|
431 This BadMatch error |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
432 */ |
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
|
433 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
|
434 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
|
435 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
|
436 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
437 #endif |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 data->format = texture->format; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 } |
2814 | 440 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
|
441 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
|
442 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 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
|
444 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 XShmSegmentInfo *shminfo = &data->shminfo; |
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 shm_error = True; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 if (SDL_X11_HAVE_SHM) { |
2814 | 450 shminfo->shmid = |
451 shmget(IPC_PRIVATE, texture->h * data->pitch, | |
452 IPC_CREAT | 0777); | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 if (shminfo->shmid >= 0) { |
2814 | 454 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
|
455 shminfo->readOnly = False; |
2814 | 456 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
|
457 shm_error = False; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 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
|
459 XShmAttach(renderdata->display, shminfo); |
3239 | 460 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
|
461 XSetErrorHandler(X_handler); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 if (shm_error) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 shmdt(shminfo->shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 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
|
467 } |
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 if (!shm_error) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
470 data->pixels = shminfo->shmaddr; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 |
2814 | 472 data->image = |
2874 | 473 XShmCreateImage(renderdata->display, renderdata->visual, |
474 renderdata->depth, ZPixmap, shminfo->shmaddr, | |
475 shminfo, texture->w, texture->h); | |
2814 | 476 if (!data->image) { |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 XShmDetach(renderdata->display, shminfo); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 XSync(renderdata->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 shmdt(shminfo->shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 shm_error = True; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 if (shm_error) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 shminfo->shmaddr = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 if (!data->image) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 #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
|
488 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 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
|
490 if (!data->pixels) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
491 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
|
492 SDL_OutOfMemory(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 |
2814 | 496 data->image = |
2874 | 497 XCreateImage(renderdata->display, renderdata->visual, |
498 renderdata->depth, ZPixmap, 0, data->pixels, | |
499 texture->w, texture->h, | |
500 SDL_BYTESPERPIXEL(data->format) * 8, | |
501 data->pitch); | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 if (!data->image) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
503 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
|
504 SDL_SetError("XCreateImage() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 } else { |
2814 | 509 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
|
510 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
|
511 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
|
512 if (data->pixmap == None) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
513 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
|
514 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
|
515 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 } |
4572
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
517 |
266ec93f49af
Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4571
diff
changeset
|
518 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
519 if(renderdata->xrender_available) { |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
520 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
|
521 unsigned long x11_fmt_mask; // Format mask |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
522 XRenderPictFormat x11_templ_fmt; // Format template |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
523 x11_fmt_mask = |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
524 (PictFormatDepth | PictFormatRedMask | PictFormatGreenMask |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
525 | PictFormatBlueMask); |
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
|
526 Uint32 Rmask, Gmask, Bmask, Amask; |
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
527 int bpp; |
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
528 SDL_PixelFormatEnumToMasks(data->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); |
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
529 x11_templ_fmt.depth = bpp; |
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
530 x11_templ_fmt.direct.redMask = Rmask; |
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
531 x11_templ_fmt.direct.greenMask = Gmask; |
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
532 x11_templ_fmt.direct.blueMask = Bmask; |
87a2d87786d4
Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4576
diff
changeset
|
533 x11_templ_fmt.direct.alphaMask = Amask; |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
534 /* Return one matching XRenderPictFormat */ |
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
|
535 data->picture_fmt = |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
536 XRenderFindFormat(renderdata->display, x11_fmt_mask, &x11_templ_fmt, 1); |
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
|
537 if(!data->picture_fmt) { |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
538 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
|
539 } |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
540 data->picture_attr_valuemask = CPGraphicsExposure; |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
541 (data->picture_attr).graphics_exposures = False; |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
542 data->picture = |
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
|
543 XRenderCreatePicture(renderdata->display, data->pixmap, data->picture_fmt, |
4573
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
544 data->picture_attr_valuemask, &(data->picture_attr)); |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
545 if(!data->picture) { |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
546 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
|
547 } |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
548 } |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
549 /* We thought we could render the texture with Xrender but this was |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
550 not possible for some reason. Now we must ensure that texture |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
551 format and window format match to avoid a BadMatch error. |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
552 */ |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
553 if(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
|
554 if (texture->format != display->current_mode.format) { |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
555 SDL_SetError("Texture format doesn't match window format"); |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
556 return -1; |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
557 } |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
558 } |
6399178be313
Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4572
diff
changeset
|
559 #endif |
2814 | 560 data->image = |
2874 | 561 XCreateImage(renderdata->display, renderdata->visual, |
562 renderdata->depth, ZPixmap, 0, NULL, texture->w, | |
563 texture->h, SDL_BYTESPERPIXEL(data->format) * 8, | |
564 data->pitch); | |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
565 if (!data->image) { |
2868
3b595278f813
Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
566 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
|
567 SDL_SetError("XCreateImage() failed"); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
568 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
569 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
570 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 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
|
577 void **pixels, int *pitch) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
578 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
579 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
|
580 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
581 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
582 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
|
583 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
584 *pixels = data->pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
585 *pitch = data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
587 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
589 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
590 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 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
|
592 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
593 switch (texture->blendMode) { |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
594 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
|
595 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 default: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
597 SDL_Unsupported(); |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
598 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
|
599 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
601 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
603 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 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
|
605 { |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
606 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
|
607 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
608 switch (texture->scaleMode) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
609 case SDL_TEXTURESCALEMODE_NONE: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
610 return 0; |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
611 case SDL_TEXTURESCALEMODE_FAST: |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
612 /* 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
|
613 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
|
614 return 0; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
615 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
616 /* 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
|
617 default: |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 SDL_Unsupported(); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 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
|
620 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
622 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
624 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
625 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
626 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
|
627 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
|
628 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
629 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
|
630 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
631 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
632 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
|
633 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
634 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
635 UpdateYUVTextureData(texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
636 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
637 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
638 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
|
639 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
640 if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
641 Uint8 *src, *dst; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 int row; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 size_t length; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
644 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
645 src = (Uint8 *) pixels; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
646 dst = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
647 (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
|
648 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
|
649 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
|
650 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
|
651 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
|
652 src += pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
653 dst += data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
656 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
|
657 data->image->height = rect->h; |
2814 | 658 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
|
659 data->image->bytes_per_line = pitch; |
2814 | 660 XPutImage(renderdata->display, data->pixmap, renderdata->gc, |
661 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
|
662 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
663 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
664 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
665 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
666 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
667 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
668 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
|
669 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
|
670 int *pitch) |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
671 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
672 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
|
673 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
674 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
675 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
|
676 pitch); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
677 } else if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
678 *pixels = |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
679 (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
|
680 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
|
681 *pitch = data->pitch; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
682 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
683 } else { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
684 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
|
685 return -1; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
686 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
687 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
688 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
689 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
690 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
|
691 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
692 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
|
693 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
694 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
695 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
|
696 UpdateYUVTextureData(texture); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
697 } |
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 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
700 static int |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
701 X11_SetDrawBlendMode(SDL_Renderer * renderer) |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
702 { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
703 switch (renderer->blendMode) { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
704 case SDL_BLENDMODE_NONE: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
705 return 0; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
706 default: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
707 SDL_Unsupported(); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
708 renderer->blendMode = SDL_BLENDMODE_NONE; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
709 return -1; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
710 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
711 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
712 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
713 static Uint32 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
714 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
|
715 { |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
716 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
|
717 Uint8 r = renderer->r; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
718 Uint8 g = renderer->g; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
719 Uint8 b = renderer->b; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
720 Uint8 a = renderer->a; |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
721 if (premult) |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
722 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
|
723 ((int) g * (int) a) / 255, |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
724 ((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
|
725 else |
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
726 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
|
727 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
728 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
729 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
|
730 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
|
731 int count) |
2901 | 732 { |
733 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
|
734 SDL_Window *window = renderer->window; |
2901 | 735 unsigned long foreground; |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
736 XPoint *xpoints, *xpoint; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
737 int i, xcount; |
2901 | 738 |
739 if (data->makedirty) { | |
740 SDL_Rect rect; | |
741 | |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
742 /* 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
|
743 rect.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
744 rect.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
745 rect.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
746 rect.h = window->h; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
747 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
|
748 /* Nothing to draw */ |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
749 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
750 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
751 SDL_AddDirtyRect(&data->dirty, &rect); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
752 } |
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 foreground = renderdrawcolor(renderer, 1); |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
755 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
|
756 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
757 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
|
758 xcount = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
759 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
|
760 int x = points[i].x; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
761 int y = points[i].y; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
762 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
|
763 continue; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
764 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
765 xpoint->x = (short)x; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
766 xpoint->y = (short)y; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
767 ++xpoint; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
768 ++xcount; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
769 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
770 if (xcount > 0) { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
771 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
|
772 CoordModeOrigin); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
773 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
774 SDL_stack_free(xpoints); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
775 |
2894 | 776 return 0; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
777 } |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
778 |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
779 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
|
780 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
|
781 int count) |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
782 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
783 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
|
784 SDL_Window *window = renderer->window; |
4458
c9584df65367
Removed unused variables
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
785 SDL_Rect clip; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
786 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
|
787 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
|
788 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
|
789 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
|
790 int maxx, maxy; |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
791 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
792 clip.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
793 clip.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
794 clip.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
795 clip.h = window->h; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
796 |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2882
diff
changeset
|
797 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
|
798 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
|
799 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
800 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
|
801 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
|
802 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
|
803 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
|
804 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
|
805 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
|
806 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
|
807 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
|
808 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
|
809 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
810 /* 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
|
811 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
|
812 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
|
813 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
|
814 } 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
|
815 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
|
816 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
817 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
|
818 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
|
819 } 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
|
820 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
|
821 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
822 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
|
823 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
|
824 ++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
|
825 ++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
|
826 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
|
827 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
828 |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
829 /* 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
|
830 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
|
831 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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 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
|
837 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
|
838 } 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
|
839 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
|
840 } |
c2154674c0c1
Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents:
3538
diff
changeset
|
841 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
|
842 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
|
843 } 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
|
844 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
|
845 } |
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 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
|
847 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
|
848 ++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
|
849 ++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
|
850 } |
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 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
|
852 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
|
853 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
|
854 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
|
855 } |
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 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
|
857 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
|
858 |
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 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
|
860 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
|
861 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
|
862 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
|
863 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
|
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 = 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
|
866 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
|
867 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
|
868 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
|
869 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
|
870 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
|
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 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
|
873 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
|
874 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
|
875 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
|
876 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
|
877 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
|
878 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
|
879 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
|
880 } 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
|
881 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
|
882 } |
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 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
|
884 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
|
885 } 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
|
886 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
|
887 } |
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 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
|
889 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
|
890 ++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
|
891 ++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
|
892 } |
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 } |
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 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
|
896 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
|
897 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
|
898 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
|
899 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
|
900 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
|
901 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
|
902 } |
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 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
|
904 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
|
905 |
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 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
|
907 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
|
908 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
|
909 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
|
910 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
|
911 } |
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 } |
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 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
|
914 |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
915 return 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
916 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
917 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
918 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
|
919 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
|
920 { |
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
|
921 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
|
922 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
|
923 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
|
924 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
|
925 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
|
926 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
|
927 |
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
|
928 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
|
929 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
|
930 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
|
931 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
|
932 |
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
|
933 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
|
934 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
|
935 |
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
|
936 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
|
937 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
|
938 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
|
939 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
|
940 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
|
941 } |
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
|
942 |
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
|
943 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
|
944 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
|
945 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
|
946 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
|
947 ++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
|
948 ++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
|
949 |
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
|
950 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
|
951 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
|
952 } |
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
|
953 } |
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
|
954 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
|
955 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
|
956 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
|
957 } |
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
|
958 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
|
959 |
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
|
960 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
|
961 } |
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 |
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 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
|
964 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
|
965 { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
966 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
|
967 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
|
968 SDL_Rect clip, rect; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
969 unsigned long foreground; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
970 XRectangle *xrects, *xrect; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
971 int i, xcount; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
972 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
973 clip.x = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
974 clip.y = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
975 clip.w = window->w; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
976 clip.h = window->h; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
977 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
978 foreground = renderdrawcolor(renderer, 1); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
979 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
|
980 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
981 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
|
982 xcount = 0; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
983 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
|
984 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
|
985 continue; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
986 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
987 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
988 xrect->x = (short)rect.x; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
989 xrect->y = (short)rect.y; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
990 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
|
991 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
|
992 ++xrect; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
993 ++xcount; |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
994 |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
995 if (data->makedirty) { |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
996 SDL_AddDirtyRect(&data->dirty, &rect); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
997 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
998 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
999 if (xcount > 0) { |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1000 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER |
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1001 if(data->xrender_available == SDL_TRUE) |
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1002 { |
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
|
1003 XRenderColor xrender_foreground_color; |
4578
cb338fa6535c
Xrender uses 16 bit color per channel. Fixed the color handling in X11_RenderFillRects to match this. Xrender just works now for filling rectangles :D .
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4577
diff
changeset
|
1004 xrender_foreground_color.red = (unsigned short) ((renderer->r / 255.0) * 0xFFFF); |
cb338fa6535c
Xrender uses 16 bit color per channel. Fixed the color handling in X11_RenderFillRects to match this. Xrender just works now for filling rectangles :D .
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4577
diff
changeset
|
1005 xrender_foreground_color.green = (unsigned short) ((renderer->g / 255.0) * 0xFFFF); |
cb338fa6535c
Xrender uses 16 bit color per channel. Fixed the color handling in X11_RenderFillRects to match this. Xrender just works now for filling rectangles :D .
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4577
diff
changeset
|
1006 xrender_foreground_color.blue = (unsigned short) ((renderer->b / 255.0) * 0xFFFF); |
cb338fa6535c
Xrender uses 16 bit color per channel. Fixed the color handling in X11_RenderFillRects to match this. Xrender just works now for filling rectangles :D .
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4577
diff
changeset
|
1007 xrender_foreground_color.alpha = (unsigned short) ((renderer->a / 255.0) * 0xFFFF); |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1008 XRenderFillRectangles(data->display, PictOpSrc, 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
|
1009 &xrender_foreground_color, xrects, xcount); |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1010 } |
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1011 else |
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1012 #endif |
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1013 { |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1014 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
|
1015 xrects, xcount); |
4576
2b98162b536a
Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents:
4575
diff
changeset
|
1016 } |
3538
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1017 } |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1018 SDL_stack_free(xpoints); |
a1896642a47e
X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1019 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1020 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1021 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1022 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1023 static int |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1024 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
|
1025 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
|
1026 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1027 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
|
1028 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
|
1029 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1030 if (data->makedirty) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1031 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
|
1032 } |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1033 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
|
1034 #ifndef NO_SHARED_MEMORY |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1035 if (texturedata->shminfo.shmaddr) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1036 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
|
1037 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
|
1038 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
|
1039 False); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1040 } else |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1041 #endif |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1042 if (texturedata->pixels) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1043 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
|
1044 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
|
1045 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
|
1046 } else { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1047 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
|
1048 data->gc, srcrect->x, srcrect->y, dstrect->w, |
3066
8cbf68bdf81b
Fixed destination of XCopyArea()
Sam Lantinga <slouken@libsdl.org>
parents:
3044
diff
changeset
|
1049 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
|
1050 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1051 } else if (texturedata->yuv |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1052 || texture->access == SDL_TEXTUREACCESS_STREAMING) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1053 SDL_Surface src, dst; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1054 SDL_PixelFormat fmt; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1055 SDL_Rect rect; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1056 XImage *image = texturedata->scaling_image; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1057 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1058 if (!image) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1059 void *pixels; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1060 int pitch; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1061 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1062 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
|
1063 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
|
1064 if (!pixels) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1065 SDL_OutOfMemory(); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1066 return -1; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1067 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1068 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1069 image = |
2874 | 1070 XCreateImage(data->display, data->visual, data->depth, |
1071 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
|
1072 SDL_BYTESPERPIXEL(texturedata->format) * 8, |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1073 pitch); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1074 if (!image) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1075 SDL_SetError("XCreateImage() failed"); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1076 return -1; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1077 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1078 texturedata->scaling_image = image; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1079 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1080 } 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
|
1081 || !image->data) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1082 image->width = dstrect->w; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1083 image->height = dstrect->h; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1084 image->bytes_per_line = |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1085 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
|
1086 image->data = |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1087 (char *) SDL_realloc(image->data, |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1088 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
|
1089 if (!image->data) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1090 SDL_OutOfMemory(); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1091 return -1; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1092 } |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1093 } |
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 /* Set up fake surfaces for SDL_SoftStretch() */ |
2882
04e89201f6ed
Fixed crash when resizing YUV textures
Sam Lantinga <slouken@libsdl.org>
parents:
2874
diff
changeset
|
1096 SDL_zero(src); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1097 src.format = &fmt; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1098 src.w = texture->w; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1099 src.h = texture->h; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1100 #ifndef NO_SHARED_MEMORY |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1101 if (texturedata->shminfo.shmaddr) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1102 src.pixels = texturedata->shminfo.shmaddr; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1103 } else |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1104 #endif |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1105 src.pixels = texturedata->pixels; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1106 src.pitch = texturedata->pitch; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1107 |
2882
04e89201f6ed
Fixed crash when resizing YUV textures
Sam Lantinga <slouken@libsdl.org>
parents:
2874
diff
changeset
|
1108 SDL_zero(dst); |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1109 dst.format = &fmt; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1110 dst.w = image->width; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1111 dst.h = image->height; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1112 dst.pixels = image->data; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1113 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
|
1114 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1115 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
|
1116 |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1117 rect.x = 0; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1118 rect.y = 0; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1119 rect.w = dstrect->w; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1120 rect.h = dstrect->h; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1121 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
|
1122 return -1; |
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 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
|
1125 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
|
1126 } 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
|
1127 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
|
1128 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
|
1129 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
|
1130 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1131 return 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1132 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1133 |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1134 static int |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1135 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
|
1136 Uint32 format, void * pixels, int pitch) |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1137 { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1138 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
|
1139 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
|
1140 SDL_VideoDisplay *display = window->display; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1141 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
|
1142 XImage *image; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1143 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1144 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
|
1145 rect->w, rect->h, AllPlanes, ZPixmap); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1146 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1147 SDL_ConvertPixels(rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1148 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
|
1149 format, pixels, pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1150 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1151 XDestroyImage(image); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1152 return 0; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1153 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1154 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1155 static int |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1156 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
|
1157 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
|
1158 { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1159 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
|
1160 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
|
1161 SDL_VideoDisplay *display = window->display; |
3559
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1162 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
|
1163 XImage *image; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1164 void *image_pixels; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1165 int image_pitch; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1166 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1167 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
|
1168 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
|
1169 if (!image_pixels) { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1170 SDL_OutOfMemory(); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1171 return -1; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1172 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1173 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1174 image = XCreateImage(data->display, data->visual, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1175 data->depth, ZPixmap, 0, image_pixels, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1176 rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1177 SDL_BYTESPERPIXEL(screen_format) * 8, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1178 image_pitch); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1179 if (!image) { |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1180 SDL_SetError("XCreateImage() failed"); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1181 return -1; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1182 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1183 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1184 SDL_ConvertPixels(rect->w, rect->h, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1185 format, pixels, pitch, |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1186 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
|
1187 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1188 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
|
1189 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
|
1190 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1191 image->data = NULL; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1192 XDestroyImage(image); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1193 |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1194 SDL_free(image_pixels); |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1195 return 0; |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1196 } |
5f26a7eb5ff0
Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3543
diff
changeset
|
1197 |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1198 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1199 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
|
1200 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1201 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
|
1202 SDL_DirtyRect *dirty; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1203 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1204 /* 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
|
1205 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
|
1206 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
|
1207 const SDL_Rect *rect = &dirty->rect; |
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
|
1208 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
|
1209 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
|
1210 rect->x, rect->y); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1211 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1212 SDL_ClearDirtyRects(&data->dirty); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1213 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1214 XSync(data->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1215 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1216 /* 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
|
1217 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
|
1218 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
|
1219 data->drawable = data->pixmaps[data->current_pixmap]; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1220 } 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
|
1221 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
|
1222 data->drawable = data->pixmaps[data->current_pixmap]; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1223 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1224 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1225 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1226 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1227 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
|
1228 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1229 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
|
1230 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
|
1231 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1232 if (!data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1233 return; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1234 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1235 if (data->yuv) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1236 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
|
1237 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1238 if (data->pixmap != None) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1239 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
|
1240 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1241 if (data->image) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1242 data->image->data = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1243 XDestroyImage(data->image); |
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 #ifndef NO_SHARED_MEMORY |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1246 if (data->shminfo.shmaddr) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1247 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
|
1248 XSync(renderdata->display, False); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1249 shmdt(data->shminfo.shmaddr); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1250 data->pixels = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1251 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1252 #endif |
2828
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1253 if (data->scaling_image) { |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1254 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
|
1255 data->scaling_image->data = NULL; |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1256 XDestroyImage(data->scaling_image); |
7e5ff6cd05bf
Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2827
diff
changeset
|
1257 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1258 if (data->pixels) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1259 SDL_free(data->pixels); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1260 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1261 SDL_free(data); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1262 texture->driverdata = NULL; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1263 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1264 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1265 static void |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1266 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
|
1267 { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1268 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
|
1269 int i; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1270 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1271 if (data) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1272 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
|
1273 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
|
1274 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
|
1275 } |
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 if (data->gc) { |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1278 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
|
1279 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1280 SDL_FreeDirtyRects(&data->dirty); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1281 SDL_free(data); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1282 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1283 SDL_free(renderer); |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1284 } |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1285 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1286 #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
|
1287 |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1288 /* vi: set ts=4 sw=4 expandtab: */ |