diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2010-03-10 15:00:58 +0100 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2010-04-08 11:22:23 +0200 |
commit | 9eeabf876d1f70f5525bbac438414557dd2d4335 (patch) | |
tree | e4f3d7186357921116831fe61e6f6a518ccbd65e /src/xvmc | |
parent | a0058369bbdfb49f8df5ee1e50671115927d3565 (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>
Diffstat (limited to 'src/xvmc')
-rw-r--r-- | src/xvmc/i915_xvmc.c | 2 | ||||
-rw-r--r-- | src/xvmc/i915_xvmc.h | 1 | ||||
-rw-r--r-- | src/xvmc/i965_xvmc.h | 1 | ||||
-rw-r--r-- | src/xvmc/intel_xvmc.c | 87 | ||||
-rw-r--r-- | src/xvmc/intel_xvmc.h | 9 |
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 67d8ecc6..8b4bd4d8 100644 --- a/src/xvmc/intel_xvmc.h +++ b/src/xvmc/intel_xvmc.h @@ -108,15 +108,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; @@ -159,7 +158,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; |