1 /***********************************************************
3 Copyright 1987, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
26 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
30 Permission to use, copy, modify, and distribute this software and its
31 documentation for any purpose and without fee is hereby granted,
32 provided that the above copyright notice appear in all copies and that
33 both that copyright notice and this permission notice appear in
34 supporting documentation, and that the name of Digital not be
35 used in advertising or publicity pertaining to distribution of the
36 software without specific, written prior permission.
38 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46 ******************************************************************/
48 #ifdef HAVE_DIX_CONFIG_H
49 #include <dix-config.h>
55 #include "windowstr.h"
56 #include "pixmapstr.h"
57 #include "scrnintstr.h"
60 #include "cfbmskbits.h"
65 cfbPutImage(pDraw
, pGC
, depth
, x
, y
, w
, h
, leftPad
, format
, pImage
)
68 int depth
, x
, y
, w
, h
;
75 if ((w
== 0) || (h
== 0))
78 if (format
!= XYPixmap
)
80 pPixmap
= GetScratchPixmapHeader(pDraw
->pScreen
, w
+leftPad
, h
, depth
,
81 BitsPerPixel(depth
), PixmapBytePad(w
+leftPad
, depth
),
87 if (format
== ZPixmap
)
88 (void)(*pGC
->ops
->CopyArea
)((DrawablePtr
)pPixmap
, pDraw
, pGC
,
89 leftPad
, 0, w
, h
, x
, y
);
91 (void)(*pGC
->ops
->CopyPlane
)((DrawablePtr
)pPixmap
, pDraw
, pGC
,
92 leftPad
, 0, w
, h
, x
, y
, 1);
94 FreeScratchPixmapHeader(pPixmap
);
100 CfbBits oldPlanemask
;
105 oldPlanemask
= pGC
->planemask
;
106 oldFg
= pGC
->fgPixel
;
107 oldBg
= pGC
->bgPixel
;
110 DoChangeGC(pGC
, GCForeground
| GCBackground
, gcv
, 0);
111 bytesPer
= (long)h
* BitmapBytePad(w
+ leftPad
);
113 for (i
= 1 << (depth
-1); i
!= 0; i
>>= 1, pImage
+= bytesPer
)
115 if (i
& oldPlanemask
)
118 DoChangeGC(pGC
, GCPlaneMask
, gcv
, 0);
119 ValidateGC(pDraw
, pGC
);
120 (*pGC
->ops
->PutImage
)(pDraw
, pGC
, 1, x
, y
, w
, h
, leftPad
,
124 gcv
[0] = oldPlanemask
;
127 DoChangeGC(pGC
, GCPlaneMask
| GCForeground
| GCBackground
, gcv
, 0);
128 ValidateGC(pDraw
, pGC
);
133 cfbGetImage(pDrawable
, sx
, sy
, w
, h
, format
, planeMask
, pdstLine
)
134 DrawablePtr pDrawable
;
137 unsigned long planeMask
;
146 if ((w
== 0) || (h
== 0))
148 if (pDrawable
->bitsPerPixel
== 1)
150 mfbGetImage(pDrawable
, sx
, sy
, w
, h
, format
, planeMask
, pdstLine
);
153 pScreen
= pDrawable
->pScreen
;
155 * XFree86 DDX empties the root borderClip when the VT is
156 * switched away; this checks for that case
158 if (!cfbDrawableEnabled (pDrawable
))
160 if (format
== ZPixmap
)
162 pPixmap
= GetScratchPixmapHeader(pScreen
, w
, h
,
163 pDrawable
->depth
, pDrawable
->bitsPerPixel
,
164 PixmapBytePad(w
,pDrawable
->depth
), (pointer
)pdstLine
);
167 if ((planeMask
& PMSK
) != PMSK
)
168 bzero((char *)pdstLine
, pPixmap
->devKind
* h
);
169 ptSrc
.x
= sx
+ pDrawable
->x
;
170 ptSrc
.y
= sy
+ pDrawable
->y
;
175 REGION_INIT(pScreen
, &rgnDst
, &box
, 1);
176 cfbDoBitblt(pDrawable
, (DrawablePtr
)pPixmap
, GXcopy
, &rgnDst
,
178 REGION_UNINIT(pScreen
, &rgnDst
);
179 FreeScratchPixmapHeader(pPixmap
);
184 #if IMAGE_BYTE_ORDER == LSBFirst
186 pPixmap
= GetScratchPixmapHeader(pScreen
, w
, h
, /*depth*/ 1,
187 /*bpp*/ 1, BitmapBytePad(w
), (pointer
)pdstLine
);
191 ptSrc
.x
= sx
+ pDrawable
->x
;
192 ptSrc
.y
= sy
+ pDrawable
->y
;
197 REGION_INIT(pScreen
, &rgnDst
, &box
, 1);
198 cfbCopyImagePlane (pDrawable
, (DrawablePtr
)pPixmap
, GXcopy
, &rgnDst
,
200 REGION_UNINIT(pScreen
, &rgnDst
);
201 FreeScratchPixmapHeader(pPixmap
);
203 miGetImage (pDrawable
, sx
, sy
, w
, h
, format
, planeMask
, pdstLine
);