summaryrefslogtreecommitdiff
path: root/hw/xfree86/xf8_32bpp/xf86overlay.c
blob: 95efb5c10b7331fae763e9e9d201d355988c4366 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
/* $XFree86$ */

/*
   Copyright (C) 1998.  The XFree86 Project Inc.

   Written by Mark Vojkovich (mvojkovi@ucsd.edu)
*/

#include "misc.h"
#include "xf86.h"
#include "xf86_ansic.h"
#include "xf86_OSproc.h"

#include "X.h"
#include "scrnintstr.h"
#include "regionstr.h"
#include "windowstr.h"
#include "xf86str.h"
#include "migc.h"
#include "gcstruct.h"
#include "pixmapstr.h"
#include "colormapst.h"
#include "cfb8_32.h"

#define IS_DIRTY 	1
#define IS_SHARED	2

/** Screen Functions **/

static Bool OverlayCloseScreen (int, ScreenPtr);
static Bool OverlayCreateGC(GCPtr pGC);
static Bool OverlayDestroyPixmap(PixmapPtr);
static PixmapPtr OverlayCreatePixmap(ScreenPtr, int, int, int);
static Bool OverlayChangeWindowAttributes(WindowPtr, unsigned long);
static void OverlayPaintWindow(WindowPtr, RegionPtr, int);

/** Funcs **/
static void OverlayValidateGC(GCPtr, unsigned long, DrawablePtr);
static void OverlayChangeGC(GCPtr, unsigned long);
static void OverlayCopyGC(GCPtr, unsigned long, GCPtr);
static void OverlayDestroyGC(GCPtr);
static void OverlayChangeClip(GCPtr, int, pointer, int);
static void OverlayDestroyClip(GCPtr);
static void OverlayCopyClip(GCPtr, GCPtr);


static PixmapPtr OverlayRefreshPixmap(PixmapPtr);

static GCFuncs OverlayGCFuncs = {
   OverlayValidateGC, OverlayChangeGC, 
   OverlayCopyGC, OverlayDestroyGC,
   OverlayChangeClip, OverlayDestroyClip, 
   OverlayCopyClip
};


/** Pixmap Ops */
static void	 PixmapFillSpans(DrawablePtr, GCPtr, int, DDXPointPtr, int *,
				  int);
static void	 PixmapSetSpans(DrawablePtr, GCPtr, char *, DDXPointPtr,
				 int *, int, int);
static void	 PixmapPutImage(DrawablePtr, GCPtr, int, int, int, int, int,
				 int, int, char *);
static void	 PixmapPushPixels(GCPtr, PixmapPtr, DrawablePtr, int, int,
				   int, int);
static RegionPtr PixmapCopyArea(DrawablePtr, DrawablePtr, GCPtr, int, int,
				 int, int, int, int);
static RegionPtr PixmapCopyPlane(DrawablePtr, DrawablePtr, GCPtr, int, int,
				  int, int, int, int, unsigned long);
static void	 PixmapPolyPoint(DrawablePtr, GCPtr, int, int, xPoint *);
static void	 PixmapPolylines(DrawablePtr, GCPtr, int, int, DDXPointPtr);
static void	 PixmapPolySegment(DrawablePtr, GCPtr, int, xSegment *);
static void	 PixmapPolyRectangle(DrawablePtr, GCPtr, int, xRectangle *);
static void	 PixmapPolyArc(DrawablePtr, GCPtr, int, xArc *);
static void	 PixmapFillPolygon(DrawablePtr, GCPtr, int, int, int,
				    DDXPointPtr);
static void	 PixmapPolyFillRect(DrawablePtr, GCPtr, int, xRectangle *);
static void	 PixmapPolyFillArc(DrawablePtr, GCPtr, int, xArc *);
static int	 PixmapPolyText8(DrawablePtr, GCPtr, int, int, int, char *);
static int	 PixmapPolyText16(DrawablePtr, GCPtr, int, int, int,
				   unsigned short *);
static void	 PixmapImageText8(DrawablePtr, GCPtr, int, int, int, char *);
static void	 PixmapImageText16(DrawablePtr, GCPtr, int, int, int,
				    unsigned short *);
static void	 PixmapImageGlyphBlt(DrawablePtr, GCPtr, int, int,
				      unsigned int, CharInfoPtr *, pointer);
static void	 PixmapPolyGlyphBlt(DrawablePtr, GCPtr, int, int,
				     unsigned int, CharInfoPtr *, pointer);

