예제 #1
0
static CoglBool
validate_statements_for_context (CoglBlendStringStatement *statements,
                                 int n_statements,
                                 CoglBlendStringContext context,
                                 CoglError **error)
{
  const char *error_string;

  if (n_statements == 1)
    {
      if (statements[0].mask == COGL_BLEND_STRING_CHANNEL_MASK_ALPHA)
        {
          error_string = "You need to also give a blend statement for the RGB"
                         "channels";
          goto error;
        }
      else if (statements[0].mask == COGL_BLEND_STRING_CHANNEL_MASK_RGB)
        {
          error_string = "You need to also give a blend statement for the "
                         "Alpha channel";
          goto error;
        }
    }

  if (context == COGL_BLEND_STRING_CONTEXT_BLENDING)
    return validate_blend_statements (statements, n_statements, error);
  else
    return validate_tex_combine_statements (statements, n_statements, error);

error:
  _cogl_set_error (error,
                   COGL_BLEND_STRING_ERROR,
                   COGL_BLEND_STRING_ERROR_INVALID_ERROR,
                   "Invalid %s string: %s",
                   context == COGL_BLEND_STRING_CONTEXT_BLENDING ?
                   "blend" : "texture combine",
                   error_string);

  if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
    {
      g_debug ("Invalid %s string: %s",
               context == COGL_BLEND_STRING_CONTEXT_BLENDING ?
               "blend" : "texture combine",
               error_string);
    }

  return FALSE;
}
예제 #2
0
static bool
validate_statements(cg_device_t *dev,
                    cg_blend_string_statement_t *statements,
                    int n_statements,
                    cg_error_t **error)
{
    const char *error_string;

    if (n_statements == 1) {
        if (statements[0].mask == CG_BLEND_STRING_CHANNEL_MASK_ALPHA) {
            error_string =
                "You need to also give a blend statement for the RGB "
                "channels";
            goto error;
        } else if (statements[0].mask == CG_BLEND_STRING_CHANNEL_MASK_RGB) {
            error_string = "You need to also give a blend statement for the "
                           "Alpha channel";
            goto error;
        }
    }

    return validate_blend_statements(dev, statements, n_statements,
                                     error);

error:
    _cg_set_error(error,
                  CG_BLEND_STRING_ERROR,
                  CG_BLEND_STRING_ERROR_INVALID_ERROR,
                  "Invalid blend string: %s",
                  error_string);

    if (CG_DEBUG_ENABLED(CG_DEBUG_BLEND_STRINGS))
        c_debug("Invalid blend string: %s", error_string);

    return false;
}