mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 19:40:43 -05:00
cogl-pipeline: Use enums for the layer combine values
Once the GLES2 wrapper is removed then we won't have the GLenums needed for setting up the layer combine state. This adds Cogl enums instead which have the same values as the corresponding GLenums. The enums are: CoglPipelineCombineFunc CoglPipelineCombineSource and CoglPipelineCombineOp
This commit is contained in:
parent
a05c701e6b
commit
2b32a9eb2a
@ -455,7 +455,7 @@ setup_arg (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
switch (src)
|
switch (src)
|
||||||
{
|
{
|
||||||
case GL_TEXTURE:
|
case COGL_PIPELINE_COMBINE_SOURCE_TEXTURE:
|
||||||
arg->type = COGL_PIPELINE_FRAGEND_ARBFP_ARG_TYPE_TEXTURE;
|
arg->type = COGL_PIPELINE_FRAGEND_ARBFP_ARG_TYPE_TEXTURE;
|
||||||
arg->name = "texel%d";
|
arg->name = "texel%d";
|
||||||
arg->texture_unit = _cogl_pipeline_layer_get_unit_index (layer);
|
arg->texture_unit = _cogl_pipeline_layer_get_unit_index (layer);
|
||||||
@ -463,7 +463,7 @@ setup_arg (CoglPipeline *pipeline,
|
|||||||
cogl_texture_get_gl_texture (texture, NULL, &gl_target);
|
cogl_texture_get_gl_texture (texture, NULL, &gl_target);
|
||||||
setup_texture_source (arbfp_program_state, arg->texture_unit, gl_target);
|
setup_texture_source (arbfp_program_state, arg->texture_unit, gl_target);
|
||||||
break;
|
break;
|
||||||
case GL_CONSTANT:
|
case COGL_PIPELINE_COMBINE_SOURCE_CONSTANT:
|
||||||
{
|
{
|
||||||
int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
|
int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
|
||||||
UnitState *unit_state = &arbfp_program_state->unit_state[unit_index];
|
UnitState *unit_state = &arbfp_program_state->unit_state[unit_index];
|
||||||
@ -476,11 +476,11 @@ setup_arg (CoglPipeline *pipeline,
|
|||||||
arg->constant_id = unit_state->constant_id;
|
arg->constant_id = unit_state->constant_id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GL_PRIMARY_COLOR:
|
case COGL_PIPELINE_COMBINE_SOURCE_PRIMARY_COLOR:
|
||||||
arg->type = COGL_PIPELINE_FRAGEND_ARBFP_ARG_TYPE_SIMPLE;
|
arg->type = COGL_PIPELINE_FRAGEND_ARBFP_ARG_TYPE_SIMPLE;
|
||||||
arg->name = "fragment.color.primary";
|
arg->name = "fragment.color.primary";
|
||||||
break;
|
break;
|
||||||
case GL_PREVIOUS:
|
case COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS:
|
||||||
arg->type = COGL_PIPELINE_FRAGEND_ARBFP_ARG_TYPE_SIMPLE;
|
arg->type = COGL_PIPELINE_FRAGEND_ARBFP_ARG_TYPE_SIMPLE;
|
||||||
if (_cogl_pipeline_layer_get_unit_index (layer) == 0)
|
if (_cogl_pipeline_layer_get_unit_index (layer) == 0)
|
||||||
arg->name = "fragment.color.primary";
|
arg->name = "fragment.color.primary";
|
||||||
@ -500,9 +500,9 @@ setup_arg (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case GL_SRC_COLOR:
|
case COGL_PIPELINE_COMBINE_OP_SRC_COLOR:
|
||||||
break;
|
break;
|
||||||
case GL_ONE_MINUS_SRC_COLOR:
|
case COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_COLOR:
|
||||||
g_string_append_printf (arbfp_program_state->source,
|
g_string_append_printf (arbfp_program_state->source,
|
||||||
"SUB tmp%d, one, ",
|
"SUB tmp%d, one, ",
|
||||||
arg_index);
|
arg_index);
|
||||||
@ -512,13 +512,13 @@ setup_arg (CoglPipeline *pipeline,
|
|||||||
arg->name = tmp_name[arg_index];
|
arg->name = tmp_name[arg_index];
|
||||||
arg->swizzle = "";
|
arg->swizzle = "";
|
||||||
break;
|
break;
|
||||||
case GL_SRC_ALPHA:
|
case COGL_PIPELINE_COMBINE_OP_SRC_ALPHA:
|
||||||
/* avoid a swizzle if we know RGB are going to be masked
|
/* avoid a swizzle if we know RGB are going to be masked
|
||||||
* in the end anyway */
|
* in the end anyway */
|
||||||
if (mask != COGL_BLEND_STRING_CHANNEL_MASK_ALPHA)
|
if (mask != COGL_BLEND_STRING_CHANNEL_MASK_ALPHA)
|
||||||
arg->swizzle = ".a";
|
arg->swizzle = ".a";
|
||||||
break;
|
break;
|
||||||
case GL_ONE_MINUS_SRC_ALPHA:
|
case COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_ALPHA:
|
||||||
g_string_append_printf (arbfp_program_state->source,
|
g_string_append_printf (arbfp_program_state->source,
|
||||||
"SUB tmp%d, one, ",
|
"SUB tmp%d, one, ",
|
||||||
arg_index);
|
arg_index);
|
||||||
@ -594,29 +594,29 @@ append_function (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
switch (function)
|
switch (function)
|
||||||
{
|
{
|
||||||
case GL_ADD:
|
case COGL_PIPELINE_COMBINE_FUNC_ADD:
|
||||||
g_string_append_printf (arbfp_program_state->source,
|
g_string_append_printf (arbfp_program_state->source,
|
||||||
"ADD_SAT output%s, ",
|
"ADD_SAT output%s, ",
|
||||||
mask_name);
|
mask_name);
|
||||||
break;
|
break;
|
||||||
case GL_MODULATE:
|
case COGL_PIPELINE_COMBINE_FUNC_MODULATE:
|
||||||
/* Note: no need to saturate since we can assume operands
|
/* Note: no need to saturate since we can assume operands
|
||||||
* have values in the range [0,1] */
|
* have values in the range [0,1] */
|
||||||
g_string_append_printf (arbfp_program_state->source, "MUL output%s, ",
|
g_string_append_printf (arbfp_program_state->source, "MUL output%s, ",
|
||||||
mask_name);
|
mask_name);
|
||||||
break;
|
break;
|
||||||
case GL_REPLACE:
|
case COGL_PIPELINE_COMBINE_FUNC_REPLACE:
|
||||||
/* Note: no need to saturate since we can assume operand
|
/* Note: no need to saturate since we can assume operand
|
||||||
* has a value in the range [0,1] */
|
* has a value in the range [0,1] */
|
||||||
g_string_append_printf (arbfp_program_state->source, "MOV output%s, ",
|
g_string_append_printf (arbfp_program_state->source, "MOV output%s, ",
|
||||||
mask_name);
|
mask_name);
|
||||||
break;
|
break;
|
||||||
case GL_SUBTRACT:
|
case COGL_PIPELINE_COMBINE_FUNC_SUBTRACT:
|
||||||
g_string_append_printf (arbfp_program_state->source,
|
g_string_append_printf (arbfp_program_state->source,
|
||||||
"SUB_SAT output%s, ",
|
"SUB_SAT output%s, ",
|
||||||
mask_name);
|
mask_name);
|
||||||
break;
|
break;
|
||||||
case GL_ADD_SIGNED:
|
case COGL_PIPELINE_COMBINE_FUNC_ADD_SIGNED:
|
||||||
g_string_append_printf (arbfp_program_state->source, "ADD tmp3%s, ",
|
g_string_append_printf (arbfp_program_state->source, "ADD tmp3%s, ",
|
||||||
mask_name);
|
mask_name);
|
||||||
append_arg (arbfp_program_state->source, &args[0]);
|
append_arg (arbfp_program_state->source, &args[0]);
|
||||||
@ -628,7 +628,7 @@ append_function (CoglPipeline *pipeline,
|
|||||||
mask_name);
|
mask_name);
|
||||||
n_args = 0;
|
n_args = 0;
|
||||||
break;
|
break;
|
||||||
case GL_DOT3_RGB:
|
case COGL_PIPELINE_COMBINE_FUNC_DOT3_RGB:
|
||||||
/* These functions are the same except that GL_DOT3_RGB never
|
/* These functions are the same except that GL_DOT3_RGB never
|
||||||
* updates the alpha channel.
|
* updates the alpha channel.
|
||||||
*
|
*
|
||||||
@ -636,7 +636,7 @@ append_function (CoglPipeline *pipeline,
|
|||||||
* an RGBA mask and we end up ignoring any separate alpha channel
|
* an RGBA mask and we end up ignoring any separate alpha channel
|
||||||
* function.
|
* function.
|
||||||
*/
|
*/
|
||||||
case GL_DOT3_RGBA:
|
case COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA:
|
||||||
{
|
{
|
||||||
const char *tmp4 = "tmp4";
|
const char *tmp4 = "tmp4";
|
||||||
|
|
||||||
@ -671,7 +671,7 @@ append_function (CoglPipeline *pipeline,
|
|||||||
n_args = 0;
|
n_args = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GL_INTERPOLATE:
|
case COGL_PIPELINE_COMBINE_FUNC_INTERPOLATE:
|
||||||
/* Note: no need to saturate since we can assume operands
|
/* Note: no need to saturate since we can assume operands
|
||||||
* have values in the range [0,1] */
|
* have values in the range [0,1] */
|
||||||
|
|
||||||
@ -708,9 +708,9 @@ static void
|
|||||||
append_masked_combine (CoglPipeline *arbfp_authority,
|
append_masked_combine (CoglPipeline *arbfp_authority,
|
||||||
CoglPipelineLayer *layer,
|
CoglPipelineLayer *layer,
|
||||||
CoglBlendStringChannelMask mask,
|
CoglBlendStringChannelMask mask,
|
||||||
GLint function,
|
CoglPipelineCombineFunc function,
|
||||||
GLint *src,
|
CoglPipelineCombineSource *src,
|
||||||
GLint *op)
|
CoglPipelineCombineOp *op)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int n_args;
|
int n_args;
|
||||||
@ -788,7 +788,8 @@ _cogl_pipeline_fragend_arbfp_add_layer (CoglPipeline *pipeline,
|
|||||||
big_state->texture_combine_rgb_src,
|
big_state->texture_combine_rgb_src,
|
||||||
big_state->texture_combine_rgb_op);
|
big_state->texture_combine_rgb_op);
|
||||||
}
|
}
|
||||||
else if (big_state->texture_combine_rgb_func == GL_DOT3_RGBA)
|
else if (big_state->texture_combine_rgb_func ==
|
||||||
|
COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA)
|
||||||
{
|
{
|
||||||
/* GL_DOT3_RGBA Is a bit weird as a GL_COMBINE_RGB function
|
/* GL_DOT3_RGBA Is a bit weird as a GL_COMBINE_RGB function
|
||||||
* since if you use it, it overrides your ALPHA function...
|
* since if you use it, it overrides your ALPHA function...
|
||||||
|
@ -463,8 +463,8 @@ static void
|
|||||||
add_arg (GlslShaderState *glsl_shader_state,
|
add_arg (GlslShaderState *glsl_shader_state,
|
||||||
CoglPipeline *pipeline,
|
CoglPipeline *pipeline,
|
||||||
CoglPipelineLayer *layer,
|
CoglPipelineLayer *layer,
|
||||||
GLint src,
|
CoglPipelineCombineSource src,
|
||||||
GLenum operand,
|
CoglPipelineCombineOp operand,
|
||||||
const char *swizzle)
|
const char *swizzle)
|
||||||
{
|
{
|
||||||
GString *shader_source = glsl_shader_state->source;
|
GString *shader_source = glsl_shader_state->source;
|
||||||
@ -472,14 +472,16 @@ add_arg (GlslShaderState *glsl_shader_state,
|
|||||||
|
|
||||||
g_string_append_c (shader_source, '(');
|
g_string_append_c (shader_source, '(');
|
||||||
|
|
||||||
if (operand == GL_ONE_MINUS_SRC_COLOR || operand == GL_ONE_MINUS_SRC_ALPHA)
|
if (operand == COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_COLOR ||
|
||||||
|
operand == COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_ALPHA)
|
||||||
g_string_append_printf (shader_source,
|
g_string_append_printf (shader_source,
|
||||||
"vec4(1.0, 1.0, 1.0, 1.0).%s - ",
|
"vec4(1.0, 1.0, 1.0, 1.0).%s - ",
|
||||||
swizzle);
|
swizzle);
|
||||||
|
|
||||||
/* If the operand is reading from the alpha then replace the swizzle
|
/* If the operand is reading from the alpha then replace the swizzle
|
||||||
with the same number of copies of the alpha */
|
with the same number of copies of the alpha */
|
||||||
if (operand == GL_SRC_ALPHA || operand == GL_ONE_MINUS_SRC_ALPHA)
|
if (operand == COGL_PIPELINE_COMBINE_OP_SRC_ALPHA ||
|
||||||
|
operand == COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_ALPHA)
|
||||||
{
|
{
|
||||||
alpha_swizzle[strlen (swizzle)] = '\0';
|
alpha_swizzle[strlen (swizzle)] = '\0';
|
||||||
swizzle = alpha_swizzle;
|
swizzle = alpha_swizzle;
|
||||||
@ -487,37 +489,38 @@ add_arg (GlslShaderState *glsl_shader_state,
|
|||||||
|
|
||||||
switch (src)
|
switch (src)
|
||||||
{
|
{
|
||||||
case GL_TEXTURE:
|
case COGL_PIPELINE_COMBINE_SOURCE_TEXTURE:
|
||||||
add_texture_lookup (glsl_shader_state,
|
add_texture_lookup (glsl_shader_state,
|
||||||
pipeline,
|
pipeline,
|
||||||
layer,
|
layer,
|
||||||
swizzle);
|
swizzle);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_CONSTANT:
|
case COGL_PIPELINE_COMBINE_SOURCE_CONSTANT:
|
||||||
add_constant_lookup (glsl_shader_state,
|
add_constant_lookup (glsl_shader_state,
|
||||||
pipeline,
|
pipeline,
|
||||||
layer,
|
layer,
|
||||||
swizzle);
|
swizzle);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_PREVIOUS:
|
case COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS:
|
||||||
if (_cogl_pipeline_layer_get_unit_index (layer) > 0)
|
if (_cogl_pipeline_layer_get_unit_index (layer) > 0)
|
||||||
{
|
{
|
||||||
g_string_append_printf (shader_source, "cogl_color_out.%s", swizzle);
|
g_string_append_printf (shader_source, "cogl_color_out.%s", swizzle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* flow through */
|
/* flow through */
|
||||||
case GL_PRIMARY_COLOR:
|
case COGL_PIPELINE_COMBINE_SOURCE_PRIMARY_COLOR:
|
||||||
g_string_append_printf (shader_source, "cogl_color_in.%s", swizzle);
|
g_string_append_printf (shader_source, "cogl_color_in.%s", swizzle);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (src >= GL_TEXTURE0 && src < GL_TEXTURE0 + 32)
|
if (src >= COGL_PIPELINE_COMBINE_SOURCE_TEXTURE0 &&
|
||||||
|
src < COGL_PIPELINE_COMBINE_SOURCE_TEXTURE0 + 32)
|
||||||
{
|
{
|
||||||
FindPipelineLayerData data;
|
FindPipelineLayerData data;
|
||||||
|
|
||||||
data.unit_index = src - GL_TEXTURE0;
|
data.unit_index = src - COGL_PIPELINE_COMBINE_SOURCE_TEXTURE0;
|
||||||
data.layer = layer;
|
data.layer = layer;
|
||||||
|
|
||||||
_cogl_pipeline_foreach_layer_internal (pipeline,
|
_cogl_pipeline_foreach_layer_internal (pipeline,
|
||||||
@ -539,9 +542,9 @@ static void
|
|||||||
append_masked_combine (CoglPipeline *pipeline,
|
append_masked_combine (CoglPipeline *pipeline,
|
||||||
CoglPipelineLayer *layer,
|
CoglPipelineLayer *layer,
|
||||||
const char *swizzle,
|
const char *swizzle,
|
||||||
GLint function,
|
CoglPipelineCombineFunc function,
|
||||||
GLint *src,
|
CoglPipelineCombineSource *src,
|
||||||
GLint *op)
|
CoglPipelineCombineOp *op)
|
||||||
{
|
{
|
||||||
GlslShaderState *glsl_shader_state = get_glsl_shader_state (pipeline);
|
GlslShaderState *glsl_shader_state = get_glsl_shader_state (pipeline);
|
||||||
GString *shader_source = glsl_shader_state->source;
|
GString *shader_source = glsl_shader_state->source;
|
||||||
@ -551,12 +554,12 @@ append_masked_combine (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
switch (function)
|
switch (function)
|
||||||
{
|
{
|
||||||
case GL_REPLACE:
|
case COGL_PIPELINE_COMBINE_FUNC_REPLACE:
|
||||||
add_arg (glsl_shader_state, pipeline, layer,
|
add_arg (glsl_shader_state, pipeline, layer,
|
||||||
src[0], op[0], swizzle);
|
src[0], op[0], swizzle);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_MODULATE:
|
case COGL_PIPELINE_COMBINE_FUNC_MODULATE:
|
||||||
add_arg (glsl_shader_state, pipeline, layer,
|
add_arg (glsl_shader_state, pipeline, layer,
|
||||||
src[0], op[0], swizzle);
|
src[0], op[0], swizzle);
|
||||||
g_string_append (shader_source, " * ");
|
g_string_append (shader_source, " * ");
|
||||||
@ -564,7 +567,7 @@ append_masked_combine (CoglPipeline *pipeline,
|
|||||||
src[1], op[1], swizzle);
|
src[1], op[1], swizzle);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_ADD:
|
case COGL_PIPELINE_COMBINE_FUNC_ADD:
|
||||||
add_arg (glsl_shader_state, pipeline, layer,
|
add_arg (glsl_shader_state, pipeline, layer,
|
||||||
src[0], op[0], swizzle);
|
src[0], op[0], swizzle);
|
||||||
g_string_append (shader_source, " + ");
|
g_string_append (shader_source, " + ");
|
||||||
@ -572,7 +575,7 @@ append_masked_combine (CoglPipeline *pipeline,
|
|||||||
src[1], op[1], swizzle);
|
src[1], op[1], swizzle);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_ADD_SIGNED:
|
case COGL_PIPELINE_COMBINE_FUNC_ADD_SIGNED:
|
||||||
add_arg (glsl_shader_state, pipeline, layer,
|
add_arg (glsl_shader_state, pipeline, layer,
|
||||||
src[0], op[0], swizzle);
|
src[0], op[0], swizzle);
|
||||||
g_string_append (shader_source, " + ");
|
g_string_append (shader_source, " + ");
|
||||||
@ -583,7 +586,7 @@ append_masked_combine (CoglPipeline *pipeline,
|
|||||||
swizzle);
|
swizzle);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_SUBTRACT:
|
case COGL_PIPELINE_COMBINE_FUNC_SUBTRACT:
|
||||||
add_arg (glsl_shader_state, pipeline, layer,
|
add_arg (glsl_shader_state, pipeline, layer,
|
||||||
src[0], op[0], swizzle);
|
src[0], op[0], swizzle);
|
||||||
g_string_append (shader_source, " - ");
|
g_string_append (shader_source, " - ");
|
||||||
@ -591,7 +594,7 @@ append_masked_combine (CoglPipeline *pipeline,
|
|||||||
src[1], op[1], swizzle);
|
src[1], op[1], swizzle);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_INTERPOLATE:
|
case COGL_PIPELINE_COMBINE_FUNC_INTERPOLATE:
|
||||||
add_arg (glsl_shader_state, pipeline, layer,
|
add_arg (glsl_shader_state, pipeline, layer,
|
||||||
src[0], op[0], swizzle);
|
src[0], op[0], swizzle);
|
||||||
g_string_append (shader_source, " * ");
|
g_string_append (shader_source, " * ");
|
||||||
@ -608,8 +611,8 @@ append_masked_combine (CoglPipeline *pipeline,
|
|||||||
g_string_append_c (shader_source, ')');
|
g_string_append_c (shader_source, ')');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_DOT3_RGB:
|
case COGL_PIPELINE_COMBINE_FUNC_DOT3_RGB:
|
||||||
case GL_DOT3_RGBA:
|
case COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA:
|
||||||
g_string_append (shader_source, "vec4(4.0 * ((");
|
g_string_append (shader_source, "vec4(4.0 * ((");
|
||||||
add_arg (glsl_shader_state, pipeline, layer,
|
add_arg (glsl_shader_state, pipeline, layer,
|
||||||
src[0], op[0], "r");
|
src[0], op[0], "r");
|
||||||
@ -653,7 +656,8 @@ _cogl_pipeline_fragend_glsl_add_layer (CoglPipeline *pipeline,
|
|||||||
/* GL_DOT3_RGBA Is a bit weird as a GL_COMBINE_RGB function
|
/* GL_DOT3_RGBA Is a bit weird as a GL_COMBINE_RGB function
|
||||||
* since if you use it, it overrides your ALPHA function...
|
* since if you use it, it overrides your ALPHA function...
|
||||||
*/
|
*/
|
||||||
big_state->texture_combine_rgb_func == GL_DOT3_RGBA)
|
big_state->texture_combine_rgb_func ==
|
||||||
|
COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA)
|
||||||
append_masked_combine (pipeline,
|
append_masked_combine (pipeline,
|
||||||
layer,
|
layer,
|
||||||
"rgba",
|
"rgba",
|
||||||
|
@ -181,17 +181,49 @@ typedef enum
|
|||||||
|
|
||||||
} CoglPipelineLayerState;
|
} CoglPipelineLayerState;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
/* These are the same values as GL */
|
||||||
|
COGL_PIPELINE_COMBINE_FUNC_ADD = 0x0104,
|
||||||
|
COGL_PIPELINE_COMBINE_FUNC_ADD_SIGNED = 0x8574,
|
||||||
|
COGL_PIPELINE_COMBINE_FUNC_SUBTRACT = 0x84E7,
|
||||||
|
COGL_PIPELINE_COMBINE_FUNC_INTERPOLATE = 0x8575,
|
||||||
|
COGL_PIPELINE_COMBINE_FUNC_REPLACE = 0x1E01,
|
||||||
|
COGL_PIPELINE_COMBINE_FUNC_MODULATE = 0x2100,
|
||||||
|
COGL_PIPELINE_COMBINE_FUNC_DOT3_RGB = 0x86AE,
|
||||||
|
COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA = 0x86AF
|
||||||
|
} CoglPipelineCombineFunc;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
/* These are the same values as GL */
|
||||||
|
COGL_PIPELINE_COMBINE_SOURCE_TEXTURE = 0x1702,
|
||||||
|
COGL_PIPELINE_COMBINE_SOURCE_CONSTANT = 0x8576,
|
||||||
|
COGL_PIPELINE_COMBINE_SOURCE_PRIMARY_COLOR = 0x8577,
|
||||||
|
COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS = 0x8578,
|
||||||
|
COGL_PIPELINE_COMBINE_SOURCE_TEXTURE0 = 0x84C0
|
||||||
|
} CoglPipelineCombineSource;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
/* These are the same values as GL */
|
||||||
|
COGL_PIPELINE_COMBINE_OP_SRC_COLOR = 0x0300,
|
||||||
|
COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_COLOR = 0x0301,
|
||||||
|
COGL_PIPELINE_COMBINE_OP_SRC_ALPHA = 0x0302,
|
||||||
|
COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_ALPHA = 0x0303
|
||||||
|
} CoglPipelineCombineOp;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/* The texture combine state determines how the color of individual
|
/* The texture combine state determines how the color of individual
|
||||||
* texture fragments are calculated. */
|
* texture fragments are calculated. */
|
||||||
GLint texture_combine_rgb_func;
|
CoglPipelineCombineFunc texture_combine_rgb_func;
|
||||||
GLint texture_combine_rgb_src[3];
|
CoglPipelineCombineSource texture_combine_rgb_src[3];
|
||||||
GLint texture_combine_rgb_op[3];
|
CoglPipelineCombineOp texture_combine_rgb_op[3];
|
||||||
|
|
||||||
GLint texture_combine_alpha_func;
|
CoglPipelineCombineFunc texture_combine_alpha_func;
|
||||||
GLint texture_combine_alpha_src[3];
|
CoglPipelineCombineSource texture_combine_alpha_src[3];
|
||||||
GLint texture_combine_alpha_op[3];
|
CoglPipelineCombineOp texture_combine_alpha_op[3];
|
||||||
|
|
||||||
float texture_combine_constant[4];
|
float texture_combine_constant[4];
|
||||||
|
|
||||||
@ -864,7 +896,7 @@ void
|
|||||||
_cogl_use_vertex_program (GLuint gl_program, CoglPipelineProgramType type);
|
_cogl_use_vertex_program (GLuint gl_program, CoglPipelineProgramType type);
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
_cogl_get_n_args_for_combine_func (GLint func);
|
_cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _cogl_pipeline_weak_copy:
|
* _cogl_pipeline_weak_copy:
|
||||||
|
@ -777,11 +777,16 @@ layer_has_alpha_cb (CoglPipelineLayer *layer, void *data)
|
|||||||
* assume it may result in an alpha value < 1
|
* assume it may result in an alpha value < 1
|
||||||
*
|
*
|
||||||
* FIXME: we could do better than this. */
|
* FIXME: we could do better than this. */
|
||||||
if (big_state->texture_combine_alpha_func != GL_MODULATE ||
|
if (big_state->texture_combine_alpha_func !=
|
||||||
big_state->texture_combine_alpha_src[0] != GL_PREVIOUS ||
|
COGL_PIPELINE_COMBINE_FUNC_MODULATE ||
|
||||||
big_state->texture_combine_alpha_op[0] != GL_SRC_ALPHA ||
|
big_state->texture_combine_alpha_src[0] !=
|
||||||
big_state->texture_combine_alpha_src[1] != GL_TEXTURE ||
|
COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS ||
|
||||||
big_state->texture_combine_alpha_op[1] != GL_SRC_ALPHA)
|
big_state->texture_combine_alpha_op[0] !=
|
||||||
|
COGL_PIPELINE_COMBINE_OP_SRC_ALPHA ||
|
||||||
|
big_state->texture_combine_alpha_src[1] !=
|
||||||
|
COGL_PIPELINE_COMBINE_SOURCE_TEXTURE ||
|
||||||
|
big_state->texture_combine_alpha_op[1] !=
|
||||||
|
COGL_PIPELINE_COMBINE_OP_SRC_ALPHA)
|
||||||
{
|
{
|
||||||
*has_alpha = TRUE;
|
*has_alpha = TRUE;
|
||||||
/* return FALSE to stop iterating layers... */
|
/* return FALSE to stop iterating layers... */
|
||||||
@ -1614,20 +1619,20 @@ _cogl_pipeline_progend_layer_change_notify (CoglPipeline *owner,
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
_cogl_get_n_args_for_combine_func (GLint func)
|
_cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func)
|
||||||
{
|
{
|
||||||
switch (func)
|
switch (func)
|
||||||
{
|
{
|
||||||
case GL_REPLACE:
|
case COGL_PIPELINE_COMBINE_FUNC_REPLACE:
|
||||||
return 1;
|
return 1;
|
||||||
case GL_MODULATE:
|
case COGL_PIPELINE_COMBINE_FUNC_MODULATE:
|
||||||
case GL_ADD:
|
case COGL_PIPELINE_COMBINE_FUNC_ADD:
|
||||||
case GL_ADD_SIGNED:
|
case COGL_PIPELINE_COMBINE_FUNC_ADD_SIGNED:
|
||||||
case GL_SUBTRACT:
|
case COGL_PIPELINE_COMBINE_FUNC_SUBTRACT:
|
||||||
case GL_DOT3_RGB:
|
case COGL_PIPELINE_COMBINE_FUNC_DOT3_RGB:
|
||||||
case GL_DOT3_RGBA:
|
case COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA:
|
||||||
return 2;
|
return 2;
|
||||||
case GL_INTERPOLATE:
|
case COGL_PIPELINE_COMBINE_FUNC_INTERPOLATE:
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -4788,16 +4793,26 @@ _cogl_pipeline_init_default_layers (void)
|
|||||||
|
|
||||||
/* Choose the same default combine mode as OpenGL:
|
/* Choose the same default combine mode as OpenGL:
|
||||||
* RGBA = MODULATE(PREVIOUS[RGBA],TEXTURE[RGBA]) */
|
* RGBA = MODULATE(PREVIOUS[RGBA],TEXTURE[RGBA]) */
|
||||||
big_state->texture_combine_rgb_func = GL_MODULATE;
|
big_state->texture_combine_rgb_func =
|
||||||
big_state->texture_combine_rgb_src[0] = GL_PREVIOUS;
|
COGL_PIPELINE_COMBINE_FUNC_MODULATE;
|
||||||
big_state->texture_combine_rgb_src[1] = GL_TEXTURE;
|
big_state->texture_combine_rgb_src[0] =
|
||||||
big_state->texture_combine_rgb_op[0] = GL_SRC_COLOR;
|
COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS;
|
||||||
big_state->texture_combine_rgb_op[1] = GL_SRC_COLOR;
|
big_state->texture_combine_rgb_src[1] =
|
||||||
big_state->texture_combine_alpha_func = GL_MODULATE;
|
COGL_PIPELINE_COMBINE_SOURCE_TEXTURE;
|
||||||
big_state->texture_combine_alpha_src[0] = GL_PREVIOUS;
|
big_state->texture_combine_rgb_op[0] =
|
||||||
big_state->texture_combine_alpha_src[1] = GL_TEXTURE;
|
COGL_PIPELINE_COMBINE_OP_SRC_COLOR;
|
||||||
big_state->texture_combine_alpha_op[0] = GL_SRC_ALPHA;
|
big_state->texture_combine_rgb_op[1] =
|
||||||
big_state->texture_combine_alpha_op[1] = GL_SRC_ALPHA;
|
COGL_PIPELINE_COMBINE_OP_SRC_COLOR;
|
||||||
|
big_state->texture_combine_alpha_func =
|
||||||
|
COGL_PIPELINE_COMBINE_FUNC_MODULATE;
|
||||||
|
big_state->texture_combine_alpha_src[0] =
|
||||||
|
COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS;
|
||||||
|
big_state->texture_combine_alpha_src[1] =
|
||||||
|
COGL_PIPELINE_COMBINE_SOURCE_TEXTURE;
|
||||||
|
big_state->texture_combine_alpha_op[0] =
|
||||||
|
COGL_PIPELINE_COMBINE_OP_SRC_ALPHA;
|
||||||
|
big_state->texture_combine_alpha_op[1] =
|
||||||
|
COGL_PIPELINE_COMBINE_OP_SRC_ALPHA;
|
||||||
|
|
||||||
big_state->point_sprite_coords = FALSE;
|
big_state->point_sprite_coords = FALSE;
|
||||||
|
|
||||||
@ -4839,37 +4854,37 @@ _cogl_pipeline_init_default_layers (void)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
setup_texture_combine_state (CoglBlendStringStatement *statement,
|
setup_texture_combine_state (CoglBlendStringStatement *statement,
|
||||||
GLint *texture_combine_func,
|
CoglPipelineCombineFunc *texture_combine_func,
|
||||||
GLint *texture_combine_src,
|
CoglPipelineCombineSource *texture_combine_src,
|
||||||
GLint *texture_combine_op)
|
CoglPipelineCombineOp *texture_combine_op)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
switch (statement->function->type)
|
switch (statement->function->type)
|
||||||
{
|
{
|
||||||
case COGL_BLEND_STRING_FUNCTION_REPLACE:
|
case COGL_BLEND_STRING_FUNCTION_REPLACE:
|
||||||
*texture_combine_func = GL_REPLACE;
|
*texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_REPLACE;
|
||||||
break;
|
break;
|
||||||
case COGL_BLEND_STRING_FUNCTION_MODULATE:
|
case COGL_BLEND_STRING_FUNCTION_MODULATE:
|
||||||
*texture_combine_func = GL_MODULATE;
|
*texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_MODULATE;
|
||||||
break;
|
break;
|
||||||
case COGL_BLEND_STRING_FUNCTION_ADD:
|
case COGL_BLEND_STRING_FUNCTION_ADD:
|
||||||
*texture_combine_func = GL_ADD;
|
*texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_ADD;
|
||||||
break;
|
break;
|
||||||
case COGL_BLEND_STRING_FUNCTION_ADD_SIGNED:
|
case COGL_BLEND_STRING_FUNCTION_ADD_SIGNED:
|
||||||
*texture_combine_func = GL_ADD_SIGNED;
|
*texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_ADD_SIGNED;
|
||||||
break;
|
break;
|
||||||
case COGL_BLEND_STRING_FUNCTION_INTERPOLATE:
|
case COGL_BLEND_STRING_FUNCTION_INTERPOLATE:
|
||||||
*texture_combine_func = GL_INTERPOLATE;
|
*texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_INTERPOLATE;
|
||||||
break;
|
break;
|
||||||
case COGL_BLEND_STRING_FUNCTION_SUBTRACT:
|
case COGL_BLEND_STRING_FUNCTION_SUBTRACT:
|
||||||
*texture_combine_func = GL_SUBTRACT;
|
*texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_SUBTRACT;
|
||||||
break;
|
break;
|
||||||
case COGL_BLEND_STRING_FUNCTION_DOT3_RGB:
|
case COGL_BLEND_STRING_FUNCTION_DOT3_RGB:
|
||||||
*texture_combine_func = GL_DOT3_RGB;
|
*texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_DOT3_RGB;
|
||||||
break;
|
break;
|
||||||
case COGL_BLEND_STRING_FUNCTION_DOT3_RGBA:
|
case COGL_BLEND_STRING_FUNCTION_DOT3_RGBA:
|
||||||
*texture_combine_func = GL_DOT3_RGBA;
|
*texture_combine_func = COGL_PIPELINE_COMBINE_FUNC_DOT3_RGBA;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4880,39 +4895,41 @@ setup_texture_combine_state (CoglBlendStringStatement *statement,
|
|||||||
switch (arg->source.info->type)
|
switch (arg->source.info->type)
|
||||||
{
|
{
|
||||||
case COGL_BLEND_STRING_COLOR_SOURCE_CONSTANT:
|
case COGL_BLEND_STRING_COLOR_SOURCE_CONSTANT:
|
||||||
texture_combine_src[i] = GL_CONSTANT;
|
texture_combine_src[i] = COGL_PIPELINE_COMBINE_SOURCE_CONSTANT;
|
||||||
break;
|
break;
|
||||||
case COGL_BLEND_STRING_COLOR_SOURCE_TEXTURE:
|
case COGL_BLEND_STRING_COLOR_SOURCE_TEXTURE:
|
||||||
texture_combine_src[i] = GL_TEXTURE;
|
texture_combine_src[i] = COGL_PIPELINE_COMBINE_SOURCE_TEXTURE;
|
||||||
break;
|
break;
|
||||||
case COGL_BLEND_STRING_COLOR_SOURCE_TEXTURE_N:
|
case COGL_BLEND_STRING_COLOR_SOURCE_TEXTURE_N:
|
||||||
texture_combine_src[i] =
|
texture_combine_src[i] =
|
||||||
GL_TEXTURE0 + arg->source.texture;
|
COGL_PIPELINE_COMBINE_SOURCE_TEXTURE0 + arg->source.texture;
|
||||||
break;
|
break;
|
||||||
case COGL_BLEND_STRING_COLOR_SOURCE_PRIMARY:
|
case COGL_BLEND_STRING_COLOR_SOURCE_PRIMARY:
|
||||||
texture_combine_src[i] = GL_PRIMARY_COLOR;
|
texture_combine_src[i] = COGL_PIPELINE_COMBINE_SOURCE_PRIMARY_COLOR;
|
||||||
break;
|
break;
|
||||||
case COGL_BLEND_STRING_COLOR_SOURCE_PREVIOUS:
|
case COGL_BLEND_STRING_COLOR_SOURCE_PREVIOUS:
|
||||||
texture_combine_src[i] = GL_PREVIOUS;
|
texture_combine_src[i] = COGL_PIPELINE_COMBINE_SOURCE_PREVIOUS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_warning ("Unexpected texture combine source");
|
g_warning ("Unexpected texture combine source");
|
||||||
texture_combine_src[i] = GL_TEXTURE;
|
texture_combine_src[i] = COGL_PIPELINE_COMBINE_SOURCE_TEXTURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg->source.mask == COGL_BLEND_STRING_CHANNEL_MASK_RGB)
|
if (arg->source.mask == COGL_BLEND_STRING_CHANNEL_MASK_RGB)
|
||||||
{
|
{
|
||||||
if (statement->args[i].source.one_minus)
|
if (statement->args[i].source.one_minus)
|
||||||
texture_combine_op[i] = GL_ONE_MINUS_SRC_COLOR;
|
texture_combine_op[i] =
|
||||||
|
COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_COLOR;
|
||||||
else
|
else
|
||||||
texture_combine_op[i] = GL_SRC_COLOR;
|
texture_combine_op[i] = COGL_PIPELINE_COMBINE_OP_SRC_COLOR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (statement->args[i].source.one_minus)
|
if (statement->args[i].source.one_minus)
|
||||||
texture_combine_op[i] = GL_ONE_MINUS_SRC_ALPHA;
|
texture_combine_op[i] =
|
||||||
|
COGL_PIPELINE_COMBINE_OP_ONE_MINUS_SRC_ALPHA;
|
||||||
else
|
else
|
||||||
texture_combine_op[i] = GL_SRC_ALPHA;
|
texture_combine_op[i] = COGL_PIPELINE_COMBINE_OP_SRC_ALPHA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user