| 1 |
|
| 2 |
package xf86dri |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
import ( |
| 7 |
"github.com/BurntSushi/xgb" |
| 8 |
|
| 9 |
"github.com/BurntSushi/xgb/xproto" |
| 10 |
) |
| 11 |
|
| 12 |
|
| 13 |
func Init(c *xgb.Conn) error { |
| 14 |
reply, err := xproto.QueryExtension(c, 11, "XFree86-DRI").Reply() |
| 15 |
switch { |
| 16 |
case err != nil: |
| 17 |
return err |
| 18 |
case !reply.Present: |
| 19 |
return xgb.Errorf("No extension named XFree86-DRI could be found on on the server.") |
| 20 |
} |
| 21 |
|
| 22 |
c.ExtLock.Lock() |
| 23 |
c.Extensions["XFree86-DRI"] = reply.MajorOpcode |
| 24 |
c.ExtLock.Unlock() |
| 25 |
for evNum, fun := range xgb.NewExtEventFuncs["XFree86-DRI"] { |
| 26 |
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun |
| 27 |
} |
| 28 |
for errNum, fun := range xgb.NewExtErrorFuncs["XFree86-DRI"] { |
| 29 |
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun |
| 30 |
} |
| 31 |
return nil |
| 32 |
} |
| 33 |
|
| 34 |
func init() { |
| 35 |
xgb.NewExtEventFuncs["XFree86-DRI"] = make(map[int]xgb.NewEventFun) |
| 36 |
xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun) |
| 37 |
} |
| 38 |
|
| 39 |
type DrmClipRect struct { |
| 40 |
X1 int16 |
| 41 |
Y1 int16 |
| 42 |
X2 int16 |
| 43 |
X3 int16 |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
func DrmClipRectRead(buf []byte, v *DrmClipRect) int { |
| 48 |
b := 0 |
| 49 |
|
| 50 |
v.X1 = int16(xgb.Get16(buf[b:])) |
| 51 |
b += 2 |
| 52 |
|
| 53 |
v.Y1 = int16(xgb.Get16(buf[b:])) |
| 54 |
b += 2 |
| 55 |
|
| 56 |
v.X2 = int16(xgb.Get16(buf[b:])) |
| 57 |
b += 2 |
| 58 |
|
| 59 |
v.X3 = int16(xgb.Get16(buf[b:])) |
| 60 |
b += 2 |
| 61 |
|
| 62 |
return b |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
func DrmClipRectReadList(buf []byte, dest []DrmClipRect) int { |
| 67 |
b := 0 |
| 68 |
for i := 0; i < len(dest); i++ { |
| 69 |
dest[i] = DrmClipRect{} |
| 70 |
b += DrmClipRectRead(buf[b:], &dest[i]) |
| 71 |
} |
| 72 |
return xgb.Pad(b) |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
func (v DrmClipRect) Bytes() []byte { |
| 77 |
buf := make([]byte, 8) |
| 78 |
b := 0 |
| 79 |
|
| 80 |
xgb.Put16(buf[b:], uint16(v.X1)) |
| 81 |
b += 2 |
| 82 |
|
| 83 |
xgb.Put16(buf[b:], uint16(v.Y1)) |
| 84 |
b += 2 |
| 85 |
|
| 86 |
xgb.Put16(buf[b:], uint16(v.X2)) |
| 87 |
b += 2 |
| 88 |
|
| 89 |
xgb.Put16(buf[b:], uint16(v.X3)) |
| 90 |
b += 2 |
| 91 |
|
| 92 |
return buf[:b] |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int { |
| 97 |
b := 0 |
| 98 |
var structBytes []byte |
| 99 |
for _, item := range list { |
| 100 |
structBytes = item.Bytes() |
| 101 |
copy(buf[b:], structBytes) |
| 102 |
b += len(structBytes) |
| 103 |
} |
| 104 |
return xgb.Pad(b) |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
type AuthConnectionCookie struct { |
| 133 |
*xgb.Cookie |
| 134 |
} |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { |
| 139 |
c.ExtLock.RLock() |
| 140 |
defer c.ExtLock.RUnlock() |
| 141 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 142 |
panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 143 |
} |
| 144 |
cookie := c.NewCookie(true, true) |
| 145 |
c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) |
| 146 |
return AuthConnectionCookie{cookie} |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
func AuthConnectionUnchecked(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie { |
| 152 |
c.ExtLock.RLock() |
| 153 |
defer c.ExtLock.RUnlock() |
| 154 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 155 |
panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 156 |
} |
| 157 |
cookie := c.NewCookie(false, true) |
| 158 |
c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie) |
| 159 |
return AuthConnectionCookie{cookie} |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
type AuthConnectionReply struct { |
| 164 |
Sequence uint16 |
| 165 |
Length uint32 |
| 166 |
|
| 167 |
Authenticated uint32 |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) { |
| 172 |
buf, err := cook.Cookie.Reply() |
| 173 |
if err != nil { |
| 174 |
return nil, err |
| 175 |
} |
| 176 |
if buf == nil { |
| 177 |
return nil, nil |
| 178 |
} |
| 179 |
return authConnectionReply(buf), nil |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
func authConnectionReply(buf []byte) *AuthConnectionReply { |
| 184 |
v := new(AuthConnectionReply) |
| 185 |
b := 1 |
| 186 |
|
| 187 |
b += 1 |
| 188 |
|
| 189 |
v.Sequence = xgb.Get16(buf[b:]) |
| 190 |
b += 2 |
| 191 |
|
| 192 |
v.Length = xgb.Get32(buf[b:]) |
| 193 |
b += 4 |
| 194 |
|
| 195 |
v.Authenticated = xgb.Get32(buf[b:]) |
| 196 |
b += 4 |
| 197 |
|
| 198 |
return v |
| 199 |
} |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte { |
| 204 |
size := 12 |
| 205 |
b := 0 |
| 206 |
buf := make([]byte, size) |
| 207 |
|
| 208 |
c.ExtLock.RLock() |
| 209 |
buf[b] = c.Extensions["XFree86-DRI"] |
| 210 |
c.ExtLock.RUnlock() |
| 211 |
b += 1 |
| 212 |
|
| 213 |
buf[b] = 11 |
| 214 |
b += 1 |
| 215 |
|
| 216 |
xgb.Put16(buf[b:], uint16(size/4)) |
| 217 |
b += 2 |
| 218 |
|
| 219 |
xgb.Put32(buf[b:], Screen) |
| 220 |
b += 4 |
| 221 |
|
| 222 |
xgb.Put32(buf[b:], Magic) |
| 223 |
b += 4 |
| 224 |
|
| 225 |
return buf |
| 226 |
} |
| 227 |
|
| 228 |
|
| 229 |
type CloseConnectionCookie struct { |
| 230 |
*xgb.Cookie |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie { |
| 236 |
c.ExtLock.RLock() |
| 237 |
defer c.ExtLock.RUnlock() |
| 238 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 239 |
panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 240 |
} |
| 241 |
cookie := c.NewCookie(false, false) |
| 242 |
c.NewRequest(closeConnectionRequest(c, Screen), cookie) |
| 243 |
return CloseConnectionCookie{cookie} |
| 244 |
} |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
func CloseConnectionChecked(c *xgb.Conn, Screen uint32) CloseConnectionCookie { |
| 249 |
c.ExtLock.RLock() |
| 250 |
defer c.ExtLock.RUnlock() |
| 251 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 252 |
panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 253 |
} |
| 254 |
cookie := c.NewCookie(true, false) |
| 255 |
c.NewRequest(closeConnectionRequest(c, Screen), cookie) |
| 256 |
return CloseConnectionCookie{cookie} |
| 257 |
} |
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
func (cook CloseConnectionCookie) Check() error { |
| 262 |
return cook.Cookie.Check() |
| 263 |
} |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte { |
| 268 |
size := 8 |
| 269 |
b := 0 |
| 270 |
buf := make([]byte, size) |
| 271 |
|
| 272 |
c.ExtLock.RLock() |
| 273 |
buf[b] = c.Extensions["XFree86-DRI"] |
| 274 |
c.ExtLock.RUnlock() |
| 275 |
b += 1 |
| 276 |
|
| 277 |
buf[b] = 3 |
| 278 |
b += 1 |
| 279 |
|
| 280 |
xgb.Put16(buf[b:], uint16(size/4)) |
| 281 |
b += 2 |
| 282 |
|
| 283 |
xgb.Put32(buf[b:], Screen) |
| 284 |
b += 4 |
| 285 |
|
| 286 |
return buf |
| 287 |
} |
| 288 |
|
| 289 |
|
| 290 |
type CreateContextCookie struct { |
| 291 |
*xgb.Cookie |
| 292 |
} |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { |
| 297 |
c.ExtLock.RLock() |
| 298 |
defer c.ExtLock.RUnlock() |
| 299 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 300 |
panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 301 |
} |
| 302 |
cookie := c.NewCookie(true, true) |
| 303 |
c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) |
| 304 |
return CreateContextCookie{cookie} |
| 305 |
} |
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie { |
| 310 |
c.ExtLock.RLock() |
| 311 |
defer c.ExtLock.RUnlock() |
| 312 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 313 |
panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 314 |
} |
| 315 |
cookie := c.NewCookie(false, true) |
| 316 |
c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie) |
| 317 |
return CreateContextCookie{cookie} |
| 318 |
} |
| 319 |
|
| 320 |
|
| 321 |
type CreateContextReply struct { |
| 322 |
Sequence uint16 |
| 323 |
Length uint32 |
| 324 |
|
| 325 |
HwContext uint32 |
| 326 |
} |
| 327 |
|
| 328 |
|
| 329 |
func (cook CreateContextCookie) Reply() (*CreateContextReply, error) { |
| 330 |
buf, err := cook.Cookie.Reply() |
| 331 |
if err != nil { |
| 332 |
return nil, err |
| 333 |
} |
| 334 |
if buf == nil { |
| 335 |
return nil, nil |
| 336 |
} |
| 337 |
return createContextReply(buf), nil |
| 338 |
} |
| 339 |
|
| 340 |
|
| 341 |
func createContextReply(buf []byte) *CreateContextReply { |
| 342 |
v := new(CreateContextReply) |
| 343 |
b := 1 |
| 344 |
|
| 345 |
b += 1 |
| 346 |
|
| 347 |
v.Sequence = xgb.Get16(buf[b:]) |
| 348 |
b += 2 |
| 349 |
|
| 350 |
v.Length = xgb.Get32(buf[b:]) |
| 351 |
b += 4 |
| 352 |
|
| 353 |
v.HwContext = xgb.Get32(buf[b:]) |
| 354 |
b += 4 |
| 355 |
|
| 356 |
return v |
| 357 |
} |
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) []byte { |
| 362 |
size := 16 |
| 363 |
b := 0 |
| 364 |
buf := make([]byte, size) |
| 365 |
|
| 366 |
c.ExtLock.RLock() |
| 367 |
buf[b] = c.Extensions["XFree86-DRI"] |
| 368 |
c.ExtLock.RUnlock() |
| 369 |
b += 1 |
| 370 |
|
| 371 |
buf[b] = 5 |
| 372 |
b += 1 |
| 373 |
|
| 374 |
xgb.Put16(buf[b:], uint16(size/4)) |
| 375 |
b += 2 |
| 376 |
|
| 377 |
xgb.Put32(buf[b:], Screen) |
| 378 |
b += 4 |
| 379 |
|
| 380 |
xgb.Put32(buf[b:], Visual) |
| 381 |
b += 4 |
| 382 |
|
| 383 |
xgb.Put32(buf[b:], Context) |
| 384 |
b += 4 |
| 385 |
|
| 386 |
return buf |
| 387 |
} |
| 388 |
|
| 389 |
|
| 390 |
type CreateDrawableCookie struct { |
| 391 |
*xgb.Cookie |
| 392 |
} |
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { |
| 397 |
c.ExtLock.RLock() |
| 398 |
defer c.ExtLock.RUnlock() |
| 399 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 400 |
panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 401 |
} |
| 402 |
cookie := c.NewCookie(true, true) |
| 403 |
c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) |
| 404 |
return CreateDrawableCookie{cookie} |
| 405 |
} |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie { |
| 410 |
c.ExtLock.RLock() |
| 411 |
defer c.ExtLock.RUnlock() |
| 412 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 413 |
panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 414 |
} |
| 415 |
cookie := c.NewCookie(false, true) |
| 416 |
c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie) |
| 417 |
return CreateDrawableCookie{cookie} |
| 418 |
} |
| 419 |
|
| 420 |
|
| 421 |
type CreateDrawableReply struct { |
| 422 |
Sequence uint16 |
| 423 |
Length uint32 |
| 424 |
|
| 425 |
HwDrawableHandle uint32 |
| 426 |
} |
| 427 |
|
| 428 |
|
| 429 |
func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) { |
| 430 |
buf, err := cook.Cookie.Reply() |
| 431 |
if err != nil { |
| 432 |
return nil, err |
| 433 |
} |
| 434 |
if buf == nil { |
| 435 |
return nil, nil |
| 436 |
} |
| 437 |
return createDrawableReply(buf), nil |
| 438 |
} |
| 439 |
|
| 440 |
|
| 441 |
func createDrawableReply(buf []byte) *CreateDrawableReply { |
| 442 |
v := new(CreateDrawableReply) |
| 443 |
b := 1 |
| 444 |
|
| 445 |
b += 1 |
| 446 |
|
| 447 |
v.Sequence = xgb.Get16(buf[b:]) |
| 448 |
b += 2 |
| 449 |
|
| 450 |
v.Length = xgb.Get32(buf[b:]) |
| 451 |
b += 4 |
| 452 |
|
| 453 |
v.HwDrawableHandle = xgb.Get32(buf[b:]) |
| 454 |
b += 4 |
| 455 |
|
| 456 |
return v |
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { |
| 462 |
size := 12 |
| 463 |
b := 0 |
| 464 |
buf := make([]byte, size) |
| 465 |
|
| 466 |
c.ExtLock.RLock() |
| 467 |
buf[b] = c.Extensions["XFree86-DRI"] |
| 468 |
c.ExtLock.RUnlock() |
| 469 |
b += 1 |
| 470 |
|
| 471 |
buf[b] = 7 |
| 472 |
b += 1 |
| 473 |
|
| 474 |
xgb.Put16(buf[b:], uint16(size/4)) |
| 475 |
b += 2 |
| 476 |
|
| 477 |
xgb.Put32(buf[b:], Screen) |
| 478 |
b += 4 |
| 479 |
|
| 480 |
xgb.Put32(buf[b:], Drawable) |
| 481 |
b += 4 |
| 482 |
|
| 483 |
return buf |
| 484 |
} |
| 485 |
|
| 486 |
|
| 487 |
type DestroyContextCookie struct { |
| 488 |
*xgb.Cookie |
| 489 |
} |
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { |
| 494 |
c.ExtLock.RLock() |
| 495 |
defer c.ExtLock.RUnlock() |
| 496 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 497 |
panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 498 |
} |
| 499 |
cookie := c.NewCookie(false, false) |
| 500 |
c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) |
| 501 |
return DestroyContextCookie{cookie} |
| 502 |
} |
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie { |
| 507 |
c.ExtLock.RLock() |
| 508 |
defer c.ExtLock.RUnlock() |
| 509 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 510 |
panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 511 |
} |
| 512 |
cookie := c.NewCookie(true, false) |
| 513 |
c.NewRequest(destroyContextRequest(c, Screen, Context), cookie) |
| 514 |
return DestroyContextCookie{cookie} |
| 515 |
} |
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
func (cook DestroyContextCookie) Check() error { |
| 520 |
return cook.Cookie.Check() |
| 521 |
} |
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte { |
| 526 |
size := 12 |
| 527 |
b := 0 |
| 528 |
buf := make([]byte, size) |
| 529 |
|
| 530 |
c.ExtLock.RLock() |
| 531 |
buf[b] = c.Extensions["XFree86-DRI"] |
| 532 |
c.ExtLock.RUnlock() |
| 533 |
b += 1 |
| 534 |
|
| 535 |
buf[b] = 6 |
| 536 |
b += 1 |
| 537 |
|
| 538 |
xgb.Put16(buf[b:], uint16(size/4)) |
| 539 |
b += 2 |
| 540 |
|
| 541 |
xgb.Put32(buf[b:], Screen) |
| 542 |
b += 4 |
| 543 |
|
| 544 |
xgb.Put32(buf[b:], Context) |
| 545 |
b += 4 |
| 546 |
|
| 547 |
return buf |
| 548 |
} |
| 549 |
|
| 550 |
|
| 551 |
type DestroyDrawableCookie struct { |
| 552 |
*xgb.Cookie |
| 553 |
} |
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { |
| 558 |
c.ExtLock.RLock() |
| 559 |
defer c.ExtLock.RUnlock() |
| 560 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 561 |
panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 562 |
} |
| 563 |
cookie := c.NewCookie(false, false) |
| 564 |
c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) |
| 565 |
return DestroyDrawableCookie{cookie} |
| 566 |
} |
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie { |
| 571 |
c.ExtLock.RLock() |
| 572 |
defer c.ExtLock.RUnlock() |
| 573 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 574 |
panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 575 |
} |
| 576 |
cookie := c.NewCookie(true, false) |
| 577 |
c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie) |
| 578 |
return DestroyDrawableCookie{cookie} |
| 579 |
} |
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
func (cook DestroyDrawableCookie) Check() error { |
| 584 |
return cook.Cookie.Check() |
| 585 |
} |
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { |
| 590 |
size := 12 |
| 591 |
b := 0 |
| 592 |
buf := make([]byte, size) |
| 593 |
|
| 594 |
c.ExtLock.RLock() |
| 595 |
buf[b] = c.Extensions["XFree86-DRI"] |
| 596 |
c.ExtLock.RUnlock() |
| 597 |
b += 1 |
| 598 |
|
| 599 |
buf[b] = 8 |
| 600 |
b += 1 |
| 601 |
|
| 602 |
xgb.Put16(buf[b:], uint16(size/4)) |
| 603 |
b += 2 |
| 604 |
|
| 605 |
xgb.Put32(buf[b:], Screen) |
| 606 |
b += 4 |
| 607 |
|
| 608 |
xgb.Put32(buf[b:], Drawable) |
| 609 |
b += 4 |
| 610 |
|
| 611 |
return buf |
| 612 |
} |
| 613 |
|
| 614 |
|
| 615 |
type GetClientDriverNameCookie struct { |
| 616 |
*xgb.Cookie |
| 617 |
} |
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { |
| 622 |
c.ExtLock.RLock() |
| 623 |
defer c.ExtLock.RUnlock() |
| 624 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 625 |
panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 626 |
} |
| 627 |
cookie := c.NewCookie(true, true) |
| 628 |
c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) |
| 629 |
return GetClientDriverNameCookie{cookie} |
| 630 |
} |
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
func GetClientDriverNameUnchecked(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie { |
| 635 |
c.ExtLock.RLock() |
| 636 |
defer c.ExtLock.RUnlock() |
| 637 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 638 |
panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 639 |
} |
| 640 |
cookie := c.NewCookie(false, true) |
| 641 |
c.NewRequest(getClientDriverNameRequest(c, Screen), cookie) |
| 642 |
return GetClientDriverNameCookie{cookie} |
| 643 |
} |
| 644 |
|
| 645 |
|
| 646 |
type GetClientDriverNameReply struct { |
| 647 |
Sequence uint16 |
| 648 |
Length uint32 |
| 649 |
|
| 650 |
ClientDriverMajorVersion uint32 |
| 651 |
ClientDriverMinorVersion uint32 |
| 652 |
ClientDriverPatchVersion uint32 |
| 653 |
ClientDriverNameLen uint32 |
| 654 |
|
| 655 |
ClientDriverName string |
| 656 |
} |
| 657 |
|
| 658 |
|
| 659 |
func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) { |
| 660 |
buf, err := cook.Cookie.Reply() |
| 661 |
if err != nil { |
| 662 |
return nil, err |
| 663 |
} |
| 664 |
if buf == nil { |
| 665 |
return nil, nil |
| 666 |
} |
| 667 |
return getClientDriverNameReply(buf), nil |
| 668 |
} |
| 669 |
|
| 670 |
|
| 671 |
func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply { |
| 672 |
v := new(GetClientDriverNameReply) |
| 673 |
b := 1 |
| 674 |
|
| 675 |
b += 1 |
| 676 |
|
| 677 |
v.Sequence = xgb.Get16(buf[b:]) |
| 678 |
b += 2 |
| 679 |
|
| 680 |
v.Length = xgb.Get32(buf[b:]) |
| 681 |
b += 4 |
| 682 |
|
| 683 |
v.ClientDriverMajorVersion = xgb.Get32(buf[b:]) |
| 684 |
b += 4 |
| 685 |
|
| 686 |
v.ClientDriverMinorVersion = xgb.Get32(buf[b:]) |
| 687 |
b += 4 |
| 688 |
|
| 689 |
v.ClientDriverPatchVersion = xgb.Get32(buf[b:]) |
| 690 |
b += 4 |
| 691 |
|
| 692 |
v.ClientDriverNameLen = xgb.Get32(buf[b:]) |
| 693 |
b += 4 |
| 694 |
|
| 695 |
b += 8 |
| 696 |
|
| 697 |
{ |
| 698 |
byteString := make([]byte, v.ClientDriverNameLen) |
| 699 |
copy(byteString[:v.ClientDriverNameLen], buf[b:]) |
| 700 |
v.ClientDriverName = string(byteString) |
| 701 |
b += int(v.ClientDriverNameLen) |
| 702 |
} |
| 703 |
|
| 704 |
return v |
| 705 |
} |
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte { |
| 710 |
size := 8 |
| 711 |
b := 0 |
| 712 |
buf := make([]byte, size) |
| 713 |
|
| 714 |
c.ExtLock.RLock() |
| 715 |
buf[b] = c.Extensions["XFree86-DRI"] |
| 716 |
c.ExtLock.RUnlock() |
| 717 |
b += 1 |
| 718 |
|
| 719 |
buf[b] = 4 |
| 720 |
b += 1 |
| 721 |
|
| 722 |
xgb.Put16(buf[b:], uint16(size/4)) |
| 723 |
b += 2 |
| 724 |
|
| 725 |
xgb.Put32(buf[b:], Screen) |
| 726 |
b += 4 |
| 727 |
|
| 728 |
return buf |
| 729 |
} |
| 730 |
|
| 731 |
|
| 732 |
type GetDeviceInfoCookie struct { |
| 733 |
*xgb.Cookie |
| 734 |
} |
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { |
| 739 |
c.ExtLock.RLock() |
| 740 |
defer c.ExtLock.RUnlock() |
| 741 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 742 |
panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 743 |
} |
| 744 |
cookie := c.NewCookie(true, true) |
| 745 |
c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) |
| 746 |
return GetDeviceInfoCookie{cookie} |
| 747 |
} |
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
func GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie { |
| 752 |
c.ExtLock.RLock() |
| 753 |
defer c.ExtLock.RUnlock() |
| 754 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 755 |
panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 756 |
} |
| 757 |
cookie := c.NewCookie(false, true) |
| 758 |
c.NewRequest(getDeviceInfoRequest(c, Screen), cookie) |
| 759 |
return GetDeviceInfoCookie{cookie} |
| 760 |
} |
| 761 |
|
| 762 |
|
| 763 |
type GetDeviceInfoReply struct { |
| 764 |
Sequence uint16 |
| 765 |
Length uint32 |
| 766 |
|
| 767 |
FramebufferHandleLow uint32 |
| 768 |
FramebufferHandleHigh uint32 |
| 769 |
FramebufferOriginOffset uint32 |
| 770 |
FramebufferSize uint32 |
| 771 |
FramebufferStride uint32 |
| 772 |
DevicePrivateSize uint32 |
| 773 |
DevicePrivate []uint32 |
| 774 |
} |
| 775 |
|
| 776 |
|
| 777 |
func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) { |
| 778 |
buf, err := cook.Cookie.Reply() |
| 779 |
if err != nil { |
| 780 |
return nil, err |
| 781 |
} |
| 782 |
if buf == nil { |
| 783 |
return nil, nil |
| 784 |
} |
| 785 |
return getDeviceInfoReply(buf), nil |
| 786 |
} |
| 787 |
|
| 788 |
|
| 789 |
func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply { |
| 790 |
v := new(GetDeviceInfoReply) |
| 791 |
b := 1 |
| 792 |
|
| 793 |
b += 1 |
| 794 |
|
| 795 |
v.Sequence = xgb.Get16(buf[b:]) |
| 796 |
b += 2 |
| 797 |
|
| 798 |
v.Length = xgb.Get32(buf[b:]) |
| 799 |
b += 4 |
| 800 |
|
| 801 |
v.FramebufferHandleLow = xgb.Get32(buf[b:]) |
| 802 |
b += 4 |
| 803 |
|
| 804 |
v.FramebufferHandleHigh = xgb.Get32(buf[b:]) |
| 805 |
b += 4 |
| 806 |
|
| 807 |
v.FramebufferOriginOffset = xgb.Get32(buf[b:]) |
| 808 |
b += 4 |
| 809 |
|
| 810 |
v.FramebufferSize = xgb.Get32(buf[b:]) |
| 811 |
b += 4 |
| 812 |
|
| 813 |
v.FramebufferStride = xgb.Get32(buf[b:]) |
| 814 |
b += 4 |
| 815 |
|
| 816 |
v.DevicePrivateSize = xgb.Get32(buf[b:]) |
| 817 |
b += 4 |
| 818 |
|
| 819 |
v.DevicePrivate = make([]uint32, v.DevicePrivateSize) |
| 820 |
for i := 0; i < int(v.DevicePrivateSize); i++ { |
| 821 |
v.DevicePrivate[i] = xgb.Get32(buf[b:]) |
| 822 |
b += 4 |
| 823 |
} |
| 824 |
|
| 825 |
return v |
| 826 |
} |
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte { |
| 831 |
size := 8 |
| 832 |
b := 0 |
| 833 |
buf := make([]byte, size) |
| 834 |
|
| 835 |
c.ExtLock.RLock() |
| 836 |
buf[b] = c.Extensions["XFree86-DRI"] |
| 837 |
c.ExtLock.RUnlock() |
| 838 |
b += 1 |
| 839 |
|
| 840 |
buf[b] = 10 |
| 841 |
b += 1 |
| 842 |
|
| 843 |
xgb.Put16(buf[b:], uint16(size/4)) |
| 844 |
b += 2 |
| 845 |
|
| 846 |
xgb.Put32(buf[b:], Screen) |
| 847 |
b += 4 |
| 848 |
|
| 849 |
return buf |
| 850 |
} |
| 851 |
|
| 852 |
|
| 853 |
type GetDrawableInfoCookie struct { |
| 854 |
*xgb.Cookie |
| 855 |
} |
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { |
| 860 |
c.ExtLock.RLock() |
| 861 |
defer c.ExtLock.RUnlock() |
| 862 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 863 |
panic("Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 864 |
} |
| 865 |
cookie := c.NewCookie(true, true) |
| 866 |
c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) |
| 867 |
return GetDrawableInfoCookie{cookie} |
| 868 |
} |
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
func GetDrawableInfoUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie { |
| 873 |
c.ExtLock.RLock() |
| 874 |
defer c.ExtLock.RUnlock() |
| 875 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 876 |
panic("Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 877 |
} |
| 878 |
cookie := c.NewCookie(false, true) |
| 879 |
c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie) |
| 880 |
return GetDrawableInfoCookie{cookie} |
| 881 |
} |
| 882 |
|
| 883 |
|
| 884 |
type GetDrawableInfoReply struct { |
| 885 |
Sequence uint16 |
| 886 |
Length uint32 |
| 887 |
|
| 888 |
DrawableTableIndex uint32 |
| 889 |
DrawableTableStamp uint32 |
| 890 |
DrawableOriginX int16 |
| 891 |
DrawableOriginY int16 |
| 892 |
DrawableSizeW int16 |
| 893 |
DrawableSizeH int16 |
| 894 |
NumClipRects uint32 |
| 895 |
BackX int16 |
| 896 |
BackY int16 |
| 897 |
NumBackClipRects uint32 |
| 898 |
ClipRects []DrmClipRect |
| 899 |
|
| 900 |
BackClipRects []DrmClipRect |
| 901 |
} |
| 902 |
|
| 903 |
|
| 904 |
func (cook GetDrawableInfoCookie) Reply() (*GetDrawableInfoReply, error) { |
| 905 |
buf, err := cook.Cookie.Reply() |
| 906 |
if err != nil { |
| 907 |
return nil, err |
| 908 |
} |
| 909 |
if buf == nil { |
| 910 |
return nil, nil |
| 911 |
} |
| 912 |
return getDrawableInfoReply(buf), nil |
| 913 |
} |
| 914 |
|
| 915 |
|
| 916 |
func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply { |
| 917 |
v := new(GetDrawableInfoReply) |
| 918 |
b := 1 |
| 919 |
|
| 920 |
b += 1 |
| 921 |
|
| 922 |
v.Sequence = xgb.Get16(buf[b:]) |
| 923 |
b += 2 |
| 924 |
|
| 925 |
v.Length = xgb.Get32(buf[b:]) |
| 926 |
b += 4 |
| 927 |
|
| 928 |
v.DrawableTableIndex = xgb.Get32(buf[b:]) |
| 929 |
b += 4 |
| 930 |
|
| 931 |
v.DrawableTableStamp = xgb.Get32(buf[b:]) |
| 932 |
b += 4 |
| 933 |
|
| 934 |
v.DrawableOriginX = int16(xgb.Get16(buf[b:])) |
| 935 |
b += 2 |
| 936 |
|
| 937 |
v.DrawableOriginY = int16(xgb.Get16(buf[b:])) |
| 938 |
b += 2 |
| 939 |
|
| 940 |
v.DrawableSizeW = int16(xgb.Get16(buf[b:])) |
| 941 |
b += 2 |
| 942 |
|
| 943 |
v.DrawableSizeH = int16(xgb.Get16(buf[b:])) |
| 944 |
b += 2 |
| 945 |
|
| 946 |
v.NumClipRects = xgb.Get32(buf[b:]) |
| 947 |
b += 4 |
| 948 |
|
| 949 |
v.BackX = int16(xgb.Get16(buf[b:])) |
| 950 |
b += 2 |
| 951 |
|
| 952 |
v.BackY = int16(xgb.Get16(buf[b:])) |
| 953 |
b += 2 |
| 954 |
|
| 955 |
v.NumBackClipRects = xgb.Get32(buf[b:]) |
| 956 |
b += 4 |
| 957 |
|
| 958 |
v.ClipRects = make([]DrmClipRect, v.NumClipRects) |
| 959 |
b += DrmClipRectReadList(buf[b:], v.ClipRects) |
| 960 |
|
| 961 |
b = (b + 3) & ^3 |
| 962 |
|
| 963 |
v.BackClipRects = make([]DrmClipRect, v.NumBackClipRects) |
| 964 |
b += DrmClipRectReadList(buf[b:], v.BackClipRects) |
| 965 |
|
| 966 |
return v |
| 967 |
} |
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte { |
| 972 |
size := 12 |
| 973 |
b := 0 |
| 974 |
buf := make([]byte, size) |
| 975 |
|
| 976 |
c.ExtLock.RLock() |
| 977 |
buf[b] = c.Extensions["XFree86-DRI"] |
| 978 |
c.ExtLock.RUnlock() |
| 979 |
b += 1 |
| 980 |
|
| 981 |
buf[b] = 9 |
| 982 |
b += 1 |
| 983 |
|
| 984 |
xgb.Put16(buf[b:], uint16(size/4)) |
| 985 |
b += 2 |
| 986 |
|
| 987 |
xgb.Put32(buf[b:], Screen) |
| 988 |
b += 4 |
| 989 |
|
| 990 |
xgb.Put32(buf[b:], Drawable) |
| 991 |
b += 4 |
| 992 |
|
| 993 |
return buf |
| 994 |
} |
| 995 |
|
| 996 |
|
| 997 |
type OpenConnectionCookie struct { |
| 998 |
*xgb.Cookie |
| 999 |
} |
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie { |
| 1004 |
c.ExtLock.RLock() |
| 1005 |
defer c.ExtLock.RUnlock() |
| 1006 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 1007 |
panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 1008 |
} |
| 1009 |
cookie := c.NewCookie(true, true) |
| 1010 |
c.NewRequest(openConnectionRequest(c, Screen), cookie) |
| 1011 |
return OpenConnectionCookie{cookie} |
| 1012 |
} |
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
func OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie { |
| 1017 |
c.ExtLock.RLock() |
| 1018 |
defer c.ExtLock.RUnlock() |
| 1019 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 1020 |
panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 1021 |
} |
| 1022 |
cookie := c.NewCookie(false, true) |
| 1023 |
c.NewRequest(openConnectionRequest(c, Screen), cookie) |
| 1024 |
return OpenConnectionCookie{cookie} |
| 1025 |
} |
| 1026 |
|
| 1027 |
|
| 1028 |
type OpenConnectionReply struct { |
| 1029 |
Sequence uint16 |
| 1030 |
Length uint32 |
| 1031 |
|
| 1032 |
SareaHandleLow uint32 |
| 1033 |
SareaHandleHigh uint32 |
| 1034 |
BusIdLen uint32 |
| 1035 |
|
| 1036 |
BusId string |
| 1037 |
} |
| 1038 |
|
| 1039 |
|
| 1040 |
func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) { |
| 1041 |
buf, err := cook.Cookie.Reply() |
| 1042 |
if err != nil { |
| 1043 |
return nil, err |
| 1044 |
} |
| 1045 |
if buf == nil { |
| 1046 |
return nil, nil |
| 1047 |
} |
| 1048 |
return openConnectionReply(buf), nil |
| 1049 |
} |
| 1050 |
|
| 1051 |
|
| 1052 |
func openConnectionReply(buf []byte) *OpenConnectionReply { |
| 1053 |
v := new(OpenConnectionReply) |
| 1054 |
b := 1 |
| 1055 |
|
| 1056 |
b += 1 |
| 1057 |
|
| 1058 |
v.Sequence = xgb.Get16(buf[b:]) |
| 1059 |
b += 2 |
| 1060 |
|
| 1061 |
v.Length = xgb.Get32(buf[b:]) |
| 1062 |
b += 4 |
| 1063 |
|
| 1064 |
v.SareaHandleLow = xgb.Get32(buf[b:]) |
| 1065 |
b += 4 |
| 1066 |
|
| 1067 |
v.SareaHandleHigh = xgb.Get32(buf[b:]) |
| 1068 |
b += 4 |
| 1069 |
|
| 1070 |
v.BusIdLen = xgb.Get32(buf[b:]) |
| 1071 |
b += 4 |
| 1072 |
|
| 1073 |
b += 12 |
| 1074 |
|
| 1075 |
{ |
| 1076 |
byteString := make([]byte, v.BusIdLen) |
| 1077 |
copy(byteString[:v.BusIdLen], buf[b:]) |
| 1078 |
v.BusId = string(byteString) |
| 1079 |
b += int(v.BusIdLen) |
| 1080 |
} |
| 1081 |
|
| 1082 |
return v |
| 1083 |
} |
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte { |
| 1088 |
size := 8 |
| 1089 |
b := 0 |
| 1090 |
buf := make([]byte, size) |
| 1091 |
|
| 1092 |
c.ExtLock.RLock() |
| 1093 |
buf[b] = c.Extensions["XFree86-DRI"] |
| 1094 |
c.ExtLock.RUnlock() |
| 1095 |
b += 1 |
| 1096 |
|
| 1097 |
buf[b] = 2 |
| 1098 |
b += 1 |
| 1099 |
|
| 1100 |
xgb.Put16(buf[b:], uint16(size/4)) |
| 1101 |
b += 2 |
| 1102 |
|
| 1103 |
xgb.Put32(buf[b:], Screen) |
| 1104 |
b += 4 |
| 1105 |
|
| 1106 |
return buf |
| 1107 |
} |
| 1108 |
|
| 1109 |
|
| 1110 |
type QueryDirectRenderingCapableCookie struct { |
| 1111 |
*xgb.Cookie |
| 1112 |
} |
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { |
| 1117 |
c.ExtLock.RLock() |
| 1118 |
defer c.ExtLock.RUnlock() |
| 1119 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 1120 |
panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 1121 |
} |
| 1122 |
cookie := c.NewCookie(true, true) |
| 1123 |
c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) |
| 1124 |
return QueryDirectRenderingCapableCookie{cookie} |
| 1125 |
} |
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie { |
| 1130 |
c.ExtLock.RLock() |
| 1131 |
defer c.ExtLock.RUnlock() |
| 1132 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 1133 |
panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 1134 |
} |
| 1135 |
cookie := c.NewCookie(false, true) |
| 1136 |
c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie) |
| 1137 |
return QueryDirectRenderingCapableCookie{cookie} |
| 1138 |
} |
| 1139 |
|
| 1140 |
|
| 1141 |
type QueryDirectRenderingCapableReply struct { |
| 1142 |
Sequence uint16 |
| 1143 |
Length uint32 |
| 1144 |
|
| 1145 |
IsCapable bool |
| 1146 |
} |
| 1147 |
|
| 1148 |
|
| 1149 |
func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, error) { |
| 1150 |
buf, err := cook.Cookie.Reply() |
| 1151 |
if err != nil { |
| 1152 |
return nil, err |
| 1153 |
} |
| 1154 |
if buf == nil { |
| 1155 |
return nil, nil |
| 1156 |
} |
| 1157 |
return queryDirectRenderingCapableReply(buf), nil |
| 1158 |
} |
| 1159 |
|
| 1160 |
|
| 1161 |
func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply { |
| 1162 |
v := new(QueryDirectRenderingCapableReply) |
| 1163 |
b := 1 |
| 1164 |
|
| 1165 |
b += 1 |
| 1166 |
|
| 1167 |
v.Sequence = xgb.Get16(buf[b:]) |
| 1168 |
b += 2 |
| 1169 |
|
| 1170 |
v.Length = xgb.Get32(buf[b:]) |
| 1171 |
b += 4 |
| 1172 |
|
| 1173 |
if buf[b] == 1 { |
| 1174 |
v.IsCapable = true |
| 1175 |
} else { |
| 1176 |
v.IsCapable = false |
| 1177 |
} |
| 1178 |
b += 1 |
| 1179 |
|
| 1180 |
return v |
| 1181 |
} |
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte { |
| 1186 |
size := 8 |
| 1187 |
b := 0 |
| 1188 |
buf := make([]byte, size) |
| 1189 |
|
| 1190 |
c.ExtLock.RLock() |
| 1191 |
buf[b] = c.Extensions["XFree86-DRI"] |
| 1192 |
c.ExtLock.RUnlock() |
| 1193 |
b += 1 |
| 1194 |
|
| 1195 |
buf[b] = 1 |
| 1196 |
b += 1 |
| 1197 |
|
| 1198 |
xgb.Put16(buf[b:], uint16(size/4)) |
| 1199 |
b += 2 |
| 1200 |
|
| 1201 |
xgb.Put32(buf[b:], Screen) |
| 1202 |
b += 4 |
| 1203 |
|
| 1204 |
return buf |
| 1205 |
} |
| 1206 |
|
| 1207 |
|
| 1208 |
type QueryVersionCookie struct { |
| 1209 |
*xgb.Cookie |
| 1210 |
} |
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
func QueryVersion(c *xgb.Conn) QueryVersionCookie { |
| 1215 |
c.ExtLock.RLock() |
| 1216 |
defer c.ExtLock.RUnlock() |
| 1217 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 1218 |
panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 1219 |
} |
| 1220 |
cookie := c.NewCookie(true, true) |
| 1221 |
c.NewRequest(queryVersionRequest(c), cookie) |
| 1222 |
return QueryVersionCookie{cookie} |
| 1223 |
} |
| 1224 |
|
| 1225 |
|
| 1226 |
|
| 1227 |
func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie { |
| 1228 |
c.ExtLock.RLock() |
| 1229 |
defer c.ExtLock.RUnlock() |
| 1230 |
if _, ok := c.Extensions["XFree86-DRI"]; !ok { |
| 1231 |
panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.") |
| 1232 |
} |
| 1233 |
cookie := c.NewCookie(false, true) |
| 1234 |
c.NewRequest(queryVersionRequest(c), cookie) |
| 1235 |
return QueryVersionCookie{cookie} |
| 1236 |
} |
| 1237 |
|
| 1238 |
|
| 1239 |
type QueryVersionReply struct { |
| 1240 |
Sequence uint16 |
| 1241 |
Length uint32 |
| 1242 |
|
| 1243 |
DriMajorVersion uint16 |
| 1244 |
DriMinorVersion uint16 |
| 1245 |
DriMinorPatch uint32 |
| 1246 |
} |
| 1247 |
|
| 1248 |
|
| 1249 |
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { |
| 1250 |
buf, err := cook.Cookie.Reply() |
| 1251 |
if err != nil { |
| 1252 |
return nil, err |
| 1253 |
} |
| 1254 |
if buf == nil { |
| 1255 |
return nil, nil |
| 1256 |
} |
| 1257 |
return queryVersionReply(buf), nil |
| 1258 |
} |
| 1259 |
|
| 1260 |
|
| 1261 |
func queryVersionReply(buf []byte) *QueryVersionReply { |
| 1262 |
v := new(QueryVersionReply) |
| 1263 |
b := 1 |
| 1264 |
|
| 1265 |
b += 1 |
| 1266 |
|
| 1267 |
v.Sequence = xgb.Get16(buf[b:]) |
| 1268 |
b += 2 |
| 1269 |
|
| 1270 |
v.Length = xgb.Get32(buf[b:]) |
| 1271 |
b += 4 |
| 1272 |
|
| 1273 |
v.DriMajorVersion = xgb.Get16(buf[b:]) |
| 1274 |
b += 2 |
| 1275 |
|
| 1276 |
v.DriMinorVersion = xgb.Get16(buf[b:]) |
| 1277 |
b += 2 |
| 1278 |
|
| 1279 |
v.DriMinorPatch = xgb.Get32(buf[b:]) |
| 1280 |
b += 4 |
| 1281 |
|
| 1282 |
return v |
| 1283 |
} |
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
func queryVersionRequest(c *xgb.Conn) []byte { |
| 1288 |
size := 4 |
| 1289 |
b := 0 |
| 1290 |
buf := make([]byte, size) |
| 1291 |
|
| 1292 |
c.ExtLock.RLock() |
| 1293 |
buf[b] = c.Extensions["XFree86-DRI"] |
| 1294 |
c.ExtLock.RUnlock() |
| 1295 |
b += 1 |
| 1296 |
|
| 1297 |
buf[b] = 0 |
| 1298 |
b += 1 |
| 1299 |
|
| 1300 |
xgb.Put16(buf[b:], uint16(size/4)) |
| 1301 |
b += 2 |
| 1302 |
|
| 1303 |
return buf |
| 1304 |
} |