static GCOps PixmapGCOps = {
    PixmapFillSpans, PixmapSetSpans, 
    PixmapPutImage, PixmapCopyArea, 
    PixmapCopyPlane, PixmapPolyPoint, 
    PixmapPolylines, PixmapPolySegment, 
    PixmapPolyRectangle, PixmapPolyArc, 
    PixmapFillPolygon, PixmapPolyFillRect, 
    PixmapPolyFillArc, PixmapPolyText8, 
    PixmapPolyText16, PixmapImageText8, 
    PixmapImageText16, PixmapImageGlyphBlt, 
    PixmapPolyGlyphBlt, PixmapPushPixels,
#ifdef NEED_LINEHELPER
    NULL,
#endif
    {NULL}		/* devPrivate */
};


/** Window Ops **/
static void	 WindowFillSpans(DrawablePtr, GCPtr, int, DDXPointPtr, int *,
				  int);
static void	 WindowSetSpans(DrawablePtr, GCPtr, char *, DDXPointPtr,
				 int *, int, int);
static void	 WindowPutImage(DrawablePtr, GCPtr, int, int, int, int, int,
				 int, int, char *);
static void	 WindowPushPixels(GCPtr, PixmapPtr, DrawablePtr, int, int,
				   int, int);
static RegionPtr WindowCopyArea(DrawablePtr, DrawablePtr, GCPtr, int, int,
				 int, int, int, int);
static RegionPtr WindowCopyPlane(DrawablePtr, DrawablePtr, GCPtr, int, int,
				  int, int, int, int, unsigned long);
static void	 WindowPolyPoint(DrawablePtr, GCPtr, int, int, xPoint *);
static void	 WindowPolylines(DrawablePtr, GCPtr, int, int, DDXPointPtr);
static void	 WindowPolySegment(DrawablePtr, GCPtr, int, xSegment *);
static void	 WindowPolyRectangle(DrawablePtr, GCPtr, int, xRectangle *);
static void	 WindowPolyArc(DrawablePtr, GCPtr, int, xArc *);
static void	 WindowFillPolygon(DrawablePtr, GCPtr, int, int, int,
				    DDXPointPtr);
static void	 WindowPolyFillRect(DrawablePtr, GCPtr, int, xRectangle *);
static void	 WindowPolyFillArc(DrawablePtr, GCPtr, int, xArc *);
static int	 WindowPolyText8(DrawablePtr, GCPtr, int, int, int, char *);
static int	 WindowPolyText16(DrawablePtr, GCPtr, int, int, int,
				   unsigned short *);
static void	 WindowImageText8(DrawablePtr, GCPtr, int, int, int, char *);
static void	 WindowImageText16(DrawablePtr, GCPtr, int, int, int,
				    unsigned short *);
static void	 WindowImageGlyphBlt(DrawablePtr, GCPtr, int, int,
				      unsigned int, CharInfoPtr *, pointer);
static void	 WindowPolyGlyphBlt(DrawablePtr, GCPtr, int, int,
				     unsigned int, CharInfoPtr *, pointer);

static GCOps WindowGCOps = {
    WindowFillSpans, WindowSetSpans, 
    WindowPutImage, WindowCopyArea, 
    WindowCopyPlane, WindowPolyPoint, 
    WindowPolylines, WindowPolySegment, 
    WindowPolyRectangle, WindowPolyArc, 
    WindowFillPolygon, WindowPolyFillRect, 
    WindowPolyFillArc, WindowPolyText8, 
    WindowPolyText16, WindowImageText8, 
    WindowImageText16, WindowImageGlyphBlt, 
    WindowPolyGlyphBlt, WindowPushPixels,
#ifdef NEED_LINEHELPER
    NULL,
#endif
    {NULL}		/* devPrivate */
};

/** privates **/

typedef struct {
   CloseScreenProcPtr		CloseScreen;
   CreateGCProcPtr		CreateGC;
   CreatePixmapProcPtr		CreatePixmap;
   DestroyPixmapProcPtr		DestroyPixmap;
   ChangeWindowAttributesProcPtr ChangeWindowAttributes;
   PaintWindowBackgroundProcPtr	PaintWindowBackground;
   PaintWindowBorderProcPtr	PaintWindowBorder;
   int				LockPrivate;
} OverlayScreenRec, *OverlayScreenPtr;

typedef struct {
   GCFuncs		*wrapFuncs;
   GCOps		*wrapOps;
   GCOps		*overlayOps;
   unsigned long 	fg;
   unsigned long 	bg;
   unsigned long 	pm;
   PixmapPtr		tile;
} OverlayGCRec, *OverlayGCPtr;

typedef struct {
   PixmapPtr		pix32;
   CARD32		dirty;
} OverlayPixmapRec, *OverlayPixmapPtr;


static int OverlayScreenIndex = -1;
static int OverlayGCIndex = -1;
static int OverlayPixmapIndex = -1;
static unsigned long OverlayGeneration = 0;

