mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
material: Adds simple breadcrumb debugging mechanism
Since it can sometimes be awkward to figure out where a particular material came from when debugging, this adds a breadcrumb mechanism that lets you associate a const string with a material that may give a clue about its origin.
This commit is contained in:
parent
ad0aab939d
commit
487c0b1ae9
@ -477,6 +477,11 @@ struct _CoglMaterial
|
||||
* be allocated dynamically when required... */
|
||||
CoglMaterialBigState *big_state;
|
||||
|
||||
/* For debugging purposes it's possible to associate a static const
|
||||
* string with a material which can be an aid when trying to trace
|
||||
* where the material originates from */
|
||||
const char *static_breadcrumb;
|
||||
|
||||
/* Cached state... */
|
||||
|
||||
/* A cached, complete list of the layers this material depends
|
||||
@ -519,6 +524,11 @@ struct _CoglMaterial
|
||||
unsigned int layers_cache_dirty:1;
|
||||
unsigned int deprecated_get_layers_list_dirty:1;
|
||||
|
||||
/* For debugging purposes it's possible to associate a static const
|
||||
* string with a material which can be an aid when trying to trace
|
||||
* where the material originates from */
|
||||
unsigned int has_static_breadcrumb:1;
|
||||
|
||||
/* There are multiple fragment processing backends for CoglMaterial,
|
||||
* glsl, arbfp and fixed. This identifies the backend being used for
|
||||
* the material and any private state the backend has associated
|
||||
@ -734,5 +744,9 @@ void
|
||||
_cogl_material_set_blend_enabled (CoglHandle handle,
|
||||
CoglMaterialBlendEnable enable);
|
||||
|
||||
void
|
||||
_cogl_material_set_static_breadcrumb (CoglHandle handle,
|
||||
const char *breadcrumb);
|
||||
|
||||
#endif /* __COGL_MATERIAL_PRIVATE_H */
|
||||
|
||||
|
@ -364,6 +364,9 @@ _cogl_material_init_default_material (void)
|
||||
material->big_state = big_state;
|
||||
material->has_big_state = TRUE;
|
||||
|
||||
material->static_breadcrumb = "default material";
|
||||
material->has_static_breadcrumb = TRUE;
|
||||
|
||||
/* Use the same defaults as the GL spec... */
|
||||
cogl_color_init_from_4ub (&material->color, 0xff, 0xff, 0xff, 0xff);
|
||||
|
||||
@ -456,15 +459,21 @@ cogl_material_copy (CoglHandle handle)
|
||||
material->backend = src->backend;
|
||||
material->backend_priv_set = FALSE;
|
||||
|
||||
material->has_static_breadcrumb = FALSE;
|
||||
|
||||
return _cogl_material_handle_new (material);
|
||||
}
|
||||
|
||||
CoglHandle
|
||||
cogl_material_new (void)
|
||||
{
|
||||
CoglHandle new;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||
|
||||
return cogl_material_copy (ctx->default_material);
|
||||
new = cogl_material_copy (ctx->default_material);
|
||||
_cogl_material_set_static_breadcrumb (new, "new");
|
||||
return new;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1109,6 +1118,8 @@ _cogl_material_pre_change_notify (CoglMaterial *material,
|
||||
COGL_COUNTER_INC (_cogl_uprof_context, material_copy_on_write_counter);
|
||||
|
||||
new_authority = cogl_material_copy (material->parent);
|
||||
_cogl_material_set_static_breadcrumb (new_authority,
|
||||
"pre_change_notify:copy-on-write");
|
||||
|
||||
/* We could explicitly walk the descendants, OR together the set
|
||||
* of differences that we determine this material is the
|
||||
@ -6569,3 +6580,13 @@ _cogl_material_apply_legacy_state (CoglHandle handle)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_material_set_static_breadcrumb (CoglHandle handle,
|
||||
const char *breadcrumb)
|
||||
{
|
||||
CoglMaterial *material = COGL_MATERIAL (handle);
|
||||
|
||||
material->has_static_breadcrumb = TRUE;
|
||||
material->static_breadcrumb = breadcrumb;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user