summaryrefslogtreecommitdiff
path: root/hw/xfree86/xf8_16bpp/cfbwindow.c
blob: 277abafc8d9e07cb9ada8bc8998e8056f64090c3 (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
/*
   Copyright (C) 1999.  The XFree86 Project Inc.

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

/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_16bpp/cfbwindow.c,v 1.4tsi Exp $ */

#include "X.h"
#include "scrnintstr.h"
#include "windowstr.h"
#define PSZ 8
#include "cfb.h"
#undef PSZ
#include "cfb16.h"
#include "cfb8_16.h"
#include "mistruct.h"
#include "regionstr.h"
#include "cfbmskbits.h"
#include "xf86.h"

/* We don't bother with cfb's fastBackground/Border so we don't
   need to use the Window privates */


Bool
cfb8_16CreateWindow(WindowPtr pWin)
{
    cfbPrivWin *pPrivWin = cfbGetWindowPrivate(pWin);

    pPrivWin->pRotatedBorder = NullPixmap;
    pPrivWin->pRotatedBackground = NullPixmap;
    pPrivWin->fastBackground = FALSE;
    pPrivWin->fastBorder = FALSE;
    pPrivWin->oldRotate.x = 0;
    pPrivWin->oldRotate.y = 0;

    return TRUE;
}


Bool
cfb8_16DestroyWindow(WindowPtr pWin)
{
    return TRUE;
}

Bool
cfb8_16PositionWindow(
    WindowPtr pWin,
    int x, int y
){
    return TRUE;
}


void
cfb8_16CopyWindow(
    WindowPtr pWin,
    DDXPointRec ptOldOrg,
    RegionPtr prgnSrc
){
    ScreenPtr pScreen = pWin->drawable.pScreen;
    cfb8_16ScreenPtr pScreenPriv = 
		CFB8_16_GET_SCREEN_PRIVATE(pWin->drawable.pScreen);
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
    DDXPointPtr ppt, pptSrc;
    RegionRec rgnDst;
    BoxPtr pbox;
    int i, nbox, dx, dy;
    WindowPtr pRoot = WindowTable[pScreen->myNum];

    REGION_NULL(pScreen, &rgnDst);

    dx = ptOldOrg.x - pWin->drawable.x;
    dy = ptOldOrg.y - pWin->drawable.y;
    REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
    REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);

    nbox = REGION_NUM_RECTS(&rgnDst);
    if(nbox &&
	(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)))) {

	pbox = REGION_RECTS(&rgnDst);
	for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
	    ppt->x = pbox->x1 + dx;
	    ppt->y = pbox->y1 + dy;
	}
	cfbDoBitbltCopy((DrawablePtr)pRoot, (DrawablePtr)pRoot,
                		GXcopy, &rgnDst, pptSrc, ~0L);
	if(pWin->drawable.bitsPerPixel == 16)
	    cfb16DoBitbltCopy((DrawablePtr)pScreenPriv->pix16, 
			      (DrawablePtr)pScreenPriv->pix16,
                		GXcopy, &rgnDst, pptSrc, ~0L);

	DEALLOCATE_LOCAL(pptSrc);
    }

    REGION_UNINIT(pScreen, &rgnDst);

    if(pWin->drawable.depth == 8) {
      REGION_NULL(pScreen, &rgnDst);
      miSegregateChildren(pWin, &rgnDst, pScrn->depth);
      if(REGION_NOTEMPTY(pScreen, &rgnDst)) {
	REGION_INTERSECT(pScreen, &rgnDst, &rgnDst, prgnSrc);
	nbox = REGION_NUM_RECTS(&rgnDst);
	if(nbox &&
	  (pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)))){

	    pbox = REGION_RECTS(&rgnDst);
	    for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
		ppt->x = pbox->x1 + dx;
		ppt->y = pbox->y1 + dy;
	    }

	    cfb16DoBitbltCopy((DrawablePtr)pScreenPriv->pix16, 
			      (DrawablePtr)pScreenPriv->pix16,
			      GXcopy, &rgnDst, pptSrc, ~0L);
	    DEALLOCATE_LOCAL(pptSrc);
	}
      }
      REGION_UNINIT(pScreen, &rgnDst);
    }
}

Bool
cfb8_16ChangeWindowAttributes(
    WindowPtr pWin,
    unsigned long mask
){
    if (pWin->drawable.bitsPerPixel == 16)
        return cfb16ChangeWindowAttributes(pWin,mask);
    else
        return cfbChangeWindowAttributes(pWin,mask);
}

void
cfb8_16WindowExposures(
   WindowPtr pWin,
   RegionPtr pReg,
   RegionPtr pOtherReg
){

    if(REGION_NUM_RECTS(pReg) && (pWin->drawable.bitsPerPixel == 16)) {
	cfb8_16ScreenPtr pScreenPriv = 
		CFB8_16_GET_SCREEN_PRIVATE(pWin->drawable.pScreen);

	cfbFillBoxSolid((DrawablePtr)pScreenPriv->pix8,
		REGION_NUM_RECTS(pReg), REGION_RECTS(pReg),
		pScreenPriv->key);
    }

    miWindowExposures(pWin, pReg, pOtherReg);
}


void
cfb8_16PaintWindow (
    WindowPtr   pWin,
    RegionPtr   pRegion,
    int         what
){
    if(pWin->drawable.bitsPerPixel == 16) {
	cfb16PaintWindow(pWin, pRegion, what);
	if(what == PW_BORDER) {
	    cfb8_16ScreenPtr pScreenPriv = 
		CFB8_16_GET_SCREEN_PRIVATE(pWin->drawable.pScreen);

	    cfbFillBoxSolid((DrawablePtr)pScreenPriv->pix8,
		REGION_NUM_RECTS(pRegion), REGION_RECTS(pRegion),
		pScreenPriv->key);
	}
    } else
	cfbPaintWindow(pWin, pRegion, what);

}