/** Macros **/

#define TILE_EXISTS(pGC) (!(pGC)->tileIsPixel && (pGC)->tile.pixmap)

#define OVERLAY_GET_PIXMAP_PRIVATE(pPix) \
    (OverlayPixmapPtr)((pPix)->devPrivates[OverlayPixmapIndex].ptr)

#define OVERLAY_GET_SCREEN_PRIVATE(pScreen) \
    (OverlayScreenPtr)((pScreen)->devPrivates[OverlayScreenIndex].ptr)

#define OVERLAY_GET_GC_PRIVATE(pGC) \
    (OverlayGCPtr)((pGC)->devPrivates[OverlayGCIndex].ptr)

#define OVERLAY_GC_FUNC_PROLOGUE(pGC)\
    OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\
    (pGC)->funcs = pGCPriv->wrapFuncs;\
    if(pGCPriv->overlayOps) \
	(pGC)->ops = pGCPriv->wrapOps

#define OVERLAY_GC_FUNC_EPILOGUE(pGC)\
    pGCPriv->wrapFuncs = (pGC)->funcs;\
    (pGC)->funcs = &OverlayGCFuncs;\
    if(pGCPriv->overlayOps) { \
	pGCPriv->wrapOps = (pGC)->ops;\
	(pGC)->ops = pGCPriv->overlayOps;\
    }

#define WINDOW_GC_OP_PROLOGUE(pGC)\
    OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE((pGC)->pScreen);\
    OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\
    unsigned long oldfg = (pGC)->fgPixel;\
    unsigned long oldbg = (pGC)->bgPixel;\
    unsigned long oldpm = (pGC)->planemask;\
    PixmapPtr oldtile = (pGC)->tile.pixmap;\
    (pGC)->fgPixel = pGCPriv->fg;\
    (pGC)->bgPixel = pGCPriv->bg;\
    (pGC)->planemask = pGCPriv->pm;\
    if(pGCPriv->tile) (pGC)->tile.pixmap = pGCPriv->tile;\
    (pGC)->funcs = pGCPriv->wrapFuncs;\
    (pGC)->ops = pGCPriv->wrapOps;\
    pScreenPriv->LockPrivate++
    

#define WINDOW_GC_OP_EPILOGUE(pGC)\
    pGCPriv->wrapOps = (pGC)->ops;\
    pGCPriv->wrapFuncs = (pGC)->funcs;\
    (pGC)->fgPixel = oldfg;\
    (pGC)->bgPixel = oldbg;\
    (pGC)->planemask = oldpm;\
    (pGC)->tile.pixmap = oldtile;\
    (pGC)->funcs = &OverlayGCFuncs;\
    (pGC)->ops   = &WindowGCOps;\
    pScreenPriv->LockPrivate--


#define PIXMAP_GC_OP_PROLOGUE(pGC)\
    OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\
    OverlayPixmapPtr pPixPriv = OVERLAY_GET_PIXMAP_PRIVATE((PixmapPtr)pDraw);\
    pGC->funcs = pGCPriv->wrapFuncs;\
    pGC->ops = pGCPriv->wrapOps
    
#define PIXMAP_GC_OP_EPILOGUE(pGC)\
    pGCPriv->wrapOps = pGC->ops;\
    pGC->funcs = &OverlayGCFuncs;\
    pGC->ops = &PixmapGCOps;\
    pPixPriv->dirty |= IS_DIRTY
    

