Add offscreen memory manager and update the servers to reflect the name
change for the kaa structure.
This commit is contained in:
parent
307f3dbd10
commit
a50438b470
|
@ -224,7 +224,7 @@ mach64DoneCopy (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KaaScreenPrivRec mach64Kaa = {
|
KaaScreenInfoRec mach64Kaa = {
|
||||||
mach64PrepareSolid,
|
mach64PrepareSolid,
|
||||||
mach64Solid,
|
mach64Solid,
|
||||||
mach64DoneSolid,
|
mach64DoneSolid,
|
||||||
|
|
|
@ -54,7 +54,6 @@ mgaCardInit (KdCardInfo *card)
|
||||||
Bool
|
Bool
|
||||||
mgaScreenInit (KdScreenInfo *screen)
|
mgaScreenInit (KdScreenInfo *screen)
|
||||||
{
|
{
|
||||||
MgaCardInfo *mgac = screen->card->driver;
|
|
||||||
MgaScreenInfo *mgas;
|
MgaScreenInfo *mgas;
|
||||||
int screen_size, memory;
|
int screen_size, memory;
|
||||||
|
|
||||||
|
@ -84,13 +83,13 @@ mgaScreenInit (KdScreenInfo *screen)
|
||||||
memory -= screen_size;
|
memory -= screen_size;
|
||||||
if (memory > screen->fb[0].byteStride)
|
if (memory > screen->fb[0].byteStride)
|
||||||
{
|
{
|
||||||
mgas->off_screen = mgas->screen + screen_size;
|
screen->off_screen_base = screen_size;
|
||||||
mgas->off_screen_size = memory;
|
screen->off_screen_size = memory;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mgas->off_screen = 0;
|
screen->off_screen_base = 0;
|
||||||
mgas->off_screen_size = 0;
|
screen->off_screen_size = 0;
|
||||||
}
|
}
|
||||||
screen->driver = mgas;
|
screen->driver = mgas;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -115,8 +114,6 @@ mgaFinishInitScreen (ScreenPtr pScreen)
|
||||||
void
|
void
|
||||||
mgaPreserve (KdCardInfo *card)
|
mgaPreserve (KdCardInfo *card)
|
||||||
{
|
{
|
||||||
MgaCardInfo *mgac = card->driver;
|
|
||||||
|
|
||||||
vesaPreserve (card);
|
vesaPreserve (card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +162,13 @@ mgaResetMMIO (KdCardInfo *card, MgaCardInfo *mgac)
|
||||||
mgaUnmapReg (card, mgac);
|
mgaUnmapReg (card, mgac);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bool
|
||||||
|
mgaDPMS (ScreenPtr pScreen, int mode)
|
||||||
|
{
|
||||||
|
/* XXX */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
mgaEnable (ScreenPtr pScreen)
|
mgaEnable (ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
|
@ -187,14 +191,8 @@ mgaDisable (ScreenPtr pScreen)
|
||||||
MgaCardInfo *mgac = pScreenPriv->card->driver;
|
MgaCardInfo *mgac = pScreenPriv->card->driver;
|
||||||
|
|
||||||
mgaResetMMIO (pScreenPriv->card, mgac);
|
mgaResetMMIO (pScreenPriv->card, mgac);
|
||||||
vesaDisable (pScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bool
|
vesaDisable (pScreen);
|
||||||
mgaDPMS (ScreenPtr pScreen, int mode)
|
|
||||||
{
|
|
||||||
/* XXX */
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -96,8 +96,6 @@ typedef struct _mgaCardInfo {
|
||||||
typedef struct _mgaScreenInfo {
|
typedef struct _mgaScreenInfo {
|
||||||
VesaScreenPrivRec vesa;
|
VesaScreenPrivRec vesa;
|
||||||
CARD8 *screen;
|
CARD8 *screen;
|
||||||
CARD8 *off_screen;
|
|
||||||
int off_screen_size;
|
|
||||||
|
|
||||||
int pitch;
|
int pitch;
|
||||||
int pw;
|
int pw;
|
||||||
|
|
|
@ -48,14 +48,12 @@ CARD32 mgaRop[16] = {
|
||||||
|
|
||||||
static VOL8 *mmio;
|
static VOL8 *mmio;
|
||||||
int fifo_size;
|
int fifo_size;
|
||||||
int pitch;
|
int pitch, src_pitch;
|
||||||
int dir;
|
int dir;
|
||||||
|
|
||||||
void
|
void
|
||||||
mgaWaitAvail (int n)
|
mgaWaitAvail (int n)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
if (fifo_size < n) {
|
if (fifo_size < n) {
|
||||||
while ((fifo_size = MGA_IN32 (mmio, MGA_REG_FIFOSTATUS) & 0xff) < n)
|
while ((fifo_size = MGA_IN32 (mmio, MGA_REG_FIFOSTATUS) & 0xff) < n)
|
||||||
;
|
;
|
||||||
|
@ -84,25 +82,43 @@ mgaSetup (ScreenPtr pScreen, int wait)
|
||||||
if (!mmio)
|
if (!mmio)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
mgaWaitAvail (wait + 7);
|
mgaWaitAvail (wait + 4);
|
||||||
MGA_OUT32 (mmio, MGA_REG_PITCH, mgas->pitch);
|
|
||||||
MGA_OUT32 (mmio, MGA_REG_SRCORG, 0);
|
|
||||||
MGA_OUT32 (mmio, MGA_REG_DSTORG, 0);
|
|
||||||
MGA_OUT32 (mmio, MGA_REG_MACCESS, mgas->pw);
|
MGA_OUT32 (mmio, MGA_REG_MACCESS, mgas->pw);
|
||||||
MGA_OUT32 (mmio, MGA_REG_CXBNDRY, 0xffff0000);
|
MGA_OUT32 (mmio, MGA_REG_CXBNDRY, 0xffff0000);
|
||||||
MGA_OUT32 (mmio, MGA_REG_YTOP, 0x00000000);
|
MGA_OUT32 (mmio, MGA_REG_YTOP, 0x00000000);
|
||||||
MGA_OUT32 (mmio, MGA_REG_YBOT, 0x007fffff);
|
MGA_OUT32 (mmio, MGA_REG_YBOT, 0x007fffff);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
mgaPrepareSolid (DrawablePtr pDrawable, int alu, Pixel pm, Pixel fg)
|
mgaPrepareSolid (DrawablePtr pDrawable, int alu, Pixel pm, Pixel fg)
|
||||||
{
|
{
|
||||||
|
KdScreenPriv(pDrawable->pScreen);
|
||||||
|
mgaScreenInfo (pScreenPriv);
|
||||||
int cmd;
|
int cmd;
|
||||||
|
|
||||||
cmd = MGA_OPCOD_TRAP | MGA_DWGCTL_SOLID | MGA_DWGCTL_ARZERO | MGA_DWGCTL_SGNZERO |
|
cmd = MGA_OPCOD_TRAP | MGA_DWGCTL_SOLID | MGA_DWGCTL_ARZERO | MGA_DWGCTL_SGNZERO |
|
||||||
MGA_DWGCTL_SHIFTZERO | mgaRop[alu];
|
MGA_DWGCTL_SHIFTZERO | mgaRop[alu];
|
||||||
|
|
||||||
mgaSetup (pDrawable->pScreen, 3);
|
mgaSetup (pDrawable->pScreen, 5);
|
||||||
|
|
||||||
|
if (pDrawable->type == DRAWABLE_WINDOW)
|
||||||
|
{
|
||||||
|
MGA_OUT32 (mmio, MGA_REG_DSTORG, 0);
|
||||||
|
MGA_OUT32 (mmio, MGA_REG_PITCH, pitch);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PixmapPtr pPixmap = (PixmapPtr)pDrawable;
|
||||||
|
int dst_org;
|
||||||
|
|
||||||
|
dst_org = (int)pPixmap->devPrivate.ptr - (int)mgas->screen;
|
||||||
|
|
||||||
|
MGA_OUT32 (mmio, MGA_REG_DSTORG, dst_org);
|
||||||
|
MGA_OUT32 (mmio, MGA_REG_PITCH, pPixmap->devKind / (pPixmap->drawable.bitsPerPixel >> 3));
|
||||||
|
}
|
||||||
|
|
||||||
MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
|
MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
|
||||||
MGA_OUT32 (mmio, MGA_REG_FCOL, fg);
|
MGA_OUT32 (mmio, MGA_REG_FCOL, fg);
|
||||||
MGA_OUT32 (mmio, MGA_REG_PLNWT, pm);
|
MGA_OUT32 (mmio, MGA_REG_PLNWT, pm);
|
||||||
|
@ -114,7 +130,8 @@ void
|
||||||
mgaSolid (int x1, int y1, int x2, int y2)
|
mgaSolid (int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
mgaWaitAvail (2);
|
mgaWaitAvail (2);
|
||||||
MGA_OUT32 (mmio, MGA_REG_FXBNDRY, (x2 << 16) | x1 & 0xffff);
|
|
||||||
|
MGA_OUT32 (mmio, MGA_REG_FXBNDRY, (x2 << 16) | (x1 & 0xffff));
|
||||||
MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (y1 << 16) | (y2 - y1));
|
MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (y1 << 16) | (y2 - y1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,13 +156,44 @@ mgaPrepareCopy (DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, int dx, int
|
||||||
dir |= BLIT_UP;
|
dir |= BLIT_UP;
|
||||||
if (dx < 0)
|
if (dx < 0)
|
||||||
dir |= BLIT_LEFT;
|
dir |= BLIT_LEFT;
|
||||||
|
|
||||||
|
mgaSetup (pDstDrawable->pScreen, 6);
|
||||||
|
|
||||||
|
if (pSrcDrawable->type == DRAWABLE_WINDOW)
|
||||||
|
{
|
||||||
|
MGA_OUT32 (mmio, MGA_REG_SRCORG, 0);
|
||||||
|
|
||||||
|
src_pitch = pitch;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
KdScreenPriv(pSrcDrawable->pScreen);
|
||||||
|
mgaScreenInfo (pScreenPriv);
|
||||||
|
PixmapPtr pPixmap = (PixmapPtr)pSrcDrawable;
|
||||||
|
|
||||||
|
MGA_OUT32 (mmio, MGA_REG_SRCORG, ((int)pPixmap->devPrivate.ptr - (int)mgas->screen));
|
||||||
|
src_pitch = pPixmap->devKind / (pPixmap->drawable.bitsPerPixel >> 3);
|
||||||
|
}
|
||||||
|
|
||||||
mgaSetup (pDstDrawable->pScreen, 4);
|
if (pDstDrawable->type == DRAWABLE_WINDOW)
|
||||||
|
{
|
||||||
|
MGA_OUT32 (mmio, MGA_REG_DSTORG, 0);
|
||||||
|
MGA_OUT32 (mmio, MGA_REG_PITCH, pitch);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
KdScreenPriv(pDstDrawable->pScreen);
|
||||||
|
mgaScreenInfo (pScreenPriv);
|
||||||
|
PixmapPtr pPixmap = (PixmapPtr)pDstDrawable;
|
||||||
|
|
||||||
|
MGA_OUT32 (mmio, MGA_REG_DSTORG, ((int)pPixmap->devPrivate.ptr - (int)mgas->screen));
|
||||||
|
MGA_OUT32 (mmio, MGA_REG_PITCH, pPixmap->devKind / (pPixmap->drawable.bitsPerPixel >> 3));
|
||||||
|
}
|
||||||
|
|
||||||
MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
|
MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
|
||||||
MGA_OUT32 (mmio, MGA_REG_SGN, dir);
|
MGA_OUT32 (mmio, MGA_REG_SGN, dir);
|
||||||
MGA_OUT32 (mmio, MGA_REG_PLNWT, pm);
|
MGA_OUT32 (mmio, MGA_REG_PLNWT, pm);
|
||||||
MGA_OUT32 (mmio, MGA_REG_AR5, pitch * (dy < 0 ? -1 : 1) );
|
MGA_OUT32 (mmio, MGA_REG_AR5, src_pitch * (dy < 0 ? -1 : 1) );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +210,7 @@ mgaCopy (int srcX, int srcY, int dstX, int dstY, int w, int h)
|
||||||
}
|
}
|
||||||
|
|
||||||
w--;
|
w--;
|
||||||
start = end = srcY * pitch + srcX;
|
start = end = srcY * src_pitch + srcX;
|
||||||
|
|
||||||
if (dir & BLIT_LEFT)
|
if (dir & BLIT_LEFT)
|
||||||
start += w;
|
start += w;
|
||||||
|
@ -173,7 +221,6 @@ mgaCopy (int srcX, int srcY, int dstX, int dstY, int w, int h)
|
||||||
MGA_OUT32 (mmio, MGA_REG_AR0, end);
|
MGA_OUT32 (mmio, MGA_REG_AR0, end);
|
||||||
MGA_OUT32 (mmio, MGA_REG_AR3, start);
|
MGA_OUT32 (mmio, MGA_REG_AR3, start);
|
||||||
MGA_OUT32 (mmio, MGA_REG_FXBNDRY, ((dstX + w) << 16) | (dstX & 0xffff));
|
MGA_OUT32 (mmio, MGA_REG_FXBNDRY, ((dstX + w) << 16) | (dstX & 0xffff));
|
||||||
|
|
||||||
MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (dstY << 16) | h);
|
MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (dstY << 16) | h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +229,7 @@ mgaDoneCopy (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KaaScreenPrivRec mgaKaa = {
|
KaaScreenInfoRec mgaKaa = {
|
||||||
mgaPrepareSolid,
|
mgaPrepareSolid,
|
||||||
mgaSolid,
|
mgaSolid,
|
||||||
mgaDoneSolid,
|
mgaDoneSolid,
|
||||||
|
@ -190,13 +237,17 @@ KaaScreenPrivRec mgaKaa = {
|
||||||
mgaPrepareCopy,
|
mgaPrepareCopy,
|
||||||
mgaCopy,
|
mgaCopy,
|
||||||
mgaDoneCopy,
|
mgaDoneCopy,
|
||||||
|
|
||||||
|
192, /* Offscreen byte alignment */
|
||||||
|
64, /* Offset pitch */
|
||||||
};
|
};
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
mgaDrawInit (ScreenPtr pScreen)
|
mgaDrawInit (ScreenPtr pScreen)
|
||||||
{
|
{
|
||||||
KdScreenPriv(pScreen);
|
KdScreenPriv(pScreen);
|
||||||
|
mgaScreenInfo (pScreenPriv);
|
||||||
|
|
||||||
if (!kaaDrawInit (pScreen, &mgaKaa))
|
if (!kaaDrawInit (pScreen, &mgaKaa))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ nvidiaDoneCopy (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KaaScreenPrivRec nvidiaKaa = {
|
KaaScreenInfoRec nvidiaKaa = {
|
||||||
nvidiaPrepareSolid,
|
nvidiaPrepareSolid,
|
||||||
nvidiaSolid,
|
nvidiaSolid,
|
||||||
nvidiaDoneSolid,
|
nvidiaDoneSolid,
|
||||||
|
|
|
@ -212,7 +212,7 @@ r128DoneCopy (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KaaScreenPrivRec r128Kaa = {
|
KaaScreenInfoRec r128Kaa = {
|
||||||
r128PrepareSolid,
|
r128PrepareSolid,
|
||||||
r128Solid,
|
r128Solid,
|
||||||
r128DoneSolid,
|
r128DoneSolid,
|
||||||
|
|
|
@ -233,7 +233,7 @@ smiDoneCopy (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KaaScreenPrivRec smiKaa = {
|
KaaScreenInfoRec smiKaa = {
|
||||||
smiPrepareSolid,
|
smiPrepareSolid,
|
||||||
smiSolid,
|
smiSolid,
|
||||||
smiDoneSolid,
|
smiDoneSolid,
|
||||||
|
|
|
@ -19,6 +19,7 @@ libkdrive_a_SOURCES = \
|
||||||
kmap.c \
|
kmap.c \
|
||||||
kmode.c \
|
kmode.c \
|
||||||
knoop.c \
|
knoop.c \
|
||||||
|
koffscreen.c \
|
||||||
kpict.c \
|
kpict.c \
|
||||||
kshadow.c \
|
kshadow.c \
|
||||||
ktest.c \
|
ktest.c \
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
*
|
*
|
||||||
* Copyright © 2001 Keith Packard
|
* Copyright © 2001 Keith Packard
|
||||||
*
|
*
|
||||||
|
* Partly based on code that is Copyright © The XFree86 Project Inc.
|
||||||
|
*
|
||||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
* documentation for any purpose is hereby granted without fee, provided that
|
* documentation for any purpose is hereby granted without fee, provided that
|
||||||
* the above copyright notice appear in all copies and that both that
|
* the above copyright notice appear in all copies and that both that
|
||||||
|
@ -29,10 +31,44 @@
|
||||||
#include "fontstruct.h"
|
#include "fontstruct.h"
|
||||||
#include "dixfontstr.h"
|
#include "dixfontstr.h"
|
||||||
|
|
||||||
int kaaGeneration;
|
int kaaGeneration;
|
||||||
int kaaScreenPrivateIndex;
|
int kaaScreenPrivateIndex;
|
||||||
|
int kaaPixmapPrivateIndex;
|
||||||
|
|
||||||
|
typedef struct _PixmapLink {
|
||||||
|
PixmapPtr pPixmap;
|
||||||
|
|
||||||
|
struct _PixmapLink *next;
|
||||||
|
} PixmapLink;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
KaaScreenInfoPtr info;
|
||||||
|
|
||||||
|
int offscreenSize;
|
||||||
|
int offscreenBase;
|
||||||
|
PixmapLink *offscreenPixmaps;
|
||||||
|
|
||||||
|
CreatePixmapProcPtr CreatePixmap;
|
||||||
|
DestroyPixmapProcPtr DestroyPixmap;
|
||||||
|
} KaaScreenPrivRec, *KaaScreenPrivPtr;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
KdOffscreenArea *offscreenArea;
|
||||||
|
Bool swappedOut;
|
||||||
|
} KaaPixmapPrivRec, *KaaPixmapPrivPtr;
|
||||||
|
|
||||||
|
|
||||||
|
#define KaaGetScreenPriv(s) ((KaaScreenPrivPtr)(s)->devPrivates[kaaScreenPrivateIndex].ptr)
|
||||||
|
#define KaaScreenPriv(s) KaaScreenPrivPtr pKaaScr = KaaGetScreenPriv(s)
|
||||||
|
|
||||||
|
#define KAA_SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
|
||||||
|
((KaaScreenPrivPtr) (pScreen)->devPrivates[kaaScreenPrivateIndex].ptr)->field)
|
||||||
|
|
||||||
|
#define KAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\
|
||||||
|
((pScreen)->field = wrapper)
|
||||||
|
|
||||||
|
#define MIN_OFFPIX_SIZE (320*200)
|
||||||
|
|
||||||
#define KaaScreenPriv(s) KaaScreenPrivPtr pKaaScr = (KaaScreenPrivPtr) (s)->devPrivates[kaaScreenPrivateIndex].ptr
|
|
||||||
|
|
||||||
void
|
void
|
||||||
kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
|
kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
|
||||||
|
@ -50,10 +86,10 @@ kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
|
||||||
|
|
||||||
if (!pScreenPriv->enabled ||
|
if (!pScreenPriv->enabled ||
|
||||||
pGC->fillStyle != FillSolid ||
|
pGC->fillStyle != FillSolid ||
|
||||||
!(*pKaaScr->PrepareSolid) (pDrawable,
|
!(*pKaaScr->info->PrepareSolid) (pDrawable,
|
||||||
pGC->alu,
|
pGC->alu,
|
||||||
pGC->planemask,
|
pGC->planemask,
|
||||||
pGC->fgPixel))
|
pGC->fgPixel))
|
||||||
{
|
{
|
||||||
KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
|
KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
|
||||||
return;
|
return;
|
||||||
|
@ -87,7 +123,7 @@ kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
|
||||||
nbox = REGION_NUM_RECTS (pClip);
|
nbox = REGION_NUM_RECTS (pClip);
|
||||||
if (nbox == 1)
|
if (nbox == 1)
|
||||||
{
|
{
|
||||||
(*pKaaScr->Solid) (fullX1, fullY1, fullX2, fullY1 + 1);
|
(*pKaaScr->info->Solid) (fullX1, fullY1, fullX2, fullY1 + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -103,13 +139,13 @@ kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
|
||||||
if (partX2 > fullX2)
|
if (partX2 > fullX2)
|
||||||
partX2 = fullX2;
|
partX2 = fullX2;
|
||||||
if (partX2 > partX1)
|
if (partX2 > partX1)
|
||||||
(*pKaaScr->Solid) (partX1, fullY1, partX2, fullY1 + 1);
|
(*pKaaScr->info->Solid) (partX1, fullY1, partX2, fullY1 + 1);
|
||||||
}
|
}
|
||||||
pbox++;
|
pbox++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(*pKaaScr->DoneSolid) ();
|
(*pKaaScr->info->DoneSolid) ();
|
||||||
KdMarkSync(pDrawable->pScreen);
|
KdMarkSync(pDrawable->pScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,29 +169,31 @@ kaaCopyNtoN (DrawablePtr pSrcDrawable,
|
||||||
CARD32 flags;
|
CARD32 flags;
|
||||||
CARD32 cmd;
|
CARD32 cmd;
|
||||||
CARD8 alu;
|
CARD8 alu;
|
||||||
|
|
||||||
if (pScreenPriv->enabled &&
|
if (pScreenPriv->enabled &&
|
||||||
pSrcDrawable->type == DRAWABLE_WINDOW &&
|
pSrcDrawable->type == DRAWABLE_WINDOW &&
|
||||||
(*pKaaScr->PrepareCopy) (pSrcDrawable,
|
(*pKaaScr->info->PrepareCopy) (pSrcDrawable,
|
||||||
pDstDrawable,
|
pDstDrawable,
|
||||||
dx,
|
dx,
|
||||||
dy,
|
dy,
|
||||||
pGC ? pGC->alu : GXcopy,
|
pGC ? pGC->alu : GXcopy,
|
||||||
pGC ? pGC->planemask : FB_ALLONES))
|
pGC ? pGC->planemask : FB_ALLONES))
|
||||||
{
|
{
|
||||||
while (nbox--)
|
while (nbox--)
|
||||||
{
|
{
|
||||||
(*pKaaScr->Copy) (pbox->x1 + dx, pbox->y1 + dy,
|
(*pKaaScr->info->Copy) (pbox->x1 + dx, pbox->y1 + dy,
|
||||||
pbox->x1, pbox->y1,
|
pbox->x1, pbox->y1,
|
||||||
pbox->x2 - pbox->x1,
|
pbox->x2 - pbox->x1,
|
||||||
pbox->y2 - pbox->y1);
|
pbox->y2 - pbox->y1);
|
||||||
pbox++;
|
pbox++;
|
||||||
}
|
}
|
||||||
(*pKaaScr->DoneCopy) ();
|
(*pKaaScr->info->DoneCopy) ();
|
||||||
KdMarkSync(pDstDrawable->pScreen);
|
KdMarkSync(pDstDrawable->pScreen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
KdScreenPriv (pDstDrawable->pScreen);
|
||||||
|
|
||||||
KdCheckSync (pDstDrawable->pScreen);
|
KdCheckSync (pDstDrawable->pScreen);
|
||||||
fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC,
|
fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC,
|
||||||
pbox, nbox, dx, dy, reverse, upsidedown,
|
pbox, nbox, dx, dy, reverse, upsidedown,
|
||||||
|
@ -191,10 +229,10 @@ kaaPolyFillRect(DrawablePtr pDrawable,
|
||||||
|
|
||||||
if (!pScreenPriv->enabled ||
|
if (!pScreenPriv->enabled ||
|
||||||
pGC->fillStyle != FillSolid ||
|
pGC->fillStyle != FillSolid ||
|
||||||
!(*pKaaScr->PrepareSolid) (pDrawable,
|
!(*pKaaScr->info->PrepareSolid) (pDrawable,
|
||||||
pGC->alu,
|
pGC->alu,
|
||||||
pGC->planemask,
|
pGC->planemask,
|
||||||
pGC->fgPixel))
|
pGC->fgPixel))
|
||||||
{
|
{
|
||||||
KdCheckPolyFillRect (pDrawable, pGC, nrect, prect);
|
KdCheckPolyFillRect (pDrawable, pGC, nrect, prect);
|
||||||
return;
|
return;
|
||||||
|
@ -233,7 +271,7 @@ kaaPolyFillRect(DrawablePtr pDrawable,
|
||||||
n = REGION_NUM_RECTS (pClip);
|
n = REGION_NUM_RECTS (pClip);
|
||||||
if (n == 1)
|
if (n == 1)
|
||||||
{
|
{
|
||||||
(*pKaaScr->Solid) (fullX1, fullY1, fullX2, fullY2);
|
(*pKaaScr->info->Solid) (fullX1, fullY1, fullX2, fullY2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -260,12 +298,12 @@ kaaPolyFillRect(DrawablePtr pDrawable,
|
||||||
pbox++;
|
pbox++;
|
||||||
|
|
||||||
if (partX1 < partX2 && partY1 < partY2)
|
if (partX1 < partX2 && partY1 < partY2)
|
||||||
(*pKaaScr->Solid) (partX1, partY1,
|
(*pKaaScr->info->Solid) (partX1, partY1,
|
||||||
partX2, partY2);
|
partX2, partY2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(*pKaaScr->DoneSolid) ();
|
(*pKaaScr->info->DoneSolid) ();
|
||||||
KdMarkSync(pDrawable->pScreen);
|
KdMarkSync(pDrawable->pScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +325,7 @@ kaaSolidBoxClipped (DrawablePtr pDrawable,
|
||||||
CARD32 cmd;
|
CARD32 cmd;
|
||||||
|
|
||||||
if (!pScreenPriv->enabled ||
|
if (!pScreenPriv->enabled ||
|
||||||
!(*pKaaScr->PrepareSolid) (pDrawable, GXcopy, pm, fg))
|
!(*pKaaScr->info->PrepareSolid) (pDrawable, GXcopy, pm, fg))
|
||||||
{
|
{
|
||||||
KdCheckSync (pDrawable->pScreen);
|
KdCheckSync (pDrawable->pScreen);
|
||||||
fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel);
|
fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel);
|
||||||
|
@ -322,9 +360,9 @@ kaaSolidBoxClipped (DrawablePtr pDrawable,
|
||||||
if (partY2 <= partY1)
|
if (partY2 <= partY1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
(*pKaaScr->Solid) (partX1, partY1, partX2, partY2);
|
(*pKaaScr->info->Solid) (partX1, partY1, partX2, partY2);
|
||||||
}
|
}
|
||||||
(*pKaaScr->DoneSolid) ();
|
(*pKaaScr->info->DoneSolid) ();
|
||||||
KdMarkSync(pDrawable->pScreen);
|
KdMarkSync(pDrawable->pScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,6 +558,7 @@ kaaCreateGC (GCPtr pGC)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
kaaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
|
kaaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
|
||||||
{
|
{
|
||||||
|
@ -555,17 +594,17 @@ kaaFillRegionSolid (DrawablePtr pDrawable,
|
||||||
KaaScreenPriv(pDrawable->pScreen);
|
KaaScreenPriv(pDrawable->pScreen);
|
||||||
|
|
||||||
if (pScreenPriv->enabled &&
|
if (pScreenPriv->enabled &&
|
||||||
(*pKaaScr->PrepareSolid) (pDrawable, GXcopy, FB_ALLONES, pixel))
|
(*pKaaScr->info->PrepareSolid) (pDrawable, GXcopy, FB_ALLONES, pixel))
|
||||||
{
|
{
|
||||||
int nbox = REGION_NUM_RECTS (pRegion);
|
int nbox = REGION_NUM_RECTS (pRegion);
|
||||||
BoxPtr pBox = REGION_RECTS (pRegion);
|
BoxPtr pBox = REGION_RECTS (pRegion);
|
||||||
|
|
||||||
while (nbox--)
|
while (nbox--)
|
||||||
{
|
{
|
||||||
(*pKaaScr->Solid) (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
|
(*pKaaScr->info->Solid) (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
|
||||||
pBox++;
|
pBox++;
|
||||||
}
|
}
|
||||||
(*pKaaScr->DoneSolid) ();
|
(*pKaaScr->info->DoneSolid) ();
|
||||||
KdMarkSync(pDrawable->pScreen);
|
KdMarkSync(pDrawable->pScreen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -613,14 +652,30 @@ kaaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
kaaDrawInit (ScreenPtr pScreen,
|
kaaDrawInit (ScreenPtr pScreen,
|
||||||
KaaScreenPrivPtr pScreenPriv)
|
KaaScreenInfoPtr pScreenInfo)
|
||||||
{
|
{
|
||||||
|
KaaScreenPrivPtr pKaaScr;
|
||||||
|
KdScreenInfo *screen = KdGetScreenPriv (pScreen)->screen;
|
||||||
|
|
||||||
if (kaaGeneration != serverGeneration)
|
if (kaaGeneration != serverGeneration)
|
||||||
{
|
{
|
||||||
kaaScreenPrivateIndex = AllocateScreenPrivateIndex();
|
kaaScreenPrivateIndex = AllocateScreenPrivateIndex();
|
||||||
|
kaaPixmapPrivateIndex = AllocatePixmapPrivateIndex();
|
||||||
kaaGeneration = serverGeneration;
|
kaaGeneration = serverGeneration;
|
||||||
}
|
}
|
||||||
pScreen->devPrivates[kaaScreenPrivateIndex].ptr = (pointer) pScreenPriv;
|
|
||||||
|
if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex, sizeof(KaaPixmapPrivRec)))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
pKaaScr = xalloc (sizeof (KaaScreenPrivRec));
|
||||||
|
|
||||||
|
if (!pKaaScr)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
pKaaScr->info = pScreenInfo;
|
||||||
|
pKaaScr->offscreenPixmaps = NULL;
|
||||||
|
|
||||||
|
pScreen->devPrivates[kaaScreenPrivateIndex].ptr = (pointer) pKaaScr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hook up asynchronous drawing
|
* Hook up asynchronous drawing
|
||||||
|
@ -634,6 +689,18 @@ kaaDrawInit (ScreenPtr pScreen,
|
||||||
pScreen->PaintWindowBackground = kaaPaintWindow;
|
pScreen->PaintWindowBackground = kaaPaintWindow;
|
||||||
pScreen->PaintWindowBorder = kaaPaintWindow;
|
pScreen->PaintWindowBorder = kaaPaintWindow;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/*
|
||||||
|
* Hookup offscreen pixmaps
|
||||||
|
*/
|
||||||
|
if (screen->off_screen_size > 0)
|
||||||
|
{
|
||||||
|
pKaaScr->CreatePixmap = pScreen->CreatePixmap;
|
||||||
|
pScreen->CreatePixmap = kaaCreatePixmap;
|
||||||
|
pKaaScr->DestroyPixmap = pScreen->DestroyPixmap;
|
||||||
|
pScreen->DestroyPixmap = kaaDestroyPixmap;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,7 @@ KdDisableScreen (ScreenPtr pScreen)
|
||||||
if (!pScreenPriv->closed)
|
if (!pScreenPriv->closed)
|
||||||
KdSetRootClip (pScreen, FALSE);
|
KdSetRootClip (pScreen, FALSE);
|
||||||
KdDisableColormap (pScreen);
|
KdDisableColormap (pScreen);
|
||||||
|
KdOffscreenSwapOut (pScreen);
|
||||||
if (!pScreenPriv->screen->dumb)
|
if (!pScreenPriv->screen->dumb)
|
||||||
(*pScreenPriv->card->cfuncs->disableAccel) (pScreen);
|
(*pScreenPriv->card->cfuncs->disableAccel) (pScreen);
|
||||||
if (!pScreenPriv->screen->softCursor)
|
if (!pScreenPriv->screen->softCursor)
|
||||||
|
@ -290,6 +291,7 @@ KdEnableScreen (ScreenPtr pScreen)
|
||||||
(*pScreenPriv->card->cfuncs->enableCursor) (pScreen);
|
(*pScreenPriv->card->cfuncs->enableCursor) (pScreen);
|
||||||
if (!pScreenPriv->screen->dumb)
|
if (!pScreenPriv->screen->dumb)
|
||||||
(*pScreenPriv->card->cfuncs->enableAccel) (pScreen);
|
(*pScreenPriv->card->cfuncs->enableAccel) (pScreen);
|
||||||
|
KdOffscreenSwapIn (pScreen);
|
||||||
KdEnableColormap (pScreen);
|
KdEnableColormap (pScreen);
|
||||||
KdSetRootClip (pScreen, TRUE);
|
KdSetRootClip (pScreen, TRUE);
|
||||||
if (pScreenPriv->card->cfuncs->dpms)
|
if (pScreenPriv->card->cfuncs->dpms)
|
||||||
|
@ -1129,6 +1131,9 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
|
||||||
if (!(*card->cfuncs->initAccel) (pScreen))
|
if (!(*card->cfuncs->initAccel) (pScreen))
|
||||||
screen->dumb = TRUE;
|
screen->dumb = TRUE;
|
||||||
|
|
||||||
|
if (screen->off_screen_size > 0)
|
||||||
|
KdOffscreenInit (pScreen);
|
||||||
|
|
||||||
#ifdef PSEUDO8
|
#ifdef PSEUDO8
|
||||||
(void) p8Init (pScreen, PSEUDO8_USE_DEFAULT);
|
(void) p8Init (pScreen, PSEUDO8_USE_DEFAULT);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1216,7 +1221,6 @@ KdInitScreen (ScreenInfo *pScreenInfo,
|
||||||
screen->dumb = TRUE;
|
screen->dumb = TRUE;
|
||||||
if (!card->cfuncs->initCursor)
|
if (!card->cfuncs->initCursor)
|
||||||
screen->softCursor = TRUE;
|
screen->softCursor = TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
|
|
|
@ -118,6 +118,9 @@ typedef struct _KdScreenInfo {
|
||||||
int mynum;
|
int mynum;
|
||||||
DDXPointRec origin;
|
DDXPointRec origin;
|
||||||
KdFrameBuffer fb[KD_MAX_FB];
|
KdFrameBuffer fb[KD_MAX_FB];
|
||||||
|
int off_screen_base;
|
||||||
|
int off_screen_size;
|
||||||
|
pointer off_screen_areas;
|
||||||
} KdScreenInfo;
|
} KdScreenInfo;
|
||||||
|
|
||||||
typedef struct _KdCardFuncs {
|
typedef struct _KdCardFuncs {
|
||||||
|
@ -259,6 +262,14 @@ typedef struct _KdMonitorTiming {
|
||||||
KdSyncPolarity vpol; /* polarity */
|
KdSyncPolarity vpol; /* polarity */
|
||||||
} KdMonitorTiming;
|
} KdMonitorTiming;
|
||||||
|
|
||||||
|
typedef struct _KdOffscreenArea {
|
||||||
|
ScreenPtr screen;
|
||||||
|
int offset;
|
||||||
|
int size;
|
||||||
|
pointer privData;
|
||||||
|
Bool swappedOut;
|
||||||
|
} KdOffscreenArea;
|
||||||
|
|
||||||
extern const KdMonitorTiming kdMonitorTimings[];
|
extern const KdMonitorTiming kdMonitorTimings[];
|
||||||
extern const int kdNumMonitorTimings;
|
extern const int kdNumMonitorTimings;
|
||||||
|
|
||||||
|
@ -266,7 +277,7 @@ typedef struct _KdMouseMatrix {
|
||||||
int matrix[2][3];
|
int matrix[2][3];
|
||||||
} KdMouseMatrix;
|
} KdMouseMatrix;
|
||||||
|
|
||||||
typedef struct _KaaScreenPriv {
|
typedef struct _KaaScreenInfo {
|
||||||
Bool (*PrepareSolid) (DrawablePtr pDrawable,
|
Bool (*PrepareSolid) (DrawablePtr pDrawable,
|
||||||
int alu,
|
int alu,
|
||||||
Pixel planemask,
|
Pixel planemask,
|
||||||
|
@ -287,11 +298,11 @@ typedef struct _KaaScreenPriv {
|
||||||
int width,
|
int width,
|
||||||
int height);
|
int height);
|
||||||
void (*DoneCopy) (void);
|
void (*DoneCopy) (void);
|
||||||
} KaaScreenPrivRec, *KaaScreenPrivPtr;
|
|
||||||
|
|
||||||
Bool
|
int offscreenByteAlign;
|
||||||
KaaInit (ScreenPtr pScreen,
|
int offscreenPitch;
|
||||||
KaaScreenPrivPtr pScreenPriv);
|
} KaaScreenInfoRec, *KaaScreenInfoPtr;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the only completely portable way to
|
* This is the only completely portable way to
|
||||||
|
@ -335,8 +346,8 @@ extern KdOsFuncs *kdOsFuncs;
|
||||||
|
|
||||||
/* kaa.c */
|
/* kaa.c */
|
||||||
Bool
|
Bool
|
||||||
kaaDrawInit (ScreenPtr pScreen,
|
kaaDrawInit (ScreenPtr pScreen,
|
||||||
KaaScreenPrivPtr pScreenPriv);
|
KaaScreenInfoPtr pScreenInfo);
|
||||||
|
|
||||||
void
|
void
|
||||||
kaaWrapGC (GCPtr pGC);
|
kaaWrapGC (GCPtr pGC);
|
||||||
|
@ -751,6 +762,28 @@ KdFrameBufferValid (CARD8 *base, int size);
|
||||||
int
|
int
|
||||||
KdFrameBufferSize (CARD8 *base, int max);
|
KdFrameBufferSize (CARD8 *base, int max);
|
||||||
|
|
||||||
/* function prototypes to be imlpemented by the drivers */
|
/* koffscreen.c */
|
||||||
|
typedef void (*KdOffscreenMoveDataProc) (KdOffscreenArea *area);
|
||||||
|
|
||||||
|
Bool
|
||||||
|
KdOffscreenInit (ScreenPtr pScreen);
|
||||||
|
|
||||||
|
KdOffscreenArea *
|
||||||
|
KdOffscreenAlloc (ScreenPtr pScreen, int size, int align,
|
||||||
|
Bool locked,
|
||||||
|
KdOffscreenMoveDataProc moveIn,
|
||||||
|
KdOffscreenMoveDataProc moveOut,
|
||||||
|
pointer privData);
|
||||||
|
|
||||||
|
void
|
||||||
|
KdOffscreenFree (KdOffscreenArea *area);
|
||||||
|
|
||||||
|
void
|
||||||
|
KdOffscreenSwapOut (ScreenPtr pScreen);
|
||||||
|
|
||||||
|
void
|
||||||
|
KdOffscreenSwapIn (ScreenPtr pScreen);
|
||||||
|
|
||||||
|
/* function prototypes to be implemented by the drivers */
|
||||||
void
|
void
|
||||||
InitCard (char *name);
|
InitCard (char *name);
|
||||||
|
|
|
@ -0,0 +1,200 @@
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright © 2003 Anders Carlsson
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
* documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
* the above copyright notice appear in all copies and that both that
|
||||||
|
* copyright notice and this permission notice appear in supporting
|
||||||
|
* documentation, and that the name of Anders Carlsson not be used in
|
||||||
|
* advertising or publicity pertaining to distribution of the software without
|
||||||
|
* specific, written prior permission. Anders Carlsson makes no
|
||||||
|
* representations about the suitability of this software for any purpose. It
|
||||||
|
* is provided "as is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
* ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||||
|
* EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||||
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||||
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
/* $Header$ */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
#include "kdrive.h"
|
||||||
|
|
||||||
|
typedef struct _RealOffscreenArea {
|
||||||
|
KdOffscreenArea area;
|
||||||
|
|
||||||
|
KdOffscreenMoveDataProc moveIn;
|
||||||
|
KdOffscreenMoveDataProc moveOut;
|
||||||
|
|
||||||
|
Bool locked;
|
||||||
|
|
||||||
|
struct _RealOffscreenArea *next;
|
||||||
|
struct _RealOffscreenArea *prev;
|
||||||
|
} RealOffscreenArea;
|
||||||
|
|
||||||
|
KdOffscreenArea *
|
||||||
|
KdOffscreenAlloc (ScreenPtr pScreen, int size, int align,
|
||||||
|
Bool locked,
|
||||||
|
KdOffscreenMoveDataProc moveIn,
|
||||||
|
KdOffscreenMoveDataProc moveOut,
|
||||||
|
pointer privData)
|
||||||
|
{
|
||||||
|
RealOffscreenArea *area;
|
||||||
|
KdScreenPriv (pScreen);
|
||||||
|
int tmp, real_size;
|
||||||
|
|
||||||
|
|
||||||
|
/* Go through the areas */
|
||||||
|
area = pScreenPriv->screen->off_screen_areas;
|
||||||
|
while (area != NULL)
|
||||||
|
{
|
||||||
|
if (area->area.screen != NULL)
|
||||||
|
{
|
||||||
|
area = area->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
real_size = size;
|
||||||
|
tmp = (area->area.offset + area->area.size - size) % align;
|
||||||
|
|
||||||
|
if (tmp)
|
||||||
|
real_size += (align - tmp);
|
||||||
|
|
||||||
|
if (real_size <= area->area.size)
|
||||||
|
{
|
||||||
|
RealOffscreenArea *new_area;
|
||||||
|
|
||||||
|
if (real_size == area->area.size)
|
||||||
|
{
|
||||||
|
area->area.screen = pScreen;
|
||||||
|
area->area.privData = privData;
|
||||||
|
area->locked = locked;
|
||||||
|
area->moveIn = moveIn;
|
||||||
|
area->moveOut = moveOut;
|
||||||
|
|
||||||
|
return (KdOffscreenArea *)area;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a new area */
|
||||||
|
new_area = xalloc (sizeof (RealOffscreenArea));
|
||||||
|
new_area->area.offset = area->area.offset + area->area.size - real_size;
|
||||||
|
new_area->area.size = real_size;
|
||||||
|
new_area->area.screen = pScreen;
|
||||||
|
|
||||||
|
area->area.size -= real_size;
|
||||||
|
|
||||||
|
new_area->prev = area;
|
||||||
|
new_area->next = area->next;
|
||||||
|
|
||||||
|
if (area->next)
|
||||||
|
area->next->prev = new_area;
|
||||||
|
area->next = new_area;
|
||||||
|
|
||||||
|
return (KdOffscreenArea *)new_area;
|
||||||
|
}
|
||||||
|
|
||||||
|
area = area->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Could not allocate memory */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KdOffscreenSwapOut (ScreenPtr pScreen)
|
||||||
|
{
|
||||||
|
KdScreenPriv (pScreen);
|
||||||
|
RealOffscreenArea *area = pScreenPriv->screen->off_screen_areas;
|
||||||
|
|
||||||
|
while (area)
|
||||||
|
{
|
||||||
|
(*area->moveOut) ((KdOffscreenArea *)area);
|
||||||
|
|
||||||
|
area->area.swappedOut = TRUE;
|
||||||
|
|
||||||
|
area = area->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KdOffscreenSwapIn (ScreenPtr pScreen)
|
||||||
|
{
|
||||||
|
KdScreenPriv (pScreen);
|
||||||
|
RealOffscreenArea *area = pScreenPriv->screen->off_screen_areas;
|
||||||
|
|
||||||
|
while (area)
|
||||||
|
{
|
||||||
|
(*area->moveOut) ((KdOffscreenArea *)area);
|
||||||
|
|
||||||
|
area->area.swappedOut = TRUE;
|
||||||
|
area = area->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KdOffscreenFree (KdOffscreenArea *area)
|
||||||
|
{
|
||||||
|
RealOffscreenArea *real_area = (RealOffscreenArea *)area;
|
||||||
|
|
||||||
|
real_area->area.screen = NULL;
|
||||||
|
|
||||||
|
if (real_area && real_area->next && !real_area->next->area.screen)
|
||||||
|
{
|
||||||
|
RealOffscreenArea *tmp;
|
||||||
|
|
||||||
|
real_area->next->prev = real_area->prev;
|
||||||
|
if (real_area->prev)
|
||||||
|
real_area->prev->next = real_area->next;
|
||||||
|
|
||||||
|
real_area->next->area.size += real_area->area.size;
|
||||||
|
real_area->next->area.offset = real_area->area.offset;
|
||||||
|
|
||||||
|
tmp = real_area->next;
|
||||||
|
xfree (real_area);
|
||||||
|
real_area = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (real_area->prev && !real_area->prev->area.screen)
|
||||||
|
{
|
||||||
|
real_area->prev->next = real_area->next;
|
||||||
|
if (real_area->next)
|
||||||
|
real_area->next->prev = real_area->prev;
|
||||||
|
|
||||||
|
real_area->prev->area.size += real_area->area.size;
|
||||||
|
|
||||||
|
xfree (real_area);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Bool
|
||||||
|
KdOffscreenInit (ScreenPtr pScreen)
|
||||||
|
{
|
||||||
|
KdScreenPriv (pScreen);
|
||||||
|
RealOffscreenArea *area;
|
||||||
|
|
||||||
|
/* Allocate a big free area */
|
||||||
|
area = xalloc (sizeof (RealOffscreenArea));
|
||||||
|
|
||||||
|
if (!area)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
area->area.screen = NULL;
|
||||||
|
area->area.offset = pScreenPriv->screen->off_screen_base;
|
||||||
|
area->area.size = pScreenPriv->screen->off_screen_size;
|
||||||
|
area->next = NULL;
|
||||||
|
area->prev = NULL;
|
||||||
|
|
||||||
|
/* Add it to the free areas */
|
||||||
|
pScreenPriv->screen->off_screen_areas = area;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue