annotate src/video/x11/SDL_x11render.c @ 4602:4fbf64d504cf

Use XDamage to optimise drawing operations.
author Sunny Sachanandani <sunnysachanandani@gmail.com>
date Mon, 19 Jul 2010 17:46:37 +0530
parents 8b22d33d8260
children dffa432f0e2b
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
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
34 #include <X11/extensions/Xdamage.h>
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
35 #include <X11/extensions/Xfixes.h>
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
36
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 /* X11 renderer implementation */
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 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
40 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
41 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
42 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
43 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
44 int *pitch);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 static int X11_SetTextureBlendMode(SDL_Renderer * renderer,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 SDL_Texture * texture);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 static int X11_SetTextureScaleMode(SDL_Renderer * renderer,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 SDL_Texture * texture);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 static int X11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 const SDL_Rect * rect, const void *pixels,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 int pitch);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 static int X11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 const SDL_Rect * rect, int markDirty,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 void **pixels, int *pitch);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 static void X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
56 static int X11_SetDrawBlendMode(SDL_Renderer * renderer);
3596
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3559
diff changeset
57 static int X11_RenderDrawPoints(SDL_Renderer * renderer,
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3559
diff changeset
58 const SDL_Point * points, int count);
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3559
diff changeset
59 static int X11_RenderDrawLines(SDL_Renderer * renderer,
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3559
diff changeset
60 const SDL_Point * points, int count);
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3559
diff changeset
61 static int X11_RenderDrawRects(SDL_Renderer * renderer,
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3559
diff changeset
62 const SDL_Rect ** rects, int count);
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3559
diff changeset
63 static int X11_RenderFillRects(SDL_Renderer * renderer,
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3559
diff changeset
64 const SDL_Rect ** rects, int count);
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 static int X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 const SDL_Rect * srcrect, const SDL_Rect * dstrect);
3559
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
67 static int X11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
68 Uint32 format, void * pixels, int pitch);
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
69 static int X11_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
70 Uint32 format, const void * pixels, int pitch);
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 static void X11_RenderPresent(SDL_Renderer * renderer);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 static void X11_DestroyTexture(SDL_Renderer * renderer,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 SDL_Texture * texture);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 static void X11_DestroyRenderer(SDL_Renderer * renderer);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 SDL_RenderDriver X11_RenderDriver = {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 X11_CreateRenderer,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 "x11",
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED),
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 SDL_TEXTUREMODULATE_NONE,
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
85 SDL_BLENDMODE_NONE,
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 SDL_TEXTURESCALEMODE_NONE,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 0,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 {0},
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 0,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 0}
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 };
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 typedef struct
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 Display *display;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 int screen;
2870
b801df19835f The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents: 2868
diff changeset
97 Visual *visual;
b801df19835f The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents: 2868
diff changeset
98 int depth;
2916
ffdd533f7add Fixed pitch alignment problem causing MITSHM error on 16-bit displays
Sam Lantinga <slouken@libsdl.org>
parents: 2901
diff changeset
99 int scanline_pad;
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3596
diff changeset
100 Window xwindow;
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 Pixmap pixmaps[3];
4571
97dcf6f6213c Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4458
diff changeset
102 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
103 Pixmap stencil;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
104 Pixmap brush;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
105 Picture brush_pict;
4571
97dcf6f6213c Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4458
diff changeset
106 Picture xwindow_pict;
4572
266ec93f49af Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4571
diff changeset
107 Picture pixmap_picts[3];
4576
2b98162b536a Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4575
diff changeset
108 Picture drawable_pict;
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
109 Picture stencil_pict;
4588
0ddd78496d68 Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4587
diff changeset
110 int blend_op;
4571
97dcf6f6213c Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4458
diff changeset
111 XRenderPictFormat* xwindow_pict_fmt;
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
112 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
113 SDL_bool use_xrender;
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
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 int current_pixmap;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 Drawable drawable;
2967
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
119 SDL_PixelFormat format;
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 GC gc;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 SDL_DirtyRectList dirty;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 SDL_bool makedirty;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 } X11_RenderData;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 typedef struct
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 SDL_SW_YUVTexture *yuv;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 Uint32 format;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 Pixmap pixmap;
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
130 int depth;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
131 Visual *visual;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
132 GC gc;
4571
97dcf6f6213c Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4458
diff changeset
133 #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
134 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
135 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
136 int blend_op;
4571
97dcf6f6213c Added a #define option for compile time Xrender support.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4458
diff changeset
137 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 XImage *image;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 #ifndef NO_SHARED_MEMORY
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 /* 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
141 XShmSegmentInfo shminfo;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 #endif
2828
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
143 XImage *scaling_image;
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 void *pixels;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 int pitch;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 } X11_TextureData;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 #ifndef NO_SHARED_MEMORY
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 /* 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
150 static int shm_error;
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
151 static int (*X_handler) (Display *, XErrorEvent *) = NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
152 static int
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
153 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
154 {
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
155 if (e->error_code == BadAccess) {
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
156 shm_error = True;
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
157 return (0);
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
158 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
159 return (X_handler(d, e));
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
160 }
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 #endif /* ! NO_SHARED_MEMORY */
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 static void
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 UpdateYUVTextureData(SDL_Texture * texture)
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 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
168 SDL_Rect rect;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 rect.x = 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 rect.y = 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 rect.w = texture->w;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 rect.h = texture->h;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 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
175 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
176 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 void
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 X11_AddRenderDriver(_THIS)
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 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
182 SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode;
3520
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3239
diff changeset
183 int i;
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184
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
185 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
186 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
187 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
188 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
189 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
190 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU;
4596
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
191 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_ARGB8888;
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192
3520
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3239
diff changeset
193 for (i = 0; i < _this->num_displays; ++i) {
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3239
diff changeset
194 SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver);
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3239
diff changeset
195 }
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 SDL_Renderer *
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 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
200 {
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
201 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
202 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
203 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
204 SDL_Renderer *renderer;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 X11_RenderData *data;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 XGCValues gcv;
4596
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
207 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
208 int i, n;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 int bpp;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 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
211
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 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
213 if (!renderer) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 SDL_OutOfMemory();
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 return NULL;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 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
219 if (!data) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 X11_DestroyRenderer(renderer);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 SDL_OutOfMemory();
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 return NULL;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 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
225 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
226 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
227 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
228 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
229 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
230
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 renderer->DisplayModeChanged = X11_DisplayModeChanged;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 renderer->CreateTexture = X11_CreateTexture;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 renderer->QueryTexturePixels = X11_QueryTexturePixels;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 renderer->SetTextureBlendMode = X11_SetTextureBlendMode;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 renderer->SetTextureScaleMode = X11_SetTextureScaleMode;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 renderer->UpdateTexture = X11_UpdateTexture;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 renderer->LockTexture = X11_LockTexture;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 renderer->UnlockTexture = X11_UnlockTexture;
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
239 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
240 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
241 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
242 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
243 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
244 renderer->RenderCopy = X11_RenderCopy;
3559
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
245 renderer->RenderReadPixels = X11_RenderReadPixels;
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
246 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
247 renderer->RenderPresent = X11_RenderPresent;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 renderer->DestroyTexture = X11_DestroyTexture;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 renderer->DestroyRenderer = X11_DestroyRenderer;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 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
251 renderer->window = window;
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 renderer->driverdata = data;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 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
255
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
256 #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
257 data->use_xrender = SDL_FALSE;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
258 if (SDL_X11_HAVE_XRENDER) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
259 // Query the extension. This is the server runtime check.
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
260 int event_basep, error_basep;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
261 if(XRenderQueryExtension(data->display,
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
262 &event_basep, &error_basep) == True)
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
263 data->use_xrender = SDL_TRUE;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
264 }
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
265 if (data->use_xrender) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
266 // Find the PictFormat from the visual.
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
267 // 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
268 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
269 data->visual);
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
270 if (!data->xwindow_pict_fmt) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
271 SDL_SetError("XRenderFindVisualFormat() failed");
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
272 return NULL;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
273 }
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
274 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
275 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
276 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
277 0, NULL);
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
278 if (!data->xwindow_pict) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
279 SDL_SetError("XRenderCreatePicture() failed");
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
280 return NULL;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
281 }
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
282 // 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
283 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
284 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
285 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
286 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
287 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
288 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
289 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
290 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
291 window->w, window->h);
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
292 // Add some blending modes to the list of supported blending modes
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
293 renderer->info.blend_modes |=
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
294 (SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MASK);
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
295 // 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
296 data->stencil = XCreatePixmap(data->display, data->xwindow,
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
297 window->w, window->h, 8);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
298
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
299 // 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
300 data->stencil_gc = XCreateGC(data->display, data->stencil,
4596
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
301 GCGraphicsExposures, &gcv);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
302 XSetBackground(data->display, data->stencil_gc, 0x00);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
303 XSetForeground(data->display, data->stencil_gc, 0x00);
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
304 XFillRectangle(data->display, data->stencil, data->stencil_gc,
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
305 0, 0, window->w, window->h);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
306 XSetForeground(data->display, data->stencil_gc, 0xFF);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
307 data->stencil_pict =
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
308 XRenderCreatePicture(data->display, data->stencil,
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
309 XRenderFindStandardFormat(data->display,
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
310 PictStandardA8),
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
311 0, NULL);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
312 data->stencil_damage =
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
313 XDamageCreate(data->display, data->stencil, XDamageReportNonEmpty);
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
314 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
315 data->brush =
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
316 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
317 XRenderPictureAttributes brush_attr;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
318 brush_attr.repeat = RepeatNormal;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
319 data->brush_pict =
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
320 XRenderCreatePicture(data->display, data->brush,
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
321 XRenderFindStandardFormat(data->display,
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
322 PictStandardARGB32),
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
323 CPRepeat, &brush_attr);
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
324 // 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
325 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
326 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
327 }
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
328 #endif
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
329
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 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
331 renderer->info.flags |=
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 (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
333 n = 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 } 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
335 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
336 n = 2;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 } 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
338 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
339 n = 3;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 } else {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 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
342 n = 1;
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 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
345 #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
346 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
347 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
348 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
349 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
350 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
351 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
352 }
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
353 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
354 #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
355 {
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
356 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
357 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
358 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
359 }
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 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
361 X11_DestroyRenderer(renderer);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 SDL_SetError("XCreatePixmap() failed");
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 return NULL;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 }
4573
6399178be313 Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4572
diff changeset
365 #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
366 if (data->use_xrender) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
367 // Create xrender pictures for each of the pixmaps
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
368 // 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
369 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
370 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
371 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
372 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
373 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
374 0, None);
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
375 if (!data->pixmap_picts[i]) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
376 SDL_SetError("XRenderCreatePicture() failed");
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
377 return NULL;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
378 }
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
379
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
380 XRenderComposite(data->display,
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
381 PictOpClear,
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
382 data->pixmap_picts[i],
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
383 None,
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
384 data->pixmap_picts[i],
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
385 0, 0,
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
386 0, 0,
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
387 0, 0,
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
388 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
389 }
6399178be313 Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4572
diff changeset
390 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 if (n > 0) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 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
394 #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
395 if(data->use_xrender == SDL_TRUE)
4576
2b98162b536a Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4575
diff changeset
396 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
397 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 data->makedirty = SDL_TRUE;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 } 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
400 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
401 #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
402 if(data->use_xrender == SDL_TRUE)
4576
2b98162b536a Add Xrender support to X11_FillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4575
diff changeset
403 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
404 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 data->makedirty = SDL_FALSE;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 data->current_pixmap = 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 /* Get the format of the window */
2874
Sam Lantinga <slouken@libsdl.org>
parents: 2870
diff changeset
410 if (!SDL_PixelFormatEnumToMasks
Sam Lantinga <slouken@libsdl.org>
parents: 2870
diff changeset
411 (display->current_mode.format, &bpp, &Rmask, &Gmask, &Bmask,
Sam Lantinga <slouken@libsdl.org>
parents: 2870
diff changeset
412 &Amask)) {
2870
b801df19835f The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents: 2868
diff changeset
413 SDL_SetError("Unknown display format");
b801df19835f The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents: 2868
diff changeset
414 X11_DestroyRenderer(renderer);
b801df19835f The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents: 2868
diff changeset
415 return NULL;
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 }
2967
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
417 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
418
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 /* Create the drawing context */
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 gcv.graphics_exposures = False;
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
421 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
422 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
423 if (!data->gc) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 X11_DestroyRenderer(renderer);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 SDL_SetError("XCreateGC() failed");
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 return NULL;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 return renderer;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 static int
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 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
434 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 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
436 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
437 int i, n;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438
4596
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
439 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
440 if (data->use_xrender) {
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
441 XRenderFreePicture(data->display, data->xwindow_pict);
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
442 data->xwindow_pict_fmt =
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
443 XRenderFindVisualFormat(data->display, data->visual);
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
444 data->xwindow_pict =
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
445 XRenderCreatePicture(data->display, data->xwindow,
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
446 data->xwindow_pict_fmt, 0, NULL);
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
447 }
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
448 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 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
450 n = 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 } 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
452 n = 2;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 } 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
454 n = 3;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 } else {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 n = 1;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 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
459 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
460 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
461 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
462 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
4596
dc26c37ad70e Got testsprite2 to work reasonably.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4595
diff changeset
463 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
464 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
465 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468 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
469 #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
470 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
471 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
472 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
473 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
474 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
475 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
476 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
477 }
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
478 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
479 #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
480 {
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
481 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
482 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
483 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
484 }
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 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
486 SDL_SetError("XCreatePixmap() failed");
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487 return -1;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 }
4572
266ec93f49af Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4571
diff changeset
489 #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
490 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
491 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
492 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
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 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
495 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
496 0, None);
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
497 if (!data->pixmap_picts[i]) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
498 SDL_SetError("XRenderCreatePicture() failed");
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
499 return -1;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
500 }
4591
1e998db9b597 Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4590
diff changeset
501 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
502 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
503 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
504 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
505 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
506 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
507 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
508 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
509 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
510
1e998db9b597 Implement blending modes for textures. Fix off-screen pixmaps to be ARGB rather than RGB to enable blending across frames. Clear the screen and off-screen pixmaps when the renderer is created.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4590
diff changeset
511 }
4572
266ec93f49af Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4571
diff changeset
512 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514 if (n > 0) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 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
516 #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
517 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
518 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 data->current_pixmap = 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522 return 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
525 #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
526 static void
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
527 SDLMaskToXRenderMask(Uint32 sdl_mask, short *comp, short *compMask) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
528 (*comp) = 0;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
529 (*compMask) = 0;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
530 while(!(sdl_mask & 1)) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
531 (*comp)++;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
532 sdl_mask >>= 1;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
533 }
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
534 while(sdl_mask & 1) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
535 (*compMask) = ((*compMask) << 1) | 1;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
536 sdl_mask >>= 1;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
537 }
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
538 }
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
539
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
540 static XRenderPictFormat*
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
541 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
542 XRenderPictFormat* pict_fmt = NULL;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
543 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
544
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
545 if (data->use_xrender) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
546
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
547 int bpp;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
548 Uint32 Amask, Rmask, Gmask, Bmask;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
549 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
550
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
551 XRenderPictFormat templ;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
552 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
553 PictFormatRedMask | PictFormatGreen | PictFormatGreenMask |
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
554 PictFormatBlue | PictFormatBlueMask | PictFormatAlpha |
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
555 PictFormatAlphaMask);
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
556
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
557 templ.type = PictTypeDirect;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
558 templ.depth = bpp;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
559 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
560 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
561 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
562 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
563
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
564 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
565 }
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
566
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
567 return pict_fmt;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
568 }
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
569
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
570
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
571 static Visual*
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
572 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
573 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
574
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
575 if (data->use_xrender) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
576 int bpp;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
577 Uint32 Amask, Rmask, Gmask, Bmask;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
578 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
579
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
580 XVisualInfo vinfo_templ;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
581 long vinfo_mask;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
582 int nitems_return;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
583
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
584 vinfo_mask = (VisualDepthMask | VisualRedMaskMask |
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
585 VisualGreenMaskMask | VisualBlueMaskMask);
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
586 vinfo_templ.depth = bpp;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
587 vinfo_templ.red_mask = Rmask;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
588 vinfo_templ.green_mask = Gmask;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
589 vinfo_templ.blue_mask = Bmask;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
590
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
591 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
592 &vinfo_templ, &nitems_return);
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
594 if (nitems_return) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
595 return ret[0].visual;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
596 }
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
597 }
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
598
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
599 return NULL;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
600 }
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
601 #endif
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
602
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
603 static int
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
604 X11_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
605 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
606 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
607 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
608 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
609 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
610 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
611 XGCValues gcv;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
612
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 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
614 if (!data) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615 SDL_OutOfMemory();
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
616 return -1;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
617 }
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
618 data->depth = renderdata->depth;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
619 data->visual = renderdata->visual;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
620 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
621
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
622 texture->driverdata = data;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
623 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
624 data->yuv =
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
625 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
626 if (!data->yuv) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627 return -1;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
628 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629 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
630 } else {
4573
6399178be313 Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4572
diff changeset
631 /* If Xrender support is builtin we only need to check whether
6399178be313 Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4572
diff changeset
632 Xrender is available at runtime. If it is available there
6399178be313 Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4572
diff changeset
633 can be no BadMatch error since Xrender takes care of that.
6399178be313 Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4572
diff changeset
634 */
4572
266ec93f49af Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4571
diff changeset
635 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
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
636 if (renderdata->use_xrender == SDL_FALSE) {
4572
266ec93f49af Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4571
diff changeset
637 if (texture->format != display->current_mode.format) {
266ec93f49af Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4571
diff changeset
638 SDL_SetError("Texture format doesn't match window format");
266ec93f49af Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4571
diff changeset
639 return -1;
266ec93f49af Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4571
diff changeset
640 }
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
641 } else {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
642 Uint32 Amask, Rmask, Gmask, Bmask;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
643 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
644 &Rmask, &Gmask, &Bmask, &Amask);
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
645 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
646 }
266ec93f49af Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4571
diff changeset
647 #else
4573
6399178be313 Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4572
diff changeset
648 /* The image/pixmap depth must be the same as the window or you
6399178be313 Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4572
diff changeset
649 get a BadMatch error when trying to putimage or copyarea.
6399178be313 Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4572
diff changeset
650 This BadMatch error
6399178be313 Completed work on X11_CreateTexture. Added lots of safety features.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4572
diff changeset
651 */
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
652 if (texture->format != display->current_mode.format) {
b801df19835f The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents: 2868
diff changeset
653 SDL_SetError("Texture format doesn't match window format");
b801df19835f The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents: 2868
diff changeset
654 return -1;
b801df19835f The X11 window and all pixmaps and images share the same visual and depth.
Sam Lantinga <slouken@libsdl.org>
parents: 2868
diff changeset
655 }
4572
266ec93f49af Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4571
diff changeset
656 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
657 data->format = texture->format;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658 }
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
659 data->pitch = texture->w * SDL_BYTESPERPIXEL(data->format);
2916
ffdd533f7add Fixed pitch alignment problem causing MITSHM error on 16-bit displays
Sam Lantinga <slouken@libsdl.org>
parents: 2901
diff changeset
660 data->pitch = (data->pitch + pitch_alignmask) & ~pitch_alignmask;
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
661
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
662 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
663 #ifndef NO_SHARED_MEMORY
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
664 XShmSegmentInfo *shminfo = &data->shminfo;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
665
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
666 shm_error = True;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
667
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
668 if (SDL_X11_HAVE_SHM) {
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
669 shminfo->shmid =
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
670 shmget(IPC_PRIVATE, texture->h * data->pitch,
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
671 IPC_CREAT | 0777);
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
672 if (shminfo->shmid >= 0) {
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
673 shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0);
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
674 shminfo->readOnly = False;
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
675 if (shminfo->shmaddr != (char *) -1) {
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
676 shm_error = False;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
677 X_handler = XSetErrorHandler(shm_errhandler);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
678 XShmAttach(renderdata->display, shminfo);
3239
ab5aebd50add Fix suggested by Bob
Sam Lantinga <slouken@libsdl.org>
parents: 3066
diff changeset
679 XSync(renderdata->display, False);
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
680 XSetErrorHandler(X_handler);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
681 if (shm_error) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
682 shmdt(shminfo->shmaddr);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
683 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
685 shmctl(shminfo->shmid, IPC_RMID, NULL);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
686 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
687 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
688 if (!shm_error) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
689 data->pixels = shminfo->shmaddr;
4587
25391ccf16a0 Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4586
diff changeset
690 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
691 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
692 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
693 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
694 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
695 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
696 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
697 }
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
698 data->image =
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
699 XShmCreateImage(renderdata->display, data->visual,
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
700 data->depth, ZPixmap, shminfo->shmaddr,
2874
Sam Lantinga <slouken@libsdl.org>
parents: 2870
diff changeset
701 shminfo, texture->w, texture->h);
4580
cfea5b007bc7 Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4579
diff changeset
702
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
703 if (!data->image) {
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
704 XShmDetach(renderdata->display, shminfo);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
705 XSync(renderdata->display, False);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
706 shmdt(shminfo->shmaddr);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
707 shm_error = True;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
708 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
709 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
710 if (shm_error) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
711 shminfo->shmaddr = NULL;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
712 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
713 if (!data->image)
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
714 #endif /* not NO_SHARED_MEMORY */
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
715 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
716 data->pixels = SDL_malloc(texture->h * data->pitch);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
717 if (!data->pixels) {
2868
3b595278f813 Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
718 X11_DestroyTexture(renderer, texture);
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
719 SDL_OutOfMemory();
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
720 return -1;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
721 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
722
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
723 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
724 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
725 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
726 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
727 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
728 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
729 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
730 }
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
731 data->image =
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
732 XCreateImage(renderdata->display, data->visual,
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
733 data->depth, ZPixmap, 0, data->pixels,
2874
Sam Lantinga <slouken@libsdl.org>
parents: 2870
diff changeset
734 texture->w, texture->h,
Sam Lantinga <slouken@libsdl.org>
parents: 2870
diff changeset
735 SDL_BYTESPERPIXEL(data->format) * 8,
Sam Lantinga <slouken@libsdl.org>
parents: 2870
diff changeset
736 data->pitch);
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
737 if (!data->image) {
2868
3b595278f813 Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
738 X11_DestroyTexture(renderer, texture);
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
739 SDL_SetError("XCreateImage() failed");
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
740 return -1;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
741 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
742 }
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
743 }
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
744 else {
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
745 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
746 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
747 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
748 if (data->pixmap == None) {
2868
3b595278f813 Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
749 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
750 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
751 return -1;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
752 }
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
753 data->image =
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
754 XCreateImage(renderdata->display, data->visual,
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
755 data->depth, ZPixmap, 0, NULL,
4580
cfea5b007bc7 Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4579
diff changeset
756 texture->w, texture->h,
cfea5b007bc7 Fix the rendering color channels to be premultiplied with the alpha channel as thats what Xrender expects. Small fixes in X11_CreateTexture. Add some new functions in SDL_x11sym.h as well as support for Xrender.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4579
diff changeset
757 SDL_BYTESPERPIXEL(data->format) * 8,
2874
Sam Lantinga <slouken@libsdl.org>
parents: 2870
diff changeset
758 data->pitch);
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
759 if (!data->image) {
2868
3b595278f813 Fixed BadMatch error in X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
760 X11_DestroyTexture(renderer, texture);
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
761 SDL_SetError("XCreateImage() failed");
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
762 return -1;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
763 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
764 }
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
765 #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
766 if(renderdata->use_xrender) {
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
767 gcv.graphics_exposures = False;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
768 data->gc =
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
769 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
770 if (!data->gc) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
771 SDL_SetError("XCreateGC() failed");
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
772 return -1;
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 data->picture_fmt =
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
775 PixelFormatEnumToXRenderPictFormat(renderer, texture->format);
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
776 if (data->picture_fmt == NULL) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
777 X11_DestroyTexture(renderer, texture);
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
778 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
779 return -1;
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
780 }
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
781 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
782 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
783 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
784 if (!data->picture) {
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
785 X11_DestroyTexture(renderer, texture);
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
786 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
787 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
788 }
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
789 }
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
790 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
791 return 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
792 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
793
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
794 static int
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
795 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
796 void **pixels, int *pitch)
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
797 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
798 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
799
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
800 if (data->yuv) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
801 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
802 } else {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
803 *pixels = data->pixels;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
804 *pitch = data->pitch;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
805 return 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
806 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
807 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
808
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
809 static int
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
810 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
811 {
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
812 X11_TextureData *data = (X11_TextureData *) texture->driverdata;
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
813 switch (texture->blendMode) {
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
814 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
815 #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
816 data->blend_op = PictOpSrc;
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
817 return 0;
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
818 case SDL_BLENDMODE_BLEND:
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
819 data->blend_op = PictOpOver;
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
820 return 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
821 case SDL_BLENDMODE_ADD:
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
822 data->blend_op = PictOpAdd;
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
823 return 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
824 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
825 default:
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
826 SDL_Unsupported();
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
827 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
828 #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
829 texture->blendMode = SDL_BLENDMODE_BLEND;
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
830 data->blend_op = PictOpOver;
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
831 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
832 return -1;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
833 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
834 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
835
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
836 static int
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
837 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
838 {
2828
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
839 X11_TextureData *data = (X11_TextureData *) texture->driverdata;
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
840
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
841 switch (texture->scaleMode) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
842 case SDL_TEXTURESCALEMODE_NONE:
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
843 return 0;
2828
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
844 case SDL_TEXTURESCALEMODE_FAST:
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
845 /* 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
846 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
847 return 0;
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
848 }
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
849 /* 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
850 default:
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
851 SDL_Unsupported();
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
852 texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
853 return -1;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
854 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
855 return 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
856 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
857
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
858 static int
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
859 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
860 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
861 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
862 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
863
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
864 if (data->yuv) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
865 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
866 return -1;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
867 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
868 UpdateYUVTextureData(texture);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
869 return 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
870 } else {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
871 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
872
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
873 if (data->pixels) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
874 Uint8 *src, *dst;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
875 int row;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
876 size_t length;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
877
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
878 src = (Uint8 *) pixels;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
879 dst =
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
880 (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
881 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
882 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
883 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
884 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
885 src += pitch;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
886 dst += data->pitch;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
887 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
888 } else {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
889 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
890 data->image->height = rect->h;
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
891 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
892 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
893 XPutImage(renderdata->display, data->pixmap, data->gc,
2814
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
894 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
895 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
896 return 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
897 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
898 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
899
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
900 static int
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
901 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
902 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
903 int *pitch)
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
904 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
905 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
906
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
907 if (data->yuv) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
908 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
909 pitch);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
910 } else if (data->pixels) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
911 *pixels =
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
912 (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
913 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
914 *pitch = data->pitch;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
915 return 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
916 } else {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
917 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
918 return -1;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
919 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
920 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
921
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
922 static void
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
923 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
924 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
925 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
926
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
927 if (data->yuv) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
928 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
929 UpdateYUVTextureData(texture);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
930 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
931 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
932
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
933 static int
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
934 X11_SetDrawBlendMode(SDL_Renderer * renderer)
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
935 {
4588
0ddd78496d68 Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4587
diff changeset
936 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
937 switch (renderer->blendMode) {
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
938 case SDL_BLENDMODE_NONE:
4588
0ddd78496d68 Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4587
diff changeset
939 #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
940 //PictOpSrc
4588
0ddd78496d68 Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4587
diff changeset
941 data->blend_op = PictOpSrc;
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
942 return 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
943 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
944 data->blend_op = PictOpOver;
4588
0ddd78496d68 Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4587
diff changeset
945 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
946 case SDL_BLENDMODE_ADD: // PictOpAdd
4588
0ddd78496d68 Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4587
diff changeset
947 data->blend_op = PictOpAdd;
0ddd78496d68 Preliminary support for blending modes on drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4587
diff changeset
948 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
949 /* 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
950 #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
951 return 0;
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
952 default:
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
953 SDL_Unsupported();
4589
8d8a889530eb Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4588
diff changeset
954 #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
955 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
956 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
957 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
958 }
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
959 else
4589
8d8a889530eb Fix blending modes for primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4588
diff changeset
960 #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
961 {
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
962 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
963 }
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
964 return -1;
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
965 }
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
966 }
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
967
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
968 static Uint32
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
969 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
970 {
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
971 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
972 Uint8 r = renderer->r;
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
973 Uint8 g = renderer->g;
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
974 Uint8 b = renderer->b;
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
975 Uint8 a = renderer->a;
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
976 if (premult)
2967
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
977 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
978 ((int) g * (int) a) / 255,
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
979 ((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
980 else
2967
e4a469d6ddab Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
981 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
982 }
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
983
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
984 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
985 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
986 {
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
987 // 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
988 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
989 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
990 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
991 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
992 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
993 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
994
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
995 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
996
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
997 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
998 (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
999 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
1000 (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
1001 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
1002 (unsigned short) ((renderer->b / 255.0) * alphad * 0xFFFF);
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
1003 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
1004 }
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
1005
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
1006 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
1007 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
1008 int count)
2901
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2894
diff changeset
1009 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2894
diff changeset
1010 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
1011 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
1012 XPoint *xpoints, *xpoint;
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1013 int i, xcount;
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1014 SDL_Rect clip, rect;
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1015 /*Damage damage;
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1016 XserverRegion parts;*/
2901
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2894
diff changeset
1017
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1018 clip.x = 0;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1019 clip.y = 0;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1020 clip.w = window->w;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1021 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
1022 if (data->makedirty) {
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1023
4598
66e13a224bd6 Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4597
diff changeset
1024 /* 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
1025 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
1026 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
1027 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
1028 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
1029 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
1030 /* 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
1031 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
1032 }
66e13a224bd6 Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4597
diff changeset
1033 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
1034 }
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1035 {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1036 xpoint = xpoints = SDL_stack_alloc(XPoint, count);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1037 xcount = 0;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1038 for (i = 0; i < count; ++i) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1039 int x = points[i].x;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1040 int y = points[i].y;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1041 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
1042 continue;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1043 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1044 xpoint->x = (short)x;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1045 xpoint->y = (short)y;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1046 ++xpoint;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1047 ++xcount;
3538
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1048 }
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1049
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1050 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1051 if (data->use_xrender) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1052 XSetForeground(data->display, data->stencil_gc, 0x00);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1053 XFixesSetGCClipRegion(data->display, data->stencil_gc, 0, 0, data->stencil_parts);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1054 XFillRectangle(data->display, data->stencil, data->stencil_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
1055 rect.x, rect.y, rect.w, rect.h);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1056 XFixesSetGCClipRegion(data->display, data->stencil_gc, 0, 0, None);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1057 XSetForeground(data->display, data->stencil_gc, 0xFF);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1058 /*damage =
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1059 XDamageCreate(data->display, data->stencil, XDamageReportRawRectangles);*/
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1060 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
1061 CoordModeOrigin);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1062 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1063 }
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1064 #endif
3538
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1065 }
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1066
4585
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1067 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1068 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
1069 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
1070 foreground = xrenderdrawcolor(renderer);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1071 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict,
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1072 &foreground, 0, 0, 1, 1);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1073 XFixesSetPictureClipRegion(data->display, data->drawable_pict, 0, 0, data->stencil_parts);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1074 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
1075 data->stencil_pict, data->drawable_pict,
4598
66e13a224bd6 Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4597
diff changeset
1076 rect.x, rect.y, rect.x, rect.y, rect.x, rect.y, rect.w, rect.h);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1077 XFixesSetPictureClipRegion(data->display, data->drawable_pict, 0, 0, None);
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1078 //XDamageDestroy(data->display, damage);
4585
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1079 }
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1080 else
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1081 #endif
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1082 {
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1083 unsigned long foreground = renderdrawcolor(renderer, 1);
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1084 XSetForeground(data->display, data->gc, foreground);
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1085
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1086
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1087 if (xcount > 0) {
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1088 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
1089 CoordModeOrigin);
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1090 }
3538
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1091 }
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1092
3538
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1093 SDL_stack_free(xpoints);
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1094
2894
e80f347b6d29 Added missing return
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
1095 return 0;
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
1096 }
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
1097
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2882
diff changeset
1098 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
1099 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
1100 int count)
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1101 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1102 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
1103 SDL_Window *window = renderer->window;
4458
c9584df65367 Removed unused variables
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1104 SDL_Rect clip;
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1105 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
1106 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
1107 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
1108 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
1109 int maxx, maxy;
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1110 XserverRegion parts;
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1111 Damage damage;
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1112
3538
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1113 clip.x = 0;
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1114 clip.y = 0;
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1115 clip.w = window->w;
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1116 clip.h = window->h;
4585
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1117 {
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1118 Pixmap drawable;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1119 GC gc;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1120 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1121 if (data->use_xrender) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1122 drawable = data->stencil;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1123 gc = data->stencil_gc;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1124 XSetForeground(data->display, data->stencil_gc, 0x00);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1125 XFixesSetGCClipRegion(data->display, data->stencil_gc, 0, 0, data->stencil_parts);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1126 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
1127 0, 0, window->w, window->h);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1128 XFixesSetGCClipRegion(data->display, data->stencil_gc, 0, 0, None);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1129 XSetForeground(data->display, data->stencil_gc, 0xFF);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1130 /*damage =
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1131 XDamageCreate(data->display, data->stencil, XDamageReportRawRectangles);*/
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1132 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1133 else
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1134 #endif
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1135 {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1136 drawable = data->drawable;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1137 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
1138 }
c2154674c0c1 Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents: 3538
diff changeset
1139
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1140 foreground = renderdrawcolor(renderer, 1);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1141 XSetForeground(data->display, data->gc, foreground);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1142
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1143 xpoint = xpoints = SDL_stack_alloc(XPoint, count);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1144 xcount = 0;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1145 minx = INT_MAX;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1146 miny = INT_MAX;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1147 maxx = INT_MIN;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1148 maxy = INT_MIN;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1149 for (i = 0; i < count; ++i) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1150 int x = points[i].x;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1151 int y = points[i].y;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1152
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1153 /* 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
1154 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
1155 if (x < minx) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1156 minx = x;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1157 } else if (x > maxx) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1158 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
1159 }
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1160 if (y < miny) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1161 miny = y;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1162 } else if (y > maxy) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1163 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
1164 }
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1165 xpoint->x = (short)x;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1166 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
1167 ++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
1168 ++xcount;
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1169 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
1170 }
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1171
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1172 /* 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
1173 if (xcount > 0) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1174 int x1 = xpoint[-1].x;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1175 int y1 = xpoint[-1].y;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1176 int x2 = x;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1177 int y2 = y;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1178 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
1179 if (x2 < minx) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1180 minx = x2;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1181 } else if (x2 > maxx) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1182 maxx = x2;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1183 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1184 if (y2 < miny) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1185 miny = y2;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1186 } else if (y2 > maxy) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1187 maxy = y2;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1188 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1189 xpoint->x = (short)x2;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1190 xpoint->y = (short)y2;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1191 ++xpoint;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1192 ++xcount;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1193 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1194 XDrawLines(data->display, drawable, gc,
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1195 xpoints, xcount, CoordModeOrigin);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1196 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
1197 XDrawPoint(data->display, drawable, gc, x2, y2);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1198 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1199 if (data->makedirty) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1200 SDL_Rect rect;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1201
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1202 rect.x = minx;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1203 rect.y = miny;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1204 rect.w = (maxx - minx) + 1;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1205 rect.h = (maxy - miny) + 1;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1206 SDL_AddDirtyRect(&data->dirty, &rect);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1207 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1208 xpoint = xpoints;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1209 xcount = 0;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1210 minx = INT_MAX;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1211 miny = INT_MAX;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1212 maxx = INT_MIN;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1213 maxy = INT_MIN;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1214 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1215 if (i < (count-1)) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1216 int x1 = x;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1217 int y1 = y;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1218 int x2 = points[i+1].x;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1219 int y2 = points[i+1].y;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1220 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
1221 if (x1 < minx) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1222 minx = x1;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1223 } else if (x1 > maxx) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1224 maxx = x1;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1225 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1226 if (y1 < miny) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1227 miny = y1;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1228 } else if (y1 > maxy) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1229 maxy = y1;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1230 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1231 xpoint->x = (short)x1;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1232 xpoint->y = (short)y1;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1233 ++xpoint;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1234 ++xcount;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1235 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1236 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1237 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1238 if (xcount > 1) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1239 int x2 = xpoint[-1].x;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1240 int y2 = xpoint[-1].y;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1241 XDrawLines(data->display, drawable, gc, xpoints, xcount,
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1242 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
1243 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
1244 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
1245 }
c2154674c0c1 Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents: 3538
diff changeset
1246 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
1247 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
1248
c2154674c0c1 Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents: 3538
diff changeset
1249 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
1250 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
1251 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
1252 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
1253 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
1254 }
c2154674c0c1 Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents: 3538
diff changeset
1255 }
c2154674c0c1 Fixed X11 line implementation - clip lines that are going to go outside the window.
Sam Lantinga <slouken@libsdl.org>
parents: 3538
diff changeset
1256 }
4585
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1257 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1258 if (data->use_xrender) {
4585
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1259 XRenderColor xrforeground = xrenderdrawcolor(renderer);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1260 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict,
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1261 &xrforeground, 0, 0, 1, 1);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1262 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts);
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1263 XFixesSetPictureClipRegion(data->display, data->drawable_pict, 0, 0, data->stencil_parts);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1264 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
1265 data->stencil_pict, data->drawable_pict,
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1266 0, 0, 0, 0, 0, 0, window->w, window->h);
4602
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1267 XFixesSetPictureClipRegion(data->display, data->drawable_pict, 0, 0, None);
4fbf64d504cf Use XDamage to optimise drawing operations.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4600
diff changeset
1268 //XDamageDestroy(data->display, damage);
4585
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1269 }
21600c6d6445 X11_RenderDrawLines and X11_RenderDrawPoints use XRender now.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4584
diff changeset
1270 #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
1271 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
1272
3538
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1273 return 0;
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1274 }
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1275
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1276 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
1277 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
1278 {
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
1279 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
1280 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
1281 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
1282 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
1283 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
1284 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
1285 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
1286
1ad70fb49fcb Fix so many things that there is little place in this column to list them all but the result is that blending modes just work now for drawing primitives.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4589
diff changeset
1287 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
1288 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
1289 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
1290 clip.h = window->h;
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1291 {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1292
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1293 for (i = 0; i < count; ++i) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1294 if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1295 continue;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1296 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1297
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1298 xrect->x = (short)rect.x;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1299 xrect->y = (short)rect.y;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1300 xrect->width = (unsigned short)rect.w;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1301 xrect->height = (unsigned short)rect.h;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1302 ++xrect;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1303 ++xcount;
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1304
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1305 if (data->makedirty) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1306 SDL_AddDirtyRect(&data->dirty, &rect);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1307 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1308 }
4598
66e13a224bd6 Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4597
diff changeset
1309 /*
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1310 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1311 if (data->use_xrender) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1312 XSetForeground(data->display, data->stencil_gc, 0x00);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1313 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
1314 0, 0, window->w, window->h);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1315 XSetForeground(data->display, data->stencil_gc, 0xFF);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1316
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1317 XDrawRectangles(data->display, data->stencil, data->stencil_gc, xrects, xcount);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1318 }
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1319 #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
1320 */
66e13a224bd6 Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4597
diff changeset
1321 }
66e13a224bd6 Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4597
diff changeset
1322 /*
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1323 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1324 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
1325 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
1326 foreground = xrenderdrawcolor(renderer);
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1327
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1328 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict,
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1329 &foreground, 0, 0, 1, 1);
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1330 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
1331 data->stencil_pict, data->drawable_pict,
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1332 0, 0, 0, 0, 0, 0, window->w, window->h);
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
1333 }
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
1334 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
1335 #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
1336 */
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
1337 {
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
1338 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
1339
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
1340 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
1341 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
1342
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
1343 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
1344 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
1345 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
1346 }
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3559
diff changeset
1347 }
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
1348 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
1349
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
1350 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
1351 }
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
1352
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
1353 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
1354 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
1355 {
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1356 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
1357 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
1358 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
1359
3538
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1360 clip.x = 0;
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1361 clip.y = 0;
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1362 clip.w = window->w;
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1363 clip.h = window->h;
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1364
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
1365 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
1366 XRectangle *xrects, *xrect;
3538
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1367 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
1368 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
1369 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
1370 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
1371 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
1372 }
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
1373
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
1374 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
1375 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
1376 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
1377 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
1378 ++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
1379 ++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
1380
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
1381 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
1382 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
1383 }
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
1384 }
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
1385
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
1386 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1387 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
1388 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
1389 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
1390 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
1391 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
1392 &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
1393 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
1394 }
66e13a224bd6 Major changes to drawing. Reverted back to core X11 functions due to regressions.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4597
diff changeset
1395 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
1396 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
1397 &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
1398 }
3538
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1399 }
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
1400 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
1401 #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
1402 {
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
1403 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
1404
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
1405 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
1406 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
1407
3538
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1408 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
1409 xrects, xcount);
a1896642a47e X11 driver compiles again, lines are not yet implemented
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
1410 }
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
1411
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
1412 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
1413 return 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1414 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1415
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1416 static int
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1417 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
1418 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
1419 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1420 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
1421 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
1422
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1423 if (data->makedirty) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1424 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
1425 }
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
1426 #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
1427 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
1428 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
1429 #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
1430 if(texturedata->shminfo.shmaddr) {
25391ccf16a0 Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4586
diff changeset
1431 XShmPutImage(data->display, texturedata->pixmap, data->gc,
25391ccf16a0 Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4586
diff changeset
1432 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
1433 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
1434 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
1435 }
25391ccf16a0 Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4586
diff changeset
1436 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
1437 #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
1438 if (texturedata->pixels) {
25391ccf16a0 Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4586
diff changeset
1439 XPutImage(data->display, texturedata->pixmap, data->gc,
25391ccf16a0 Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4586
diff changeset
1440 texturedata->image, srcrect->x, srcrect->y, dstrect->x,
25391ccf16a0 Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4586
diff changeset
1441 dstrect->y, srcrect->w, srcrect->h);
25391ccf16a0 Texture rendering mostly works now. Even SDL_TEXTUREACCESS_STREAMING is supported now with a little overhead. Scaling of textures happens using XRender. :D
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4586
diff changeset
1442 }
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
1443 }
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
1444 Picture 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
1445 if(texture->blendMode == SDL_BLENDMODE_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
1446 pict = 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
1447 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
1448 pict = texturedata->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
1449 if(srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
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
1450 XRenderComposite(data->display, texturedata->blend_op, texturedata->picture,
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
1451 pict, data->drawable_pict, srcrect->x, srcrect->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
1452 srcrect->x, srcrect->y, dstrect->x, dstrect->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
1453 srcrect->w, srcrect->h);
2828
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
1454 } 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
1455 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
1456 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
1457 XTransform xform = {{
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
1458 {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
1459 {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
1460 {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
1461 XRenderSetPictureTransform(data->display, texturedata->picture, &xform);
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
1462
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
1463 XRenderComposite(data->display, texturedata->blend_op,
4595
73eeadf7ed8e Fixed a minor bug with texture blending.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4594
diff changeset
1464 texturedata->picture, pict, data->drawable_pict,
4593
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
1465 0, 0, 0, 0, dstrect->x, dstrect->y,
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
1466 dstrect->w, dstrect->h);
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
1467
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
1468 XTransform identity = {{
3892fe2f6537 Fixed so many things. See the changelog listed below.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4591
diff changeset
1469 {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
1470 {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
1471 {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
1472 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
1473 }
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
1474 }
e479c1e57c52 SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4585
diff changeset
1475 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
1476 #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
1477 {
e479c1e57c52 SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4585
diff changeset
1478 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
1479 #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
1480 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
1481 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
1482 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
1483 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
1484 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
1485 } 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
1486 #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
1487 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
1488 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
1489 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
1490 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
1491 } 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
1492 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
1493 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
1494 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
1495 }
e479c1e57c52 SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4585
diff changeset
1496 } 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
1497 || 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
1498 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
1499 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
1500 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
1501 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
1502
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
1503 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
1504 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
1505 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
1506
e479c1e57c52 SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4585
diff changeset
1507 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
1508 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
1509 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
1510 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
1511 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
1512 }
2828
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
1513
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
1514 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
1515 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
1516 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
1517 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
1518 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
1519 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
1520 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
1521 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
1522 }
e479c1e57c52 SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4585
diff changeset
1523 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
1524
e479c1e57c52 SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4585
diff changeset
1525 } 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
1526 || !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
1527 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
1528 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
1529 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
1530 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
1531 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
1532 (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
1533 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
1534 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
1535 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
1536 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
1537 }
2828
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
1538 }
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
1539
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
1540 /* 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
1541 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
1542 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
1543 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
1544 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
1545 #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
1546 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
1547 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
1548 } 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
1549 #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
1550 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
1551 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
1552
e479c1e57c52 SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4585
diff changeset
1553 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
1554 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
1555 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
1556 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
1557 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
1558 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
1559
e479c1e57c52 SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4585
diff changeset
1560 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
1561
e479c1e57c52 SDL_Textures should work with XRender now provided that the texture format and screen format match. This is only a temporary limitation.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4585
diff changeset
1562 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
1563 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
1564 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
1565 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
1566 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
1567 return -1;
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
1568 }
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
1569 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
1570 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
1571 } 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
1572 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
1573 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
1574 srcrect->x, srcrect->y);
2828
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
1575 }
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1576 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1577 return 0;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1578 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1579
3559
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1580 static int
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1581 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
1582 Uint32 format, void * pixels, int pitch)
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1583 {
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1584 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
1585 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
1586 SDL_VideoDisplay *display = window->display;
3559
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1587 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
1588 XImage *image;
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1589
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1590 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
1591 rect->w, rect->h, AllPlanes, ZPixmap);
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1592
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1593 SDL_ConvertPixels(rect->w, rect->h,
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1594 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
1595 format, pixels, pitch);
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1596
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1597 XDestroyImage(image);
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1598 return 0;
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1599 }
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1600
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1601 static int
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1602 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
1603 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
1604 {
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1605 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
1606 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
1607 SDL_VideoDisplay *display = window->display;
3559
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1608 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
1609 XImage *image;
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1610 void *image_pixels;
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1611 int image_pitch;
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1612
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1613 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
1614 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
1615 if (!image_pixels) {
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1616 SDL_OutOfMemory();
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1617 return -1;
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1618 }
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1619
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1620 image = XCreateImage(data->display, data->visual,
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1621 data->depth, ZPixmap, 0, image_pixels,
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1622 rect->w, rect->h,
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1623 SDL_BYTESPERPIXEL(screen_format) * 8,
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1624 image_pitch);
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1625 if (!image) {
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1626 SDL_SetError("XCreateImage() failed");
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1627 return -1;
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1628 }
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1629
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1630 SDL_ConvertPixels(rect->w, rect->h,
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1631 format, pixels, pitch,
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1632 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
1633
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1634 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
1635 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
1636
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1637 image->data = NULL;
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1638 XDestroyImage(image);
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1639
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1640 SDL_free(image_pixels);
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1641 return 0;
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1642 }
5f26a7eb5ff0 Implemented read/write pixels for the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 3543
diff changeset
1643
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1644 static void
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1645 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
1646 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1647 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
1648 SDL_DirtyRect *dirty;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1649
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1650 /* 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
1651 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
1652 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
1653 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
1654 #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
1655 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
1656 {
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
1657 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
1658 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
1659 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
1660 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
1661 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
1662 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
1663 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
1664 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
1665 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
1666 }
d490d63bcc5e X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4578
diff changeset
1667 else
d490d63bcc5e X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4578
diff changeset
1668 #endif
d490d63bcc5e X11_RenderPresent now uses XRender to blit back-buffers to the screen.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4578
diff changeset
1669 {
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
1670 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
1671 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
1672 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
1673 }
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1674 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1675 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
1676 }
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1677 XSync(data->display, False);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1678
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1679 /* 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
1680 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
1681 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
1682 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
1683 #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
1684 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
1685 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1686 } 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
1687 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
1688 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
1689 #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
1690 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
1691 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1692 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1693 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1694
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1695 static void
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1696 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
1697 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1698 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
1699 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
1700
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1701 if (!data) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1702 return;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1703 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1704 if (data->yuv) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1705 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
1706 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1707 if (data->pixmap != None) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1708 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
1709 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1710 if (data->image) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1711 data->image->data = NULL;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1712 XDestroyImage(data->image);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1713 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1714 #ifndef NO_SHARED_MEMORY
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1715 if (data->shminfo.shmaddr) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1716 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
1717 XSync(renderdata->display, False);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1718 shmdt(data->shminfo.shmaddr);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1719 data->pixels = NULL;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1720 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1721 #endif
2828
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
1722 if (data->scaling_image) {
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
1723 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
1724 data->scaling_image->data = NULL;
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
1725 XDestroyImage(data->scaling_image);
7e5ff6cd05bf Added very slow software scaling to the X11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2827
diff changeset
1726 }
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1727 if (data->pixels) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1728 SDL_free(data->pixels);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1729 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1730 SDL_free(data);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1731 texture->driverdata = NULL;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1732 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1733
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1734 static void
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1735 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
1736 {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1737 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
1738 int i;
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1739
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1740 if (data) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1741 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
1742 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
1743 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
1744 }
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
1745 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
9907c8cc6015 X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4583
diff changeset
1746 if (data->pixmap_picts[i] != None) {
9907c8cc6015 X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4583
diff changeset
1747 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
1748 }
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
1749 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1750 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1751 if (data->gc) {
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1752 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
1753 }
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
1754 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1755 if (data->stencil_gc) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1756 XFreeGC(data->display, data->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
1757 }
4597
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1758 if (data->stencil) {
95be206b3cb7 Start experimental branch for client-side rasterization.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4596
diff changeset
1759 XFreePixmap(data->display, data->stencil);
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
1760 }
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
1761 if (data->drawable_pict) {
9907c8cc6015 X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4583
diff changeset
1762 XRenderFreePicture(data->display, data->drawable_pict);
9907c8cc6015 X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4583
diff changeset
1763 }
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
1764 if (data->xwindow_pict) {
9907c8cc6015 X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4583
diff changeset
1765 XRenderFreePicture(data->display, data->xwindow_pict);
9907c8cc6015 X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
Sunny Sachanandani <sunnysachanandani@gmail.com>
parents: 4583
diff changeset
1766 }
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
1767 #endif
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1768 SDL_FreeDirtyRects(&data->dirty);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1769 SDL_free(data);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1770 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1771 SDL_free(renderer);
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1772 }
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1773
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1774 #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
1775
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1776 /* vi: set ts=4 sw=4 expandtab: */