From 0685fb57e14104ee4ad9f70ec94f787a9a22c028 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:43:26 -0400 Subject: Update to latest xproto XML. --- nexgb/dri2/dri2.go | 912 +++++++++++++++++++++++++++++------------------------ 1 file changed, 506 insertions(+), 406 deletions(-) (limited to 'nexgb/dri2') diff --git a/nexgb/dri2/dri2.go b/nexgb/dri2/dri2.go index f047e54..3c63af5 100644 --- a/nexgb/dri2/dri2.go +++ b/nexgb/dri2/dri2.go @@ -2,7 +2,7 @@ package dri2 /* - This file was generated by dri2.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by dri2.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,130 +40,6 @@ func init() { xgb.NewExtErrorFuncs["DRI2"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Card16' - -// Skipping definition for base type 'Char' - -// Skipping definition for base type 'Card32' - -// Skipping definition for base type 'Double' - -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - -// Skipping definition for base type 'Int8' - -const ( - AttachmentBufferFrontLeft = 0 - AttachmentBufferBackLeft = 1 - AttachmentBufferFrontRight = 2 - AttachmentBufferBackRight = 3 - AttachmentBufferDepth = 4 - AttachmentBufferStencil = 5 - AttachmentBufferAccum = 6 - AttachmentBufferFakeFrontLeft = 7 - AttachmentBufferFakeFrontRight = 8 - AttachmentBufferDepthStencil = 9 - AttachmentBufferHiz = 10 -) - -const ( - DriverTypeDri = 0 - DriverTypeVdpau = 1 -) - -const ( - EventTypeExchangeComplete = 1 - EventTypeBlitComplete = 2 - EventTypeFlipComplete = 3 -) - -type DRI2Buffer struct { - Attachment uint32 - Name uint32 - Pitch uint32 - Cpp uint32 - Flags uint32 -} - -// DRI2BufferRead reads a byte slice into a DRI2Buffer value. -func DRI2BufferRead(buf []byte, v *DRI2Buffer) int { - b := 0 - - v.Attachment = xgb.Get32(buf[b:]) - b += 4 - - v.Name = xgb.Get32(buf[b:]) - b += 4 - - v.Pitch = xgb.Get32(buf[b:]) - b += 4 - - v.Cpp = xgb.Get32(buf[b:]) - b += 4 - - v.Flags = xgb.Get32(buf[b:]) - b += 4 - - return b -} - -// DRI2BufferReadList reads a byte slice into a list of DRI2Buffer values. -func DRI2BufferReadList(buf []byte, dest []DRI2Buffer) int { - b := 0 - for i := 0; i < len(dest); i++ { - dest[i] = DRI2Buffer{} - b += DRI2BufferRead(buf[b:], &dest[i]) - } - return xgb.Pad(b) -} - -// Bytes writes a DRI2Buffer value to a byte slice. -func (v DRI2Buffer) Bytes() []byte { - buf := make([]byte, 20) - b := 0 - - xgb.Put32(buf[b:], v.Attachment) - b += 4 - - xgb.Put32(buf[b:], v.Name) - b += 4 - - xgb.Put32(buf[b:], v.Pitch) - b += 4 - - xgb.Put32(buf[b:], v.Cpp) - b += 4 - - xgb.Put32(buf[b:], v.Flags) - b += 4 - - return buf -} - -// DRI2BufferListBytes writes a list of DRI2Buffer values to a byte slice. -func DRI2BufferListBytes(buf []byte, list []DRI2Buffer) int { - b := 0 - var structBytes []byte - for _, item := range list { - structBytes = item.Bytes() - copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) - } - return b -} - type AttachFormat struct { Attachment uint32 Format uint32 @@ -218,6 +94,20 @@ func AttachFormatListBytes(buf []byte, list []AttachFormat) int { return b } +const ( + AttachmentBufferFrontLeft = 0 + AttachmentBufferBackLeft = 1 + AttachmentBufferFrontRight = 2 + AttachmentBufferBackRight = 3 + AttachmentBufferDepth = 4 + AttachmentBufferStencil = 5 + AttachmentBufferAccum = 6 + AttachmentBufferFakeFrontLeft = 7 + AttachmentBufferFakeFrontRight = 8 + AttachmentBufferDepthStencil = 9 + AttachmentBufferHiz = 10 +) + // BufferSwapComplete is the event number for a BufferSwapCompleteEvent. const BufferSwapComplete = 0 @@ -334,6 +224,92 @@ func init() { xgb.NewExtEventFuncs["DRI2"][0] = BufferSwapCompleteEventNew } +type DRI2Buffer struct { + Attachment uint32 + Name uint32 + Pitch uint32 + Cpp uint32 + Flags uint32 +} + +// DRI2BufferRead reads a byte slice into a DRI2Buffer value. +func DRI2BufferRead(buf []byte, v *DRI2Buffer) int { + b := 0 + + v.Attachment = xgb.Get32(buf[b:]) + b += 4 + + v.Name = xgb.Get32(buf[b:]) + b += 4 + + v.Pitch = xgb.Get32(buf[b:]) + b += 4 + + v.Cpp = xgb.Get32(buf[b:]) + b += 4 + + v.Flags = xgb.Get32(buf[b:]) + b += 4 + + return b +} + +// DRI2BufferReadList reads a byte slice into a list of DRI2Buffer values. +func DRI2BufferReadList(buf []byte, dest []DRI2Buffer) int { + b := 0 + for i := 0; i < len(dest); i++ { + dest[i] = DRI2Buffer{} + b += DRI2BufferRead(buf[b:], &dest[i]) + } + return xgb.Pad(b) +} + +// Bytes writes a DRI2Buffer value to a byte slice. +func (v DRI2Buffer) Bytes() []byte { + buf := make([]byte, 20) + b := 0 + + xgb.Put32(buf[b:], v.Attachment) + b += 4 + + xgb.Put32(buf[b:], v.Name) + b += 4 + + xgb.Put32(buf[b:], v.Pitch) + b += 4 + + xgb.Put32(buf[b:], v.Cpp) + b += 4 + + xgb.Put32(buf[b:], v.Flags) + b += 4 + + return buf +} + +// DRI2BufferListBytes writes a list of DRI2Buffer values to a byte slice. +func DRI2BufferListBytes(buf []byte, list []DRI2Buffer) int { + b := 0 + var structBytes []byte + for _, item := range list { + structBytes = item.Bytes() + copy(buf[b:], structBytes) + b += xgb.Pad(len(structBytes)) + } + return b +} + +const ( + DriverTypeDri = 0 + DriverTypeVdpau = 1 +) + +const ( + EventTypeExchangeComplete = 1 + EventTypeBlitComplete = 2 + EventTypeFlipComplete = 3 +) + // InvalidateBuffers is the event number for a InvalidateBuffersEvent. const InvalidateBuffers = 1 @@ -397,44 +373,67 @@ func init() { xgb.NewExtEventFuncs["DRI2"][1] = InvalidateBuffersEventNew } -// QueryVersionCookie is a cookie used only for QueryVersion requests. -type QueryVersionCookie struct { +// 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' + +// AuthenticateCookie is a cookie used only for Authenticate requests. +type AuthenticateCookie 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, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { +// Authenticate sends a checked request. +// If an error occurs, it will be returned with the reply by calling AuthenticateCookie.Reply() +func Authenticate(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'Authenticate' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(authenticateRequest(c, Window, Magic), cookie) + return AuthenticateCookie{cookie} } -// QueryVersionUnchecked sends an unchecked request. +// AuthenticateUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { +func AuthenticateUnchecked(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'Authenticate' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) - return QueryVersionCookie{cookie} + c.NewRequest(authenticateRequest(c, Window, Magic), cookie) + return AuthenticateCookie{cookie} } -// QueryVersionReply represents the data returned from a QueryVersion request. -type QueryVersionReply struct { +// AuthenticateReply represents the data returned from a Authenticate request. +type AuthenticateReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - MajorVersion uint32 - MinorVersion uint32 + Authenticated uint32 } -// Reply blocks and returns the reply data for a QueryVersion request. -func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { +// Reply blocks and returns the reply data for a Authenticate request. +func (cook AuthenticateCookie) Reply() (*AuthenticateReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -442,12 +441,12 @@ func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { if buf == nil { return nil, nil } - return queryVersionReply(buf), nil + return authenticateReply(buf), nil } -// queryVersionReply reads a byte slice into a QueryVersionReply value. -func queryVersionReply(buf []byte) *QueryVersionReply { - v := new(QueryVersionReply) +// authenticateReply reads a byte slice into a AuthenticateReply value. +func authenticateReply(buf []byte) *AuthenticateReply { + v := new(AuthenticateReply) b := 1 // skip reply determinant b += 1 // padding @@ -458,18 +457,15 @@ func queryVersionReply(buf []byte) *QueryVersionReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.MajorVersion = xgb.Get32(buf[b:]) - b += 4 - - v.MinorVersion = xgb.Get32(buf[b:]) + v.Authenticated = 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, MajorVersion uint32, MinorVersion uint32) []byte { +// Write request to wire for Authenticate +// authenticateRequest writes a Authenticate request to a byte slice. +func authenticateRequest(c *xgb.Conn, Window xproto.Window, Magic uint32) []byte { size := 12 b := 0 buf := make([]byte, size) @@ -477,16 +473,16 @@ func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) buf[b] = c.Extensions["DRI2"] b += 1 - buf[b] = 0 // request opcode + 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:], MajorVersion) + xgb.Put32(buf[b:], uint32(Window)) b += 4 - xgb.Put32(buf[b:], MinorVersion) + xgb.Put32(buf[b:], Magic) b += 4 return buf @@ -611,43 +607,42 @@ func connectRequest(c *xgb.Conn, Window xproto.Window, DriverType uint32) []byte return buf } -// AuthenticateCookie is a cookie used only for Authenticate requests. -type AuthenticateCookie struct { +// CopyRegionCookie is a cookie used only for CopyRegion requests. +type CopyRegionCookie struct { *xgb.Cookie } -// Authenticate sends a checked request. -// If an error occurs, it will be returned with the reply by calling AuthenticateCookie.Reply() -func Authenticate(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { +// CopyRegion sends a checked request. +// If an error occurs, it will be returned with the reply by calling CopyRegionCookie.Reply() +func CopyRegion(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'Authenticate' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(authenticateRequest(c, Window, Magic), cookie) - return AuthenticateCookie{cookie} + c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) + return CopyRegionCookie{cookie} } -// AuthenticateUnchecked sends an unchecked request. +// CopyRegionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func AuthenticateUnchecked(c *xgb.Conn, Window xproto.Window, Magic uint32) AuthenticateCookie { +func CopyRegionUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'Authenticate' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(authenticateRequest(c, Window, Magic), cookie) - return AuthenticateCookie{cookie} + c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) + return CopyRegionCookie{cookie} } -// AuthenticateReply represents the data returned from a Authenticate request. -type AuthenticateReply struct { +// CopyRegionReply represents the data returned from a CopyRegion request. +type CopyRegionReply 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 Authenticate request. -func (cook AuthenticateCookie) Reply() (*AuthenticateReply, error) { +// Reply blocks and returns the reply data for a CopyRegion request. +func (cook CopyRegionCookie) Reply() (*CopyRegionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -655,12 +650,12 @@ func (cook AuthenticateCookie) Reply() (*AuthenticateReply, error) { if buf == nil { return nil, nil } - return authenticateReply(buf), nil + return copyRegionReply(buf), nil } -// authenticateReply reads a byte slice into a AuthenticateReply value. -func authenticateReply(buf []byte) *AuthenticateReply { - v := new(AuthenticateReply) +// copyRegionReply reads a byte slice into a CopyRegionReply value. +func copyRegionReply(buf []byte) *CopyRegionReply { + v := new(CopyRegionReply) b := 1 // skip reply determinant b += 1 // padding @@ -671,32 +666,35 @@ func authenticateReply(buf []byte) *AuthenticateReply { 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 Authenticate -// authenticateRequest writes a Authenticate request to a byte slice. -func authenticateRequest(c *xgb.Conn, Window xproto.Window, Magic uint32) []byte { - size := 12 + +// Write request to wire for CopyRegion +// copyRegionRequest writes a CopyRegion request to a byte slice. +func copyRegionRequest(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) []byte { + size := 20 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DRI2"] b += 1 - buf[b] = 2 // request opcode + 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:], uint32(Window)) + xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], Magic) + xgb.Put32(buf[b:], Region) + b += 4 + + xgb.Put32(buf[b:], Dest) + b += 4 + + xgb.Put32(buf[b:], Src) b += 4 return buf @@ -924,42 +922,47 @@ func getBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Atta return buf } -// CopyRegionCookie is a cookie used only for CopyRegion requests. -type CopyRegionCookie struct { +// GetBuffersWithFormatCookie is a cookie used only for GetBuffersWithFormat requests. +type GetBuffersWithFormatCookie struct { *xgb.Cookie } -// CopyRegion sends a checked request. -// If an error occurs, it will be returned with the reply by calling CopyRegionCookie.Reply() -func CopyRegion(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { +// GetBuffersWithFormat sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetBuffersWithFormatCookie.Reply() +func GetBuffersWithFormat(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'GetBuffersWithFormat' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) - return CopyRegionCookie{cookie} + c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) + return GetBuffersWithFormatCookie{cookie} } -// CopyRegionUnchecked sends an unchecked request. +// GetBuffersWithFormatUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func CopyRegionUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) CopyRegionCookie { +func GetBuffersWithFormatUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'CopyRegion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'GetBuffersWithFormat' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(copyRegionRequest(c, Drawable, Region, Dest, Src), cookie) - return CopyRegionCookie{cookie} + c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) + return GetBuffersWithFormatCookie{cookie} } -// CopyRegionReply represents the data returned from a CopyRegion request. -type CopyRegionReply struct { +// GetBuffersWithFormatReply represents the data returned from a GetBuffersWithFormat request. +type GetBuffersWithFormatReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes + Width uint32 + Height uint32 + Count uint32 + // padding: 12 bytes + Buffers []DRI2Buffer // size: xgb.Pad((int(Count) * 20)) } -// Reply blocks and returns the reply data for a CopyRegion request. -func (cook CopyRegionCookie) Reply() (*CopyRegionReply, error) { +// Reply blocks and returns the reply data for a GetBuffersWithFormat request. +func (cook GetBuffersWithFormatCookie) Reply() (*GetBuffersWithFormatReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -967,12 +970,121 @@ func (cook CopyRegionCookie) Reply() (*CopyRegionReply, error) { if buf == nil { return nil, nil } - return copyRegionReply(buf), nil + return getBuffersWithFormatReply(buf), nil } -// copyRegionReply reads a byte slice into a CopyRegionReply value. -func copyRegionReply(buf []byte) *CopyRegionReply { - v := new(CopyRegionReply) +// getBuffersWithFormatReply reads a byte slice into a GetBuffersWithFormatReply value. +func getBuffersWithFormatReply(buf []byte) *GetBuffersWithFormatReply { + v := new(GetBuffersWithFormatReply) + 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.Width = xgb.Get32(buf[b:]) + b += 4 + + v.Height = xgb.Get32(buf[b:]) + b += 4 + + v.Count = xgb.Get32(buf[b:]) + b += 4 + + b += 12 // padding + + v.Buffers = make([]DRI2Buffer, v.Count) + b += DRI2BufferReadList(buf[b:], v.Buffers) + + return v +} + +// Write request to wire for GetBuffersWithFormat +// getBuffersWithFormatRequest writes a GetBuffersWithFormat request to a byte slice. +func getBuffersWithFormatRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) []byte { + size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 8)))) + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + 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:], uint32(Drawable)) + b += 4 + + xgb.Put32(buf[b:], Count) + b += 4 + + b += AttachFormatListBytes(buf[b:], Attachments) + + return buf +} + +// GetMSCCookie is a cookie used only for GetMSC requests. +type GetMSCCookie struct { + *xgb.Cookie +} + +// GetMSC sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetMSCCookie.Reply() +func GetMSC(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { + if _, ok := c.Extensions["DRI2"]; !ok { + panic("Cannot issue request 'GetMSC' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getMSCRequest(c, Drawable), cookie) + return GetMSCCookie{cookie} +} + +// GetMSCUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetMSCUnchecked(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { + if _, ok := c.Extensions["DRI2"]; !ok { + panic("Cannot issue request 'GetMSC' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getMSCRequest(c, Drawable), cookie) + return GetMSCCookie{cookie} +} + +// GetMSCReply represents the data returned from a GetMSC request. +type GetMSCReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + UstHi uint32 + UstLo uint32 + MscHi uint32 + MscLo uint32 + SbcHi uint32 + SbcLo uint32 +} + +// Reply blocks and returns the reply data for a GetMSC request. +func (cook GetMSCCookie) Reply() (*GetMSCReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getMSCReply(buf), nil +} + +// getMSCReply reads a byte slice into a GetMSCReply value. +func getMSCReply(buf []byte) *GetMSCReply { + v := new(GetMSCReply) b := 1 // skip reply determinant b += 1 // padding @@ -980,23 +1092,138 @@ func copyRegionReply(buf []byte) *CopyRegionReply { v.Sequence = xgb.Get16(buf[b:]) b += 2 - v.Length = xgb.Get32(buf[b:]) // 4-byte units + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.UstHi = xgb.Get32(buf[b:]) + b += 4 + + v.UstLo = xgb.Get32(buf[b:]) + b += 4 + + v.MscHi = xgb.Get32(buf[b:]) + b += 4 + + v.MscLo = xgb.Get32(buf[b:]) + b += 4 + + v.SbcHi = xgb.Get32(buf[b:]) + b += 4 + + v.SbcLo = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for GetMSC +// getMSCRequest writes a GetMSC request to a byte slice. +func getMSCRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DRI2"] + 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:], uint32(Drawable)) + b += 4 + + return buf +} + +// GetParamCookie is a cookie used only for GetParam requests. +type GetParamCookie struct { + *xgb.Cookie +} + +// GetParam sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetParamCookie.Reply() +func GetParam(c *xgb.Conn, Drawable xproto.Drawable, Param uint32) GetParamCookie { + if _, ok := c.Extensions["DRI2"]; !ok { + panic("Cannot issue request 'GetParam' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, true) + c.NewRequest(getParamRequest(c, Drawable, Param), cookie) + return GetParamCookie{cookie} +} + +// GetParamUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetParamUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Param uint32) GetParamCookie { + if _, ok := c.Extensions["DRI2"]; !ok { + panic("Cannot issue request 'GetParam' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, true) + c.NewRequest(getParamRequest(c, Drawable, Param), cookie) + return GetParamCookie{cookie} +} + +// GetParamReply represents the data returned from a GetParam request. +type GetParamReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + IsParamRecognized bool + ValueHi uint32 + ValueLo uint32 +} + +// Reply blocks and returns the reply data for a GetParam request. +func (cook GetParamCookie) Reply() (*GetParamReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getParamReply(buf), nil +} + +// getParamReply reads a byte slice into a GetParamReply value. +func getParamReply(buf []byte) *GetParamReply { + v := new(GetParamReply) + b := 1 // skip reply determinant + + if buf[b] == 1 { + v.IsParamRecognized = true + } else { + v.IsParamRecognized = false + } + b += 1 + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ValueHi = xgb.Get32(buf[b:]) + b += 4 + + v.ValueLo = xgb.Get32(buf[b:]) b += 4 return v } -// Write request to wire for CopyRegion -// copyRegionRequest writes a CopyRegion request to a byte slice. -func copyRegionRequest(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Dest uint32, Src uint32) []byte { - size := 20 +// Write request to wire for GetParam +// getParamRequest writes a GetParam request to a byte slice. +func getParamRequest(c *xgb.Conn, Drawable xproto.Drawable, Param uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DRI2"] b += 1 - buf[b] = 6 // request opcode + buf[b] = 13 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1005,59 +1232,50 @@ func copyRegionRequest(c *xgb.Conn, Drawable xproto.Drawable, Region uint32, Des xgb.Put32(buf[b:], uint32(Drawable)) b += 4 - xgb.Put32(buf[b:], Region) - b += 4 - - xgb.Put32(buf[b:], Dest) - b += 4 - - xgb.Put32(buf[b:], Src) + xgb.Put32(buf[b:], Param) b += 4 return buf } -// GetBuffersWithFormatCookie is a cookie used only for GetBuffersWithFormat requests. -type GetBuffersWithFormatCookie struct { +// QueryVersionCookie is a cookie used only for QueryVersion requests. +type QueryVersionCookie struct { *xgb.Cookie } -// GetBuffersWithFormat sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetBuffersWithFormatCookie.Reply() -func GetBuffersWithFormat(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { +// 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, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'GetBuffersWithFormat' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) - return GetBuffersWithFormatCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetBuffersWithFormatUnchecked sends an unchecked request. +// QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetBuffersWithFormatUnchecked(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) GetBuffersWithFormatCookie { +func QueryVersionUnchecked(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) QueryVersionCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'GetBuffersWithFormat' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getBuffersWithFormatRequest(c, Drawable, Count, Attachments), cookie) - return GetBuffersWithFormatCookie{cookie} + c.NewRequest(queryVersionRequest(c, MajorVersion, MinorVersion), cookie) + return QueryVersionCookie{cookie} } -// GetBuffersWithFormatReply represents the data returned from a GetBuffersWithFormat request. -type GetBuffersWithFormatReply struct { +// 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 - Width uint32 - Height uint32 - Count uint32 - // padding: 12 bytes - Buffers []DRI2Buffer // size: xgb.Pad((int(Count) * 20)) + MajorVersion uint32 + MinorVersion uint32 } -// Reply blocks and returns the reply data for a GetBuffersWithFormat request. -func (cook GetBuffersWithFormatCookie) Reply() (*GetBuffersWithFormatReply, error) { +// 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 @@ -1065,12 +1283,12 @@ func (cook GetBuffersWithFormatCookie) Reply() (*GetBuffersWithFormatReply, erro if buf == nil { return nil, nil } - return getBuffersWithFormatReply(buf), nil + return queryVersionReply(buf), nil } -// getBuffersWithFormatReply reads a byte slice into a GetBuffersWithFormatReply value. -func getBuffersWithFormatReply(buf []byte) *GetBuffersWithFormatReply { - v := new(GetBuffersWithFormatReply) +// 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 @@ -1081,47 +1299,37 @@ func getBuffersWithFormatReply(buf []byte) *GetBuffersWithFormatReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.Width = xgb.Get32(buf[b:]) - b += 4 - - v.Height = xgb.Get32(buf[b:]) + v.MajorVersion = xgb.Get32(buf[b:]) b += 4 - v.Count = xgb.Get32(buf[b:]) + v.MinorVersion = xgb.Get32(buf[b:]) b += 4 - b += 12 // padding - - v.Buffers = make([]DRI2Buffer, v.Count) - b += DRI2BufferReadList(buf[b:], v.Buffers) - return v } -// Write request to wire for GetBuffersWithFormat -// getBuffersWithFormatRequest writes a GetBuffersWithFormat request to a byte slice. -func getBuffersWithFormatRequest(c *xgb.Conn, Drawable xproto.Drawable, Count uint32, Attachments []AttachFormat) []byte { - size := xgb.Pad((12 + xgb.Pad((len(Attachments) * 8)))) +// Write request to wire for QueryVersion +// queryVersionRequest writes a QueryVersion request to a byte slice. +func queryVersionRequest(c *xgb.Conn, MajorVersion uint32, MinorVersion uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DRI2"] b += 1 - buf[b] = 7 // request opcode + buf[b] = 0 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], uint32(Drawable)) + xgb.Put32(buf[b:], MajorVersion) b += 4 - xgb.Put32(buf[b:], Count) + xgb.Put32(buf[b:], MinorVersion) b += 4 - b += AttachFormatListBytes(buf[b:], Attachments) - return buf } @@ -1235,103 +1443,50 @@ func swapBuffersRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetMscHi uint3 return buf } -// GetMSCCookie is a cookie used only for GetMSC requests. -type GetMSCCookie struct { +// SwapIntervalCookie is a cookie used only for SwapInterval requests. +type SwapIntervalCookie struct { *xgb.Cookie } -// GetMSC sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetMSCCookie.Reply() -func GetMSC(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { - if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'GetMSC' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getMSCRequest(c, Drawable), cookie) - return GetMSCCookie{cookie} -} - -// GetMSCUnchecked sends an unchecked request. +// SwapInterval sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetMSCUnchecked(c *xgb.Conn, Drawable xproto.Drawable) GetMSCCookie { +func SwapInterval(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'GetMSC' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") + panic("Cannot issue request 'SwapInterval' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getMSCRequest(c, Drawable), cookie) - return GetMSCCookie{cookie} -} - -// GetMSCReply represents the data returned from a GetMSC request. -type GetMSCReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - UstHi uint32 - UstLo uint32 - MscHi uint32 - MscLo uint32 - SbcHi uint32 - SbcLo uint32 + cookie := c.NewCookie(false, false) + c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) + return SwapIntervalCookie{cookie} } -// Reply blocks and returns the reply data for a GetMSC request. -func (cook GetMSCCookie) Reply() (*GetMSCReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// SwapIntervalChecked sends a checked request. +// If an error occurs, it can be retrieved using SwapIntervalCookie.Check() +func SwapIntervalChecked(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { + if _, ok := c.Extensions["DRI2"]; !ok { + panic("Cannot issue request 'SwapInterval' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") } - return getMSCReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) + return SwapIntervalCookie{cookie} } -// getMSCReply reads a byte slice into a GetMSCReply value. -func getMSCReply(buf []byte) *GetMSCReply { - v := new(GetMSCReply) - 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.UstHi = xgb.Get32(buf[b:]) - b += 4 - - v.UstLo = xgb.Get32(buf[b:]) - b += 4 - - v.MscHi = xgb.Get32(buf[b:]) - b += 4 - - v.MscLo = xgb.Get32(buf[b:]) - b += 4 - - v.SbcHi = xgb.Get32(buf[b:]) - b += 4 - - v.SbcLo = xgb.Get32(buf[b:]) - b += 4 - - return v +// 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 SwapIntervalCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetMSC -// getMSCRequest writes a GetMSC request to a byte slice. -func getMSCRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { - size := 8 +// Write request to wire for SwapInterval +// swapIntervalRequest writes a SwapInterval request to a byte slice. +func swapIntervalRequest(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) []byte { + size := 12 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DRI2"] b += 1 - buf[b] = 9 // request opcode + buf[b] = 12 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -1340,6 +1495,9 @@ func getMSCRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte { xgb.Put32(buf[b:], uint32(Drawable)) b += 4 + xgb.Put32(buf[b:], Interval) + b += 4 + return buf } @@ -1582,61 +1740,3 @@ func waitSBCRequest(c *xgb.Conn, Drawable xproto.Drawable, TargetSbcHi uint32, T return buf } - -// SwapIntervalCookie is a cookie used only for SwapInterval requests. -type SwapIntervalCookie struct { - *xgb.Cookie -} - -// SwapInterval sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SwapInterval(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { - if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'SwapInterval' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, false) - c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) - return SwapIntervalCookie{cookie} -} - -// SwapIntervalChecked sends a checked request. -// If an error occurs, it can be retrieved using SwapIntervalCookie.Check() -func SwapIntervalChecked(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) SwapIntervalCookie { - if _, ok := c.Extensions["DRI2"]; !ok { - panic("Cannot issue request 'SwapInterval' using the uninitialized extension 'DRI2'. dri2.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, false) - c.NewRequest(swapIntervalRequest(c, Drawable, Interval), cookie) - return SwapIntervalCookie{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 SwapIntervalCookie) Check() error { - return cook.Cookie.Check() -} - -// Write request to wire for SwapInterval -// swapIntervalRequest writes a SwapInterval request to a byte slice. -func swapIntervalRequest(c *xgb.Conn, Drawable xproto.Drawable, Interval uint32) []byte { - size := 12 - b := 0 - buf := make([]byte, size) - - buf[b] = c.Extensions["DRI2"] - b += 1 - - buf[b] = 12 // request opcode - b += 1 - - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 - - xgb.Put32(buf[b:], uint32(Drawable)) - b += 4 - - xgb.Put32(buf[b:], Interval) - b += 4 - - return buf -} -- cgit v1.2.3