2 * Copyright © 2001 Keith Packard
4 * Partly based on code that is Copyright © The XFree86 Project Inc.
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
10 * documentation, and that the name of Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. Keith Packard makes no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
26 #include <kdrive-config.h>
30 #include "dixfontstr.h"
32 #define DEBUG_MIGRATE 0
33 #define DEBUG_PIXMAP 0
35 #define DBG_MIGRATE(a) ErrorF a
37 #define DBG_MIGRATE(a)
40 #define DBG_PIXMAP(a) ErrorF a
46 int kaaScreenPrivateIndex
;
47 int kaaPixmapPrivateIndex
;
49 #define KAA_PIXMAP_SCORE_MOVE_IN 10
50 #define KAA_PIXMAP_SCORE_MAX 20
51 #define KAA_PIXMAP_SCORE_MOVE_OUT -10
52 #define KAA_PIXMAP_SCORE_MIN -20
53 #define KAA_PIXMAP_SCORE_PINNED 1000
54 #define KAA_PIXMAP_SCORE_INIT 1001
57 kaaDrawableDirty (DrawablePtr pDrawable
)
60 KaaPixmapPrivPtr pKaaPixmap
;
62 if (pDrawable
->type
== DRAWABLE_WINDOW
)
63 pPixmap
= (*pDrawable
->pScreen
->GetWindowPixmap
)((WindowPtr
) pDrawable
);
65 pPixmap
= (PixmapPtr
)pDrawable
;
67 pKaaPixmap
= KaaGetPixmapPriv(pPixmap
);
68 if (pKaaPixmap
!= NULL
)
69 pKaaPixmap
->dirty
= TRUE
;
73 kaaPixmapSave (ScreenPtr pScreen
, KdOffscreenArea
*area
)
75 PixmapPtr pPixmap
= area
->privData
;
76 KaaPixmapPriv(pPixmap
);
77 int dst_pitch
, src_pitch
, bytes
;
78 unsigned char *dst
, *src
;
81 DBG_MIGRATE (("Save 0x%08x (0x%x) (%dx%d)\n",
83 KaaGetPixmapPriv(pPixmap
)->area
?
84 KaaGetPixmapPriv(pPixmap
)->area
->offset
: -1,
85 pPixmap
->drawable
.width
,
86 pPixmap
->drawable
.height
));
88 src_pitch
= pPixmap
->devKind
;
89 dst_pitch
= pKaaPixmap
->devKind
;
91 src
= pPixmap
->devPrivate
.ptr
;
92 dst
= pKaaPixmap
->devPrivate
.ptr
;
94 pPixmap
->devKind
= dst_pitch
;
95 pPixmap
->devPrivate
.ptr
= dst
;
96 pPixmap
->drawable
.serialNumber
= NEXT_SERIAL_NUMBER
;
97 pKaaPixmap
->area
= NULL
;
100 if (!pKaaPixmap
->dirty
)
104 kaaWaitSync (pPixmap
->drawable
.pScreen
);
106 bytes
= src_pitch
< dst_pitch
? src_pitch
: dst_pitch
;
108 i
= pPixmap
->drawable
.height
;
110 memcpy (dst
, src
, bytes
);
123 for (bits
= 0; val
!= 0; bits
++)
129 kaaPixmapAllocArea (PixmapPtr pPixmap
)
131 ScreenPtr pScreen
= pPixmap
->drawable
.pScreen
;
132 KaaScreenPriv (pScreen
);
133 KaaPixmapPriv (pPixmap
);
134 KdScreenPriv (pScreen
);
135 int bpp
= pPixmap
->drawable
.bitsPerPixel
;
136 CARD16 h
= pPixmap
->drawable
.height
;
137 CARD16 w
= pPixmap
->drawable
.width
;
140 if (pKaaScr
->info
->flags
& KAA_OFFSCREEN_ALIGN_POT
&& w
!= 1)
141 w
= 1 << (kaaLog2(w
- 1) + 1);
142 pitch
= (w
* bpp
/ 8 + pKaaScr
->info
->pitchAlign
- 1) &
143 ~(pKaaScr
->info
->pitchAlign
- 1);
145 pKaaPixmap
->devKind
= pPixmap
->devKind
;
146 pKaaPixmap
->devPrivate
= pPixmap
->devPrivate
;
147 pKaaPixmap
->area
= KdOffscreenAlloc (pScreen
, pitch
* h
,
148 pKaaScr
->info
->offsetAlign
,
150 kaaPixmapSave
, (pointer
) pPixmap
);
151 if (!pKaaPixmap
->area
)
154 DBG_PIXMAP(("++ 0x%08x (0x%x) (%dx%d)\n",
155 pPixmap
->drawable
.id
,
156 KaaGetPixmapPriv(pPixmap
)->area
?
157 KaaGetPixmapPriv(pPixmap
)->area
->offset
: -1,
158 pPixmap
->drawable
.width
,
159 pPixmap
->drawable
.height
));
160 pPixmap
->devKind
= pitch
;
161 pPixmap
->devPrivate
.ptr
= (pointer
) ((CARD8
*) pScreenPriv
->screen
->memory_base
+ pKaaPixmap
->area
->offset
);
162 pPixmap
->drawable
.serialNumber
= NEXT_SERIAL_NUMBER
;
167 kaaMoveInPixmap (PixmapPtr pPixmap
)
169 ScreenPtr pScreen
= pPixmap
->drawable
.pScreen
;
170 KaaScreenPriv (pScreen
);
171 KaaPixmapPriv (pPixmap
);
172 int dst_pitch
, src_pitch
, bytes
;
173 unsigned char *dst
, *src
;
176 DBG_MIGRATE (("-> 0x%08x (0x%x) (%dx%d)\n",
177 pPixmap
->drawable
.id
,
178 KaaGetPixmapPriv(pPixmap
)->area
?
179 KaaGetPixmapPriv(pPixmap
)->area
->offset
: -1,
180 pPixmap
->drawable
.width
,
181 pPixmap
->drawable
.height
));
183 src
= pPixmap
->devPrivate
.ptr
;
184 src_pitch
= pPixmap
->devKind
;
186 if (!kaaPixmapAllocArea (pPixmap
))
189 pKaaPixmap
->dirty
= FALSE
;
191 if (pKaaScr
->info
->UploadToScreen
)
193 if (pKaaScr
->info
->UploadToScreen(pPixmap
, (char *) src
, src_pitch
))
197 dst
= pPixmap
->devPrivate
.ptr
;
198 dst_pitch
= pPixmap
->devKind
;
200 bytes
= src_pitch
< dst_pitch
? src_pitch
: dst_pitch
;
202 kaaWaitSync (pPixmap
->drawable
.pScreen
);
204 i
= pPixmap
->drawable
.height
;
206 memcpy (dst
, src
, bytes
);
213 kaaMoveOutPixmap (PixmapPtr pPixmap
)
215 KaaPixmapPriv (pPixmap
);
216 KdOffscreenArea
*area
= pKaaPixmap
->area
;
218 DBG_MIGRATE (("<- 0x%08x (0x%x) (%dx%d)\n",
219 pPixmap
->drawable
.id
,
220 KaaGetPixmapPriv(pPixmap
)->area
?
221 KaaGetPixmapPriv(pPixmap
)->area
->offset
: -1,
222 pPixmap
->drawable
.width
,
223 pPixmap
->drawable
.height
));
226 kaaPixmapSave (pPixmap
->drawable
.pScreen
, area
);
227 KdOffscreenFree (pPixmap
->drawable
.pScreen
, area
);
232 kaaPixmapUseScreen (PixmapPtr pPixmap
)
234 KaaPixmapPriv (pPixmap
);
236 if (pKaaPixmap
->score
== KAA_PIXMAP_SCORE_PINNED
)
239 if (pKaaPixmap
->score
== KAA_PIXMAP_SCORE_INIT
) {
240 kaaMoveInPixmap(pPixmap
);
241 pKaaPixmap
->score
= 0;
244 if (pKaaPixmap
->score
< KAA_PIXMAP_SCORE_MAX
)
247 if (!kaaPixmapIsOffscreen(pPixmap
) &&
248 pKaaPixmap
->score
>= KAA_PIXMAP_SCORE_MOVE_IN
)
249 kaaMoveInPixmap (pPixmap
);
251 KdOffscreenMarkUsed (pPixmap
);
255 kaaPixmapUseMemory (PixmapPtr pPixmap
)
257 KaaPixmapPriv (pPixmap
);
259 if (pKaaPixmap
->score
== KAA_PIXMAP_SCORE_PINNED
)
262 if (pKaaPixmap
->score
== KAA_PIXMAP_SCORE_INIT
)
263 pKaaPixmap
->score
= 0;
265 if (pKaaPixmap
->score
> KAA_PIXMAP_SCORE_MIN
)
268 if (pKaaPixmap
->area
&&
269 pKaaPixmap
->score
<= KAA_PIXMAP_SCORE_MOVE_OUT
)
270 kaaMoveOutPixmap (pPixmap
);
275 kaaDestroyPixmap (PixmapPtr pPixmap
)
277 if (pPixmap
->refcnt
== 1)
279 KaaPixmapPriv (pPixmap
);
280 if (pKaaPixmap
->area
)
282 DBG_PIXMAP(("-- 0x%08x (0x%x) (%dx%d)\n",
283 pPixmap
->drawable
.id
,
284 KaaGetPixmapPriv(pPixmap
)->area
->offset
,
285 pPixmap
->drawable
.width
,
286 pPixmap
->drawable
.height
));
287 /* Free the offscreen area */
288 KdOffscreenFree (pPixmap
->drawable
.pScreen
, pKaaPixmap
->area
);
289 pPixmap
->devPrivate
= pKaaPixmap
->devPrivate
;
290 pPixmap
->devKind
= pKaaPixmap
->devKind
;
293 return fbDestroyPixmap (pPixmap
);
297 kaaCreatePixmap(ScreenPtr pScreen
, int w
, int h
, int depth
)
300 KaaPixmapPrivPtr pKaaPixmap
;
303 bpp
= BitsPerPixel (depth
);
304 if (bpp
== 32 && depth
== 24)
307 KdScreenPriv (pScreen
);
309 for (fb
= 0; fb
< KD_MAX_FB
&& pScreenPriv
->screen
->fb
[fb
].depth
; fb
++)
310 if (pScreenPriv
->screen
->fb
[fb
].depth
== 24)
312 bpp
= pScreenPriv
->screen
->fb
[fb
].bitsPerPixel
;
317 pPixmap
= fbCreatePixmapBpp (pScreen
, w
, h
, depth
, bpp
);
320 pKaaPixmap
= KaaGetPixmapPriv(pPixmap
);
322 pKaaPixmap
->score
= KAA_PIXMAP_SCORE_PINNED
;
324 pKaaPixmap
->score
= KAA_PIXMAP_SCORE_INIT
;
326 pKaaPixmap
->area
= NULL
;
327 pKaaPixmap
->dirty
= FALSE
;
333 kaaPixmapIsOffscreen(PixmapPtr p
)
335 ScreenPtr pScreen
= p
->drawable
.pScreen
;
336 KdScreenPriv(pScreen
);
338 return ((unsigned long) ((CARD8
*) p
->devPrivate
.ptr
-
339 (CARD8
*) pScreenPriv
->screen
->memory_base
) <
340 pScreenPriv
->screen
->memory_size
);
344 kaaGetOffscreenPixmap (DrawablePtr pDrawable
, int *xp
, int *yp
)
349 if (pDrawable
->type
== DRAWABLE_WINDOW
) {
350 pPixmap
= (*pDrawable
->pScreen
->GetWindowPixmap
) ((WindowPtr
) pDrawable
);
352 x
= -pPixmap
->screen_x
;
353 y
= -pPixmap
->screen_y
;
361 pPixmap
= (PixmapPtr
) pDrawable
;
367 if (kaaPixmapIsOffscreen (pPixmap
))
374 kaaDrawableIsOffscreen (DrawablePtr pDrawable
)
377 if (pDrawable
->type
== DRAWABLE_WINDOW
)
378 pPixmap
= (*pDrawable
->pScreen
->GetWindowPixmap
) ((WindowPtr
) pDrawable
);
380 pPixmap
= (PixmapPtr
) pDrawable
;
381 return kaaPixmapIsOffscreen (pPixmap
);
386 kaaFillTiled(int dst_x
,
394 void (*Copy
) (int srcX
,
401 modulus (src_x
, src_width
, src_x
);
402 modulus (src_y
, src_height
, src_y
);
406 int dst_x_tmp
= dst_x
;
407 int src_x_tmp
= src_x
;
408 int width_tmp
= width
;
409 int height_left
= src_height
- src_y
;
410 int height_this
= min (height
, height_left
);
414 int width_left
= src_width
- src_x_tmp
;
415 int width_this
= min (width_tmp
, width_left
);
417 (*Copy
) (src_x_tmp
, src_y
,
419 width_this
, height_this
);
421 width_tmp
-= width_this
;
422 dst_x_tmp
+= width_this
;
424 height
-= height_this
;
425 dst_y
+= height_this
;
432 kaaFillSpans(DrawablePtr pDrawable
, GCPtr pGC
, int n
,
433 DDXPointPtr ppt
, int *pwidth
, int fSorted
)
435 ScreenPtr pScreen
= pDrawable
->pScreen
;
436 KdScreenPriv (pScreen
);
437 KaaScreenPriv (pScreen
);
438 RegionPtr pClip
= fbGetCompositeClip(pGC
);
440 BoxPtr pextent
, pbox
;
442 int extentX1
, extentX2
, extentY1
, extentY2
;
443 int fullX1
, fullX2
, fullY1
;
447 if (!pScreenPriv
->enabled
||
448 pGC
->fillStyle
!= FillSolid
||
449 !(pPixmap
= kaaGetOffscreenPixmap (pDrawable
, &off_x
, &off_y
)) ||
450 !(*pKaaScr
->info
->PrepareSolid
) (pPixmap
,
455 KdCheckFillSpans (pDrawable
, pGC
, n
, ppt
, pwidth
, fSorted
);
459 pextent
= REGION_EXTENTS(pGC
->pScreen
, pClip
);
460 extentX1
= pextent
->x1
;
461 extentY1
= pextent
->y1
;
462 extentX2
= pextent
->x2
;
463 extentY2
= pextent
->y2
;
468 fullX2
= fullX1
+ (int) *pwidth
;
472 if (fullY1
< extentY1
|| extentY2
<= fullY1
)
475 if (fullX1
< extentX1
)
478 if (fullX2
> extentX2
)
481 if (fullX1
>= fullX2
)
484 nbox
= REGION_NUM_RECTS (pClip
);
487 (*pKaaScr
->info
->Solid
) (fullX1
+ off_x
, fullY1
+ off_y
,
488 fullX2
+ off_x
, fullY1
+ 1 + off_y
);
492 pbox
= REGION_RECTS(pClip
);
495 if (pbox
->y1
<= fullY1
&& fullY1
< pbox
->y2
)
504 (*pKaaScr
->info
->Solid
) (partX1
+ off_x
, fullY1
+ off_y
,
505 partX2
+ off_x
, fullY1
+ 1 + off_y
);
511 (*pKaaScr
->info
->DoneSolid
) ();
512 kaaDrawableDirty (pDrawable
);
513 kaaMarkSync (pDrawable
->pScreen
);
517 kaaCopyNtoN (DrawablePtr pSrcDrawable
,
518 DrawablePtr pDstDrawable
,
529 KdScreenPriv (pDstDrawable
->pScreen
);
530 KaaScreenPriv (pDstDrawable
->pScreen
);
531 PixmapPtr pSrcPixmap
, pDstPixmap
;
532 int src_off_x
, src_off_y
;
533 int dst_off_x
, dst_off_y
;
535 /* Migrate pixmaps to same place as destination */
536 if (pScreenPriv
->enabled
&& pSrcDrawable
->type
== DRAWABLE_PIXMAP
) {
537 if (kaaDrawableIsOffscreen (pDstDrawable
))
538 kaaPixmapUseScreen ((PixmapPtr
) pSrcDrawable
);
540 kaaPixmapUseMemory ((PixmapPtr
) pSrcDrawable
);
543 if (pScreenPriv
->enabled
&&
544 (pSrcPixmap
= kaaGetOffscreenPixmap (pSrcDrawable
, &src_off_x
, &src_off_y
)) &&
545 (pDstPixmap
= kaaGetOffscreenPixmap (pDstDrawable
, &dst_off_x
, &dst_off_y
)) &&
546 (*pKaaScr
->info
->PrepareCopy
) (pSrcPixmap
,
550 pGC
? pGC
->alu
: GXcopy
,
551 pGC
? pGC
->planemask
: FB_ALLONES
))
555 (*pKaaScr
->info
->Copy
) (pbox
->x1
+ dx
+ src_off_x
,
556 pbox
->y1
+ dy
+ src_off_y
,
557 pbox
->x1
+ dst_off_x
, pbox
->y1
+ dst_off_y
,
559 pbox
->y2
- pbox
->y1
);
562 (*pKaaScr
->info
->DoneCopy
) ();
563 kaaMarkSync (pDstDrawable
->pScreen
);
567 kaaWaitSync (pDstDrawable
->pScreen
);
568 fbCopyNtoN (pSrcDrawable
, pDstDrawable
, pGC
,
569 pbox
, nbox
, dx
, dy
, reverse
, upsidedown
,
572 kaaDrawableDirty (pDstDrawable
);
576 kaaCopyArea(DrawablePtr pSrcDrawable
, DrawablePtr pDstDrawable
, GCPtr pGC
,
577 int srcx
, int srcy
, int width
, int height
, int dstx
, int dsty
)
579 return fbDoCopy (pSrcDrawable
, pDstDrawable
, pGC
,
580 srcx
, srcy
, width
, height
,
581 dstx
, dsty
, kaaCopyNtoN
, 0, 0);
585 kaaPolyFillRect(DrawablePtr pDrawable
,
590 KdScreenPriv (pDrawable
->pScreen
);
591 KaaScreenPriv (pDrawable
->pScreen
);
592 RegionPtr pClip
= fbGetCompositeClip(pGC
);
594 register BoxPtr pbox
;
596 int extentX1
, extentX2
, extentY1
, extentY2
;
597 int fullX1
, fullX2
, fullY1
, fullY2
;
598 int partX1
, partX2
, partY1
, partY2
;
603 if (!pScreenPriv
->enabled
||
604 pGC
->fillStyle
!= FillSolid
||
605 !(pPixmap
= kaaGetOffscreenPixmap (pDrawable
, &xoff
, &yoff
)) ||
606 !(*pKaaScr
->info
->PrepareSolid
) (pPixmap
,
611 KdCheckPolyFillRect (pDrawable
, pGC
, nrect
, prect
);
618 pextent
= REGION_EXTENTS(pGC
->pScreen
, pClip
);
619 extentX1
= pextent
->x1
;
620 extentY1
= pextent
->y1
;
621 extentX2
= pextent
->x2
;
622 extentY2
= pextent
->y2
;
625 fullX1
= prect
->x
+ xorg
;
626 fullY1
= prect
->y
+ yorg
;
627 fullX2
= fullX1
+ (int) prect
->width
;
628 fullY2
= fullY1
+ (int) prect
->height
;
631 if (fullX1
< extentX1
)
634 if (fullY1
< extentY1
)
637 if (fullX2
> extentX2
)
640 if (fullY2
> extentY2
)
643 if ((fullX1
>= fullX2
) || (fullY1
>= fullY2
))
645 n
= REGION_NUM_RECTS (pClip
);
648 (*pKaaScr
->info
->Solid
) (fullX1
+ xoff
, fullY1
+ yoff
,
649 fullX2
+ xoff
, fullY2
+ yoff
);
653 pbox
= REGION_RECTS(pClip
);
655 * clip the rectangle to each box in the clip region
656 * this is logically equivalent to calling Intersect()
675 if (partX1
< partX2
&& partY1
< partY2
)
676 (*pKaaScr
->info
->Solid
) (partX1
+ xoff
, partY1
+ yoff
,
677 partX2
+ xoff
, partY2
+ yoff
);
681 (*pKaaScr
->info
->DoneSolid
) ();
682 kaaDrawableDirty (pDrawable
);
683 kaaMarkSync (pDrawable
->pScreen
);
687 kaaSolidBoxClipped (DrawablePtr pDrawable
,
696 KdScreenPriv (pDrawable
->pScreen
);
697 KaaScreenPriv (pDrawable
->pScreen
);
702 int partX1
, partX2
, partY1
, partY2
;
704 if (!pScreenPriv
->enabled
||
705 !(pPixmap
= kaaGetOffscreenPixmap (pDrawable
, &xoff
, &yoff
)) ||
706 !(*pKaaScr
->info
->PrepareSolid
) (pPixmap
, GXcopy
, pm
, fg
))
708 kaaWaitSync (pDrawable
->pScreen
);
709 fg
= fbReplicatePixel (fg
, pDrawable
->bitsPerPixel
);
710 fbSolidBoxClipped (pDrawable
, pClip
, x1
, y1
, x2
, y2
,
711 fbAnd (GXcopy
, fg
, pm
),
712 fbXor (GXcopy
, fg
, pm
));
713 kaaDrawableDirty (pDrawable
);
716 for (nbox
= REGION_NUM_RECTS(pClip
), pbox
= REGION_RECTS(pClip
);
728 if (partX2
<= partX1
)
739 if (partY2
<= partY1
)
742 (*pKaaScr
->info
->Solid
) (partX1
+ xoff
, partY1
+ yoff
,
743 partX2
+ xoff
, partY2
+ yoff
);
745 (*pKaaScr
->info
->DoneSolid
) ();
746 kaaDrawableDirty (pDrawable
);
747 kaaMarkSync (pDrawable
->pScreen
);
751 kaaImageGlyphBlt (DrawablePtr pDrawable
,
756 CharInfoPtr
*ppciInit
,
759 FbGCPrivPtr pPriv
= fbGetGCPrivate(pGC
);
762 unsigned char *pglyph
; /* pointer bits in glyph */
763 int gWidth
, gHeight
; /* width and height of glyph */
764 FbStride gStride
; /* stride of glyph */
768 void (*glyph
) (FbBits
*,
778 int dstXoff
, dstYoff
;
781 depthMask
= FbFullMask(pDrawable
->depth
);
782 if ((pGC
->planemask
& depthMask
) != depthMask
)
784 KdCheckImageGlyphBlt(pDrawable
, pGC
, x
, y
, nglyph
, ppciInit
, pglyphBase
);
788 fbGetDrawable (pDrawable
, dst
, dstStride
, dstBpp
, dstXoff
, dstYoff
);
790 case 8: glyph
= fbGlyph8
; break;
791 case 16: glyph
= fbGlyph16
; break;
792 case 24: glyph
= fbGlyph24
; break;
793 case 32: glyph
= fbGlyph32
; break;
799 if (TERMINALFONT (pGC
->font
) && !glyph
)
805 int xBack
, widthBack
;
806 int yBack
, heightBack
;
812 widthBack
+= (*ppci
++)->metrics
.characterWidth
;
818 widthBack
= -widthBack
;
820 yBack
= y
- FONTASCENT(pGC
->font
);
821 heightBack
= FONTASCENT(pGC
->font
) + FONTDESCENT(pGC
->font
);
822 kaaSolidBoxClipped (pDrawable
,
823 fbGetCompositeClip(pGC
),
833 kaaWaitSync (pDrawable
->pScreen
);
834 kaaDrawableDirty (pDrawable
);
840 pglyph
= FONTGLYPHBITS(pglyphBase
, pci
);
841 gWidth
= GLYPHWIDTHPIXELS(pci
);
842 gHeight
= GLYPHHEIGHTPIXELS(pci
);
843 if (gWidth
&& gHeight
)
845 gx
= x
+ pci
->metrics
.leftSideBearing
;
846 gy
= y
- pci
->metrics
.ascent
;
847 if (glyph
&& gWidth
<= sizeof (FbStip
) * 8 &&
848 fbGlyphIn (fbGetCompositeClip(pGC
), gx
, gy
, gWidth
, gHeight
))
850 (*glyph
) (dst
+ (gy
+ dstYoff
) * dstStride
,
860 gStride
= GLYPHWIDTHBYTESPADDED(pci
) / sizeof (FbStip
);
861 fbPutXYImage (pDrawable
,
862 fbGetCompositeClip(pGC
),
878 x
+= pci
->metrics
.characterWidth
;
882 static const GCOps kaaOps
= {
906 kaaValidateGC (GCPtr pGC
, Mask changes
, DrawablePtr pDrawable
)
908 fbValidateGC (pGC
, changes
, pDrawable
);
910 if (kaaDrawableIsOffscreen (pDrawable
))
911 pGC
->ops
= (GCOps
*) &kaaOps
;
913 pGC
->ops
= (GCOps
*) &kdAsyncPixmapGCOps
;
916 GCFuncs kaaGCFuncs
= {
927 kaaCreateGC (GCPtr pGC
)
929 if (!fbCreateGC (pGC
))
932 pGC
->funcs
= &kaaGCFuncs
;
939 kaaCopyWindow(WindowPtr pWin
, DDXPointRec ptOldOrg
, RegionPtr prgnSrc
)
943 PixmapPtr pPixmap
= (*pWin
->drawable
.pScreen
->GetWindowPixmap
) (pWin
);
945 dx
= ptOldOrg
.x
- pWin
->drawable
.x
;
946 dy
= ptOldOrg
.y
- pWin
->drawable
.y
;
947 REGION_TRANSLATE(pWin
->drawable
.pScreen
, prgnSrc
, -dx
, -dy
);
949 REGION_INIT (pWin
->drawable
.pScreen
, &rgnDst
, NullBox
, 0);
951 REGION_INTERSECT(pWin
->drawable
.pScreen
, &rgnDst
, &pWin
->borderClip
, prgnSrc
);
953 if (pPixmap
->screen_x
|| pPixmap
->screen_y
)
954 REGION_TRANSLATE (pWin
->drawable
.pScreen
, &rgnDst
,
955 -pPixmap
->screen_x
, -pPixmap
->screen_y
);
958 fbCopyRegion (&pPixmap
->drawable
, &pPixmap
->drawable
,
960 &rgnDst
, dx
, dy
, kaaCopyNtoN
, 0, 0);
962 REGION_UNINIT(pWin
->drawable
.pScreen
, &rgnDst
);
966 kaaFillRegionSolid (DrawablePtr pDrawable
,
970 KdScreenPriv(pDrawable
->pScreen
);
971 KaaScreenPriv(pDrawable
->pScreen
);
975 if (pScreenPriv
->enabled
&&
976 (pPixmap
= kaaGetOffscreenPixmap (pDrawable
, &xoff
, &yoff
)) &&
977 (*pKaaScr
->info
->PrepareSolid
) (pPixmap
, GXcopy
, FB_ALLONES
, pixel
))
979 int nbox
= REGION_NUM_RECTS (pRegion
);
980 BoxPtr pBox
= REGION_RECTS (pRegion
);
984 (*pKaaScr
->info
->Solid
) (pBox
->x1
+ xoff
, pBox
->y1
+ yoff
,
985 pBox
->x2
+ xoff
, pBox
->y2
+ yoff
);
988 (*pKaaScr
->info
->DoneSolid
) ();
989 kaaMarkSync (pDrawable
->pScreen
);
993 kaaWaitSync (pDrawable
->pScreen
);
994 fbFillRegionSolid (pDrawable
, pRegion
, 0,
995 fbReplicatePixel (pixel
, pDrawable
->bitsPerPixel
));
997 kaaDrawableDirty (pDrawable
);
1002 kaaFillRegionTiled (DrawablePtr pDrawable
,
1013 kaaPaintWindow(WindowPtr pWin
, RegionPtr pRegion
, int what
)
1016 if (!REGION_NUM_RECTS(pRegion
))
1020 switch (pWin
->backgroundState
) {
1023 case ParentRelative
:
1025 pWin
= pWin
->parent
;
1026 } while (pWin
->backgroundState
== ParentRelative
);
1027 (*pWin
->drawable
.pScreen
->PaintWindowBackground
)(pWin
, pRegion
,
1030 case BackgroundPixel
:
1031 kaaFillRegionSolid((DrawablePtr
)pWin
, pRegion
, pWin
->background
.pixel
);
1034 case BackgroundPixmap
:
1035 kaaFillRegionTiled((DrawablePtr
)pWin
, pRegion
, pWin
->background
.pixmap
);
1041 if (pWin
->borderIsPixel
)
1043 kaaFillRegionSolid((DrawablePtr
)pWin
, pRegion
, pWin
->border
.pixel
);
1049 kaaFillRegionTiled((DrawablePtr
)pWin
, pRegion
, pWin
->border
.pixmap
);
1055 KdCheckPaintWindow (pWin
, pRegion
, what
);
1059 kaaDrawInit (ScreenPtr pScreen
,
1060 KaaScreenInfoPtr pScreenInfo
)
1062 KaaScreenPrivPtr pKaaScr
;
1063 KdScreenPriv(pScreen
);
1064 KdScreenInfo
*screen
= pScreenPriv
->screen
;
1066 PictureScreenPtr ps
= GetPictureScreenIfSet(pScreen
);
1069 if (kaaGeneration
!= serverGeneration
)
1071 kaaScreenPrivateIndex
= AllocateScreenPrivateIndex();
1072 kaaPixmapPrivateIndex
= AllocatePixmapPrivateIndex();
1073 kaaGeneration
= serverGeneration
;
1076 pKaaScr
= xalloc (sizeof (KaaScreenPrivRec
));
1081 pKaaScr
->info
= pScreenInfo
;
1083 pScreen
->devPrivates
[kaaScreenPrivateIndex
].ptr
= (pointer
) pKaaScr
;
1086 * Hook up asynchronous drawing
1088 KdScreenInitAsync (pScreen
);
1090 * Replace various fb screen functions
1092 pScreen
->CreateGC
= kaaCreateGC
;
1093 pScreen
->CopyWindow
= kaaCopyWindow
;
1094 pScreen
->PaintWindowBackground
= kaaPaintWindow
;
1095 pScreen
->PaintWindowBorder
= kaaPaintWindow
;
1098 ps
->Composite
= kaaComposite
;
1099 ps
->RasterizeTrapezoid
= kaaRasterizeTrapezoid
;
1104 * Hookup offscreen pixmaps
1106 if ((pKaaScr
->info
->flags
& KAA_OFFSCREEN_PIXMAPS
) &&
1107 screen
->off_screen_base
< screen
->memory_size
)
1109 if (!AllocatePixmapPrivate(pScreen
, kaaPixmapPrivateIndex
,
1110 sizeof (KaaPixmapPrivRec
)))
1112 pScreen
->CreatePixmap
= kaaCreatePixmap
;
1113 pScreen
->DestroyPixmap
= kaaDestroyPixmap
;
1117 if (!AllocatePixmapPrivate(pScreen
, kaaPixmapPrivateIndex
, 0))
1125 kaaDrawFini (ScreenPtr pScreen
)
1127 KaaScreenPriv(pScreen
);
1133 kaaMarkSync (ScreenPtr pScreen
)
1135 KdScreenPriv(pScreen
);
1136 KaaScreenPriv(pScreen
);
1138 pScreenPriv
->card
->needSync
= TRUE
;
1139 if (pKaaScr
->info
->markSync
!= NULL
) {
1140 pScreenPriv
->card
->lastMarker
= (*pKaaScr
->info
->markSync
) (pScreen
);
1145 kaaWaitSync (ScreenPtr pScreen
)
1147 KdScreenPriv(pScreen
);
1148 KaaScreenPriv(pScreen
);
1149 KdCardInfo
*card
= pScreenPriv
->card
;
1151 if (card
->needSync
) {
1152 (*pKaaScr
->info
->waitMarker
) (pScreen
, card
->lastMarker
);
1153 card
->needSync
= FALSE
;