main: Refactor _mesa_[update|get]_clamp_fragment_color.
Reviewed-by: Fredrik Höglund <fredrik@kde.org> Signed-off-by: Fredrik Höglund <fredrik@kde.org>
This commit is contained in:

committed by
Fredrik Höglund

parent
c1fe8d841c
commit
2cabfd9636
@@ -778,7 +778,7 @@ _mesa_ClampColor(GLenum target, GLenum clamp)
|
||||
}
|
||||
FLUSH_VERTICES(ctx, _NEW_FRAG_CLAMP);
|
||||
ctx->Color.ClampFragmentColor = clamp;
|
||||
_mesa_update_clamp_fragment_color(ctx);
|
||||
_mesa_update_clamp_fragment_color(ctx, ctx->DrawBuffer);
|
||||
break;
|
||||
case GL_CLAMP_READ_COLOR_ARB:
|
||||
ctx->Color.ClampReadColor = clamp;
|
||||
@@ -807,10 +807,10 @@ get_clamp_color(const struct gl_framebuffer *fb, GLenum clamp)
|
||||
}
|
||||
|
||||
GLboolean
|
||||
_mesa_get_clamp_fragment_color(const struct gl_context *ctx)
|
||||
_mesa_get_clamp_fragment_color(const struct gl_context *ctx,
|
||||
const struct gl_framebuffer *drawFb)
|
||||
{
|
||||
return get_clamp_color(ctx->DrawBuffer,
|
||||
ctx->Color.ClampFragmentColor);
|
||||
return get_clamp_color(drawFb, ctx->Color.ClampFragmentColor);
|
||||
}
|
||||
|
||||
GLboolean
|
||||
@@ -830,19 +830,20 @@ _mesa_get_clamp_read_color(const struct gl_context *ctx)
|
||||
* Update the ctx->Color._ClampFragmentColor field
|
||||
*/
|
||||
void
|
||||
_mesa_update_clamp_fragment_color(struct gl_context *ctx)
|
||||
_mesa_update_clamp_fragment_color(struct gl_context *ctx,
|
||||
const struct gl_framebuffer *drawFb)
|
||||
{
|
||||
struct gl_framebuffer *fb = ctx->DrawBuffer;
|
||||
|
||||
/* Don't clamp if:
|
||||
* - there is no colorbuffer
|
||||
* - all colorbuffers are unsigned normalized, so clamping has no effect
|
||||
* - there is an integer colorbuffer
|
||||
*/
|
||||
if (!fb || !fb->_HasSNormOrFloatColorBuffer || fb->_IntegerColor)
|
||||
if (!drawFb || !drawFb->_HasSNormOrFloatColorBuffer ||
|
||||
drawFb->_IntegerColor)
|
||||
ctx->Color._ClampFragmentColor = GL_FALSE;
|
||||
else
|
||||
ctx->Color._ClampFragmentColor = _mesa_get_clamp_fragment_color(ctx);
|
||||
ctx->Color._ClampFragmentColor =
|
||||
_mesa_get_clamp_fragment_color(ctx, drawFb);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -102,7 +102,8 @@ extern void GLAPIENTRY
|
||||
_mesa_ClampColor(GLenum target, GLenum clamp);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_get_clamp_fragment_color(const struct gl_context *ctx);
|
||||
_mesa_get_clamp_fragment_color(const struct gl_context *ctx,
|
||||
const struct gl_framebuffer *drawFb);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_get_clamp_vertex_color(const struct gl_context *ctx,
|
||||
@@ -112,7 +113,8 @@ extern GLboolean
|
||||
_mesa_get_clamp_read_color(const struct gl_context *ctx);
|
||||
|
||||
extern void
|
||||
_mesa_update_clamp_fragment_color(struct gl_context *ctx);
|
||||
_mesa_update_clamp_fragment_color(struct gl_context *ctx,
|
||||
const struct gl_framebuffer *drawFb);
|
||||
|
||||
extern void
|
||||
_mesa_update_clamp_vertex_color(struct gl_context *ctx,
|
||||
|
@@ -692,7 +692,7 @@ _mesa_update_framebuffer(struct gl_context *ctx,
|
||||
update_framebuffer(ctx, readFb);
|
||||
|
||||
_mesa_update_clamp_vertex_color(ctx, drawFb);
|
||||
_mesa_update_clamp_fragment_color(ctx);
|
||||
_mesa_update_clamp_fragment_color(ctx, drawFb);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -909,13 +909,13 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
|
||||
break;
|
||||
|
||||
case GL_FOG_COLOR:
|
||||
if (_mesa_get_clamp_fragment_color(ctx))
|
||||
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
|
||||
COPY_4FV(v->value_float_4, ctx->Fog.Color);
|
||||
else
|
||||
COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped);
|
||||
break;
|
||||
case GL_COLOR_CLEAR_VALUE:
|
||||
if (_mesa_get_clamp_fragment_color(ctx)) {
|
||||
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) {
|
||||
v->value_float_4[0] = CLAMP(ctx->Color.ClearColor.f[0], 0.0F, 1.0F);
|
||||
v->value_float_4[1] = CLAMP(ctx->Color.ClearColor.f[1], 0.0F, 1.0F);
|
||||
v->value_float_4[2] = CLAMP(ctx->Color.ClearColor.f[2], 0.0F, 1.0F);
|
||||
@@ -924,13 +924,13 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
|
||||
COPY_4FV(v->value_float_4, ctx->Color.ClearColor.f);
|
||||
break;
|
||||
case GL_BLEND_COLOR_EXT:
|
||||
if (_mesa_get_clamp_fragment_color(ctx))
|
||||
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
|
||||
COPY_4FV(v->value_float_4, ctx->Color.BlendColor);
|
||||
else
|
||||
COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped);
|
||||
break;
|
||||
case GL_ALPHA_TEST_REF:
|
||||
if (_mesa_get_clamp_fragment_color(ctx))
|
||||
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
|
||||
v->value_float = ctx->Color.AlphaRef;
|
||||
else
|
||||
v->value_float = ctx->Color.AlphaRefUnclamped;
|
||||
|
@@ -646,7 +646,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
|
||||
if (pname == GL_TEXTURE_ENV_COLOR) {
|
||||
if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
|
||||
_mesa_update_state(ctx);
|
||||
if (_mesa_get_clamp_fragment_color(ctx))
|
||||
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
|
||||
COPY_4FV( params, texUnit->EnvColor );
|
||||
else
|
||||
COPY_4FV( params, texUnit->EnvColorUnclamped );
|
||||
|
@@ -1709,7 +1709,7 @@ get_tex_parameterfv(struct gl_context *ctx,
|
||||
|
||||
if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
|
||||
_mesa_update_state_locked(ctx);
|
||||
if (_mesa_get_clamp_fragment_color(ctx)) {
|
||||
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) {
|
||||
params[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F);
|
||||
params[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F);
|
||||
params[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F);
|
||||
|
@@ -244,14 +244,14 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
|
||||
{
|
||||
/* state[1] is the texture unit */
|
||||
const GLuint unit = (GLuint) state[1];
|
||||
if (_mesa_get_clamp_fragment_color(ctx))
|
||||
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
|
||||
COPY_4V(value, ctx->Texture.Unit[unit].EnvColor);
|
||||
else
|
||||
COPY_4V(value, ctx->Texture.Unit[unit].EnvColorUnclamped);
|
||||
}
|
||||
return;
|
||||
case STATE_FOG_COLOR:
|
||||
if (_mesa_get_clamp_fragment_color(ctx))
|
||||
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
|
||||
COPY_4V(value, ctx->Fog.Color);
|
||||
else
|
||||
COPY_4V(value, ctx->Fog.ColorUnclamped);
|
||||
|
Reference in New Issue
Block a user