mirror of
https://github.com/brl/mutter.git
synced 2025-01-25 19:08:56 +00:00
Clean up antialiasing fixes
Simplify the code by noting that when we have square end-caps, the results of generic line path give the right pixel-aligned rectangle for horizontal/vertical lines. Add comments and remove some extra braces. https://bugzilla.gnome.org/show_bug.cgi?id=630426
This commit is contained in:
parent
6ed34976c9
commit
4b214b4710
@ -3505,44 +3505,31 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
|
|||||||
y2 = y1;
|
y2 = y1;
|
||||||
|
|
||||||
/* This is one of the cases where we are matching the exact
|
/* This is one of the cases where we are matching the exact
|
||||||
* pixel aligned rectangle produced by X.
|
* pixel aligned rectangle produced by X; for zero-width lines
|
||||||
|
* the generic algorithm produces the right result so we don't
|
||||||
|
* need to handle them here.
|
||||||
*/
|
*/
|
||||||
if (y1 == y2 || x1 == x2)
|
if ((y1 == y2 || x1 == x2) && op->data.line.width != 0)
|
||||||
{
|
{
|
||||||
double offset = (op->data.line.width == 0 ||
|
double offset = op->data.line.width % 2 ? .5 : 0;
|
||||||
op->data.line.width % 2) ? .5 : 0;
|
|
||||||
/* X includes end points for lines of width 0 */
|
|
||||||
double line_extend = op->data.line.width == 0 ? 1. : 0.;
|
|
||||||
|
|
||||||
if (y1 == y2)
|
if (y1 == y2)
|
||||||
{
|
{
|
||||||
if (x2 < x1)
|
|
||||||
{
|
|
||||||
x1 ^= x2;
|
|
||||||
x2 ^= x1;
|
|
||||||
x1 ^= x2;
|
|
||||||
}
|
|
||||||
cairo_move_to (cr, x1, y1 + offset);
|
cairo_move_to (cr, x1, y1 + offset);
|
||||||
cairo_line_to (cr, x2 + line_extend, y2 + offset);
|
cairo_line_to (cr, x2, y2 + offset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (y2 < y1)
|
|
||||||
{
|
|
||||||
y1 ^= y2;
|
|
||||||
y2 ^= y1;
|
|
||||||
y1 ^= y2;
|
|
||||||
}
|
|
||||||
cairo_move_to (cr, x1 + offset, y1);
|
cairo_move_to (cr, x1 + offset, y1);
|
||||||
cairo_line_to (cr, x2 + offset, y2 + line_extend);
|
cairo_line_to (cr, x2 + offset, y2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (op->data.line.width <= 0)
|
/* zero-width lines include both end-points in X, unlike wide lines */
|
||||||
{
|
if (op->data.line.width == 0)
|
||||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
||||||
}
|
|
||||||
cairo_move_to (cr, x1 + .5, y1 + .5);
|
cairo_move_to (cr, x1 + .5, y1 + .5);
|
||||||
cairo_line_to (cr, x2 + .5, y2 + .5);
|
cairo_line_to (cr, x2 + .5, y2 + .5);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user