mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
blend-strings: Make braces around blend factor optional
for a blend string like: "RGBA=ADD(SRC_COLOR, SRC_COLOR * (DST_COLOR[A]))" it was awkward that we were requiring developers to explicitly put redundant brackets around the DST_COLOR[A] blend factor. The parser has been updated so now braces are only required for factors like "(1-SRC_COLOR[A])" Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
c36652a4c3
commit
9b56ce4d5b
@ -482,6 +482,7 @@ parse_argument (const char *string, /* original user string */
|
|||||||
const char *error_string = NULL;
|
const char *error_string = NULL;
|
||||||
ParserArgState state = PARSER_ARG_STATE_START;
|
ParserArgState state = PARSER_ARG_STATE_START;
|
||||||
gboolean parsing_factor = FALSE;
|
gboolean parsing_factor = FALSE;
|
||||||
|
gboolean implicit_factor_brace;
|
||||||
|
|
||||||
arg->source.is_zero = FALSE;
|
arg->source.is_zero = FALSE;
|
||||||
arg->source.info = NULL;
|
arg->source.info = NULL;
|
||||||
@ -631,11 +632,21 @@ parse_argument (const char *string, /* original user string */
|
|||||||
case PARSER_ARG_STATE_EXPECT_OPEN_PAREN:
|
case PARSER_ARG_STATE_EXPECT_OPEN_PAREN:
|
||||||
if (*p != '(')
|
if (*p != '(')
|
||||||
{
|
{
|
||||||
error_string = "Expected '(' before blend factor - the parser "
|
if (is_alphanum_char (*p))
|
||||||
"currently requires that all blend factors "
|
{
|
||||||
"following a '*' be surrounded in brackets";
|
p--; /* compensate for implicit brace and ensure this
|
||||||
goto error;
|
* char gets considered part of the blend factor */
|
||||||
|
implicit_factor_brace = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error_string = "Expected '(' around blend factor or alpha "
|
||||||
|
"numeric character for blend factor name";
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
implicit_factor_brace = FALSE;
|
||||||
parsing_factor = TRUE;
|
parsing_factor = TRUE;
|
||||||
state = PARSER_ARG_STATE_EXPECT_FACTOR;
|
state = PARSER_ARG_STATE_EXPECT_FACTOR;
|
||||||
continue;
|
continue;
|
||||||
@ -676,6 +687,12 @@ parse_argument (const char *string, /* original user string */
|
|||||||
case PARSER_ARG_STATE_MAYBE_MINUS:
|
case PARSER_ARG_STATE_MAYBE_MINUS:
|
||||||
if (*p == '-')
|
if (*p == '-')
|
||||||
{
|
{
|
||||||
|
if (implicit_factor_brace)
|
||||||
|
{
|
||||||
|
error_string = "Expected ( ) braces around blend factor with "
|
||||||
|
"a subtraction";
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
arg->factor.source.one_minus = TRUE;
|
arg->factor.source.one_minus = TRUE;
|
||||||
state = PARSER_ARG_STATE_EXPECT_COLOR_SRC_NAME;
|
state = PARSER_ARG_STATE_EXPECT_COLOR_SRC_NAME;
|
||||||
}
|
}
|
||||||
@ -687,6 +704,12 @@ parse_argument (const char *string, /* original user string */
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
case PARSER_ARG_STATE_EXPECT_CLOSE_PAREN:
|
case PARSER_ARG_STATE_EXPECT_CLOSE_PAREN:
|
||||||
|
if (implicit_factor_brace)
|
||||||
|
{
|
||||||
|
p--;
|
||||||
|
state = PARSER_ARG_STATE_EXPECT_END;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (*p != ')')
|
if (*p != ')')
|
||||||
{
|
{
|
||||||
error_string = "Expected closing parenthesis after blend factor";
|
error_string = "Expected closing parenthesis after blend factor";
|
||||||
|
@ -522,9 +522,6 @@ cogl_pipeline_get_alpha_test_reference (CoglPipeline *pipeline);
|
|||||||
* <channel-mask>=ADD(SRC_COLOR*(<factor>), DST_COLOR*(<factor>))
|
* <channel-mask>=ADD(SRC_COLOR*(<factor>), DST_COLOR*(<factor>))
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* <warning>The brackets around blend factors are currently not
|
|
||||||
* optional!</warning>
|
|
||||||
*
|
|
||||||
* This is the list of source-names usable as blend factors:
|
* This is the list of source-names usable as blend factors:
|
||||||
* <itemizedlist>
|
* <itemizedlist>
|
||||||
* <listitem><para>SRC_COLOR: The color of the in comming fragment</para></listitem>
|
* <listitem><para>SRC_COLOR: The color of the in comming fragment</para></listitem>
|
||||||
|
Loading…
Reference in New Issue
Block a user