diff options
author | Chia-I Wu <[email protected]> | 2010-11-26 23:21:17 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2010-12-01 11:23:49 +0800 |
commit | 6b241f532a21990a7849c5a786504f7ac4124f76 (patch) | |
tree | 7c2763a9002c8a609c7cdcd5c3cbaf53709f7b91 /src/gallium/state_trackers/vega/renderer.c | |
parent | 54cb382ea55610688c97465ef048a4990b8fd4d7 (diff) |
st/vega: Add CLEAR renderer state for vgClear.
This state provides the ability to clear rectangles of the framebuffer
to the specified color, honoring scissoring. vegaClear is updated to
make use of the state.
Diffstat (limited to 'src/gallium/state_trackers/vega/renderer.c')
-rw-r--r-- | src/gallium/state_trackers/vega/renderer.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index 60c4315a1fd..d326cfc5015 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -48,6 +48,7 @@ typedef enum { RENDERER_STATE_COPY, RENDERER_STATE_DRAWTEX, RENDERER_STATE_SCISSOR, + RENDERER_STATE_CLEAR, NUM_RENDERER_STATES } RendererState; @@ -623,6 +624,60 @@ void renderer_scissor_end(struct renderer *renderer) renderer->state = RENDERER_STATE_INIT; } +/** + * Prepare the renderer for clearing. + */ +VGboolean renderer_clear_begin(struct renderer *renderer) +{ + assert(renderer->state == RENDERER_STATE_INIT); + + cso_save_blend(renderer->cso); + cso_save_fragment_shader(renderer->cso); + cso_save_vertex_shader(renderer->cso); + + renderer_set_blend(renderer, ~0); + renderer_set_fs(renderer, RENDERER_FS_COLOR); + renderer_set_vs(renderer, RENDERER_VS_COLOR); + + renderer->state = RENDERER_STATE_CLEAR; + + return VG_TRUE; +} + +/** + * Clear the framebuffer with the specified region and color. + * + * The coordinates are in surface coordinates. + */ +void renderer_clear(struct renderer *renderer, + VGint x, VGint y, VGint width, VGint height, + const VGfloat color[4]) +{ + VGuint i; + + assert(renderer->state == RENDERER_STATE_CLEAR); + + renderer_quad_pos(renderer, x, y, x + width, y + height, VG_TRUE); + for (i = 0; i < 4; i++) + memcpy(renderer->vertices[i][1], color, sizeof(VGfloat) * 4); + + renderer_quad_draw(renderer); +} + +/** + * End clearing and retore the states. + */ +void renderer_clear_end(struct renderer *renderer) +{ + assert(renderer->state == RENDERER_STATE_CLEAR); + + cso_restore_blend(renderer->cso); + cso_restore_fragment_shader(renderer->cso); + cso_restore_vertex_shader(renderer->cso); + + renderer->state = RENDERER_STATE_INIT; +} + static void setup_shaders(struct renderer *ctx) { struct pipe_context *pipe = ctx->pipe; |