[xserver-commit] xserver/hw/kdrive/src koffscreen.c,1.10,1.11 kxv.c,1.8,1.9 kxv.h,1.3,1.4
Keith Packard
xserver-commit@pdx.freedesktop.org
Mon, 10 Nov 2003 12:35:07 -0800
Committed by: keithp
Update of /cvs/xserver/xserver/hw/kdrive/src
In directory pdx:/tmp/cvs-serv4090/hw/kdrive/src
Modified Files:
koffscreen.c kxv.c kxv.h
Log Message:
* hw/kdrive/mach64/mach64video.c: (mach64PaintRegion),
(mach64PutImage), (mach64ReputImage):
* hw/kdrive/src/koffscreen.c: (KdOffscreenAlloc):
* hw/kdrive/src/kxv.c: (KdXVRegetVideo), (KdXVReputVideo),
(KdXVReputImage), (KdXVPutStill), (KdXVGetStill), (KdXVPutImage):
* hw/kdrive/src/kxv.h:
Fix KdXv interface to pass drawable down so that bits can be
put into drawable pixmap rather than directly into the frame buffer.
Rewrite logic in kdoffscreen to make space for new allocations,
now deals correctly with locked areas.
Index: koffscreen.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/koffscreen.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- koffscreen.c 2 Nov 2003 19:56:10 -0000 1.10
+++ koffscreen.c 10 Nov 2003 20:35:05 -0000 1.11
@@ -83,7 +83,7 @@
{
RealOffscreenArea *area, **prev;
KdScreenPriv (pScreen);
- int tmp, real_size;
+ int tmp, real_size = 0;
KdOffscreenValidate (pScreen);
if (!align)
@@ -102,8 +102,6 @@
return NULL;
}
-retry:
-
/* Go through the areas */
for (area = pScreenPriv->screen->off_screen_areas; area; area = area->next)
{
@@ -119,79 +117,99 @@
/* does it fit? */
if (real_size <= area->area.size)
+ break;
+ }
+
+ if (!area)
+ {
+ /*
+ * Kick out existing users to make space.
+ *
+ * First, locate a region which can hold the desired object.
+ */
+
+ /* prev points at the first object to boot */
+ prev = (RealOffscreenArea **) &pScreenPriv->screen->off_screen_areas;
+ while ((area = *prev))
{
- RealOffscreenArea *new_area;
-
- /* save extra space in new area */
- if (real_size < area->area.size)
+ int avail;
+ RealOffscreenArea *scan;
+
+ /* adjust size to match alignment requirement */
+ real_size = size;
+ tmp = area->area.offset % align;
+ if (tmp)
+ real_size += (align - tmp);
+
+ avail = 0;
+ /* now see if we can make room here */
+ for (scan = area; scan; scan = scan->next)
{
- new_area = xalloc (sizeof (RealOffscreenArea));
- if (!new_area)
- return NULL;
- new_area->area.offset = area->area.offset + real_size;
- new_area->area.size = area->area.size - real_size;
- new_area->area.screen = 0;
- new_area->locked = FALSE;
- new_area->save = 0;
- if ((new_area->next = area->next))
- new_area->next->prev = new_area;
- new_area->prev = area;
- area->next = new_area;
- area->area.size = real_size;
+ if (scan->locked)
+ break;
+ avail += scan->area.size;
+ if (avail >= real_size)
+ break;
}
- area->area.screen = pScreen;
- area->area.privData = privData;
- area->locked = locked;
- area->save = save;
-
- KdOffscreenValidate (pScreen);
-
- DBG_OFFSCREEN (("Alloc 0x%x -> 0x%x\n", size, area->area.offset));
- return &area->area;
- }
- }
-
- /*
- * Kick out existing users. This is pretty simplistic; it just
- * keeps deleting areas until the first area is free and has enough room
- */
+ /* space? */
+ if (avail >= real_size)
+ break;
- prev = (RealOffscreenArea **) &pScreenPriv->screen->off_screen_areas;
- while ((area = *prev))
- {
- if (area->area.screen && !area->locked)
+ /* nope, try the next area */
+ prev = &scan->next;
+ }
+ if (!area)
{
- KdOffscreenKickOut (&area->area);
- continue;
+ DBG_OFFSCREEN (("Alloc 0x%x -> NOSPACE\n", size));
+ /* Could not allocate memory */
+ KdOffscreenValidate (pScreen);
+ return NULL;
}
- /* adjust size to match alignment requirement */
- real_size = size;
- tmp = area->area.offset % align;
- if (tmp)
- real_size += (align - tmp);
-
- /* does it fit? */
- if (real_size <= area->area.size)
- goto retry;
- /* kick out the next area */
- area = area->next;
- if (!area)
- break;
- /* skip over locked areas */
- if (area->locked)
+ /*
+ * Kick out first area if in use
+ */
+ if (area->area.screen)
+ KdOffscreenKickOut (&area->area);
+ /*
+ * Now get the system to merge the other needed areas together
+ */
+ while (area->area.size < real_size)
{
- prev = &area->next;
- continue;
+ assert (area->next && area->next->area.screen);
+ KdOffscreenKickOut (&area->next->area);
}
- assert (area->area.screen);
- KdOffscreenKickOut (&area->area);
}
- DBG_OFFSCREEN (("Alloc 0x%x -> NOSPACE\n", size));
- /* Could not allocate memory */
+ /* save extra space in new area */
+ if (real_size < area->area.size)
+ {
+ RealOffscreenArea *new_area = xalloc (sizeof (RealOffscreenArea));
+ if (!new_area)
+ return NULL;
+ new_area->area.offset = area->area.offset + real_size;
+ new_area->area.size = area->area.size - real_size;
+ new_area->area.screen = 0;
+ new_area->locked = FALSE;
+ new_area->save = 0;
+ if ((new_area->next = area->next))
+ new_area->next->prev = new_area;
+ new_area->prev = area;
+ area->next = new_area;
+ area->area.size = real_size;
+ }
+ /*
+ * Mark this area as in use
+ */
+ area->area.screen = pScreen;
+ area->area.privData = privData;
+ area->locked = locked;
+ area->save = save;
+
KdOffscreenValidate (pScreen);
- return NULL;
+
+ DBG_OFFSCREEN (("Alloc 0x%x -> 0x%x\n", size, area->area.offset));
+ return &area->area;
}
void
Index: kxv.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kxv.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- kxv.c 14 Oct 2003 05:07:39 -0000 1.8
+++ kxv.c 10 Nov 2003 20:35:05 -0000 1.9
@@ -694,7 +694,7 @@
REGION_SUBTRACT(portPriv->pDraw->pScreen, &ClipRegion, &WinRegion, &ClipRegion);
}
- ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->screen,
+ ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->screen, portPriv->pDraw,
portPriv->vid_x, portPriv->vid_y,
WinBox.x1, WinBox.y1,
portPriv->vid_w, portPriv->vid_h,
@@ -785,7 +785,7 @@
REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
}
- ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->screen,
+ ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->screen, portPriv->pDraw,
portPriv->vid_x, portPriv->vid_y,
WinBox.x1, WinBox.y1,
portPriv->vid_w, portPriv->vid_h,
@@ -874,7 +874,7 @@
REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
}
- ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->screen,
+ ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->screen, portPriv->pDraw,
WinBox.x1, WinBox.y1,
&ClipRegion, portPriv->DevPriv.ptr);
@@ -1387,7 +1387,7 @@
REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
}
- ret = (*portPriv->AdaptorRec->PutStill)(portPriv->screen,
+ ret = (*portPriv->AdaptorRec->PutStill)(portPriv->screen, pDraw,
vid_x, vid_y, WinBox.x1, WinBox.y1,
vid_w, vid_h, drw_w, drw_h,
&ClipRegion, portPriv->DevPriv.ptr);
@@ -1515,7 +1515,7 @@
REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
}
- ret = (*portPriv->AdaptorRec->GetStill)(portPriv->screen,
+ ret = (*portPriv->AdaptorRec->GetStill)(portPriv->screen, pDraw,
vid_x, vid_y, WinBox.x1, WinBox.y1,
vid_w, vid_h, drw_w, drw_h,
&ClipRegion, portPriv->DevPriv.ptr);
@@ -1687,7 +1687,7 @@
REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
}
- ret = (*portPriv->AdaptorRec->PutImage)(portPriv->screen,
+ ret = (*portPriv->AdaptorRec->PutImage)(portPriv->screen, pDraw,
src_x, src_y, WinBox.x1, WinBox.y1,
src_w, src_h, drw_w, drw_h, format->id, data, width, height,
sync, &ClipRegion, portPriv->DevPriv.ptr);
Index: kxv.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kxv.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- kxv.h 7 Jul 2003 19:12:57 -0000 1.3
+++ kxv.h 10 Nov 2003 20:35:05 -0000 1.4
@@ -98,19 +98,19 @@
} KdSurfaceRec, *KdSurfacePtr;
-typedef int (* PutVideoFuncPtr)( KdScreenInfo * screen,
+typedef int (* PutVideoFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
short vid_x, short vid_y, short drw_x, short drw_y,
short vid_w, short vid_h, short drw_w, short drw_h,
RegionPtr clipBoxes, pointer data );
-typedef int (* PutStillFuncPtr)( KdScreenInfo * screen,
+typedef int (* PutStillFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
short vid_x, short vid_y, short drw_x, short drw_y,
short vid_w, short vid_h, short drw_w, short drw_h,
RegionPtr clipBoxes, pointer data );
-typedef int (* GetVideoFuncPtr)( KdScreenInfo * screen,
+typedef int (* GetVideoFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
short vid_x, short vid_y, short drw_x, short drw_y,
short vid_w, short vid_h, short drw_w, short drw_h,
RegionPtr clipBoxes, pointer data );
-typedef int (* GetStillFuncPtr)( KdScreenInfo * screen,
+typedef int (* GetStillFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
short vid_x, short vid_y, short drw_x, short drw_y,
short vid_w, short vid_h, short drw_w, short drw_h,
RegionPtr clipBoxes, pointer data );
@@ -122,13 +122,14 @@
typedef void (* QueryBestSizeFuncPtr)(KdScreenInfo * screen, Bool motion,
short vid_w, short vid_h, short drw_w, short drw_h,
unsigned int *p_w, unsigned int *p_h, pointer data);
-typedef int (* PutImageFuncPtr)( KdScreenInfo * screen,
+typedef int (* PutImageFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
short src_x, short src_y, short drw_x, short drw_y,
short src_w, short src_h, short drw_w, short drw_h,
int image, unsigned char* buf, short width, short height, Bool Sync,
RegionPtr clipBoxes, pointer data );
-typedef int (* ReputImageFuncPtr)( KdScreenInfo * screen, short drw_x, short drw_y,
- RegionPtr clipBoxes, pointer data );
+typedef int (* ReputImageFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
+ short drw_x, short drw_y,
+ RegionPtr clipBoxes, pointer data );
typedef int (*QueryImageAttributesFuncPtr)(KdScreenInfo * screen,
int image, unsigned short *width, unsigned short *height,
int *pitches, int *offsets);