Bool
xf86Overlay8Plus32Init (ScreenPtr pScreen)
{
    OverlayScreenPtr pScreenPriv;

    if(OverlayGeneration != serverGeneration) {
	if(((OverlayScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
	   ((OverlayGCIndex = AllocateGCPrivateIndex()) < 0) ||
	   ((OverlayPixmapIndex = AllocatePixmapPrivateIndex()) < 0))
		return FALSE;

	OverlayGeneration = serverGeneration;
    }

    if (!AllocateGCPrivate(pScreen, OverlayGCIndex, sizeof(OverlayGCRec)))
	return FALSE;

    if (!AllocatePixmapPrivate(pScreen, OverlayPixmapIndex, 
						sizeof(OverlayPixmapRec)))
	return FALSE;

    if (!(pScreenPriv = xalloc(sizeof(OverlayScreenRec))))
	return FALSE;

    pScreen->devPrivates[OverlayScreenIndex].ptr = (pointer)pScreenPriv;

    pScreenPriv->CreateGC = pScreen->CreateGC;
    pScreenPriv->CloseScreen = pScreen->CloseScreen;
    pScreenPriv->CreatePixmap = pScreen->CreatePixmap;
    pScreenPriv->DestroyPixmap = pScreen->DestroyPixmap;
    pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
    pScreenPriv->PaintWindowBackground = pScreen->PaintWindowBackground;
    pScreenPriv->PaintWindowBorder = pScreen->PaintWindowBorder;

    pScreen->CreateGC = OverlayCreateGC;
    pScreen->CloseScreen = OverlayCloseScreen;
    pScreen->CreatePixmap = OverlayCreatePixmap; 
    pScreen->DestroyPixmap = OverlayDestroyPixmap; 
    pScreen->ChangeWindowAttributes = OverlayChangeWindowAttributes; 
    pScreen->PaintWindowBackground = OverlayPaintWindow; 
    pScreen->PaintWindowBorder = OverlayPaintWindow; 

    pScreenPriv->LockPrivate = 0; 

    /* allocate the key in the default map */
    if(pScreen->defColormap) {
	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
	ColormapPtr pmap;
	xColorItem color;

	pmap = (ColormapPtr)LookupIDByType(pScreen->defColormap, RT_COLORMAP);

	pmap->red[pScrn->colorKey].refcnt = AllocPrivate;
	pmap->red[pScrn->colorKey].fShared = FALSE;
	pmap->freeRed--;
	
	color.red = color.blue = color.green = 0;
	color.pixel = pScrn->colorKey;
	color.flags = DoRed | DoGreen | DoBlue;

	StoreColors(pmap, 1, &color);
    }

    return TRUE;
}


/*********************** Screen Funcs ***********************/

Bool
OverlayCreateGC(GCPtr pGC)
{
    ScreenPtr    pScreen = pGC->pScreen;
    OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);
    OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen);
    Bool ret;

    pScreen->CreateGC = pScreenPriv->CreateGC;

    if((ret = (*pScreen->CreateGC)(pGC)) && (pGC->depth != 1)) {
	pGCPriv->wrapFuncs = pGC->funcs;
	pGC->funcs = &OverlayGCFuncs;
	pGCPriv->wrapOps = NULL;
	pGCPriv->overlayOps = NULL;
	pGCPriv->tile = NULL;
    }

    pScreen->CreateGC = OverlayCreateGC;

    return ret;
}

static PixmapPtr 
OverlayCreatePixmap(ScreenPtr pScreen, int w, int h, int depth)
{
    OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen);
    PixmapPtr pPix;
    
    pScreen->CreatePixmap = pScreenPriv->CreatePixmap;
    pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth);
    pScreen->CreatePixmap = OverlayCreatePixmap;

    /* We initialize all the privates */
    if(pPix) {
	OverlayPixmapPtr pPriv = OVERLAY_GET_PIXMAP_PRIVATE(pPix);
        pPriv->pix32 = NULL;
        pPriv->dirty = IS_DIRTY;
	if(!w || !h)
	   pPriv->dirty |= IS_SHARED;
    }

    return pPix;
}

static Bool
OverlayDestroyPixmap(PixmapPtr pPix)
{
    ScreenPtr pScreen = pPix->drawable.pScreen;
    OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen);
    Bool result;

    pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap;

    if((pPix->refcnt == 1) && (pPix->drawable.bitsPerPixel == 8)) {
	OverlayPixmapPtr pPriv = OVERLAY_GET_PIXMAP_PRIVATE(pPix);
	if(pPriv->pix32) {
	   if(pPriv->pix32->refcnt != 1)
	     ErrorF("Warning! private pix refcnt = %i\n", pPriv->pix32->refcnt);
	   (*pScreen->DestroyPixmap)(pPriv->pix32);
	}
	pPriv->pix32 = NULL;
    }

    result = (*pScreen->DestroyPixmap) (pPix);
    pScreen->DestroyPixmap = OverlayDestroyPixmap;

    return result;
}

static Bool
OverlayCloseScreen (int i, ScreenPtr pScreen)
{
    OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen);

    pScreen->CreateGC = pScreenPriv->CreateGC;
    pScreen->CloseScreen = pScreenPriv->CloseScreen;
    pScreen->CreatePixmap = pScreenPriv->CreatePixmap;
    pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap;
    pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes;
    pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground;
    pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder;

    xfree ((pointer) pScreenPriv);

    return (*pScreen->CloseScreen) (i, pScreen);
}



static Bool
OverlayChangeWindowAttributes (WindowPtr pWin, unsigned long mask)
{
    ScreenPtr pScreen = pWin->drawable.pScreen;
    OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen);
    Bool result;    

    if(pWin->drawable.depth == 8) {
	if((mask & CWBackPixmap) && 
	   (pWin->backgroundState == BackgroundPixmap)) 	
		OverlayRefreshPixmap(pWin->background.pixmap);

	if((mask & CWBorderPixmap) && !pWin->borderIsPixel)
		OverlayRefreshPixmap(pWin->border.pixmap);
    }

    pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes;
    result = (*pScreen->ChangeWindowAttributes) (pWin, mask);
    pScreen->ChangeWindowAttributes = OverlayChangeWindowAttributes;

    return result;
}

