Skip to content

Commit

Permalink
GL: Cleanup
Browse files Browse the repository at this point in the history
Reordered gl_defer.c functions logically.
  • Loading branch information
skyjake committed Feb 8, 2012
1 parent ee25e35 commit cda9247
Showing 1 changed file with 64 additions and 64 deletions.
128 changes: 64 additions & 64 deletions doomsday/engine/portable/src/gl_defer.c
Expand Up @@ -116,39 +116,19 @@ static void enqueueTask(deferredtask_type_t type, void* data)
Sys_Unlock(deferredMutex);
}

static void destroyTaskData(deferredtask_t* d)
static deferredtask_t* nextTask(void)
{
apifunc_t* api = (apifunc_t*) d->data;

assert(VALID_DEFERREDTASK_TYPE(d->type));

// Free data allocated for the task.
switch(d->type)
assert(inited);
{
case DTT_UPLOAD_TEXTURECONTENT:
GL_DestroyTextureContent(d->data);
break;

case DTT_FUNC_PTR_UINT_ARRAY:
free(api->param.uintArray.values);
break;

default:
break;
}

if(d->type >= DTT_FUNC_PTR_BEGIN && d->type < DTT_FUNC_PTR_END)
deferredtask_t* d = NULL;
if(NULL != (d = (deferredtask_t*) deferredTaskFirst))
{
// Free the apifunc_t.
free(d->data);
deferredTaskFirst = d->next;
}
if(!deferredTaskFirst)
deferredTaskLast = NULL;
return d;
}
}

static void destroyTask(deferredtask_t* d)
{
assert(inited && d);
destroyTaskData(d);
free(d);
}

LIBDENG_GL_DEFER1(e, GLenum e)
Expand All @@ -174,21 +154,68 @@ LIBDENG_GL_DEFER2(uintArray, GLsizei s, const GLuint* v)
enqueueTask(DTT_FUNC_PTR_UINT_ARRAY, api);
}

static deferredtask_t* nextTask(void)
static void processTask(deferredtask_t* task)
{
assert(inited);
apifunc_t* api = (apifunc_t*) task->data;

switch(task->type)
{
deferredtask_t* d = NULL;
if(NULL != (d = (deferredtask_t*) deferredTaskFirst))
case DTT_UPLOAD_TEXTURECONTENT:
GL_UploadTextureContent(task->data);
break;

case DTT_FUNC_PTR_E:
#ifdef _DEBUG
fprintf(stderr, "processDeferred: ptr=%p param=%i\n", api->func.ptr_e, api->param.e);
#endif
api->func.ptr_e(api->param.e);
break;

case DTT_FUNC_PTR_UINT_ARRAY:
api->func.ptr_uintArray(api->param.uintArray.count, api->param.uintArray.values);
break;

default:
Con_Error("Unknown deferred GL task type %i.", (int) task->type);
break;
}
}

static void destroyTaskData(deferredtask_t* d)
{
apifunc_t* api = (apifunc_t*) d->data;

assert(VALID_DEFERREDTASK_TYPE(d->type));

// Free data allocated for the task.
switch(d->type)
{
deferredTaskFirst = d->next;
case DTT_UPLOAD_TEXTURECONTENT:
GL_DestroyTextureContent(d->data);
break;

case DTT_FUNC_PTR_UINT_ARRAY:
free(api->param.uintArray.values);
break;

default:
break;
}
if(!deferredTaskFirst)
deferredTaskLast = NULL;
return d;

if(d->type >= DTT_FUNC_PTR_BEGIN && d->type < DTT_FUNC_PTR_END)
{
// Free the apifunc_t.
free(d->data);
}
}

static void destroyTask(deferredtask_t* d)
{
assert(inited && d);
destroyTaskData(d);
free(d);
}

void GL_InitDeferredTask(void)
{
if(inited)
Expand Down Expand Up @@ -313,33 +340,6 @@ static deferredtask_t* GL_NextDeferredTask(void)
return d;
}

static void processTask(deferredtask_t* task)
{
apifunc_t* api = (apifunc_t*) task->data;

switch(task->type)
{
case DTT_UPLOAD_TEXTURECONTENT:
GL_UploadTextureContent(task->data);
break;

case DTT_FUNC_PTR_E:
#ifdef _DEBUG
fprintf(stderr, "processDeferred: ptr=%p param=%i\n", api->func.ptr_e, api->param.e);
#endif
api->func.ptr_e(api->param.e);
break;

case DTT_FUNC_PTR_UINT_ARRAY:
api->func.ptr_uintArray(api->param.uintArray.count, api->param.uintArray.values);
break;

default:
Con_Error("Unknown deferred GL task type %i.", (int) task->type);
break;
}
}

void GL_ProcessDeferredTasks(uint timeOutMilliSeconds)
{
deferredtask_t* d;
Expand Down

0 comments on commit cda9247

Please sign in to comment.