annotate src/video/x11/SDL_x11render.c @ 4612:9a5db97cd569

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