From 284efcfc27aaeb447e0898ae3342e9fee20c584a Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 3 Jul 2007 17:19:30 -0600 Subject: [PATCH] hook in state tracking for blend color --- src/mesa/pipe/p_context.h | 3 +++ src/mesa/pipe/softpipe/sp_context.c | 1 + src/mesa/pipe/softpipe/sp_state.h | 3 +++ src/mesa/pipe/softpipe/sp_state_blend.c | 11 +++++++++++ src/mesa/state_tracker/st_atom_blend.c | 9 +++++++++ src/mesa/state_tracker/st_context.h | 1 + 6 files changed, 28 insertions(+) diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index b87c428..e411522 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -66,6 +66,9 @@ struct pipe_context { void (*set_blend_state)( struct pipe_context *, const struct pipe_blend_state * ); + void (*set_blend_color)( struct pipe_context *, + const struct pipe_blend_color * ); + void (*set_clip_state)( struct pipe_context *, const struct pipe_clip_state * ); diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 5bd652f..6bd1d9f 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -67,6 +67,7 @@ struct pipe_context *softpipe_create( void ) softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state; softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state; softpipe->pipe.set_blend_state = softpipe_set_blend_state; + softpipe->pipe.set_blend_color = softpipe_set_blend_color; softpipe->pipe.set_clip_state = softpipe_set_clip_state; softpipe->pipe.set_clear_color_state = softpipe_set_clear_color_state; softpipe->pipe.set_depth_state = softpipe_set_depth_test_state; diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 60c2488..38a212b 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -44,6 +44,9 @@ void softpipe_set_alpha_test_state( struct pipe_context *, void softpipe_set_blend_state( struct pipe_context *, const struct pipe_blend_state * ); +void softpipe_set_blend_color( struct pipe_context *pipe, + const struct pipe_blend_color *blend_color ); + void softpipe_set_clear_color_state( struct pipe_context *, const struct pipe_clear_color_state * ); diff --git a/src/mesa/pipe/softpipe/sp_state_blend.c b/src/mesa/pipe/softpipe/sp_state_blend.c index c364d8a..6ca42e8 100644 --- a/src/mesa/pipe/softpipe/sp_state_blend.c +++ b/src/mesa/pipe/softpipe/sp_state_blend.c @@ -46,6 +46,17 @@ void softpipe_set_blend_state( struct pipe_context *pipe, } +void softpipe_set_blend_color( struct pipe_context *pipe, + const struct pipe_blend_color *blend_color ) +{ + struct softpipe_context *softpipe = softpipe_context(pipe); + + softpipe->blend_color = *blend_color; + + softpipe->dirty |= G_NEW_BLEND; +} + + /** XXX move someday? Or consolidate all these simple state setters * into one file. */ diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index e0215c9..3e5410c 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -201,6 +201,15 @@ update_blend( struct st_context *st ) st->state.blend = blend; /* struct copy */ st->pipe->set_blend_state(st->pipe, &blend); /* set new state */ } + + if (memcmp(st->ctx->Color.BlendColor, &st->state.blend_color, 4 * sizeof(GLfloat)) != 0) { + /* state has changed */ + st->state.blend_color.color[0] = st->ctx->Color.BlendColor[0]; + st->state.blend_color.color[1] = st->ctx->Color.BlendColor[1]; + st->state.blend_color.color[2] = st->ctx->Color.BlendColor[2]; + st->state.blend_color.color[3] = st->ctx->Color.BlendColor[3]; + st->pipe->set_blend_color(st->pipe, (struct pipe_blend_color *) st->ctx->Color.BlendColor); + } } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 3b47785..c1d8686 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -67,6 +67,7 @@ struct st_context struct { struct pipe_alpha_test_state alpha_test; struct pipe_blend_state blend; + struct pipe_blend_color blend_color; struct pipe_clear_color_state clear_color; struct pipe_clip_state clip; struct pipe_depth_state depth; -- 2.7.4