[picking] Use cogl_clip_push_window_rect to greatly reduce the cost of picking.
cogl_clip_push_window_rect is implemented using GPU scissoring which allows the GPU to cull anything that falls outside a given rectangle. Since in the case of picking we only ever care about a single pixel we can get the GPU to ignore all geometry that doesn't intersect that pixel and only rasterize for one pixel.
This commit is contained in:
parent
e80fcbc298
commit
d1fa83039d
@ -370,6 +370,7 @@ _clutter_do_pick (ClutterStage *stage,
|
|||||||
/* needed for when a context switch happens */
|
/* needed for when a context switch happens */
|
||||||
_clutter_stage_maybe_setup_viewport (stage);
|
_clutter_stage_maybe_setup_viewport (stage);
|
||||||
|
|
||||||
|
cogl_clip_push_window_rect (x, y, 1, 1);
|
||||||
cogl_color_set_from_4ub (&white, 255, 255, 255, 255);
|
cogl_color_set_from_4ub (&white, 255, 255, 255, 255);
|
||||||
cogl_disable_fog ();
|
cogl_disable_fog ();
|
||||||
cogl_clear (&white,
|
cogl_clear (&white,
|
||||||
@ -387,6 +388,7 @@ _clutter_do_pick (ClutterStage *stage,
|
|||||||
context->pick_mode = mode;
|
context->pick_mode = mode;
|
||||||
clutter_actor_paint (CLUTTER_ACTOR (stage));
|
clutter_actor_paint (CLUTTER_ACTOR (stage));
|
||||||
context->pick_mode = CLUTTER_PICK_NONE;
|
context->pick_mode = CLUTTER_PICK_NONE;
|
||||||
|
cogl_clip_pop ();
|
||||||
|
|
||||||
/* Calls should work under both GL and GLES, note GLES needs RGBA */
|
/* Calls should work under both GL and GLES, note GLES needs RGBA */
|
||||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user