2 * Copyright © 1998 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Keith Packard not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Keith Packard makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
23 #ifdef HAVE_DIX_CONFIG_H
24 #include <dix-config.h>
32 fbPutImage(DrawablePtr pDrawable
,
35 int x
, int y
, int w
, int h
, int leftPad
, int format
, char *pImage
)
37 FbGCPrivPtr pPriv
= fbGetGCPrivate(pGC
);
40 FbStip
*src
= (FbStip
*) pImage
;
47 srcStride
= BitmapBytePad(w
+ leftPad
) / sizeof(FbStip
);
48 fbPutXYImage(pDrawable
,
49 fbGetCompositeClip(pGC
),
53 pGC
->alu
, TRUE
, x
, y
, w
, h
, src
, srcStride
, leftPad
);
56 srcStride
= BitmapBytePad(w
+ leftPad
) / sizeof(FbStip
);
57 for (i
= (unsigned long) 1 << (pDrawable
->depth
- 1); i
; i
>>= 1) {
58 if (i
& pGC
->planemask
) {
59 fbPutXYImage(pDrawable
,
60 fbGetCompositeClip(pGC
),
63 fbReplicatePixel(i
, pDrawable
->bitsPerPixel
),
65 TRUE
, x
, y
, w
, h
, src
, srcStride
, leftPad
);
71 if (pDrawable
->bitsPerPixel
!= BitsPerPixel(pDrawable
->depth
)) {
72 srcStride
= PixmapBytePad(w
, pDrawable
->depth
);
73 fb24_32PutZImage(pDrawable
,
74 fbGetCompositeClip(pGC
),
76 (FbBits
) pGC
->planemask
,
77 x
, y
, w
, h
, (CARD8
*) pImage
, srcStride
);
80 srcStride
= PixmapBytePad(w
, pDrawable
->depth
) / sizeof(FbStip
);
81 fbPutZImage(pDrawable
,
82 fbGetCompositeClip(pGC
),
83 pGC
->alu
, pPriv
->pm
, x
, y
, w
, h
, src
, srcStride
);
89 fbPutZImage(DrawablePtr pDrawable
,
94 int y
, int width
, int height
, FbStip
* src
, FbStride srcStride
)
104 fbGetStipDrawable(pDrawable
, dst
, dstStride
, dstBpp
, dstXoff
, dstYoff
);
106 for (nbox
= RegionNumRects(pClip
),
107 pbox
= RegionRects(pClip
); nbox
--; pbox
++) {
120 if (x1
>= x2
|| y1
>= y2
)
122 fbBltStip(src
+ (y1
- y
) * srcStride
,
125 dst
+ (y1
+ dstYoff
) * dstStride
,
127 (x1
+ dstXoff
) * dstBpp
,
128 (x2
- x1
) * dstBpp
, (y2
- y1
), alu
, pm
, dstBpp
);
131 fbFinishAccess(pDrawable
);
135 fbPutXYImage(DrawablePtr pDrawable
,
144 int width
, int height
, FbStip
* src
, FbStride srcStride
, int srcX
)
149 int dstXoff
, dstYoff
;
153 FbBits fgand
= 0, fgxor
= 0, bgand
= 0, bgxor
= 0;
155 fbGetDrawable(pDrawable
, dst
, dstStride
, dstBpp
, dstXoff
, dstYoff
);
159 alu
= FbOpaqueStipple1Rop(alu
, fg
, bg
);
161 alu
= FbStipple1Rop(alu
, fg
);
164 fgand
= fbAnd(alu
, fg
, pm
);
165 fgxor
= fbXor(alu
, fg
, pm
);
167 bgand
= fbAnd(alu
, bg
, pm
);
168 bgxor
= fbXor(alu
, bg
, pm
);
171 bgand
= fbAnd(GXnoop
, (FbBits
) 0, FB_ALLONES
);
172 bgxor
= fbXor(GXnoop
, (FbBits
) 0, FB_ALLONES
);
176 for (nbox
= RegionNumRects(pClip
),
177 pbox
= RegionRects(pClip
); nbox
--; pbox
++) {
190 if (x1
>= x2
|| y1
>= y2
)
193 fbBltStip(src
+ (y1
- y
) * srcStride
,
196 (FbStip
*) (dst
+ (y1
+ dstYoff
) * dstStride
),
197 FbBitsStrideToStipStride(dstStride
),
198 (x1
+ dstXoff
) * dstBpp
,
199 (x2
- x1
) * dstBpp
, (y2
- y1
), alu
, pm
, dstBpp
);
202 fbBltOne(src
+ (y1
- y
) * srcStride
,
205 dst
+ (y1
+ dstYoff
) * dstStride
,
207 (x1
+ dstXoff
) * dstBpp
,
209 (x2
- x1
) * dstBpp
, (y2
- y1
), fgand
, fgxor
, bgand
, bgxor
);
213 fbFinishAccess(pDrawable
);
217 fbGetImage(DrawablePtr pDrawable
,
220 int w
, int h
, unsigned int format
, unsigned long planeMask
, char *d
)
225 int srcXoff
, srcYoff
;
230 * XFree86 DDX empties the root borderClip when the VT is
231 * switched away; this checks for that case
233 if (!fbDrawableEnabled(pDrawable
))
236 if (format
== ZPixmap
&&
237 pDrawable
->bitsPerPixel
!= BitsPerPixel(pDrawable
->depth
)) {
238 fb24_32GetImage(pDrawable
, x
, y
, w
, h
, format
, planeMask
, d
);
242 fbGetDrawable(pDrawable
, src
, srcStride
, srcBpp
, srcXoff
, srcYoff
);
248 if (format
== ZPixmap
|| srcBpp
== 1) {
251 pm
= fbReplicatePixel(planeMask
, srcBpp
);
252 dstStride
= PixmapBytePad(w
, pDrawable
->depth
);
253 if (pm
!= FB_ALLONES
)
254 memset(d
, 0, dstStride
* h
);
255 dstStride
/= sizeof(FbStip
);
256 fbBltStip((FbStip
*) (src
+ (y
+ srcYoff
) * srcStride
),
257 FbBitsStrideToStipStride(srcStride
),
258 (x
+ srcXoff
) * srcBpp
,
259 dst
, dstStride
, 0, w
* srcBpp
, h
, GXcopy
, pm
, srcBpp
);
262 dstStride
= BitmapBytePad(w
) / sizeof(FbStip
);
263 fbBltPlane(src
+ (y
+ srcYoff
) * srcStride
,
265 (x
+ srcXoff
) * srcBpp
,
271 fbAndStip(GXcopy
, FB_STIP_ALLONES
, FB_STIP_ALLONES
),
272 fbXorStip(GXcopy
, FB_STIP_ALLONES
, FB_STIP_ALLONES
),
273 fbAndStip(GXcopy
, 0, FB_STIP_ALLONES
),
274 fbXorStip(GXcopy
, 0, FB_STIP_ALLONES
), planeMask
);
277 fbFinishAccess(pDrawable
);