MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / fbxv_init

Function fbxv_init

util/fbxv.c:94–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92
93
94int fbxv_init(fbxv_struct *fb, Display *dpy, Window win, int width_,
95 int height_, int format, int useShm)
96{
97 int width, height, k, shmok = 1, nformats;
98 unsigned int dummy1, dummy2, dummy3, dummy4, dummy5, i, j, nadaptors = 0;
99 XWindowAttributes xwa;
100 XvAdaptorInfo *ai = NULL;
101 XvImageFormatValues *ifv = NULL;
102
103 if(!fb) THROW("Invalid argument");
104
105 if(!dpy || !win) THROW("Invalid argument");
106 ERRIFNOT(XGetWindowAttributes(dpy, win, &xwa));
107 if(width_ > 0) width = width_; else width = xwa.width;
108 if(height_ > 0) height = height_; else height = xwa.height;
109 if(fb->dpy == dpy && fb->win == win)
110 {
111 if(width == fb->reqwidth && height == fb->reqheight && fb->xvi && fb->xgc
112 && fb->xvi->data)
113 return 0;
114 else if(fbxv_term(fb) == -1) return -1;
115 }
116 memset(fb, 0, sizeof(fbxv_struct));
117 fb->dpy = dpy; fb->win = win;
118 fb->reqwidth = width; fb->reqheight = height;
119
120 if(XvQueryExtension(dpy, &dummy1, &dummy2, &dummy3, &dummy4, &dummy5)
121 != Success)
122 THROW("X Video Extension not available");
123 if(XvQueryAdaptors(dpy, DefaultRootWindow(dpy), &nadaptors, &ai) != Success)
124 THROW("Could not query X Video adaptors");
125 if(nadaptors < 1 || !ai) THROW("No X Video adaptors available");
126
127 fb->port = -1;
128 for(i = 0; i < nadaptors; i++)
129 {
130 for(j = ai[i].base_id; j < ai[i].base_id + ai[i].num_ports; j++)
131 {
132 nformats = 0;
133 ifv = XvListImageFormats(dpy, j, &nformats);
134 if(ifv && nformats > 0)
135 {
136 for(k = 0; k < nformats; k++)
137 {
138 if(ifv[k].id == format)
139 {
140 XFree(ifv); fb->port = j;
141 goto found;
142 }
143 }
144 }
145 XFree(ifv);
146 }
147 }
148 found:
149 XvFreeAdaptorInfo(ai); ai = NULL;
150 if(fb->port == -1)
151 THROW("The X Video implementation on the 2D X Server does not support the desired pixel format");

Callers 3

initMethod · 0.85
doTestFunction · 0.85
doInteractiveTestFunction · 0.85

Calls 2

fbxv_termFunction · 0.85
XFreeFunction · 0.85

Tested by 2

doTestFunction · 0.68
doInteractiveTestFunction · 0.68