* just a few style cleanups, reordered the method implementations to match
the declaration in the header git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23760 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2007, Haiku. All rights reserved.
|
* Copyright 2006-2008, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -132,14 +132,16 @@ extern const char * color_space_name(color_space space);
|
|||||||
#include "swrast/s_spantemp.h"
|
#include "swrast/s_spantemp.h"
|
||||||
|
|
||||||
|
|
||||||
extern "C" _EXPORT BGLRenderer *
|
extern "C" _EXPORT BGLRenderer*
|
||||||
instantiate_gl_renderer(BGLView *view, ulong options, BGLDispatcher *dispatcher)
|
instantiate_gl_renderer(BGLView* view, ulong options,
|
||||||
|
BGLDispatcher* dispatcher)
|
||||||
{
|
{
|
||||||
return new MesaSoftwareRenderer(view, options, dispatcher);
|
return new MesaSoftwareRenderer(view, options, dispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView *view, ulong options, BGLDispatcher *dispatcher)
|
MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView* view, ulong options,
|
||||||
|
BGLDispatcher* dispatcher)
|
||||||
: BGLRenderer(view, options, dispatcher),
|
: BGLRenderer(view, options, dispatcher),
|
||||||
fBitmap(NULL),
|
fBitmap(NULL),
|
||||||
fDirectModeEnabled(false),
|
fDirectModeEnabled(false),
|
||||||
@@ -177,8 +179,9 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView *view, ulong options, BGLDisp
|
|||||||
//fOptions = options | BGL_INDIRECT;
|
//fOptions = options | BGL_INDIRECT;
|
||||||
struct dd_function_table functions;
|
struct dd_function_table functions;
|
||||||
|
|
||||||
fVisual = _mesa_create_visual(rgbFlag, dblFlag, stereoFlag, red, green, blue, alpha,
|
fVisual = _mesa_create_visual(rgbFlag, dblFlag, stereoFlag, red, green,
|
||||||
index, depth, stencil, accum, accum, accum, alpha ? accum : 0, 1);
|
blue, alpha, index, depth, stencil, accum, accum, accum,
|
||||||
|
alpha ? accum : 0, 1);
|
||||||
|
|
||||||
// Initialize device driver function table
|
// Initialize device driver function table
|
||||||
_mesa_init_driver_functions(&functions);
|
_mesa_init_driver_functions(&functions);
|
||||||
@@ -337,8 +340,9 @@ void
|
|||||||
MesaSoftwareRenderer::SwapBuffers(bool VSync)
|
MesaSoftwareRenderer::SwapBuffers(bool VSync)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
|
// TODO: support VSync
|
||||||
|
|
||||||
if (fBitmap) {
|
if (fBitmap) {
|
||||||
if (fVisual->doubleBufferMode)
|
if (fVisual->doubleBufferMode)
|
||||||
_mesa_notifySwapBuffers(fContext);
|
_mesa_notifySwapBuffers(fContext);
|
||||||
@@ -353,9 +357,10 @@ MesaSoftwareRenderer::SwapBuffers(bool VSync)
|
|||||||
for (uint32 i = 0; i < fInfo->clip_list_count; i++) {
|
for (uint32 i = 0; i < fInfo->clip_list_count; i++) {
|
||||||
clipping_rect *clip = &fInfo->clip_list[i];
|
clipping_rect *clip = &fInfo->clip_list[i];
|
||||||
int32 height = clip->bottom - clip->top + 1;
|
int32 height = clip->bottom - clip->top + 1;
|
||||||
int32 bytesWidth = (clip->right - clip->left + 1) * bytesPerPixel;
|
int32 bytesWidth
|
||||||
uint8 *p = (uint8 *)fInfo->bits + clip->top * fInfo->bytes_per_row
|
= (clip->right - clip->left + 1) * bytesPerPixel;
|
||||||
+ clip->left * bytesPerPixel;
|
uint8 *p = (uint8 *)fInfo->bits + clip->top
|
||||||
|
* fInfo->bytes_per_row + clip->left * bytesPerPixel;
|
||||||
uint8 *b = (uint8 *)fBitmap->Bits()
|
uint8 *b = (uint8 *)fBitmap->Bits()
|
||||||
+ (clip->top - fInfo->window_bounds.top) * bytesPerRow
|
+ (clip->top - fInfo->window_bounds.top) * bytesPerRow
|
||||||
+ (clip->left - fInfo->window_bounds.left) * bytesPerPixel;
|
+ (clip->left - fInfo->window_bounds.left) * bytesPerPixel;
|
||||||
@@ -409,7 +414,8 @@ MesaSoftwareRenderer::CopyPixelsOut(BPoint location, BBitmap *bitmap)
|
|||||||
s = (uint32 *)(ps + y * fBitmap->BytesPerRow());
|
s = (uint32 *)(ps + y * fBitmap->BytesPerRow());
|
||||||
s += (uint32) sr.left;
|
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;
|
d += (uint32) dr.left;
|
||||||
|
|
||||||
memcpy(d, s, dr.IntegerWidth() * 4);
|
memcpy(d, s, dr.IntegerWidth() * 4);
|
||||||
@@ -446,7 +452,8 @@ MesaSoftwareRenderer::CopyPixelsIn(BBitmap *bitmap, BPoint location)
|
|||||||
s = (uint32 *)(ps + y * bitmap->BytesPerRow());
|
s = (uint32 *)(ps + y * bitmap->BytesPerRow());
|
||||||
s += (uint32) sr.left;
|
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;
|
d += (uint32) dr.left;
|
||||||
|
|
||||||
memcpy(d, s, dr.IntegerWidth() * 4);
|
memcpy(d, s, dr.IntegerWidth() * 4);
|
||||||
@@ -456,11 +463,28 @@ MesaSoftwareRenderer::CopyPixelsIn(BBitmap *bitmap, BPoint location)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MesaSoftwareRenderer::Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
|
MesaSoftwareRenderer::EnableDirectMode(bool enabled)
|
||||||
{
|
{
|
||||||
CALLED();
|
fDirectModeEnabled = enabled;
|
||||||
/* poll for window size change and realloc software Z/stencil/etc if needed */
|
}
|
||||||
_mesa_ResizeBuffersMESA();
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MesaSoftwareRenderer::DirectConnected(direct_buffer_info *info)
|
||||||
|
{
|
||||||
|
fInfo = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - static
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MesaSoftwareRenderer::Error(GLcontext *ctx)
|
||||||
|
{
|
||||||
|
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
|
||||||
|
if (mr && mr->GLView())
|
||||||
|
mr->GLView()->ErrorCallback((unsigned long) ctx->ErrorValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -474,23 +498,30 @@ MesaSoftwareRenderer::GetString(GLcontext *ctx, GLenum name)
|
|||||||
if (!buffer[0]) {
|
if (!buffer[0]) {
|
||||||
// Let's build an renderer string
|
// Let's build an renderer string
|
||||||
// TODO: add SVN revision
|
// TODO: add SVN revision
|
||||||
strncat(buffer, "Haiku's Mesa " MESA_VERSION_STRING " Software Renderer", sizeof(buffer));
|
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
|
#ifdef USE_X86_ASM
|
||||||
if (_mesa_x86_cpu_features)
|
if (_mesa_x86_cpu_features)
|
||||||
strncat(buffer, ", optimized for x86", sizeof(buffer));
|
strncat(buffer, ", optimized for x86", sizeof(buffer));
|
||||||
#ifdef USE_MMX_ASM
|
#ifdef USE_MMX_ASM
|
||||||
if (cpu_has_mmx)
|
if (cpu_has_mmx) {
|
||||||
strncat(buffer, (cpu_has_mmxext) ? "/MMX+" : "/MMX", sizeof(buffer));
|
strncat(buffer, (cpu_has_mmxext) ? "/MMX+" : "/MMX",
|
||||||
|
sizeof(buffer));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_3DNOW_ASM
|
#ifdef USE_3DNOW_ASM
|
||||||
if (cpu_has_3dnow)
|
if (cpu_has_3dnow) {
|
||||||
strncat(buffer, (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!", sizeof(buffer));
|
strncat(buffer, (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!",
|
||||||
|
sizeof(buffer));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_SSE_ASM
|
#ifdef USE_SSE_ASM
|
||||||
if (cpu_has_xmm)
|
if (cpu_has_xmm) {
|
||||||
strncat(buffer, (cpu_has_xmm2) ? "/SSE2" : "/SSE", sizeof(buffer));
|
strncat(buffer, (cpu_has_xmm2) ? "/SSE2" : "/SSE",
|
||||||
|
sizeof(buffer));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(USE_SPARC_ASM)
|
#elif defined(USE_SPARC_ASM)
|
||||||
@@ -499,8 +530,11 @@ MesaSoftwareRenderer::GetString(GLcontext *ctx, GLenum name)
|
|||||||
|
|
||||||
#elif defined(USE_PPC_ASM)
|
#elif defined(USE_PPC_ASM)
|
||||||
|
|
||||||
if (_mesa_ppc_cpu_features)
|
if (_mesa_ppc_cpu_features) {
|
||||||
strncat(buffer, (cpu_has_64) ? ", optimized for PowerPC 64" : ", optimized for PowerPC", sizeof(buffer));
|
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)
|
if (cpu_has_vmx)
|
||||||
@@ -522,11 +556,26 @@ MesaSoftwareRenderer::GetString(GLcontext *ctx, GLenum name)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MesaSoftwareRenderer::Error(GLcontext *ctx)
|
MesaSoftwareRenderer::Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w,
|
||||||
|
GLsizei h)
|
||||||
{
|
{
|
||||||
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
|
CALLED();
|
||||||
if (mr && mr->GLView())
|
// poll for window size change and realloc software Z/stencil/etc if needed
|
||||||
mr->GLView()->ErrorCallback((unsigned long) ctx->ErrorValue);
|
_mesa_ResizeBuffersMESA();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MesaSoftwareRenderer::UpdateState(GLcontext *ctx, GLuint new_state)
|
||||||
|
{
|
||||||
|
if (!ctx)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CALLED();
|
||||||
|
_swrast_InvalidateState(ctx, new_state);
|
||||||
|
_swsetup_InvalidateState(ctx, new_state);
|
||||||
|
_vbo_InvalidateState(ctx, new_state);
|
||||||
|
_tnl_InvalidateState(ctx, new_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -587,7 +636,8 @@ MesaSoftwareRenderer::ClearFront(GLcontext *ctx)
|
|||||||
int y = ctx->DrawBuffer->_Ymin;
|
int y = ctx->DrawBuffer->_Ymin;
|
||||||
uint32 width = ctx->DrawBuffer->_Xmax - x;
|
uint32 width = ctx->DrawBuffer->_Xmax - x;
|
||||||
uint32 height = ctx->DrawBuffer->_Ymax - y;
|
uint32 height = ctx->DrawBuffer->_Ymax - y;
|
||||||
GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->Height);
|
GLboolean all = (width == ctx->DrawBuffer->Width
|
||||||
|
&& height == ctx->DrawBuffer->Height);
|
||||||
|
|
||||||
if (all) {
|
if (all) {
|
||||||
const int numPixels = mr->fWidth * mr->fHeight;
|
const int numPixels = mr->fWidth * mr->fHeight;
|
||||||
@@ -611,23 +661,10 @@ MesaSoftwareRenderer::ClearFront(GLcontext *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MesaSoftwareRenderer::UpdateState(GLcontext *ctx, GLuint new_state)
|
|
||||||
{
|
|
||||||
if (!ctx)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CALLED();
|
|
||||||
_swrast_InvalidateState(ctx, new_state);
|
|
||||||
_swsetup_InvalidateState(ctx, new_state);
|
|
||||||
_vbo_InvalidateState(ctx, new_state);
|
|
||||||
_tnl_InvalidateState(ctx, new_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GLboolean
|
GLboolean
|
||||||
MesaSoftwareRenderer::RenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *render,
|
MesaSoftwareRenderer::RenderbufferStorage(GLcontext* ctx,
|
||||||
GLenum internalFormat, GLuint width, GLuint height)
|
struct gl_renderbuffer* render, GLenum internalFormat,
|
||||||
|
GLuint width, GLuint height)
|
||||||
{
|
{
|
||||||
render->Width = width;
|
render->Width = width;
|
||||||
render->Height = height;
|
render->Height = height;
|
||||||
@@ -635,16 +672,3 @@ MesaSoftwareRenderer::RenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MesaSoftwareRenderer::EnableDirectMode(bool enabled)
|
|
||||||
{
|
|
||||||
fDirectModeEnabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MesaSoftwareRenderer::DirectConnected(direct_buffer_info *info)
|
|
||||||
{
|
|
||||||
fInfo = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006-2007, Haiku. All rights reserved.
|
* Copyright 2006-2008, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -23,53 +23,59 @@ extern "C" {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MesaSoftwareRenderer : public BGLRenderer
|
class MesaSoftwareRenderer : public BGLRenderer {
|
||||||
{
|
public:
|
||||||
public:
|
MesaSoftwareRenderer(BGLView* view,
|
||||||
MesaSoftwareRenderer(BGLView *view, ulong bgl_options, BGLDispatcher *dispatcher);
|
ulong bgl_options,
|
||||||
virtual ~MesaSoftwareRenderer();
|
BGLDispatcher* dispatcher);
|
||||||
|
virtual ~MesaSoftwareRenderer();
|
||||||
|
|
||||||
virtual void LockGL();
|
virtual void LockGL();
|
||||||
virtual void UnlockGL();
|
virtual void UnlockGL();
|
||||||
|
|
||||||
virtual void SwapBuffers(bool VSync = false);
|
virtual void SwapBuffers(bool VSync = false);
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual status_t CopyPixelsOut(BPoint source, BBitmap *dest);
|
virtual status_t CopyPixelsOut(BPoint source, BBitmap* dest);
|
||||||
virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest);
|
virtual status_t CopyPixelsIn(BBitmap* source, BPoint dest);
|
||||||
|
|
||||||
GLvoid ** GetRows() { return fRowAddr; };
|
GLvoid** GetRows() { return fRowAddr; }
|
||||||
|
|
||||||
virtual void EnableDirectMode(bool enabled);
|
virtual void EnableDirectMode(bool enabled);
|
||||||
virtual void DirectConnected(direct_buffer_info *info);
|
virtual void DirectConnected(direct_buffer_info* info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void Error(GLcontext *ctx);
|
static void Error(GLcontext* ctx);
|
||||||
static const GLubyte * GetString(GLcontext *ctx, GLenum name);
|
static const GLubyte* GetString(GLcontext* ctx, GLenum name);
|
||||||
static void Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
|
static void Viewport(GLcontext* ctx, GLint x, GLint y,
|
||||||
static void UpdateState(GLcontext *ctx, GLuint new_state);
|
GLsizei w, GLsizei h);
|
||||||
static void ClearFront(GLcontext *ctx);
|
static void UpdateState(GLcontext* ctx, GLuint newState);
|
||||||
static void ClearIndex(GLcontext *ctx, GLuint index);
|
static void ClearFront(GLcontext* ctx);
|
||||||
static void ClearColor(GLcontext *ctx, const GLfloat color[4]);
|
static void ClearIndex(GLcontext* ctx, GLuint index);
|
||||||
static void Clear(GLcontext *ctx, GLbitfield mask);
|
static void ClearColor(GLcontext* ctx,
|
||||||
static GLboolean RenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *render,
|
const GLfloat color[4]);
|
||||||
GLenum internalFormat, GLuint width, GLuint height);
|
static void Clear(GLcontext* ctx, GLbitfield mask);
|
||||||
|
static GLboolean RenderbufferStorage(GLcontext* ctx,
|
||||||
|
struct gl_renderbuffer* render,
|
||||||
|
GLenum internalFormat,
|
||||||
|
GLuint width, GLuint height);
|
||||||
|
|
||||||
BBitmap *fBitmap;
|
BBitmap* fBitmap;
|
||||||
bool fDirectModeEnabled;
|
bool fDirectModeEnabled;
|
||||||
direct_buffer_info *fInfo;
|
direct_buffer_info* fInfo;
|
||||||
|
|
||||||
GLcontext *fContext;
|
GLcontext* fContext;
|
||||||
GLvisual *fVisual;
|
GLvisual* fVisual;
|
||||||
GLframebuffer *fFrameBuffer;
|
GLframebuffer* fFrameBuffer;
|
||||||
struct gl_renderbuffer *fRenderBuffer;
|
struct gl_renderbuffer* fRenderBuffer;
|
||||||
|
|
||||||
GLchan fClearColor[4]; // buffer clear color
|
GLchan fClearColor[4]; // buffer clear color
|
||||||
GLuint fClearIndex; // buffer clear color index
|
GLuint fClearIndex; // buffer clear color index
|
||||||
GLuint fWidth;
|
GLuint fWidth;
|
||||||
GLuint fHeight;
|
GLuint fHeight;
|
||||||
color_space fColorSpace;
|
color_space fColorSpace;
|
||||||
|
|
||||||
GLvoid * fRowAddr[MAX_HEIGHT]; /*< address of first pixel in each image row */
|
GLvoid* fRowAddr[MAX_HEIGHT];
|
||||||
|
// address of first pixel in each image row
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESASOFTWARERENDERER_H
|
#endif // MESASOFTWARERENDERER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user