• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/intel/common/libva


Commit MetaInfo

Révision4cc9a74bd82e9b1c5cfe7fc5fce056a01b99ecdb (tree)
l'heure2017-11-22 14:38:52
AuteurMark Thompson <sw@jkqx...>
CommiterXiang, Haihao

Message de Log

Move driver context allocation to common code

This will be required to set common options on a newly-created driver
context.

Signed-off-by: Mark Thompson <sw@jkqxz.net>

Change Summary

Modification

--- a/va/android/va_android.cpp
+++ b/va/android/va_android.cpp
@@ -125,43 +125,40 @@ VADisplay vaGetDisplay (
125125 void *native_dpy /* implementation specific */
126126 )
127127 {
128- VADisplay dpy = NULL;
129128 VADisplayContextP pDisplayContext;
129+ VADriverContextP pDriverContext;
130+ struct drm_state *drm_state;
130131
131132 if (!native_dpy)
132133 return NULL;
133134
134- if (!dpy)
135- {
136- /* create new entry */
137- VADriverContextP pDriverContext = 0;
138- struct drm_state *drm_state = 0;
139- pDisplayContext = va_newDisplayContext();
140- pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext));
141- drm_state = (struct drm_state*)calloc(1, sizeof(*drm_state));
142- if (pDisplayContext && pDriverContext && drm_state)
143- {
144- pDriverContext->native_dpy = (void *)native_dpy;
145- pDriverContext->display_type = VA_DISPLAY_ANDROID;
146- pDisplayContext->pDriverContext = pDriverContext;
147- pDisplayContext->vaIsValid = va_DisplayContextIsValid;
148- pDisplayContext->vaDestroy = va_DisplayContextDestroy;
149- pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
150- pDriverContext->drm_state = drm_state;
151- dpy = (VADisplay)pDisplayContext;
152- }
153- else
154- {
155- if (pDisplayContext)
156- free(pDisplayContext);
157- if (pDriverContext)
158- free(pDriverContext);
159- if (drm_state)
160- free(drm_state);
161- }
135+ pDisplayContext = va_newDisplayContext();
136+ if (!pDisplayContext)
137+ return NULL;
138+
139+ pDisplayContext->vaIsValid = va_DisplayContextIsValid;
140+ pDisplayContext->vaDestroy = va_DisplayContextDestroy;
141+ pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
142+
143+ pDriverContext = va_newDriverContext(pDisplayContext);
144+ if (!pDriverContext) {
145+ free(pDisplayContext);
146+ return NULL;
162147 }
163-
164- return dpy;
148+
149+ pDriverContext->native_dpy = (void *)native_dpy;
150+ pDriverContext->display_type = VA_DISPLAY_ANDROID
151+
152+ drm_state = calloc(1, sizeof(*drm_state));
153+ if (!drm_state) {
154+ free(pDisplayContext);
155+ free(pDriverContext);
156+ return NULL;
157+ }
158+
159+ pDriverContext->drm_state = drm_state;
160+
161+ return (VADisplay)pDisplayContext;
165162 }
166163
167164
--- a/va/drm/va_drm.c
+++ b/va/drm/va_drm.c
@@ -102,22 +102,23 @@ vaGetDisplayDRM(int fd)
102102 goto error;
103103 drm_state->fd = fd;
104104
105- pDriverContext = calloc(1, sizeof(*pDriverContext));
106- if (!pDriverContext)
107- goto error;
108- pDriverContext->native_dpy = NULL;
109- pDriverContext->display_type = is_render_nodes ?
110- VA_DISPLAY_DRM_RENDERNODES : VA_DISPLAY_DRM;
111- pDriverContext->drm_state = drm_state;
112-
113105 pDisplayContext = va_newDisplayContext();
114106 if (!pDisplayContext)
115107 goto error;
116108
117- pDisplayContext->pDriverContext = pDriverContext;
118109 pDisplayContext->vaIsValid = va_DisplayContextIsValid;
119110 pDisplayContext->vaDestroy = va_DisplayContextDestroy;
120111 pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
112+
113+ pDriverContext = va_newDriverContext(pDisplayContext);
114+ if (!pDriverContext)
115+ goto error;
116+
117+ pDriverContext->native_dpy = NULL;
118+ pDriverContext->display_type = is_render_nodes ?
119+ VA_DISPLAY_DRM_RENDERNODES : VA_DISPLAY_DRM;
120+ pDriverContext->drm_state = drm_state;
121+
121122 return pDisplayContext;
122123
123124 error:
--- a/va/va.c
+++ b/va/va.c
@@ -275,6 +275,17 @@ VADisplayContextP va_newDisplayContext(void)
275275 return dctx;
276276 }
277277
278+VADriverContextP va_newDriverContext(VADisplayContextP dctx)
279+{
280+ VADriverContextP ctx = calloc(1, sizeof(*ctx));
281+ if (!ctx)
282+ return NULL;
283+
284+ dctx->pDriverContext = ctx;
285+
286+ return ctx;
287+}
288+
278289 static bool va_checkVtable(VADisplay dpy, void *ptr, char *function)
279290 {
280291 if (!ptr) {
--- a/va/va_internal.h
+++ b/va/va_internal.h
@@ -39,6 +39,8 @@ int va_parseConfig(char *env, char *env_value);
3939
4040 VADisplayContextP va_newDisplayContext(void);
4141
42+VADriverContextP va_newDriverContext(VADisplayContextP dctx);
43+
4244 #ifdef __cplusplus
4345 }
4446 #endif
--- a/va/wayland/va_wayland.c
+++ b/va/wayland/va_wayland.c
@@ -129,10 +129,9 @@ vaGetDisplayWl(struct wl_display *display)
129129 pDisplayContext->vaDestroy = va_DisplayContextDestroy;
130130 pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
131131
132- pDriverContext = calloc(1, sizeof(*pDriverContext));
132+ pDriverContext = va_newDriverContext(pDisplayContext);
133133 if (!pDriverContext)
134134 goto error;
135- pDisplayContext->pDriverContext = pDriverContext;
136135
137136 pDriverContext->native_dpy = display;
138137 pDriverContext->display_type = VA_DISPLAY_WAYLAND;
--- a/va/x11/va_x11.c
+++ b/va/x11/va_x11.c
@@ -153,45 +153,41 @@ VADisplay vaGetDisplay (
153153 Display *native_dpy /* implementation specific */
154154 )
155155 {
156- VADisplay dpy = NULL;
157- VADisplayContextP pDisplayContext;
158-
159- if (!native_dpy)
160- return NULL;
161-
162- if (!dpy)
163- {
164- /* create new entry */
165- VADriverContextP pDriverContext;
166- struct dri_state *dri_state;
167- pDisplayContext = va_newDisplayContext();
168- pDriverContext = calloc(1, sizeof(*pDriverContext));
169- dri_state = calloc(1, sizeof(*dri_state));
170- if (pDisplayContext && pDriverContext && dri_state)
171- {
172- pDriverContext->native_dpy = (void *)native_dpy;
173- pDriverContext->x11_screen = XDefaultScreen(native_dpy);
174- pDriverContext->display_type = VA_DISPLAY_X11;
175- pDisplayContext->pDriverContext = pDriverContext;
176- pDisplayContext->vaIsValid = va_DisplayContextIsValid;
177- pDisplayContext->vaDestroy = va_DisplayContextDestroy;
178- pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
179- pDisplayContext->opaque = NULL;
180- pDriverContext->drm_state = dri_state;
181- dpy = (VADisplay)pDisplayContext;
182- }
183- else
184- {
185- if (pDisplayContext)
186- free(pDisplayContext);
187- if (pDriverContext)
188- free(pDriverContext);
189- if (dri_state)
190- free(dri_state);
191- }
192- }
193-
194- return dpy;
156+ VADisplayContextP pDisplayContext;
157+ VADriverContextP pDriverContext;
158+ struct dri_state *dri_state;
159+
160+ if (!native_dpy)
161+ return NULL;
162+
163+ pDisplayContext = va_newDisplayContext();
164+ if (!pDisplayContext)
165+ return NULL;
166+
167+ pDisplayContext->vaIsValid = va_DisplayContextIsValid;
168+ pDisplayContext->vaDestroy = va_DisplayContextDestroy;
169+ pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
170+
171+ pDriverContext = va_newDriverContext(pDisplayContext);
172+ if (!pDriverContext) {
173+ free(pDisplayContext);
174+ return NULL;
175+ }
176+
177+ pDriverContext->native_dpy = (void *)native_dpy;
178+ pDriverContext->x11_screen = XDefaultScreen(native_dpy);
179+ pDriverContext->display_type = VA_DISPLAY_X11;
180+
181+ dri_state = calloc(1, sizeof(*dri_state));
182+ if (!dri_state) {
183+ free(pDisplayContext);
184+ free(pDriverContext);
185+ return NULL;
186+ }
187+
188+ pDriverContext->drm_state = dri_state;
189+
190+ return (VADisplay)pDisplayContext;
195191 }
196192
197193