static void
OverlayPaintWindow(
  WindowPtr pWin,
  RegionPtr pReg,
  int what
){
    ScreenPtr pScreen = pWin->drawable.pScreen;
    OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen);
    OverlayPixmapPtr pixPriv;
    PixmapPtr oldPix = NULL;

    if(what == PW_BACKGROUND) {
	if(pWin->drawable.depth == 8) {
	   if(pWin->backgroundState == ParentRelative) {
		do {
		   pWin = pWin->parent;
		} while (pWin->backgroundState == ParentRelative);
	   }

	   if(pWin->backgroundState == BackgroundPixmap) {
		oldPix = pWin->background.pixmap;
		pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(oldPix);
		/* have to do this here because alot of applications
		   incorrectly assume changes to a pixmap that is
		   a window background go into effect immediatedly */
		if(pixPriv->dirty & IS_DIRTY)
		    OverlayRefreshPixmap(pWin->background.pixmap);
		pWin->background.pixmap = pixPriv->pix32;
	   }
	}

	pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground;
	(*pScreen->PaintWindowBackground) (pWin, pReg, what);
	pScreen->PaintWindowBackground = OverlayPaintWindow;

	if(oldPix)
	   pWin->background.pixmap = oldPix;
    } else {
	if((pWin->drawable.depth == 8) && !pWin->borderIsPixel) {
	   oldPix = pWin->border.pixmap;
	   pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(oldPix);
	   if(pixPriv->dirty & IS_DIRTY)
		OverlayRefreshPixmap(pWin->border.pixmap);
	   pWin->border.pixmap = pixPriv->pix32;
        }

	pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder;
	(*pScreen->PaintWindowBorder) (pWin, pReg, what);
	pScreen->PaintWindowBorder = OverlayPaintWindow;

	if(oldPix)
	   pWin->border.pixmap = oldPix;
    }
}


/*********************** GC Funcs *****************************/


static PixmapPtr
OverlayRefreshPixmap(PixmapPtr pix8) 
{
    OverlayPixmapPtr pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(pix8);
    ScreenPtr pScreen = pix8->drawable.pScreen;

    if(!pixPriv->pix32) {
	PixmapPtr newPix;

	newPix = (*pScreen->CreatePixmap)(pScreen, pix8->drawable.width,
		pix8->drawable.height, 24);
	newPix->drawable.depth = 8;  /* Bad Mark! Bad Mark! */
        pixPriv->pix32 = newPix;
    }

    if(pixPriv->dirty) {
	OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen);
	GCPtr pGC;

	pGC = GetScratchGC(8, pScreen);

	pScreenPriv->LockPrivate++;  /* don't modify this one */
	ValidateGC((DrawablePtr)pixPriv->pix32, pGC);

	(*pGC->ops->CopyArea)((DrawablePtr)pix8, (DrawablePtr)pixPriv->pix32,
		pGC, 0, 0, pix8->drawable.width, pix8->drawable.height, 0, 0);  
	pScreenPriv->LockPrivate--;
	FreeScratchGC(pGC);

	pixPriv->dirty &= ~IS_DIRTY;
	pixPriv->pix32->drawable.serialNumber = NEXT_SERIAL_NUMBER;    
    }

    return pixPriv->pix32;
}


