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; }
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; }