now uses macro based read/write functions to access the bitmap
the code is now very compact, on par with other Mesa drivers git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20172 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
cab58350ac
commit
54a71c95b7
@ -70,6 +70,35 @@ extern const char * color_space_name(color_space space);
|
||||
(color[BCOMP] << 24) | 0xFF000000)
|
||||
#endif
|
||||
|
||||
/**********************************************************************/
|
||||
/***** Read/write spans/arrays of pixels *****/
|
||||
/**********************************************************************/
|
||||
|
||||
/* 8-bit RGBA */
|
||||
#define NAME(PREFIX) PREFIX##_RGBA8
|
||||
#define RB_TYPE GLubyte
|
||||
#define SPAN_VARS \
|
||||
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
|
||||
#define INIT_PIXEL_PTR(P, X, Y) \
|
||||
GLubyte *P = ((GLubyte **) mr->GetRows())[Y] + (X) * 4
|
||||
#define INC_PIXEL_PTR(P) P += 4
|
||||
#define STORE_PIXEL(DST, X, Y, VALUE) \
|
||||
DST[BE_RCOMP] = VALUE[RCOMP]; \
|
||||
DST[BE_GCOMP] = VALUE[GCOMP]; \
|
||||
DST[BE_BCOMP] = VALUE[BCOMP]; \
|
||||
DST[BE_ACOMP] = VALUE[ACOMP]
|
||||
#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
|
||||
DST[BE_RCOMP] = VALUE[RCOMP]; \
|
||||
DST[BE_GCOMP] = VALUE[GCOMP]; \
|
||||
DST[BE_BCOMP] = VALUE[BCOMP]; \
|
||||
DST[BE_ACOMP] = 255
|
||||
#define FETCH_PIXEL(DST, SRC) \
|
||||
DST[RCOMP] = SRC[BE_RCOMP]; \
|
||||
DST[GCOMP] = SRC[BE_GCOMP]; \
|
||||
DST[BCOMP] = SRC[BE_BCOMP]; \
|
||||
DST[ACOMP] = SRC[BE_ACOMP]
|
||||
#include "swrast/s_spantemp.h"
|
||||
|
||||
extern "C" _EXPORT BGLRenderer *
|
||||
instanciate_gl_renderer(BGLView *view, ulong options, BGLDispatcher *dispatcher)
|
||||
{
|
||||
@ -151,12 +180,13 @@ MesaSoftwareRenderer::MesaSoftwareRenderer(BGLView *view, ulong options, BGLDisp
|
||||
fRenderBuffer->Data = NULL;
|
||||
fRenderBuffer->AllocStorage = RenderbufferStorage;
|
||||
|
||||
fRenderBuffer->GetRow = ReadRGBASpan;
|
||||
fRenderBuffer->GetValues = ReadRGBAPixels;
|
||||
fRenderBuffer->PutRow = WriteRGBASpan;
|
||||
fRenderBuffer->PutRowRGB = WriteRGBSpan;
|
||||
fRenderBuffer->PutMonoRow = WriteMonoRGBASpan;
|
||||
fRenderBuffer->PutValues = WriteMonoRGBAPixels;
|
||||
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;
|
||||
|
||||
_mesa_add_renderbuffer(fFrameBuffer, BUFFER_FRONT_LEFT, fRenderBuffer);
|
||||
|
||||
@ -213,14 +243,14 @@ MesaSoftwareRenderer::LockGL()
|
||||
delete fBitmap;
|
||||
BRect rect(0.0, 0.0, width - 1, height - 1);
|
||||
fBitmap = new BBitmap(rect, B_RGBA32);
|
||||
for (uint i = 0; i < height; i++)
|
||||
fRowAddr[height - i - 1] = (GLvoid *) ((GLubyte *) fBitmap->Bits() + i * fBitmap->BytesPerRow());
|
||||
|
||||
_mesa_resize_framebuffer(fContext, fFrameBuffer, width, height);
|
||||
}
|
||||
fWidth = width;
|
||||
fHeight = height;
|
||||
fBottom = (GLint) b.bottom;
|
||||
fRenderBuffer->Data = fBitmap->Bits();
|
||||
|
||||
fBitmap->LockBits();
|
||||
fWidth = width;
|
||||
fHeight = height;
|
||||
fRenderBuffer->Data = fBitmap->Bits();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -228,7 +258,6 @@ void
|
||||
MesaSoftwareRenderer::UnlockGL()
|
||||
{
|
||||
CALLED();
|
||||
fBitmap->UnlockBits();
|
||||
_mesa_make_current(fContext, NULL, NULL);
|
||||
BGLRenderer::UnlockGL();
|
||||
}
|
||||
@ -434,15 +463,8 @@ void
|
||||
MesaSoftwareRenderer::Clear(GLcontext *ctx, GLbitfield mask)
|
||||
{
|
||||
CALLED();
|
||||
#if 0
|
||||
if (mask & BUFFER_BIT_FRONT_LEFT)
|
||||
ClearFront(ctx);
|
||||
if (mask & BUFFER_BIT_BACK_LEFT)
|
||||
ClearBack(ctx);
|
||||
#else
|
||||
if (mask & BUFFER_BIT_FRONT_LEFT)
|
||||
ClearBack(ctx);
|
||||
#endif
|
||||
|
||||
mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
|
||||
if (mask)
|
||||
@ -455,57 +477,6 @@ MesaSoftwareRenderer::ClearFront(GLcontext *ctx)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
|
||||
BGLView *bglview = mr->GLView();
|
||||
assert(bglview);
|
||||
|
||||
bglview->SetHighColor(mr->fClearColor[BE_RCOMP],
|
||||
mr->fClearColor[BE_GCOMP],
|
||||
mr->fClearColor[BE_BCOMP],
|
||||
mr->fClearColor[BE_ACOMP]);
|
||||
bglview->SetLowColor(mr->fClearColor[BE_RCOMP],
|
||||
mr->fClearColor[BE_GCOMP],
|
||||
mr->fClearColor[BE_BCOMP],
|
||||
mr->fClearColor[BE_ACOMP]);
|
||||
|
||||
int x = ctx->DrawBuffer->_Xmin;
|
||||
int y = ctx->DrawBuffer->_Ymin;
|
||||
int width = ctx->DrawBuffer->_Xmax - x;
|
||||
int height = ctx->DrawBuffer->_Ymax - y;
|
||||
GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->Height);
|
||||
|
||||
if (all) {
|
||||
BRect b = bglview->Bounds();
|
||||
bglview->FillRect(b);
|
||||
} else {
|
||||
// XXX untested
|
||||
BRect b;
|
||||
b.left = x;
|
||||
b.right = x + width;
|
||||
b.bottom = mr->fHeight - y - 1;
|
||||
b.top = b.bottom - height;
|
||||
bglview->FillRect(b);
|
||||
}
|
||||
|
||||
// restore drawing color
|
||||
#if 0
|
||||
bglview->SetHighColor(md->mColor[BE_RCOMP],
|
||||
md->mColor[BE_GCOMP],
|
||||
md->mColor[BE_BCOMP],
|
||||
md->mColor[BE_ACOMP]);
|
||||
bglview->SetLowColor(md->mColor[BE_RCOMP],
|
||||
md->mColor[BE_GCOMP],
|
||||
md->mColor[BE_BCOMP],
|
||||
md->mColor[BE_ACOMP]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::ClearBack(GLcontext *ctx)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
|
||||
BGLView *bglview = mr->GLView();
|
||||
assert(bglview);
|
||||
@ -517,8 +488,8 @@ MesaSoftwareRenderer::ClearBack(GLcontext *ctx)
|
||||
|
||||
int x = ctx->DrawBuffer->_Xmin;
|
||||
int y = ctx->DrawBuffer->_Ymin;
|
||||
int width = ctx->DrawBuffer->_Xmax - x;
|
||||
int height = ctx->DrawBuffer->_Ymax - y;
|
||||
uint32 width = ctx->DrawBuffer->_Xmax - x;
|
||||
uint32 height = ctx->DrawBuffer->_Ymax - y;
|
||||
GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->Height);
|
||||
|
||||
if (all) {
|
||||
@ -533,8 +504,8 @@ MesaSoftwareRenderer::ClearBack(GLcontext *ctx)
|
||||
} else {
|
||||
// XXX untested
|
||||
start += y * mr->fWidth + x;
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) {
|
||||
for (uint32 i = 0; i < height; i++) {
|
||||
for (uint32 j = 0; j < width; j++) {
|
||||
start[j] = clearPixel;
|
||||
}
|
||||
start += mr->fWidth;
|
||||
@ -563,419 +534,3 @@ MesaSoftwareRenderer::RenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer
|
||||
{
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
// Plot a pixel. (0,0) is upper-left corner
|
||||
// This is only used when drawing to the front buffer.
|
||||
inline void Plot(BGLView *bglview, int x, int y)
|
||||
{
|
||||
// XXX There's got to be a better way!
|
||||
BPoint p(x, y), q(x+1, y);
|
||||
bglview->StrokeLine(p, q);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::WriteRGBASpan(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const void *values,
|
||||
const GLubyte mask[])
|
||||
{
|
||||
//CALLED();
|
||||
|
||||
CONST GLubyte (*rgba)[4] = (CONST GLubyte (*)[4])values;
|
||||
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
|
||||
|
||||
//printf("WriteRGBASpan 1 n %ld x %ld y %ld mask %ld rb %p %p\n", n, x ,y, mask, rb, rgba);
|
||||
|
||||
/*if (rb->Name == BUFFER_FRONT_LEFT) {
|
||||
BGLView *bglview = mr->GLView();
|
||||
assert(bglview);
|
||||
int flippedY = mr->fBottom - y;
|
||||
if (mask) {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
if (mask[i]) {
|
||||
bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]);
|
||||
Plot(bglview, x++, flippedY);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]);
|
||||
Plot(bglview, x++, flippedY);
|
||||
}
|
||||
}
|
||||
} else {*/
|
||||
BBitmap *bitmap = mr->fBitmap;
|
||||
|
||||
assert(bitmap);
|
||||
|
||||
int row = mr->fBottom - y;
|
||||
uint8 * ptr = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + x * 4;
|
||||
uint32 * pixel = (uint32 *) ptr;
|
||||
|
||||
if (mask) {
|
||||
while(n--) {
|
||||
if (*mask++)
|
||||
*pixel = PACK_B_RGBA32(rgba[0]);
|
||||
pixel++;
|
||||
rgba++;
|
||||
};
|
||||
} else {
|
||||
while(n--) {
|
||||
*pixel++ = PACK_B_RGBA32(rgba[0]);
|
||||
rgba++;
|
||||
};
|
||||
};
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::WriteRGBSpan(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const void *values,
|
||||
const GLubyte mask[])
|
||||
{
|
||||
CALLED();
|
||||
|
||||
//printf("WriteRGBSpan 1 n %ld x %ld y %ld mask %ld\n", n, x ,y, mask);
|
||||
|
||||
CONST GLubyte **rgba = (CONST GLubyte **)values;
|
||||
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
|
||||
|
||||
/*if (rb->Name == BUFFER_FRONT_LEFT) {
|
||||
BGLView *bglview = mr->GLView();
|
||||
assert(bglview);
|
||||
int flippedY = mr->fBottom - y;
|
||||
|
||||
if (mask) {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
if (mask[i]) {
|
||||
bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2]);
|
||||
Plot(bglview, x++, flippedY);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2]);
|
||||
Plot(bglview, x++, flippedY);
|
||||
}
|
||||
}
|
||||
} else {*/
|
||||
BBitmap *bitmap = mr->fBitmap;
|
||||
|
||||
assert(bitmap);
|
||||
|
||||
int row = mr->fBottom - y;
|
||||
uint8 * ptr = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + x * 4;
|
||||
uint32 * pixel = (uint32 *) ptr;
|
||||
|
||||
if (mask) {
|
||||
while(n--) {
|
||||
if (*mask++)
|
||||
*pixel = PACK_B_RGB32(rgba[0]);
|
||||
pixel++;
|
||||
rgba++;
|
||||
};
|
||||
} else {
|
||||
while(n--) {
|
||||
*pixel++ = PACK_B_RGB32(rgba[0]);
|
||||
rgba++;
|
||||
};
|
||||
};
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::WriteMonoRGBASpan(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const void *values,
|
||||
const GLubyte mask[])
|
||||
{
|
||||
CALLED();
|
||||
|
||||
const GLchan *color = (const GLchan *)values;
|
||||
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
|
||||
|
||||
/*if (rb->Name == BUFFER_FRONT_LEFT) {
|
||||
BGLView *bglview = mr->GLView();
|
||||
assert(bglview);
|
||||
int flippedY = mr->fBottom - y;
|
||||
bglview->SetHighColor(color[RCOMP], color[GCOMP], color[BCOMP]);
|
||||
if (mask) {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
if (mask[i]) {
|
||||
Plot(bglview, x++, flippedY);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
Plot(bglview, x++, flippedY);
|
||||
}
|
||||
}
|
||||
} else {*/
|
||||
BBitmap *bitmap = mr->fBitmap;
|
||||
|
||||
assert(bitmap);
|
||||
|
||||
int row = mr->fBottom - y;
|
||||
uint8 * ptr = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + x * 4;
|
||||
uint32 * pixel = (uint32 *) ptr;
|
||||
uint32 pixel_color = PACK_B_RGBA32(color);
|
||||
|
||||
if (mask) {
|
||||
while(n--) {
|
||||
if (*mask++)
|
||||
*pixel = pixel_color;
|
||||
pixel++;
|
||||
};
|
||||
} else {
|
||||
while(n--) {
|
||||
*pixel++ = pixel_color;
|
||||
};
|
||||
};
|
||||
//}
|
||||
}
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::WriteRGBAPixels(GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
const void *values,
|
||||
const GLubyte mask[] )
|
||||
{
|
||||
CALLED();
|
||||
CONST GLubyte **rgba = (CONST GLubyte **)values;
|
||||
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
|
||||
|
||||
/*if (rb->Name == BUFFER_FRONT_LEFT) {
|
||||
BGLView *bglview = mr->GLView();
|
||||
assert(bglview);
|
||||
if (mask) {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
if (mask[i]) {
|
||||
bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2]);
|
||||
Plot(bglview, x[i], mr->fBottom - y[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2]);
|
||||
Plot(bglview, x[i], mr->fBottom - y[i]);
|
||||
}
|
||||
}
|
||||
} else {*/
|
||||
BBitmap *bitmap = mr->fBitmap;
|
||||
|
||||
assert(bitmap);
|
||||
#if 0
|
||||
while(n--) {
|
||||
if (*mask++) {
|
||||
int row = md->m_bottom - *y;
|
||||
uint8 * pixel = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + *x * 4;
|
||||
*((uint32 *) pixel) = PACK_B_RGBA32(rgba[0]);
|
||||
};
|
||||
x++;
|
||||
y++;
|
||||
rgba++;
|
||||
};
|
||||
#else
|
||||
if (mask) {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
if (mask[i]) {
|
||||
GLubyte *pixel = (GLubyte *) bitmap->Bits()
|
||||
+ ((mr->fBottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
|
||||
pixel[BE_RCOMP] = rgba[i][RCOMP];
|
||||
pixel[BE_GCOMP] = rgba[i][GCOMP];
|
||||
pixel[BE_BCOMP] = rgba[i][BCOMP];
|
||||
pixel[BE_ACOMP] = rgba[i][ACOMP];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
GLubyte *pixel = (GLubyte *) bitmap->Bits()
|
||||
+ ((mr->fBottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
|
||||
pixel[BE_RCOMP] = rgba[i][RCOMP];
|
||||
pixel[BE_GCOMP] = rgba[i][GCOMP];
|
||||
pixel[BE_BCOMP] = rgba[i][BCOMP];
|
||||
pixel[BE_ACOMP] = rgba[i][ACOMP];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::WriteMonoRGBAPixels(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
const void *values,
|
||||
const GLubyte mask[])
|
||||
{
|
||||
//CALLED();
|
||||
const GLchan *color = (const GLchan *)values;
|
||||
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
|
||||
|
||||
/*if (rb->Name == BUFFER_FRONT_LEFT) {
|
||||
BGLView *bglview = mr->GLView();
|
||||
assert(bglview);
|
||||
// plot points using current color
|
||||
bglview->SetHighColor(color[RCOMP], color[GCOMP], color[BCOMP]);
|
||||
if (mask) {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
if (mask[i]) {
|
||||
Plot(bglview, x[i], mr->fBottom - y[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
Plot(bglview, x[i], mr->fBottom - y[i]);
|
||||
}
|
||||
}
|
||||
} else {*/
|
||||
BBitmap *bitmap = mr->fBitmap;
|
||||
|
||||
assert(bitmap);
|
||||
|
||||
uint32 pixel_color = PACK_B_RGBA32(color);
|
||||
#if 0
|
||||
while(n--) {
|
||||
if (*mask++) {
|
||||
int row = md->m_bottom - *y;
|
||||
uint8 * pixel = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + *x * 4;
|
||||
|
||||
*((uint32 *) pixel) = pixel_color;
|
||||
};
|
||||
x++;
|
||||
y++;
|
||||
};
|
||||
#else
|
||||
if (mask) {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
if (mask[i]) {
|
||||
GLubyte * ptr = (GLubyte *) bitmap->Bits()
|
||||
+ ((mr->fBottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
|
||||
*((uint32 *) ptr) = pixel_color;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
GLubyte * ptr = (GLubyte *) bitmap->Bits()
|
||||
+ ((mr->fBottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
|
||||
*((uint32 *) ptr) = pixel_color;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::WriteCI32Span( const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y,
|
||||
const GLuint index[], const GLubyte mask[] )
|
||||
{
|
||||
printf("WriteCI32Span() not implemented yet!\n");
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::WriteCI8Span( const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y,
|
||||
const GLubyte index[], const GLubyte mask[] )
|
||||
{
|
||||
printf("WriteCI8Span() not implemented yet!\n");
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::WriteMonoCISpan( const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
GLint x, GLint y,
|
||||
GLuint colorIndex, const GLubyte mask[] )
|
||||
{
|
||||
printf("WriteMonoCISpan() not implemented yet!\n");
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::WriteCI32Pixels( const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
const GLuint index[], const GLubyte mask[] )
|
||||
{
|
||||
printf("WriteCI32Pixels() not implemented yet!\n");
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::WriteMonoCIPixels( const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
GLuint colorIndex, const GLubyte mask[] )
|
||||
{
|
||||
printf("WriteMonoCIPixels() not implemented yet!\n");
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::ReadCI32Span( const GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
GLuint n, GLint x, GLint y, GLuint index[] )
|
||||
{
|
||||
printf("ReadCI32Span() not implemented yet!\n");
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::ReadRGBASpan(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
GLint x, GLint y, void *values )
|
||||
{
|
||||
//CALLED();
|
||||
GLubyte (*rgba)[4] = (GLubyte (*)[4])values;
|
||||
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
|
||||
const BBitmap *bitmap = mr->fBitmap;
|
||||
assert(bitmap);
|
||||
int row = mr->fBottom - y;
|
||||
const GLubyte *pixel = (GLubyte *) bitmap->Bits()
|
||||
+ (row * bitmap->BytesPerRow()) + x * 4;
|
||||
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
rgba[i][RCOMP] = pixel[BE_RCOMP];
|
||||
rgba[i][GCOMP] = pixel[BE_GCOMP];
|
||||
rgba[i][BCOMP] = pixel[BE_BCOMP];
|
||||
rgba[i][ACOMP] = pixel[BE_ACOMP];
|
||||
pixel += 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::ReadCI32Pixels( const GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
GLuint indx[], const GLubyte mask[] )
|
||||
{
|
||||
printf("ReadCI32Pixels() not implemented yet!\n");
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MesaSoftwareRenderer::ReadRGBAPixels(GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
void *values)
|
||||
{
|
||||
CALLED();
|
||||
GLubyte (*rgba)[4] = (GLubyte (*)[4])values;
|
||||
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx;
|
||||
const BBitmap *bitmap = mr->fBitmap;
|
||||
assert(bitmap);
|
||||
|
||||
for (GLuint i = 0; i < n; i++) {
|
||||
GLubyte *pixel = (GLubyte *) bitmap->Bits()
|
||||
+ ((mr->fBottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
|
||||
rgba[i][RCOMP] = pixel[BE_RCOMP];
|
||||
rgba[i][GCOMP] = pixel[BE_GCOMP];
|
||||
rgba[i][BCOMP] = pixel[BE_BCOMP];
|
||||
rgba[i][ACOMP] = pixel[BE_ACOMP];
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -34,70 +34,22 @@ public:
|
||||
|
||||
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 status_t CopyPixelsOut(BPoint source, BBitmap *dest);
|
||||
virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest);
|
||||
|
||||
GLvoid ** GetRows() { return fRowAddr; };
|
||||
|
||||
private:
|
||||
static void Error(GLcontext *ctx);
|
||||
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 ClearBack(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,
|
||||
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 );
|
||||
|
||||
// Buffer functions
|
||||
static void WriteRGBASpan(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const void *values,
|
||||
const GLubyte mask[]);
|
||||
static void WriteRGBSpan(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const void *values,
|
||||
const GLubyte mask[]);
|
||||
static void WriteMonoRGBASpan(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const void *values,
|
||||
const GLubyte mask[]);
|
||||
static void WriteRGBAPixels(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
const void *values,
|
||||
const GLubyte mask[]);
|
||||
static void WriteMonoRGBAPixels(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
const void *values,
|
||||
const GLubyte mask[]);
|
||||
static void WriteCI32Span(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const GLuint index[], const GLubyte mask[]);
|
||||
static void WriteCI8Span(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
GLint x, GLint y,
|
||||
const GLubyte index[], const GLubyte mask[]);
|
||||
static void WriteMonoCISpan(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
GLint x, GLint y,
|
||||
GLuint colorIndex, const GLubyte mask[]);
|
||||
static void WriteCI32Pixels(const GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
const GLuint index[], const GLubyte mask[]);
|
||||
static void WriteMonoCIPixels(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
const GLint x[], const GLint y[],
|
||||
GLuint colorIndex, const GLubyte mask[]);
|
||||
static void ReadCI32Span(const GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
GLuint n, GLint x, GLint y, GLuint index[]);
|
||||
static void ReadRGBASpan(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
|
||||
GLint x, GLint y,
|
||||
void *values);
|
||||
static void ReadCI32Pixels(const GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
GLuint indx[], const GLubyte mask[]);
|
||||
static void ReadRGBAPixels(GLcontext *ctx, struct gl_renderbuffer *rb,
|
||||
GLuint n, const GLint x[], const GLint y[],
|
||||
void *values);
|
||||
|
||||
|
||||
BBitmap *fBitmap;
|
||||
|
||||
@ -108,9 +60,10 @@ private:
|
||||
|
||||
GLchan fClearColor[4]; // buffer clear color
|
||||
GLuint fClearIndex; // buffer clear color index
|
||||
GLint fBottom; // used for flipping Y coords
|
||||
GLuint fWidth;
|
||||
GLuint fHeight;
|
||||
|
||||
GLvoid * fRowAddr[MAX_HEIGHT]; /*< address of first pixel in each image row */
|
||||
};
|
||||
|
||||
#endif // MESASOFTWARERENDERER_H
|
||||
|
Loading…
Reference in New Issue
Block a user