static void
OverlayValidateGC(
   GCPtr         pGC,
   unsigned long changes,
   DrawablePtr   pDraw 
){
    OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pGC->pScreen);
    OVERLAY_GC_FUNC_PROLOGUE (pGC);

    if(pScreenPriv->LockPrivate < 0) {
	ErrorF("Something is wrong in OverlayValidateGC!\n");
	pScreenPriv->LockPrivate = 0;
    }

    if(pGC->depth == 24) {
	unsigned long oldpm = pGC->planemask;
	pGCPriv->overlayOps = NULL;

	if(pDraw->type == DRAWABLE_WINDOW)
	   pGC->planemask &= 0x00ffffff;
	else
	   pGC->planemask |= 0xff000000; 

        if(oldpm != pGC->planemask) changes |= GCPlaneMask;

	(*pGC->funcs->ValidateGC)(pGC, changes, pDraw);

    } else { /* depth == 8 */
	unsigned long newChanges = 0;

	if(pDraw->bitsPerPixel == 32) {
	
	    if(pGC->fillStyle == FillTiled)
		pGCPriv->tile = OverlayRefreshPixmap(pGC->tile.pixmap);
	    else pGCPriv->tile = NULL;

	    if(pGCPriv->overlayOps != &WindowGCOps) {
		newChanges = GCForeground | GCBackground | GCPlaneMask;
		if(pGCPriv->tile) 
		    newChanges |= GCTile;
	    }
	    pGCPriv->overlayOps = &WindowGCOps;

	    if(!pScreenPriv->LockPrivate) {
		unsigned long oldfg = pGC->fgPixel;
		unsigned long oldbg = pGC->bgPixel;
		unsigned long oldpm = pGC->planemask;
		PixmapPtr oldtile = pGC->tile.pixmap;

		pGC->fgPixel = pGCPriv->fg = oldfg << 24;
		pGC->bgPixel = pGCPriv->bg = oldbg << 24;
		pGC->planemask = pGCPriv->pm = oldpm << 24;
		if(pGCPriv->tile)
		    pGC->tile.pixmap = pGCPriv->tile;

		(*pGC->funcs->ValidateGC)(pGC, changes | newChanges, pDraw);

		pGC->fgPixel = oldfg;
		pGC->bgPixel = oldbg;
		pGC->planemask = oldpm;
		pGC->tile.pixmap = oldtile;
	    } else {
		pGCPriv->fg = pGC->fgPixel;
		pGCPriv->bg = pGC->bgPixel;
		pGCPriv->pm = pGC->planemask;

		(*pGC->funcs->ValidateGC)(pGC, changes | newChanges, pDraw);
	    }

	} else {  /* bitsPerPixel == 8 */
	    if(pGCPriv->overlayOps == &WindowGCOps) {
		newChanges = GCForeground | GCBackground | GCPlaneMask;
		if(pGCPriv->tile) 
		    newChanges |= GCTile;
	    }
	    pGCPriv->overlayOps = &PixmapGCOps;

	    (*pGC->funcs->ValidateGC)(pGC, changes | newChanges, pDraw);
	}
    }

    OVERLAY_GC_FUNC_EPILOGUE (pGC);
}


static void
OverlayDestroyGC(GCPtr pGC)
{
    OVERLAY_GC_FUNC_PROLOGUE (pGC);
    (*pGC->funcs->DestroyGC)(pGC);
    OVERLAY_GC_FUNC_EPILOGUE (pGC);
}

static void
OverlayChangeGC (
    GCPtr	    pGC,
    unsigned long   mask
){
    OVERLAY_GC_FUNC_PROLOGUE (pGC);
    (*pGC->funcs->ChangeGC) (pGC, mask);
    OVERLAY_GC_FUNC_EPILOGUE (pGC);
}

