3 Star 0 Fork 0

Gitee 极速下载 / xgb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/BurntSushi/xgb
克隆/下载
xf86dri.go 36.99 KB
一键复制 编辑 原始数据 按行查看 历史
aarzilli 提交于 2016-03-01 15:41 . Read/Write mutex for Extensions map
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
// Package xf86dri is the X client API for the XFree86-DRI extension.
package xf86dri
// This file is automatically generated from xf86dri.xml. Edit at your peril!
import (
"github.com/BurntSushi/xgb"
"github.com/BurntSushi/xgb/xproto"
)
// Init must be called before using the XFree86-DRI extension.
func Init(c *xgb.Conn) error {
reply, err := xproto.QueryExtension(c, 11, "XFree86-DRI").Reply()
switch {
case err != nil:
return err
case !reply.Present:
return xgb.Errorf("No extension named XFree86-DRI could be found on on the server.")
}
c.ExtLock.Lock()
c.Extensions["XFree86-DRI"] = reply.MajorOpcode
c.ExtLock.Unlock()
for evNum, fun := range xgb.NewExtEventFuncs["XFree86-DRI"] {
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
}
for errNum, fun := range xgb.NewExtErrorFuncs["XFree86-DRI"] {
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
}
return nil
}
func init() {
xgb.NewExtEventFuncs["XFree86-DRI"] = make(map[int]xgb.NewEventFun)
xgb.NewExtErrorFuncs["XFree86-DRI"] = make(map[int]xgb.NewErrorFun)
}
type DrmClipRect struct {
X1 int16
Y1 int16
X2 int16
X3 int16
}
// DrmClipRectRead reads a byte slice into a DrmClipRect value.
func DrmClipRectRead(buf []byte, v *DrmClipRect) int {
b := 0
v.X1 = int16(xgb.Get16(buf[b:]))
b += 2
v.Y1 = int16(xgb.Get16(buf[b:]))
b += 2
v.X2 = int16(xgb.Get16(buf[b:]))
b += 2
v.X3 = int16(xgb.Get16(buf[b:]))
b += 2
return b
}
// DrmClipRectReadList reads a byte slice into a list of DrmClipRect values.
func DrmClipRectReadList(buf []byte, dest []DrmClipRect) int {
b := 0
for i := 0; i < len(dest); i++ {
dest[i] = DrmClipRect{}
b += DrmClipRectRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
// Bytes writes a DrmClipRect value to a byte slice.
func (v DrmClipRect) Bytes() []byte {
buf := make([]byte, 8)
b := 0
xgb.Put16(buf[b:], uint16(v.X1))
b += 2
xgb.Put16(buf[b:], uint16(v.Y1))
b += 2
xgb.Put16(buf[b:], uint16(v.X2))
b += 2
xgb.Put16(buf[b:], uint16(v.X3))
b += 2
return buf[:b]
}
// DrmClipRectListBytes writes a list of DrmClipRect values to a byte slice.
func DrmClipRectListBytes(buf []byte, list []DrmClipRect) int {
b := 0
var structBytes []byte
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += len(structBytes)
}
return xgb.Pad(b)
}
// Skipping definition for base type 'Bool'
// Skipping definition for base type 'Byte'
// Skipping definition for base type 'Card8'
// Skipping definition for base type 'Char'
// Skipping definition for base type 'Void'
// Skipping definition for base type 'Double'
// Skipping definition for base type 'Float'
// Skipping definition for base type 'Int16'
// Skipping definition for base type 'Int32'
// Skipping definition for base type 'Int8'
// Skipping definition for base type 'Card16'
// Skipping definition for base type 'Card32'
// AuthConnectionCookie is a cookie used only for AuthConnection requests.
type AuthConnectionCookie struct {
*xgb.Cookie
}
// AuthConnection sends a checked request.
// If an error occurs, it will be returned with the reply by calling AuthConnectionCookie.Reply()
func AuthConnection(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie)
return AuthConnectionCookie{cookie}
}
// AuthConnectionUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func AuthConnectionUnchecked(c *xgb.Conn, Screen uint32, Magic uint32) AuthConnectionCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'AuthConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(authConnectionRequest(c, Screen, Magic), cookie)
return AuthConnectionCookie{cookie}
}
// AuthConnectionReply represents the data returned from a AuthConnection request.
type AuthConnectionReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
Authenticated uint32
}
// Reply blocks and returns the reply data for a AuthConnection request.
func (cook AuthConnectionCookie) Reply() (*AuthConnectionReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return authConnectionReply(buf), nil
}
// authConnectionReply reads a byte slice into a AuthConnectionReply value.
func authConnectionReply(buf []byte) *AuthConnectionReply {
v := new(AuthConnectionReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.Authenticated = xgb.Get32(buf[b:])
b += 4
return v
}
// Write request to wire for AuthConnection
// authConnectionRequest writes a AuthConnection request to a byte slice.
func authConnectionRequest(c *xgb.Conn, Screen uint32, Magic uint32) []byte {
size := 12
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XFree86-DRI"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 11 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], Screen)
b += 4
xgb.Put32(buf[b:], Magic)
b += 4
return buf
}
// CloseConnectionCookie is a cookie used only for CloseConnection requests.
type CloseConnectionCookie struct {
*xgb.Cookie
}
// CloseConnection sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func CloseConnection(c *xgb.Conn, Screen uint32) CloseConnectionCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(closeConnectionRequest(c, Screen), cookie)
return CloseConnectionCookie{cookie}
}
// CloseConnectionChecked sends a checked request.
// If an error occurs, it can be retrieved using CloseConnectionCookie.Check()
func CloseConnectionChecked(c *xgb.Conn, Screen uint32) CloseConnectionCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'CloseConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(closeConnectionRequest(c, Screen), cookie)
return CloseConnectionCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook CloseConnectionCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for CloseConnection
// closeConnectionRequest writes a CloseConnection request to a byte slice.
func closeConnectionRequest(c *xgb.Conn, Screen uint32) []byte {
size := 8
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XFree86-DRI"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 3 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], Screen)
b += 4
return buf
}
// CreateContextCookie is a cookie used only for CreateContext requests.
type CreateContextCookie struct {
*xgb.Cookie
}
// CreateContext sends a checked request.
// If an error occurs, it will be returned with the reply by calling CreateContextCookie.Reply()
func CreateContext(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie)
return CreateContextCookie{cookie}
}
// CreateContextUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func CreateContextUnchecked(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) CreateContextCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'CreateContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(createContextRequest(c, Screen, Visual, Context), cookie)
return CreateContextCookie{cookie}
}
// CreateContextReply represents the data returned from a CreateContext request.
type CreateContextReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
HwContext uint32
}
// Reply blocks and returns the reply data for a CreateContext request.
func (cook CreateContextCookie) Reply() (*CreateContextReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return createContextReply(buf), nil
}
// createContextReply reads a byte slice into a CreateContextReply value.
func createContextReply(buf []byte) *CreateContextReply {
v := new(CreateContextReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.HwContext = xgb.Get32(buf[b:])
b += 4
return v
}
// Write request to wire for CreateContext
// createContextRequest writes a CreateContext request to a byte slice.
func createContextRequest(c *xgb.Conn, Screen uint32, Visual uint32, Context uint32) []byte {
size := 16
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XFree86-DRI"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 5 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], Screen)
b += 4
xgb.Put32(buf[b:], Visual)
b += 4
xgb.Put32(buf[b:], Context)
b += 4
return buf
}
// CreateDrawableCookie is a cookie used only for CreateDrawable requests.
type CreateDrawableCookie struct {
*xgb.Cookie
}
// CreateDrawable sends a checked request.
// If an error occurs, it will be returned with the reply by calling CreateDrawableCookie.Reply()
func CreateDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie)
return CreateDrawableCookie{cookie}
}
// CreateDrawableUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func CreateDrawableUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) CreateDrawableCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'CreateDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(createDrawableRequest(c, Screen, Drawable), cookie)
return CreateDrawableCookie{cookie}
}
// CreateDrawableReply represents the data returned from a CreateDrawable request.
type CreateDrawableReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
HwDrawableHandle uint32
}
// Reply blocks and returns the reply data for a CreateDrawable request.
func (cook CreateDrawableCookie) Reply() (*CreateDrawableReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return createDrawableReply(buf), nil
}
// createDrawableReply reads a byte slice into a CreateDrawableReply value.
func createDrawableReply(buf []byte) *CreateDrawableReply {
v := new(CreateDrawableReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.HwDrawableHandle = xgb.Get32(buf[b:])
b += 4
return v
}
// Write request to wire for CreateDrawable
// createDrawableRequest writes a CreateDrawable request to a byte slice.
func createDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte {
size := 12
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XFree86-DRI"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 7 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], Screen)
b += 4
xgb.Put32(buf[b:], Drawable)
b += 4
return buf
}
// DestroyContextCookie is a cookie used only for DestroyContext requests.
type DestroyContextCookie struct {
*xgb.Cookie
}
// DestroyContext sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func DestroyContext(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(destroyContextRequest(c, Screen, Context), cookie)
return DestroyContextCookie{cookie}
}
// DestroyContextChecked sends a checked request.
// If an error occurs, it can be retrieved using DestroyContextCookie.Check()
func DestroyContextChecked(c *xgb.Conn, Screen uint32, Context uint32) DestroyContextCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'DestroyContext' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(destroyContextRequest(c, Screen, Context), cookie)
return DestroyContextCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook DestroyContextCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for DestroyContext
// destroyContextRequest writes a DestroyContext request to a byte slice.
func destroyContextRequest(c *xgb.Conn, Screen uint32, Context uint32) []byte {
size := 12
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XFree86-DRI"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 6 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], Screen)
b += 4
xgb.Put32(buf[b:], Context)
b += 4
return buf
}
// DestroyDrawableCookie is a cookie used only for DestroyDrawable requests.
type DestroyDrawableCookie struct {
*xgb.Cookie
}
// DestroyDrawable sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func DestroyDrawable(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie)
return DestroyDrawableCookie{cookie}
}
// DestroyDrawableChecked sends a checked request.
// If an error occurs, it can be retrieved using DestroyDrawableCookie.Check()
func DestroyDrawableChecked(c *xgb.Conn, Screen uint32, Drawable uint32) DestroyDrawableCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'DestroyDrawable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(destroyDrawableRequest(c, Screen, Drawable), cookie)
return DestroyDrawableCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook DestroyDrawableCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for DestroyDrawable
// destroyDrawableRequest writes a DestroyDrawable request to a byte slice.
func destroyDrawableRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte {
size := 12
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XFree86-DRI"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 8 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], Screen)
b += 4
xgb.Put32(buf[b:], Drawable)
b += 4
return buf
}
// GetClientDriverNameCookie is a cookie used only for GetClientDriverName requests.
type GetClientDriverNameCookie struct {
*xgb.Cookie
}
// GetClientDriverName sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetClientDriverNameCookie.Reply()
func GetClientDriverName(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(getClientDriverNameRequest(c, Screen), cookie)
return GetClientDriverNameCookie{cookie}
}
// GetClientDriverNameUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetClientDriverNameUnchecked(c *xgb.Conn, Screen uint32) GetClientDriverNameCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'GetClientDriverName' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(getClientDriverNameRequest(c, Screen), cookie)
return GetClientDriverNameCookie{cookie}
}
// GetClientDriverNameReply represents the data returned from a GetClientDriverName request.
type GetClientDriverNameReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
ClientDriverMajorVersion uint32
ClientDriverMinorVersion uint32
ClientDriverPatchVersion uint32
ClientDriverNameLen uint32
// padding: 8 bytes
ClientDriverName string // size: xgb.Pad((int(ClientDriverNameLen) * 1))
}
// Reply blocks and returns the reply data for a GetClientDriverName request.
func (cook GetClientDriverNameCookie) Reply() (*GetClientDriverNameReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return getClientDriverNameReply(buf), nil
}
// getClientDriverNameReply reads a byte slice into a GetClientDriverNameReply value.
func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply {
v := new(GetClientDriverNameReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.ClientDriverMajorVersion = xgb.Get32(buf[b:])
b += 4
v.ClientDriverMinorVersion = xgb.Get32(buf[b:])
b += 4
v.ClientDriverPatchVersion = xgb.Get32(buf[b:])
b += 4
v.ClientDriverNameLen = xgb.Get32(buf[b:])
b += 4
b += 8 // padding
{
byteString := make([]byte, v.ClientDriverNameLen)
copy(byteString[:v.ClientDriverNameLen], buf[b:])
v.ClientDriverName = string(byteString)
b += int(v.ClientDriverNameLen)
}
return v
}
// Write request to wire for GetClientDriverName
// getClientDriverNameRequest writes a GetClientDriverName request to a byte slice.
func getClientDriverNameRequest(c *xgb.Conn, Screen uint32) []byte {
size := 8
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XFree86-DRI"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 4 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], Screen)
b += 4
return buf
}
// GetDeviceInfoCookie is a cookie used only for GetDeviceInfo requests.
type GetDeviceInfoCookie struct {
*xgb.Cookie
}
// GetDeviceInfo sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetDeviceInfoCookie.Reply()
func GetDeviceInfo(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(getDeviceInfoRequest(c, Screen), cookie)
return GetDeviceInfoCookie{cookie}
}
// GetDeviceInfoUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetDeviceInfoUnchecked(c *xgb.Conn, Screen uint32) GetDeviceInfoCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'GetDeviceInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(getDeviceInfoRequest(c, Screen), cookie)
return GetDeviceInfoCookie{cookie}
}
// GetDeviceInfoReply represents the data returned from a GetDeviceInfo request.
type GetDeviceInfoReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
FramebufferHandleLow uint32
FramebufferHandleHigh uint32
FramebufferOriginOffset uint32
FramebufferSize uint32
FramebufferStride uint32
DevicePrivateSize uint32
DevicePrivate []uint32 // size: xgb.Pad((int(DevicePrivateSize) * 4))
}
// Reply blocks and returns the reply data for a GetDeviceInfo request.
func (cook GetDeviceInfoCookie) Reply() (*GetDeviceInfoReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return getDeviceInfoReply(buf), nil
}
// getDeviceInfoReply reads a byte slice into a GetDeviceInfoReply value.
func getDeviceInfoReply(buf []byte) *GetDeviceInfoReply {
v := new(GetDeviceInfoReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.FramebufferHandleLow = xgb.Get32(buf[b:])
b += 4
v.FramebufferHandleHigh = xgb.Get32(buf[b:])
b += 4
v.FramebufferOriginOffset = xgb.Get32(buf[b:])
b += 4
v.FramebufferSize = xgb.Get32(buf[b:])
b += 4
v.FramebufferStride = xgb.Get32(buf[b:])
b += 4
v.DevicePrivateSize = xgb.Get32(buf[b:])
b += 4
v.DevicePrivate = make([]uint32, v.DevicePrivateSize)
for i := 0; i < int(v.DevicePrivateSize); i++ {
v.DevicePrivate[i] = xgb.Get32(buf[b:])
b += 4
}
return v
}
// Write request to wire for GetDeviceInfo
// getDeviceInfoRequest writes a GetDeviceInfo request to a byte slice.
func getDeviceInfoRequest(c *xgb.Conn, Screen uint32) []byte {
size := 8
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XFree86-DRI"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 10 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], Screen)
b += 4
return buf
}
// GetDrawableInfoCookie is a cookie used only for GetDrawableInfo requests.
type GetDrawableInfoCookie struct {
*xgb.Cookie
}
// GetDrawableInfo sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetDrawableInfoCookie.Reply()
func GetDrawableInfo(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie)
return GetDrawableInfoCookie{cookie}
}
// GetDrawableInfoUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetDrawableInfoUnchecked(c *xgb.Conn, Screen uint32, Drawable uint32) GetDrawableInfoCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'GetDrawableInfo' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(getDrawableInfoRequest(c, Screen, Drawable), cookie)
return GetDrawableInfoCookie{cookie}
}
// GetDrawableInfoReply represents the data returned from a GetDrawableInfo request.
type GetDrawableInfoReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
DrawableTableIndex uint32
DrawableTableStamp uint32
DrawableOriginX int16
DrawableOriginY int16
DrawableSizeW int16
DrawableSizeH int16
NumClipRects uint32
BackX int16
BackY int16
NumBackClipRects uint32
ClipRects []DrmClipRect // size: xgb.Pad((int(NumClipRects) * 8))
// alignment gap to multiple of 4
BackClipRects []DrmClipRect // size: xgb.Pad((int(NumBackClipRects) * 8))
}
// Reply blocks and returns the reply data for a GetDrawableInfo request.
func (cook GetDrawableInfoCookie) Reply() (*GetDrawableInfoReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return getDrawableInfoReply(buf), nil
}
// getDrawableInfoReply reads a byte slice into a GetDrawableInfoReply value.
func getDrawableInfoReply(buf []byte) *GetDrawableInfoReply {
v := new(GetDrawableInfoReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.DrawableTableIndex = xgb.Get32(buf[b:])
b += 4
v.DrawableTableStamp = xgb.Get32(buf[b:])
b += 4
v.DrawableOriginX = int16(xgb.Get16(buf[b:]))
b += 2
v.DrawableOriginY = int16(xgb.Get16(buf[b:]))
b += 2
v.DrawableSizeW = int16(xgb.Get16(buf[b:]))
b += 2
v.DrawableSizeH = int16(xgb.Get16(buf[b:]))
b += 2
v.NumClipRects = xgb.Get32(buf[b:])
b += 4
v.BackX = int16(xgb.Get16(buf[b:]))
b += 2
v.BackY = int16(xgb.Get16(buf[b:]))
b += 2
v.NumBackClipRects = xgb.Get32(buf[b:])
b += 4
v.ClipRects = make([]DrmClipRect, v.NumClipRects)
b += DrmClipRectReadList(buf[b:], v.ClipRects)
b = (b + 3) & ^3 // alignment gap
v.BackClipRects = make([]DrmClipRect, v.NumBackClipRects)
b += DrmClipRectReadList(buf[b:], v.BackClipRects)
return v
}
// Write request to wire for GetDrawableInfo
// getDrawableInfoRequest writes a GetDrawableInfo request to a byte slice.
func getDrawableInfoRequest(c *xgb.Conn, Screen uint32, Drawable uint32) []byte {
size := 12
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XFree86-DRI"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 9 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], Screen)
b += 4
xgb.Put32(buf[b:], Drawable)
b += 4
return buf
}
// OpenConnectionCookie is a cookie used only for OpenConnection requests.
type OpenConnectionCookie struct {
*xgb.Cookie
}
// OpenConnection sends a checked request.
// If an error occurs, it will be returned with the reply by calling OpenConnectionCookie.Reply()
func OpenConnection(c *xgb.Conn, Screen uint32) OpenConnectionCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(openConnectionRequest(c, Screen), cookie)
return OpenConnectionCookie{cookie}
}
// OpenConnectionUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func OpenConnectionUnchecked(c *xgb.Conn, Screen uint32) OpenConnectionCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'OpenConnection' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(openConnectionRequest(c, Screen), cookie)
return OpenConnectionCookie{cookie}
}
// OpenConnectionReply represents the data returned from a OpenConnection request.
type OpenConnectionReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
SareaHandleLow uint32
SareaHandleHigh uint32
BusIdLen uint32
// padding: 12 bytes
BusId string // size: xgb.Pad((int(BusIdLen) * 1))
}
// Reply blocks and returns the reply data for a OpenConnection request.
func (cook OpenConnectionCookie) Reply() (*OpenConnectionReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return openConnectionReply(buf), nil
}
// openConnectionReply reads a byte slice into a OpenConnectionReply value.
func openConnectionReply(buf []byte) *OpenConnectionReply {
v := new(OpenConnectionReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.SareaHandleLow = xgb.Get32(buf[b:])
b += 4
v.SareaHandleHigh = xgb.Get32(buf[b:])
b += 4
v.BusIdLen = xgb.Get32(buf[b:])
b += 4
b += 12 // padding
{
byteString := make([]byte, v.BusIdLen)
copy(byteString[:v.BusIdLen], buf[b:])
v.BusId = string(byteString)
b += int(v.BusIdLen)
}
return v
}
// Write request to wire for OpenConnection
// openConnectionRequest writes a OpenConnection request to a byte slice.
func openConnectionRequest(c *xgb.Conn, Screen uint32) []byte {
size := 8
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XFree86-DRI"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 2 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], Screen)
b += 4
return buf
}
// QueryDirectRenderingCapableCookie is a cookie used only for QueryDirectRenderingCapable requests.
type QueryDirectRenderingCapableCookie struct {
*xgb.Cookie
}
// QueryDirectRenderingCapable sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryDirectRenderingCapableCookie.Reply()
func QueryDirectRenderingCapable(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie)
return QueryDirectRenderingCapableCookie{cookie}
}
// QueryDirectRenderingCapableUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func QueryDirectRenderingCapableUnchecked(c *xgb.Conn, Screen uint32) QueryDirectRenderingCapableCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'QueryDirectRenderingCapable' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(queryDirectRenderingCapableRequest(c, Screen), cookie)
return QueryDirectRenderingCapableCookie{cookie}
}
// QueryDirectRenderingCapableReply represents the data returned from a QueryDirectRenderingCapable request.
type QueryDirectRenderingCapableReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
IsCapable bool
}
// Reply blocks and returns the reply data for a QueryDirectRenderingCapable request.
func (cook QueryDirectRenderingCapableCookie) Reply() (*QueryDirectRenderingCapableReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return queryDirectRenderingCapableReply(buf), nil
}
// queryDirectRenderingCapableReply reads a byte slice into a QueryDirectRenderingCapableReply value.
func queryDirectRenderingCapableReply(buf []byte) *QueryDirectRenderingCapableReply {
v := new(QueryDirectRenderingCapableReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
if buf[b] == 1 {
v.IsCapable = true
} else {
v.IsCapable = false
}
b += 1
return v
}
// Write request to wire for QueryDirectRenderingCapable
// queryDirectRenderingCapableRequest writes a QueryDirectRenderingCapable request to a byte slice.
func queryDirectRenderingCapableRequest(c *xgb.Conn, Screen uint32) []byte {
size := 8
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XFree86-DRI"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 1 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], Screen)
b += 4
return buf
}
// QueryVersionCookie is a cookie used only for QueryVersion requests.
type QueryVersionCookie struct {
*xgb.Cookie
}
// QueryVersion sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply()
func QueryVersion(c *xgb.Conn) QueryVersionCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(queryVersionRequest(c), cookie)
return QueryVersionCookie{cookie}
}
// QueryVersionUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func QueryVersionUnchecked(c *xgb.Conn) QueryVersionCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XFree86-DRI"]; !ok {
panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'XFree86-DRI'. xf86dri.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(queryVersionRequest(c), cookie)
return QueryVersionCookie{cookie}
}
// QueryVersionReply represents the data returned from a QueryVersion request.
type QueryVersionReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
DriMajorVersion uint16
DriMinorVersion uint16
DriMinorPatch uint32
}
// Reply blocks and returns the reply data for a QueryVersion request.
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return queryVersionReply(buf), nil
}
// queryVersionReply reads a byte slice into a QueryVersionReply value.
func queryVersionReply(buf []byte) *QueryVersionReply {
v := new(QueryVersionReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.DriMajorVersion = xgb.Get16(buf[b:])
b += 2
v.DriMinorVersion = xgb.Get16(buf[b:])
b += 2
v.DriMinorPatch = xgb.Get32(buf[b:])
b += 4
return v
}
// Write request to wire for QueryVersion
// queryVersionRequest writes a QueryVersion request to a byte slice.
func queryVersionRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XFree86-DRI"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 0 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
1
https://gitee.com/mirrors/xgb.git
git@gitee.com:mirrors/xgb.git
mirrors
xgb
xgb
deaf085860bc

搜索帮助

53164aa7 5694891 3bd8fe86 5694891