~ubuntu-branches/ubuntu/edgy/xorg-server/edgy-updates

« back to all changes in this revision

Viewing changes to hw/kdrive/src/kaa.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Parra Novo
  • Date: 2006-07-25 20:06:28 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060725200628-gjmmd9gxfxdc4ejs
Tags: 1:1.1.1-0ubuntu1
* New Upstream version
* Changed Build-Depends from mesa-swrast-source to mesa-swx11-source,
  following Debian package nomenclature
* Re-did 12_security_policy_in_etc.diff for 1.1.1
* Dropped 15_security_allocate_local.diff (applied upstream)
* Dropped 16_SECURITY_setuid.diff (applied upstream)
* Dropped 000_ubuntu_fix_read_kernel_mapping.patch (applied upstream)
* Dropped 002_ubuntu_fix_for_certain_intel_chipsets.patch (applied upstream)
* Updated versioned Build-Depends on mesa-swx11-source to version
  6.5.0.cvs.20060725-0ubuntu1
* Added arrayobj.c, arrayobj.h, bitset.h & rbadaptors.h to
  GL/symlink-mesa.sh (linked from mesa-swx11-source)
* Added arrayobj.c to default build target on GL/mesa/main

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $RCSId: xc/programs/Xserver/hw/kdrive/kaa.c,v 1.4 2001/06/04 09:45:41 keithp Exp $
 
3
 *
 
4
 * Copyright � 2001 Keith Packard
 
5
 *
 
6
 * Partly based on code that is Copyright � The XFree86 Project Inc.
 
7
 *
 
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.
 
17
 *
 
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.
 
25
 */
 
26
 
 
27
#ifdef HAVE_CONFIG_H
 
28
#include <kdrive-config.h>
 
29
#endif
 
30
#include "kdrive.h"
 
31
#include "kaa.h"
 
32
#include "dixfontstr.h"
 
33
 
 
34
#define DEBUG_MIGRATE 0
 
35
#define DEBUG_PIXMAP 0
 
36
#if DEBUG_MIGRATE
 
37
#define DBG_MIGRATE(a) ErrorF a
 
38
#else
 
39
#define DBG_MIGRATE(a)
 
40
#endif
 
41
#if DEBUG_PIXMAP
 
42
#define DBG_PIXMAP(a) ErrorF a
 
43
#else
 
44
#define DBG_PIXMAP(a)
 
45
#endif
 
46
 
 
47
int kaaGeneration;
 
48
int kaaScreenPrivateIndex;
 
49
int kaaPixmapPrivateIndex;
 
50
 
 
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
 
57
 
 
58
void
 
59
kaaDrawableDirty (DrawablePtr pDrawable)
 
60
{
 
61
    PixmapPtr pPixmap;
 
62
    KaaPixmapPrivPtr pKaaPixmap;
 
63
 
 
64
    if (pDrawable->type == DRAWABLE_WINDOW)
 
65
        pPixmap = (*pDrawable->pScreen->GetWindowPixmap)((WindowPtr) pDrawable);
 
66
    else
 
67
        pPixmap = (PixmapPtr)pDrawable;
 
68
 
 
69
    pKaaPixmap = KaaGetPixmapPriv(pPixmap);
 
70
    if (pKaaPixmap != NULL)
 
71
        pKaaPixmap->dirty = TRUE;
 
72
}
 
73
 
 
74
static void
 
75
kaaPixmapSave (ScreenPtr pScreen, KdOffscreenArea *area)
 
76
{
 
77
    PixmapPtr pPixmap = area->privData;
 
78
    KaaPixmapPriv(pPixmap);
 
79
    int dst_pitch, src_pitch, bytes;
 
80
    unsigned char *dst, *src;
 
81
    int i; 
 
82
    
 
83
    DBG_MIGRATE (("Save 0x%08x (0x%x) (%dx%d)\n",
 
84
                  pPixmap->drawable.id,
 
85
                  KaaGetPixmapPriv(pPixmap)->area ? 
 
86
                  KaaGetPixmapPriv(pPixmap)->area->offset : -1,
 
87
                  pPixmap->drawable.width,
 
88
                  pPixmap->drawable.height));
 
89
                  
 
90
    src_pitch = pPixmap->devKind;
 
91
    dst_pitch = pKaaPixmap->devKind;
 
92
 
 
93
    src = pPixmap->devPrivate.ptr;
 
94
    dst = pKaaPixmap->devPrivate.ptr;
 
95
    
 
96
    pPixmap->devKind = dst_pitch;
 
97
    pPixmap->devPrivate.ptr = dst;
 
98
    pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 
99
    pKaaPixmap->area = NULL;
 
100
 
 
101
#if 0
 
102
    if (!pKaaPixmap->dirty)
 
103
        return;
 
104
#endif
 
105
 
 
106
    kaaWaitSync (pPixmap->drawable.pScreen);
 
107
 
 
108
    bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;
 
109
 
 
110
    i = pPixmap->drawable.height;
 
111
    while (i--) {
 
112
        memcpy (dst, src, bytes);
 
113
        dst += dst_pitch;
 
114
        src += src_pitch;
 
115
    }
 
116
}
 
117
 
 
118
static int
 
119
kaaLog2(int val)
 
120
{
 
121
    int bits;
 
122
 
 
123
    if (!val)
 
124
        return 0;
 
125
    for (bits = 0; val != 0; bits++)
 
126
        val >>= 1;
 
127
    return bits - 1;
 
128
}
 
