summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/glamo/glamo_context.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2009-02-10 22:59:47 +0000
committerMartin Jansa <Martin.Jansa@gmail.com>2010-02-18 15:39:21 +0100
commit013b2daf84322703a8270491a8eaa8697aaf643f (patch)
treeba9df9287c4a6dc5bf84f2a2ff81cb9bc36a5441 /src/mesa/drivers/dri/glamo/glamo_context.c
parent260be54c67eb77b4da9550f70c14a6aa33c95768 (diff)
Context stuff
Diffstat (limited to 'src/mesa/drivers/dri/glamo/glamo_context.c')
-rw-r--r--src/mesa/drivers/dri/glamo/glamo_context.c154
1 files changed, 154 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/glamo/glamo_context.c b/src/mesa/drivers/dri/glamo/glamo_context.c
new file mode 100644
index 0000000000..627f8f56a0
--- /dev/null
+++ b/src/mesa/drivers/dri/glamo/glamo_context.c
@@ -0,0 +1,154 @@
+/*
+ * Direct Rendering Support for SMedia Glamo 336x/337x
+ *
+ * (c) 2009 Thomas White <taw@bitwiz.org.uk>
+ * Roughly based on sis_context.c (c) 2003 Eric Anholt
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "dri_util.h"
+#include "utils.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "drivers/common/driverfuncs.h"
+#include "vbo/vbo.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "glamo_context.h"
+#include "glamo_screen.h"
+
+
+GLboolean glamoCreateContext(const __GLcontextModes *glVisual,
+ __DRIcontext *driContextPriv,
+ void *sharedContextPrivate)
+{
+ GLcontext *ctx, *shareCtx;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ glamoContextPtr context;
+ glamoScreenPtr glamoScreen;
+ struct dd_function_table functions;
+
+ context = (glamoContextPtr)CALLOC(sizeof(*context));
+ if ( context == NULL ) return GL_FALSE;
+
+ _mesa_init_driver_functions(&functions);
+
+ /* Allocate the Mesa context */
+ if ( sharedContextPrivate )
+ shareCtx = ((glamoContextPtr)sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ context->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *)context);
+ if ( context->glCtx == NULL ) {
+ FREE(context);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = context;
+ ctx = context->glCtx;
+
+ glamoScreen = context->glamoScreen = (glamoScreenPtr)sPriv->private;
+
+ context->driContext = driContextPriv;
+ context->driScreen = sPriv;
+ context->driDrawable = NULL;
+ context->driFd = sPriv->fd;
+
+ /* Parse configuration files */
+ driParseConfigFiles(&context->optionCache, &glamoScreen->optionCache,
+ glamoScreen->driScreen->myNum, "glamo");
+
+ /* Initialize the software rasterizer and helper modules. */
+ _swrast_CreateContext( ctx );
+ _vbo_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ _swrast_allow_pixel_fog( ctx, GL_TRUE );
+ _swrast_allow_vertex_fog( ctx, GL_FALSE );
+ _tnl_allow_pixel_fog( ctx, GL_TRUE );
+ _tnl_allow_vertex_fog( ctx, GL_FALSE );
+
+ return GL_TRUE;
+}
+
+
+void glamoDestroyContext(__DRIcontext *driContextPriv)
+{
+ glamoContextPtr context;
+
+ context = (glamoContextPtr)driContextPriv->driverPrivate;
+ assert(context != NULL);
+
+ if ( context != NULL ) {
+
+ _swsetup_DestroyContext(context->glCtx);
+ _tnl_DestroyContext(context->glCtx);
+ _vbo_DestroyContext(context->glCtx);
+ _swrast_DestroyContext(context->glCtx);
+
+ _mesa_destroy_context(context->glCtx);
+
+ }
+
+ FREE(context);
+}
+
+
+GLboolean glamoMakeCurrent(__DRIcontext *driContextPriv,
+ __DRIdrawable *driDrawPriv,
+ __DRIdrawable *driReadPriv)
+{
+ if ( driContextPriv ) {
+
+ GET_CURRENT_CONTEXT(ctx);
+ glamoContextPtr oldGlamoCtx;
+ glamoContextPtr newGlamoCtx;
+ struct gl_framebuffer *drawBuffer, *readBuffer;
+
+ oldGlamoCtx = ctx ? GLAMO_CONTEXT(ctx) : NULL;
+ newGlamoCtx = (glamoContextPtr)driContextPriv->driverPrivate;
+
+ if ( newGlamoCtx != oldGlamoCtx) {
+ newGlamoCtx->GlobalFlag = GFLAG_ALL;
+ }
+
+ newGlamoCtx->driDrawable = driDrawPriv;
+
+ drawBuffer = (GLframebuffer *)driDrawPriv->driverPrivate;
+ readBuffer = (GLframebuffer *)driReadPriv->driverPrivate;
+
+ _mesa_make_current(newGlamoCtx->glCtx, drawBuffer, readBuffer);
+
+ } else {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ return GL_TRUE;
+}
+
+
+GLboolean glamoUnbindContext(__DRIcontext *driContextPriv)
+{
+ return GL_TRUE;
+}
+
+/* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */