static void
colorFilterFiniScreen (CompPlugin * p, CompScreen * s)
{
    FILTER_SCREEN (s);

    freeWindowPrivateIndex (s, cfs->windowPrivateIndex);
    UNWRAP (cfs, s, drawWindowTexture);

    unloadFilters (s);

    free (cfs);
}
示例#2
0
/*
 * Load filters from a list of files for current screen
 */
static int
loadFilters (CompScreen  *s,
             CompTexture *texture)
{
	int i, target, loaded, function, count;
	char *name;
	CompWindow *w;

	FILTER_SCREEN (s);

	cfs->filtersLoaded = TRUE;

	/* Fetch filters filenames */
	const BananaValue *
	option_filters = bananaGetOption (bananaIndex,
	                                  "filters",
	                                  s->screenNum);

	count = option_filters->list.nItem;

	/* The texture target that will be used for some ops */
	if (texture->target == GL_TEXTURE_2D)
		target = COMP_FETCH_TARGET_2D;
	else
		target = COMP_FETCH_TARGET_RECT;

	/* Free previously loaded filters and malloc */
	unloadFilters (s);
	cfs->filtersFunctions = malloc (sizeof (int) * count);

	if (!cfs->filtersFunctions)
		return 0;

	cfs->filtersCount = count;

	/* Load each filter one by one */
	loaded = 0;

	for (i = 0; i < count; i++)
	{
		name = base_name (option_filters->list.item[i].s);
		if (!name || !strlen (name))
		{
			if (name)
				free (name);

			cfs->filtersFunctions[i] = 0;
			continue;
		}

		compLogMessage ("colorfilter", CompLogLevelInfo,
		                "Loading filter %s (item %s).", name,
		                option_filters->list.item[i].s);

		function = loadFragmentProgram (option_filters->list.item[i].s, name, s, target);
		free (name);

		cfs->filtersFunctions[i] = function;

		if (function)
			loaded++;
	}

	/* Warn if there was at least one loading failure */
	if (loaded < count)
		compLogMessage ("colorfilter", CompLogLevelWarn,
		                "Tried to load %d filter(s), %d succeeded.",
		                count, loaded);

	if (!loaded)
		cfs->filtersCount = 0;

	/* Damage currently filtered windows */
	for (w = s->windows; w; w = w->next)
	{
		FILTER_WINDOW (w);

		if (cfw->isFiltered)
			addWindowDamage (w);
	}

	return loaded;
}