129
 
 
130
static Bool
 
131
kaaPixmapAllocArea (PixmapPtr pPixmap)
 
132
{
 
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;
 
140
    int         pitch;
 
141
 
 
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);
 
146
    
 
147
    pKaaPixmap->devKind = pPixmap->devKind;
 
148
    pKaaPixmap->devPrivate = pPixmap->devPrivate;
 
149
    pKaaPixmap->area = KdOffscreenAlloc (pScreen, pitch * h,
 
150
                                         pKaaScr->info->offsetAlign,
 
151
                                         FALSE, 
 
152
                                         kaaPixmapSave, (pointer) pPixmap);
 
153
    if (!pKaaPixmap->area)
 
154
        return FALSE;
 
155
    
 
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;
 
165
    return TRUE;
 
166
}
 
167
 
 
168
void
 
169
kaaMoveInPixmap (PixmapPtr pPixmap)
 
170
{
 
171
    ScreenPtr   pScreen = pPixmap->drawable.pScreen;
 
172
    KaaScreenPriv (pScreen);
 
173
    KaaPixmapPriv (pPixmap);
 
174
    int dst_pitch, src_pitch, bytes;
 
175
    unsigned char *dst, *src;
 
176
    int i;
 
177
 
 
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));
 
184
 
 
185
    src = pPixmap->devPrivate.ptr;
 
186
    src_pitch = pPixmap->devKind;
 
187
    
 
188
    if (!kaaPixmapAllocArea (pPixmap))
 
189
        return;
 
190
 
 
191
    pKaaPixmap->dirty = FALSE;
 
192
 
 
193
    if (pKaaScr->info->UploadToScreen)
 
194
    {
 
195
        if (pKaaScr->info->UploadToScreen(pPixmap, (char *) src, src_pitch))
 
196
            return;
 
197
    }
 
198
 
 
199
    dst = pPixmap->devPrivate.ptr;
 
200
    dst_pitch = pPixmap->devKind;
 
201
    
 
202
    bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;
 
203
 
 
204
    kaaWaitSync (pPixmap->drawable.pScreen);
 
205
 
 
206
    i = pPixmap->drawable.height;
 
207
    while (i--) {
 
208
        memcpy (dst, src, bytes);
 
209
        dst += dst_pitch;
 
210
        src += src_pitch;
 
211
    }
 
212
}
 
213
 
 
214
static void
 
215
kaaMoveOutPixmap (PixmapPtr pPixmap)
 
216
{
 
217
    KaaPixmapPriv (pPixmap);
 
218
    KdOffscreenArea *area = pKaaPixmap->area;
 
219
 
 
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));
 
226
    if (area)
 
227
    {
 
228
        kaaPixmapSave (pPixmap->drawable.pScreen, area);
 
229
        KdOffscreenFree (pPixmap->drawable.pScreen, area);
 
230
    }
 
231
}
 
232
 
 
233
void
 
234
kaaPixmapUseScreen (PixmapPtr pPixmap)
 
235
{
 
236
    KaaPixmapPriv (pPixmap);
 
237
 
 
238
    if (pKaaPixmap->score == KAA_PIXMAP_SCORE_PINNED)
 
239
        return;
 
240
 
 
241
    if (pKaaPixmap->score == KAA_PIXMAP_SCORE_INIT) {
 
242
        kaaMoveInPixmap(pPixmap);
 
243
        pKaaPixmap->score = 0;
 
244
    }
 
245
 
 
246
    if (pKaaPixmap->score < KAA_PIXMAP_SCORE_MAX)
 
247
    {
 
248
        pKaaPixmap->score++;
 
249
        if (!kaaPixmapIsOffscreen(pPixmap) &&
 
250
            pKaaPixmap->score >= KAA_PIXMAP_SCORE_MOVE_IN)
 
251
            kaaMoveInPixmap (pPixmap);
 
252
    }
 
253
    KdOffscreenMarkUsed (pPixmap);
 
254
}
 
255
 
 
256
void
 
257
kaaPixmapUseMemory (PixmapPtr pPixmap)
 
258
{
 
259
    KaaPixmapPriv (pPixmap);
 
260
 
 
261
    if (pKaaPixmap->score == KAA_PIXMAP_SCORE_PINNED)
 
262
        return;
 
263
 
 
264
    if (pKaaPixmap->score == KAA_PIXMAP_SCORE_INIT)
 
265
        pKaaPixmap->score = 0;
 
266
 
 
267
    if (pKaaPixmap->score > KAA_PIXMAP_SCORE_MIN)
 
268
    {
 
269
        pKaaPixmap->score--;
 
270
        if (pKaaPixmap->area &&
 
271
            pKaaPixmap->score <= KAA_PIXMAP_SCORE_MOVE_OUT)
 
272
            kaaMoveOutPixmap (pPixmap);
 
273
    }
 
274
}
 
275
 
 
276
static Bool
 
277
kaaDestroyPixmap (PixmapPtr pPixmap)
 
278
{
 
279
    if (pPixmap->refcnt == 1)
 
280
    {
 
281
        KaaPixmapPriv (pPixmap);
 
282
        if (pKaaPixmap->area)
 
283
        {
 
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;
 
293
        }
 
294
    }
 
295
    return fbDestroyPixmap (pPixmap);
 
296
}
 
297
 
 
298
static PixmapPtr 
 
299
kaaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth)
 
