zorldo

Goofing around with Ebiten
git clone git://bsandro.tech/zorldo
Log | Files | Refs | README

render.go (113010B)


      1 // Package render is the X client API for the RENDER extension.
      2 package render
      3 
      4 // This file is automatically generated from render.xml. Edit at your peril!
      5 
      6 import (
      7 	"github.com/jezek/xgb"
      8 
      9 	"github.com/jezek/xgb/xproto"
     10 )
     11 
     12 // Init must be called before using the RENDER extension.
     13 func Init(c *xgb.Conn) error {
     14 	reply, err := xproto.QueryExtension(c, 6, "RENDER").Reply()
     15 	switch {
     16 	case err != nil:
     17 		return err
     18 	case !reply.Present:
     19 		return xgb.Errorf("No extension named RENDER could be found on on the server.")
     20 	}
     21 
     22 	c.ExtLock.Lock()
     23 	c.Extensions["RENDER"] = reply.MajorOpcode
     24 	c.ExtLock.Unlock()
     25 	for evNum, fun := range xgb.NewExtEventFuncs["RENDER"] {
     26 		xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
     27 	}
     28 	for errNum, fun := range xgb.NewExtErrorFuncs["RENDER"] {
     29 		xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
     30 	}
     31 	return nil
     32 }
     33 
     34 func init() {
     35 	xgb.NewExtEventFuncs["RENDER"] = make(map[int]xgb.NewEventFun)
     36 	xgb.NewExtErrorFuncs["RENDER"] = make(map[int]xgb.NewErrorFun)
     37 }
     38 
     39 type Animcursorelt struct {
     40 	Cursor xproto.Cursor
     41 	Delay  uint32
     42 }
     43 
     44 // AnimcursoreltRead reads a byte slice into a Animcursorelt value.
     45 func AnimcursoreltRead(buf []byte, v *Animcursorelt) int {
     46 	b := 0
     47 
     48 	v.Cursor = xproto.Cursor(xgb.Get32(buf[b:]))
     49 	b += 4
     50 
     51 	v.Delay = xgb.Get32(buf[b:])
     52 	b += 4
     53 
     54 	return b
     55 }
     56 
     57 // AnimcursoreltReadList reads a byte slice into a list of Animcursorelt values.
     58 func AnimcursoreltReadList(buf []byte, dest []Animcursorelt) int {
     59 	b := 0
     60 	for i := 0; i < len(dest); i++ {
     61 		dest[i] = Animcursorelt{}
     62 		b += AnimcursoreltRead(buf[b:], &dest[i])
     63 	}
     64 	return xgb.Pad(b)
     65 }
     66 
     67 // Bytes writes a Animcursorelt value to a byte slice.
     68 func (v Animcursorelt) Bytes() []byte {
     69 	buf := make([]byte, 8)
     70 	b := 0
     71 
     72 	xgb.Put32(buf[b:], uint32(v.Cursor))
     73 	b += 4
     74 
     75 	xgb.Put32(buf[b:], v.Delay)
     76 	b += 4
     77 
     78 	return buf[:b]
     79 }
     80 
     81 // AnimcursoreltListBytes writes a list of Animcursorelt values to a byte slice.
     82 func AnimcursoreltListBytes(buf []byte, list []Animcursorelt) int {
     83 	b := 0
     84 	var structBytes []byte
     85 	for _, item := range list {
     86 		structBytes = item.Bytes()
     87 		copy(buf[b:], structBytes)
     88 		b += len(structBytes)
     89 	}
     90 	return xgb.Pad(b)
     91 }
     92 
     93 type Color struct {
     94 	Red   uint16
     95 	Green uint16
     96 	Blue  uint16
     97 	Alpha uint16
     98 }
     99 
    100 // ColorRead reads a byte slice into a Color value.
    101 func ColorRead(buf []byte, v *Color) int {
    102 	b := 0
    103 
    104 	v.Red = xgb.Get16(buf[b:])
    105 	b += 2
    106 
    107 	v.Green = xgb.Get16(buf[b:])
    108 	b += 2
    109 
    110 	v.Blue = xgb.Get16(buf[b:])
    111 	b += 2
    112 
    113 	v.Alpha = xgb.Get16(buf[b:])
    114 	b += 2
    115 
    116 	return b
    117 }
    118 
    119 // ColorReadList reads a byte slice into a list of Color values.
    120 func ColorReadList(buf []byte, dest []Color) int {
    121 	b := 0
    122 	for i := 0; i < len(dest); i++ {
    123 		dest[i] = Color{}
    124 		b += ColorRead(buf[b:], &dest[i])
    125 	}
    126 	return xgb.Pad(b)
    127 }
    128 
    129 // Bytes writes a Color value to a byte slice.
    130 func (v Color) Bytes() []byte {
    131 	buf := make([]byte, 8)
    132 	b := 0
    133 
    134 	xgb.Put16(buf[b:], v.Red)
    135 	b += 2
    136 
    137 	xgb.Put16(buf[b:], v.Green)
    138 	b += 2
    139 
    140 	xgb.Put16(buf[b:], v.Blue)
    141 	b += 2
    142 
    143 	xgb.Put16(buf[b:], v.Alpha)
    144 	b += 2
    145 
    146 	return buf[:b]
    147 }
    148 
    149 // ColorListBytes writes a list of Color values to a byte slice.
    150 func ColorListBytes(buf []byte, list []Color) int {
    151 	b := 0
    152 	var structBytes []byte
    153 	for _, item := range list {
    154 		structBytes = item.Bytes()
    155 		copy(buf[b:], structBytes)
    156 		b += len(structBytes)
    157 	}
    158 	return xgb.Pad(b)
    159 }
    160 
    161 const (
    162 	CpRepeat           = 1
    163 	CpAlphaMap         = 2
    164 	CpAlphaXOrigin     = 4
    165 	CpAlphaYOrigin     = 8
    166 	CpClipXOrigin      = 16
    167 	CpClipYOrigin      = 32
    168 	CpClipMask         = 64
    169 	CpGraphicsExposure = 128
    170 	CpSubwindowMode    = 256
    171 	CpPolyEdge         = 512
    172 	CpPolyMode         = 1024
    173 	CpDither           = 2048
    174 	CpComponentAlpha   = 4096
    175 )
    176 
    177 type Directformat struct {
    178 	RedShift   uint16
    179 	RedMask    uint16
    180 	GreenShift uint16
    181 	GreenMask  uint16
    182 	BlueShift  uint16
    183 	BlueMask   uint16
    184 	AlphaShift uint16
    185 	AlphaMask  uint16
    186 }
    187 
    188 // DirectformatRead reads a byte slice into a Directformat value.
    189 func DirectformatRead(buf []byte, v *Directformat) int {
    190 	b := 0
    191 
    192 	v.RedShift = xgb.Get16(buf[b:])
    193 	b += 2
    194 
    195 	v.RedMask = xgb.Get16(buf[b:])
    196 	b += 2
    197 
    198 	v.GreenShift = xgb.Get16(buf[b:])
    199 	b += 2
    200 
    201 	v.GreenMask = xgb.Get16(buf[b:])
    202 	b += 2
    203 
    204 	v.BlueShift = xgb.Get16(buf[b:])
    205 	b += 2
    206 
    207 	v.BlueMask = xgb.Get16(buf[b:])
    208 	b += 2
    209 
    210 	v.AlphaShift = xgb.Get16(buf[b:])
    211 	b += 2
    212 
    213 	v.AlphaMask = xgb.Get16(buf[b:])
    214 	b += 2
    215 
    216 	return b
    217 }
    218 
    219 // DirectformatReadList reads a byte slice into a list of Directformat values.
    220 func DirectformatReadList(buf []byte, dest []Directformat) int {
    221 	b := 0
    222 	for i := 0; i < len(dest); i++ {
    223 		dest[i] = Directformat{}
    224 		b += DirectformatRead(buf[b:], &dest[i])
    225 	}
    226 	return xgb.Pad(b)
    227 }
    228 
    229 // Bytes writes a Directformat value to a byte slice.
    230 func (v Directformat) Bytes() []byte {
    231 	buf := make([]byte, 16)
    232 	b := 0
    233 
    234 	xgb.Put16(buf[b:], v.RedShift)
    235 	b += 2
    236 
    237 	xgb.Put16(buf[b:], v.RedMask)
    238 	b += 2
    239 
    240 	xgb.Put16(buf[b:], v.GreenShift)
    241 	b += 2
    242 
    243 	xgb.Put16(buf[b:], v.GreenMask)
    244 	b += 2
    245 
    246 	xgb.Put16(buf[b:], v.BlueShift)
    247 	b += 2
    248 
    249 	xgb.Put16(buf[b:], v.BlueMask)
    250 	b += 2
    251 
    252 	xgb.Put16(buf[b:], v.AlphaShift)
    253 	b += 2
    254 
    255 	xgb.Put16(buf[b:], v.AlphaMask)
    256 	b += 2
    257 
    258 	return buf[:b]
    259 }
    260 
    261 // DirectformatListBytes writes a list of Directformat values to a byte slice.
    262 func DirectformatListBytes(buf []byte, list []Directformat) int {
    263 	b := 0
    264 	var structBytes []byte
    265 	for _, item := range list {
    266 		structBytes = item.Bytes()
    267 		copy(buf[b:], structBytes)
    268 		b += len(structBytes)
    269 	}
    270 	return xgb.Pad(b)
    271 }
    272 
    273 type Fixed int32
    274 
    275 type Glyph uint32
    276 
    277 // BadGlyph is the error number for a BadGlyph.
    278 const BadGlyph = 4
    279 
    280 type GlyphError struct {
    281 	Sequence uint16
    282 	NiceName string
    283 }
    284 
    285 // GlyphErrorNew constructs a GlyphError value that implements xgb.Error from a byte slice.
    286 func GlyphErrorNew(buf []byte) xgb.Error {
    287 	v := GlyphError{}
    288 	v.NiceName = "Glyph"
    289 
    290 	b := 1 // skip error determinant
    291 	b += 1 // don't read error number
    292 
    293 	v.Sequence = xgb.Get16(buf[b:])
    294 	b += 2
    295 
    296 	return v
    297 }
    298 
    299 // SequenceId returns the sequence id attached to the BadGlyph error.
    300 // This is mostly used internally.
    301 func (err GlyphError) SequenceId() uint16 {
    302 	return err.Sequence
    303 }
    304 
    305 // BadId returns the 'BadValue' number if one exists for the BadGlyph error. If no bad value exists, 0 is returned.
    306 func (err GlyphError) BadId() uint32 {
    307 	return 0
    308 }
    309 
    310 // Error returns a rudimentary string representation of the BadGlyph error.
    311 
    312 func (err GlyphError) Error() string {
    313 	fieldVals := make([]string, 0, 0)
    314 	fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
    315 	fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
    316 	return "BadGlyph {" + xgb.StringsJoin(fieldVals, ", ") + "}"
    317 }
    318 
    319 func init() {
    320 	xgb.NewExtErrorFuncs["RENDER"][4] = GlyphErrorNew
    321 }
    322 
    323 // BadGlyphSet is the error number for a BadGlyphSet.
    324 const BadGlyphSet = 3
    325 
    326 type GlyphSetError struct {
    327 	Sequence uint16
    328 	NiceName string
    329 }
    330 
    331 // GlyphSetErrorNew constructs a GlyphSetError value that implements xgb.Error from a byte slice.
    332 func GlyphSetErrorNew(buf []byte) xgb.Error {
    333 	v := GlyphSetError{}
    334 	v.NiceName = "GlyphSet"
    335 
    336 	b := 1 // skip error determinant
    337 	b += 1 // don't read error number
    338 
    339 	v.Sequence = xgb.Get16(buf[b:])
    340 	b += 2
    341 
    342 	return v
    343 }
    344 
    345 // SequenceId returns the sequence id attached to the BadGlyphSet error.
    346 // This is mostly used internally.
    347 func (err GlyphSetError) SequenceId() uint16 {
    348 	return err.Sequence
    349 }
    350 
    351 // BadId returns the 'BadValue' number if one exists for the BadGlyphSet error. If no bad value exists, 0 is returned.
    352 func (err GlyphSetError) BadId() uint32 {
    353 	return 0
    354 }
    355 
    356 // Error returns a rudimentary string representation of the BadGlyphSet error.
    357 
    358 func (err GlyphSetError) Error() string {
    359 	fieldVals := make([]string, 0, 0)
    360 	fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
    361 	fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
    362 	return "BadGlyphSet {" + xgb.StringsJoin(fieldVals, ", ") + "}"
    363 }
    364 
    365 func init() {
    366 	xgb.NewExtErrorFuncs["RENDER"][3] = GlyphSetErrorNew
    367 }
    368 
    369 type Glyphinfo struct {
    370 	Width  uint16
    371 	Height uint16
    372 	X      int16
    373 	Y      int16
    374 	XOff   int16
    375 	YOff   int16
    376 }
    377 
    378 // GlyphinfoRead reads a byte slice into a Glyphinfo value.
    379 func GlyphinfoRead(buf []byte, v *Glyphinfo) int {
    380 	b := 0
    381 
    382 	v.Width = xgb.Get16(buf[b:])
    383 	b += 2
    384 
    385 	v.Height = xgb.Get16(buf[b:])
    386 	b += 2
    387 
    388 	v.X = int16(xgb.Get16(buf[b:]))
    389 	b += 2
    390 
    391 	v.Y = int16(xgb.Get16(buf[b:]))
    392 	b += 2
    393 
    394 	v.XOff = int16(xgb.Get16(buf[b:]))
    395 	b += 2
    396 
    397 	v.YOff = int16(xgb.Get16(buf[b:]))
    398 	b += 2
    399 
    400 	return b
    401 }
    402 
    403 // GlyphinfoReadList reads a byte slice into a list of Glyphinfo values.
    404 func GlyphinfoReadList(buf []byte, dest []Glyphinfo) int {
    405 	b := 0
    406 	for i := 0; i < len(dest); i++ {
    407 		dest[i] = Glyphinfo{}
    408 		b += GlyphinfoRead(buf[b:], &dest[i])
    409 	}
    410 	return xgb.Pad(b)
    411 }
    412 
    413 // Bytes writes a Glyphinfo value to a byte slice.
    414 func (v Glyphinfo) Bytes() []byte {
    415 	buf := make([]byte, 12)
    416 	b := 0
    417 
    418 	xgb.Put16(buf[b:], v.Width)
    419 	b += 2
    420 
    421 	xgb.Put16(buf[b:], v.Height)
    422 	b += 2
    423 
    424 	xgb.Put16(buf[b:], uint16(v.X))
    425 	b += 2
    426 
    427 	xgb.Put16(buf[b:], uint16(v.Y))
    428 	b += 2
    429 
    430 	xgb.Put16(buf[b:], uint16(v.XOff))
    431 	b += 2
    432 
    433 	xgb.Put16(buf[b:], uint16(v.YOff))
    434 	b += 2
    435 
    436 	return buf[:b]
    437 }
    438 
    439 // GlyphinfoListBytes writes a list of Glyphinfo values to a byte slice.
    440 func GlyphinfoListBytes(buf []byte, list []Glyphinfo) int {
    441 	b := 0
    442 	var structBytes []byte
    443 	for _, item := range list {
    444 		structBytes = item.Bytes()
    445 		copy(buf[b:], structBytes)
    446 		b += len(structBytes)
    447 	}
    448 	return xgb.Pad(b)
    449 }
    450 
    451 type Glyphset uint32
    452 
    453 func NewGlyphsetId(c *xgb.Conn) (Glyphset, error) {
    454 	id, err := c.NewId()
    455 	if err != nil {
    456 		return 0, err
    457 	}
    458 	return Glyphset(id), nil
    459 }
    460 
    461 type Indexvalue struct {
    462 	Pixel uint32
    463 	Red   uint16
    464 	Green uint16
    465 	Blue  uint16
    466 	Alpha uint16
    467 }
    468 
    469 // IndexvalueRead reads a byte slice into a Indexvalue value.
    470 func IndexvalueRead(buf []byte, v *Indexvalue) int {
    471 	b := 0
    472 
    473 	v.Pixel = xgb.Get32(buf[b:])
    474 	b += 4
    475 
    476 	v.Red = xgb.Get16(buf[b:])
    477 	b += 2
    478 
    479 	v.Green = xgb.Get16(buf[b:])
    480 	b += 2
    481 
    482 	v.Blue = xgb.Get16(buf[b:])
    483 	b += 2
    484 
    485 	v.Alpha = xgb.Get16(buf[b:])
    486 	b += 2
    487 
    488 	return b
    489 }
    490 
    491 // IndexvalueReadList reads a byte slice into a list of Indexvalue values.
    492 func IndexvalueReadList(buf []byte, dest []Indexvalue) int {
    493 	b := 0
    494 	for i := 0; i < len(dest); i++ {
    495 		dest[i] = Indexvalue{}
    496 		b += IndexvalueRead(buf[b:], &dest[i])
    497 	}
    498 	return xgb.Pad(b)
    499 }
    500 
    501 // Bytes writes a Indexvalue value to a byte slice.
    502 func (v Indexvalue) Bytes() []byte {
    503 	buf := make([]byte, 12)
    504 	b := 0
    505 
    506 	xgb.Put32(buf[b:], v.Pixel)
    507 	b += 4
    508 
    509 	xgb.Put16(buf[b:], v.Red)
    510 	b += 2
    511 
    512 	xgb.Put16(buf[b:], v.Green)
    513 	b += 2
    514 
    515 	xgb.Put16(buf[b:], v.Blue)
    516 	b += 2
    517 
    518 	xgb.Put16(buf[b:], v.Alpha)
    519 	b += 2
    520 
    521 	return buf[:b]
    522 }
    523 
    524 // IndexvalueListBytes writes a list of Indexvalue values to a byte slice.
    525 func IndexvalueListBytes(buf []byte, list []Indexvalue) int {
    526 	b := 0
    527 	var structBytes []byte
    528 	for _, item := range list {
    529 		structBytes = item.Bytes()
    530 		copy(buf[b:], structBytes)
    531 		b += len(structBytes)
    532 	}
    533 	return xgb.Pad(b)
    534 }
    535 
    536 type Linefix struct {
    537 	P1 Pointfix
    538 	P2 Pointfix
    539 }
    540 
    541 // LinefixRead reads a byte slice into a Linefix value.
    542 func LinefixRead(buf []byte, v *Linefix) int {
    543 	b := 0
    544 
    545 	v.P1 = Pointfix{}
    546 	b += PointfixRead(buf[b:], &v.P1)
    547 
    548 	v.P2 = Pointfix{}
    549 	b += PointfixRead(buf[b:], &v.P2)
    550 
    551 	return b
    552 }
    553 
    554 // LinefixReadList reads a byte slice into a list of Linefix values.
    555 func LinefixReadList(buf []byte, dest []Linefix) int {
    556 	b := 0
    557 	for i := 0; i < len(dest); i++ {
    558 		dest[i] = Linefix{}
    559 		b += LinefixRead(buf[b:], &dest[i])
    560 	}
    561 	return xgb.Pad(b)
    562 }
    563 
    564 // Bytes writes a Linefix value to a byte slice.
    565 func (v Linefix) Bytes() []byte {
    566 	buf := make([]byte, 16)
    567 	b := 0
    568 
    569 	{
    570 		structBytes := v.P1.Bytes()
    571 		copy(buf[b:], structBytes)
    572 		b += len(structBytes)
    573 	}
    574 
    575 	{
    576 		structBytes := v.P2.Bytes()
    577 		copy(buf[b:], structBytes)
    578 		b += len(structBytes)
    579 	}
    580 
    581 	return buf[:b]
    582 }
    583 
    584 // LinefixListBytes writes a list of Linefix values to a byte slice.
    585 func LinefixListBytes(buf []byte, list []Linefix) int {
    586 	b := 0
    587 	var structBytes []byte
    588 	for _, item := range list {
    589 		structBytes = item.Bytes()
    590 		copy(buf[b:], structBytes)
    591 		b += len(structBytes)
    592 	}
    593 	return xgb.Pad(b)
    594 }
    595 
    596 // BadPictFormat is the error number for a BadPictFormat.
    597 const BadPictFormat = 0
    598 
    599 type PictFormatError struct {
    600 	Sequence uint16
    601 	NiceName string
    602 }
    603 
    604 // PictFormatErrorNew constructs a PictFormatError value that implements xgb.Error from a byte slice.
    605 func PictFormatErrorNew(buf []byte) xgb.Error {
    606 	v := PictFormatError{}
    607 	v.NiceName = "PictFormat"
    608 
    609 	b := 1 // skip error determinant
    610 	b += 1 // don't read error number
    611 
    612 	v.Sequence = xgb.Get16(buf[b:])
    613 	b += 2
    614 
    615 	return v
    616 }
    617 
    618 // SequenceId returns the sequence id attached to the BadPictFormat error.
    619 // This is mostly used internally.
    620 func (err PictFormatError) SequenceId() uint16 {
    621 	return err.Sequence
    622 }
    623 
    624 // BadId returns the 'BadValue' number if one exists for the BadPictFormat error. If no bad value exists, 0 is returned.
    625 func (err PictFormatError) BadId() uint32 {
    626 	return 0
    627 }
    628 
    629 // Error returns a rudimentary string representation of the BadPictFormat error.
    630 
    631 func (err PictFormatError) Error() string {
    632 	fieldVals := make([]string, 0, 0)
    633 	fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
    634 	fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
    635 	return "BadPictFormat {" + xgb.StringsJoin(fieldVals, ", ") + "}"
    636 }
    637 
    638 func init() {
    639 	xgb.NewExtErrorFuncs["RENDER"][0] = PictFormatErrorNew
    640 }
    641 
    642 // BadPictOp is the error number for a BadPictOp.
    643 const BadPictOp = 2
    644 
    645 type PictOpError struct {
    646 	Sequence uint16
    647 	NiceName string
    648 }
    649 
    650 // PictOpErrorNew constructs a PictOpError value that implements xgb.Error from a byte slice.
    651 func PictOpErrorNew(buf []byte) xgb.Error {
    652 	v := PictOpError{}
    653 	v.NiceName = "PictOp"
    654 
    655 	b := 1 // skip error determinant
    656 	b += 1 // don't read error number
    657 
    658 	v.Sequence = xgb.Get16(buf[b:])
    659 	b += 2
    660 
    661 	return v
    662 }
    663 
    664 // SequenceId returns the sequence id attached to the BadPictOp error.
    665 // This is mostly used internally.
    666 func (err PictOpError) SequenceId() uint16 {
    667 	return err.Sequence
    668 }
    669 
    670 // BadId returns the 'BadValue' number if one exists for the BadPictOp error. If no bad value exists, 0 is returned.
    671 func (err PictOpError) BadId() uint32 {
    672 	return 0
    673 }
    674 
    675 // Error returns a rudimentary string representation of the BadPictOp error.
    676 
    677 func (err PictOpError) Error() string {
    678 	fieldVals := make([]string, 0, 0)
    679 	fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
    680 	fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
    681 	return "BadPictOp {" + xgb.StringsJoin(fieldVals, ", ") + "}"
    682 }
    683 
    684 func init() {
    685 	xgb.NewExtErrorFuncs["RENDER"][2] = PictOpErrorNew
    686 }
    687 
    688 const (
    689 	PictOpClear               = 0
    690 	PictOpSrc                 = 1
    691 	PictOpDst                 = 2
    692 	PictOpOver                = 3
    693 	PictOpOverReverse         = 4
    694 	PictOpIn                  = 5
    695 	PictOpInReverse           = 6
    696 	PictOpOut                 = 7
    697 	PictOpOutReverse          = 8
    698 	PictOpAtop                = 9
    699 	PictOpAtopReverse         = 10
    700 	PictOpXor                 = 11
    701 	PictOpAdd                 = 12
    702 	PictOpSaturate            = 13
    703 	PictOpDisjointClear       = 16
    704 	PictOpDisjointSrc         = 17
    705 	PictOpDisjointDst         = 18
    706 	PictOpDisjointOver        = 19
    707 	PictOpDisjointOverReverse = 20
    708 	PictOpDisjointIn          = 21
    709 	PictOpDisjointInReverse   = 22
    710 	PictOpDisjointOut         = 23
    711 	PictOpDisjointOutReverse  = 24
    712 	PictOpDisjointAtop        = 25
    713 	PictOpDisjointAtopReverse = 26
    714 	PictOpDisjointXor         = 27
    715 	PictOpConjointClear       = 32
    716 	PictOpConjointSrc         = 33
    717 	PictOpConjointDst         = 34
    718 	PictOpConjointOver        = 35
    719 	PictOpConjointOverReverse = 36
    720 	PictOpConjointIn          = 37
    721 	PictOpConjointInReverse   = 38
    722 	PictOpConjointOut         = 39
    723 	PictOpConjointOutReverse  = 40
    724 	PictOpConjointAtop        = 41
    725 	PictOpConjointAtopReverse = 42
    726 	PictOpConjointXor         = 43
    727 	PictOpMultiply            = 48
    728 	PictOpScreen              = 49
    729 	PictOpOverlay             = 50
    730 	PictOpDarken              = 51
    731 	PictOpLighten             = 52
    732 	PictOpColorDodge          = 53
    733 	PictOpColorBurn           = 54
    734 	PictOpHardLight           = 55
    735 	PictOpSoftLight           = 56
    736 	PictOpDifference          = 57
    737 	PictOpExclusion           = 58
    738 	PictOpHSLHue              = 59
    739 	PictOpHSLSaturation       = 60
    740 	PictOpHSLColor            = 61
    741 	PictOpHSLLuminosity       = 62
    742 )
    743 
    744 const (
    745 	PictTypeIndexed = 0
    746 	PictTypeDirect  = 1
    747 )
    748 
    749 type Pictdepth struct {
    750 	Depth byte
    751 	// padding: 1 bytes
    752 	NumVisuals uint16
    753 	// padding: 4 bytes
    754 	Visuals []Pictvisual // size: xgb.Pad((int(NumVisuals) * 8))
    755 }
    756 
    757 // PictdepthRead reads a byte slice into a Pictdepth value.
    758 func PictdepthRead(buf []byte, v *Pictdepth) int {
    759 	b := 0
    760 
    761 	v.Depth = buf[b]
    762 	b += 1
    763 
    764 	b += 1 // padding
    765 
    766 	v.NumVisuals = xgb.Get16(buf[b:])
    767 	b += 2
    768 
    769 	b += 4 // padding
    770 
    771 	v.Visuals = make([]Pictvisual, v.NumVisuals)
    772 	b += PictvisualReadList(buf[b:], v.Visuals)
    773 
    774 	return b
    775 }
    776 
    777 // PictdepthReadList reads a byte slice into a list of Pictdepth values.
    778 func PictdepthReadList(buf []byte, dest []Pictdepth) int {
    779 	b := 0
    780 	for i := 0; i < len(dest); i++ {
    781 		dest[i] = Pictdepth{}
    782 		b += PictdepthRead(buf[b:], &dest[i])
    783 	}
    784 	return xgb.Pad(b)
    785 }
    786 
    787 // Bytes writes a Pictdepth value to a byte slice.
    788 func (v Pictdepth) Bytes() []byte {
    789 	buf := make([]byte, (8 + xgb.Pad((int(v.NumVisuals) * 8))))
    790 	b := 0
    791 
    792 	buf[b] = v.Depth
    793 	b += 1
    794 
    795 	b += 1 // padding
    796 
    797 	xgb.Put16(buf[b:], v.NumVisuals)
    798 	b += 2
    799 
    800 	b += 4 // padding
    801 
    802 	b += PictvisualListBytes(buf[b:], v.Visuals)
    803 
    804 	return buf[:b]
    805 }
    806 
    807 // PictdepthListBytes writes a list of Pictdepth values to a byte slice.
    808 func PictdepthListBytes(buf []byte, list []Pictdepth) int {
    809 	b := 0
    810 	var structBytes []byte
    811 	for _, item := range list {
    812 		structBytes = item.Bytes()
    813 		copy(buf[b:], structBytes)
    814 		b += len(structBytes)
    815 	}
    816 	return xgb.Pad(b)
    817 }
    818 
    819 // PictdepthListSize computes the size (bytes) of a list of Pictdepth values.
    820 func PictdepthListSize(list []Pictdepth) int {
    821 	size := 0
    822 	for _, item := range list {
    823 		size += (8 + xgb.Pad((int(item.NumVisuals) * 8)))
    824 	}
    825 	return size
    826 }
    827 
    828 type Pictformat uint32
    829 
    830 func NewPictformatId(c *xgb.Conn) (Pictformat, error) {
    831 	id, err := c.NewId()
    832 	if err != nil {
    833 		return 0, err
    834 	}
    835 	return Pictformat(id), nil
    836 }
    837 
    838 type Pictforminfo struct {
    839 	Id    Pictformat
    840 	Type  byte
    841 	Depth byte
    842 	// padding: 2 bytes
    843 	Direct   Directformat
    844 	Colormap xproto.Colormap
    845 }
    846 
    847 // PictforminfoRead reads a byte slice into a Pictforminfo value.
    848 func PictforminfoRead(buf []byte, v *Pictforminfo) int {
    849 	b := 0
    850 
    851 	v.Id = Pictformat(xgb.Get32(buf[b:]))
    852 	b += 4
    853 
    854 	v.Type = buf[b]
    855 	b += 1
    856 
    857 	v.Depth = buf[b]
    858 	b += 1
    859 
    860 	b += 2 // padding
    861 
    862 	v.Direct = Directformat{}
    863 	b += DirectformatRead(buf[b:], &v.Direct)
    864 
    865 	v.Colormap = xproto.Colormap(xgb.Get32(buf[b:]))
    866 	b += 4
    867 
    868 	return b
    869 }
    870 
    871 // PictforminfoReadList reads a byte slice into a list of Pictforminfo values.
    872 func PictforminfoReadList(buf []byte, dest []Pictforminfo) int {
    873 	b := 0
    874 	for i := 0; i < len(dest); i++ {
    875 		dest[i] = Pictforminfo{}
    876 		b += PictforminfoRead(buf[b:], &dest[i])
    877 	}
    878 	return xgb.Pad(b)
    879 }
    880 
    881 // Bytes writes a Pictforminfo value to a byte slice.
    882 func (v Pictforminfo) Bytes() []byte {
    883 	buf := make([]byte, 28)
    884 	b := 0
    885 
    886 	xgb.Put32(buf[b:], uint32(v.Id))
    887 	b += 4
    888 
    889 	buf[b] = v.Type
    890 	b += 1
    891 
    892 	buf[b] = v.Depth
    893 	b += 1
    894 
    895 	b += 2 // padding
    896 
    897 	{
    898 		structBytes := v.Direct.Bytes()
    899 		copy(buf[b:], structBytes)
    900 		b += len(structBytes)
    901 	}
    902 
    903 	xgb.Put32(buf[b:], uint32(v.Colormap))
    904 	b += 4
    905 
    906 	return buf[:b]
    907 }
    908 
    909 // PictforminfoListBytes writes a list of Pictforminfo values to a byte slice.
    910 func PictforminfoListBytes(buf []byte, list []Pictforminfo) int {
    911 	b := 0
    912 	var structBytes []byte
    913 	for _, item := range list {
    914 		structBytes = item.Bytes()
    915 		copy(buf[b:], structBytes)
    916 		b += len(structBytes)
    917 	}
    918 	return xgb.Pad(b)
    919 }
    920 
    921 type Pictscreen struct {
    922 	NumDepths uint32
    923 	Fallback  Pictformat
    924 	Depths    []Pictdepth // size: PictdepthListSize(Depths)
    925 }
    926 
    927 // PictscreenRead reads a byte slice into a Pictscreen value.
    928 func PictscreenRead(buf []byte, v *Pictscreen) int {
    929 	b := 0
    930 
    931 	v.NumDepths = xgb.Get32(buf[b:])
    932 	b += 4
    933 
    934 	v.Fallback = Pictformat(xgb.Get32(buf[b:]))
    935 	b += 4
    936 
    937 	v.Depths = make([]Pictdepth, v.NumDepths)
    938 	b += PictdepthReadList(buf[b:], v.Depths)
    939 
    940 	return b
    941 }
    942 
    943 // PictscreenReadList reads a byte slice into a list of Pictscreen values.
    944 func PictscreenReadList(buf []byte, dest []Pictscreen) int {
    945 	b := 0
    946 	for i := 0; i < len(dest); i++ {
    947 		dest[i] = Pictscreen{}
    948 		b += PictscreenRead(buf[b:], &dest[i])
    949 	}
    950 	return xgb.Pad(b)
    951 }
    952 
    953 // Bytes writes a Pictscreen value to a byte slice.
    954 func (v Pictscreen) Bytes() []byte {
    955 	buf := make([]byte, (8 + PictdepthListSize(v.Depths)))
    956 	b := 0
    957 
    958 	xgb.Put32(buf[b:], v.NumDepths)
    959 	b += 4
    960 
    961 	xgb.Put32(buf[b:], uint32(v.Fallback))
    962 	b += 4
    963 
    964 	b += PictdepthListBytes(buf[b:], v.Depths)
    965 
    966 	return buf[:b]
    967 }
    968 
    969 // PictscreenListBytes writes a list of Pictscreen values to a byte slice.
    970 func PictscreenListBytes(buf []byte, list []Pictscreen) int {
    971 	b := 0
    972 	var structBytes []byte
    973 	for _, item := range list {
    974 		structBytes = item.Bytes()
    975 		copy(buf[b:], structBytes)
    976 		b += len(structBytes)
    977 	}
    978 	return xgb.Pad(b)
    979 }
    980 
    981 // PictscreenListSize computes the size (bytes) of a list of Pictscreen values.
    982 func PictscreenListSize(list []Pictscreen) int {
    983 	size := 0
    984 	for _, item := range list {
    985 		size += (8 + PictdepthListSize(item.Depths))
    986 	}
    987 	return size
    988 }
    989 
    990 type Picture uint32
    991 
    992 func NewPictureId(c *xgb.Conn) (Picture, error) {
    993 	id, err := c.NewId()
    994 	if err != nil {
    995 		return 0, err
    996 	}
    997 	return Picture(id), nil
    998 }
    999 
   1000 // BadPicture is the error number for a BadPicture.
   1001 const BadPicture = 1
   1002 
   1003 type PictureError struct {
   1004 	Sequence uint16
   1005 	NiceName string
   1006 }
   1007 
   1008 // PictureErrorNew constructs a PictureError value that implements xgb.Error from a byte slice.
   1009 func PictureErrorNew(buf []byte) xgb.Error {
   1010 	v := PictureError{}
   1011 	v.NiceName = "Picture"
   1012 
   1013 	b := 1 // skip error determinant
   1014 	b += 1 // don't read error number
   1015 
   1016 	v.Sequence = xgb.Get16(buf[b:])
   1017 	b += 2
   1018 
   1019 	return v
   1020 }
   1021 
   1022 // SequenceId returns the sequence id attached to the BadPicture error.
   1023 // This is mostly used internally.
   1024 func (err PictureError) SequenceId() uint16 {
   1025 	return err.Sequence
   1026 }
   1027 
   1028 // BadId returns the 'BadValue' number if one exists for the BadPicture error. If no bad value exists, 0 is returned.
   1029 func (err PictureError) BadId() uint32 {
   1030 	return 0
   1031 }
   1032 
   1033 // Error returns a rudimentary string representation of the BadPicture error.
   1034 
   1035 func (err PictureError) Error() string {
   1036 	fieldVals := make([]string, 0, 0)
   1037 	fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
   1038 	fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
   1039 	return "BadPicture {" + xgb.StringsJoin(fieldVals, ", ") + "}"
   1040 }
   1041 
   1042 func init() {
   1043 	xgb.NewExtErrorFuncs["RENDER"][1] = PictureErrorNew
   1044 }
   1045 
   1046 const (
   1047 	PictureNone = 0
   1048 )
   1049 
   1050 type Pictvisual struct {
   1051 	Visual xproto.Visualid
   1052 	Format Pictformat
   1053 }
   1054 
   1055 // PictvisualRead reads a byte slice into a Pictvisual value.
   1056 func PictvisualRead(buf []byte, v *Pictvisual) int {
   1057 	b := 0
   1058 
   1059 	v.Visual = xproto.Visualid(xgb.Get32(buf[b:]))
   1060 	b += 4
   1061 
   1062 	v.Format = Pictformat(xgb.Get32(buf[b:]))
   1063 	b += 4
   1064 
   1065 	return b
   1066 }
   1067 
   1068 // PictvisualReadList reads a byte slice into a list of Pictvisual values.
   1069 func PictvisualReadList(buf []byte, dest []Pictvisual) int {
   1070 	b := 0
   1071 	for i := 0; i < len(dest); i++ {
   1072 		dest[i] = Pictvisual{}
   1073 		b += PictvisualRead(buf[b:], &dest[i])
   1074 	}
   1075 	return xgb.Pad(b)
   1076 }
   1077 
   1078 // Bytes writes a Pictvisual value to a byte slice.
   1079 func (v Pictvisual) Bytes() []byte {
   1080 	buf := make([]byte, 8)
   1081 	b := 0
   1082 
   1083 	xgb.Put32(buf[b:], uint32(v.Visual))
   1084 	b += 4
   1085 
   1086 	xgb.Put32(buf[b:], uint32(v.Format))
   1087 	b += 4
   1088 
   1089 	return buf[:b]
   1090 }
   1091 
   1092 // PictvisualListBytes writes a list of Pictvisual values to a byte slice.
   1093 func PictvisualListBytes(buf []byte, list []Pictvisual) int {
   1094 	b := 0
   1095 	var structBytes []byte
   1096 	for _, item := range list {
   1097 		structBytes = item.Bytes()
   1098 		copy(buf[b:], structBytes)
   1099 		b += len(structBytes)
   1100 	}
   1101 	return xgb.Pad(b)
   1102 }
   1103 
   1104 type Pointfix struct {
   1105 	X Fixed
   1106 	Y Fixed
   1107 }
   1108 
   1109 // PointfixRead reads a byte slice into a Pointfix value.
   1110 func PointfixRead(buf []byte, v *Pointfix) int {
   1111 	b := 0
   1112 
   1113 	v.X = Fixed(xgb.Get32(buf[b:]))
   1114 	b += 4
   1115 
   1116 	v.Y = Fixed(xgb.Get32(buf[b:]))
   1117 	b += 4
   1118 
   1119 	return b
   1120 }
   1121 
   1122 // PointfixReadList reads a byte slice into a list of Pointfix values.
   1123 func PointfixReadList(buf []byte, dest []Pointfix) int {
   1124 	b := 0
   1125 	for i := 0; i < len(dest); i++ {
   1126 		dest[i] = Pointfix{}
   1127 		b += PointfixRead(buf[b:], &dest[i])
   1128 	}
   1129 	return xgb.Pad(b)
   1130 }
   1131 
   1132 // Bytes writes a Pointfix value to a byte slice.
   1133 func (v Pointfix) Bytes() []byte {
   1134 	buf := make([]byte, 8)
   1135 	b := 0
   1136 
   1137 	xgb.Put32(buf[b:], uint32(v.X))
   1138 	b += 4
   1139 
   1140 	xgb.Put32(buf[b:], uint32(v.Y))
   1141 	b += 4
   1142 
   1143 	return buf[:b]
   1144 }
   1145 
   1146 // PointfixListBytes writes a list of Pointfix values to a byte slice.
   1147 func PointfixListBytes(buf []byte, list []Pointfix) int {
   1148 	b := 0
   1149 	var structBytes []byte
   1150 	for _, item := range list {
   1151 		structBytes = item.Bytes()
   1152 		copy(buf[b:], structBytes)
   1153 		b += len(structBytes)
   1154 	}
   1155 	return xgb.Pad(b)
   1156 }
   1157 
   1158 const (
   1159 	PolyEdgeSharp  = 0
   1160 	PolyEdgeSmooth = 1
   1161 )
   1162 
   1163 const (
   1164 	PolyModePrecise   = 0
   1165 	PolyModeImprecise = 1
   1166 )
   1167 
   1168 const (
   1169 	RepeatNone    = 0
   1170 	RepeatNormal  = 1
   1171 	RepeatPad     = 2
   1172 	RepeatReflect = 3
   1173 )
   1174 
   1175 type Spanfix struct {
   1176 	L Fixed
   1177 	R Fixed
   1178 	Y Fixed
   1179 }
   1180 
   1181 // SpanfixRead reads a byte slice into a Spanfix value.
   1182 func SpanfixRead(buf []byte, v *Spanfix) int {
   1183 	b := 0
   1184 
   1185 	v.L = Fixed(xgb.Get32(buf[b:]))
   1186 	b += 4
   1187 
   1188 	v.R = Fixed(xgb.Get32(buf[b:]))
   1189 	b += 4
   1190 
   1191 	v.Y = Fixed(xgb.Get32(buf[b:]))
   1192 	b += 4
   1193 
   1194 	return b
   1195 }
   1196 
   1197 // SpanfixReadList reads a byte slice into a list of Spanfix values.
   1198 func SpanfixReadList(buf []byte, dest []Spanfix) int {
   1199 	b := 0
   1200 	for i := 0; i < len(dest); i++ {
   1201 		dest[i] = Spanfix{}
   1202 		b += SpanfixRead(buf[b:], &dest[i])
   1203 	}
   1204 	return xgb.Pad(b)
   1205 }
   1206 
   1207 // Bytes writes a Spanfix value to a byte slice.
   1208 func (v Spanfix) Bytes() []byte {
   1209 	buf := make([]byte, 12)
   1210 	b := 0
   1211 
   1212 	xgb.Put32(buf[b:], uint32(v.L))
   1213 	b += 4
   1214 
   1215 	xgb.Put32(buf[b:], uint32(v.R))
   1216 	b += 4
   1217 
   1218 	xgb.Put32(buf[b:], uint32(v.Y))
   1219 	b += 4
   1220 
   1221 	return buf[:b]
   1222 }
   1223 
   1224 // SpanfixListBytes writes a list of Spanfix values to a byte slice.
   1225 func SpanfixListBytes(buf []byte, list []Spanfix) int {
   1226 	b := 0
   1227 	var structBytes []byte
   1228 	for _, item := range list {
   1229 		structBytes = item.Bytes()
   1230 		copy(buf[b:], structBytes)
   1231 		b += len(structBytes)
   1232 	}
   1233 	return xgb.Pad(b)
   1234 }
   1235 
   1236 const (
   1237 	SubPixelUnknown       = 0
   1238 	SubPixelHorizontalRGB = 1
   1239 	SubPixelHorizontalBGR = 2
   1240 	SubPixelVerticalRGB   = 3
   1241 	SubPixelVerticalBGR   = 4
   1242 	SubPixelNone          = 5
   1243 )
   1244 
   1245 type Transform struct {
   1246 	Matrix11 Fixed
   1247 	Matrix12 Fixed
   1248 	Matrix13 Fixed
   1249 	Matrix21 Fixed
   1250 	Matrix22 Fixed
   1251 	Matrix23 Fixed
   1252 	Matrix31 Fixed
   1253 	Matrix32 Fixed
   1254 	Matrix33 Fixed
   1255 }
   1256 
   1257 // TransformRead reads a byte slice into a Transform value.
   1258 func TransformRead(buf []byte, v *Transform) int {
   1259 	b := 0
   1260 
   1261 	v.Matrix11 = Fixed(xgb.Get32(buf[b:]))
   1262 	b += 4
   1263 
   1264 	v.Matrix12 = Fixed(xgb.Get32(buf[b:]))
   1265 	b += 4
   1266 
   1267 	v.Matrix13 = Fixed(xgb.Get32(buf[b:]))
   1268 	b += 4
   1269 
   1270 	v.Matrix21 = Fixed(xgb.Get32(buf[b:]))
   1271 	b += 4
   1272 
   1273 	v.Matrix22 = Fixed(xgb.Get32(buf[b:]))
   1274 	b += 4
   1275 
   1276 	v.Matrix23 = Fixed(xgb.Get32(buf[b:]))
   1277 	b += 4
   1278 
   1279 	v.Matrix31 = Fixed(xgb.Get32(buf[b:]))
   1280 	b += 4
   1281 
   1282 	v.Matrix32 = Fixed(xgb.Get32(buf[b:]))
   1283 	b += 4
   1284 
   1285 	v.Matrix33 = Fixed(xgb.Get32(buf[b:]))
   1286 	b += 4
   1287 
   1288 	return b
   1289 }
   1290 
   1291 // TransformReadList reads a byte slice into a list of Transform values.
   1292 func TransformReadList(buf []byte, dest []Transform) int {
   1293 	b := 0
   1294 	for i := 0; i < len(dest); i++ {
   1295 		dest[i] = Transform{}
   1296 		b += TransformRead(buf[b:], &dest[i])
   1297 	}
   1298 	return xgb.Pad(b)
   1299 }
   1300 
   1301 // Bytes writes a Transform value to a byte slice.
   1302 func (v Transform) Bytes() []byte {
   1303 	buf := make([]byte, 36)
   1304 	b := 0
   1305 
   1306 	xgb.Put32(buf[b:], uint32(v.Matrix11))
   1307 	b += 4
   1308 
   1309 	xgb.Put32(buf[b:], uint32(v.Matrix12))
   1310 	b += 4
   1311 
   1312 	xgb.Put32(buf[b:], uint32(v.Matrix13))
   1313 	b += 4
   1314 
   1315 	xgb.Put32(buf[b:], uint32(v.Matrix21))
   1316 	b += 4
   1317 
   1318 	xgb.Put32(buf[b:], uint32(v.Matrix22))
   1319 	b += 4
   1320 
   1321 	xgb.Put32(buf[b:], uint32(v.Matrix23))
   1322 	b += 4
   1323 
   1324 	xgb.Put32(buf[b:], uint32(v.Matrix31))
   1325 	b += 4
   1326 
   1327 	xgb.Put32(buf[b:], uint32(v.Matrix32))
   1328 	b += 4
   1329 
   1330 	xgb.Put32(buf[b:], uint32(v.Matrix33))
   1331 	b += 4
   1332 
   1333 	return buf[:b]
   1334 }
   1335 
   1336 // TransformListBytes writes a list of Transform values to a byte slice.
   1337 func TransformListBytes(buf []byte, list []Transform) int {
   1338 	b := 0
   1339 	var structBytes []byte
   1340 	for _, item := range list {
   1341 		structBytes = item.Bytes()
   1342 		copy(buf[b:], structBytes)
   1343 		b += len(structBytes)
   1344 	}
   1345 	return xgb.Pad(b)
   1346 }
   1347 
   1348 type Trap struct {
   1349 	Top Spanfix
   1350 	Bot Spanfix
   1351 }
   1352 
   1353 // TrapRead reads a byte slice into a Trap value.
   1354 func TrapRead(buf []byte, v *Trap) int {
   1355 	b := 0
   1356 
   1357 	v.Top = Spanfix{}
   1358 	b += SpanfixRead(buf[b:], &v.Top)
   1359 
   1360 	v.Bot = Spanfix{}
   1361 	b += SpanfixRead(buf[b:], &v.Bot)
   1362 
   1363 	return b
   1364 }
   1365 
   1366 // TrapReadList reads a byte slice into a list of Trap values.
   1367 func TrapReadList(buf []byte, dest []Trap) int {
   1368 	b := 0
   1369 	for i := 0; i < len(dest); i++ {
   1370 		dest[i] = Trap{}
   1371 		b += TrapRead(buf[b:], &dest[i])
   1372 	}
   1373 	return xgb.Pad(b)
   1374 }
   1375 
   1376 // Bytes writes a Trap value to a byte slice.
   1377 func (v Trap) Bytes() []byte {
   1378 	buf := make([]byte, 24)
   1379 	b := 0
   1380 
   1381 	{
   1382 		structBytes := v.Top.Bytes()
   1383 		copy(buf[b:], structBytes)
   1384 		b += len(structBytes)
   1385 	}
   1386 
   1387 	{
   1388 		structBytes := v.Bot.Bytes()
   1389 		copy(buf[b:], structBytes)
   1390 		b += len(structBytes)
   1391 	}
   1392 
   1393 	return buf[:b]
   1394 }
   1395 
   1396 // TrapListBytes writes a list of Trap values to a byte slice.
   1397 func TrapListBytes(buf []byte, list []Trap) int {
   1398 	b := 0
   1399 	var structBytes []byte
   1400 	for _, item := range list {
   1401 		structBytes = item.Bytes()
   1402 		copy(buf[b:], structBytes)
   1403 		b += len(structBytes)
   1404 	}
   1405 	return xgb.Pad(b)
   1406 }
   1407 
   1408 type Trapezoid struct {
   1409 	Top    Fixed
   1410 	Bottom Fixed
   1411 	Left   Linefix
   1412 	Right  Linefix
   1413 }
   1414 
   1415 // TrapezoidRead reads a byte slice into a Trapezoid value.
   1416 func TrapezoidRead(buf []byte, v *Trapezoid) int {
   1417 	b := 0
   1418 
   1419 	v.Top = Fixed(xgb.Get32(buf[b:]))
   1420 	b += 4
   1421 
   1422 	v.Bottom = Fixed(xgb.Get32(buf[b:]))
   1423 	b += 4
   1424 
   1425 	v.Left = Linefix{}
   1426 	b += LinefixRead(buf[b:], &v.Left)
   1427 
   1428 	v.Right = Linefix{}
   1429 	b += LinefixRead(buf[b:], &v.Right)
   1430 
   1431 	return b
   1432 }
   1433 
   1434 // TrapezoidReadList reads a byte slice into a list of Trapezoid values.
   1435 func TrapezoidReadList(buf []byte, dest []Trapezoid) int {
   1436 	b := 0
   1437 	for i := 0; i < len(dest); i++ {
   1438 		dest[i] = Trapezoid{}
   1439 		b += TrapezoidRead(buf[b:], &dest[i])
   1440 	}
   1441 	return xgb.Pad(b)
   1442 }
   1443 
   1444 // Bytes writes a Trapezoid value to a byte slice.
   1445 func (v Trapezoid) Bytes() []byte {
   1446 	buf := make([]byte, 40)
   1447 	b := 0
   1448 
   1449 	xgb.Put32(buf[b:], uint32(v.Top))
   1450 	b += 4
   1451 
   1452 	xgb.Put32(buf[b:], uint32(v.Bottom))
   1453 	b += 4
   1454 
   1455 	{
   1456 		structBytes := v.Left.Bytes()
   1457 		copy(buf[b:], structBytes)
   1458 		b += len(structBytes)
   1459 	}
   1460 
   1461 	{
   1462 		structBytes := v.Right.Bytes()
   1463 		copy(buf[b:], structBytes)
   1464 		b += len(structBytes)
   1465 	}
   1466 
   1467 	return buf[:b]
   1468 }
   1469 
   1470 // TrapezoidListBytes writes a list of Trapezoid values to a byte slice.
   1471 func TrapezoidListBytes(buf []byte, list []Trapezoid) int {
   1472 	b := 0
   1473 	var structBytes []byte
   1474 	for _, item := range list {
   1475 		structBytes = item.Bytes()
   1476 		copy(buf[b:], structBytes)
   1477 		b += len(structBytes)
   1478 	}
   1479 	return xgb.Pad(b)
   1480 }
   1481 
   1482 type Triangle struct {
   1483 	P1 Pointfix
   1484 	P2 Pointfix
   1485 	P3 Pointfix
   1486 }
   1487 
   1488 // TriangleRead reads a byte slice into a Triangle value.
   1489 func TriangleRead(buf []byte, v *Triangle) int {
   1490 	b := 0
   1491 
   1492 	v.P1 = Pointfix{}
   1493 	b += PointfixRead(buf[b:], &v.P1)
   1494 
   1495 	v.P2 = Pointfix{}
   1496 	b += PointfixRead(buf[b:], &v.P2)
   1497 
   1498 	v.P3 = Pointfix{}
   1499 	b += PointfixRead(buf[b:], &v.P3)
   1500 
   1501 	return b
   1502 }
   1503 
   1504 // TriangleReadList reads a byte slice into a list of Triangle values.
   1505 func TriangleReadList(buf []byte, dest []Triangle) int {
   1506 	b := 0
   1507 	for i := 0; i < len(dest); i++ {
   1508 		dest[i] = Triangle{}
   1509 		b += TriangleRead(buf[b:], &dest[i])
   1510 	}
   1511 	return xgb.Pad(b)
   1512 }
   1513 
   1514 // Bytes writes a Triangle value to a byte slice.
   1515 func (v Triangle) Bytes() []byte {
   1516 	buf := make([]byte, 24)
   1517 	b := 0
   1518 
   1519 	{
   1520 		structBytes := v.P1.Bytes()
   1521 		copy(buf[b:], structBytes)
   1522 		b += len(structBytes)
   1523 	}
   1524 
   1525 	{
   1526 		structBytes := v.P2.Bytes()
   1527 		copy(buf[b:], structBytes)
   1528 		b += len(structBytes)
   1529 	}
   1530 
   1531 	{
   1532 		structBytes := v.P3.Bytes()
   1533 		copy(buf[b:], structBytes)
   1534 		b += len(structBytes)
   1535 	}
   1536 
   1537 	return buf[:b]
   1538 }
   1539 
   1540 // TriangleListBytes writes a list of Triangle values to a byte slice.
   1541 func TriangleListBytes(buf []byte, list []Triangle) int {
   1542 	b := 0
   1543 	var structBytes []byte
   1544 	for _, item := range list {
   1545 		structBytes = item.Bytes()
   1546 		copy(buf[b:], structBytes)
   1547 		b += len(structBytes)
   1548 	}
   1549 	return xgb.Pad(b)
   1550 }
   1551 
   1552 // Skipping definition for base type 'Bool'
   1553 
   1554 // Skipping definition for base type 'Byte'
   1555 
   1556 // Skipping definition for base type 'Card8'
   1557 
   1558 // Skipping definition for base type 'Char'
   1559 
   1560 // Skipping definition for base type 'Void'
   1561 
   1562 // Skipping definition for base type 'Double'
   1563 
   1564 // Skipping definition for base type 'Float'
   1565 
   1566 // Skipping definition for base type 'Int16'
   1567 
   1568 // Skipping definition for base type 'Int32'
   1569 
   1570 // Skipping definition for base type 'Int8'
   1571 
   1572 // Skipping definition for base type 'Card16'
   1573 
   1574 // Skipping definition for base type 'Card32'
   1575 
   1576 // AddGlyphsCookie is a cookie used only for AddGlyphs requests.
   1577 type AddGlyphsCookie struct {
   1578 	*xgb.Cookie
   1579 }
   1580 
   1581 // AddGlyphs sends an unchecked request.
   1582 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   1583 func AddGlyphs(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie {
   1584 	c.ExtLock.RLock()
   1585 	defer c.ExtLock.RUnlock()
   1586 	if _, ok := c.Extensions["RENDER"]; !ok {
   1587 		panic("Cannot issue request 'AddGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   1588 	}
   1589 	cookie := c.NewCookie(false, false)
   1590 	c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie)
   1591 	return AddGlyphsCookie{cookie}
   1592 }
   1593 
   1594 // AddGlyphsChecked sends a checked request.
   1595 // If an error occurs, it can be retrieved using AddGlyphsCookie.Check()
   1596 func AddGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) AddGlyphsCookie {
   1597 	c.ExtLock.RLock()
   1598 	defer c.ExtLock.RUnlock()
   1599 	if _, ok := c.Extensions["RENDER"]; !ok {
   1600 		panic("Cannot issue request 'AddGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   1601 	}
   1602 	cookie := c.NewCookie(true, false)
   1603 	c.NewRequest(addGlyphsRequest(c, Glyphset, GlyphsLen, Glyphids, Glyphs, Data), cookie)
   1604 	return AddGlyphsCookie{cookie}
   1605 }
   1606 
   1607 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   1608 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   1609 func (cook AddGlyphsCookie) Check() error {
   1610 	return cook.Cookie.Check()
   1611 }
   1612 
   1613 // Write request to wire for AddGlyphs
   1614 // addGlyphsRequest writes a AddGlyphs request to a byte slice.
   1615 func addGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, GlyphsLen uint32, Glyphids []uint32, Glyphs []Glyphinfo, Data []byte) []byte {
   1616 	size := xgb.Pad(((((12 + xgb.Pad((int(GlyphsLen) * 4))) + 4) + xgb.Pad((int(GlyphsLen) * 12))) + xgb.Pad((len(Data) * 1))))
   1617 	b := 0
   1618 	buf := make([]byte, size)
   1619 
   1620 	c.ExtLock.RLock()
   1621 	buf[b] = c.Extensions["RENDER"]
   1622 	c.ExtLock.RUnlock()
   1623 	b += 1
   1624 
   1625 	buf[b] = 20 // request opcode
   1626 	b += 1
   1627 
   1628 	blen := b
   1629 	b += 2
   1630 
   1631 	xgb.Put32(buf[b:], uint32(Glyphset))
   1632 	b += 4
   1633 
   1634 	xgb.Put32(buf[b:], GlyphsLen)
   1635 	b += 4
   1636 
   1637 	for i := 0; i < int(GlyphsLen); i++ {
   1638 		xgb.Put32(buf[b:], Glyphids[i])
   1639 		b += 4
   1640 	}
   1641 
   1642 	b = (b + 3) & ^3 // alignment gap
   1643 
   1644 	b += GlyphinfoListBytes(buf[b:], Glyphs)
   1645 
   1646 	copy(buf[b:], Data[:len(Data)])
   1647 	b += int(len(Data))
   1648 
   1649 	b = xgb.Pad(b)
   1650 	xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
   1651 	return buf[:b]
   1652 }
   1653 
   1654 // AddTrapsCookie is a cookie used only for AddTraps requests.
   1655 type AddTrapsCookie struct {
   1656 	*xgb.Cookie
   1657 }
   1658 
   1659 // AddTraps sends an unchecked request.
   1660 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   1661 func AddTraps(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie {
   1662 	c.ExtLock.RLock()
   1663 	defer c.ExtLock.RUnlock()
   1664 	if _, ok := c.Extensions["RENDER"]; !ok {
   1665 		panic("Cannot issue request 'AddTraps' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   1666 	}
   1667 	cookie := c.NewCookie(false, false)
   1668 	c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie)
   1669 	return AddTrapsCookie{cookie}
   1670 }
   1671 
   1672 // AddTrapsChecked sends a checked request.
   1673 // If an error occurs, it can be retrieved using AddTrapsCookie.Check()
   1674 func AddTrapsChecked(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) AddTrapsCookie {
   1675 	c.ExtLock.RLock()
   1676 	defer c.ExtLock.RUnlock()
   1677 	if _, ok := c.Extensions["RENDER"]; !ok {
   1678 		panic("Cannot issue request 'AddTraps' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   1679 	}
   1680 	cookie := c.NewCookie(true, false)
   1681 	c.NewRequest(addTrapsRequest(c, Picture, XOff, YOff, Traps), cookie)
   1682 	return AddTrapsCookie{cookie}
   1683 }
   1684 
   1685 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   1686 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   1687 func (cook AddTrapsCookie) Check() error {
   1688 	return cook.Cookie.Check()
   1689 }
   1690 
   1691 // Write request to wire for AddTraps
   1692 // addTrapsRequest writes a AddTraps request to a byte slice.
   1693 func addTrapsRequest(c *xgb.Conn, Picture Picture, XOff int16, YOff int16, Traps []Trap) []byte {
   1694 	size := xgb.Pad((12 + xgb.Pad((len(Traps) * 24))))
   1695 	b := 0
   1696 	buf := make([]byte, size)
   1697 
   1698 	c.ExtLock.RLock()
   1699 	buf[b] = c.Extensions["RENDER"]
   1700 	c.ExtLock.RUnlock()
   1701 	b += 1
   1702 
   1703 	buf[b] = 32 // request opcode
   1704 	b += 1
   1705 
   1706 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   1707 	b += 2
   1708 
   1709 	xgb.Put32(buf[b:], uint32(Picture))
   1710 	b += 4
   1711 
   1712 	xgb.Put16(buf[b:], uint16(XOff))
   1713 	b += 2
   1714 
   1715 	xgb.Put16(buf[b:], uint16(YOff))
   1716 	b += 2
   1717 
   1718 	b += TrapListBytes(buf[b:], Traps)
   1719 
   1720 	return buf
   1721 }
   1722 
   1723 // ChangePictureCookie is a cookie used only for ChangePicture requests.
   1724 type ChangePictureCookie struct {
   1725 	*xgb.Cookie
   1726 }
   1727 
   1728 // ChangePicture sends an unchecked request.
   1729 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   1730 func ChangePicture(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie {
   1731 	c.ExtLock.RLock()
   1732 	defer c.ExtLock.RUnlock()
   1733 	if _, ok := c.Extensions["RENDER"]; !ok {
   1734 		panic("Cannot issue request 'ChangePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   1735 	}
   1736 	cookie := c.NewCookie(false, false)
   1737 	c.NewRequest(changePictureRequest(c, Picture, ValueMask, ValueList), cookie)
   1738 	return ChangePictureCookie{cookie}
   1739 }
   1740 
   1741 // ChangePictureChecked sends a checked request.
   1742 // If an error occurs, it can be retrieved using ChangePictureCookie.Check()
   1743 func ChangePictureChecked(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) ChangePictureCookie {
   1744 	c.ExtLock.RLock()
   1745 	defer c.ExtLock.RUnlock()
   1746 	if _, ok := c.Extensions["RENDER"]; !ok {
   1747 		panic("Cannot issue request 'ChangePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   1748 	}
   1749 	cookie := c.NewCookie(true, false)
   1750 	c.NewRequest(changePictureRequest(c, Picture, ValueMask, ValueList), cookie)
   1751 	return ChangePictureCookie{cookie}
   1752 }
   1753 
   1754 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   1755 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   1756 func (cook ChangePictureCookie) Check() error {
   1757 	return cook.Cookie.Check()
   1758 }
   1759 
   1760 // Write request to wire for ChangePicture
   1761 // changePictureRequest writes a ChangePicture request to a byte slice.
   1762 func changePictureRequest(c *xgb.Conn, Picture Picture, ValueMask uint32, ValueList []uint32) []byte {
   1763 	size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask)))))))
   1764 	b := 0
   1765 	buf := make([]byte, size)
   1766 
   1767 	c.ExtLock.RLock()
   1768 	buf[b] = c.Extensions["RENDER"]
   1769 	c.ExtLock.RUnlock()
   1770 	b += 1
   1771 
   1772 	buf[b] = 5 // request opcode
   1773 	b += 1
   1774 
   1775 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   1776 	b += 2
   1777 
   1778 	xgb.Put32(buf[b:], uint32(Picture))
   1779 	b += 4
   1780 
   1781 	xgb.Put32(buf[b:], ValueMask)
   1782 	b += 4
   1783 	for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
   1784 		xgb.Put32(buf[b:], ValueList[i])
   1785 		b += 4
   1786 	}
   1787 	b = xgb.Pad(b)
   1788 
   1789 	return buf
   1790 }
   1791 
   1792 // CompositeCookie is a cookie used only for Composite requests.
   1793 type CompositeCookie struct {
   1794 	*xgb.Cookie
   1795 }
   1796 
   1797 // Composite sends an unchecked request.
   1798 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   1799 func Composite(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie {
   1800 	c.ExtLock.RLock()
   1801 	defer c.ExtLock.RUnlock()
   1802 	if _, ok := c.Extensions["RENDER"]; !ok {
   1803 		panic("Cannot issue request 'Composite' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   1804 	}
   1805 	cookie := c.NewCookie(false, false)
   1806 	c.NewRequest(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie)
   1807 	return CompositeCookie{cookie}
   1808 }
   1809 
   1810 // CompositeChecked sends a checked request.
   1811 // If an error occurs, it can be retrieved using CompositeCookie.Check()
   1812 func CompositeChecked(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) CompositeCookie {
   1813 	c.ExtLock.RLock()
   1814 	defer c.ExtLock.RUnlock()
   1815 	if _, ok := c.Extensions["RENDER"]; !ok {
   1816 		panic("Cannot issue request 'Composite' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   1817 	}
   1818 	cookie := c.NewCookie(true, false)
   1819 	c.NewRequest(compositeRequest(c, Op, Src, Mask, Dst, SrcX, SrcY, MaskX, MaskY, DstX, DstY, Width, Height), cookie)
   1820 	return CompositeCookie{cookie}
   1821 }
   1822 
   1823 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   1824 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   1825 func (cook CompositeCookie) Check() error {
   1826 	return cook.Cookie.Check()
   1827 }
   1828 
   1829 // Write request to wire for Composite
   1830 // compositeRequest writes a Composite request to a byte slice.
   1831 func compositeRequest(c *xgb.Conn, Op byte, Src Picture, Mask Picture, Dst Picture, SrcX int16, SrcY int16, MaskX int16, MaskY int16, DstX int16, DstY int16, Width uint16, Height uint16) []byte {
   1832 	size := 36
   1833 	b := 0
   1834 	buf := make([]byte, size)
   1835 
   1836 	c.ExtLock.RLock()
   1837 	buf[b] = c.Extensions["RENDER"]
   1838 	c.ExtLock.RUnlock()
   1839 	b += 1
   1840 
   1841 	buf[b] = 8 // request opcode
   1842 	b += 1
   1843 
   1844 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   1845 	b += 2
   1846 
   1847 	buf[b] = Op
   1848 	b += 1
   1849 
   1850 	b += 3 // padding
   1851 
   1852 	xgb.Put32(buf[b:], uint32(Src))
   1853 	b += 4
   1854 
   1855 	xgb.Put32(buf[b:], uint32(Mask))
   1856 	b += 4
   1857 
   1858 	xgb.Put32(buf[b:], uint32(Dst))
   1859 	b += 4
   1860 
   1861 	xgb.Put16(buf[b:], uint16(SrcX))
   1862 	b += 2
   1863 
   1864 	xgb.Put16(buf[b:], uint16(SrcY))
   1865 	b += 2
   1866 
   1867 	xgb.Put16(buf[b:], uint16(MaskX))
   1868 	b += 2
   1869 
   1870 	xgb.Put16(buf[b:], uint16(MaskY))
   1871 	b += 2
   1872 
   1873 	xgb.Put16(buf[b:], uint16(DstX))
   1874 	b += 2
   1875 
   1876 	xgb.Put16(buf[b:], uint16(DstY))
   1877 	b += 2
   1878 
   1879 	xgb.Put16(buf[b:], Width)
   1880 	b += 2
   1881 
   1882 	xgb.Put16(buf[b:], Height)
   1883 	b += 2
   1884 
   1885 	return buf
   1886 }
   1887 
   1888 // CompositeGlyphs16Cookie is a cookie used only for CompositeGlyphs16 requests.
   1889 type CompositeGlyphs16Cookie struct {
   1890 	*xgb.Cookie
   1891 }
   1892 
   1893 // CompositeGlyphs16 sends an unchecked request.
   1894 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   1895 func CompositeGlyphs16(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie {
   1896 	c.ExtLock.RLock()
   1897 	defer c.ExtLock.RUnlock()
   1898 	if _, ok := c.Extensions["RENDER"]; !ok {
   1899 		panic("Cannot issue request 'CompositeGlyphs16' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   1900 	}
   1901 	cookie := c.NewCookie(false, false)
   1902 	c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie)
   1903 	return CompositeGlyphs16Cookie{cookie}
   1904 }
   1905 
   1906 // CompositeGlyphs16Checked sends a checked request.
   1907 // If an error occurs, it can be retrieved using CompositeGlyphs16Cookie.Check()
   1908 func CompositeGlyphs16Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs16Cookie {
   1909 	c.ExtLock.RLock()
   1910 	defer c.ExtLock.RUnlock()
   1911 	if _, ok := c.Extensions["RENDER"]; !ok {
   1912 		panic("Cannot issue request 'CompositeGlyphs16' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   1913 	}
   1914 	cookie := c.NewCookie(true, false)
   1915 	c.NewRequest(compositeGlyphs16Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie)
   1916 	return CompositeGlyphs16Cookie{cookie}
   1917 }
   1918 
   1919 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   1920 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   1921 func (cook CompositeGlyphs16Cookie) Check() error {
   1922 	return cook.Cookie.Check()
   1923 }
   1924 
   1925 // Write request to wire for CompositeGlyphs16
   1926 // compositeGlyphs16Request writes a CompositeGlyphs16 request to a byte slice.
   1927 func compositeGlyphs16Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte {
   1928 	size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1))))
   1929 	b := 0
   1930 	buf := make([]byte, size)
   1931 
   1932 	c.ExtLock.RLock()
   1933 	buf[b] = c.Extensions["RENDER"]
   1934 	c.ExtLock.RUnlock()
   1935 	b += 1
   1936 
   1937 	buf[b] = 24 // request opcode
   1938 	b += 1
   1939 
   1940 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   1941 	b += 2
   1942 
   1943 	buf[b] = Op
   1944 	b += 1
   1945 
   1946 	b += 3 // padding
   1947 
   1948 	xgb.Put32(buf[b:], uint32(Src))
   1949 	b += 4
   1950 
   1951 	xgb.Put32(buf[b:], uint32(Dst))
   1952 	b += 4
   1953 
   1954 	xgb.Put32(buf[b:], uint32(MaskFormat))
   1955 	b += 4
   1956 
   1957 	xgb.Put32(buf[b:], uint32(Glyphset))
   1958 	b += 4
   1959 
   1960 	xgb.Put16(buf[b:], uint16(SrcX))
   1961 	b += 2
   1962 
   1963 	xgb.Put16(buf[b:], uint16(SrcY))
   1964 	b += 2
   1965 
   1966 	copy(buf[b:], Glyphcmds[:len(Glyphcmds)])
   1967 	b += int(len(Glyphcmds))
   1968 
   1969 	return buf
   1970 }
   1971 
   1972 // CompositeGlyphs32Cookie is a cookie used only for CompositeGlyphs32 requests.
   1973 type CompositeGlyphs32Cookie struct {
   1974 	*xgb.Cookie
   1975 }
   1976 
   1977 // CompositeGlyphs32 sends an unchecked request.
   1978 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   1979 func CompositeGlyphs32(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie {
   1980 	c.ExtLock.RLock()
   1981 	defer c.ExtLock.RUnlock()
   1982 	if _, ok := c.Extensions["RENDER"]; !ok {
   1983 		panic("Cannot issue request 'CompositeGlyphs32' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   1984 	}
   1985 	cookie := c.NewCookie(false, false)
   1986 	c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie)
   1987 	return CompositeGlyphs32Cookie{cookie}
   1988 }
   1989 
   1990 // CompositeGlyphs32Checked sends a checked request.
   1991 // If an error occurs, it can be retrieved using CompositeGlyphs32Cookie.Check()
   1992 func CompositeGlyphs32Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs32Cookie {
   1993 	c.ExtLock.RLock()
   1994 	defer c.ExtLock.RUnlock()
   1995 	if _, ok := c.Extensions["RENDER"]; !ok {
   1996 		panic("Cannot issue request 'CompositeGlyphs32' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   1997 	}
   1998 	cookie := c.NewCookie(true, false)
   1999 	c.NewRequest(compositeGlyphs32Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie)
   2000 	return CompositeGlyphs32Cookie{cookie}
   2001 }
   2002 
   2003 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2004 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2005 func (cook CompositeGlyphs32Cookie) Check() error {
   2006 	return cook.Cookie.Check()
   2007 }
   2008 
   2009 // Write request to wire for CompositeGlyphs32
   2010 // compositeGlyphs32Request writes a CompositeGlyphs32 request to a byte slice.
   2011 func compositeGlyphs32Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte {
   2012 	size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1))))
   2013 	b := 0
   2014 	buf := make([]byte, size)
   2015 
   2016 	c.ExtLock.RLock()
   2017 	buf[b] = c.Extensions["RENDER"]
   2018 	c.ExtLock.RUnlock()
   2019 	b += 1
   2020 
   2021 	buf[b] = 25 // request opcode
   2022 	b += 1
   2023 
   2024 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   2025 	b += 2
   2026 
   2027 	buf[b] = Op
   2028 	b += 1
   2029 
   2030 	b += 3 // padding
   2031 
   2032 	xgb.Put32(buf[b:], uint32(Src))
   2033 	b += 4
   2034 
   2035 	xgb.Put32(buf[b:], uint32(Dst))
   2036 	b += 4
   2037 
   2038 	xgb.Put32(buf[b:], uint32(MaskFormat))
   2039 	b += 4
   2040 
   2041 	xgb.Put32(buf[b:], uint32(Glyphset))
   2042 	b += 4
   2043 
   2044 	xgb.Put16(buf[b:], uint16(SrcX))
   2045 	b += 2
   2046 
   2047 	xgb.Put16(buf[b:], uint16(SrcY))
   2048 	b += 2
   2049 
   2050 	copy(buf[b:], Glyphcmds[:len(Glyphcmds)])
   2051 	b += int(len(Glyphcmds))
   2052 
   2053 	return buf
   2054 }
   2055 
   2056 // CompositeGlyphs8Cookie is a cookie used only for CompositeGlyphs8 requests.
   2057 type CompositeGlyphs8Cookie struct {
   2058 	*xgb.Cookie
   2059 }
   2060 
   2061 // CompositeGlyphs8 sends an unchecked request.
   2062 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2063 func CompositeGlyphs8(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie {
   2064 	c.ExtLock.RLock()
   2065 	defer c.ExtLock.RUnlock()
   2066 	if _, ok := c.Extensions["RENDER"]; !ok {
   2067 		panic("Cannot issue request 'CompositeGlyphs8' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2068 	}
   2069 	cookie := c.NewCookie(false, false)
   2070 	c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie)
   2071 	return CompositeGlyphs8Cookie{cookie}
   2072 }
   2073 
   2074 // CompositeGlyphs8Checked sends a checked request.
   2075 // If an error occurs, it can be retrieved using CompositeGlyphs8Cookie.Check()
   2076 func CompositeGlyphs8Checked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) CompositeGlyphs8Cookie {
   2077 	c.ExtLock.RLock()
   2078 	defer c.ExtLock.RUnlock()
   2079 	if _, ok := c.Extensions["RENDER"]; !ok {
   2080 		panic("Cannot issue request 'CompositeGlyphs8' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2081 	}
   2082 	cookie := c.NewCookie(true, false)
   2083 	c.NewRequest(compositeGlyphs8Request(c, Op, Src, Dst, MaskFormat, Glyphset, SrcX, SrcY, Glyphcmds), cookie)
   2084 	return CompositeGlyphs8Cookie{cookie}
   2085 }
   2086 
   2087 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2088 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2089 func (cook CompositeGlyphs8Cookie) Check() error {
   2090 	return cook.Cookie.Check()
   2091 }
   2092 
   2093 // Write request to wire for CompositeGlyphs8
   2094 // compositeGlyphs8Request writes a CompositeGlyphs8 request to a byte slice.
   2095 func compositeGlyphs8Request(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, Glyphset Glyphset, SrcX int16, SrcY int16, Glyphcmds []byte) []byte {
   2096 	size := xgb.Pad((28 + xgb.Pad((len(Glyphcmds) * 1))))
   2097 	b := 0
   2098 	buf := make([]byte, size)
   2099 
   2100 	c.ExtLock.RLock()
   2101 	buf[b] = c.Extensions["RENDER"]
   2102 	c.ExtLock.RUnlock()
   2103 	b += 1
   2104 
   2105 	buf[b] = 23 // request opcode
   2106 	b += 1
   2107 
   2108 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   2109 	b += 2
   2110 
   2111 	buf[b] = Op
   2112 	b += 1
   2113 
   2114 	b += 3 // padding
   2115 
   2116 	xgb.Put32(buf[b:], uint32(Src))
   2117 	b += 4
   2118 
   2119 	xgb.Put32(buf[b:], uint32(Dst))
   2120 	b += 4
   2121 
   2122 	xgb.Put32(buf[b:], uint32(MaskFormat))
   2123 	b += 4
   2124 
   2125 	xgb.Put32(buf[b:], uint32(Glyphset))
   2126 	b += 4
   2127 
   2128 	xgb.Put16(buf[b:], uint16(SrcX))
   2129 	b += 2
   2130 
   2131 	xgb.Put16(buf[b:], uint16(SrcY))
   2132 	b += 2
   2133 
   2134 	copy(buf[b:], Glyphcmds[:len(Glyphcmds)])
   2135 	b += int(len(Glyphcmds))
   2136 
   2137 	return buf
   2138 }
   2139 
   2140 // CreateAnimCursorCookie is a cookie used only for CreateAnimCursor requests.
   2141 type CreateAnimCursorCookie struct {
   2142 	*xgb.Cookie
   2143 }
   2144 
   2145 // CreateAnimCursor sends an unchecked request.
   2146 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2147 func CreateAnimCursor(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie {
   2148 	c.ExtLock.RLock()
   2149 	defer c.ExtLock.RUnlock()
   2150 	if _, ok := c.Extensions["RENDER"]; !ok {
   2151 		panic("Cannot issue request 'CreateAnimCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2152 	}
   2153 	cookie := c.NewCookie(false, false)
   2154 	c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie)
   2155 	return CreateAnimCursorCookie{cookie}
   2156 }
   2157 
   2158 // CreateAnimCursorChecked sends a checked request.
   2159 // If an error occurs, it can be retrieved using CreateAnimCursorCookie.Check()
   2160 func CreateAnimCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) CreateAnimCursorCookie {
   2161 	c.ExtLock.RLock()
   2162 	defer c.ExtLock.RUnlock()
   2163 	if _, ok := c.Extensions["RENDER"]; !ok {
   2164 		panic("Cannot issue request 'CreateAnimCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2165 	}
   2166 	cookie := c.NewCookie(true, false)
   2167 	c.NewRequest(createAnimCursorRequest(c, Cid, Cursors), cookie)
   2168 	return CreateAnimCursorCookie{cookie}
   2169 }
   2170 
   2171 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2172 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2173 func (cook CreateAnimCursorCookie) Check() error {
   2174 	return cook.Cookie.Check()
   2175 }
   2176 
   2177 // Write request to wire for CreateAnimCursor
   2178 // createAnimCursorRequest writes a CreateAnimCursor request to a byte slice.
   2179 func createAnimCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Cursors []Animcursorelt) []byte {
   2180 	size := xgb.Pad((8 + xgb.Pad((len(Cursors) * 8))))
   2181 	b := 0
   2182 	buf := make([]byte, size)
   2183 
   2184 	c.ExtLock.RLock()
   2185 	buf[b] = c.Extensions["RENDER"]
   2186 	c.ExtLock.RUnlock()
   2187 	b += 1
   2188 
   2189 	buf[b] = 31 // request opcode
   2190 	b += 1
   2191 
   2192 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   2193 	b += 2
   2194 
   2195 	xgb.Put32(buf[b:], uint32(Cid))
   2196 	b += 4
   2197 
   2198 	b += AnimcursoreltListBytes(buf[b:], Cursors)
   2199 
   2200 	return buf
   2201 }
   2202 
   2203 // CreateConicalGradientCookie is a cookie used only for CreateConicalGradient requests.
   2204 type CreateConicalGradientCookie struct {
   2205 	*xgb.Cookie
   2206 }
   2207 
   2208 // CreateConicalGradient sends an unchecked request.
   2209 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2210 func CreateConicalGradient(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie {
   2211 	c.ExtLock.RLock()
   2212 	defer c.ExtLock.RUnlock()
   2213 	if _, ok := c.Extensions["RENDER"]; !ok {
   2214 		panic("Cannot issue request 'CreateConicalGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2215 	}
   2216 	cookie := c.NewCookie(false, false)
   2217 	c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie)
   2218 	return CreateConicalGradientCookie{cookie}
   2219 }
   2220 
   2221 // CreateConicalGradientChecked sends a checked request.
   2222 // If an error occurs, it can be retrieved using CreateConicalGradientCookie.Check()
   2223 func CreateConicalGradientChecked(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateConicalGradientCookie {
   2224 	c.ExtLock.RLock()
   2225 	defer c.ExtLock.RUnlock()
   2226 	if _, ok := c.Extensions["RENDER"]; !ok {
   2227 		panic("Cannot issue request 'CreateConicalGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2228 	}
   2229 	cookie := c.NewCookie(true, false)
   2230 	c.NewRequest(createConicalGradientRequest(c, Picture, Center, Angle, NumStops, Stops, Colors), cookie)
   2231 	return CreateConicalGradientCookie{cookie}
   2232 }
   2233 
   2234 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2235 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2236 func (cook CreateConicalGradientCookie) Check() error {
   2237 	return cook.Cookie.Check()
   2238 }
   2239 
   2240 // Write request to wire for CreateConicalGradient
   2241 // createConicalGradientRequest writes a CreateConicalGradient request to a byte slice.
   2242 func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix, Angle Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte {
   2243 	size := xgb.Pad((((24 + xgb.Pad((int(NumStops) * 4))) + 4) + xgb.Pad((int(NumStops) * 8))))
   2244 	b := 0
   2245 	buf := make([]byte, size)
   2246 
   2247 	c.ExtLock.RLock()
   2248 	buf[b] = c.Extensions["RENDER"]
   2249 	c.ExtLock.RUnlock()
   2250 	b += 1
   2251 
   2252 	buf[b] = 36 // request opcode
   2253 	b += 1
   2254 
   2255 	blen := b
   2256 	b += 2
   2257 
   2258 	xgb.Put32(buf[b:], uint32(Picture))
   2259 	b += 4
   2260 
   2261 	{
   2262 		structBytes := Center.Bytes()
   2263 		copy(buf[b:], structBytes)
   2264 		b += len(structBytes)
   2265 	}
   2266 
   2267 	xgb.Put32(buf[b:], uint32(Angle))
   2268 	b += 4
   2269 
   2270 	xgb.Put32(buf[b:], NumStops)
   2271 	b += 4
   2272 
   2273 	for i := 0; i < int(NumStops); i++ {
   2274 		xgb.Put32(buf[b:], uint32(Stops[i]))
   2275 		b += 4
   2276 	}
   2277 
   2278 	b = (b + 3) & ^3 // alignment gap
   2279 
   2280 	b += ColorListBytes(buf[b:], Colors)
   2281 
   2282 	b = xgb.Pad(b)
   2283 	xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
   2284 	return buf[:b]
   2285 }
   2286 
   2287 // CreateCursorCookie is a cookie used only for CreateCursor requests.
   2288 type CreateCursorCookie struct {
   2289 	*xgb.Cookie
   2290 }
   2291 
   2292 // CreateCursor sends an unchecked request.
   2293 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2294 func CreateCursor(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie {
   2295 	c.ExtLock.RLock()
   2296 	defer c.ExtLock.RUnlock()
   2297 	if _, ok := c.Extensions["RENDER"]; !ok {
   2298 		panic("Cannot issue request 'CreateCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2299 	}
   2300 	cookie := c.NewCookie(false, false)
   2301 	c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie)
   2302 	return CreateCursorCookie{cookie}
   2303 }
   2304 
   2305 // CreateCursorChecked sends a checked request.
   2306 // If an error occurs, it can be retrieved using CreateCursorCookie.Check()
   2307 func CreateCursorChecked(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) CreateCursorCookie {
   2308 	c.ExtLock.RLock()
   2309 	defer c.ExtLock.RUnlock()
   2310 	if _, ok := c.Extensions["RENDER"]; !ok {
   2311 		panic("Cannot issue request 'CreateCursor' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2312 	}
   2313 	cookie := c.NewCookie(true, false)
   2314 	c.NewRequest(createCursorRequest(c, Cid, Source, X, Y), cookie)
   2315 	return CreateCursorCookie{cookie}
   2316 }
   2317 
   2318 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2319 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2320 func (cook CreateCursorCookie) Check() error {
   2321 	return cook.Cookie.Check()
   2322 }
   2323 
   2324 // Write request to wire for CreateCursor
   2325 // createCursorRequest writes a CreateCursor request to a byte slice.
   2326 func createCursorRequest(c *xgb.Conn, Cid xproto.Cursor, Source Picture, X uint16, Y uint16) []byte {
   2327 	size := 16
   2328 	b := 0
   2329 	buf := make([]byte, size)
   2330 
   2331 	c.ExtLock.RLock()
   2332 	buf[b] = c.Extensions["RENDER"]
   2333 	c.ExtLock.RUnlock()
   2334 	b += 1
   2335 
   2336 	buf[b] = 27 // request opcode
   2337 	b += 1
   2338 
   2339 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   2340 	b += 2
   2341 
   2342 	xgb.Put32(buf[b:], uint32(Cid))
   2343 	b += 4
   2344 
   2345 	xgb.Put32(buf[b:], uint32(Source))
   2346 	b += 4
   2347 
   2348 	xgb.Put16(buf[b:], X)
   2349 	b += 2
   2350 
   2351 	xgb.Put16(buf[b:], Y)
   2352 	b += 2
   2353 
   2354 	return buf
   2355 }
   2356 
   2357 // CreateGlyphSetCookie is a cookie used only for CreateGlyphSet requests.
   2358 type CreateGlyphSetCookie struct {
   2359 	*xgb.Cookie
   2360 }
   2361 
   2362 // CreateGlyphSet sends an unchecked request.
   2363 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2364 func CreateGlyphSet(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie {
   2365 	c.ExtLock.RLock()
   2366 	defer c.ExtLock.RUnlock()
   2367 	if _, ok := c.Extensions["RENDER"]; !ok {
   2368 		panic("Cannot issue request 'CreateGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2369 	}
   2370 	cookie := c.NewCookie(false, false)
   2371 	c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie)
   2372 	return CreateGlyphSetCookie{cookie}
   2373 }
   2374 
   2375 // CreateGlyphSetChecked sends a checked request.
   2376 // If an error occurs, it can be retrieved using CreateGlyphSetCookie.Check()
   2377 func CreateGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Format Pictformat) CreateGlyphSetCookie {
   2378 	c.ExtLock.RLock()
   2379 	defer c.ExtLock.RUnlock()
   2380 	if _, ok := c.Extensions["RENDER"]; !ok {
   2381 		panic("Cannot issue request 'CreateGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2382 	}
   2383 	cookie := c.NewCookie(true, false)
   2384 	c.NewRequest(createGlyphSetRequest(c, Gsid, Format), cookie)
   2385 	return CreateGlyphSetCookie{cookie}
   2386 }
   2387 
   2388 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2389 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2390 func (cook CreateGlyphSetCookie) Check() error {
   2391 	return cook.Cookie.Check()
   2392 }
   2393 
   2394 // Write request to wire for CreateGlyphSet
   2395 // createGlyphSetRequest writes a CreateGlyphSet request to a byte slice.
   2396 func createGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Format Pictformat) []byte {
   2397 	size := 12
   2398 	b := 0
   2399 	buf := make([]byte, size)
   2400 
   2401 	c.ExtLock.RLock()
   2402 	buf[b] = c.Extensions["RENDER"]
   2403 	c.ExtLock.RUnlock()
   2404 	b += 1
   2405 
   2406 	buf[b] = 17 // request opcode
   2407 	b += 1
   2408 
   2409 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   2410 	b += 2
   2411 
   2412 	xgb.Put32(buf[b:], uint32(Gsid))
   2413 	b += 4
   2414 
   2415 	xgb.Put32(buf[b:], uint32(Format))
   2416 	b += 4
   2417 
   2418 	return buf
   2419 }
   2420 
   2421 // CreateLinearGradientCookie is a cookie used only for CreateLinearGradient requests.
   2422 type CreateLinearGradientCookie struct {
   2423 	*xgb.Cookie
   2424 }
   2425 
   2426 // CreateLinearGradient sends an unchecked request.
   2427 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2428 func CreateLinearGradient(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie {
   2429 	c.ExtLock.RLock()
   2430 	defer c.ExtLock.RUnlock()
   2431 	if _, ok := c.Extensions["RENDER"]; !ok {
   2432 		panic("Cannot issue request 'CreateLinearGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2433 	}
   2434 	cookie := c.NewCookie(false, false)
   2435 	c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie)
   2436 	return CreateLinearGradientCookie{cookie}
   2437 }
   2438 
   2439 // CreateLinearGradientChecked sends a checked request.
   2440 // If an error occurs, it can be retrieved using CreateLinearGradientCookie.Check()
   2441 func CreateLinearGradientChecked(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) CreateLinearGradientCookie {
   2442 	c.ExtLock.RLock()
   2443 	defer c.ExtLock.RUnlock()
   2444 	if _, ok := c.Extensions["RENDER"]; !ok {
   2445 		panic("Cannot issue request 'CreateLinearGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2446 	}
   2447 	cookie := c.NewCookie(true, false)
   2448 	c.NewRequest(createLinearGradientRequest(c, Picture, P1, P2, NumStops, Stops, Colors), cookie)
   2449 	return CreateLinearGradientCookie{cookie}
   2450 }
   2451 
   2452 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2453 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2454 func (cook CreateLinearGradientCookie) Check() error {
   2455 	return cook.Cookie.Check()
   2456 }
   2457 
   2458 // Write request to wire for CreateLinearGradient
   2459 // createLinearGradientRequest writes a CreateLinearGradient request to a byte slice.
   2460 func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 Pointfix, NumStops uint32, Stops []Fixed, Colors []Color) []byte {
   2461 	size := xgb.Pad((((28 + xgb.Pad((int(NumStops) * 4))) + 4) + xgb.Pad((int(NumStops) * 8))))
   2462 	b := 0
   2463 	buf := make([]byte, size)
   2464 
   2465 	c.ExtLock.RLock()
   2466 	buf[b] = c.Extensions["RENDER"]
   2467 	c.ExtLock.RUnlock()
   2468 	b += 1
   2469 
   2470 	buf[b] = 34 // request opcode
   2471 	b += 1
   2472 
   2473 	blen := b
   2474 	b += 2
   2475 
   2476 	xgb.Put32(buf[b:], uint32(Picture))
   2477 	b += 4
   2478 
   2479 	{
   2480 		structBytes := P1.Bytes()
   2481 		copy(buf[b:], structBytes)
   2482 		b += len(structBytes)
   2483 	}
   2484 
   2485 	{
   2486 		structBytes := P2.Bytes()
   2487 		copy(buf[b:], structBytes)
   2488 		b += len(structBytes)
   2489 	}
   2490 
   2491 	xgb.Put32(buf[b:], NumStops)
   2492 	b += 4
   2493 
   2494 	for i := 0; i < int(NumStops); i++ {
   2495 		xgb.Put32(buf[b:], uint32(Stops[i]))
   2496 		b += 4
   2497 	}
   2498 
   2499 	b = (b + 3) & ^3 // alignment gap
   2500 
   2501 	b += ColorListBytes(buf[b:], Colors)
   2502 
   2503 	b = xgb.Pad(b)
   2504 	xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
   2505 	return buf[:b]
   2506 }
   2507 
   2508 // CreatePictureCookie is a cookie used only for CreatePicture requests.
   2509 type CreatePictureCookie struct {
   2510 	*xgb.Cookie
   2511 }
   2512 
   2513 // CreatePicture sends an unchecked request.
   2514 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2515 func CreatePicture(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie {
   2516 	c.ExtLock.RLock()
   2517 	defer c.ExtLock.RUnlock()
   2518 	if _, ok := c.Extensions["RENDER"]; !ok {
   2519 		panic("Cannot issue request 'CreatePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2520 	}
   2521 	cookie := c.NewCookie(false, false)
   2522 	c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie)
   2523 	return CreatePictureCookie{cookie}
   2524 }
   2525 
   2526 // CreatePictureChecked sends a checked request.
   2527 // If an error occurs, it can be retrieved using CreatePictureCookie.Check()
   2528 func CreatePictureChecked(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) CreatePictureCookie {
   2529 	c.ExtLock.RLock()
   2530 	defer c.ExtLock.RUnlock()
   2531 	if _, ok := c.Extensions["RENDER"]; !ok {
   2532 		panic("Cannot issue request 'CreatePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2533 	}
   2534 	cookie := c.NewCookie(true, false)
   2535 	c.NewRequest(createPictureRequest(c, Pid, Drawable, Format, ValueMask, ValueList), cookie)
   2536 	return CreatePictureCookie{cookie}
   2537 }
   2538 
   2539 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2540 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2541 func (cook CreatePictureCookie) Check() error {
   2542 	return cook.Cookie.Check()
   2543 }
   2544 
   2545 // Write request to wire for CreatePicture
   2546 // createPictureRequest writes a CreatePicture request to a byte slice.
   2547 func createPictureRequest(c *xgb.Conn, Pid Picture, Drawable xproto.Drawable, Format Pictformat, ValueMask uint32, ValueList []uint32) []byte {
   2548 	size := xgb.Pad((16 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask)))))))
   2549 	b := 0
   2550 	buf := make([]byte, size)
   2551 
   2552 	c.ExtLock.RLock()
   2553 	buf[b] = c.Extensions["RENDER"]
   2554 	c.ExtLock.RUnlock()
   2555 	b += 1
   2556 
   2557 	buf[b] = 4 // request opcode
   2558 	b += 1
   2559 
   2560 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   2561 	b += 2
   2562 
   2563 	xgb.Put32(buf[b:], uint32(Pid))
   2564 	b += 4
   2565 
   2566 	xgb.Put32(buf[b:], uint32(Drawable))
   2567 	b += 4
   2568 
   2569 	xgb.Put32(buf[b:], uint32(Format))
   2570 	b += 4
   2571 
   2572 	xgb.Put32(buf[b:], ValueMask)
   2573 	b += 4
   2574 	for i := 0; i < xgb.PopCount(int(ValueMask)); i++ {
   2575 		xgb.Put32(buf[b:], ValueList[i])
   2576 		b += 4
   2577 	}
   2578 	b = xgb.Pad(b)
   2579 
   2580 	return buf
   2581 }
   2582 
   2583 // CreateRadialGradientCookie is a cookie used only for CreateRadialGradient requests.
   2584 type CreateRadialGradientCookie struct {
   2585 	*xgb.Cookie
   2586 }
   2587 
   2588 // CreateRadialGradient sends an unchecked request.
   2589 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2590 func CreateRadialGradient(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie {
   2591 	c.ExtLock.RLock()
   2592 	defer c.ExtLock.RUnlock()
   2593 	if _, ok := c.Extensions["RENDER"]; !ok {
   2594 		panic("Cannot issue request 'CreateRadialGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2595 	}
   2596 	cookie := c.NewCookie(false, false)
   2597 	c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie)
   2598 	return CreateRadialGradientCookie{cookie}
   2599 }
   2600 
   2601 // CreateRadialGradientChecked sends a checked request.
   2602 // If an error occurs, it can be retrieved using CreateRadialGradientCookie.Check()
   2603 func CreateRadialGradientChecked(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) CreateRadialGradientCookie {
   2604 	c.ExtLock.RLock()
   2605 	defer c.ExtLock.RUnlock()
   2606 	if _, ok := c.Extensions["RENDER"]; !ok {
   2607 		panic("Cannot issue request 'CreateRadialGradient' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2608 	}
   2609 	cookie := c.NewCookie(true, false)
   2610 	c.NewRequest(createRadialGradientRequest(c, Picture, Inner, Outer, InnerRadius, OuterRadius, NumStops, Stops, Colors), cookie)
   2611 	return CreateRadialGradientCookie{cookie}
   2612 }
   2613 
   2614 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2615 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2616 func (cook CreateRadialGradientCookie) Check() error {
   2617 	return cook.Cookie.Check()
   2618 }
   2619 
   2620 // Write request to wire for CreateRadialGradient
   2621 // createRadialGradientRequest writes a CreateRadialGradient request to a byte slice.
   2622 func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, Outer Pointfix, InnerRadius Fixed, OuterRadius Fixed, NumStops uint32, Stops []Fixed, Colors []Color) []byte {
   2623 	size := xgb.Pad((((36 + xgb.Pad((int(NumStops) * 4))) + 4) + xgb.Pad((int(NumStops) * 8))))
   2624 	b := 0
   2625 	buf := make([]byte, size)
   2626 
   2627 	c.ExtLock.RLock()
   2628 	buf[b] = c.Extensions["RENDER"]
   2629 	c.ExtLock.RUnlock()
   2630 	b += 1
   2631 
   2632 	buf[b] = 35 // request opcode
   2633 	b += 1
   2634 
   2635 	blen := b
   2636 	b += 2
   2637 
   2638 	xgb.Put32(buf[b:], uint32(Picture))
   2639 	b += 4
   2640 
   2641 	{
   2642 		structBytes := Inner.Bytes()
   2643 		copy(buf[b:], structBytes)
   2644 		b += len(structBytes)
   2645 	}
   2646 
   2647 	{
   2648 		structBytes := Outer.Bytes()
   2649 		copy(buf[b:], structBytes)
   2650 		b += len(structBytes)
   2651 	}
   2652 
   2653 	xgb.Put32(buf[b:], uint32(InnerRadius))
   2654 	b += 4
   2655 
   2656 	xgb.Put32(buf[b:], uint32(OuterRadius))
   2657 	b += 4
   2658 
   2659 	xgb.Put32(buf[b:], NumStops)
   2660 	b += 4
   2661 
   2662 	for i := 0; i < int(NumStops); i++ {
   2663 		xgb.Put32(buf[b:], uint32(Stops[i]))
   2664 		b += 4
   2665 	}
   2666 
   2667 	b = (b + 3) & ^3 // alignment gap
   2668 
   2669 	b += ColorListBytes(buf[b:], Colors)
   2670 
   2671 	b = xgb.Pad(b)
   2672 	xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
   2673 	return buf[:b]
   2674 }
   2675 
   2676 // CreateSolidFillCookie is a cookie used only for CreateSolidFill requests.
   2677 type CreateSolidFillCookie struct {
   2678 	*xgb.Cookie
   2679 }
   2680 
   2681 // CreateSolidFill sends an unchecked request.
   2682 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2683 func CreateSolidFill(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie {
   2684 	c.ExtLock.RLock()
   2685 	defer c.ExtLock.RUnlock()
   2686 	if _, ok := c.Extensions["RENDER"]; !ok {
   2687 		panic("Cannot issue request 'CreateSolidFill' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2688 	}
   2689 	cookie := c.NewCookie(false, false)
   2690 	c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie)
   2691 	return CreateSolidFillCookie{cookie}
   2692 }
   2693 
   2694 // CreateSolidFillChecked sends a checked request.
   2695 // If an error occurs, it can be retrieved using CreateSolidFillCookie.Check()
   2696 func CreateSolidFillChecked(c *xgb.Conn, Picture Picture, Color Color) CreateSolidFillCookie {
   2697 	c.ExtLock.RLock()
   2698 	defer c.ExtLock.RUnlock()
   2699 	if _, ok := c.Extensions["RENDER"]; !ok {
   2700 		panic("Cannot issue request 'CreateSolidFill' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2701 	}
   2702 	cookie := c.NewCookie(true, false)
   2703 	c.NewRequest(createSolidFillRequest(c, Picture, Color), cookie)
   2704 	return CreateSolidFillCookie{cookie}
   2705 }
   2706 
   2707 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2708 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2709 func (cook CreateSolidFillCookie) Check() error {
   2710 	return cook.Cookie.Check()
   2711 }
   2712 
   2713 // Write request to wire for CreateSolidFill
   2714 // createSolidFillRequest writes a CreateSolidFill request to a byte slice.
   2715 func createSolidFillRequest(c *xgb.Conn, Picture Picture, Color Color) []byte {
   2716 	size := 16
   2717 	b := 0
   2718 	buf := make([]byte, size)
   2719 
   2720 	c.ExtLock.RLock()
   2721 	buf[b] = c.Extensions["RENDER"]
   2722 	c.ExtLock.RUnlock()
   2723 	b += 1
   2724 
   2725 	buf[b] = 33 // request opcode
   2726 	b += 1
   2727 
   2728 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   2729 	b += 2
   2730 
   2731 	xgb.Put32(buf[b:], uint32(Picture))
   2732 	b += 4
   2733 
   2734 	{
   2735 		structBytes := Color.Bytes()
   2736 		copy(buf[b:], structBytes)
   2737 		b += len(structBytes)
   2738 	}
   2739 
   2740 	return buf
   2741 }
   2742 
   2743 // FillRectanglesCookie is a cookie used only for FillRectangles requests.
   2744 type FillRectanglesCookie struct {
   2745 	*xgb.Cookie
   2746 }
   2747 
   2748 // FillRectangles sends an unchecked request.
   2749 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2750 func FillRectangles(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie {
   2751 	c.ExtLock.RLock()
   2752 	defer c.ExtLock.RUnlock()
   2753 	if _, ok := c.Extensions["RENDER"]; !ok {
   2754 		panic("Cannot issue request 'FillRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2755 	}
   2756 	cookie := c.NewCookie(false, false)
   2757 	c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie)
   2758 	return FillRectanglesCookie{cookie}
   2759 }
   2760 
   2761 // FillRectanglesChecked sends a checked request.
   2762 // If an error occurs, it can be retrieved using FillRectanglesCookie.Check()
   2763 func FillRectanglesChecked(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) FillRectanglesCookie {
   2764 	c.ExtLock.RLock()
   2765 	defer c.ExtLock.RUnlock()
   2766 	if _, ok := c.Extensions["RENDER"]; !ok {
   2767 		panic("Cannot issue request 'FillRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2768 	}
   2769 	cookie := c.NewCookie(true, false)
   2770 	c.NewRequest(fillRectanglesRequest(c, Op, Dst, Color, Rects), cookie)
   2771 	return FillRectanglesCookie{cookie}
   2772 }
   2773 
   2774 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2775 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2776 func (cook FillRectanglesCookie) Check() error {
   2777 	return cook.Cookie.Check()
   2778 }
   2779 
   2780 // Write request to wire for FillRectangles
   2781 // fillRectanglesRequest writes a FillRectangles request to a byte slice.
   2782 func fillRectanglesRequest(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects []xproto.Rectangle) []byte {
   2783 	size := xgb.Pad((20 + xgb.Pad((len(Rects) * 8))))
   2784 	b := 0
   2785 	buf := make([]byte, size)
   2786 
   2787 	c.ExtLock.RLock()
   2788 	buf[b] = c.Extensions["RENDER"]
   2789 	c.ExtLock.RUnlock()
   2790 	b += 1
   2791 
   2792 	buf[b] = 26 // request opcode
   2793 	b += 1
   2794 
   2795 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   2796 	b += 2
   2797 
   2798 	buf[b] = Op
   2799 	b += 1
   2800 
   2801 	b += 3 // padding
   2802 
   2803 	xgb.Put32(buf[b:], uint32(Dst))
   2804 	b += 4
   2805 
   2806 	{
   2807 		structBytes := Color.Bytes()
   2808 		copy(buf[b:], structBytes)
   2809 		b += len(structBytes)
   2810 	}
   2811 
   2812 	b += xproto.RectangleListBytes(buf[b:], Rects)
   2813 
   2814 	return buf
   2815 }
   2816 
   2817 // FreeGlyphSetCookie is a cookie used only for FreeGlyphSet requests.
   2818 type FreeGlyphSetCookie struct {
   2819 	*xgb.Cookie
   2820 }
   2821 
   2822 // FreeGlyphSet sends an unchecked request.
   2823 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2824 func FreeGlyphSet(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie {
   2825 	c.ExtLock.RLock()
   2826 	defer c.ExtLock.RUnlock()
   2827 	if _, ok := c.Extensions["RENDER"]; !ok {
   2828 		panic("Cannot issue request 'FreeGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2829 	}
   2830 	cookie := c.NewCookie(false, false)
   2831 	c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie)
   2832 	return FreeGlyphSetCookie{cookie}
   2833 }
   2834 
   2835 // FreeGlyphSetChecked sends a checked request.
   2836 // If an error occurs, it can be retrieved using FreeGlyphSetCookie.Check()
   2837 func FreeGlyphSetChecked(c *xgb.Conn, Glyphset Glyphset) FreeGlyphSetCookie {
   2838 	c.ExtLock.RLock()
   2839 	defer c.ExtLock.RUnlock()
   2840 	if _, ok := c.Extensions["RENDER"]; !ok {
   2841 		panic("Cannot issue request 'FreeGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2842 	}
   2843 	cookie := c.NewCookie(true, false)
   2844 	c.NewRequest(freeGlyphSetRequest(c, Glyphset), cookie)
   2845 	return FreeGlyphSetCookie{cookie}
   2846 }
   2847 
   2848 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2849 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2850 func (cook FreeGlyphSetCookie) Check() error {
   2851 	return cook.Cookie.Check()
   2852 }
   2853 
   2854 // Write request to wire for FreeGlyphSet
   2855 // freeGlyphSetRequest writes a FreeGlyphSet request to a byte slice.
   2856 func freeGlyphSetRequest(c *xgb.Conn, Glyphset Glyphset) []byte {
   2857 	size := 8
   2858 	b := 0
   2859 	buf := make([]byte, size)
   2860 
   2861 	c.ExtLock.RLock()
   2862 	buf[b] = c.Extensions["RENDER"]
   2863 	c.ExtLock.RUnlock()
   2864 	b += 1
   2865 
   2866 	buf[b] = 19 // request opcode
   2867 	b += 1
   2868 
   2869 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   2870 	b += 2
   2871 
   2872 	xgb.Put32(buf[b:], uint32(Glyphset))
   2873 	b += 4
   2874 
   2875 	return buf
   2876 }
   2877 
   2878 // FreeGlyphsCookie is a cookie used only for FreeGlyphs requests.
   2879 type FreeGlyphsCookie struct {
   2880 	*xgb.Cookie
   2881 }
   2882 
   2883 // FreeGlyphs sends an unchecked request.
   2884 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2885 func FreeGlyphs(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie {
   2886 	c.ExtLock.RLock()
   2887 	defer c.ExtLock.RUnlock()
   2888 	if _, ok := c.Extensions["RENDER"]; !ok {
   2889 		panic("Cannot issue request 'FreeGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2890 	}
   2891 	cookie := c.NewCookie(false, false)
   2892 	c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie)
   2893 	return FreeGlyphsCookie{cookie}
   2894 }
   2895 
   2896 // FreeGlyphsChecked sends a checked request.
   2897 // If an error occurs, it can be retrieved using FreeGlyphsCookie.Check()
   2898 func FreeGlyphsChecked(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) FreeGlyphsCookie {
   2899 	c.ExtLock.RLock()
   2900 	defer c.ExtLock.RUnlock()
   2901 	if _, ok := c.Extensions["RENDER"]; !ok {
   2902 		panic("Cannot issue request 'FreeGlyphs' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2903 	}
   2904 	cookie := c.NewCookie(true, false)
   2905 	c.NewRequest(freeGlyphsRequest(c, Glyphset, Glyphs), cookie)
   2906 	return FreeGlyphsCookie{cookie}
   2907 }
   2908 
   2909 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2910 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2911 func (cook FreeGlyphsCookie) Check() error {
   2912 	return cook.Cookie.Check()
   2913 }
   2914 
   2915 // Write request to wire for FreeGlyphs
   2916 // freeGlyphsRequest writes a FreeGlyphs request to a byte slice.
   2917 func freeGlyphsRequest(c *xgb.Conn, Glyphset Glyphset, Glyphs []Glyph) []byte {
   2918 	size := xgb.Pad((8 + xgb.Pad((len(Glyphs) * 4))))
   2919 	b := 0
   2920 	buf := make([]byte, size)
   2921 
   2922 	c.ExtLock.RLock()
   2923 	buf[b] = c.Extensions["RENDER"]
   2924 	c.ExtLock.RUnlock()
   2925 	b += 1
   2926 
   2927 	buf[b] = 22 // request opcode
   2928 	b += 1
   2929 
   2930 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   2931 	b += 2
   2932 
   2933 	xgb.Put32(buf[b:], uint32(Glyphset))
   2934 	b += 4
   2935 
   2936 	for i := 0; i < int(len(Glyphs)); i++ {
   2937 		xgb.Put32(buf[b:], uint32(Glyphs[i]))
   2938 		b += 4
   2939 	}
   2940 
   2941 	return buf
   2942 }
   2943 
   2944 // FreePictureCookie is a cookie used only for FreePicture requests.
   2945 type FreePictureCookie struct {
   2946 	*xgb.Cookie
   2947 }
   2948 
   2949 // FreePicture sends an unchecked request.
   2950 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   2951 func FreePicture(c *xgb.Conn, Picture Picture) FreePictureCookie {
   2952 	c.ExtLock.RLock()
   2953 	defer c.ExtLock.RUnlock()
   2954 	if _, ok := c.Extensions["RENDER"]; !ok {
   2955 		panic("Cannot issue request 'FreePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2956 	}
   2957 	cookie := c.NewCookie(false, false)
   2958 	c.NewRequest(freePictureRequest(c, Picture), cookie)
   2959 	return FreePictureCookie{cookie}
   2960 }
   2961 
   2962 // FreePictureChecked sends a checked request.
   2963 // If an error occurs, it can be retrieved using FreePictureCookie.Check()
   2964 func FreePictureChecked(c *xgb.Conn, Picture Picture) FreePictureCookie {
   2965 	c.ExtLock.RLock()
   2966 	defer c.ExtLock.RUnlock()
   2967 	if _, ok := c.Extensions["RENDER"]; !ok {
   2968 		panic("Cannot issue request 'FreePicture' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   2969 	}
   2970 	cookie := c.NewCookie(true, false)
   2971 	c.NewRequest(freePictureRequest(c, Picture), cookie)
   2972 	return FreePictureCookie{cookie}
   2973 }
   2974 
   2975 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   2976 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   2977 func (cook FreePictureCookie) Check() error {
   2978 	return cook.Cookie.Check()
   2979 }
   2980 
   2981 // Write request to wire for FreePicture
   2982 // freePictureRequest writes a FreePicture request to a byte slice.
   2983 func freePictureRequest(c *xgb.Conn, Picture Picture) []byte {
   2984 	size := 8
   2985 	b := 0
   2986 	buf := make([]byte, size)
   2987 
   2988 	c.ExtLock.RLock()
   2989 	buf[b] = c.Extensions["RENDER"]
   2990 	c.ExtLock.RUnlock()
   2991 	b += 1
   2992 
   2993 	buf[b] = 7 // request opcode
   2994 	b += 1
   2995 
   2996 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   2997 	b += 2
   2998 
   2999 	xgb.Put32(buf[b:], uint32(Picture))
   3000 	b += 4
   3001 
   3002 	return buf
   3003 }
   3004 
   3005 // QueryFiltersCookie is a cookie used only for QueryFilters requests.
   3006 type QueryFiltersCookie struct {
   3007 	*xgb.Cookie
   3008 }
   3009 
   3010 // QueryFilters sends a checked request.
   3011 // If an error occurs, it will be returned with the reply by calling QueryFiltersCookie.Reply()
   3012 func QueryFilters(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie {
   3013 	c.ExtLock.RLock()
   3014 	defer c.ExtLock.RUnlock()
   3015 	if _, ok := c.Extensions["RENDER"]; !ok {
   3016 		panic("Cannot issue request 'QueryFilters' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3017 	}
   3018 	cookie := c.NewCookie(true, true)
   3019 	c.NewRequest(queryFiltersRequest(c, Drawable), cookie)
   3020 	return QueryFiltersCookie{cookie}
   3021 }
   3022 
   3023 // QueryFiltersUnchecked sends an unchecked request.
   3024 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   3025 func QueryFiltersUnchecked(c *xgb.Conn, Drawable xproto.Drawable) QueryFiltersCookie {
   3026 	c.ExtLock.RLock()
   3027 	defer c.ExtLock.RUnlock()
   3028 	if _, ok := c.Extensions["RENDER"]; !ok {
   3029 		panic("Cannot issue request 'QueryFilters' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3030 	}
   3031 	cookie := c.NewCookie(false, true)
   3032 	c.NewRequest(queryFiltersRequest(c, Drawable), cookie)
   3033 	return QueryFiltersCookie{cookie}
   3034 }
   3035 
   3036 // QueryFiltersReply represents the data returned from a QueryFilters request.
   3037 type QueryFiltersReply struct {
   3038 	Sequence uint16 // sequence number of the request for this reply
   3039 	Length   uint32 // number of bytes in this reply
   3040 	// padding: 1 bytes
   3041 	NumAliases uint32
   3042 	NumFilters uint32
   3043 	// padding: 16 bytes
   3044 	Aliases []uint16     // size: xgb.Pad((int(NumAliases) * 2))
   3045 	Filters []xproto.Str // size: xproto.StrListSize(Filters)
   3046 }
   3047 
   3048 // Reply blocks and returns the reply data for a QueryFilters request.
   3049 func (cook QueryFiltersCookie) Reply() (*QueryFiltersReply, error) {
   3050 	buf, err := cook.Cookie.Reply()
   3051 	if err != nil {
   3052 		return nil, err
   3053 	}
   3054 	if buf == nil {
   3055 		return nil, nil
   3056 	}
   3057 	return queryFiltersReply(buf), nil
   3058 }
   3059 
   3060 // queryFiltersReply reads a byte slice into a QueryFiltersReply value.
   3061 func queryFiltersReply(buf []byte) *QueryFiltersReply {
   3062 	v := new(QueryFiltersReply)
   3063 	b := 1 // skip reply determinant
   3064 
   3065 	b += 1 // padding
   3066 
   3067 	v.Sequence = xgb.Get16(buf[b:])
   3068 	b += 2
   3069 
   3070 	v.Length = xgb.Get32(buf[b:]) // 4-byte units
   3071 	b += 4
   3072 
   3073 	v.NumAliases = xgb.Get32(buf[b:])
   3074 	b += 4
   3075 
   3076 	v.NumFilters = xgb.Get32(buf[b:])
   3077 	b += 4
   3078 
   3079 	b += 16 // padding
   3080 
   3081 	v.Aliases = make([]uint16, v.NumAliases)
   3082 	for i := 0; i < int(v.NumAliases); i++ {
   3083 		v.Aliases[i] = xgb.Get16(buf[b:])
   3084 		b += 2
   3085 	}
   3086 
   3087 	v.Filters = make([]xproto.Str, v.NumFilters)
   3088 	b += xproto.StrReadList(buf[b:], v.Filters)
   3089 
   3090 	return v
   3091 }
   3092 
   3093 // Write request to wire for QueryFilters
   3094 // queryFiltersRequest writes a QueryFilters request to a byte slice.
   3095 func queryFiltersRequest(c *xgb.Conn, Drawable xproto.Drawable) []byte {
   3096 	size := 8
   3097 	b := 0
   3098 	buf := make([]byte, size)
   3099 
   3100 	c.ExtLock.RLock()
   3101 	buf[b] = c.Extensions["RENDER"]
   3102 	c.ExtLock.RUnlock()
   3103 	b += 1
   3104 
   3105 	buf[b] = 29 // request opcode
   3106 	b += 1
   3107 
   3108 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   3109 	b += 2
   3110 
   3111 	xgb.Put32(buf[b:], uint32(Drawable))
   3112 	b += 4
   3113 
   3114 	return buf
   3115 }
   3116 
   3117 // QueryPictFormatsCookie is a cookie used only for QueryPictFormats requests.
   3118 type QueryPictFormatsCookie struct {
   3119 	*xgb.Cookie
   3120 }
   3121 
   3122 // QueryPictFormats sends a checked request.
   3123 // If an error occurs, it will be returned with the reply by calling QueryPictFormatsCookie.Reply()
   3124 func QueryPictFormats(c *xgb.Conn) QueryPictFormatsCookie {
   3125 	c.ExtLock.RLock()
   3126 	defer c.ExtLock.RUnlock()
   3127 	if _, ok := c.Extensions["RENDER"]; !ok {
   3128 		panic("Cannot issue request 'QueryPictFormats' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3129 	}
   3130 	cookie := c.NewCookie(true, true)
   3131 	c.NewRequest(queryPictFormatsRequest(c), cookie)
   3132 	return QueryPictFormatsCookie{cookie}
   3133 }
   3134 
   3135 // QueryPictFormatsUnchecked sends an unchecked request.
   3136 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   3137 func QueryPictFormatsUnchecked(c *xgb.Conn) QueryPictFormatsCookie {
   3138 	c.ExtLock.RLock()
   3139 	defer c.ExtLock.RUnlock()
   3140 	if _, ok := c.Extensions["RENDER"]; !ok {
   3141 		panic("Cannot issue request 'QueryPictFormats' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3142 	}
   3143 	cookie := c.NewCookie(false, true)
   3144 	c.NewRequest(queryPictFormatsRequest(c), cookie)
   3145 	return QueryPictFormatsCookie{cookie}
   3146 }
   3147 
   3148 // QueryPictFormatsReply represents the data returned from a QueryPictFormats request.
   3149 type QueryPictFormatsReply struct {
   3150 	Sequence uint16 // sequence number of the request for this reply
   3151 	Length   uint32 // number of bytes in this reply
   3152 	// padding: 1 bytes
   3153 	NumFormats  uint32
   3154 	NumScreens  uint32
   3155 	NumDepths   uint32
   3156 	NumVisuals  uint32
   3157 	NumSubpixel uint32
   3158 	// padding: 4 bytes
   3159 	Formats []Pictforminfo // size: xgb.Pad((int(NumFormats) * 28))
   3160 	// alignment gap to multiple of 4
   3161 	Screens []Pictscreen // size: PictscreenListSize(Screens)
   3162 	// alignment gap to multiple of 4
   3163 	Subpixels []uint32 // size: xgb.Pad((int(NumSubpixel) * 4))
   3164 }
   3165 
   3166 // Reply blocks and returns the reply data for a QueryPictFormats request.
   3167 func (cook QueryPictFormatsCookie) Reply() (*QueryPictFormatsReply, error) {
   3168 	buf, err := cook.Cookie.Reply()
   3169 	if err != nil {
   3170 		return nil, err
   3171 	}
   3172 	if buf == nil {
   3173 		return nil, nil
   3174 	}
   3175 	return queryPictFormatsReply(buf), nil
   3176 }
   3177 
   3178 // queryPictFormatsReply reads a byte slice into a QueryPictFormatsReply value.
   3179 func queryPictFormatsReply(buf []byte) *QueryPictFormatsReply {
   3180 	v := new(QueryPictFormatsReply)
   3181 	b := 1 // skip reply determinant
   3182 
   3183 	b += 1 // padding
   3184 
   3185 	v.Sequence = xgb.Get16(buf[b:])
   3186 	b += 2
   3187 
   3188 	v.Length = xgb.Get32(buf[b:]) // 4-byte units
   3189 	b += 4
   3190 
   3191 	v.NumFormats = xgb.Get32(buf[b:])
   3192 	b += 4
   3193 
   3194 	v.NumScreens = xgb.Get32(buf[b:])
   3195 	b += 4
   3196 
   3197 	v.NumDepths = xgb.Get32(buf[b:])
   3198 	b += 4
   3199 
   3200 	v.NumVisuals = xgb.Get32(buf[b:])
   3201 	b += 4
   3202 
   3203 	v.NumSubpixel = xgb.Get32(buf[b:])
   3204 	b += 4
   3205 
   3206 	b += 4 // padding
   3207 
   3208 	v.Formats = make([]Pictforminfo, v.NumFormats)
   3209 	b += PictforminfoReadList(buf[b:], v.Formats)
   3210 
   3211 	b = (b + 3) & ^3 // alignment gap
   3212 
   3213 	v.Screens = make([]Pictscreen, v.NumScreens)
   3214 	b += PictscreenReadList(buf[b:], v.Screens)
   3215 
   3216 	b = (b + 3) & ^3 // alignment gap
   3217 
   3218 	v.Subpixels = make([]uint32, v.NumSubpixel)
   3219 	for i := 0; i < int(v.NumSubpixel); i++ {
   3220 		v.Subpixels[i] = xgb.Get32(buf[b:])
   3221 		b += 4
   3222 	}
   3223 
   3224 	return v
   3225 }
   3226 
   3227 // Write request to wire for QueryPictFormats
   3228 // queryPictFormatsRequest writes a QueryPictFormats request to a byte slice.
   3229 func queryPictFormatsRequest(c *xgb.Conn) []byte {
   3230 	size := 4
   3231 	b := 0
   3232 	buf := make([]byte, size)
   3233 
   3234 	c.ExtLock.RLock()
   3235 	buf[b] = c.Extensions["RENDER"]
   3236 	c.ExtLock.RUnlock()
   3237 	b += 1
   3238 
   3239 	buf[b] = 1 // request opcode
   3240 	b += 1
   3241 
   3242 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   3243 	b += 2
   3244 
   3245 	return buf
   3246 }
   3247 
   3248 // QueryPictIndexValuesCookie is a cookie used only for QueryPictIndexValues requests.
   3249 type QueryPictIndexValuesCookie struct {
   3250 	*xgb.Cookie
   3251 }
   3252 
   3253 // QueryPictIndexValues sends a checked request.
   3254 // If an error occurs, it will be returned with the reply by calling QueryPictIndexValuesCookie.Reply()
   3255 func QueryPictIndexValues(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie {
   3256 	c.ExtLock.RLock()
   3257 	defer c.ExtLock.RUnlock()
   3258 	if _, ok := c.Extensions["RENDER"]; !ok {
   3259 		panic("Cannot issue request 'QueryPictIndexValues' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3260 	}
   3261 	cookie := c.NewCookie(true, true)
   3262 	c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie)
   3263 	return QueryPictIndexValuesCookie{cookie}
   3264 }
   3265 
   3266 // QueryPictIndexValuesUnchecked sends an unchecked request.
   3267 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   3268 func QueryPictIndexValuesUnchecked(c *xgb.Conn, Format Pictformat) QueryPictIndexValuesCookie {
   3269 	c.ExtLock.RLock()
   3270 	defer c.ExtLock.RUnlock()
   3271 	if _, ok := c.Extensions["RENDER"]; !ok {
   3272 		panic("Cannot issue request 'QueryPictIndexValues' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3273 	}
   3274 	cookie := c.NewCookie(false, true)
   3275 	c.NewRequest(queryPictIndexValuesRequest(c, Format), cookie)
   3276 	return QueryPictIndexValuesCookie{cookie}
   3277 }
   3278 
   3279 // QueryPictIndexValuesReply represents the data returned from a QueryPictIndexValues request.
   3280 type QueryPictIndexValuesReply struct {
   3281 	Sequence uint16 // sequence number of the request for this reply
   3282 	Length   uint32 // number of bytes in this reply
   3283 	// padding: 1 bytes
   3284 	NumValues uint32
   3285 	// padding: 20 bytes
   3286 	Values []Indexvalue // size: xgb.Pad((int(NumValues) * 12))
   3287 }
   3288 
   3289 // Reply blocks and returns the reply data for a QueryPictIndexValues request.
   3290 func (cook QueryPictIndexValuesCookie) Reply() (*QueryPictIndexValuesReply, error) {
   3291 	buf, err := cook.Cookie.Reply()
   3292 	if err != nil {
   3293 		return nil, err
   3294 	}
   3295 	if buf == nil {
   3296 		return nil, nil
   3297 	}
   3298 	return queryPictIndexValuesReply(buf), nil
   3299 }
   3300 
   3301 // queryPictIndexValuesReply reads a byte slice into a QueryPictIndexValuesReply value.
   3302 func queryPictIndexValuesReply(buf []byte) *QueryPictIndexValuesReply {
   3303 	v := new(QueryPictIndexValuesReply)
   3304 	b := 1 // skip reply determinant
   3305 
   3306 	b += 1 // padding
   3307 
   3308 	v.Sequence = xgb.Get16(buf[b:])
   3309 	b += 2
   3310 
   3311 	v.Length = xgb.Get32(buf[b:]) // 4-byte units
   3312 	b += 4
   3313 
   3314 	v.NumValues = xgb.Get32(buf[b:])
   3315 	b += 4
   3316 
   3317 	b += 20 // padding
   3318 
   3319 	v.Values = make([]Indexvalue, v.NumValues)
   3320 	b += IndexvalueReadList(buf[b:], v.Values)
   3321 
   3322 	return v
   3323 }
   3324 
   3325 // Write request to wire for QueryPictIndexValues
   3326 // queryPictIndexValuesRequest writes a QueryPictIndexValues request to a byte slice.
   3327 func queryPictIndexValuesRequest(c *xgb.Conn, Format Pictformat) []byte {
   3328 	size := 8
   3329 	b := 0
   3330 	buf := make([]byte, size)
   3331 
   3332 	c.ExtLock.RLock()
   3333 	buf[b] = c.Extensions["RENDER"]
   3334 	c.ExtLock.RUnlock()
   3335 	b += 1
   3336 
   3337 	buf[b] = 2 // request opcode
   3338 	b += 1
   3339 
   3340 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   3341 	b += 2
   3342 
   3343 	xgb.Put32(buf[b:], uint32(Format))
   3344 	b += 4
   3345 
   3346 	return buf
   3347 }
   3348 
   3349 // QueryVersionCookie is a cookie used only for QueryVersion requests.
   3350 type QueryVersionCookie struct {
   3351 	*xgb.Cookie
   3352 }
   3353 
   3354 // QueryVersion sends a checked request.
   3355 // If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply()
   3356 func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie {
   3357 	c.ExtLock.RLock()
   3358 	defer c.ExtLock.RUnlock()
   3359 	if _, ok := c.Extensions["RENDER"]; !ok {
   3360 		panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3361 	}
   3362 	cookie := c.NewCookie(true, true)
   3363 	c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
   3364 	return QueryVersionCookie{cookie}
   3365 }
   3366 
   3367 // QueryVersionUnchecked sends an unchecked request.
   3368 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   3369 func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie {
   3370 	c.ExtLock.RLock()
   3371 	defer c.ExtLock.RUnlock()
   3372 	if _, ok := c.Extensions["RENDER"]; !ok {
   3373 		panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3374 	}
   3375 	cookie := c.NewCookie(false, true)
   3376 	c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie)
   3377 	return QueryVersionCookie{cookie}
   3378 }
   3379 
   3380 // QueryVersionReply represents the data returned from a QueryVersion request.
   3381 type QueryVersionReply struct {
   3382 	Sequence uint16 // sequence number of the request for this reply
   3383 	Length   uint32 // number of bytes in this reply
   3384 	// padding: 1 bytes
   3385 	MajorVersion uint32
   3386 	MinorVersion uint32
   3387 	// padding: 16 bytes
   3388 }
   3389 
   3390 // Reply blocks and returns the reply data for a QueryVersion request.
   3391 func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) {
   3392 	buf, err := cook.Cookie.Reply()
   3393 	if err != nil {
   3394 		return nil, err
   3395 	}
   3396 	if buf == nil {
   3397 		return nil, nil
   3398 	}
   3399 	return queryVersionReply(buf), nil
   3400 }
   3401 
   3402 // queryVersionReply reads a byte slice into a QueryVersionReply value.
   3403 func queryVersionReply(buf []byte) *QueryVersionReply {
   3404 	v := new(QueryVersionReply)
   3405 	b := 1 // skip reply determinant
   3406 
   3407 	b += 1 // padding
   3408 
   3409 	v.Sequence = xgb.Get16(buf[b:])
   3410 	b += 2
   3411 
   3412 	v.Length = xgb.Get32(buf[b:]) // 4-byte units
   3413 	b += 4
   3414 
   3415 	v.MajorVersion = xgb.Get32(buf[b:])
   3416 	b += 4
   3417 
   3418 	v.MinorVersion = xgb.Get32(buf[b:])
   3419 	b += 4
   3420 
   3421 	b += 16 // padding
   3422 
   3423 	return v
   3424 }
   3425 
   3426 // Write request to wire for QueryVersion
   3427 // queryVersionRequest writes a QueryVersion request to a byte slice.
   3428 func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte {
   3429 	size := 12
   3430 	b := 0
   3431 	buf := make([]byte, size)
   3432 
   3433 	c.ExtLock.RLock()
   3434 	buf[b] = c.Extensions["RENDER"]
   3435 	c.ExtLock.RUnlock()
   3436 	b += 1
   3437 
   3438 	buf[b] = 0 // request opcode
   3439 	b += 1
   3440 
   3441 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   3442 	b += 2
   3443 
   3444 	xgb.Put32(buf[b:], ClientMajorVersion)
   3445 	b += 4
   3446 
   3447 	xgb.Put32(buf[b:], ClientMinorVersion)
   3448 	b += 4
   3449 
   3450 	return buf
   3451 }
   3452 
   3453 // ReferenceGlyphSetCookie is a cookie used only for ReferenceGlyphSet requests.
   3454 type ReferenceGlyphSetCookie struct {
   3455 	*xgb.Cookie
   3456 }
   3457 
   3458 // ReferenceGlyphSet sends an unchecked request.
   3459 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   3460 func ReferenceGlyphSet(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie {
   3461 	c.ExtLock.RLock()
   3462 	defer c.ExtLock.RUnlock()
   3463 	if _, ok := c.Extensions["RENDER"]; !ok {
   3464 		panic("Cannot issue request 'ReferenceGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3465 	}
   3466 	cookie := c.NewCookie(false, false)
   3467 	c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie)
   3468 	return ReferenceGlyphSetCookie{cookie}
   3469 }
   3470 
   3471 // ReferenceGlyphSetChecked sends a checked request.
   3472 // If an error occurs, it can be retrieved using ReferenceGlyphSetCookie.Check()
   3473 func ReferenceGlyphSetChecked(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) ReferenceGlyphSetCookie {
   3474 	c.ExtLock.RLock()
   3475 	defer c.ExtLock.RUnlock()
   3476 	if _, ok := c.Extensions["RENDER"]; !ok {
   3477 		panic("Cannot issue request 'ReferenceGlyphSet' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3478 	}
   3479 	cookie := c.NewCookie(true, false)
   3480 	c.NewRequest(referenceGlyphSetRequest(c, Gsid, Existing), cookie)
   3481 	return ReferenceGlyphSetCookie{cookie}
   3482 }
   3483 
   3484 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   3485 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   3486 func (cook ReferenceGlyphSetCookie) Check() error {
   3487 	return cook.Cookie.Check()
   3488 }
   3489 
   3490 // Write request to wire for ReferenceGlyphSet
   3491 // referenceGlyphSetRequest writes a ReferenceGlyphSet request to a byte slice.
   3492 func referenceGlyphSetRequest(c *xgb.Conn, Gsid Glyphset, Existing Glyphset) []byte {
   3493 	size := 12
   3494 	b := 0
   3495 	buf := make([]byte, size)
   3496 
   3497 	c.ExtLock.RLock()
   3498 	buf[b] = c.Extensions["RENDER"]
   3499 	c.ExtLock.RUnlock()
   3500 	b += 1
   3501 
   3502 	buf[b] = 18 // request opcode
   3503 	b += 1
   3504 
   3505 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   3506 	b += 2
   3507 
   3508 	xgb.Put32(buf[b:], uint32(Gsid))
   3509 	b += 4
   3510 
   3511 	xgb.Put32(buf[b:], uint32(Existing))
   3512 	b += 4
   3513 
   3514 	return buf
   3515 }
   3516 
   3517 // SetPictureClipRectanglesCookie is a cookie used only for SetPictureClipRectangles requests.
   3518 type SetPictureClipRectanglesCookie struct {
   3519 	*xgb.Cookie
   3520 }
   3521 
   3522 // SetPictureClipRectangles sends an unchecked request.
   3523 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   3524 func SetPictureClipRectangles(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie {
   3525 	c.ExtLock.RLock()
   3526 	defer c.ExtLock.RUnlock()
   3527 	if _, ok := c.Extensions["RENDER"]; !ok {
   3528 		panic("Cannot issue request 'SetPictureClipRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3529 	}
   3530 	cookie := c.NewCookie(false, false)
   3531 	c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie)
   3532 	return SetPictureClipRectanglesCookie{cookie}
   3533 }
   3534 
   3535 // SetPictureClipRectanglesChecked sends a checked request.
   3536 // If an error occurs, it can be retrieved using SetPictureClipRectanglesCookie.Check()
   3537 func SetPictureClipRectanglesChecked(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) SetPictureClipRectanglesCookie {
   3538 	c.ExtLock.RLock()
   3539 	defer c.ExtLock.RUnlock()
   3540 	if _, ok := c.Extensions["RENDER"]; !ok {
   3541 		panic("Cannot issue request 'SetPictureClipRectangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3542 	}
   3543 	cookie := c.NewCookie(true, false)
   3544 	c.NewRequest(setPictureClipRectanglesRequest(c, Picture, ClipXOrigin, ClipYOrigin, Rectangles), cookie)
   3545 	return SetPictureClipRectanglesCookie{cookie}
   3546 }
   3547 
   3548 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   3549 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   3550 func (cook SetPictureClipRectanglesCookie) Check() error {
   3551 	return cook.Cookie.Check()
   3552 }
   3553 
   3554 // Write request to wire for SetPictureClipRectangles
   3555 // setPictureClipRectanglesRequest writes a SetPictureClipRectangles request to a byte slice.
   3556 func setPictureClipRectanglesRequest(c *xgb.Conn, Picture Picture, ClipXOrigin int16, ClipYOrigin int16, Rectangles []xproto.Rectangle) []byte {
   3557 	size := xgb.Pad((12 + xgb.Pad((len(Rectangles) * 8))))
   3558 	b := 0
   3559 	buf := make([]byte, size)
   3560 
   3561 	c.ExtLock.RLock()
   3562 	buf[b] = c.Extensions["RENDER"]
   3563 	c.ExtLock.RUnlock()
   3564 	b += 1
   3565 
   3566 	buf[b] = 6 // request opcode
   3567 	b += 1
   3568 
   3569 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   3570 	b += 2
   3571 
   3572 	xgb.Put32(buf[b:], uint32(Picture))
   3573 	b += 4
   3574 
   3575 	xgb.Put16(buf[b:], uint16(ClipXOrigin))
   3576 	b += 2
   3577 
   3578 	xgb.Put16(buf[b:], uint16(ClipYOrigin))
   3579 	b += 2
   3580 
   3581 	b += xproto.RectangleListBytes(buf[b:], Rectangles)
   3582 
   3583 	return buf
   3584 }
   3585 
   3586 // SetPictureFilterCookie is a cookie used only for SetPictureFilter requests.
   3587 type SetPictureFilterCookie struct {
   3588 	*xgb.Cookie
   3589 }
   3590 
   3591 // SetPictureFilter sends an unchecked request.
   3592 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   3593 func SetPictureFilter(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie {
   3594 	c.ExtLock.RLock()
   3595 	defer c.ExtLock.RUnlock()
   3596 	if _, ok := c.Extensions["RENDER"]; !ok {
   3597 		panic("Cannot issue request 'SetPictureFilter' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3598 	}
   3599 	cookie := c.NewCookie(false, false)
   3600 	c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie)
   3601 	return SetPictureFilterCookie{cookie}
   3602 }
   3603 
   3604 // SetPictureFilterChecked sends a checked request.
   3605 // If an error occurs, it can be retrieved using SetPictureFilterCookie.Check()
   3606 func SetPictureFilterChecked(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) SetPictureFilterCookie {
   3607 	c.ExtLock.RLock()
   3608 	defer c.ExtLock.RUnlock()
   3609 	if _, ok := c.Extensions["RENDER"]; !ok {
   3610 		panic("Cannot issue request 'SetPictureFilter' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3611 	}
   3612 	cookie := c.NewCookie(true, false)
   3613 	c.NewRequest(setPictureFilterRequest(c, Picture, FilterLen, Filter, Values), cookie)
   3614 	return SetPictureFilterCookie{cookie}
   3615 }
   3616 
   3617 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   3618 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   3619 func (cook SetPictureFilterCookie) Check() error {
   3620 	return cook.Cookie.Check()
   3621 }
   3622 
   3623 // Write request to wire for SetPictureFilter
   3624 // setPictureFilterRequest writes a SetPictureFilter request to a byte slice.
   3625 func setPictureFilterRequest(c *xgb.Conn, Picture Picture, FilterLen uint16, Filter string, Values []Fixed) []byte {
   3626 	size := xgb.Pad((((12 + xgb.Pad((int(FilterLen) * 1))) + 4) + xgb.Pad((len(Values) * 4))))
   3627 	b := 0
   3628 	buf := make([]byte, size)
   3629 
   3630 	c.ExtLock.RLock()
   3631 	buf[b] = c.Extensions["RENDER"]
   3632 	c.ExtLock.RUnlock()
   3633 	b += 1
   3634 
   3635 	buf[b] = 30 // request opcode
   3636 	b += 1
   3637 
   3638 	blen := b
   3639 	b += 2
   3640 
   3641 	xgb.Put32(buf[b:], uint32(Picture))
   3642 	b += 4
   3643 
   3644 	xgb.Put16(buf[b:], FilterLen)
   3645 	b += 2
   3646 
   3647 	b += 2 // padding
   3648 
   3649 	copy(buf[b:], Filter[:FilterLen])
   3650 	b += int(FilterLen)
   3651 
   3652 	b = (b + 3) & ^3 // alignment gap
   3653 
   3654 	for i := 0; i < int(len(Values)); i++ {
   3655 		xgb.Put32(buf[b:], uint32(Values[i]))
   3656 		b += 4
   3657 	}
   3658 
   3659 	b = xgb.Pad(b)
   3660 	xgb.Put16(buf[blen:], uint16(b/4)) // write request size in 4-byte units
   3661 	return buf[:b]
   3662 }
   3663 
   3664 // SetPictureTransformCookie is a cookie used only for SetPictureTransform requests.
   3665 type SetPictureTransformCookie struct {
   3666 	*xgb.Cookie
   3667 }
   3668 
   3669 // SetPictureTransform sends an unchecked request.
   3670 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   3671 func SetPictureTransform(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie {
   3672 	c.ExtLock.RLock()
   3673 	defer c.ExtLock.RUnlock()
   3674 	if _, ok := c.Extensions["RENDER"]; !ok {
   3675 		panic("Cannot issue request 'SetPictureTransform' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3676 	}
   3677 	cookie := c.NewCookie(false, false)
   3678 	c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie)
   3679 	return SetPictureTransformCookie{cookie}
   3680 }
   3681 
   3682 // SetPictureTransformChecked sends a checked request.
   3683 // If an error occurs, it can be retrieved using SetPictureTransformCookie.Check()
   3684 func SetPictureTransformChecked(c *xgb.Conn, Picture Picture, Transform Transform) SetPictureTransformCookie {
   3685 	c.ExtLock.RLock()
   3686 	defer c.ExtLock.RUnlock()
   3687 	if _, ok := c.Extensions["RENDER"]; !ok {
   3688 		panic("Cannot issue request 'SetPictureTransform' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3689 	}
   3690 	cookie := c.NewCookie(true, false)
   3691 	c.NewRequest(setPictureTransformRequest(c, Picture, Transform), cookie)
   3692 	return SetPictureTransformCookie{cookie}
   3693 }
   3694 
   3695 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   3696 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   3697 func (cook SetPictureTransformCookie) Check() error {
   3698 	return cook.Cookie.Check()
   3699 }
   3700 
   3701 // Write request to wire for SetPictureTransform
   3702 // setPictureTransformRequest writes a SetPictureTransform request to a byte slice.
   3703 func setPictureTransformRequest(c *xgb.Conn, Picture Picture, Transform Transform) []byte {
   3704 	size := 44
   3705 	b := 0
   3706 	buf := make([]byte, size)
   3707 
   3708 	c.ExtLock.RLock()
   3709 	buf[b] = c.Extensions["RENDER"]
   3710 	c.ExtLock.RUnlock()
   3711 	b += 1
   3712 
   3713 	buf[b] = 28 // request opcode
   3714 	b += 1
   3715 
   3716 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   3717 	b += 2
   3718 
   3719 	xgb.Put32(buf[b:], uint32(Picture))
   3720 	b += 4
   3721 
   3722 	{
   3723 		structBytes := Transform.Bytes()
   3724 		copy(buf[b:], structBytes)
   3725 		b += len(structBytes)
   3726 	}
   3727 
   3728 	return buf
   3729 }
   3730 
   3731 // TrapezoidsCookie is a cookie used only for Trapezoids requests.
   3732 type TrapezoidsCookie struct {
   3733 	*xgb.Cookie
   3734 }
   3735 
   3736 // Trapezoids sends an unchecked request.
   3737 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   3738 func Trapezoids(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie {
   3739 	c.ExtLock.RLock()
   3740 	defer c.ExtLock.RUnlock()
   3741 	if _, ok := c.Extensions["RENDER"]; !ok {
   3742 		panic("Cannot issue request 'Trapezoids' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3743 	}
   3744 	cookie := c.NewCookie(false, false)
   3745 	c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie)
   3746 	return TrapezoidsCookie{cookie}
   3747 }
   3748 
   3749 // TrapezoidsChecked sends a checked request.
   3750 // If an error occurs, it can be retrieved using TrapezoidsCookie.Check()
   3751 func TrapezoidsChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) TrapezoidsCookie {
   3752 	c.ExtLock.RLock()
   3753 	defer c.ExtLock.RUnlock()
   3754 	if _, ok := c.Extensions["RENDER"]; !ok {
   3755 		panic("Cannot issue request 'Trapezoids' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3756 	}
   3757 	cookie := c.NewCookie(true, false)
   3758 	c.NewRequest(trapezoidsRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Traps), cookie)
   3759 	return TrapezoidsCookie{cookie}
   3760 }
   3761 
   3762 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   3763 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   3764 func (cook TrapezoidsCookie) Check() error {
   3765 	return cook.Cookie.Check()
   3766 }
   3767 
   3768 // Write request to wire for Trapezoids
   3769 // trapezoidsRequest writes a Trapezoids request to a byte slice.
   3770 func trapezoidsRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Traps []Trapezoid) []byte {
   3771 	size := xgb.Pad((24 + xgb.Pad((len(Traps) * 40))))
   3772 	b := 0
   3773 	buf := make([]byte, size)
   3774 
   3775 	c.ExtLock.RLock()
   3776 	buf[b] = c.Extensions["RENDER"]
   3777 	c.ExtLock.RUnlock()
   3778 	b += 1
   3779 
   3780 	buf[b] = 10 // request opcode
   3781 	b += 1
   3782 
   3783 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   3784 	b += 2
   3785 
   3786 	buf[b] = Op
   3787 	b += 1
   3788 
   3789 	b += 3 // padding
   3790 
   3791 	xgb.Put32(buf[b:], uint32(Src))
   3792 	b += 4
   3793 
   3794 	xgb.Put32(buf[b:], uint32(Dst))
   3795 	b += 4
   3796 
   3797 	xgb.Put32(buf[b:], uint32(MaskFormat))
   3798 	b += 4
   3799 
   3800 	xgb.Put16(buf[b:], uint16(SrcX))
   3801 	b += 2
   3802 
   3803 	xgb.Put16(buf[b:], uint16(SrcY))
   3804 	b += 2
   3805 
   3806 	b += TrapezoidListBytes(buf[b:], Traps)
   3807 
   3808 	return buf
   3809 }
   3810 
   3811 // TriFanCookie is a cookie used only for TriFan requests.
   3812 type TriFanCookie struct {
   3813 	*xgb.Cookie
   3814 }
   3815 
   3816 // TriFan sends an unchecked request.
   3817 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   3818 func TriFan(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie {
   3819 	c.ExtLock.RLock()
   3820 	defer c.ExtLock.RUnlock()
   3821 	if _, ok := c.Extensions["RENDER"]; !ok {
   3822 		panic("Cannot issue request 'TriFan' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3823 	}
   3824 	cookie := c.NewCookie(false, false)
   3825 	c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie)
   3826 	return TriFanCookie{cookie}
   3827 }
   3828 
   3829 // TriFanChecked sends a checked request.
   3830 // If an error occurs, it can be retrieved using TriFanCookie.Check()
   3831 func TriFanChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriFanCookie {
   3832 	c.ExtLock.RLock()
   3833 	defer c.ExtLock.RUnlock()
   3834 	if _, ok := c.Extensions["RENDER"]; !ok {
   3835 		panic("Cannot issue request 'TriFan' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3836 	}
   3837 	cookie := c.NewCookie(true, false)
   3838 	c.NewRequest(triFanRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie)
   3839 	return TriFanCookie{cookie}
   3840 }
   3841 
   3842 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   3843 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   3844 func (cook TriFanCookie) Check() error {
   3845 	return cook.Cookie.Check()
   3846 }
   3847 
   3848 // Write request to wire for TriFan
   3849 // triFanRequest writes a TriFan request to a byte slice.
   3850 func triFanRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte {
   3851 	size := xgb.Pad((24 + xgb.Pad((len(Points) * 8))))
   3852 	b := 0
   3853 	buf := make([]byte, size)
   3854 
   3855 	c.ExtLock.RLock()
   3856 	buf[b] = c.Extensions["RENDER"]
   3857 	c.ExtLock.RUnlock()
   3858 	b += 1
   3859 
   3860 	buf[b] = 13 // request opcode
   3861 	b += 1
   3862 
   3863 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   3864 	b += 2
   3865 
   3866 	buf[b] = Op
   3867 	b += 1
   3868 
   3869 	b += 3 // padding
   3870 
   3871 	xgb.Put32(buf[b:], uint32(Src))
   3872 	b += 4
   3873 
   3874 	xgb.Put32(buf[b:], uint32(Dst))
   3875 	b += 4
   3876 
   3877 	xgb.Put32(buf[b:], uint32(MaskFormat))
   3878 	b += 4
   3879 
   3880 	xgb.Put16(buf[b:], uint16(SrcX))
   3881 	b += 2
   3882 
   3883 	xgb.Put16(buf[b:], uint16(SrcY))
   3884 	b += 2
   3885 
   3886 	b += PointfixListBytes(buf[b:], Points)
   3887 
   3888 	return buf
   3889 }
   3890 
   3891 // TriStripCookie is a cookie used only for TriStrip requests.
   3892 type TriStripCookie struct {
   3893 	*xgb.Cookie
   3894 }
   3895 
   3896 // TriStrip sends an unchecked request.
   3897 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   3898 func TriStrip(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie {
   3899 	c.ExtLock.RLock()
   3900 	defer c.ExtLock.RUnlock()
   3901 	if _, ok := c.Extensions["RENDER"]; !ok {
   3902 		panic("Cannot issue request 'TriStrip' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3903 	}
   3904 	cookie := c.NewCookie(false, false)
   3905 	c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie)
   3906 	return TriStripCookie{cookie}
   3907 }
   3908 
   3909 // TriStripChecked sends a checked request.
   3910 // If an error occurs, it can be retrieved using TriStripCookie.Check()
   3911 func TriStripChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) TriStripCookie {
   3912 	c.ExtLock.RLock()
   3913 	defer c.ExtLock.RUnlock()
   3914 	if _, ok := c.Extensions["RENDER"]; !ok {
   3915 		panic("Cannot issue request 'TriStrip' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3916 	}
   3917 	cookie := c.NewCookie(true, false)
   3918 	c.NewRequest(triStripRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Points), cookie)
   3919 	return TriStripCookie{cookie}
   3920 }
   3921 
   3922 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   3923 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   3924 func (cook TriStripCookie) Check() error {
   3925 	return cook.Cookie.Check()
   3926 }
   3927 
   3928 // Write request to wire for TriStrip
   3929 // triStripRequest writes a TriStrip request to a byte slice.
   3930 func triStripRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Points []Pointfix) []byte {
   3931 	size := xgb.Pad((24 + xgb.Pad((len(Points) * 8))))
   3932 	b := 0
   3933 	buf := make([]byte, size)
   3934 
   3935 	c.ExtLock.RLock()
   3936 	buf[b] = c.Extensions["RENDER"]
   3937 	c.ExtLock.RUnlock()
   3938 	b += 1
   3939 
   3940 	buf[b] = 12 // request opcode
   3941 	b += 1
   3942 
   3943 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   3944 	b += 2
   3945 
   3946 	buf[b] = Op
   3947 	b += 1
   3948 
   3949 	b += 3 // padding
   3950 
   3951 	xgb.Put32(buf[b:], uint32(Src))
   3952 	b += 4
   3953 
   3954 	xgb.Put32(buf[b:], uint32(Dst))
   3955 	b += 4
   3956 
   3957 	xgb.Put32(buf[b:], uint32(MaskFormat))
   3958 	b += 4
   3959 
   3960 	xgb.Put16(buf[b:], uint16(SrcX))
   3961 	b += 2
   3962 
   3963 	xgb.Put16(buf[b:], uint16(SrcY))
   3964 	b += 2
   3965 
   3966 	b += PointfixListBytes(buf[b:], Points)
   3967 
   3968 	return buf
   3969 }
   3970 
   3971 // TrianglesCookie is a cookie used only for Triangles requests.
   3972 type TrianglesCookie struct {
   3973 	*xgb.Cookie
   3974 }
   3975 
   3976 // Triangles sends an unchecked request.
   3977 // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
   3978 func Triangles(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie {
   3979 	c.ExtLock.RLock()
   3980 	defer c.ExtLock.RUnlock()
   3981 	if _, ok := c.Extensions["RENDER"]; !ok {
   3982 		panic("Cannot issue request 'Triangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3983 	}
   3984 	cookie := c.NewCookie(false, false)
   3985 	c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie)
   3986 	return TrianglesCookie{cookie}
   3987 }
   3988 
   3989 // TrianglesChecked sends a checked request.
   3990 // If an error occurs, it can be retrieved using TrianglesCookie.Check()
   3991 func TrianglesChecked(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) TrianglesCookie {
   3992 	c.ExtLock.RLock()
   3993 	defer c.ExtLock.RUnlock()
   3994 	if _, ok := c.Extensions["RENDER"]; !ok {
   3995 		panic("Cannot issue request 'Triangles' using the uninitialized extension 'RENDER'. render.Init(connObj) must be called first.")
   3996 	}
   3997 	cookie := c.NewCookie(true, false)
   3998 	c.NewRequest(trianglesRequest(c, Op, Src, Dst, MaskFormat, SrcX, SrcY, Triangles), cookie)
   3999 	return TrianglesCookie{cookie}
   4000 }
   4001 
   4002 // Check returns an error if one occurred for checked requests that are not expecting a reply.
   4003 // This cannot be called for requests expecting a reply, nor for unchecked requests.
   4004 func (cook TrianglesCookie) Check() error {
   4005 	return cook.Cookie.Check()
   4006 }
   4007 
   4008 // Write request to wire for Triangles
   4009 // trianglesRequest writes a Triangles request to a byte slice.
   4010 func trianglesRequest(c *xgb.Conn, Op byte, Src Picture, Dst Picture, MaskFormat Pictformat, SrcX int16, SrcY int16, Triangles []Triangle) []byte {
   4011 	size := xgb.Pad((24 + xgb.Pad((len(Triangles) * 24))))
   4012 	b := 0
   4013 	buf := make([]byte, size)
   4014 
   4015 	c.ExtLock.RLock()
   4016 	buf[b] = c.Extensions["RENDER"]
   4017 	c.ExtLock.RUnlock()
   4018 	b += 1
   4019 
   4020 	buf[b] = 11 // request opcode
   4021 	b += 1
   4022 
   4023 	xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
   4024 	b += 2
   4025 
   4026 	buf[b] = Op
   4027 	b += 1
   4028 
   4029 	b += 3 // padding
   4030 
   4031 	xgb.Put32(buf[b:], uint32(Src))
   4032 	b += 4
   4033 
   4034 	xgb.Put32(buf[b:], uint32(Dst))
   4035 	b += 4
   4036 
   4037 	xgb.Put32(buf[b:], uint32(MaskFormat))
   4038 	b += 4
   4039 
   4040 	xgb.Put16(buf[b:], uint16(SrcX))
   4041 	b += 2
   4042 
   4043 	xgb.Put16(buf[b:], uint16(SrcY))
   4044 	b += 2
   4045 
   4046 	b += TriangleListBytes(buf[b:], Triangles)
   4047 
   4048 	return buf
   4049 }