summaryrefslogtreecommitdiff
path: root/src/xvmc
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2010-03-10 15:00:58 +0100
committerOwain G. Ainsworth <oga@openbsd.org>2010-05-16 19:59:26 +0100
commit4760fe22710d4b1701ccbfff5f747b1501b22c1c (patch)
treecd23f06e402d2481a7012d7c632f4252a6267f80 /src/xvmc
parentbe5824da1e90556d0241ec51e0b8b66633f4f052 (diff)
libXvMC: derive driver surfaces from struct intel_xvmc_surface
... by putting struct intel_xvmc_surface at the beginning. This will allow to consolidate surface and bo handling. Also kill some now dead code used to handle the common surface structure. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> (cherry picked from commit 9eeabf876d1f70f5525bbac438414557dd2d4335) Signed-off-by: Owain G. Ainsworth <oga@openbsd.org>
Diffstat (limited to 'src/xvmc')
-rw-r--r--src/xvmc/i915_xvmc.c2
-rw-r--r--src/xvmc/i915_xvmc.h1
-rw-r--r--src/xvmc/i965_xvmc.h1
-rw-r--r--src/xvmc/intel_xvmc.c87
-rw-r--r--src/xvmc/intel_xvmc.h9
5 files changed, 19 insertions, 81 deletions
diff --git a/src/xvmc/i915_xvmc.c b/src/xvmc/i915_xvmc.c
index c8501e35..23f2f42f 100644
--- a/src/xvmc/i915_xvmc.c
+++ b/src/xvmc/i915_xvmc.c
@@ -984,7 +984,7 @@ static Status i915_xvmc_mc_create_surface(Display * display,
XVMC_DBG("%s\n", __FUNCTION__);
PPTHREAD_MUTEX_LOCK();
- surface->privData = (i915XvMCSurface *) malloc(sizeof(i915XvMCSurface));
+ surface->privData = (i915XvMCSurface *) calloc(1, sizeof(i915XvMCSurface));
if (!(pI915Surface = surface->privData)) {
PPTHREAD_MUTEX_UNLOCK();
diff --git a/src/xvmc/i915_xvmc.h b/src/xvmc/i915_xvmc.h
index 0bf59289..af4e2047 100644
--- a/src/xvmc/i915_xvmc.h
+++ b/src/xvmc/i915_xvmc.h
@@ -97,6 +97,7 @@ typedef struct _i915XvMCSubpicture {
* structure.
*/
typedef struct _i915XvMCSurface {
+ struct intel_xvmc_surface comm;
unsigned int srfNo; /* XvMC private surface numbers */
unsigned int yStride; /* Stride of YUV420 Y component. */
unsigned int uvStride;
diff --git a/src/xvmc/i965_xvmc.h b/src/xvmc/i965_xvmc.h
index 58462685..a80866fe 100644
--- a/src/xvmc/i965_xvmc.h
+++ b/src/xvmc/i965_xvmc.h
@@ -2,5 +2,6 @@
#define I965_MAX_SURFACES 12
struct i965_xvmc_surface {
+ struct intel_xvmc_surface comm;
dri_bo *bo;
};
diff --git a/src/xvmc/intel_xvmc.c b/src/xvmc/intel_xvmc.c
index 8ff27dae..664e91a5 100644
--- a/src/xvmc/intel_xvmc.c
+++ b/src/xvmc/intel_xvmc.c
@@ -182,63 +182,6 @@ intel_xvmc_context_ptr intel_xvmc_find_context(XID id)
return NULL;
}
-static intel_xvmc_surface_ptr intel_xvmc_new_surface(Display * dpy)
-{
- intel_xvmc_surface_ptr ret;
-
- ret = (intel_xvmc_surface_ptr) calloc(1, sizeof(intel_xvmc_surface_t));
- if (!ret)
- return NULL;
-
- if (!xvmc_driver->surf_list)
- ret->next = NULL;
- else
- ret->next = xvmc_driver->surf_list;
- xvmc_driver->surf_list = ret;
- xvmc_driver->num_surf++;
-
- ret->image = NULL;
- ret->gc_init = FALSE;
-
- return ret;
-
-}
-
-static void intel_xvmc_free_surface(XID id)
-{
- intel_xvmc_surface_ptr p = xvmc_driver->surf_list;
- intel_xvmc_surface_ptr pre = p;
-
- while (p) {
- if (p->surface && p->surface->surface_id == id) {
- if (p == xvmc_driver->surf_list)
- xvmc_driver->surf_list = p->next;
- else
- pre->next = p->next;
- break;
- }
- pre = p;
- p = p->next;
- }
-
- if (p) {
- free(p);
- xvmc_driver->num_surf--;
- }
-}
-
-intel_xvmc_surface_ptr intel_xvmc_find_surface(XID id)
-{
- intel_xvmc_surface_ptr p = xvmc_driver->surf_list;
-
- while (p) {
- if (p->surface && p->surface->surface_id == id)
- return p;
- p = p->next;
- }
- return NULL;
-}
-
static int
dri2_connect(Display *display)
{
@@ -534,17 +477,22 @@ _X_EXPORT Status XvMCCreateSurface(Display * display, XvMCContext * context,
if (!surface)
return XvMCBadSurface;
- intel_surf = intel_xvmc_new_surface(display);
- if (!intel_surf)
- return BadAlloc;
- intel_surf->surface = surface;
-
if ((ret = _xvmc_create_surface(display, context, surface,
&priv_count, &priv_data))) {
XVMC_ERR("Unable to create XvMCSurface.");
return ret;
}
+ ret =
+ (xvmc_driver->create_surface) (display, context, surface,
+ priv_count, priv_data);
+ if (ret) {
+ XVMC_ERR("create surface failed\n");
+ return ret;
+ }
+
+ intel_surf = surface->privData;
+
intel_surf->image = XvCreateImage(display, context->port,
FOURCC_XVMC,
(char *) &intel_surf->gem_handle,
@@ -552,18 +500,9 @@ _X_EXPORT Status XvMCCreateSurface(Display * display, XvMCContext * context,
if (!intel_surf->image) {
XVMC_ERR("Can't create XvImage for surface\n");
_xvmc_destroy_surface(display, surface);
- intel_xvmc_free_surface(surface->surface_id);
return BadAlloc;
}
- ret =
- (xvmc_driver->create_surface) (display, context, surface,
- priv_count, priv_data);
- if (ret) {
- XVMC_ERR("create surface failed\n");
- return ret;
- }
-
return Success;
}
@@ -577,14 +516,13 @@ _X_EXPORT Status XvMCDestroySurface(Display * display, XvMCSurface * surface)
if (!display || !surface)
return XvMCBadSurface;
- intel_surf = intel_xvmc_find_surface(surface->surface_id);
+ intel_surf = surface->privData;
if (!intel_surf)
return XvMCBadSurface;
XFree(intel_surf->image);
if (intel_surf->gc_init)
XFreeGC(display, intel_surf->gc);
- intel_xvmc_free_surface(surface->surface_id);
(xvmc_driver->destroy_surface) (display, surface);
@@ -768,7 +706,7 @@ _X_EXPORT Status XvMCPutSurface(Display * display, XvMCSurface * surface,
return XvMCBadSurface;
intel_ctx = intel_xvmc_find_context(surface->context_id);
- intel_surf = intel_xvmc_find_surface(surface->surface_id);
+ intel_surf = surface->privData;
if (!intel_ctx || !intel_surf)
return XvMCBadSurface;
context = intel_ctx->context;
@@ -781,7 +719,6 @@ _X_EXPORT Status XvMCPutSurface(Display * display, XvMCSurface * surface,
intel_surf->gc = XCreateGC(display, draw, 0, NULL);
}
intel_surf->last_draw = draw;
- /* fill intel_surf->data */
ret = (xvmc_driver->put_surface) (display, surface, draw, srcx, srcy,
srcw, srch, destx, desty, destw,
desth, flags,
diff --git a/src/xvmc/intel_xvmc.h b/src/xvmc/intel_xvmc.h
index a27065aa..dfe892ea 100644
--- a/src/xvmc/intel_xvmc.h
+++ b/src/xvmc/intel_xvmc.h
@@ -109,15 +109,14 @@ typedef struct _intel_xvmc_context {
struct _intel_xvmc_context *next;
} intel_xvmc_context_t, *intel_xvmc_context_ptr;
-typedef struct _intel_xvmc_surface {
- XvMCSurface *surface;
+struct intel_xvmc_surface {
XvImage *image;
GC gc;
Bool gc_init;
Drawable last_draw;
uint32_t gem_handle;
- struct _intel_xvmc_surface *next;
-} intel_xvmc_surface_t, *intel_xvmc_surface_ptr;
+};
+typedef struct intel_xvmc_surface *intel_xvmc_surface_ptr;
typedef struct _intel_xvmc_drm_map {
drm_handle_t handle;
@@ -160,7 +159,7 @@ typedef struct _intel_xvmc_driver {
int num_ctx;
intel_xvmc_context_ptr ctx_list;
int num_surf;
- intel_xvmc_surface_ptr surf_list;
+ struct intel_xvmc_surface * surf_list;
void *private;