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