haiku/swrast: Inherit gl_config, fix flush
authorAlexander von Gluck IV <kallisti5@unixzen.com>
Wed, 13 Nov 2013 23:51:00 +0000 (23:51 +0000)
committerAlexander von Gluck IV <kallisti5@unixzen.com>
Thu, 14 Nov 2013 18:33:03 +0000 (12:33 -0600)
* Inherit gl_context so we always have access to it
* Thanks curro for the idea.
* Last Haiku cannidate for 10.0.0

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/mesa/drivers/haiku/swrast/SoftwareRast.cpp
src/mesa/drivers/haiku/swrast/SoftwareRast.h

index 52e8e5ede5751fd1fdd7523a7421077f87754b2b..df697e4a3842645e082e3e53b16c283dbadf7d63 100644 (file)
@@ -72,7 +72,6 @@ MesaSoftwareRast::MesaSoftwareRast(BGLView* view, ulong options,
        fDirectModeEnabled(false),
        fInfo(NULL),
        fInfoLocker("info locker"),
-       fContext(NULL),
        fVisual(NULL),
        fFrameBuffer(NULL),
        fFrontRenderBuffer(NULL),
@@ -114,34 +113,27 @@ MesaSoftwareRast::MesaSoftwareRast(BGLView* view, ulong options,
        functions.Flush = _Flush;
 
        // create core context
-       fContext = _mesa_create_context(API_OPENGL_COMPAT, fVisual, NULL,
+       // We inherit gl_context to this class
+       _mesa_initialize_context(this, API_OPENGL_COMPAT, fVisual, NULL,
                &functions);
 
-       if (!fContext) {
-               ERROR("%s: Failed to create Mesa context!\n", __func__);
-               _mesa_destroy_visual(fVisual);
-               return;
-       }
-
-       fContext->DriverCtx = (void*)this;
-
        /* Initialize the software rasterizer and helper modules. */
-       _swrast_CreateContext(fContext);
-       _vbo_CreateContext(fContext);
-       _tnl_CreateContext(fContext);
-       _swsetup_CreateContext(fContext);
-       _swsetup_Wakeup(fContext);
+       _swrast_CreateContext(this);
+       _vbo_CreateContext(this);
+       _tnl_CreateContext(this);
+       _swsetup_CreateContext(this);
+       _swsetup_Wakeup(this);
 
        // Use default TCL pipeline
-       TNL_CONTEXT(fContext)->Driver.RunPipeline = _tnl_run_pipeline;
+       TNL_CONTEXT(this)->Driver.RunPipeline = _tnl_run_pipeline;
 
-       _mesa_meta_init(fContext);
-       _mesa_enable_sw_extensions(fContext);
+       _mesa_meta_init(this);
+       _mesa_enable_sw_extensions(this);
 
-       _mesa_compute_version(fContext);
+       _mesa_compute_version(this);
 
-       _mesa_initialize_dispatch_tables(fContext);
-       _mesa_initialize_vbo_vtxfmt(fContext);
+       _mesa_initialize_dispatch_tables(this);
+       _mesa_initialize_vbo_vtxfmt(this);
 
        // create core framebuffer
        fFrameBuffer = _mesa_create_framebuffer(fVisual);
@@ -199,13 +191,13 @@ MesaSoftwareRast::MesaSoftwareRast(BGLView* view, ulong options,
 MesaSoftwareRast::~MesaSoftwareRast()
 {
        CALLED();
-       _swsetup_DestroyContext(fContext);
-       _swrast_DestroyContext(fContext);
-       _tnl_DestroyContext(fContext);
-       _vbo_DestroyContext(fContext);
+       _swsetup_DestroyContext(this);
+       _swrast_DestroyContext(this);
+       _tnl_DestroyContext(this);
+       _vbo_DestroyContext(this);
        _mesa_destroy_visual(fVisual);
        _mesa_destroy_framebuffer(fFrameBuffer);
-       _mesa_destroy_context(fContext);
+       _mesa_destroy_context(this);
 
        free(fInfo);
        free(fFrameBuffer);
@@ -220,7 +212,7 @@ MesaSoftwareRast::LockGL()
        CALLED();
        BGLRenderer::LockGL();
 
-       _mesa_make_current(fContext, fFrameBuffer, fFrameBuffer);
+       _mesa_make_current(this, fFrameBuffer, fFrameBuffer);
 
        color_space colorSpace = BScreen(GLView()->Window()).ColorSpace();
 
@@ -250,7 +242,7 @@ void
 MesaSoftwareRast::UnlockGL()
 {
        CALLED();
-       _mesa_make_current(fContext, NULL, NULL);
+       _mesa_make_current(this, NULL, NULL);
        BGLRenderer::UnlockGL();
 }
 
@@ -264,7 +256,7 @@ MesaSoftwareRast::SwapBuffers(bool VSync)
                return;
 
        if (fVisual->doubleBufferMode)
-               _mesa_notifySwapBuffers(fContext);
+               _mesa_notifySwapBuffers(this);
 
        if (!fDirectModeEnabled || fInfo == NULL) {
                if (GLView()->LockLooperWithTimeout(1000) == B_OK) {
@@ -416,7 +408,7 @@ MesaSoftwareRast::_CheckResize(GLuint newWidth, GLuint newHeight)
                return;
        }
 
-       _mesa_resize_framebuffer(fContext, fFrameBuffer, newWidth, newHeight);
+       _mesa_resize_framebuffer(this, fFrameBuffer, newWidth, newHeight);
        fHeight = newHeight;
        fWidth = newWidth;
 
@@ -546,17 +538,15 @@ void
 MesaSoftwareRast::_Flush(gl_context* ctx)
 {
        CALLED();
-       // TODO: We may want to add the void* DriverCtx back into mtypes.h for
-       // gl_context someday...
-       #if 0
-       MesaSoftwareRast* driverContext = (MesaSoftwareRast*)ctx->DriverCtx;
+       MesaSoftwareRast* driverContext = static_cast<MesaSoftwareRast*>(ctx);
+
+       //MesaSoftwareRast* driverContext = (MesaSoftwareRast*)ctx->DriverCtx;
        if ((driverContext->fOptions & BGL_DOUBLE) == 0) {
                // TODO: SwapBuffers() can call _CopyToDirect(), which should
                // be always called with with the BGLView drawlocked.
                // This is not always the case if called from here.
                driverContext->SwapBuffers();
        }
-       #endif
 }
 
 
index 8ef84938d6c2dc25ea75d12510fd5f73456e3204..8f0f01848634da8bcf1490092d94ebe2e73b1fe8 100644 (file)
@@ -24,7 +24,7 @@ extern "C" {
 }
 
 
-class MesaSoftwareRast : public BGLRenderer {
+class MesaSoftwareRast : public BGLRenderer, public gl_context {
 public:
                                                        MesaSoftwareRast(BGLView* view,
                                                                ulong bgl_options,
@@ -79,7 +79,6 @@ private:
                        BLocker                 fInfoLocker;
                        ulong                   fOptions;
 
-                       gl_context*             fContext;
                        gl_config*              fVisual;
 
                        struct gl_framebuffer* fFrameBuffer;