135c4bbdfSmrg/* 235c4bbdfSmrg * Copyright © 2013 Intel Corporation 335c4bbdfSmrg * 435c4bbdfSmrg * Permission is hereby granted, free of charge, to any person obtaining a 535c4bbdfSmrg * copy of this software and associated documentation files (the "Software"), 635c4bbdfSmrg * to deal in the Software without restriction, including without limitation 735c4bbdfSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 835c4bbdfSmrg * and/or sell copies of the Software, and to permit persons to whom the 935c4bbdfSmrg * Software is furnished to do so, subject to the following conditions: 1035c4bbdfSmrg * 1135c4bbdfSmrg * The above copyright notice and this permission notice (including the next 1235c4bbdfSmrg * paragraph) shall be included in all copies or substantial portions of the 1335c4bbdfSmrg * Software. 1435c4bbdfSmrg * 1535c4bbdfSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1635c4bbdfSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1735c4bbdfSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1835c4bbdfSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1935c4bbdfSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2035c4bbdfSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 2135c4bbdfSmrg * IN THE SOFTWARE. 2235c4bbdfSmrg */ 2335c4bbdfSmrg 2435c4bbdfSmrg#include <epoxy/glx.h> 2535c4bbdfSmrg#include "glamor_context.h" 2635c4bbdfSmrg 2735c4bbdfSmrg/** 2835c4bbdfSmrg * @file glamor_glx.c 2935c4bbdfSmrg * 3035c4bbdfSmrg * GLX context management for glamor. 3135c4bbdfSmrg * 3235c4bbdfSmrg * This has to be kept separate from the server sources because of 3335c4bbdfSmrg * Xlib's conflicting definition of CARD32 and similar typedefs. 3435c4bbdfSmrg */ 3535c4bbdfSmrg 3635c4bbdfSmrgstatic void 3735c4bbdfSmrgglamor_glx_make_current(struct glamor_context *glamor_ctx) 3835c4bbdfSmrg{ 3935c4bbdfSmrg /* There's only a single global dispatch table in Mesa. EGL, GLX, 4035c4bbdfSmrg * and AIGLX's direct dispatch table manipulation don't talk to 4135c4bbdfSmrg * each other. We need to set the context to NULL first to avoid 4235c4bbdfSmrg * GLX's no-op context change fast path when switching back to 4335c4bbdfSmrg * GLX. 4435c4bbdfSmrg */ 4535c4bbdfSmrg glXMakeCurrent(glamor_ctx->display, None, None); 4635c4bbdfSmrg 4735c4bbdfSmrg glXMakeCurrent(glamor_ctx->display, glamor_ctx->drawable_xid, 4835c4bbdfSmrg glamor_ctx->ctx); 4935c4bbdfSmrg} 5035c4bbdfSmrg 5135c4bbdfSmrg 5235c4bbdfSmrgBool 5335c4bbdfSmrgglamor_glx_screen_init(struct glamor_context *glamor_ctx) 5435c4bbdfSmrg{ 5535c4bbdfSmrg glamor_ctx->ctx = glXGetCurrentContext(); 5635c4bbdfSmrg if (!glamor_ctx->ctx) 5735c4bbdfSmrg return False; 5835c4bbdfSmrg 5935c4bbdfSmrg glamor_ctx->display = glXGetCurrentDisplay(); 6035c4bbdfSmrg if (!glamor_ctx->display) 6135c4bbdfSmrg return False; 6235c4bbdfSmrg 6335c4bbdfSmrg glamor_ctx->drawable_xid = glXGetCurrentDrawable(); 6435c4bbdfSmrg 6535c4bbdfSmrg glamor_ctx->make_current = glamor_glx_make_current; 6635c4bbdfSmrg 6735c4bbdfSmrg return True; 6835c4bbdfSmrg} 69