300
{
 
301
    PixmapPtr           pPixmap;
 
302
    KaaPixmapPrivPtr    pKaaPixmap;
 
303
    int                 bpp;
 
304
    
 
305
    bpp = BitsPerPixel (depth);
 
306
    if (bpp == 32 && depth == 24)
 
307
    {
 
308
        int fb;
 
309
        KdScreenPriv (pScreen);
 
310
        
 
311
        for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++)
 
312
            if (pScreenPriv->screen->fb[fb].depth == 24)
 
313
            {
 
314
                bpp = pScreenPriv->screen->fb[fb].bitsPerPixel;
 
315
                break;
 
316
            }
 
317
    }
 
318
 
 
319
    pPixmap = fbCreatePixmapBpp (pScreen, w, h, depth, bpp);
 
320
    if (!pPixmap)
 
321
        return NULL;
 
322
    pKaaPixmap = KaaGetPixmapPriv(pPixmap);
 
323
    if (!w || !h)
 
324
        pKaaPixmap->score = KAA_PIXMAP_SCORE_PINNED;
 
325
    else
 
326
        pKaaPixmap->score = KAA_PIXMAP_SCORE_INIT;
 
327
    
 
328
    pKaaPixmap->area = NULL;
 
329
    pKaaPixmap->dirty = FALSE;
 
330
 
 
331
    return pPixmap;
 
332
}
 
333
 
 
334
Bool
 
335
kaaPixmapIsOffscreen(PixmapPtr p)
 
336
{
 
337
    ScreenPtr   pScreen = p->drawable.pScreen;
 
338
    KdScreenPriv(pScreen);
 
339
 
 
340
    return ((unsigned long) ((CARD8 *) p->devPrivate.ptr - 
 
341
                             (CARD8 *) pScreenPriv->screen->memory_base) <
 
342
            pScreenPriv->screen->memory_size);
 
343
}
 
344
 
 
345
PixmapPtr
 
346
kaaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp)
 
347
{
 
348
    PixmapPtr   pPixmap;
 
349
    int         x, y;
 
350
    
 
351
    if (pDrawable->type == DRAWABLE_WINDOW) {
 
352
        pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
 
353
#ifdef COMPOSITE
 
354
        x = -pPixmap->screen_x;
 
355
        y = -pPixmap->screen_y;
 
356
#else
 
357
        x = 0;
 
358
        y = 0;
 
359
#endif
 
360
    }
 
361
    else
 
362
    {
 
363
        pPixmap = (PixmapPtr) pDrawable;
 
364
        x = 0;
 
365
        y = 0;
 
366
    }
 
367
    *xp = x;
 
368
    *yp = y;
 
369
    if (kaaPixmapIsOffscreen (pPixmap))
 
370
        return pPixmap;
 
371
    else
 
372
        return NULL;
 
373
}
 
374
 
 
375
Bool
 
376
kaaDrawableIsOffscreen (DrawablePtr pDrawable)
 
377
{
 
378
    PixmapPtr   pPixmap;
 
379
    if (pDrawable->type == DRAWABLE_WINDOW)
 
380
        pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
 
381
    else
 
382
        pPixmap = (PixmapPtr) pDrawable;
 
383
    return kaaPixmapIsOffscreen (pPixmap);
 
384
}
 
385
 
 
386
#if 0
 
387
static void
 
388
kaaFillTiled(int        dst_x,
 
389
             int        dst_y,
 
390
             int        width,
 
391
             int        height,
 
392
             int        src_x,
 
393
             int        src_y,
 
394
             int        src_width,
 
395
             int        src_height,
 
396
             void       (*Copy) (int    srcX,
 
397
                                 int    srcY,
 
398
                                 int    dstX,
 
399
                                 int    dstY,
 
400
                                 int    width,
 
401
                                 int    height))
 
402
{
 
403
    modulus (src_x, src_width, src_x);
 
404
    modulus (src_y, src_height, src_y);
 
405
    
 
406
    while (height)
 
407
    {
 
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);
 
413
        
 
414
        while (width_tmp)
 
415
        {
 
416
            int width_left = src_width - src_x_tmp;
 
417
            int width_this = min (width_tmp, width_left);
 
418
 
 
419
            (*Copy) (src_x_tmp, src_y,
 
420
                     dst_x_tmp, dst_y,
 
421
                     width_this, height_this);
 
422
 
 
423
            width_tmp -= width_this;
 
424
            dst_x_tmp += width_this;
 
425
        }
 
426
        height -= height_this;
 
427
        dst_y += height_this;
 
428
        src_y = 0;
 
429
    }
 
430
}
 
431
#endif
 
432
 
 
433
static void
 
434
kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n, 
 
435
             DDXPointPtr ppt, int *pwidth, int fSorted)
 
