st/dri: adapt to interface changes
[mesa.git] / src / gallium / state_trackers / dri / common / dri_context.c
index f14f4130bf4b2158a73f5e9f834c41724ed0a846..203682ef330469ba2040daf64d503f5881625f82 100644 (file)
@@ -34,7 +34,6 @@
 #include "dri_screen.h"
 #include "dri_drawable.h"
 #include "dri_context.h"
-#include "dri_st_api.h"
 
 #include "pipe/p_context.h"
 #include "state_tracker/st_context.h"
@@ -50,12 +49,12 @@ dri_init_extensions(struct dri_context *ctx)
 }
 
 GLboolean
-dri_create_context(const __GLcontextModes * visual,
+dri_create_context(gl_api api, const __GLcontextModes * visual,
                   __DRIcontext * cPriv, void *sharedContextPrivate)
 {
-   struct st_api *stapi = dri_get_st_api();
    __DRIscreen *sPriv = cPriv->driScreenPriv;
    struct dri_screen *screen = dri_screen(sPriv);
+   struct st_api *stapi = screen->st_api;
    struct dri_context *ctx = NULL;
    struct st_context_iface *st_share = NULL;
    struct st_visual stvis;
@@ -77,7 +76,7 @@ dri_create_context(const __GLcontextModes * visual,
                       &screen->optionCache, sPriv->myNum, "dri");
 
    dri_fill_st_visual(&stvis, screen, visual);
-   ctx->st = stapi->create_context(stapi, screen->smapi, &stvis, st_share);
+   ctx->st = stapi->create_context(stapi, &screen->base, &stvis, st_share);
    if (ctx->st == NULL)
       goto fail;
    ctx->st->st_manager_private = (void *) ctx;
@@ -119,16 +118,15 @@ dri_destroy_context(__DRIcontext * cPriv)
 GLboolean
 dri_unbind_context(__DRIcontext * cPriv)
 {
-   struct st_api *stapi = dri_get_st_api();
-
-   if (cPriv) {
-      struct dri_context *ctx = dri_context(cPriv);
+   /* dri_util.c ensures cPriv is not null */
+   struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
+   struct dri_context *ctx = dri_context(cPriv);
+   struct st_api *stapi = screen->st_api;
 
-      if (--ctx->bind_count == 0) {
-         if (ctx->st == stapi->get_current(stapi)) {
-            ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
-            stapi->make_current(stapi, NULL, NULL, NULL);
-         }
+   if (--ctx->bind_count == 0) {
+      if (ctx->st == stapi->get_current(stapi)) {
+         ctx->st->flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+         stapi->make_current(stapi, NULL, NULL, NULL);
       }
    }
 
@@ -140,42 +138,38 @@ dri_make_current(__DRIcontext * cPriv,
                 __DRIdrawable * driDrawPriv,
                 __DRIdrawable * driReadPriv)
 {
-   struct st_api *stapi = dri_get_st_api();
-
-   if (cPriv) {
-      struct dri_context *ctx = dri_context(cPriv);
-      struct dri_drawable *draw = dri_drawable(driDrawPriv);
-      struct dri_drawable *read = dri_drawable(driReadPriv);
-      struct st_context_iface *old_st;
+   /* dri_util.c ensures cPriv is not null */
+   struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
+   struct dri_context *ctx = dri_context(cPriv);
+   struct st_api *stapi = screen->st_api;
+   struct dri_drawable *draw = dri_drawable(driDrawPriv);
+   struct dri_drawable *read = dri_drawable(driReadPriv);
+   struct st_context_iface *old_st = stapi->get_current(stapi);
 
-      old_st = stapi->get_current(stapi);
-      if (old_st && old_st != ctx->st)
-        ctx->st->flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL);
+   if (old_st && old_st != ctx->st)
+      old_st->flush(old_st, PIPE_FLUSH_RENDER_CACHE, NULL);
 
-      ++ctx->bind_count;
+   ++ctx->bind_count;
 
-      if (ctx->dPriv != driDrawPriv) {
-        ctx->dPriv = driDrawPriv;
-         draw->texture_stamp = driDrawPriv->lastStamp - 1;
-      }
-      if (ctx->rPriv != driReadPriv) {
-        ctx->rPriv = driReadPriv;
-         read->texture_stamp = driReadPriv->lastStamp - 1;
-      }
-
-      stapi->make_current(stapi, ctx->st, draw->stfb, read->stfb);
+   if (ctx->dPriv != driDrawPriv) {
+      ctx->dPriv = driDrawPriv;
+      draw->texture_stamp = driDrawPriv->lastStamp - 1;
    }
-   else {
-      stapi->make_current(stapi, NULL, NULL, NULL);
+   if (ctx->rPriv != driReadPriv) {
+      ctx->rPriv = driReadPriv;
+      read->texture_stamp = driReadPriv->lastStamp - 1;
    }
 
+   stapi->make_current(stapi, ctx->st, &draw->base, &read->base);
+
    return GL_TRUE;
 }
 
 struct dri_context *
-dri_get_current(void)
+dri_get_current(__DRIscreen *sPriv)
 {
-   struct st_api *stapi = dri_get_st_api();
+   struct dri_screen *screen = dri_screen(sPriv);
+   struct st_api *stapi = screen->st_api;
    struct st_context_iface *st;
 
    st = stapi->get_current(stapi);