1
0
Fork 0

clutter-stage-cogl: Use CoglPrimitive for the debug redraw code

CoglVertexBuffer is deprecated so here is a fairly simple replacement
to use the experimental CoglPrimitive API.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
This commit is contained in:
Neil Roberts 2012-04-20 17:11:47 +01:00
parent 032870dccc
commit 107f43a838

View file

@ -408,22 +408,22 @@ clutter_stage_cogl_redraw (ClutterStageWindow *stage_window)
if (may_use_clipped_redraw && if (may_use_clipped_redraw &&
G_UNLIKELY ((clutter_paint_debug_flags & CLUTTER_DEBUG_REDRAWS))) G_UNLIKELY ((clutter_paint_debug_flags & CLUTTER_DEBUG_REDRAWS)))
{ {
CoglContext *ctx = CoglFramebuffer *fb = COGL_FRAMEBUFFER (stage_cogl->onscreen);
clutter_backend_get_cogl_context (clutter_get_default_backend ()); CoglContext *ctx = cogl_framebuffer_get_context (fb);
static CoglPipeline *outline = NULL; static CoglPipeline *outline = NULL;
cairo_rectangle_int_t *clip = &stage_cogl->bounding_redraw_clip; cairo_rectangle_int_t *clip = &stage_cogl->bounding_redraw_clip;
ClutterActor *actor = CLUTTER_ACTOR (wrapper); ClutterActor *actor = CLUTTER_ACTOR (wrapper);
CoglHandle vbo;
float x_1 = clip->x; float x_1 = clip->x;
float x_2 = clip->x + clip->width; float x_2 = clip->x + clip->width;
float y_1 = clip->y; float y_1 = clip->y;
float y_2 = clip->y + clip->height; float y_2 = clip->y + clip->height;
float quad[8] = { CoglVertexP2 quad[4] = {
x_1, y_1, { x_1, y_1 },
x_2, y_1, { x_2, y_1 },
x_2, y_2, { x_2, y_2 },
x_1, y_2 { x_1, y_2 }
}; };
CoglPrimitive *prim;
CoglMatrix modelview; CoglMatrix modelview;
if (outline == NULL) if (outline == NULL)
@ -432,25 +432,20 @@ clutter_stage_cogl_redraw (ClutterStageWindow *stage_window)
cogl_pipeline_set_color4ub (outline, 0xff, 0x00, 0x00, 0xff); cogl_pipeline_set_color4ub (outline, 0xff, 0x00, 0x00, 0xff);
} }
vbo = cogl_vertex_buffer_new (4); prim = cogl_primitive_new_p2 (ctx,
cogl_vertex_buffer_add (vbo, COGL_VERTICES_MODE_LINE_LOOP,
"gl_Vertex", 4, /* n_vertices */
2, /* n_components */ quad);
COGL_ATTRIBUTE_TYPE_FLOAT,
FALSE, /* normalized */
0, /* stride */
quad);
cogl_vertex_buffer_submit (vbo);
cogl_push_matrix (); cogl_framebuffer_push_matrix (fb);
cogl_matrix_init_identity (&modelview); cogl_matrix_init_identity (&modelview);
_clutter_actor_apply_modelview_transform (actor, &modelview); _clutter_actor_apply_modelview_transform (actor, &modelview);
cogl_set_modelview_matrix (&modelview); cogl_framebuffer_set_modelview_matrix (fb, &modelview);
cogl_set_source (outline); cogl_framebuffer_draw_primitive (COGL_FRAMEBUFFER (stage_cogl->onscreen),
cogl_vertex_buffer_draw (vbo, COGL_VERTICES_MODE_LINE_LOOP, outline,
0 , 4); prim);
cogl_pop_matrix (); cogl_framebuffer_pop_matrix (fb);
cogl_object_unref (vbo); cogl_object_unref (prim);
} }
CLUTTER_TIMER_STOP (_clutter_uprof_context, painting_timer); CLUTTER_TIMER_STOP (_clutter_uprof_context, painting_timer);