436
{
 
437
    ScreenPtr       pScreen = pDrawable->pScreen;
 
438
    KdScreenPriv (pScreen);
 
439
    KaaScreenPriv (pScreen);
 
440
    RegionPtr       pClip = fbGetCompositeClip(pGC);
 
441
    PixmapPtr       pPixmap;    
 
442
    BoxPtr          pextent, pbox;
 
443
    int             nbox;
 
444
    int             extentX1, extentX2, extentY1, extentY2;
 
445
    int             fullX1, fullX2, fullY1;
 
446
    int             partX1, partX2;
 
447
    int             off_x, off_y;
 
448
 
 
449
    if (!pScreenPriv->enabled ||
 
450
        pGC->fillStyle != FillSolid ||
 
451
        !(pPixmap = kaaGetOffscreenPixmap (pDrawable, &off_x, &off_y)) ||
 
452
        !(*pKaaScr->info->PrepareSolid) (pPixmap,
 
453
                                         pGC->alu,
 
454
                                         pGC->planemask,
 
455
                                         pGC->fgPixel))
 
456
    {
 
457
        KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
 
458
        return;
 
459
    }
 
460
    
 
461
    pextent = REGION_EXTENTS(pGC->pScreen, pClip);
 
462
    extentX1 = pextent->x1;
 
463
    extentY1 = pextent->y1;
 
464
    extentX2 = pextent->x2;
 
465
    extentY2 = pextent->y2;
 
466
    while (n--)
 
467
    {
 
468
        fullX1 = ppt->x;
 
469
        fullY1 = ppt->y;
 
470
        fullX2 = fullX1 + (int) *pwidth;
 
471
        ppt++;
 
472
        pwidth++;
 
473
        
 
474
        if (fullY1 < extentY1 || extentY2 <= fullY1)
 
475
            continue;
 
476
        
 
477
        if (fullX1 < extentX1)
 
478
            fullX1 = extentX1;
 
479
 
 
480
        if (fullX2 > extentX2)
 
481
            fullX2 = extentX2;
 
482
        
 
483
        if (fullX1 >= fullX2)
 
484
            continue;
 
485
        
 
486
        nbox = REGION_NUM_RECTS (pClip);
 
487
        if (nbox == 1)
 
488
        {
 
489
            (*pKaaScr->info->Solid) (fullX1 + off_x, fullY1 + off_y,
 
490
                                     fullX2 + off_x, fullY1 + 1 + off_y);
 
491
        }
 
492
        else
 
493
        {
 
494
            pbox = REGION_RECTS(pClip);
 
495
            while(nbox--)
 
496
            {
 
497
                if (pbox->y1 <= fullY1 && fullY1 < pbox->y2)
 
498
                {
 
499
                    partX1 = pbox->x1;
 
500
                    if (partX1 < fullX1)
 
501
                        partX1 = fullX1;
 
502
                    partX2 = pbox->x2;
 
503
                    if (partX2 > fullX2)
 
504
                        partX2 = fullX2;
 
505
                    if (partX2 > partX1)
 
506
                        (*pKaaScr->info->Solid) (partX1 + off_x, fullY1 + off_y,
 
507
                                                 partX2 + off_x, fullY1 + 1 + off_y);
 
508
                }
 
509
                pbox++;
 
510
            }
 
511
        }
 
512
    }
 
513
    (*pKaaScr->info->DoneSolid) ();
 
514
    kaaDrawableDirty (pDrawable);
 
515
    kaaMarkSync (pDrawable->pScreen);
 
516
}
 
517
 
 
518
void
 
519
kaaCopyNtoN (DrawablePtr    pSrcDrawable,
 
520
             DrawablePtr    pDstDrawable,
 
521
             GCPtr          pGC,
 
522
             BoxPtr         pbox,
 
523
             int            nbox,
 
524
             int            dx,
 
525
             int            dy,
 
526
             Bool           reverse,
 
527
             Bool           upsidedown,
 
528
             Pixel          bitplane,
 
529
             void           *closure)
 
530
{
 
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;
 
536
 
 
537
    /* Migrate pixmaps to same place as destination */
 
538
    if (pScreenPriv->enabled && pSrcDrawable->type == DRAWABLE_PIXMAP) {
 
539
        if (kaaDrawableIsOffscreen (pDstDrawable))
 
540
            kaaPixmapUseScreen ((PixmapPtr) pSrcDrawable);
 
541
        else
 
542
            kaaPixmapUseMemory ((PixmapPtr) pSrcDrawable);
 
543
    }
 
544
 
 
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,
 
549
                                       pDstPixmap,
 
550
                                       dx,
 
551
                                       dy,
 
552
                                       pGC ? pGC->alu : GXcopy,
 
553
                                       pGC ? pGC->planemask : FB_ALLONES))
 
554
    {
 
555
        while (nbox--)
 
556
        {
 
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,
 
560
                                    pbox->x2 - pbox->x1,
 
561
                                    pbox->y2 - pbox->y1);
 
562
            pbox++;
 
563
        }
 
564
        (*pKaaScr->info->DoneCopy) ();
 
565
        kaaMarkSync (pDstDrawable->pScreen);
 
566
    }
 
567
    else
 
568
    {
 
569
        kaaWaitSync (pDstDrawable->pScreen);
 
570
        fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC, 
 
571
                    pbox, nbox, dx, dy, reverse, upsidedown, 
 
572
                    bitplane, closure);
 
573
    }
 
574
    kaaDrawableDirty (pDstDrawable);
 
575
}
 
576
 
 
577
static RegionPtr
 
578
kaaCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
 
579
            int srcx, int srcy, int width, int height, int dstx, int dsty)
 
580
{
 
581
    return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, 
 
582
                     srcx, srcy, width, height, 
 
583
                     dstx, dsty, kaaCopyNtoN, 0, 0);
 
584
}
 
585
 
 
586
static void
 
587
kaaPolyFillRect(DrawablePtr pDrawable, 
 
588
                GCPtr       pGC, 
 
589
                int         nrect,
 
590
                xRectangle  *prect)
 
