Skip to content

Commit

Permalink
swpipe: Cleanup; Store GalliumContext
Browse files Browse the repository at this point in the history
* Store GalliumContext in st_manager_private
  • Loading branch information
kallisti5 committed Mar 24, 2013
1 parent 2b69feb commit d31319b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.
37 changes: 7 additions & 30 deletions src/add-ons/opengl/swpipe/GalliumContext.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -49,37 +49,14 @@ static void
hgl_viewport(struct gl_context* glContext, GLint x, GLint y, hgl_viewport(struct gl_context* glContext, GLint x, GLint y,
GLsizei width, GLsizei height) GLsizei width, GLsizei height)
{ {
TRACE("%s(glContext: %p, x: %d, y: %d, width: %d, height: %d\n", __func__, TRACE("%s(glContext: %p, x: %d, y: %d, w: %d, h: %d\n", __func__,
glContext, x, y, width, height); glContext, x, y, width, height);


#if 0
struct hgl_context* context = DOWNCAST(hgl_context, gl_context, glContext);

if (!context) {
ERROR("%s: No context yet. bailing.\n", __func__);
return;
}

int32 bitmapWidth;
int32 bitmapHeight;

get_bitmap_size(context->bitmap, &bitmapWidth, &bitmapHeight);

if (width != bitmapWidth || height != bitmapHeight) {
struct gl_framebuffer *draw = glContext->WinSysDrawBuffer;
struct gl_framebuffer *read = glContext->WinSysReadBuffer;

if (draw)
_mesa_resize_framebuffer(glContext, draw, bitmapWidth, bitmapHeight);
if (read)
_mesa_resize_framebuffer(glContext, read, bitmapWidth, bitmapHeight);
}
#endif
struct gl_framebuffer *draw = glContext->WinSysDrawBuffer; struct gl_framebuffer *draw = glContext->WinSysDrawBuffer;
struct gl_framebuffer *read = glContext->WinSysReadBuffer; struct gl_framebuffer *read = glContext->WinSysReadBuffer;


// TODO: SLOW! We need to check for changes in size here. // TODO: SLOW! We need to check for changes in bitmap vs gl_framebuffer

// size before doing a _mesa_resize_framebuffer.
if (draw) if (draw)
_mesa_resize_framebuffer(glContext, draw, width, height); _mesa_resize_framebuffer(glContext, draw, width, height);
if (read) if (read)
Expand Down Expand Up @@ -313,8 +290,8 @@ GalliumContext::CreateContext(Bitmap *bitmap)
// Convert Mesa calculated visual into state tracker visual // Convert Mesa calculated visual into state tracker visual
context->stVisual = hgl_fill_st_visual(glVisual); context->stVisual = hgl_fill_st_visual(glVisual);


context->draw = new GalliumFramebuffer(context->stVisual); context->draw = new GalliumFramebuffer(context->stVisual, (void*)this);
context->read = new GalliumFramebuffer(context->stVisual); context->read = new GalliumFramebuffer(context->stVisual, (void*)this);


if (!context->draw || !context->read) { if (!context->draw || !context->read) {
ERROR("%s: Problem allocating framebuffer!\n", __func__); ERROR("%s: Problem allocating framebuffer!\n", __func__);
Expand Down Expand Up @@ -377,7 +354,7 @@ GalliumContext::CreateContext(Bitmap *bitmap)
//context->postProcess = pp_init(fScreen, context->postProcessEnable); //context->postProcess = pp_init(fScreen, context->postProcessEnable);


assert(!context->st->st_manager_private); assert(!context->st->st_manager_private);
context->st->st_manager_private = (void*)context; context->st->st_manager_private = (void*)this;


struct st_context *stContext = (struct st_context*)context->st; struct st_context *stContext = (struct st_context*)context->st;


Expand Down Expand Up @@ -470,7 +447,7 @@ GalliumContext::SetCurrentContext(Bitmap *bitmap, context_id contextID)


if (!bitmap) { if (!bitmap) {
api->make_current(context->api, NULL, NULL, NULL); api->make_current(context->api, NULL, NULL, NULL);
return B_ERROR; return B_OK;
} }


// Everything seems valid, lets set the new context. // Everything seems valid, lets set the new context.
Expand Down
4 changes: 3 additions & 1 deletion src/add-ons/opengl/swpipe/GalliumFramebuffer.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ hgl_framebuffer_validate(struct st_framebuffer_iface* stfb,
} }




GalliumFramebuffer::GalliumFramebuffer(struct st_visual* visual) GalliumFramebuffer::GalliumFramebuffer(struct st_visual* visual,
void* privateContext)
: :
fBuffer(NULL) fBuffer(NULL)
{ {
Expand All @@ -73,6 +74,7 @@ GalliumFramebuffer::GalliumFramebuffer(struct st_visual* visual)
fBuffer->visual = visual; fBuffer->visual = visual;
fBuffer->flush_front = hgl_framebuffer_flush_front; fBuffer->flush_front = hgl_framebuffer_flush_front;
fBuffer->validate = hgl_framebuffer_validate; fBuffer->validate = hgl_framebuffer_validate;
fBuffer->st_manager_private = privateContext;


pipe_mutex_init(fMutex); pipe_mutex_init(fMutex);
} }
Expand Down
3 changes: 2 additions & 1 deletion src/add-ons/opengl/swpipe/GalliumFramebuffer.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ extern "C" {


class GalliumFramebuffer { class GalliumFramebuffer {
public: public:
GalliumFramebuffer(struct st_visual* visual); GalliumFramebuffer(struct st_visual* visual,
void* privateContext);
~GalliumFramebuffer(); ~GalliumFramebuffer();
status_t Lock(); status_t Lock();
status_t Unlock(); status_t Unlock();
Expand Down
2 changes: 1 addition & 1 deletion src/add-ons/opengl/swpipe/SoftwareWinsys.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ hook_winsys_displaytarget_create(struct sw_winsys* winsys,
unsigned textureUsage, enum pipe_format format, unsigned width, unsigned textureUsage, enum pipe_format format, unsigned width,
unsigned height, unsigned alignment, unsigned* stride) unsigned height, unsigned alignment, unsigned* stride)
{ {
CALLED(); TRACE("%s: %dx%d\n", __func__, width, height);


struct haiku_displaytarget* haikuDisplayTarget struct haiku_displaytarget* haikuDisplayTarget
= CALLOC_STRUCT(haiku_displaytarget); = CALLOC_STRUCT(haiku_displaytarget);
Expand Down

0 comments on commit d31319b

Please sign in to comment.