1
/* $Xorg: cfbwindow.c,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ */
2
/***********************************************************
4
Copyright 1987, 1998 The Open Group
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
Except as contained in this notice, the name of The Open Group shall not be
23
used in advertising or otherwise to promote the sale, use or other dealings
24
in this Software without prior written authorization from The Open Group.
27
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
31
Permission to use, copy, modify, and distribute this software and its
32
documentation for any purpose and without fee is hereby granted,
33
provided that the above copyright notice appear in all copies and that
34
both that copyright notice and this permission notice appear in
35
supporting documentation, and that the name of Digital not be
36
used in advertising or publicity pertaining to distribution of the
37
software without specific, written prior permission.
39
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47
******************************************************************/
50
#include "scrnintstr.h"
51
#include "windowstr.h"
54
#include "regionstr.h"
55
#include "cfbmskbits.h"
57
extern WindowPtr *WindowTable;
65
pPrivWin = cfbGetWindowPrivate(pWin);
66
pPrivWin->pRotatedBorder = NullPixmap;
67
pPrivWin->pRotatedBackground = NullPixmap;
68
pPrivWin->fastBackground = FALSE;
69
pPrivWin->fastBorder = FALSE;
70
pPrivWin->oldRotate.x = 0;
71
pPrivWin->oldRotate.y = 0;
73
#ifdef PIXMAP_PER_WINDOW
74
/* Setup pointer to Screen pixmap */
75
pWin->devPrivates[frameWindowPrivateIndex].ptr =
76
(pointer) cfbGetScreenPixmap(pWin->drawable.pScreen);
83
cfbDestroyWindow(pWin)
88
pPrivWin = cfbGetWindowPrivate(pWin);
90
if (pPrivWin->pRotatedBorder)
91
(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
92
if (pPrivWin->pRotatedBackground)
93
(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
105
/* (x, y) is the upper left corner of the window on the screen
106
do we really need to pass this? (is it a;ready in pWin->absCorner?)
107
we only do the rotation for pixmaps that are 32 bits wide (padded
109
cfbChangeWindowAttributes() has already put a copy of the pixmap
110
in pPrivWin->pRotated*
114
cfbPositionWindow(pWin, x, y)
118
cfbPrivWin *pPrivWin;
121
pPrivWin = cfbGetWindowPrivate(pWin);
122
if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
124
cfbXRotatePixmap(pPrivWin->pRotatedBackground,
125
pWin->drawable.x - pPrivWin->oldRotate.x);
126
cfbYRotatePixmap(pPrivWin->pRotatedBackground,
127
pWin->drawable.y - pPrivWin->oldRotate.y);
131
if (!pWin->borderIsPixel && pPrivWin->fastBorder)
133
while (pWin->backgroundState == ParentRelative)
135
cfbXRotatePixmap(pPrivWin->pRotatedBorder,
136
pWin->drawable.x - pPrivWin->oldRotate.x);
137
cfbYRotatePixmap(pPrivWin->pRotatedBorder,
138
pWin->drawable.y - pPrivWin->oldRotate.y);
143
pPrivWin->oldRotate.x = pWin->drawable.x;
144
pPrivWin->oldRotate.y = pWin->drawable.y;
151
cfbUnmapWindow(pWindow)
158
this code calls the bitblt helper code directly.
160
cfbCopyWindow copies only the parts of the destination that are
161
visible in the source.
166
cfbCopyWindow(pWin, ptOldOrg, prgnSrc)
168
DDXPointRec ptOldOrg;
172
register DDXPointPtr ppt;
174
register BoxPtr pbox;
176
register int i, nbox;
179
pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
181
REGION_INIT(pWin->drawable.pScreen, &rgnDst, NullBox, 0);
183
dx = ptOldOrg.x - pWin->drawable.x;
184
dy = ptOldOrg.y - pWin->drawable.y;
185
REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
186
REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
188
pbox = REGION_RECTS(&rgnDst);
189
nbox = REGION_NUM_RECTS(&rgnDst);
190
if(!nbox || !(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
192
REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
197
for (i = nbox; --i >= 0; ppt++, pbox++)
199
ppt->x = pbox->x1 + dx;
200
ppt->y = pbox->y1 + dy;
203
cfbDoBitbltCopy((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
204
GXcopy, &rgnDst, pptSrc, ~0L);
205
DEALLOCATE_LOCAL(pptSrc);
206
REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
211
/* swap in correct PaintWindow* routine. If we can use a fast output
212
routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
213
of it in devPrivates[cfbWindowPrivateIndex].ptr.
216
cfbChangeWindowAttributes(pWin, mask)
220
register unsigned long index;
221
register cfbPrivWin *pPrivWin;
225
pPrivWin = cfbGetWindowPrivate(pWin);
228
* When background state changes from ParentRelative and
229
* we had previously rotated the fast border pixmap to match
230
* the parent relative origin, rerotate to match window
232
if (mask & (CWBackPixmap | CWBackPixel) &&
233
pWin->backgroundState != ParentRelative &&
234
pPrivWin->fastBorder &&
235
(pPrivWin->oldRotate.x != pWin->drawable.x ||
236
pPrivWin->oldRotate.y != pWin->drawable.y))
238
cfbXRotatePixmap(pPrivWin->pRotatedBorder,
239
pWin->drawable.x - pPrivWin->oldRotate.x);
240
cfbYRotatePixmap(pPrivWin->pRotatedBorder,
241
pWin->drawable.y - pPrivWin->oldRotate.y);
242
pPrivWin->oldRotate.x = pWin->drawable.x;
243
pPrivWin->oldRotate.y = pWin->drawable.y;
247
index = lowbit (mask);
252
if (pWin->backgroundState == None)
254
pPrivWin->fastBackground = FALSE;
256
else if (pWin->backgroundState == ParentRelative)
258
pPrivWin->fastBackground = FALSE;
259
/* Rotate border to match parent origin */
260
if (pPrivWin->pRotatedBorder) {
261
for (pBgWin = pWin->parent;
262
pBgWin->backgroundState == ParentRelative;
263
pBgWin = pBgWin->parent);
264
cfbXRotatePixmap(pPrivWin->pRotatedBorder,
265
pBgWin->drawable.x - pPrivWin->oldRotate.x);
266
cfbYRotatePixmap(pPrivWin->pRotatedBorder,
267
pBgWin->drawable.y - pPrivWin->oldRotate.y);
268
pPrivWin->oldRotate.x = pBgWin->drawable.x;
269
pPrivWin->oldRotate.y = pBgWin->drawable.y;
272
else if (((width = (pWin->background.pixmap->drawable.width * PSZ))
273
<= PGSZ) && !(width & (width - 1)))
275
cfbCopyRotatePixmap(pWin->background.pixmap,
276
&pPrivWin->pRotatedBackground,
279
if (pPrivWin->pRotatedBackground)
281
pPrivWin->fastBackground = TRUE;
282
pPrivWin->oldRotate.x = pWin->drawable.x;
283
pPrivWin->oldRotate.y = pWin->drawable.y;
287
pPrivWin->fastBackground = FALSE;
292
pPrivWin->fastBackground = FALSE;
297
pPrivWin->fastBackground = FALSE;
301
if (((width = (pWin->border.pixmap->drawable.width * PSZ)) <= PGSZ) &&
302
!(width & (width - 1)))
305
pBgWin->backgroundState == ParentRelative;
306
pBgWin = pBgWin->parent);
307
cfbCopyRotatePixmap(pWin->border.pixmap,
308
&pPrivWin->pRotatedBorder,
311
if (pPrivWin->pRotatedBorder)
313
pPrivWin->fastBorder = TRUE;
314
pPrivWin->oldRotate.x = pBgWin->drawable.x;
315
pPrivWin->oldRotate.y = pBgWin->drawable.y;
319
pPrivWin->fastBorder = FALSE;
324
pPrivWin->fastBorder = FALSE;
328
pPrivWin->fastBorder = FALSE;