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