swrast: Legacy renderer fixes / cleanup
* Fix red teapot on mouseover. This was due to extra buffer swap. * Fix crash on double buffer usage. * We still use single buffer at the moment as Haiku has a software cursor that gets overwritten by GL apps
This commit is contained in:
@@ -388,14 +388,7 @@ MesaSoftwareRenderer::LockGL()
|
|||||||
_SetupRenderBuffer(fBackRenderBuffer, fColorSpace);
|
_SetupRenderBuffer(fBackRenderBuffer, fColorSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fBitmap && fNewWidth == fWidth
|
_CheckResize();
|
||||||
&& fNewHeight == fHeight)
|
|
||||||
return;
|
|
||||||
|
|
||||||
fWidth = fNewWidth;
|
|
||||||
fHeight = fNewHeight;
|
|
||||||
|
|
||||||
_AllocateBitmap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -404,9 +397,6 @@ MesaSoftwareRenderer::UnlockGL()
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
_mesa_make_current(fContext, NULL, NULL);
|
_mesa_make_current(fContext, NULL, NULL);
|
||||||
if ((fOptions & BGL_DOUBLE) == 0) {
|
|
||||||
SwapBuffers();
|
|
||||||
}
|
|
||||||
BGLRenderer::UnlockGL();
|
BGLRenderer::UnlockGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,6 +550,25 @@ MesaSoftwareRenderer::FrameResized(float width, float height)
|
|||||||
BAutolock lock(fInfoLocker);
|
BAutolock lock(fInfoLocker);
|
||||||
fNewWidth = (GLuint)width;
|
fNewWidth = (GLuint)width;
|
||||||
fNewHeight = (GLuint)height;
|
fNewHeight = (GLuint)height;
|
||||||
|
_CheckResize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MesaSoftwareRenderer::_CheckResize()
|
||||||
|
{
|
||||||
|
CALLED();
|
||||||
|
|
||||||
|
if (fBitmap && fNewWidth == fWidth
|
||||||
|
&& fNewHeight == fHeight) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fHeight = fNewHeight;
|
||||||
|
fWidth = fNewWidth;
|
||||||
|
_mesa_resize_framebuffer(fContext, &fFrameBuffer->base, fWidth, fHeight);
|
||||||
|
|
||||||
|
_AllocateBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -575,6 +584,7 @@ MesaSoftwareRenderer::_AllocateBitmap()
|
|||||||
TRACE("%s: Cannot allocate bitmap < 1x1!\n", __func__);
|
TRACE("%s: Cannot allocate bitmap < 1x1!\n", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BRect rect(0.0, 0.0, fWidth - 1, fHeight - 1);
|
BRect rect(0.0, 0.0, fWidth - 1, fHeight - 1);
|
||||||
fBitmap = new BBitmap(rect, fColorSpace);
|
fBitmap = new BBitmap(rect, fColorSpace);
|
||||||
for (uint i = 0; i < fHeight; i++) {
|
for (uint i = 0; i < fHeight; i++) {
|
||||||
@@ -582,13 +592,12 @@ MesaSoftwareRenderer::_AllocateBitmap()
|
|||||||
+ i * fBitmap->BytesPerRow());
|
+ i * fBitmap->BytesPerRow());
|
||||||
}
|
}
|
||||||
|
|
||||||
_mesa_resize_framebuffer(fContext, &fFrameBuffer->base, fWidth, fHeight);
|
|
||||||
fFrontRenderBuffer->base.Data = fBitmap->Bits();
|
|
||||||
fFrontRenderBuffer->size = fBitmap->BitsLength();
|
fFrontRenderBuffer->size = fBitmap->BitsLength();
|
||||||
if (fVisual->doubleBufferMode)
|
if (fVisual->doubleBufferMode)
|
||||||
fBackRenderBuffer->size = fBitmap->BitsLength();
|
fBackRenderBuffer->size = fBitmap->BitsLength();
|
||||||
fFrameBuffer->width = fWidth;
|
TRACE("%s: Bitmap Size: %" B_PRIu32 "\n", __func__, fBitmap->BitsLength());
|
||||||
fFrameBuffer->height = fHeight;
|
|
||||||
|
fFrontRenderBuffer->base.Data = fBitmap->Bits();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -727,10 +736,16 @@ MesaSoftwareRenderer::_BackRenderbufferStorage(gl_context* ctx,
|
|||||||
struct gl_renderbuffer* render, GLenum internalFormat,
|
struct gl_renderbuffer* render, GLenum internalFormat,
|
||||||
GLuint width, GLuint height)
|
GLuint width, GLuint height)
|
||||||
{
|
{
|
||||||
|
CALLED();
|
||||||
struct msr_renderbuffer* mrb = msr_renderbuffer(render);
|
struct msr_renderbuffer* mrb = msr_renderbuffer(render);
|
||||||
|
|
||||||
free(render->Data);
|
free(render->Data);
|
||||||
_FrontRenderbufferStorage(ctx, render, internalFormat, width, height);
|
_FrontRenderbufferStorage(ctx, render, internalFormat, width, height);
|
||||||
|
|
||||||
|
if (mrb->size)
|
||||||
|
ERROR("%s: suspicious malloc of 0 bytes.\n", __func__);
|
||||||
render->Data = malloc(mrb->size);
|
render->Data = malloc(mrb->size);
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#ifndef MESASOFTWARERENDERER_H
|
#ifndef MESASOFTWARERENDERER_H
|
||||||
#define MESASOFTWARERENDERER_H
|
#define MESASOFTWARERENDERER_H
|
||||||
|
|
||||||
|
|
||||||
#include "GLRenderer.h"
|
#include "GLRenderer.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -91,6 +92,7 @@ private:
|
|||||||
static const GLubyte* _GetString(gl_context* ctx, GLenum name);
|
static const GLubyte* _GetString(gl_context* ctx, GLenum name);
|
||||||
static void _Viewport(gl_context* ctx, GLint x, GLint y,
|
static void _Viewport(gl_context* ctx, GLint x, GLint y,
|
||||||
GLsizei w, GLsizei h);
|
GLsizei w, GLsizei h);
|
||||||
|
void _CheckResize();
|
||||||
static void _UpdateState(gl_context* ctx, GLuint newState);
|
static void _UpdateState(gl_context* ctx, GLuint newState);
|
||||||
static void _ClearFront(gl_context* ctx);
|
static void _ClearFront(gl_context* ctx);
|
||||||
static GLboolean _FrontRenderbufferStorage(gl_context* ctx,
|
static GLboolean _FrontRenderbufferStorage(gl_context* ctx,
|
||||||
|
|||||||
Reference in New Issue
Block a user