summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xfree86/accel/mach64/mach64win.c
blob: d8d5836a63e98d8425742868b4c352cac6b3128c (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
/* $XConsortium: mach64win.c,v 1.1 94/12/14 15:04:34 kaleb Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/mach64/mach64win.c,v 3.0 1994/11/26 12:43:03 dawes Exp $ */
/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
Copyright 1993,1994 by Kevin E. Martin, Chapel Hill, North Carolina.

                        All Rights Reserved

Permission to use, copy, modify, and distribute this software and its 
documentation for any purpose and without fee is hereby granted, 
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in 
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.  

DIGITAL AND KEVIN E. MARTIN AND RICKARD E. FAITH DISCLAIM ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL OR KEVIN E. MARTIN
BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Rewritten for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
Modified for the Mach-8 by Rickard E. Faith (faith@cs.unc.edu)
Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu)
Modified for the Mach64 by Kevin E. Martin (martin@cs.unc.edu)

******************************************************************/

#include "X.h"
#include "scrnintstr.h"
#include "windowstr.h"
#include "gcstruct.h"
#include "cfb.h"
#include "mistruct.h"
#include "regionstr.h"
#include "cfbmskbits.h"
#include "cfb16.h"
#include "cfb32.h"
#include "mach64.h"

void 
mach64CopyWindow(pWin, ptOldOrg, prgnSrc)
    WindowPtr pWin;
    DDXPointRec ptOldOrg;
    RegionPtr prgnSrc;
{
    RegionPtr prgnDst;
    DDXPointPtr pptInit;
    register DDXPointPtr pPt;
    register BoxPtr pbox, pboxOrig;
    register int dx, dy;
    register int count; 
    register int nbox;
    WindowPtr pWinRoot;
    GC dummyGC;
    extern WindowPtr *WindowTable;

    if (!xf86VTSema)
    {
	switch(pWin->drawable.bitsPerPixel)
	{
	    case 8:
	        cfbCopyWindow(pWin, ptOldOrg, prgnSrc);
		break;
	    case 16:
	        cfb16CopyWindow(pWin, ptOldOrg, prgnSrc);
		break;
	    case 32:
	        cfb32CopyWindow(pWin, ptOldOrg, prgnSrc);
		break;
	    default:
		ErrorF("mach64CopyWindow: unsupported depth %d \n",
			pWin->drawable.bitsPerPixel);
	}
	return;
    }

    dummyGC.subWindowMode = ~IncludeInferiors;
    dummyGC.alu = GXcopy;
    dummyGC.planemask = 0xffffffff;

    pWinRoot = WindowTable[pWin->drawable.pScreen->myNum];

    prgnDst = (* pWin->drawable.pScreen->RegionCreate)(NULL, 1);

    dx = ptOldOrg.x - pWin->drawable.x;
    dy = ptOldOrg.y - pWin->drawable.y;

    (* pWin->drawable.pScreen->TranslateRegion)(prgnSrc, -dx, -dy);
    (* pWin->drawable.pScreen->Intersect)(prgnDst, &pWin->borderClip, prgnSrc);

    pboxOrig = REGION_RECTS(prgnDst);
    nbox = REGION_NUM_RECTS(prgnDst);

    pptInit = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec));
    if(!pptInit)
	return;

    pPt = pptInit;
    for (pbox = pboxOrig, count = nbox; --count >= 0; pPt++, pbox++)
    {
        pPt->x = pbox->x1 + dx;
        pPt->y = pbox->y1 + dy;
    }

    mach64DoBitBlt((DrawablePtr)pWinRoot, (DrawablePtr)pWinRoot,
                   &dummyGC, prgnDst, pptInit, 0);

    DEALLOCATE_LOCAL(pptInit);
    (* pWin->drawable.pScreen->RegionDestroy)(prgnDst);
}