summaryrefslogtreecommitdiff
path: root/hw/xfree86/xf8_32bpp/cfbgcmisc.c
blob: f009afc0c9babff92e873256a8b0e82b713b281a (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
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif

#include <stdlib.h>

#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xproto.h>
#define PSZ 8
#include "cfb.h"
#undef PSZ
#include "cfb32.h"
#include "cfb8_32.h"
#include <X11/fonts/fontstruct.h>
#include "dixfontstr.h"
#include "gcstruct.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "scrnintstr.h"
#include "region.h"

#include "mistruct.h"
#include "mibstore.h"
#include "migc.h"


static void cfb8_32ValidateGC(GCPtr, unsigned long, DrawablePtr);
static void cfb8_32DestroyGC(GCPtr pGC);
static void cfb32DestroyGC_Underlay(GCPtr pGC);

static
GCFuncs cfb8_32GCFuncs = {
    cfb8_32ValidateGC,
    miChangeGC,
    miCopyGC,
    cfb8_32DestroyGC,
    miChangeClip,
    miDestroyClip,
    miCopyClip,
};


static
GCFuncs cfb32GCFuncs_Underlay = {
    cfb32ValidateGC_Underlay,
    miChangeGC,
    miCopyGC,
    cfb32DestroyGC_Underlay,
    miChangeClip,
    miDestroyClip,
    miCopyClip,
};

static void
cfb32DestroyGC_Underlay(GCPtr pGC)
{
    if (pGC->freeCompClip)
        REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);

    if(pGC->ops)
	miDestroyGCOps(pGC->ops);
}


static void
cfb8_32DestroyGC(GCPtr pGC)
{
    cfb8_32GCPtr pGCPriv = CFB8_32_GET_GC_PRIVATE(pGC);

    if (pGC->freeCompClip)
        REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
    if(pGCPriv->Ops8bpp)
	miDestroyGCOps(pGCPriv->Ops8bpp);
    if(pGCPriv->Ops32bpp)
	miDestroyGCOps(pGCPriv->Ops32bpp);
}

Bool
cfb8_32CreateGC(GCPtr pGC)
{
    cfb8_32GCPtr pGCPriv;
    cfbPrivGC *pPriv;

    if (PixmapWidthPaddingInfo[pGC->depth].padPixelsLog2 == LOG2_BITMAP_PAD)
        return (mfbCreateGC(pGC));

    pGC->clientClip = NULL;
    pGC->clientClipType = CT_NONE;
    pGC->miTranslate = 1;
    pGC->fExpose = TRUE;
    pGC->freeCompClip = FALSE;
    pGC->pRotatedPixmap = (PixmapPtr) NULL;

    pPriv = cfbGetGCPrivate(pGC);
    pPriv->rop = pGC->alu;
    pPriv->oneRect = FALSE;

    pGC->ops = NULL;

    if (pGC->depth == 8) {
	pGC->funcs = &cfb8_32GCFuncs;

	pGCPriv = CFB8_32_GET_GC_PRIVATE(pGC);
	pGCPriv->Ops8bpp = NULL;
	pGCPriv->Ops32bpp = NULL;
	pGCPriv->OpsAre8bpp = FALSE;
	pGCPriv->changes = 0;
    } else
	pGC->funcs = &cfb32GCFuncs_Underlay;
	
    return TRUE;
}


static void
cfb8_32ValidateGC(
    GCPtr pGC,
    unsigned long changes,
    DrawablePtr pDraw
){
    cfb8_32GCPtr pGCPriv = CFB8_32_GET_GC_PRIVATE(pGC);

    if(pDraw->bitsPerPixel == 32) {
	if(pGCPriv->OpsAre8bpp) {
	    int origChanges = changes;
	    pGC->ops = pGCPriv->Ops32bpp;
	    changes |= pGCPriv->changes;
	    pGCPriv->changes = origChanges;
	    pGCPriv->OpsAre8bpp = FALSE;
	} else 
	    pGCPriv->changes |= changes;

	cfb8_32ValidateGC32(pGC, changes, pDraw);
	pGCPriv->Ops32bpp = pGC->ops;
    } else {  /* bitsPerPixel == 8 */
	if(!pGCPriv->OpsAre8bpp) {
	    int origChanges = changes;
	    pGC->ops = pGCPriv->Ops8bpp;
	    changes |= pGCPriv->changes;
	    pGCPriv->changes = origChanges;
	    pGCPriv->OpsAre8bpp = TRUE;
	} else 
	    pGCPriv->changes |= changes;

	cfb8_32ValidateGC8(pGC, changes, pDraw);
	pGCPriv->Ops8bpp = pGC->ops;
    }
}