static void
OverlayCopyGC (
    GCPtr	    pGCSrc, 
    unsigned long   mask,
    GCPtr	    pGCDst
){
    OVERLAY_GC_FUNC_PROLOGUE (pGCDst);
    (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
    OVERLAY_GC_FUNC_EPILOGUE (pGCDst);
}
static void
OverlayChangeClip (
    GCPtr   pGC,
    int		type,
    pointer	pvalue,
    int		nrects
){
    OVERLAY_GC_FUNC_PROLOGUE (pGC);
    (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
    OVERLAY_GC_FUNC_EPILOGUE (pGC);
}

static void
OverlayCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
{
    OVERLAY_GC_FUNC_PROLOGUE (pgcDst);
    (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
    OVERLAY_GC_FUNC_EPILOGUE (pgcDst);
}

static void
OverlayDestroyClip(GCPtr pGC)
{
    OVERLAY_GC_FUNC_PROLOGUE (pGC);
    (* pGC->funcs->DestroyClip)(pGC);
    OVERLAY_GC_FUNC_EPILOGUE (pGC);
}



/******************* Window GC ops ***********************/

static void
WindowFillSpans(
    DrawablePtr pDraw,
    GC		*pGC,
    int		nInit,	
    DDXPointPtr pptInit,	
    int *pwidthInit,		
    int fSorted 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void
WindowSetSpans(
    DrawablePtr		pDraw,
    GCPtr		pGC,
    char		*pcharsrc,
    register DDXPointPtr ppt,
    int			*pwidth,
    int			nspans,
    int			fSorted 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void
WindowPutImage(
    DrawablePtr pDraw,
    GCPtr	pGC,
    int		depth, 
    int x, int y, int w, int h,
    int		leftPad,
    int		format,
    char 	*pImage 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, 
						leftPad, format, pImage);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static RegionPtr
WindowCopyArea(
    DrawablePtr pSrc,
    DrawablePtr pDst,
    GC *pGC,
    int srcx, int srcy,
    int width, int height,
    int dstx, int dsty 
){
    RegionPtr ret;

    WINDOW_GC_OP_PROLOGUE(pGC);
    ret = (*pGC->ops->CopyArea)(pSrc, pDst,
            pGC, srcx, srcy, width, height, dstx, dsty);
    WINDOW_GC_OP_EPILOGUE(pGC);
    return ret;
}

static RegionPtr
WindowCopyPlane(
    DrawablePtr	pSrc,
    DrawablePtr	pDst,
    GCPtr pGC,
    int	srcx, int srcy,
    int	width, int height,
    int	dstx, int dsty,
    unsigned long bitPlane 
){
    RegionPtr ret;

    WINDOW_GC_OP_PROLOGUE(pGC);
    ret = (*pGC->ops->CopyPlane)(pSrc, pDst,
	       pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
    WINDOW_GC_OP_EPILOGUE(pGC);
    return ret;
}

static void
WindowPolyPoint(
    DrawablePtr pDraw,
    GCPtr pGC,
    int mode,
    int npt,
    xPoint *pptInit
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void
WindowPolylines(
    DrawablePtr pDraw,
    GCPtr	pGC,
    int		mode,		
    int		npt,		
    DDXPointPtr pptInit 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void 
WindowPolySegment(
    DrawablePtr	pDraw,
    GCPtr	pGC,
    int		nseg,
    xSegment	*pSeg 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void
WindowPolyRectangle(
    DrawablePtr  pDraw,
    GCPtr        pGC,
    int	         nRectsInit,
    xRectangle  *pRectsInit 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void
WindowPolyArc(
    DrawablePtr	pDraw,
    GCPtr	pGC,
    int		narcs,
    xArc	*parcs 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void
WindowFillPolygon(
    DrawablePtr	pDraw,
    GCPtr	pGC,
    int		shape,
    int		mode,
    int		count,
    DDXPointPtr	ptsIn 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void 
WindowPolyFillRect(
    DrawablePtr	pDraw,
    GCPtr	pGC,
    int		nrectFill, 
    xRectangle	*prectInit 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void
WindowPolyFillArc(
    DrawablePtr	pDraw,
    GCPtr	pGC,
    int		narcs,
    xArc	*parcs 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static int
WindowPolyText8(
    DrawablePtr pDraw,
    GCPtr	pGC,
    int		x, 
    int 	y,
    int 	count,
    char	*chars 
){
    int ret;

    WINDOW_GC_OP_PROLOGUE(pGC);
    ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
    WINDOW_GC_OP_EPILOGUE(pGC);
    return ret;
}

static int
WindowPolyText16(
    DrawablePtr pDraw,
    GCPtr	pGC,
    int		x,
    int		y,
    int 	count,
    unsigned short *chars 
){
    int ret;

    WINDOW_GC_OP_PROLOGUE(pGC);
    ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
    WINDOW_GC_OP_EPILOGUE(pGC);
    return ret;
}

static void
WindowImageText8(
    DrawablePtr pDraw,
    GCPtr	pGC,
    int		x, 
    int		y,
    int 	count,
    char	*chars 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void
WindowImageText16(
    DrawablePtr pDraw,
    GCPtr	pGC,
    int		x,
    int		y,
    int 	count,
    unsigned short *chars 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void
WindowImageGlyphBlt(
    DrawablePtr pDraw,
    GCPtr pGC,
    int xInit, int yInit,
    unsigned int nglyph,
    CharInfoPtr *ppci,
    pointer pglyphBase 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, 
					ppci, pglyphBase);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void
WindowPolyGlyphBlt(
    DrawablePtr pDraw,
    GCPtr pGC,
    int xInit, int yInit,
    unsigned int nglyph,
    CharInfoPtr *ppci,
    pointer pglyphBase 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, 
						ppci, pglyphBase);
    WINDOW_GC_OP_EPILOGUE(pGC);
}

static void
WindowPushPixels(
    GCPtr	pGC,
    PixmapPtr	pBitMap,
    DrawablePtr pDraw,
    int	dx, int dy, int xOrg, int yOrg 
){
    WINDOW_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
    WINDOW_GC_OP_EPILOGUE(pGC);
}


/******************* Pixmap GC ops ***********************/

static void
PixmapFillSpans(
    DrawablePtr pDraw,
    GC		*pGC,
    int		nInit,	
    DDXPointPtr pptInit,	
    int *pwidthInit,		
    int fSorted 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void
PixmapSetSpans(
    DrawablePtr		pDraw,
    GCPtr		pGC,
    char		*pcharsrc,
    register DDXPointPtr ppt,
    int			*pwidth,
    int			nspans,
    int			fSorted 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void
PixmapPutImage(
    DrawablePtr pDraw,
    GCPtr	pGC,
    int		depth, 
    int x, int y, int w, int h,
    int		leftPad,
    int		format,
    char 	*pImage 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h, 
						leftPad, format, pImage);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static RegionPtr
PixmapCopyArea(
    DrawablePtr pSrc,
    DrawablePtr pDraw,
    GC *pGC,
    int srcx, int srcy,
    int width, int height,
    int dstx, int dsty 
){
    RegionPtr ret;

    PIXMAP_GC_OP_PROLOGUE(pGC);
    ret = (*pGC->ops->CopyArea)(pSrc, pDraw,
            pGC, srcx, srcy, width, height, dstx, dsty);
    PIXMAP_GC_OP_EPILOGUE(pGC);
    return ret;
}

static RegionPtr
PixmapCopyPlane(
    DrawablePtr	pSrc,
    DrawablePtr	pDraw,
    GCPtr pGC,
    int	srcx, int srcy,
    int	width, int height,
    int	dstx, int dsty,
    unsigned long bitPlane 
){
    RegionPtr ret;

    PIXMAP_GC_OP_PROLOGUE(pGC);
    ret = (*pGC->ops->CopyPlane)(pSrc, pDraw,
	       pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
    PIXMAP_GC_OP_EPILOGUE(pGC);
    return ret;
}

static void
PixmapPolyPoint(
    DrawablePtr pDraw,
    GCPtr pGC,
    int mode,
    int npt,
    xPoint *pptInit
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void
PixmapPolylines(
    DrawablePtr pDraw,
    GCPtr	pGC,
    int		mode,		
    int		npt,		
    DDXPointPtr pptInit 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void 
PixmapPolySegment(
    DrawablePtr	pDraw,
    GCPtr	pGC,
    int		nseg,
    xSegment	*pSeg 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void
PixmapPolyRectangle(
    DrawablePtr  pDraw,
    GCPtr        pGC,
    int	         nRectsInit,
    xRectangle  *pRectsInit 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void
PixmapPolyArc(
    DrawablePtr	pDraw,
    GCPtr	pGC,
    int		narcs,
    xArc	*parcs 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void
PixmapFillPolygon(
    DrawablePtr	pDraw,
    GCPtr	pGC,
    int		shape,
    int		mode,
    int		count,
    DDXPointPtr	ptsIn 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void 
PixmapPolyFillRect(
    DrawablePtr	pDraw,
    GCPtr	pGC,
    int		nrectFill, 
    xRectangle	*prectInit 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void
PixmapPolyFillArc(
    DrawablePtr	pDraw,
    GCPtr	pGC,
    int		narcs,
    xArc	*parcs 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static int
PixmapPolyText8(
    DrawablePtr pDraw,
    GCPtr	pGC,
    int		x, 
    int 	y,
    int 	count,
    char	*chars 
){
    int ret;

    PIXMAP_GC_OP_PROLOGUE(pGC);
    ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
    PIXMAP_GC_OP_EPILOGUE(pGC);
    return ret;
}

static int
PixmapPolyText16(
    DrawablePtr pDraw,
    GCPtr	pGC,
    int		x,
    int		y,
    int 	count,
    unsigned short *chars 
){
    int ret;

    PIXMAP_GC_OP_PROLOGUE(pGC);
    ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
    PIXMAP_GC_OP_EPILOGUE(pGC);
    return ret;
}

static void
PixmapImageText8(
    DrawablePtr pDraw,
    GCPtr	pGC,
    int		x, 
    int		y,
    int 	count,
    char	*chars 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void
PixmapImageText16(
    DrawablePtr pDraw,
    GCPtr	pGC,
    int		x,
    int		y,
    int 	count,
    unsigned short *chars 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void
PixmapImageGlyphBlt(
    DrawablePtr pDraw,
    GCPtr pGC,
    int xInit, int yInit,
    unsigned int nglyph,
    CharInfoPtr *ppci,
    pointer pglyphBase 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, 
					ppci, pglyphBase);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void
PixmapPolyGlyphBlt(
    DrawablePtr pDraw,
    GCPtr pGC,
    int xInit, int yInit,
    unsigned int nglyph,
    CharInfoPtr *ppci,
    pointer pglyphBase 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit, nglyph, 
						ppci, pglyphBase);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}

static void
PixmapPushPixels(
    GCPtr	pGC,
    PixmapPtr	pBitMap,
    DrawablePtr pDraw,
    int	dx, int dy, int xOrg, int yOrg 
){
    PIXMAP_GC_OP_PROLOGUE(pGC);
    (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
    PIXMAP_GC_OP_EPILOGUE(pGC);
}