summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-08-20 13:43:11 +0200
committerAlexander Larsson <alexl@redhat.com>2010-08-20 13:52:02 +0200
commitd48f555acb1c962305c4853154989143685b8b01 (patch)
tree013421f425c29b036efcde65f5387e84526d560d
parent1c7c3ad104dfdd265de4795816a7e92ec9c49e4b (diff)
Add helper functions for surface info <-> id mapping
-rw-r--r--display/driver.c6
-rw-r--r--display/res.c4
-rw-r--r--display/surface.c8
-rw-r--r--display/surface.h20
4 files changed, 22 insertions, 16 deletions
diff --git a/display/driver.c b/display/driver.c
index c00adb0..9abecb3 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -1283,14 +1283,12 @@ out_error:
VOID APIENTRY DrvDeleteDeviceBitmap(DHSURF dhsurf)
{
UINT32 surface_id;
- PDev *pdev;
SurfaceInfo *surface;
surface = (SurfaceInfo *)dhsurf;
- pdev = surface->pdev;
- surface_id = surface - pdev->surfaces_info;
+ surface_id = GetSurfaceIdFromInfo(surface);
- DeleteDeviceBitmap(pdev, surface_id, DEVICE_BITMAP_ALLOCATION_TYPE_VRAM);
+ DeleteDeviceBitmap(surface->pdev, surface_id, DEVICE_BITMAP_ALLOCATION_TYPE_VRAM);
}
#ifdef CALL_TEST
diff --git a/display/res.c b/display/res.c
index 6be006e..e1bb110 100644
--- a/display/res.c
+++ b/display/res.c
@@ -648,11 +648,11 @@ static void FreeDelSurface(PDev *pdev, Resource *res)
switch (internal->allocation_type) {
case DEVICE_BITMAP_ALLOCATION_TYPE_DEVRAM:
FreeMem(pdev, MSPACE_TYPE_DEVRAM,
- pdev->surfaces_info[internal->surface_id].draw_area.base_mem);
+ GetSurfaceInfo(pdev, internal->surface_id)->draw_area.base_mem);
break;
case DEVICE_BITMAP_ALLOCATION_TYPE_VRAM:
FreeMem(pdev, MSPACE_TYPE_VRAM,
- pdev->surfaces_info[internal->surface_id].draw_area.base_mem);
+ GetSurfaceInfo(pdev, internal->surface_id)->draw_area.base_mem);
break;
default:
PANIC(pdev, "bad allocation type");
diff --git a/display/surface.c b/display/surface.c
index 4a84f45..d9fc6f4 100644
--- a/display/surface.c
+++ b/display/surface.c
@@ -45,7 +45,7 @@ BOOL CreateDrawArea(PDev *pdev, UINT8 *base_mem, ULONG format, UINT32 cx, UINT32
size.cx = cx;
size.cy = cy;
- drawarea = &pdev->surfaces_info[surface_id].draw_area;
+ drawarea = &GetSurfaceInfo(pdev, surface_id)->draw_area;
if (!(drawarea->bitmap = (HSURF)EngCreateBitmap(size, stride, format, 0, base_mem))) {
DEBUG_PRINT((pdev, 0, "%s: EngCreateBitmap failed\n", __FUNCTION__));
@@ -101,7 +101,7 @@ HBITMAP CreateDeviceBitmap(PDev *pdev, SIZEL size, ULONG format, QXLPHYSICAL *ph
return 0;
};
- if (!(surf = EngCreateDeviceBitmap((DHSURF)&pdev->surfaces_info[surface_id], size, format))) {
+ if (!(surf = EngCreateDeviceBitmap((DHSURF)GetSurfaceInfo(pdev, surface_id), size, format))) {
DEBUG_PRINT((NULL, 0, "%s: create device surface failed, 0x%lx\n",
__FUNCTION__, pdev));
goto out_error1;
@@ -119,7 +119,7 @@ HBITMAP CreateDeviceBitmap(PDev *pdev, SIZEL size, ULONG format, QXLPHYSICAL *ph
goto out_error2;
}
- pdev->surfaces_info[surface_id].pdev = pdev;
+ GetSurfaceInfo(pdev, surface_id)->pdev = pdev;
QXLGetSurface(pdev, phys_mem, size.cx, size.cy, depth,
&stride, base_mem, allocation_type);
@@ -158,7 +158,7 @@ VOID DeleteDeviceBitmap(PDev *pdev, UINT32 surface_id, UINT8 allocation_type)
{
DrawArea *drawarea;
- drawarea = &pdev->surfaces_info[surface_id].draw_area;
+ drawarea = &GetSurfaceInfo(pdev,surface_id)->draw_area;
FreeDrawArea(drawarea);
diff --git a/display/surface.h b/display/surface.h
index ca1ffec..6390d77 100644
--- a/display/surface.h
+++ b/display/surface.h
@@ -3,17 +3,25 @@
#include "qxldd.h"
+static _inline UINT32 GetSurfaceIdFromInfo(SurfaceInfo *info)
+{
+ PDev *pdev;
+
+ pdev = info->pdev;
+ return info - pdev->surfaces_info;
+}
+
+static _inline SurfaceInfo *GetSurfaceInfo(PDev *pdev, UINT32 id)
+{
+ return &pdev->surfaces_info[id];
+}
+
static _inline UINT32 GetSurfaceId(SURFOBJ *surf)
{
- PDev *pdev;
SurfaceInfo *surface;
- UINT32 surface_id;
-
- pdev = (PDev *)surf->dhpdev;
surface = (SurfaceInfo *)surf->dhsurf;
- surface_id = surface - pdev->surfaces_info;
- return surface_id;
+ return GetSurfaceIdFromInfo(surface);
}
static _inline void FreeSurface(PDev *pdev, UINT32 surface_id)