2
* $RCSId: xc/programs/Xserver/hw/kdrive/kaa.c,v 1.4 2001/06/04 09:45:41 keithp Exp $
4
* Copyright � 2001 Keith Packard
6
* Partly based on code that is Copyright � The XFree86 Project Inc.
8
* Permission to use, copy, modify, distribute, and sell this software and its
9
* documentation for any purpose is hereby granted without fee, provided that
10
* the above copyright notice appear in all copies and that both that
11
* copyright notice and this permission notice appear in supporting
12
* documentation, and that the name of Keith Packard not be used in
13
* advertising or publicity pertaining to distribution of the software without
14
* specific, written prior permission. Keith Packard makes no
15
* representations about the suitability of this software for any purpose. It
16
* is provided "as is" without express or implied warranty.
18
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
20
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
21
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
22
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
23
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24
* PERFORMANCE OF THIS SOFTWARE.
28
#include <kdrive-config.h>
32
#include "dixfontstr.h"
34
#define DEBUG_MIGRATE 0
35
#define DEBUG_PIXMAP 0
37
#define DBG_MIGRATE(a) ErrorF a
39
#define DBG_MIGRATE(a)
42
#define DBG_PIXMAP(a) ErrorF a
48
int kaaScreenPrivateIndex;
49
int kaaPixmapPrivateIndex;
51
#define KAA_PIXMAP_SCORE_MOVE_IN 10
52
#define KAA_PIXMAP_SCORE_MAX 20
53
#define KAA_PIXMAP_SCORE_MOVE_OUT -10
54
#define KAA_PIXMAP_SCORE_MIN -20
55
#define KAA_PIXMAP_SCORE_PINNED 1000
56
#define KAA_PIXMAP_SCORE_INIT 1001
59
kaaDrawableDirty (DrawablePtr pDrawable)
62
KaaPixmapPrivPtr pKaaPixmap;
64
if (pDrawable->type == DRAWABLE_WINDOW)
65
pPixmap = (*pDrawable->pScreen->GetWindowPixmap)((WindowPtr) pDrawable);
67
pPixmap = (PixmapPtr)pDrawable;
69
pKaaPixmap = KaaGetPixmapPriv(pPixmap);
70
if (pKaaPixmap != NULL)
71
pKaaPixmap->dirty = TRUE;
75
kaaPixmapSave (ScreenPtr pScreen, KdOffscreenArea *area)
77
PixmapPtr pPixmap = area->privData;
78
KaaPixmapPriv(pPixmap);
79
int dst_pitch, src_pitch, bytes;
80
unsigned char *dst, *src;
83
DBG_MIGRATE (("Save 0x%08x (0x%x) (%dx%d)\n",
85
KaaGetPixmapPriv(pPixmap)->area ?
86
KaaGetPixmapPriv(pPixmap)->area->offset : -1,
87
pPixmap->drawable.width,
88
pPixmap->drawable.height));
90
src_pitch = pPixmap->devKind;
91
dst_pitch = pKaaPixmap->devKind;
93
src = pPixmap->devPrivate.ptr;
94
dst = pKaaPixmap->devPrivate.ptr;
96
pPixmap->devKind = dst_pitch;
97
pPixmap->devPrivate.ptr = dst;
98
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
99
pKaaPixmap->area = NULL;
102
if (!pKaaPixmap->dirty)
106
kaaWaitSync (pPixmap->drawable.pScreen);
108
bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;
110
i = pPixmap->drawable.height;
112
memcpy (dst, src, bytes);
125
for (bits = 0; val != 0; bits++)
131
kaaPixmapAllocArea (PixmapPtr pPixmap)
133
ScreenPtr pScreen = pPixmap->drawable.pScreen;
134
KaaScreenPriv (pScreen);
135
KaaPixmapPriv (pPixmap);
136
KdScreenPriv (pScreen);
137
int bpp = pPixmap->drawable.bitsPerPixel;
138
CARD16 h = pPixmap->drawable.height;
139
CARD16 w = pPixmap->drawable.width;
142
if (pKaaScr->info->flags & KAA_OFFSCREEN_ALIGN_POT && w != 1)
143
w = 1 << (kaaLog2(w - 1) + 1);
144
pitch = (w * bpp / 8 + pKaaScr->info->pitchAlign - 1) &
145
~(pKaaScr->info->pitchAlign - 1);
147
pKaaPixmap->devKind = pPixmap->devKind;
148
pKaaPixmap->devPrivate = pPixmap->devPrivate;
149
pKaaPixmap->area = KdOffscreenAlloc (pScreen, pitch * h,
150
pKaaScr->info->offsetAlign,
152
kaaPixmapSave, (pointer) pPixmap);
153
if (!pKaaPixmap->area)
156
DBG_PIXMAP(("++ 0x%08x (0x%x) (%dx%d)\n",
157
pPixmap->drawable.id,
158
KaaGetPixmapPriv(pPixmap)->area ?
159
KaaGetPixmapPriv(pPixmap)->area->offset : -1,
160
pPixmap->drawable.width,
161
pPixmap->drawable.height));
162
pPixmap->devKind = pitch;
163
pPixmap->devPrivate.ptr = (pointer) ((CARD8 *) pScreenPriv->screen->memory_base + pKaaPixmap->area->offset);
164
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
169
kaaMoveInPixmap (PixmapPtr pPixmap)
171
ScreenPtr pScreen = pPixmap->drawable.pScreen;
172
KaaScreenPriv (pScreen);
173
KaaPixmapPriv (pPixmap);
174
int dst_pitch, src_pitch, bytes;
175
unsigned char *dst, *src;
178
DBG_MIGRATE (("-> 0x%08x (0x%x) (%dx%d)\n",
179
pPixmap->drawable.id,
180
KaaGetPixmapPriv(pPixmap)->area ?
181
KaaGetPixmapPriv(pPixmap)->area->offset : -1,
182
pPixmap->drawable.width,
183
pPixmap->drawable.height));
185
src = pPixmap->devPrivate.ptr;
186
src_pitch = pPixmap->devKind;
188
if (!kaaPixmapAllocArea (pPixmap))
191
pKaaPixmap->dirty = FALSE;
193
if (pKaaScr->info->UploadToScreen)
195
if (pKaaScr->info->UploadToScreen(pPixmap, (char *) src, src_pitch))
199
dst = pPixmap->devPrivate.ptr;
200
dst_pitch = pPixmap->devKind;
202
bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;
204
kaaWaitSync (pPixmap->drawable.pScreen);
206
i = pPixmap->drawable.height;
208
memcpy (dst, src, bytes);
215
kaaMoveOutPixmap (PixmapPtr pPixmap)
217
KaaPixmapPriv (pPixmap);
218
KdOffscreenArea *area = pKaaPixmap->area;
220
DBG_MIGRATE (("<- 0x%08x (0x%x) (%dx%d)\n",
221
pPixmap->drawable.id,
222
KaaGetPixmapPriv(pPixmap)->area ?
223
KaaGetPixmapPriv(pPixmap)->area->offset : -1,
224
pPixmap->drawable.width,
225
pPixmap->drawable.height));
228
kaaPixmapSave (pPixmap->drawable.pScreen, area);
229
KdOffscreenFree (pPixmap->drawable.pScreen, area);
234
kaaPixmapUseScreen (PixmapPtr pPixmap)
236
KaaPixmapPriv (pPixmap);
238
if (pKaaPixmap->score == KAA_PIXMAP_SCORE_PINNED)
241
if (pKaaPixmap->score == KAA_PIXMAP_SCORE_INIT) {
242
kaaMoveInPixmap(pPixmap);
243
pKaaPixmap->score = 0;
246
if (pKaaPixmap->score < KAA_PIXMAP_SCORE_MAX)
249
if (!kaaPixmapIsOffscreen(pPixmap) &&
250
pKaaPixmap->score >= KAA_PIXMAP_SCORE_MOVE_IN)
251
kaaMoveInPixmap (pPixmap);
253
KdOffscreenMarkUsed (pPixmap);
257
kaaPixmapUseMemory (PixmapPtr pPixmap)
259
KaaPixmapPriv (pPixmap);
261
if (pKaaPixmap->score == KAA_PIXMAP_SCORE_PINNED)
264
if (pKaaPixmap->score == KAA_PIXMAP_SCORE_INIT)
265
pKaaPixmap->score = 0;
267
if (pKaaPixmap->score > KAA_PIXMAP_SCORE_MIN)
270
if (pKaaPixmap->area &&
271
pKaaPixmap->score <= KAA_PIXMAP_SCORE_MOVE_OUT)
272
kaaMoveOutPixmap (pPixmap);
277
kaaDestroyPixmap (PixmapPtr pPixmap)
279
if (pPixmap->refcnt == 1)
281
KaaPixmapPriv (pPixmap);
282
if (pKaaPixmap->area)
284
DBG_PIXMAP(("-- 0x%08x (0x%x) (%dx%d)\n",
285
pPixmap->drawable.id,
286
KaaGetPixmapPriv(pPixmap)->area->offset,
287
pPixmap->drawable.width,
288
pPixmap->drawable.height));
289
/* Free the offscreen area */
290
KdOffscreenFree (pPixmap->drawable.pScreen, pKaaPixmap->area);
291
pPixmap->devPrivate = pKaaPixmap->devPrivate;
292
pPixmap->devKind = pKaaPixmap->devKind;
295
return fbDestroyPixmap (pPixmap);
299
kaaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth)
302
KaaPixmapPrivPtr pKaaPixmap;
305
bpp = BitsPerPixel (depth);
306
if (bpp == 32 && depth == 24)
309
KdScreenPriv (pScreen);
311
for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++)
312
if (pScreenPriv->screen->fb[fb].depth == 24)
314
bpp = pScreenPriv->screen->fb[fb].bitsPerPixel;
319
pPixmap = fbCreatePixmapBpp (pScreen, w, h, depth, bpp);
322
pKaaPixmap = KaaGetPixmapPriv(pPixmap);
324
pKaaPixmap->score = KAA_PIXMAP_SCORE_PINNED;
326
pKaaPixmap->score = KAA_PIXMAP_SCORE_INIT;
328
pKaaPixmap->area = NULL;
329
pKaaPixmap->dirty = FALSE;
335
kaaPixmapIsOffscreen(PixmapPtr p)
337
ScreenPtr pScreen = p->drawable.pScreen;
338
KdScreenPriv(pScreen);
340
return ((unsigned long) ((CARD8 *) p->devPrivate.ptr -
341
(CARD8 *) pScreenPriv->screen->memory_base) <
342
pScreenPriv->screen->memory_size);
346
kaaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp)
351
if (pDrawable->type == DRAWABLE_WINDOW) {
352
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
354
x = -pPixmap->screen_x;
355
y = -pPixmap->screen_y;
363
pPixmap = (PixmapPtr) pDrawable;
369
if (kaaPixmapIsOffscreen (pPixmap))
376
kaaDrawableIsOffscreen (DrawablePtr pDrawable)
379
if (pDrawable->type == DRAWABLE_WINDOW)
380
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
382
pPixmap = (PixmapPtr) pDrawable;
383
return kaaPixmapIsOffscreen (pPixmap);
388
kaaFillTiled(int dst_x,
396
void (*Copy) (int srcX,
403
modulus (src_x, src_width, src_x);
404
modulus (src_y, src_height, src_y);
408
int dst_x_tmp = dst_x;
409
int src_x_tmp = src_x;
410
int width_tmp = width;
411
int height_left = src_height - src_y;
412
int height_this = min (height, height_left);
416
int width_left = src_width - src_x_tmp;
417
int width_this = min (width_tmp, width_left);
419
(*Copy) (src_x_tmp, src_y,
421
width_this, height_this);
423
width_tmp -= width_this;
424
dst_x_tmp += width_this;
426
height -= height_this;
427
dst_y += height_this;
434
kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
435
DDXPointPtr ppt, int *pwidth, int fSorted)
437
ScreenPtr pScreen = pDrawable->pScreen;
438
KdScreenPriv (pScreen);
439
KaaScreenPriv (pScreen);
440
RegionPtr pClip = fbGetCompositeClip(pGC);
442
BoxPtr pextent, pbox;
444
int extentX1, extentX2, extentY1, extentY2;
445
int fullX1, fullX2, fullY1;
449
if (!pScreenPriv->enabled ||
450
pGC->fillStyle != FillSolid ||
451
!(pPixmap = kaaGetOffscreenPixmap (pDrawable, &off_x, &off_y)) ||
452
!(*pKaaScr->info->PrepareSolid) (pPixmap,
457
KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
461
pextent = REGION_EXTENTS(pGC->pScreen, pClip);
462
extentX1 = pextent->x1;
463
extentY1 = pextent->y1;
464
extentX2 = pextent->x2;
465
extentY2 = pextent->y2;
470
fullX2 = fullX1 + (int) *pwidth;
474
if (fullY1 < extentY1 || extentY2 <= fullY1)
477
if (fullX1 < extentX1)
480
if (fullX2 > extentX2)
483
if (fullX1 >= fullX2)
486
nbox = REGION_NUM_RECTS (pClip);
489
(*pKaaScr->info->Solid) (fullX1 + off_x, fullY1 + off_y,
490
fullX2 + off_x, fullY1 + 1 + off_y);
494
pbox = REGION_RECTS(pClip);
497
if (pbox->y1 <= fullY1 && fullY1 < pbox->y2)
506
(*pKaaScr->info->Solid) (partX1 + off_x, fullY1 + off_y,
507
partX2 + off_x, fullY1 + 1 + off_y);
513
(*pKaaScr->info->DoneSolid) ();
514
kaaDrawableDirty (pDrawable);
515
kaaMarkSync (pDrawable->pScreen);
519
kaaCopyNtoN (DrawablePtr pSrcDrawable,
520
DrawablePtr pDstDrawable,
531
KdScreenPriv (pDstDrawable->pScreen);
532
KaaScreenPriv (pDstDrawable->pScreen);
533
PixmapPtr pSrcPixmap, pDstPixmap;
534
int src_off_x, src_off_y;
535
int dst_off_x, dst_off_y;
537
/* Migrate pixmaps to same place as destination */
538
if (pScreenPriv->enabled && pSrcDrawable->type == DRAWABLE_PIXMAP) {
539
if (kaaDrawableIsOffscreen (pDstDrawable))
540
kaaPixmapUseScreen ((PixmapPtr) pSrcDrawable);
542
kaaPixmapUseMemory ((PixmapPtr) pSrcDrawable);
545
if (pScreenPriv->enabled &&
546
(pSrcPixmap = kaaGetOffscreenPixmap (pSrcDrawable, &src_off_x, &src_off_y)) &&
547
(pDstPixmap = kaaGetOffscreenPixmap (pDstDrawable, &dst_off_x, &dst_off_y)) &&
548
(*pKaaScr->info->PrepareCopy) (pSrcPixmap,
552
pGC ? pGC->alu : GXcopy,
553
pGC ? pGC->planemask : FB_ALLONES))
557
(*pKaaScr->info->Copy) (pbox->x1 + dx + src_off_x,
558
pbox->y1 + dy + src_off_y,
559
pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,
561
pbox->y2 - pbox->y1);
564
(*pKaaScr->info->DoneCopy) ();
565
kaaMarkSync (pDstDrawable->pScreen);
569
kaaWaitSync (pDstDrawable->pScreen);
570
fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC,
571
pbox, nbox, dx, dy, reverse, upsidedown,
574
kaaDrawableDirty (pDstDrawable);
578
kaaCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
579
int srcx, int srcy, int width, int height, int dstx, int dsty)
581
return fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
582
srcx, srcy, width, height,
583
dstx, dsty, kaaCopyNtoN, 0, 0);
587
kaaPolyFillRect(DrawablePtr pDrawable,
592
KdScreenPriv (pDrawable->pScreen);
593
KaaScreenPriv (pDrawable->pScreen);
594
RegionPtr pClip = fbGetCompositeClip(pGC);
596
register BoxPtr pbox;
598
int extentX1, extentX2, extentY1, extentY2;
599
int fullX1, fullX2, fullY1, fullY2;
600
int partX1, partX2, partY1, partY2;
605
if (!pScreenPriv->enabled ||
606
pGC->fillStyle != FillSolid ||
607
!(pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) ||
608
!(*pKaaScr->info->PrepareSolid) (pPixmap,
613
KdCheckPolyFillRect (pDrawable, pGC, nrect, prect);
620
pextent = REGION_EXTENTS(pGC->pScreen, pClip);
621
extentX1 = pextent->x1;
622
extentY1 = pextent->y1;
623
extentX2 = pextent->x2;
624
extentY2 = pextent->y2;
627
fullX1 = prect->x + xorg;
628
fullY1 = prect->y + yorg;
629
fullX2 = fullX1 + (int) prect->width;
630
fullY2 = fullY1 + (int) prect->height;
633
if (fullX1 < extentX1)
636
if (fullY1 < extentY1)
639
if (fullX2 > extentX2)
642
if (fullY2 > extentY2)
645
if ((fullX1 >= fullX2) || (fullY1 >= fullY2))
647
n = REGION_NUM_RECTS (pClip);
650
(*pKaaScr->info->Solid) (fullX1 + xoff, fullY1 + yoff,
651
fullX2 + xoff, fullY2 + yoff);
655
pbox = REGION_RECTS(pClip);
657
* clip the rectangle to each box in the clip region
658
* this is logically equivalent to calling Intersect()
677
if (partX1 < partX2 && partY1 < partY2)
678
(*pKaaScr->info->Solid) (partX1 + xoff, partY1 + yoff,
679
partX2 + xoff, partY2 + yoff);
683
(*pKaaScr->info->DoneSolid) ();
684
kaaDrawableDirty (pDrawable);
685
kaaMarkSync (pDrawable->pScreen);
689
kaaSolidBoxClipped (DrawablePtr pDrawable,
698
KdScreenPriv (pDrawable->pScreen);
699
KaaScreenPriv (pDrawable->pScreen);
704
int partX1, partX2, partY1, partY2;
706
if (!pScreenPriv->enabled ||
707
!(pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) ||
708
!(*pKaaScr->info->PrepareSolid) (pPixmap, GXcopy, pm, fg))
710
kaaWaitSync (pDrawable->pScreen);
711
fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel);
712
fbSolidBoxClipped (pDrawable, pClip, x1, y1, x2, y2,
713
fbAnd (GXcopy, fg, pm),
714
fbXor (GXcopy, fg, pm));
715
kaaDrawableDirty (pDrawable);
718
for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip);
730
if (partX2 <= partX1)
741
if (partY2 <= partY1)
744
(*pKaaScr->info->Solid) (partX1 + xoff, partY1 + yoff,
745
partX2 + xoff, partY2 + yoff);
747
(*pKaaScr->info->DoneSolid) ();
748
kaaDrawableDirty (pDrawable);
749
kaaMarkSync (pDrawable->pScreen);
753
kaaImageGlyphBlt (DrawablePtr pDrawable,
758
CharInfoPtr *ppciInit,
761
FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
764
unsigned char *pglyph; /* pointer bits in glyph */
765
int gWidth, gHeight; /* width and height of glyph */
766
FbStride gStride; /* stride of glyph */
770
void (*glyph) (FbBits *,
780
int dstXoff, dstYoff;
783
depthMask = FbFullMask(pDrawable->depth);
784
if ((pGC->planemask & depthMask) != depthMask)
786
KdCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase);
790
fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
792
case 8: glyph = fbGlyph8; break;
793
case 16: glyph = fbGlyph16; break;
794
case 24: glyph = fbGlyph24; break;
795
case 32: glyph = fbGlyph32; break;
801
if (TERMINALFONT (pGC->font) && !glyph)
807
int xBack, widthBack;
808
int yBack, heightBack;
814
widthBack += (*ppci++)->metrics.characterWidth;
820
widthBack = -widthBack;
822
yBack = y - FONTASCENT(pGC->font);
823
heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
824
kaaSolidBoxClipped (pDrawable,
825
fbGetCompositeClip(pGC),
835
kaaWaitSync (pDrawable->pScreen);
836
kaaDrawableDirty (pDrawable);
842
pglyph = FONTGLYPHBITS(pglyphBase, pci);
843
gWidth = GLYPHWIDTHPIXELS(pci);
844
gHeight = GLYPHHEIGHTPIXELS(pci);
845
if (gWidth && gHeight)
847
gx = x + pci->metrics.leftSideBearing;
848
gy = y - pci->metrics.ascent;
849
if (glyph && gWidth <= sizeof (FbStip) * 8 &&
850
fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
852
(*glyph) (dst + (gy + dstYoff) * dstStride,
862
gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
863
fbPutXYImage (pDrawable,
864
fbGetCompositeClip(pGC),
880
x += pci->metrics.characterWidth;
884
static const GCOps kaaOps = {
905
#ifdef NEED_LINEHELPER
911
kaaValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
913
fbValidateGC (pGC, changes, pDrawable);
915
if (kaaDrawableIsOffscreen (pDrawable))
916
pGC->ops = (GCOps *) &kaaOps;
918
pGC->ops = (GCOps *) &kdAsyncPixmapGCOps;
921
GCFuncs kaaGCFuncs = {
932
kaaCreateGC (GCPtr pGC)
934
if (!fbCreateGC (pGC))
937
pGC->funcs = &kaaGCFuncs;
944
kaaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
948
PixmapPtr pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
950
dx = ptOldOrg.x - pWin->drawable.x;
951
dy = ptOldOrg.y - pWin->drawable.y;
952
REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
954
REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
956
REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
958
if (pPixmap->screen_x || pPixmap->screen_y)
959
REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
960
-pPixmap->screen_x, -pPixmap->screen_y);
963
fbCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
965
&rgnDst, dx, dy, kaaCopyNtoN, 0, 0);
967
REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
971
kaaFillRegionSolid (DrawablePtr pDrawable,
975
KdScreenPriv(pDrawable->pScreen);
976
KaaScreenPriv(pDrawable->pScreen);
980
if (pScreenPriv->enabled &&
981
(pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) &&
982
(*pKaaScr->info->PrepareSolid) (pPixmap, GXcopy, FB_ALLONES, pixel))
984
int nbox = REGION_NUM_RECTS (pRegion);
985
BoxPtr pBox = REGION_RECTS (pRegion);
989
(*pKaaScr->info->Solid) (pBox->x1 + xoff, pBox->y1 + yoff,
990
pBox->x2 + xoff, pBox->y2 + yoff);
993
(*pKaaScr->info->DoneSolid) ();
994
kaaMarkSync (pDrawable->pScreen);
998
kaaWaitSync (pDrawable->pScreen);
999
fbFillRegionSolid (pDrawable, pRegion, 0,
1000
fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
1002
kaaDrawableDirty (pDrawable);
1007
kaaFillRegionTiled (DrawablePtr pDrawable,
1018
kaaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
1021
if (!REGION_NUM_RECTS(pRegion))
1025
switch (pWin->backgroundState) {
1028
case ParentRelative:
1030
pWin = pWin->parent;
1031
} while (pWin->backgroundState == ParentRelative);
1032
(*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
1035
case BackgroundPixel:
1036
kaaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel);
1039
case BackgroundPixmap:
1040
kaaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->background.pixmap);
1046
if (pWin->borderIsPixel)
1048
kaaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel);
1054
kaaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->border.pixmap);
1060
KdCheckPaintWindow (pWin, pRegion, what);
1064
kaaDrawInit (ScreenPtr pScreen,
1065
KaaScreenInfoPtr pScreenInfo)
1067
KaaScreenPrivPtr pKaaScr;
1068
KdScreenPriv(pScreen);
1069
KdScreenInfo *screen = pScreenPriv->screen;
1071
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
1074
if (kaaGeneration != serverGeneration)
1076
kaaScreenPrivateIndex = AllocateScreenPrivateIndex();
1077
kaaPixmapPrivateIndex = AllocatePixmapPrivateIndex();
1078
kaaGeneration = serverGeneration;
1081
pKaaScr = xalloc (sizeof (KaaScreenPrivRec));
1086
pKaaScr->info = pScreenInfo;
1088
pScreen->devPrivates[kaaScreenPrivateIndex].ptr = (pointer) pKaaScr;
1091
* Hook up asynchronous drawing
1093
KdScreenInitAsync (pScreen);
1095
* Replace various fb screen functions
1097
pScreen->CreateGC = kaaCreateGC;
1098
pScreen->CopyWindow = kaaCopyWindow;
1099
pScreen->PaintWindowBackground = kaaPaintWindow;
1100
pScreen->PaintWindowBorder = kaaPaintWindow;
1103
ps->Composite = kaaComposite;
1104
ps->RasterizeTrapezoid = kaaRasterizeTrapezoid;
1109
* Hookup offscreen pixmaps
1111
if ((pKaaScr->info->flags & KAA_OFFSCREEN_PIXMAPS) &&
1112
screen->off_screen_base < screen->memory_size)
1114
if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex,
1115
sizeof (KaaPixmapPrivRec)))
1117
pScreen->CreatePixmap = kaaCreatePixmap;
1118
pScreen->DestroyPixmap = kaaDestroyPixmap;
1122
if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex, 0))
1130
kaaDrawFini (ScreenPtr pScreen)
1132
KaaScreenPriv(pScreen);
1138
kaaMarkSync (ScreenPtr pScreen)
1140
KdScreenPriv(pScreen);
1141
KaaScreenPriv(pScreen);
1143
pScreenPriv->card->needSync = TRUE;
1144
if (pKaaScr->info->markSync != NULL) {
1145
pScreenPriv->card->lastMarker = (*pKaaScr->info->markSync) (pScreen);
1150
kaaWaitSync (ScreenPtr pScreen)
1152
KdScreenPriv(pScreen);
1153
KaaScreenPriv(pScreen);
1154
KdCardInfo *card = pScreenPriv->card;
1156
if (card->needSync) {
1157
(*pKaaScr->info->waitMarker) (pScreen, card->lastMarker);
1158
card->needSync = FALSE;