mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
clutter/stage-cogl: Add option to visualize damaged regions
This is useful to visualize which parts of the screen are being damaged. Add a new 'damage-region' value for CLUTTER_PAINT and paint the damaged regions accordingly.
This commit is contained in:
parent
e4de9ed580
commit
20b271fa49
@ -39,7 +39,8 @@ typedef enum {
|
||||
CLUTTER_DEBUG_DISABLE_CULLING = 1 << 4,
|
||||
CLUTTER_DEBUG_DISABLE_OFFSCREEN_REDIRECT = 1 << 5,
|
||||
CLUTTER_DEBUG_CONTINUOUS_REDRAW = 1 << 6,
|
||||
CLUTTER_DEBUG_PAINT_DEFORM_TILES = 1 << 7
|
||||
CLUTTER_DEBUG_PAINT_DEFORM_TILES = 1 << 7,
|
||||
CLUTTER_DEBUG_PAINT_DAMAGE_REGION = 1 << 8,
|
||||
} ClutterDrawDebugFlag;
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
|
@ -142,6 +142,7 @@ static const GDebugKey clutter_paint_debug_keys[] = {
|
||||
{ "disable-offscreen-redirect", CLUTTER_DEBUG_DISABLE_OFFSCREEN_REDIRECT },
|
||||
{ "continuous-redraw", CLUTTER_DEBUG_CONTINUOUS_REDRAW },
|
||||
{ "paint-deform-tiles", CLUTTER_DEBUG_PAINT_DEFORM_TILES },
|
||||
{ "damage-region", CLUTTER_DEBUG_PAINT_DAMAGE_REGION },
|
||||
};
|
||||
|
||||
static void
|
||||
@ -1365,6 +1366,9 @@ clutter_init_real (GError **error)
|
||||
CLUTTER_DEBUG_DISABLE_CLIPPED_REDRAWS | CLUTTER_DEBUG_DISABLE_CULLING;
|
||||
}
|
||||
|
||||
if (clutter_paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION)
|
||||
g_message ("Enabling damaged region");
|
||||
|
||||
/* this will take care of initializing Cogl's state and
|
||||
* query the GL machinery for features
|
||||
*/
|
||||
|
@ -351,6 +351,58 @@ valid_buffer_age (ClutterStageViewCogl *view_cogl,
|
||||
return age < MIN (view_priv->damage_index, DAMAGE_HISTORY_MAX);
|
||||
}
|
||||
|
||||
static void
|
||||
paint_damage_region (ClutterStageWindow *stage_window,
|
||||
ClutterStageView *view,
|
||||
cairo_rectangle_int_t *swap_region)
|
||||
{
|
||||
CoglFramebuffer *framebuffer = clutter_stage_view_get_onscreen (view);
|
||||
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
|
||||
static CoglPipeline *overlay_blue = NULL;
|
||||
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
|
||||
ClutterActor *actor = CLUTTER_ACTOR (stage_cogl->wrapper);
|
||||
float x_1 = swap_region->x;
|
||||
float x_2 = swap_region->x + swap_region->width;
|
||||
float y_1 = swap_region->y;
|
||||
float y_2 = swap_region->y + swap_region->height;
|
||||
CoglMatrix modelview;
|
||||
|
||||
if (G_UNLIKELY (overlay_blue == NULL))
|
||||
{
|
||||
overlay_blue = cogl_pipeline_new (ctx);
|
||||
cogl_pipeline_set_color4ub (overlay_blue, 0x00, 0x00, 0x33, 0x33);
|
||||
}
|
||||
|
||||
cogl_framebuffer_push_matrix (framebuffer);
|
||||
cogl_matrix_init_identity (&modelview);
|
||||
_clutter_actor_apply_modelview_transform (actor, &modelview);
|
||||
cogl_framebuffer_set_modelview_matrix (framebuffer, &modelview);
|
||||
|
||||
/* Blue for the swap region */
|
||||
cogl_framebuffer_draw_rectangle (framebuffer, overlay_blue, x_1, y_1, x_2, y_2);
|
||||
|
||||
/* Red for the clip */
|
||||
if (stage_cogl->initialized_redraw_clip)
|
||||
{
|
||||
static CoglPipeline *overlay_red = NULL;
|
||||
|
||||
if (G_UNLIKELY (overlay_red == NULL))
|
||||
{
|
||||
overlay_red = cogl_pipeline_new (ctx);
|
||||
cogl_pipeline_set_color4ub (overlay_red, 0x33, 0x00, 0x00, 0x33);
|
||||
}
|
||||
|
||||
x_1 = stage_cogl->bounding_redraw_clip.x;
|
||||
x_2 = stage_cogl->bounding_redraw_clip.x + stage_cogl->bounding_redraw_clip.width;
|
||||
y_1 = stage_cogl->bounding_redraw_clip.y;
|
||||
y_2 = stage_cogl->bounding_redraw_clip.y + stage_cogl->bounding_redraw_clip.height;
|
||||
|
||||
cogl_framebuffer_draw_rectangle (framebuffer, overlay_red, x_1, y_1, x_2, y_2);
|
||||
}
|
||||
|
||||
cogl_framebuffer_pop_matrix (framebuffer);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
swap_framebuffer (ClutterStageWindow *stage_window,
|
||||
ClutterStageView *view,
|
||||
@ -370,6 +422,9 @@ swap_framebuffer (ClutterStageWindow *stage_window,
|
||||
else
|
||||
ndamage = 0;
|
||||
|
||||
if (G_UNLIKELY ((clutter_paint_debug_flags & CLUTTER_DEBUG_PAINT_DAMAGE_REGION)))
|
||||
paint_damage_region (stage_window, view, swap_region);
|
||||
|
||||
if (cogl_is_onscreen (framebuffer))
|
||||
{
|
||||
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
|
||||
|
Loading…
Reference in New Issue
Block a user