591
{
 
592
    KdScreenPriv (pDrawable->pScreen);
 
593
    KaaScreenPriv (pDrawable->pScreen);
 
594
    RegionPtr       pClip = fbGetCompositeClip(pGC);
 
595
    PixmapPtr       pPixmap;
 
596
    register BoxPtr pbox;
 
597
    BoxPtr          pextent;
 
598
    int             extentX1, extentX2, extentY1, extentY2;
 
599
    int             fullX1, fullX2, fullY1, fullY2;
 
600
    int             partX1, partX2, partY1, partY2;
 
601
    int             xoff, yoff;
 
602
    int             xorg, yorg;
 
603
    int             n;
 
604
    
 
605
    if (!pScreenPriv->enabled ||
 
606
        pGC->fillStyle != FillSolid ||
 
607
        !(pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) || 
 
608
        !(*pKaaScr->info->PrepareSolid) (pPixmap,
 
609
                                         pGC->alu,
 
610
                                         pGC->planemask,
 
611
                                         pGC->fgPixel))
 
612
    {
 
613
        KdCheckPolyFillRect (pDrawable, pGC, nrect, prect);
 
614
        return;
 
615
    }
 
616
    
 
617
    xorg = pDrawable->x;
 
618
    yorg = pDrawable->y;
 
619
    
 
620
    pextent = REGION_EXTENTS(pGC->pScreen, pClip);
 
621
    extentX1 = pextent->x1;
 
622
    extentY1 = pextent->y1;
 
623
    extentX2 = pextent->x2;
 
624
    extentY2 = pextent->y2;
 
625
    while (nrect--)
 
626
    {
 
627
        fullX1 = prect->x + xorg;
 
628
        fullY1 = prect->y + yorg;
 
629
        fullX2 = fullX1 + (int) prect->width;
 
630
        fullY2 = fullY1 + (int) prect->height;
 
631
        prect++;
 
632
        
 
633
        if (fullX1 < extentX1)
 
634
            fullX1 = extentX1;
 
635
 
 
636
        if (fullY1 < extentY1)
 
637
            fullY1 = extentY1;
 
638
 
 
639
        if (fullX2 > extentX2)
 
640
            fullX2 = extentX2;
 
641
        
 
642
        if (fullY2 > extentY2)
 
643
            fullY2 = extentY2;
 
644
 
 
645
        if ((fullX1 >= fullX2) || (fullY1 >= fullY2))
 
646
            continue;
 
647
        n = REGION_NUM_RECTS (pClip);
 
648
        if (n == 1)
 
649
        {
 
650
            (*pKaaScr->info->Solid) (fullX1 + xoff, fullY1 + yoff,
 
651
                                     fullX2 + xoff, fullY2 + yoff);
 
652
        }
 
653
        else
 
654
        {
 
655
            pbox = REGION_RECTS(pClip);
 
656
            /* 
 
657
             * clip the rectangle to each box in the clip region
 
658
             * this is logically equivalent to calling Intersect()
 
659
             */
 
660
            while(n--)
 
661
            {
 
662
                partX1 = pbox->x1;
 
663
                if (partX1 < fullX1)
 
664
                    partX1 = fullX1;
 
665
                partY1 = pbox->y1;
 
666
                if (partY1 < fullY1)
 
667
                    partY1 = fullY1;
 
668
                partX2 = pbox->x2;
 
669
                if (partX2 > fullX2)
 
670
                    partX2 = fullX2;
 
671
                partY2 = pbox->y2;
 
672
                if (partY2 > fullY2)
 
673
                    partY2 = fullY2;
 
674
    
 
675
                pbox++;
 
676
                
 
677
                if (partX1 < partX2 && partY1 < partY2)
 
678
                    (*pKaaScr->info->Solid) (partX1 + xoff, partY1 + yoff,
 
679
                                             partX2 + xoff, partY2 + yoff);
 
680
            }
 
681
        }
 
682
    }
 
683
    (*pKaaScr->info->DoneSolid) ();
 
684
    kaaDrawableDirty (pDrawable);
 
685
    kaaMarkSync (pDrawable->pScreen);
 
686
}
 
687
    
 
688
static void
 
689
kaaSolidBoxClipped (DrawablePtr pDrawable,
 
690
                    RegionPtr   pClip,
 
691
                    FbBits      pm,
 
692
                    FbBits      fg,
 
693
                    int         x1,
 
694
                    int         y1,
 
695
                    int         x2,
 
696
                    int         y2)
 
697
{
 
698
    KdScreenPriv (pDrawable->pScreen);
 
699
    KaaScreenPriv (pDrawable->pScreen);
 
700
    PixmapPtr   pPixmap;        
 
701
    BoxPtr      pbox;
 
702
    int         nbox;
 
703
    int         xoff, yoff;
 
704
    int         partX1, partX2, partY1, partY2;
 
705
 
 
706
    if (!pScreenPriv->enabled ||
 
707
        !(pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) ||
 
708
        !(*pKaaScr->info->PrepareSolid) (pPixmap, GXcopy, pm, fg))
 
709
    {
 
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);
 
716
        return;
 
717
    }
 
718
    for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip); 
 
719
         nbox--; 
 
720
         pbox++)
 
