blob: a51c591f22639983e02c61c28b4a8bdb5a342b7f [file] [log] [blame]
Nicolas Capens68a82382018-10-02 13:16:55 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef libX11_hpp
16#define libX11_hpp
17
18#define Bool int
19#include <X11/Xlib.h>
20#include <X11/Xutil.h>
21#include <X11/extensions/XShm.h>
22
23struct LibX11exports
24{
25 LibX11exports(void *libX11, void *libXext);
26
27 Display *(*XOpenDisplay)(char *display_name);
28 Status (*XGetWindowAttributes)(Display *display, Window w, XWindowAttributes *window_attributes_return);
29 Screen *(*XDefaultScreenOfDisplay)(Display *display);
30 int (*XWidthOfScreen)(Screen *screen);
31 int (*XHeightOfScreen)(Screen *screen);
32 int (*XPlanesOfScreen)(Screen *screen);
Ben Clayton45c697a2019-12-17 20:38:03 +000033 GC(*XDefaultGC)
34 (Display *display, int screen_number);
Nicolas Capens68a82382018-10-02 13:16:55 -040035 int (*XDefaultDepth)(Display *display, int screen_number);
36 Status (*XMatchVisualInfo)(Display *display, int screen, int depth, int screen_class, XVisualInfo *vinfo_return);
37 Visual *(*XDefaultVisual)(Display *display, int screen_number);
Ben Clayton45c697a2019-12-17 20:38:03 +000038 int (*(*XSetErrorHandler)(int (*handler)(Display *, XErrorEvent *)))(Display *, XErrorEvent *);
Nicolas Capens68a82382018-10-02 13:16:55 -040039 int (*XSync)(Display *display, Bool discard);
40 XImage *(*XCreateImage)(Display *display, Visual *visual, unsigned int depth, int format, int offset, char *data, unsigned int width, unsigned int height, int bitmap_pad, int bytes_per_line);
41 int (*XCloseDisplay)(Display *display);
42 int (*XPutImage)(Display *display, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height);
43 int (*XDrawString)(Display *display, Drawable d, GC gc, int x, int y, char *string, int length);
44
45 Bool (*XShmQueryExtension)(Display *display);
46 XImage *(*XShmCreateImage)(Display *display, Visual *visual, unsigned int depth, int format, char *data, XShmSegmentInfo *shminfo, unsigned int width, unsigned int height);
47 Bool (*XShmAttach)(Display *display, XShmSegmentInfo *shminfo);
48 Bool (*XShmDetach)(Display *display, XShmSegmentInfo *shminfo);
49 int (*XShmPutImage)(Display *display, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height, bool send_event);
50};
51
Ben Clayton45c697a2019-12-17 20:38:03 +000052#undef Bool // b/127920555
Nicolas Capens68a82382018-10-02 13:16:55 -040053
54class LibX11
55{
56public:
57 operator bool()
58 {
59 return loadExports();
60 }
61
62 LibX11exports *operator->();
63
64private:
65 LibX11exports *loadExports();
66};
67
68extern LibX11 libX11;
69
Ben Clayton45c697a2019-12-17 20:38:03 +000070#endif // libX11_hpp