21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_X11
29 #ifndef NO_SHARED_MEMORY
33 static int (*X_handler)(Display *, XErrorEvent *) =
NULL;
34 static int shm_errhandler(Display *
d, XErrorEvent *
e)
36 if (
e->error_code == BadAccess ) {
40 return(X_handler(
d,
e));
46 return X11_XShmQueryExtension(
dpy) ? SDL_X11_HAVE_SHM :
SDL_FALSE;
53 void **
pixels,
int *pitch)
64 gcv.graphics_exposures = False;
65 data->gc = X11_XCreateGC(display,
data->xwindow, GCGraphicsExposures, &gcv);
72 return SDL_SetError(
"Couldn't get window visual information");
84 #ifndef NO_SHARED_MEMORY
85 if (have_mitshm(display)) {
86 XShmSegmentInfo *shminfo = &
data->shminfo;
88 shminfo->shmid = shmget(IPC_PRIVATE,
window->h*(*pitch), IPC_CREAT | 0777);
89 if ( shminfo->shmid >= 0 ) {
90 shminfo->shmaddr = (
char *)shmat(shminfo->shmid, 0, 0);
91 shminfo->readOnly = False;
92 if ( shminfo->shmaddr != (
char *)-1 ) {
94 X_handler = X11_XSetErrorHandler(shm_errhandler);
95 X11_XShmAttach(display, shminfo);
96 X11_XSync(display, False);
97 X11_XSetErrorHandler(X_handler);
99 shmdt(shminfo->shmaddr);
103 shmctl(shminfo->shmid, IPC_RMID,
NULL);
108 data->ximage = X11_XShmCreateImage(display,
data->visual,
109 vinfo.depth, ZPixmap,
110 shminfo->shmaddr, shminfo,
113 X11_XShmDetach(display, shminfo);
114 X11_XSync(display, False);
115 shmdt(shminfo->shmaddr);
119 *
pixels = shminfo->shmaddr;
131 data->ximage = X11_XCreateImage(display,
data->visual,
132 vinfo.depth, ZPixmap, 0, (
char *)(*
pixels),
149 #ifndef NO_SHARED_MEMORY
151 for (
i = 0;
i < numrects; ++
i) {
157 if (
w <= 0 ||
h <= 0 || (
x +
w) <= 0 || (
y +
h) <= 0) {
176 X11_XShmPutImage(display,
data->xwindow,
data->gc,
data->ximage,
183 for (
i = 0;
i < numrects; ++
i) {
189 if (
w <= 0 ||
h <= 0 || (
x +
w) <= 0 || (
y +
h) <= 0) {
208 X11_XPutImage(display,
data->xwindow,
data->gc,
data->ximage,
213 X11_XSync(display, False);
229 display =
data->videodata->display;
232 XDestroyImage(
data->ximage);
234 #ifndef NO_SHARED_MEMORY
235 if (
data->use_mitshm) {
236 X11_XShmDetach(display, &
data->shminfo);
237 X11_XSync(display, False);
238 shmdt(
data->shminfo.shmaddr);
246 X11_XFreeGC(display,
data->gc);
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 * e
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
#define SDL_OutOfMemory()
GLint GLint GLint GLint GLint GLint y
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
#define SDL_BYTESPERPIXEL(X)
@ SDL_PIXELFORMAT_UNKNOWN
static SDL_VideoDevice * _this
void X11_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
int X11_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
int X11_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Uint32 X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo *vinfo)
int X11_GetVisualInfoFromVisual(Display *display, Visual *visual, XVisualInfo *vinfo)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display dpy)
EGLSurface EGLNativeWindowType * window
EGLSurface EGLint * rects
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
A rectangle, with the origin at the upper left (integer).
struct wl_display * display
struct SDL_VideoData * videodata
The type used to identify a window.
typedef int(__stdcall *FARPROC)()