コード例 #1
0
ファイル: st_manager.c プロジェクト: james026yeah/mesa
static boolean
st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi,
                    struct st_framebuffer_iface *stdrawi,
                    struct st_framebuffer_iface *streadi)
{
   struct st_context *st = (struct st_context *) stctxi;
   struct st_framebuffer *stdraw, *stread;
   boolean ret;

   _glapi_check_multithread();

   if (st) {
      /* reuse or create the draw fb */
      stdraw = st_framebuffer_reuse_or_create(st->ctx->WinSysDrawBuffer,
                                              stdrawi);
      if (streadi != stdrawi) {
         /* do the same for the read fb */
         stread = st_framebuffer_reuse_or_create(st->ctx->WinSysReadBuffer,
                                                 streadi);
      }
      else {
         stread = NULL;
         /* reuse the draw fb for the read fb */
         if (stdraw)
            st_framebuffer_reference(&stread, stdraw);
      }

      if (stdraw && stread) {
         st_framebuffer_validate(stdraw, st);
         if (stread != stdraw)
            st_framebuffer_validate(stread, st);

         ret = _mesa_make_current(st->ctx, &stdraw->Base, &stread->Base);

         st->draw_stamp = stdraw->stamp - 1;
         st->read_stamp = stread->stamp - 1;
         st_context_validate(st, stdraw, stread);
      }
      else {
         struct gl_framebuffer *incomplete = _mesa_get_incomplete_framebuffer();
         ret = _mesa_make_current(st->ctx, incomplete, incomplete);
      }

      st_framebuffer_reference(&stdraw, NULL);
      st_framebuffer_reference(&stread, NULL);
   }
   else {
      ret = _mesa_make_current(NULL, NULL, NULL);
   }

   return ret;
}
コード例 #2
0
ファイル: st_manager.c プロジェクト: mlankhorst/Mesa-3D
static struct st_framebuffer *
st_framebuffer_reuse_or_create(struct gl_framebuffer *fb,
                               struct st_framebuffer_iface *stfbi)
{
   struct st_framebuffer *cur = st_ws_framebuffer(fb), *stfb = NULL;

   if (cur && cur->iface == stfbi) {
      /* reuse the current stfb */
      st_framebuffer_reference(&stfb, cur);
   }
   else {
      /* create a new one */
      stfb = st_framebuffer_create(stfbi);
   }

   return stfb;
}
コード例 #3
0
ファイル: st_manager.c プロジェクト: james026yeah/mesa
static struct st_framebuffer *
st_framebuffer_reuse_or_create(struct gl_framebuffer *fb,
                               struct st_framebuffer_iface *stfbi)
{
   struct st_framebuffer *cur = st_ws_framebuffer(fb), *stfb = NULL;

   /* dummy framebuffers cant be used as st_framebuffer */
   if (cur && &cur->Base != _mesa_get_incomplete_framebuffer() &&
       cur->iface == stfbi) {
      /* reuse the current stfb */
      st_framebuffer_reference(&stfb, cur);
   }
   else {
      /* create a new one */
      stfb = st_framebuffer_create(stfbi);
   }

   return stfb;
}
コード例 #4
0
ファイル: st_manager.c プロジェクト: iquiw/xsrc
static boolean
st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi,
                    struct st_framebuffer_iface *stdrawi,
                    struct st_framebuffer_iface *streadi)
{
   struct st_context *st = (struct st_context *) stctxi;
   struct st_framebuffer *stdraw, *stread;
   boolean ret;

   _glapi_check_multithread();

   if (st) {
      /* reuse or create the draw fb */
      stdraw = st_framebuffer_reuse_or_create(st->ctx->WinSysDrawBuffer,
                                              stdrawi);
      if (streadi != stdrawi) {
         /* do the same for the read fb */
         stread = st_framebuffer_reuse_or_create(st->ctx->WinSysReadBuffer,
                                                 streadi);
      }
      else {
         stread = NULL;
         /* reuse the draw fb for the read fb */
         if (stdraw)
            st_framebuffer_reference(&stread, stdraw);
      }

      if (stdraw && stread) {
         if (stctxi != st_api_get_current(stapi)) {
            p_atomic_set(&stdraw->revalidate, TRUE);
            p_atomic_set(&stread->revalidate, TRUE);
         }
         st_framebuffer_validate(stdraw, st);
         if (stread != stdraw)
            st_framebuffer_validate(stread, st);

         /* modify the draw/read buffers of the context */
         if (stdraw->iface) {
            st_visual_to_default_buffer(stdraw->iface->visual,
                  &st->ctx->Color.DrawBuffer[0], NULL);
         }
         if (stread->iface) {
            st_visual_to_default_buffer(stread->iface->visual,
                  &st->ctx->Pixel.ReadBuffer, NULL);
         }

         ret = _mesa_make_current(st->ctx, &stdraw->Base, &stread->Base);
      }
      else {
         struct gl_framebuffer *incomplete = _mesa_get_incomplete_framebuffer();
         ret = _mesa_make_current(st->ctx, incomplete, incomplete);
      }

      st_framebuffer_reference(&stdraw, NULL);
      st_framebuffer_reference(&stread, NULL);
   }
   else {
      ret = _mesa_make_current(NULL, NULL, NULL);
   }

   return ret;
}