window_bounds are now coordinates of the view on the screen (was the window before)
this eases dramatically the drawing of the clip from the buffer
now allocates m_clip_info whenever needed as some apps call EnableDirectMode() after DirectConnected(), ie GLTeapot.
MesaSoftwareRenderer:
implemented DirectConnected() support in Mesa Software Renderer
tested with GLTeapot on QEmu, B_RGB16 mode only


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20797 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2007-04-24 17:37:51 +00:00
parent f8486a0219
commit 7cfdfca2e2
3 changed files with 289 additions and 173 deletions
@@ -4,7 +4,7 @@
*
* Authors:
* Jérôme Duval, [email protected]
* Philippe Houdoin, [email protected]
* Philippe Houdoin, [email protected]
*/
/*
* Mesa 3-D graphics library
@@ -16,57 +16,59 @@
#define CALLED() //printf("CALLED %s\n",__PRETTY_FUNCTION__)
#include "MesaSoftwareRenderer.h"
#include <GraphicsDefs.h>
#include <Screen.h>
extern "C" {
#include "array_cache/acache.h"
#include "extensions.h"
#include "drivers/common/driverfuncs.h"
#include "main/colormac.h"
#include "main/buffers.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "main/state.h"
#include "main/version.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
#include "array_cache/acache.h"
#include "extensions.h"
#include "drivers/common/driverfuncs.h"
#include "main/colormac.h"
#include "main/buffers.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "main/state.h"
#include "main/version.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
#if defined(USE_X86_ASM)
#include "x86/common_x86_asm.h"
#endif
#if defined(USE_X86_ASM)
#include "x86/common_x86_asm.h"
#endif
#if defined(USE_PPC_ASM)
#include "ppc/common_ppc_features.h"
#endif
#if defined(USE_PPC_ASM)
#include "ppc/common_ppc_features.h"
#endif
}
extern const char * color_space_name(color_space space);
// BeOS component ordering for B_RGBA32 bitmap format
#if B_HOST_IS_LENDIAN
#define BE_RCOMP 2
#define BE_GCOMP 1
#define BE_BCOMP 0
#define BE_ACOMP 3
#define BE_RCOMP 2
#define BE_GCOMP 1
#define BE_BCOMP 0
#define BE_ACOMP 3
#define PACK_B_RGBA32(color) (color[BCOMP] | (color[GCOMP] << 8) | \
#define PACK_B_RGBA32(color) (color[BCOMP] | (color[GCOMP] << 8) | \
(color[RCOMP] << 16) | (color[ACOMP] << 24))
#define PACK_B_RGB32(color) (color[BCOMP] | (color[GCOMP] << 8) | \
#define PACK_B_RGB32(color) (color[BCOMP] | (color[GCOMP] << 8) | \
(color[RCOMP] << 16) | 0xFF000000)
#else
// Big Endian B_RGBA32 bitmap format
#define BE_RCOMP 1
#define BE_GCOMP 2
#define BE_BCOMP 3
#define BE_ACOMP 0
// Big Endian B_RGBA32 bitmap format
#define BE_RCOMP 1
#define BE_GCOMP 2
#define BE_BCOMP 3
#define BE_ACOMP 0
#define PACK_B_RGBA32(color) (color[ACOMP] | (color[RCOMP] << 8) | \
#define PACK_B_RGBA32(color) (color[ACOMP] | (color[RCOMP] << 8) | \
(color[GCOMP] << 16) | (color[BCOMP] << 24))
#define PACK_B_RGB32(color) ((color[RCOMP] << 8) | (color[GCOMP] << 16) | \
#define PACK_B_RGB32(color) ((color[RCOMP] << 8) | (color[GCOMP] << 16) | \
(color[BCOMP] << 24) | 0xFF000000)
#endif
@@ -99,8 +101,28 @@ extern const char * color_space_name(color_space space);
DST[ACOMP] = SRC[BE_ACOMP]
#include "swrast/s_spantemp.h"
/* 16-bit RGB */
#define NAME(PREFIX) PREFIX##_RGB16
#define RB_TYPE GLubyte
#define SPAN_VARS \
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \
GLushort *P = (GLushort *) (((GLubyte **) mr->GetRows())[Y] + (X) * 2)
#define INC_PIXEL_PTR(P) P += 1
#define STORE_PIXEL(DST, X, Y, VALUE) \
*DST = ( (((VALUE[RCOMP]) & 0xf8) << 8) | \
(((VALUE[GCOMP]) & 0xfc) << 3) | \
(((VALUE[BCOMP]) ) >> 3) )
#define FETCH_PIXEL(DST, SRC) \
DST[RCOMP] = ((*SRC & 0xf800) >> 8); \
DST[GCOMP] = ((*SRC & 0x07e0) >> 3); \
DST[BCOMP] = ((*SRC & 0x001f) << 3); \
DST[ACOMP] = 0xff
#include "swrast/s_spantemp.h"
extern "C" _EXPORT BGLRenderer *
instanciate_gl_renderer(BGLView *view, ulong options, BGLDispatcher *dispatcher)
instanciate_gl_renderer(BGLView *view, ulong options, BGLDispatcher *dispatcher)
{
return new MesaSoftwareRenderer(view, options, dispatcher);
}
@@ -109,9 +131,12 @@ instanciate_gl_renderer(BGLView *view, ulong options, BGLDispatcher *dispatcher)
MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView *view, ulong options, BGLDispatcher *dispatcher)
: BGLRenderer(view, options, dispatcher),
fBitmap(NULL),
fDirectModeEnabled(false),
fInfo(NULL),
fContext(NULL),
fVisual(NULL),
fFrameBuffer(NULL)
fFrameBuffer(NULL),
fColorSpace(B_NO_COLOR_SPACE)
{
CALLED();
@@ -141,19 +166,19 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView *view, ulong options, BGLDisp
//fOptions = options | BGL_INDIRECT;
struct dd_function_table functions;
fVisual = _mesa_create_visual( rgbFlag, dblFlag, stereoFlag, red, green, blue, alpha,
index, depth, stencil, accum, accum, accum, alpha ? accum : 0, 1);
fVisual = _mesa_create_visual(rgbFlag, dblFlag, stereoFlag, red, green, blue, alpha,
index, depth, stencil, accum, accum, accum, alpha ? accum : 0, 1);
// Initialize device driver function table
_mesa_init_driver_functions(&functions);
functions.GetString = GetString;
functions.UpdateState = UpdateState;
functions.Clear = Clear;
functions.ClearIndex = ClearIndex;
functions.ClearColor = ClearColor;
functions.Error = Error;
functions.Viewport = Viewport;
//functions.Clear = Clear;
//functions.ClearIndex = ClearIndex;
//functions.ClearColor = ClearColor;
functions.Error = Error;
functions.Viewport = Viewport;
// create core context
fContext = _mesa_create_context(fVisual, NULL, &functions, this);
@@ -180,26 +205,39 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView *view, ulong options, BGLDisp
fRenderBuffer->Data = NULL;
fRenderBuffer->AllocStorage = RenderbufferStorage;
fRenderBuffer->GetRow = get_row_RGBA8;
fRenderBuffer->GetValues = get_values_RGBA8;
fRenderBuffer->PutRow = put_row_RGBA8;
fRenderBuffer->PutRowRGB = put_row_rgb_RGBA8;
fRenderBuffer->PutMonoRow = put_mono_row_RGBA8;
fRenderBuffer->PutValues = put_values_RGBA8;
fRenderBuffer->PutMonoValues = put_mono_values_RGBA8;
/*switch (fColorSpace) {
case B_RGBA32:
fRenderBuffer->GetRow = get_row_RGBA8;
fRenderBuffer->GetValues = get_values_RGBA8;
fRenderBuffer->PutRow = put_row_RGBA8;
fRenderBuffer->PutRowRGB = put_row_rgb_RGBA8;
fRenderBuffer->PutMonoRow = put_mono_row_RGBA8;
fRenderBuffer->PutValues = put_values_RGBA8;
fRenderBuffer->PutMonoValues = put_mono_values_RGBA8;
break;
case B_RGB16:
fRenderBuffer->GetRow = get_row_RGB16;
fRenderBuffer->GetValues = get_values_RGB16;
fRenderBuffer->PutRow = put_row_RGB16;
fRenderBuffer->PutRowRGB = put_row_rgb_RGB16;
fRenderBuffer->PutMonoRow = put_mono_row_RGB16;
fRenderBuffer->PutValues = put_values_RGB16;
fRenderBuffer->PutMonoValues = put_mono_values_RGB16;
break;
}*/
_mesa_add_renderbuffer(fFrameBuffer, BUFFER_FRONT_LEFT, fRenderBuffer);
_mesa_add_soft_renderbuffers(fFrameBuffer,
GL_FALSE,
fVisual->haveDepthBuffer,
fVisual->haveStencilBuffer,
fVisual->haveAccumBuffer,
alphaFlag,
GL_FALSE );
GL_FALSE,
fVisual->haveDepthBuffer,
fVisual->haveStencilBuffer,
fVisual->haveAccumBuffer,
alphaFlag,
GL_FALSE);
// Use default TCL pipeline
TNL_CONTEXT( fContext )->Driver.RunPipeline = _tnl_run_pipeline;
TNL_CONTEXT(fContext)->Driver.RunPipeline = _tnl_run_pipeline;
_mesa_enable_sw_extensions(fContext);
_mesa_enable_1_3_extensions(fContext);
@@ -235,16 +273,43 @@ MesaSoftwareRenderer::LockGL()
_mesa_make_current(fContext, fFrameBuffer, fFrameBuffer);
BRect b = GLView()->Bounds();
color_space cs = B_RGBA32;
if (fDirectModeEnabled && fInfo != NULL) {
cs = BScreen(GLView()->Window()).ColorSpace();
}
uint32 width = b.IntegerWidth() + 1;
uint32 height = b.IntegerHeight() + 1;
if (width != fWidth || height != fHeight || !fBitmap) {
if (width != fWidth || height != fHeight || !fBitmap || cs != fColorSpace) {
if (cs != fColorSpace)
switch (cs) {
case B_RGBA32:
fRenderBuffer->GetRow = get_row_RGBA8;
fRenderBuffer->GetValues = get_values_RGBA8;
fRenderBuffer->PutRow = put_row_RGBA8;
fRenderBuffer->PutRowRGB = put_row_rgb_RGBA8;
fRenderBuffer->PutMonoRow = put_mono_row_RGBA8;
fRenderBuffer->PutValues = put_values_RGBA8;
fRenderBuffer->PutMonoValues = put_mono_values_RGBA8;
break;
case B_RGB16:
fRenderBuffer->GetRow = get_row_RGB16;
fRenderBuffer->GetValues = get_values_RGB16;
fRenderBuffer->PutRow = put_row_RGB16;
fRenderBuffer->PutRowRGB = put_row_rgb_RGB16;
fRenderBuffer->PutMonoRow = put_mono_row_RGB16;
fRenderBuffer->PutValues = put_values_RGB16;
fRenderBuffer->PutMonoValues = put_mono_values_RGB16;
break;
}
// allocate new size of back buffer bitmap
if (fBitmap)
delete fBitmap;
fColorSpace = cs;
BRect rect(0.0, 0.0, width - 1, height - 1);
fBitmap = new BBitmap(rect, B_RGBA32);
fBitmap = new BBitmap(rect, fColorSpace);
for (uint i = 0; i < height; i++)
fRowAddr[height - i - 1] = (GLvoid *) ((GLubyte *) fBitmap->Bits() + i * fBitmap->BytesPerRow());
fRowAddr[height - i - 1] = (GLvoid *)((GLubyte *) fBitmap->Bits() + i * fBitmap->BytesPerRow());
_mesa_resize_framebuffer(fContext, fFrameBuffer, width, height);
fWidth = width;
@@ -270,9 +335,27 @@ MesaSoftwareRenderer::SwapBuffers(bool VSync)
_mesa_notifySwapBuffers(fContext);
if (fBitmap) {
GLView()->LockLooper();
GLView()->DrawBitmap(fBitmap);
GLView()->UnlockLooper();
if (!fDirectModeEnabled || fInfo == NULL) {
GLView()->LockLooper();
GLView()->DrawBitmap(fBitmap);
GLView()->UnlockLooper();
} else {
uint8 bytesPerPixel = fInfo->bits_per_pixel / 8;
uint32 bytesPerRow = fBitmap->BytesPerRow();
for (int i=0; i<fInfo->clip_list_count; i++) {
clipping_rect *clip = &fInfo->clip_list[i];
int32 height = clip->bottom - clip->top + 1;
int32 bytesWidth = (clip->right - clip->left + 1) * bytesPerPixel;
uint8 *p = (uint8 *)fInfo->bits + (clip->top * fInfo->bytes_per_row) + clip->left * bytesPerPixel;
uint8 *b = (uint8 *)fBitmap->Bits() + (clip->top - fInfo->window_bounds.top) * bytesPerRow
+ (clip->left - fInfo->window_bounds.left) * bytesPerPixel;
for (int y = 0; y < height; y++) {
memcpy(p, b, bytesWidth);
p += fInfo->bytes_per_row;
b += bytesPerRow;
}
}
}
}
}
@@ -281,8 +364,9 @@ void
MesaSoftwareRenderer::Draw(BRect updateRect)
{
CALLED();
if (fBitmap)
if (fBitmap && (!fDirectModeEnabled || (fInfo == NULL)))
GLView()->DrawBitmap(fBitmap, updateRect, updateRect);
}
@@ -311,10 +395,10 @@ MesaSoftwareRenderer::CopyPixelsOut(BPoint location, BBitmap *bitmap)
uint32 *s, *d;
uint32 y;
for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) {
s = (uint32 *) (ps + y * fBitmap->BytesPerRow());
s = (uint32 *)(ps + y * fBitmap->BytesPerRow());
s += (uint32) sr.left;
d = (uint32 *) (pd + (y + (uint32) (dr.top - sr.top)) * bitmap->BytesPerRow());
d = (uint32 *)(pd + (y + (uint32)(dr.top - sr.top)) * bitmap->BytesPerRow());
d += (uint32) dr.left;
memcpy(d, s, dr.IntegerWidth() * 4);
@@ -348,10 +432,10 @@ MesaSoftwareRenderer::CopyPixelsIn(BBitmap *bitmap, BPoint location)
uint32 *s, *d;
uint32 y;
for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) {
s = (uint32 *) (ps + y * bitmap->BytesPerRow());
s = (uint32 *)(ps + y * bitmap->BytesPerRow());
s += (uint32) sr.left;
d = (uint32 *) (pd + (y + (uint32) (dr.top - sr.top)) * fBitmap->BytesPerRow());
d = (uint32 *)(pd + (y + (uint32)(dr.top - sr.top)) * fBitmap->BytesPerRow());
d += (uint32) dr.left;
memcpy(d, s, dr.IntegerWidth() * 4);
@@ -376,27 +460,27 @@ MesaSoftwareRenderer::GetString(GLcontext *ctx, GLenum name)
case GL_RENDERER: {
static char buffer[256] = { '\0' };
if (!buffer[0] ) {
if (!buffer[0]) {
// Let's build an renderer string
// TODO: add SVN revision
strncat(buffer, "Haiku's Mesa " MESA_VERSION_STRING " Software Renderer", sizeof(buffer));
// Append any CPU-specific information.
// Append any CPU-specific information.
#ifdef USE_X86_ASM
if (_mesa_x86_cpu_features)
strncat(buffer, ", optimized for x86", sizeof(buffer));
#ifdef USE_MMX_ASM
if (cpu_has_mmx)
strncat(buffer, (cpu_has_mmxext) ? "/MMX+" : "/MMX", sizeof(buffer));
#endif
#ifdef USE_3DNOW_ASM
#ifdef USE_MMX_ASM
if (cpu_has_mmx)
strncat(buffer, (cpu_has_mmxext) ? "/MMX+" : "/MMX", sizeof(buffer));
#endif
#ifdef USE_3DNOW_ASM
if (cpu_has_3dnow)
strncat(buffer, (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!", sizeof(buffer));
#endif
#ifdef USE_SSE_ASM
strncat(buffer, (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!", sizeof(buffer));
#endif
#ifdef USE_SSE_ASM
if (cpu_has_xmm)
strncat(buffer, (cpu_has_xmm2) ? "/SSE2" : "/SSE", sizeof(buffer));
#endif
strncat(buffer, (cpu_has_xmm2) ? "/SSE2" : "/SSE", sizeof(buffer));
#endif
#elif defined(USE_SPARC_ASM)
@@ -407,10 +491,10 @@ MesaSoftwareRenderer::GetString(GLcontext *ctx, GLenum name)
if (_mesa_ppc_cpu_features)
strncat(buffer, (cpu_has_64) ? ", optimized for PowerPC 64" : ", optimized for PowerPC", sizeof(buffer));
#ifdef USE_VMX_ASM
#ifdef USE_VMX_ASM
if (cpu_has_vmx)
strncat(buffer, "/Altivec", sizeof(buffer));
#endif
#endif
if (! cpu_has_fpu)
strncat(buffer, "/No FPU", sizeof(buffer));
@@ -468,7 +552,7 @@ MesaSoftwareRenderer::Clear(GLcontext *ctx, GLbitfield mask)
mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
if (mask)
_swrast_Clear( ctx, mask);
_swrast_Clear(ctx, mask);
}
@@ -483,6 +567,8 @@ MesaSoftwareRenderer::ClearFront(GLcontext *ctx)
BBitmap *bitmap = mr->fBitmap;
assert(bitmap);
GLuint *start = (GLuint *) bitmap->Bits();
size_t pixelSize = 0;
get_pixel_size_for(bitmap->ColorSpace(), &pixelSize, NULL, NULL);
const GLuint *clearPixelPtr = (const GLuint *) mr->fClearColor;
const GLuint clearPixel = B_LENDIAN_TO_HOST_INT32(*clearPixelPtr);
@@ -495,7 +581,7 @@ MesaSoftwareRenderer::ClearFront(GLcontext *ctx)
if (all) {
const int numPixels = mr->fWidth * mr->fHeight;
if (clearPixel == 0) {
memset(start, 0, numPixels * 4);
memset(start, 0, numPixels * pixelSize);
} else {
for (int i = 0; i < numPixels; i++) {
start[i] = clearPixel;
@@ -515,22 +601,36 @@ MesaSoftwareRenderer::ClearFront(GLcontext *ctx)
void
MesaSoftwareRenderer::UpdateState( GLcontext *ctx, GLuint new_state )
MesaSoftwareRenderer::UpdateState(GLcontext *ctx, GLuint new_state)
{
if (!ctx)
return;
CALLED();
_swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
_ac_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state );
_swrast_InvalidateState(ctx, new_state);
_swsetup_InvalidateState(ctx, new_state);
_ac_InvalidateState(ctx, new_state);
_tnl_InvalidateState(ctx, new_state);
}
GLboolean
MesaSoftwareRenderer::RenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *render,
GLenum internalFormat, GLuint width, GLuint height )
GLenum internalFormat, GLuint width, GLuint height)
{
return GL_TRUE;
return GL_TRUE;
}
void
MesaSoftwareRenderer::EnableDirectMode(bool enabled)
{
fDirectModeEnabled = enabled;
}
void
MesaSoftwareRenderer::DirectConnected(direct_buffer_info *info)
{
fInfo = info;
}
@@ -25,45 +25,51 @@ extern "C" {
class MesaSoftwareRenderer : public BGLRenderer
{
public:
MesaSoftwareRenderer(BGLView *view, ulong bgl_options, BGLDispatcher *dispatcher);
virtual ~MesaSoftwareRenderer();
public:
MesaSoftwareRenderer(BGLView *view, ulong bgl_options, BGLDispatcher *dispatcher);
virtual ~MesaSoftwareRenderer();
virtual void LockGL();
virtual void UnlockGL();
virtual void LockGL();
virtual void UnlockGL();
virtual void SwapBuffers(bool VSync = false);
virtual void Draw(BRect updateRect);
virtual status_t CopyPixelsOut(BPoint source, BBitmap *dest);
virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest);
virtual void SwapBuffers(bool VSync = false);
virtual void Draw(BRect updateRect);
virtual status_t CopyPixelsOut(BPoint source, BBitmap *dest);
virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest);
GLvoid ** GetRows() { return fRowAddr; };
GLvoid ** GetRows() { return fRowAddr; };
private:
static void Error(GLcontext *ctx);
static const GLubyte * GetString(GLcontext *ctx, GLenum name);
static void Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
static void UpdateState(GLcontext *ctx, GLuint new_state);
static void ClearFront(GLcontext *ctx);
static void ClearIndex(GLcontext *ctx, GLuint index);
static void ClearColor(GLcontext *ctx, const GLfloat color[4]);
static void Clear(GLcontext *ctx, GLbitfield mask);
static GLboolean RenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *render,
GLenum internalFormat, GLuint width, GLuint height );
virtual void EnableDirectMode(bool enabled);
virtual void DirectConnected(direct_buffer_info *info);
BBitmap *fBitmap;
private:
static void Error(GLcontext *ctx);
static const GLubyte * GetString(GLcontext *ctx, GLenum name);
static void Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
static void UpdateState(GLcontext *ctx, GLuint new_state);
static void ClearFront(GLcontext *ctx);
static void ClearIndex(GLcontext *ctx, GLuint index);
static void ClearColor(GLcontext *ctx, const GLfloat color[4]);
static void Clear(GLcontext *ctx, GLbitfield mask);
static GLboolean RenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *render,
GLenum internalFormat, GLuint width, GLuint height);
GLcontext *fContext;
GLvisual *fVisual;
GLframebuffer *fFrameBuffer;
struct gl_renderbuffer *fRenderBuffer;
BBitmap *fBitmap;
bool fDirectModeEnabled;
direct_buffer_info *fInfo;
GLchan fClearColor[4]; // buffer clear color
GLuint fClearIndex; // buffer clear color index
GLuint fWidth;
GLuint fHeight;
GLcontext *fContext;
GLvisual *fVisual;
GLframebuffer *fFrameBuffer;
struct gl_renderbuffer *fRenderBuffer;
GLvoid * fRowAddr[MAX_HEIGHT]; /*< address of first pixel in each image row */
GLchan fClearColor[4]; // buffer clear color
GLuint fClearIndex; // buffer clear color index
GLuint fWidth;
GLuint fHeight;
color_space fColorSpace;
GLvoid * fRowAddr[MAX_HEIGHT]; /*< address of first pixel in each image row */
};
#endif // MESASOFTWARERENDERER_H
+25 -15
View File
@@ -1,3 +1,12 @@
/*
* Copyright 2006-2007, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Jérôme Duval, [email protected]
* Philippe Houdoin, [email protected]
* Stefano Ceccherini, [email protected]
*/
/*
* Mesa 3-D graphics library
* Version: 6.1
@@ -35,6 +44,7 @@
struct glview_direct_info {
direct_buffer_info *direct_info;
bool direct_connected;
bool enable_direct_mode;
glview_direct_info();
~glview_direct_info();
@@ -170,6 +180,11 @@ BGLView::AttachedToWindow()
// Set default OpenGL viewport:
glViewport(0, 0, Bounds().IntegerWidth(), Bounds().IntegerHeight());
if (m_clip_info) {
fRenderer->DirectConnected(((glview_direct_info *)m_clip_info)->direct_info);
fRenderer->EnableDirectMode(((glview_direct_info *)m_clip_info)->enable_direct_mode);
}
return;
}
@@ -285,8 +300,9 @@ BGLView::DirectConnected(direct_buffer_info *info)
// TODO: We should probably prevent the renderer to draw anything
// (lock_draw() ??) while we are in this method
if (!m_clip_info/* && m_direct_connection_disabled*/)
return;
if (!m_clip_info/* && m_direct_connection_disabled*/) {
m_clip_info = new glview_direct_info();
}
glview_direct_info *glviewDirectInfo = (glview_direct_info *)m_clip_info;
direct_buffer_info *localInfo = glviewDirectInfo->direct_info;
@@ -309,16 +325,12 @@ BGLView::DirectConnected(direct_buffer_info *info)
//localInfo->_dd_type_ = info->_dd_type_;
//localInfo->_dd_token_ = info->_dd_token_;
localInfo->window_bounds = info->window_bounds;
// Collect the rects into a BRegion, then clip to the view's bounds
BRegion region;
for (uint32 c = 0; c < info->clip_list_count; c++)
region.Include(info->clip_list[c]);
// TODO: I have the feeling that this Bounds() call won't work here.
// Probably m_bounds should be used, but it should then be maintained correctly
// on view resizing/moving...
BRegion boundsRegion = m_bounds.OffsetByCopy(localInfo->window_bounds.left, localInfo->window_bounds.top);
BRegion boundsRegion = m_bounds.OffsetByCopy(info->window_bounds.left, info->window_bounds.top);
localInfo->window_bounds = boundsRegion.RectAtInt(0); // window_bounds are now view bounds
region.IntersectWith(&boundsRegion);
localInfo->clip_list_count = region.CountRects();
@@ -343,15 +355,12 @@ BGLView::DirectConnected(direct_buffer_info *info)
void
BGLView::EnableDirectMode(bool enabled)
{
if (!m_clip_info && enabled)
m_clip_info = new glview_direct_info();
else if (m_clip_info && !enabled) {
delete (glview_direct_info *)m_clip_info;
m_clip_info = NULL;
}
if (fRenderer)
fRenderer->EnableDirectMode(enabled);
if (!m_clip_info) {
m_clip_info = new glview_direct_info();
}
((glview_direct_info *)m_clip_info)->enable_direct_mode = enabled;
}
@@ -511,6 +520,7 @@ glview_direct_info::glview_direct_info()
// TODO: See direct_window_data() in app_server's ServerWindow.cpp
direct_info = (direct_buffer_info *)calloc(1, B_PAGE_SIZE);
direct_connected = false;
enable_direct_mode = false;
}