721
    {
 
722
        partX1 = pbox->x1;
 
723
        if (partX1 < x1)
 
724
            partX1 = x1;
 
725
        
 
726
        partX2 = pbox->x2;
 
727
        if (partX2 > x2)
 
728
            partX2 = x2;
 
729
        
 
730
        if (partX2 <= partX1)
 
731
            continue;
 
732
        
 
733
        partY1 = pbox->y1;
 
734
        if (partY1 < y1)
 
735
            partY1 = y1;
 
736
        
 
737
        partY2 = pbox->y2;
 
738
        if (partY2 > y2)
 
739
            partY2 = y2;
 
740
        
 
741
        if (partY2 <= partY1)
 
742
            continue;
 
743
        
 
744
        (*pKaaScr->info->Solid) (partX1 + xoff, partY1 + yoff,
 
745
                                 partX2 + xoff, partY2 + yoff);
 
746
    }
 
747
    (*pKaaScr->info->DoneSolid) ();
 
748
    kaaDrawableDirty (pDrawable);
 
749
    kaaMarkSync (pDrawable->pScreen);
 
750
}
 
751
 
 
752
static void
 
753
kaaImageGlyphBlt (DrawablePtr   pDrawable,
 
754
                  GCPtr         pGC,
 
755
                  int           x, 
 
756
                  int           y,
 
757
                  unsigned int  nglyph,
 
758
                  CharInfoPtr   *ppciInit,
 
759
                  pointer       pglyphBase)
 
760
{
 
761
    FbGCPrivPtr     pPriv = fbGetGCPrivate(pGC);
 
762
    CharInfoPtr     *ppci;
 
763
    CharInfoPtr     pci;
 
764
    unsigned char   *pglyph;            /* pointer bits in glyph */
 
765
    int             gWidth, gHeight;    /* width and height of glyph */
 
766
    FbStride        gStride;            /* stride of glyph */
 
767
    Bool            opaque;
 
768
    int             n;
 
769
    int             gx, gy;
 
770
    void            (*glyph) (FbBits *,
 
771
                              FbStride,
 
772
                              int,
 
773
                              FbStip *,
 
774
                              FbBits,
 
775
                              int,
 
776
                              int);
 
777
    FbBits          *dst;
 
778
    FbStride        dstStride;
 
779
    int             dstBpp;
 
780
    int             dstXoff, dstYoff;
 
781
    FbBits          depthMask;
 
782
    
 
783
    depthMask = FbFullMask(pDrawable->depth);
 
784
    if ((pGC->planemask & depthMask) != depthMask)
 
785
    {
 
786
        KdCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase);
 
787
        return;
 
788
    }
 
789
    glyph = 0;
 
790
    fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
 
791
    switch (dstBpp) {
 
792
    case 8:     glyph = fbGlyph8; break;
 
793
    case 16:    glyph = fbGlyph16; break;
 
794
    case 24:    glyph = fbGlyph24; break;
 
795
    case 32:    glyph = fbGlyph32; break;
 
796
    }
 
797
    
 
798
    x += pDrawable->x;
 
799
    y += pDrawable->y;
 
800
 
 
801
    if (TERMINALFONT (pGC->font) && !glyph)
 
802
    {
 
803
        opaque = TRUE;
 
804
    }
 
805
    else
 
806
    {
 
807
        int             xBack, widthBack;
 
808
        int             yBack, heightBack;
 
809
        
 
810
        ppci = ppciInit;
 
811
        n = nglyph;
 
812
        widthBack = 0;
 
813
        while (n--)
 
814
            widthBack += (*ppci++)->metrics.characterWidth;
 
815
        
 
816
        xBack = x;
 
817
        if (widthBack < 0)
 
818
        {
 
819
            xBack += widthBack;
 
820
            widthBack = -widthBack;
 
821
        }
 
822
        yBack = y - FONTASCENT(pGC->font);
 
823
        heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
 
824
        kaaSolidBoxClipped (pDrawable,
 
825
                            fbGetCompositeClip(pGC),
 
826
                            pGC->planemask,
 
827
                            pGC->bgPixel,
 
828
                            xBack,
 
829
                            yBack,
 
830
                            xBack + widthBack,
 
831
                            yBack + heightBack);
 
832
        opaque = FALSE;
 
833
    }
 
834
 
 
835
    kaaWaitSync (pDrawable->pScreen);
 
836
    kaaDrawableDirty (pDrawable);
 
837
    
 
838
    ppci = ppciInit;
 
839
    while (nglyph--)
 
840
    {
 
841
        pci = *ppci++;
 
842
        pglyph = FONTGLYPHBITS(pglyphBase, pci);
 
843
        gWidth = GLYPHWIDTHPIXELS(pci);
 
844
        gHeight = GLYPHHEIGHTPIXELS(pci);
 
845
        if (gWidth && gHeight)
 
846
        {
 
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))
 
851
            {
 
852
                (*glyph) (dst + (gy + dstYoff) * dstStride,
 
853
                          dstStride,
 
854
                          dstBpp,
 
855
                          (FbStip *) pglyph,
 
856
                          pPriv->fg,
 
857
                          gx + dstXoff,
 
858
                          gHeight);
 
859
            }
 
860
            else
 
861
            {
 
862
                gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
 
863
                fbPutXYImage (pDrawable,
 
864
                              fbGetCompositeClip(pGC),
 
865
                              pPriv->fg,
 
866
                              pPriv->bg,
 
867
                              pPriv->pm,
 
868
                              GXcopy,
 
869
                              opaque,
 
870
    
 
871
                              gx,
 
872
                              gy,
 
873
                              gWidth, gHeight,
 
874
    
 
875
                              (FbStip *) pglyph,
 
876
                              gStride,
 
877
                              0);
 
878
            }
 
