Skip to content

cogl/clip-stack: Restore old matrices after drawing to stencil buffer

Jonas Dreßler requested to merge verdre/mutter:fix-text-clipping-issue into master

When using a region clip and something has a rectangle clip pushed, a special drawing method for ClutterTexts (emit_vertex_buffer_geometry() in cogl-pango-display-list.c) starts to fail and clipping issues with long texts (because emit_vertex_buffer_geometry() is only used for texts longer than 25 characters) start to appear. This specifically happened in Looking Glass, where the StViewport of the ScrollView sets a rectangle clips and the texts are usually longer than 25 characters.

This is caused by the changing of the perspective and modelview matrix when drawing to the stencil buffer and started happening when region-clipping was introduced with commit 8598b654. Even though the changing of the matrices was done before that, too, the issue probably didn't happen because rect->can_be_scissor was TRUE and no stencil buffer clipping was used at all.

To fix this, temporarily save the old matrices, then set the new ones and restore the old ones when we're done drawing to the stencil buffer.

Fixes gnome-shell#2246 (closed)

Merge request reports