diff options
author | Eric Anholt <[email protected]> | 2013-01-16 15:01:10 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2013-01-21 21:26:46 -0800 |
commit | 23916cae8ed3c18ae6b851365a25ccff6fcce7da (patch) | |
tree | 7a9c23d3b949c32a52b60dc6ea8ad1ea24fd5774 /src/mesa/vbo/vbo_exec_api.c | |
parent | 7b3c8b37472d84cc6aac2b178c0d8bb3f789a9bb (diff) |
mesa: Use an early return to unindent most of vbo_exec_Begin/End().
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/vbo/vbo_exec_api.c')
-rw-r--r-- | src/mesa/vbo/vbo_exec_api.c | 109 |
1 files changed, 54 insertions, 55 deletions
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 657c9aaee50..42eb953c223 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -789,54 +789,53 @@ vbo_exec_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) static void GLAPIENTRY vbo_exec_Begin( GLenum mode ) { GET_CURRENT_CONTEXT( ctx ); + struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + int i; - if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END) { - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - int i; - - if (!_mesa_valid_prim_mode(ctx, mode, "glBegin")) { - return; - } + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glBegin"); + return; + } - vbo_draw_method(vbo_context(ctx), DRAW_BEGIN_END); + if (!_mesa_valid_prim_mode(ctx, mode, "glBegin")) { + return; + } - if (ctx->Driver.PrepareExecBegin) - ctx->Driver.PrepareExecBegin(ctx); + vbo_draw_method(vbo_context(ctx), DRAW_BEGIN_END); - if (ctx->NewState) { - _mesa_update_state( ctx ); + if (ctx->Driver.PrepareExecBegin) + ctx->Driver.PrepareExecBegin(ctx); - CALL_Begin(ctx->Exec, (mode)); - return; - } + if (ctx->NewState) { + _mesa_update_state( ctx ); - if (!_mesa_valid_to_render(ctx, "glBegin")) { - return; - } + CALL_Begin(ctx->Exec, (mode)); + return; + } - /* Heuristic: attempt to isolate attributes occuring outside - * begin/end pairs. - */ - if (exec->vtx.vertex_size && !exec->vtx.attrsz[0]) - vbo_exec_FlushVertices_internal(exec, GL_FALSE); - - i = exec->vtx.prim_count++; - exec->vtx.prim[i].mode = mode; - exec->vtx.prim[i].begin = 1; - exec->vtx.prim[i].end = 0; - exec->vtx.prim[i].indexed = 0; - exec->vtx.prim[i].weak = 0; - exec->vtx.prim[i].pad = 0; - exec->vtx.prim[i].start = exec->vtx.vert_count; - exec->vtx.prim[i].count = 0; - exec->vtx.prim[i].num_instances = 1; - exec->vtx.prim[i].base_instance = 0; - - ctx->Driver.CurrentExecPrimitive = mode; + if (!_mesa_valid_to_render(ctx, "glBegin")) { + return; } - else - _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" ); - + + /* Heuristic: attempt to isolate attributes occuring outside + * begin/end pairs. + */ + if (exec->vtx.vertex_size && !exec->vtx.attrsz[0]) + vbo_exec_FlushVertices_internal(exec, GL_FALSE); + + i = exec->vtx.prim_count++; + exec->vtx.prim[i].mode = mode; + exec->vtx.prim[i].begin = 1; + exec->vtx.prim[i].end = 0; + exec->vtx.prim[i].indexed = 0; + exec->vtx.prim[i].weak = 0; + exec->vtx.prim[i].pad = 0; + exec->vtx.prim[i].start = exec->vtx.vert_count; + exec->vtx.prim[i].count = 0; + exec->vtx.prim[i].num_instances = 1; + exec->vtx.prim[i].base_instance = 0; + + ctx->Driver.CurrentExecPrimitive = mode; } @@ -846,26 +845,26 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode ) static void GLAPIENTRY vbo_exec_End( void ) { GET_CURRENT_CONTEXT( ctx ); + struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { - struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glEnd"); + return; + } - if (exec->vtx.prim_count > 0) { - /* close off current primitive */ - int idx = exec->vtx.vert_count; - int i = exec->vtx.prim_count - 1; + if (exec->vtx.prim_count > 0) { + /* close off current primitive */ + int idx = exec->vtx.vert_count; + int i = exec->vtx.prim_count - 1; - exec->vtx.prim[i].end = 1; - exec->vtx.prim[i].count = idx - exec->vtx.prim[i].start; - } + exec->vtx.prim[i].end = 1; + exec->vtx.prim[i].count = idx - exec->vtx.prim[i].start; + } - ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; + ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; - if (exec->vtx.prim_count == VBO_MAX_PRIM) - vbo_exec_vtx_flush( exec, GL_FALSE ); - } - else - _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" ); + if (exec->vtx.prim_count == VBO_MAX_PRIM) + vbo_exec_vtx_flush( exec, GL_FALSE ); if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) { _mesa_flush(ctx); |