(pointers) style.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40052 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2011-01-01 16:46:58 +00:00
parent 903625ee29
commit c4b9b7dbe5
@@ -52,7 +52,7 @@ extern "C" {
#endif #endif
} }
extern const char * color_space_name(color_space space); extern const char* color_space_name(color_space space);
// BeOS component ordering for B_RGBA32 bitmap format // BeOS component ordering for B_RGBA32 bitmap format
#if B_HOST_IS_LENDIAN #if B_HOST_IS_LENDIAN
@@ -80,9 +80,9 @@ extern "C" {
#define NAME(PREFIX) PREFIX##_RGBA32 #define NAME(PREFIX) PREFIX##_RGBA32
#define RB_TYPE GLubyte #define RB_TYPE GLubyte
#define SPAN_VARS \ #define SPAN_VARS \
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx; MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \ #define INIT_PIXEL_PTR(P, X, Y) \
GLubyte *P = ((GLubyte **) mr->GetRows())[Y] + (X) * 4 GLubyte* P = ((GLubyte**)mr->GetRows())[Y] + (X) * 4
#define INC_PIXEL_PTR(P) P += 4 #define INC_PIXEL_PTR(P) P += 4
#define STORE_PIXEL(DST, X, Y, VALUE) \ #define STORE_PIXEL(DST, X, Y, VALUE) \
DST[BE_RCOMP] = VALUE[RCOMP]; \ DST[BE_RCOMP] = VALUE[RCOMP]; \
@@ -105,9 +105,9 @@ extern "C" {
#define NAME(PREFIX) PREFIX##_RGB32 #define NAME(PREFIX) PREFIX##_RGB32
#define RB_TYPE GLubyte #define RB_TYPE GLubyte
#define SPAN_VARS \ #define SPAN_VARS \
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx; MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \ #define INIT_PIXEL_PTR(P, X, Y) \
GLuint *P = (GLuint *)(((GLubyte **) mr->GetRows())[Y] + (X) * 4) GLuint* P = (GLuint*)(((GLubyte**)mr->GetRows())[Y] + (X) * 4)
#define INC_PIXEL_PTR(P) P += 1 #define INC_PIXEL_PTR(P) P += 1
#define STORE_PIXEL(DST, X, Y, VALUE) \ #define STORE_PIXEL(DST, X, Y, VALUE) \
*DST = ( ((VALUE[RCOMP]) << 16) | \ *DST = ( ((VALUE[RCOMP]) << 16) | \
@@ -124,9 +124,9 @@ extern "C" {
#define NAME(PREFIX) PREFIX##_RGB24 #define NAME(PREFIX) PREFIX##_RGB24
#define RB_TYPE GLubyte #define RB_TYPE GLubyte
#define SPAN_VARS \ #define SPAN_VARS \
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx; MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \ #define INIT_PIXEL_PTR(P, X, Y) \
GLubyte *P = ((GLubyte **) mr->GetRows())[Y] + (X) * 3 GLubyte* P = ((GLubyte**)mr->GetRows())[Y] + (X) * 3
#define INC_PIXEL_PTR(P) P += 3 #define INC_PIXEL_PTR(P) P += 3
#define STORE_PIXEL(DST, X, Y, VALUE) \ #define STORE_PIXEL(DST, X, Y, VALUE) \
DST[BE_RCOMP] = VALUE[RCOMP]; \ DST[BE_RCOMP] = VALUE[RCOMP]; \
@@ -143,9 +143,9 @@ extern "C" {
#define NAME(PREFIX) PREFIX##_RGB16 #define NAME(PREFIX) PREFIX##_RGB16
#define RB_TYPE GLubyte #define RB_TYPE GLubyte
#define SPAN_VARS \ #define SPAN_VARS \
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx; MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \ #define INIT_PIXEL_PTR(P, X, Y) \
GLushort *P = (GLushort *) (((GLubyte **) mr->GetRows())[Y] + (X) * 2) GLushort* P = (GLushort*)(((GLubyte**)mr->GetRows())[Y] + (X) * 2)
#define INC_PIXEL_PTR(P) P += 1 #define INC_PIXEL_PTR(P) P += 1
#define STORE_PIXEL(DST, X, Y, VALUE) \ #define STORE_PIXEL(DST, X, Y, VALUE) \
*DST = ( (((VALUE[RCOMP]) & 0xf8) << 8) | \ *DST = ( (((VALUE[RCOMP]) & 0xf8) << 8) | \
@@ -162,9 +162,9 @@ extern "C" {
#define NAME(PREFIX) PREFIX##_RGB15 #define NAME(PREFIX) PREFIX##_RGB15
#define RB_TYPE GLubyte #define RB_TYPE GLubyte
#define SPAN_VARS \ #define SPAN_VARS \
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx; MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx;
#define INIT_PIXEL_PTR(P, X, Y) \ #define INIT_PIXEL_PTR(P, X, Y) \
GLushort *P = (GLushort *) (((GLubyte **) mr->GetRows())[Y] + (X) * 2) GLushort* P = (GLushort*)(((GLubyte**)mr->GetRows())[Y] + (X) * 2)
#define INC_PIXEL_PTR(P) P += 1 #define INC_PIXEL_PTR(P) P += 1
#define STORE_PIXEL(DST, X, Y, VALUE) \ #define STORE_PIXEL(DST, X, Y, VALUE) \
*DST = ( (((VALUE[RCOMP]) & 0xf8) << 7) | \ *DST = ( (((VALUE[RCOMP]) & 0xf8) << 7) | \
@@ -181,10 +181,10 @@ extern "C" {
#define NAME(PREFIX) PREFIX##_CMAP8 #define NAME(PREFIX) PREFIX##_CMAP8
#define RB_TYPE GLubyte #define RB_TYPE GLubyte
#define SPAN_VARS \ #define SPAN_VARS \
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx; \ MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx; \
const color_map *colorMap = system_colors(); const color_map* colorMap = system_colors();
#define INIT_PIXEL_PTR(P, X, Y) \ #define INIT_PIXEL_PTR(P, X, Y) \
GLubyte *P = ((GLubyte **) mr->GetRows())[Y] + (X) GLubyte* P = ((GLubyte**) mr->GetRows())[Y] + (X)
#define INC_PIXEL_PTR(P) P += 1 #define INC_PIXEL_PTR(P) P += 1
#define STORE_PIXEL(DST, X, Y, VALUE) \ #define STORE_PIXEL(DST, X, Y, VALUE) \
*DST = colorMap->index_map[( (((VALUE[BCOMP]) ) >> 3) | \ *DST = colorMap->index_map[( (((VALUE[BCOMP]) ) >> 3) | \
@@ -450,7 +450,7 @@ MesaSoftwareRenderer::Draw(BRect updateRect)
status_t status_t
MesaSoftwareRenderer::CopyPixelsOut(BPoint location, BBitmap *bitmap) MesaSoftwareRenderer::CopyPixelsOut(BPoint location, BBitmap* bitmap)
{ {
CALLED(); CALLED();
color_space scs = fBitmap->ColorSpace(); color_space scs = fBitmap->ColorSpace();
@@ -469,15 +469,16 @@ MesaSoftwareRenderer::CopyPixelsOut(BPoint location, BBitmap *bitmap)
sr = sr & dr.OffsetBySelf(location); sr = sr & dr.OffsetBySelf(location);
dr = sr.OffsetByCopy(-location.x, -location.y); dr = sr.OffsetByCopy(-location.x, -location.y);
uint8 *ps = (uint8 *) fBitmap->Bits(); uint8* ps = (uint8*) fBitmap->Bits();
uint8 *pd = (uint8 *) bitmap->Bits(); uint8* pd = (uint8*) bitmap->Bits();
uint32 *s, *d; uint32* s,
uint32* d;
uint32 y; uint32 y;
for (y = (uint32) sr.top; y <= (uint32) sr.bottom; 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; s += (uint32) sr.left;
d = (uint32 *)(pd + (y + (uint32)(dr.top - sr.top)) d = (uint32*)(pd + (y + (uint32)(dr.top - sr.top))
* bitmap->BytesPerRow()); * bitmap->BytesPerRow());
d += (uint32) dr.left; d += (uint32) dr.left;
@@ -488,7 +489,7 @@ MesaSoftwareRenderer::CopyPixelsOut(BPoint location, BBitmap *bitmap)
status_t status_t
MesaSoftwareRenderer::CopyPixelsIn(BBitmap *bitmap, BPoint location) MesaSoftwareRenderer::CopyPixelsIn(BBitmap* bitmap, BPoint location)
{ {
CALLED(); CALLED();
color_space scs = bitmap->ColorSpace(); color_space scs = bitmap->ColorSpace();
@@ -507,15 +508,16 @@ MesaSoftwareRenderer::CopyPixelsIn(BBitmap *bitmap, BPoint location)
sr = sr & dr.OffsetBySelf(location); sr = sr & dr.OffsetBySelf(location);
dr = sr.OffsetByCopy(-location.x, -location.y); dr = sr.OffsetByCopy(-location.x, -location.y);
uint8 *ps = (uint8 *) bitmap->Bits(); uint8* ps = (uint8*) bitmap->Bits();
uint8 *pd = (uint8 *) fBitmap->Bits(); uint8* pd = (uint8*) fBitmap->Bits();
uint32 *s, *d; uint32* s;
uint32* d;
uint32 y; uint32 y;
for (y = (uint32) sr.top; y <= (uint32) sr.bottom; 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; s += (uint32) sr.left;
d = (uint32 *)(pd + (y + (uint32)(dr.top - sr.top)) d = (uint32*)(pd + (y + (uint32)(dr.top - sr.top))
* fBitmap->BytesPerRow()); * fBitmap->BytesPerRow());
d += (uint32) dr.left; d += (uint32) dr.left;
@@ -533,7 +535,7 @@ MesaSoftwareRenderer::EnableDirectMode(bool enabled)
void void
MesaSoftwareRenderer::DirectConnected(direct_buffer_info *info) MesaSoftwareRenderer::DirectConnected(direct_buffer_info* info)
{ {
// TODO: I'm not sure we need to do this: BGLView already // TODO: I'm not sure we need to do this: BGLView already
// keeps a local copy of the direct_buffer_info passed by // keeps a local copy of the direct_buffer_info passed by
@@ -541,7 +543,7 @@ MesaSoftwareRenderer::DirectConnected(direct_buffer_info *info)
BAutolock lock(fInfoLocker); BAutolock lock(fInfoLocker);
if (info) { if (info) {
if (!fInfo) { if (!fInfo) {
fInfo = (direct_buffer_info *)malloc(DIRECT_BUFFER_INFO_AREA_SIZE); fInfo = (direct_buffer_info*)malloc(DIRECT_BUFFER_INFO_AREA_SIZE);
if (!fInfo) if (!fInfo)
return; return;
} }
@@ -550,7 +552,6 @@ MesaSoftwareRenderer::DirectConnected(direct_buffer_info *info)
free(fInfo); free(fInfo);
fInfo = NULL; fInfo = NULL;
} }
} }
@@ -569,6 +570,7 @@ MesaSoftwareRenderer::_AllocateBitmap()
// allocate new size of back buffer bitmap // allocate new size of back buffer bitmap
delete fBitmap; delete fBitmap;
fBitmap = NULL; fBitmap = NULL;
if (fWidth < 1 || fHeight < 1) if (fWidth < 1 || fHeight < 1)
return; return;
BRect rect(0.0, 0.0, fWidth - 1, fHeight - 1); BRect rect(0.0, 0.0, fWidth - 1, fHeight - 1);
@@ -591,16 +593,16 @@ MesaSoftwareRenderer::_AllocateBitmap()
void void
MesaSoftwareRenderer::_Error(GLcontext *ctx) MesaSoftwareRenderer::_Error(GLcontext* ctx)
{ {
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx; MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx;
if (mr && mr->GLView()) if (mr && mr->GLView())
mr->GLView()->ErrorCallback((unsigned long) ctx->ErrorValue); mr->GLView()->ErrorCallback((unsigned long)ctx->ErrorValue);
} }
const GLubyte * const GLubyte*
MesaSoftwareRenderer::_GetString(GLcontext *ctx, GLenum name) MesaSoftwareRenderer::_GetString(GLcontext* ctx, GLenum name)
{ {
switch (name) { switch (name) {
case GL_RENDERER: { case GL_RENDERER: {
@@ -667,14 +669,14 @@ MesaSoftwareRenderer::_GetString(GLcontext *ctx, GLenum name)
void void
MesaSoftwareRenderer::_Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, MesaSoftwareRenderer::_Viewport(GLcontext* ctx, GLint x, GLint y, GLsizei w,
GLsizei h) GLsizei h)
{ {
CALLED(); CALLED();
GLframebuffer *draw = ctx->WinSysDrawBuffer; GLframebuffer* draw = ctx->WinSysDrawBuffer;
GLframebuffer *read = ctx->WinSysReadBuffer; GLframebuffer* read = ctx->WinSysReadBuffer;
struct msr_framebuffer *msr = msr_framebuffer(draw); struct msr_framebuffer* msr = msr_framebuffer(draw);
_mesa_resize_framebuffer(ctx, draw, msr->Width, msr->Height); _mesa_resize_framebuffer(ctx, draw, msr->Width, msr->Height);
_mesa_resize_framebuffer(ctx, read, msr->Width, msr->Height); _mesa_resize_framebuffer(ctx, read, msr->Width, msr->Height);
@@ -682,7 +684,7 @@ MesaSoftwareRenderer::_Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w,
void void
MesaSoftwareRenderer::_UpdateState(GLcontext *ctx, GLuint new_state) MesaSoftwareRenderer::_UpdateState(GLcontext* ctx, GLuint new_state)
{ {
if (!ctx) if (!ctx)
return; return;
@@ -696,19 +698,19 @@ MesaSoftwareRenderer::_UpdateState(GLcontext *ctx, GLuint new_state)
void void
MesaSoftwareRenderer::_ClearFront(GLcontext *ctx) MesaSoftwareRenderer::_ClearFront(GLcontext* ctx)
{ {
CALLED(); CALLED();
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx; MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx;
BGLView *bglview = mr->GLView(); BGLView* bglview = mr->GLView();
assert(bglview); assert(bglview);
BBitmap *bitmap = mr->fBitmap; BBitmap* bitmap = mr->fBitmap;
assert(bitmap); assert(bitmap);
GLuint *start = (GLuint *) bitmap->Bits(); GLuint* start = (GLuint*)bitmap->Bits();
size_t pixelSize = 0; size_t pixelSize = 0;
get_pixel_size_for(bitmap->ColorSpace(), &pixelSize, NULL, NULL); get_pixel_size_for(bitmap->ColorSpace(), &pixelSize, NULL, NULL);
const GLuint *clearPixelPtr = (const GLuint *) mr->fClearColor; const GLuint* clearPixelPtr = (const GLuint*)mr->fClearColor;
const GLuint clearPixel = B_LENDIAN_TO_HOST_INT32(*clearPixelPtr); const GLuint clearPixel = B_LENDIAN_TO_HOST_INT32(*clearPixelPtr);
int x = ctx->DrawBuffer->_Xmin; int x = ctx->DrawBuffer->_Xmin;
@@ -757,7 +759,7 @@ MesaSoftwareRenderer::_BackRenderbufferStorage(GLcontext* ctx,
struct gl_renderbuffer* render, GLenum internalFormat, struct gl_renderbuffer* render, GLenum internalFormat,
GLuint width, GLuint height) GLuint width, GLuint height)
{ {
struct msr_renderbuffer *mrb = msr_renderbuffer(render); struct msr_renderbuffer* mrb = msr_renderbuffer(render);
_mesa_free(render->Data); _mesa_free(render->Data);
_FrontRenderbufferStorage(ctx, render, internalFormat, width, height); _FrontRenderbufferStorage(ctx, render, internalFormat, width, height);
render->Data = _mesa_malloc(mrb->Size); render->Data = _mesa_malloc(mrb->Size);
@@ -766,10 +768,10 @@ MesaSoftwareRenderer::_BackRenderbufferStorage(GLcontext* ctx,
void void
MesaSoftwareRenderer::_Flush(GLcontext *ctx) MesaSoftwareRenderer::_Flush(GLcontext* ctx)
{ {
CALLED(); CALLED();
MesaSoftwareRenderer *mr = (MesaSoftwareRenderer *) ctx->DriverCtx; MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx;
if ((mr->fOptions & BGL_DOUBLE) == 0) { if ((mr->fOptions & BGL_DOUBLE) == 0) {
mr->SwapBuffers(); mr->SwapBuffers();
} }
@@ -862,6 +864,7 @@ MesaSoftwareRenderer::_CopyToDirect()
|| fInfo->window_bounds.right - fInfo->window_bounds.left || fInfo->window_bounds.right - fInfo->window_bounds.left
!= fBitmap->Bounds().IntegerWidth()) != fBitmap->Bounds().IntegerWidth())
return; return;
uint8 bytesPerPixel = fInfo->bits_per_pixel / 8; uint8 bytesPerPixel = fInfo->bits_per_pixel / 8;
uint32 bytesPerRow = fBitmap->BytesPerRow(); uint32 bytesPerRow = fBitmap->BytesPerRow();
for (uint32 i = 0; i < fInfo->clip_list_count; i++) { for (uint32 i = 0; i < fInfo->clip_list_count; i++) {
@@ -869,9 +872,9 @@ MesaSoftwareRenderer::_CopyToDirect()
int32 height = clip->bottom - clip->top + 1; int32 height = clip->bottom - clip->top + 1;
int32 bytesWidth int32 bytesWidth
= (clip->right - clip->left + 1) * bytesPerPixel; = (clip->right - clip->left + 1) * bytesPerPixel;
uint8 *p = (uint8 *)fInfo->bits + clip->top uint8* p = (uint8*)fInfo->bits + clip->top
* fInfo->bytes_per_row + clip->left * bytesPerPixel; * 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) + (clip->left - fInfo->window_bounds.left)
* bytesPerPixel; * bytesPerPixel;