879
        }
 
880
        x += pci->metrics.characterWidth;
 
881
    }
 
882
}
 
883
 
 
884
static const GCOps      kaaOps = {
 
885
    kaaFillSpans,
 
886
    KdCheckSetSpans,
 
887
    KdCheckPutImage,
 
888
    kaaCopyArea,
 
889
    KdCheckCopyPlane,
 
890
    KdCheckPolyPoint,
 
891
    KdCheckPolylines,
 
892
    KdCheckPolySegment,
 
893
    miPolyRectangle,
 
894
    KdCheckPolyArc,
 
895
    miFillPolygon,
 
896
    kaaPolyFillRect,
 
897
    miPolyFillArc,
 
898
    miPolyText8,
 
899
    miPolyText16,
 
900
    miImageText8,
 
901
    miImageText16,
 
902
    kaaImageGlyphBlt,
 
903
    KdCheckPolyGlyphBlt,
 
904
    KdCheckPushPixels,
 
905
#ifdef NEED_LINEHELPER
 
906
    ,NULL
 
907
#endif
 
908
};
 
909
 
 
910
static void
 
911
kaaValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
 
912
{
 
913
    fbValidateGC (pGC, changes, pDrawable);
 
914
 
 
915
    if (kaaDrawableIsOffscreen (pDrawable))
 
916
        pGC->ops = (GCOps *) &kaaOps;
 
917
    else
 
918
        pGC->ops = (GCOps *) &kdAsyncPixmapGCOps;
 
919
}
 
920
 
 
921
GCFuncs kaaGCFuncs = {
 
922
    kaaValidateGC,
 
923
    miChangeGC,
 
924
    miCopyGC,
 
925
    miDestroyGC,
 
926
    miChangeClip,
 
927
    miDestroyClip,
 
928
    miCopyClip
 
929
};
 
930
 
 
931
static int
 
932
kaaCreateGC (GCPtr pGC)
 
933
{
 
934
    if (!fbCreateGC (pGC))
 
935
        return FALSE;
 
936
 
 
937
    pGC->funcs = &kaaGCFuncs;
 
938
 
 
939
    return TRUE;
 
940
}
 
941
 
 
942
 
 
943
static void
 
944
kaaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 
945
{
 
946
    RegionRec   rgnDst;
 
947
    int         dx, dy;
 
948
    PixmapPtr   pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
 
949
 
 
950
    dx = ptOldOrg.x - pWin->drawable.x;
 
951
    dy = ptOldOrg.y - pWin->drawable.y;
 
952
    REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
 
953
 
 
954
    REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
 
955
    
 
956
    REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
 
957
#ifdef COMPOSITE
 
958
    if (pPixmap->screen_x || pPixmap->screen_y)
 
959
        REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst, 
 
960
                          -pPixmap->screen_x, -pPixmap->screen_y);
 
961
#endif
 
962
 
 
963
    fbCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
 
964
                  0,
 
965
                  &rgnDst, dx, dy, kaaCopyNtoN, 0, 0);
 
966
    
 
967
    REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
 
968
}
 
969
 
 
970
static void
 
971
kaaFillRegionSolid (DrawablePtr pDrawable,
 
972
                    RegionPtr   pRegion,
 
973
                    Pixel       pixel)
 
974
{
 
975
    KdScreenPriv(pDrawable->pScreen);
 
976
    KaaScreenPriv(pDrawable->pScreen);
 
977
    PixmapPtr pPixmap;
 
978
    int xoff, yoff;
 
979
 
 
980
    if (pScreenPriv->enabled &&
 
981
        (pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) &&
 
982
        (*pKaaScr->info->PrepareSolid) (pPixmap, GXcopy, FB_ALLONES, pixel))
 
983
    {
 
984
        int     nbox = REGION_NUM_RECTS (pRegion);
 
985
        BoxPtr  pBox = REGION_RECTS (pRegion);
 
986
        
 
987
        while (nbox--)
 
988
        {
 
989
            (*pKaaScr->info->Solid) (pBox->x1 + xoff, pBox->y1 + yoff,
 
990
                                     pBox->x2 + xoff, pBox->y2 + yoff);
 
991
            pBox++;
 
992
        }
 
993
        (*pKaaScr->info->DoneSolid) ();
 
994
        kaaMarkSync (pDrawable->pScreen);
 
995
    }
 
996
    else
 
997
    {
 
998
        kaaWaitSync (pDrawable->pScreen);
 
999
        fbFillRegionSolid (pDrawable, pRegion, 0,
 
1000
                           fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
 
1001
    }
 
1002
    kaaDrawableDirty (pDrawable);
 
1003
}
 
1004
 
 
1005
#if 0
 
1006
static void
 
1007
kaaFillRegionTiled (DrawablePtr pDrawable,
 
1008
                    RegionPtr   pRegion,
 
1009
                    Pixmap      pTile)
 
1010
{
 
1011
    else
 
1012
    {
 
1013
        kaaWaitSync
 
1014
}
 
1015
#endif
 
1016
 
 
1017
static void
 
1018
kaaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
 
1019
{
 
1020
 
 
1021
    if (!REGION_NUM_RECTS(pRegion)) 
 
1022
        return;
 
1023
    switch (what) {
 
1024
    case PW_BACKGROUND:
 
1025
        switch (pWin->backgroundState) {
 
1026
        case None:
 
1027
            return;
 
1028
        case ParentRelative:
 
1029
            do {
 
1030
                pWin = pWin->parent;
 
1031
            } while (pWin->backgroundState == ParentRelative);
 
1032
            (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
 
1033
                                                             what);
 
1034
            return;
 
1035
        case BackgroundPixel:
 
1036
            kaaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel);
 
1037
            return;
 
1038
#if 0       
 
1039
        case BackgroundPixmap:
 
1040
            kaaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->background.pixmap);
 
1041
            return;
 
1042
#endif
 
1043
        }
 
1044
        break;
 
1045
    case PW_BORDER:
 
1046
        if (pWin->borderIsPixel)
 
1047
        {
 
1048
            kaaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel);
 
1049
            return;
 
1050
        }
 
1051
#if 0
 
1052
        else
 
1053
        {
 
1054
            kaaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->border.pixmap);
 
1055
            return;
 
1056
        }
 
