st/dri: Make lookup_egl_image a hook
authorJakob Bornecrantz <wallbraker@gmail.com>
Sat, 24 Apr 2010 11:35:56 +0000 (12:35 +0100)
committerJakob Bornecrantz <wallbraker@gmail.com>
Sun, 25 Apr 2010 23:40:17 +0000 (00:40 +0100)
src/gallium/state_trackers/dri/common/dri_screen.h
src/gallium/state_trackers/dri/common/dri_st_api.c
src/gallium/state_trackers/dri/drm/dri2.c
src/gallium/state_trackers/dri/drm/dri2.h

index 8ab7d4391918784dcff22fd36d7719b67a35e9a6..d84ce1bf48e1b893da1312cef319228466009402 100644 (file)
@@ -41,6 +41,8 @@
 #include "state_tracker/st_api.h"
 #include "state_tracker/drm_api.h"
 
+struct dri_context;
+
 struct dri_screen
 {
    /* dri */
@@ -55,6 +57,9 @@ struct dri_screen
    int fd;
    drmLock *drmLock;
 
+   /* hooks filled in by dri1, dri2 & drisw */
+   __DRIimage * (*lookup_egl_image)(struct dri_context *ctx, void *handle);
+
    /* gallium */
    struct drm_api *api;
    struct pipe_winsys *pipe_winsys;
index f9295cb4ca8b8bdbb0efde9dcb22a2761ae15372..cbcb149b0a217c3d59d38d1b79074967f00ea2c3 100644 (file)
@@ -229,15 +229,15 @@ static boolean
 dri_st_manager_get_egl_image(struct st_manager *smapi,
                              struct st_egl_image *stimg)
 {
+   struct dri_context *ctx =
+      (struct dri_context *)stimg->stctxi->st_manager_private;
+   struct dri_screen *screen = dri_screen(ctx->sPriv);
    __DRIimage *img = NULL;
 
-#ifndef __NOT_HAVE_DRM_H
-   if (!__dri1_api_hooks) {
-      struct dri_context *ctx = (struct dri_context *)
-         stimg->stctxi->st_manager_private;
-      img = dri2_lookup_egl_image(ctx, stimg->egl_image);
+   if (screen->lookup_egl_image) {
+      img = screen->lookup_egl_image(ctx, stimg->egl_image);
    }
-#endif
+
    if (!img)
       return FALSE;
 
index 7c84fcfd723b023fc2a329af6d78893b9fed3522..0bf8c83f21f39def5d4c89091159ae7d4aab8e0c 100644 (file)
@@ -373,7 +373,7 @@ dri2_flush_frontbuffer(struct dri_drawable *drawable,
    }
 }
 
-__DRIimage *
+static __DRIimage *
 dri2_lookup_egl_image(struct dri_context *ctx, void *handle)
 {
    __DRIimageLookupExtension *loader = ctx->sPriv->dri2.image;
@@ -512,6 +512,7 @@ dri2_init_screen(__DRIscreen * sPriv)
    screen->api = drm_api_create();
    screen->sPriv = sPriv;
    screen->fd = sPriv->fd;
+   screen->lookup_egl_image = dri2_lookup_egl_image;
 
    sPriv->private = (void *)screen;
    sPriv->extensions = dri_screen_extensions;
index 5b28850000b70bd23d2cea57c511e5f959dae4a3..379963431fb84dc2ce436471440e6114c27c0bdd 100644 (file)
@@ -43,7 +43,4 @@ dri2_allocate_textures(struct dri_drawable *drawable,
                        const enum st_attachment_type *statts,
                        unsigned count);
 
-__DRIimage *
-dri2_lookup_egl_image(struct dri_context *ctx, void *handle);
-
 #endif /* DRI2_H */