mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
[clip-stack] Handle flipped rectangles in try_pushing_rect_as_window_rect()
We were ignoring the possibility that the current modelview matrix may flip the incoming rectangle in which case we didn't calculate a valid scissor rectangle for clipping. This fixes: http://bugzilla.o-hand.com/show_bug.cgi?id=1809 (Clipping doesn't work within an FBO)
This commit is contained in:
parent
bb3a008318
commit
49db9f4f77
@ -203,6 +203,15 @@ try_pushing_rect_as_window_rect (float x_offset,
|
||||
|
||||
cogl_get_modelview_matrix (&matrix);
|
||||
|
||||
/* If the modelview meets these constraints then a transformed rectangle
|
||||
* should still be a rectangle when it reaches screen coordinates.
|
||||
*
|
||||
* FIXME: we are are making certain assumptions about the projection
|
||||
* matrix a.t.m and should really be looking at the combined modelview
|
||||
* and projection matrix.
|
||||
* FIXME: we don't consider rotations that are a multiple of 90 degrees
|
||||
* which could be quite common.
|
||||
*/
|
||||
if (matrix.xy != 0 || matrix.xz != 0 ||
|
||||
matrix.yx != 0 || matrix.yz != 0 ||
|
||||
matrix.zx != 0 || matrix.zy != 0)
|
||||
@ -214,6 +223,15 @@ try_pushing_rect_as_window_rect (float x_offset,
|
||||
transform_point (&matrix, &matrix_p, v, &_x0, &_y0);
|
||||
transform_point (&matrix, &matrix_p, v, &_x1, &_y1);
|
||||
|
||||
/* Consider that the modelview matrix may flip the rectangle
|
||||
* along the x or y axis... */
|
||||
#define SWAP(A,B) do { float tmp = B; B = A; A = tmp; } while (0)
|
||||
if (_x0 > _x1)
|
||||
SWAP (_x0, _x1);
|
||||
if (_y0 > _y1)
|
||||
SWAP (_y0, _y1);
|
||||
#undef SWAP
|
||||
|
||||
cogl_clip_push_window_rect (_x0, _y0, _x1 - _x0, _y1 - _y0);
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user