1057
#endif
 
1058
        break;
 
1059
    }
 
1060
    KdCheckPaintWindow (pWin, pRegion, what);
 
1061
}
 
1062
 
 
1063
Bool
 
1064
kaaDrawInit (ScreenPtr          pScreen,
 
1065
             KaaScreenInfoPtr   pScreenInfo)
 
1066
{
 
1067
    KaaScreenPrivPtr pKaaScr;
 
1068
    KdScreenPriv(pScreen);
 
1069
    KdScreenInfo *screen = pScreenPriv->screen;
 
1070
#ifdef RENDER
 
1071
    PictureScreenPtr    ps = GetPictureScreenIfSet(pScreen);
 
1072
#endif
 
1073
    
 
1074
    if (kaaGeneration != serverGeneration)
 
1075
    {
 
1076
        kaaScreenPrivateIndex = AllocateScreenPrivateIndex();
 
1077
        kaaPixmapPrivateIndex = AllocatePixmapPrivateIndex();
 
1078
        kaaGeneration = serverGeneration;
 
1079
    }
 
1080
 
 
1081
    pKaaScr = xalloc (sizeof (KaaScreenPrivRec));
 
1082
 
 
1083
    if (!pKaaScr)
 
1084
        return FALSE;
 
1085
    
 
1086
    pKaaScr->info = pScreenInfo;
 
1087
    
 
1088
    pScreen->devPrivates[kaaScreenPrivateIndex].ptr = (pointer) pKaaScr;
 
1089
    
 
1090
    /*
 
1091
     * Hook up asynchronous drawing
 
1092
     */
 
1093
    KdScreenInitAsync (pScreen);
 
1094
    /*
 
1095
     * Replace various fb screen functions
 
1096
     */
 
1097
    pScreen->CreateGC = kaaCreateGC;
 
1098
    pScreen->CopyWindow = kaaCopyWindow;
 
1099
    pScreen->PaintWindowBackground = kaaPaintWindow;
 
1100
    pScreen->PaintWindowBorder = kaaPaintWindow;
 
1101
#ifdef RENDER
 
1102
    if (ps) {
 
1103
        ps->Composite = kaaComposite;
 
1104
        ps->RasterizeTrapezoid = kaaRasterizeTrapezoid;
 
1105
    }
 
1106
#endif
 
1107
 
 
1108
    /*
 
1109
     * Hookup offscreen pixmaps
 
1110
     */
 
1111
    if ((pKaaScr->info->flags & KAA_OFFSCREEN_PIXMAPS) &&
 
1112
        screen->off_screen_base < screen->memory_size)
 
1113
    {
 
1114
        if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex,
 
1115
                                   sizeof (KaaPixmapPrivRec)))
 
1116
            return FALSE;
 
1117
        pScreen->CreatePixmap = kaaCreatePixmap;
 
1118
        pScreen->DestroyPixmap = kaaDestroyPixmap;
 
1119
    }
 
1120
    else
 
1121
    {
 
1122
        if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex, 0))
 
1123
            return FALSE;
 
1124
    }
 
1125
 
 
1126
    return TRUE;
 
1127
}
 
1128
 
 
1129
void
 
1130
kaaDrawFini (ScreenPtr pScreen)
 
1131
{
 
1132
    KaaScreenPriv(pScreen);
 
1133
 
 
1134
    xfree (pKaaScr);
 
1135
}
 
1136
 
 
1137
void
 
1138
kaaMarkSync (ScreenPtr pScreen)
 
1139
{
 
1140
    KdScreenPriv(pScreen);
 
1141
    KaaScreenPriv(pScreen);
 
1142
 
 
1143
    pScreenPriv->card->needSync = TRUE;
 
1144
    if (pKaaScr->info->markSync != NULL) {
 
1145
        pScreenPriv->card->lastMarker = (*pKaaScr->info->markSync) (pScreen);
 
1146
    }
 
1147
}
 
1148
 
 
1149
void
 
1150
kaaWaitSync (ScreenPtr pScreen)
 
1151
{
 
1152
    KdScreenPriv(pScreen);
 
1153
    KaaScreenPriv(pScreen);
 
1154
    KdCardInfo *card = pScreenPriv->card;
 
1155
 
 
1156
    if (card->needSync) {
 
1157
        (*pKaaScr->info->waitMarker) (pScreen, card->lastMarker);
 
1158
        card->needSync = FALSE;
 
1159
    }
 
1160
}